collabmd 0.1.52 → 0.1.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/collabmd.js +3 -2
- package/dist/client/assets/{CodeMirrorEditor-UCMRAMCV-BEz2BKN1.js → CodeMirrorEditor-UCMRAMCV-kJfwukbn.js} +1 -1
- package/dist/client/assets/{browser-BKLM0ThC-IxjwuOIz-C0mP17s1.js → browser-BKLM0ThC-BCLQGPD6-K2seJgRL.js} +1 -1
- package/dist/client/assets/{browser-utils-vlHL9goC.js → browser-utils-S4QYY31r.js} +1 -1
- package/dist/client/assets/{chunk-RUX4WMZV-BGnd3s_C.js → chunk-ISPTBLVO-BMsDq9Ha.js} +2 -2
- package/dist/client/assets/{chunk-4SOEAONT-C3fufoVl.js → chunk-T5WUORNS-DD7KlyY6.js} +9 -9
- package/dist/client/assets/{direct-engine-DdrQKpgq-4QysbH_V.js → direct-engine-DVLMOJWp-C-YL5NFb.js} +1 -1
- package/dist/client/assets/{dist-CXOUa90Q.js → dist-9Eodxf4G.js} +1 -1
- package/dist/client/assets/{dist-jVKfryIL.js → dist-B2ZNQifU.js} +1 -1
- package/dist/client/assets/dist-B6QCMNze.js +1 -0
- package/dist/client/assets/dist-BIAv19LO.js +1 -0
- package/dist/client/assets/{dist-Bog8M5U3.js → dist-BKYp1-dl.js} +4 -4
- package/dist/client/assets/{dist-DI6c02Da.js → dist-BSAZ-Hek.js} +1 -1
- package/dist/client/assets/{dist-DNONgI1P.js → dist-BSTbcioM.js} +1 -1
- package/dist/client/assets/{dist-BfpAc922.js → dist-BT9gJXCb.js} +1 -1
- package/dist/client/assets/{dist-CAG5sIOj.js → dist-BTVg1m-V.js} +1 -1
- package/dist/client/assets/{dist-GTGhtpyW.js → dist-Bi9ZIYXq.js} +1 -1
- package/dist/client/assets/{dist-CvVoyTRF.js → dist-BpAUe9sL.js} +1 -1
- package/dist/client/assets/{dist-B7fBbwrO.js → dist-Bqo-XRVG.js} +1 -1
- package/dist/client/assets/{dist-CUsXdnU4.js → dist-BrKhPlc9.js} +1 -1
- package/dist/client/assets/{dist-CYMCikZo.js → dist-CBsvKPcT.js} +1 -1
- package/dist/client/assets/{dist-W0FoeIxk.js → dist-CJBYh9Wy.js} +1 -1
- package/dist/client/assets/{dist-Ck-B8onw.js → dist-CRwfjtwz.js} +1 -1
- package/dist/client/assets/{dist-Dx37MHWs.js → dist-CX7Kc61C.js} +1 -1
- package/dist/client/assets/{dist-zHDLm1oE.js → dist-CoXN2D3R.js} +1 -1
- package/dist/client/assets/{dist-D4kDR0g8.js → dist-CucpLxUY.js} +1 -1
- package/dist/client/assets/{dist-Cu5Ze2cs.js → dist-DHBMeCxC.js} +1 -1
- package/dist/client/assets/dist-DLEg9d4u.js +1 -0
- package/dist/client/assets/{dist-Y6zYRI-A.js → dist-DOHWxIty.js} +1 -1
- package/dist/client/assets/{dist-DVBYH83t.js → dist-DYFBD-wW.js} +1 -1
- package/dist/client/assets/{dist-CsQTfQFi.js → dist-DeCV9FU4.js} +1 -1
- package/dist/client/assets/dist-DugWGOjQ.js +1 -0
- package/dist/client/assets/{dist-BVCNc-Es.js → dist-KrdpB_GB.js} +1 -1
- package/dist/client/assets/{dist-B_1hMrc6.js → dist-NNrRnB-f.js} +1 -1
- package/dist/client/assets/{dist-Da-jLrCf.js → dist-PUxZqhFe.js} +1 -1
- package/dist/client/assets/dist-cYiJMWHJ.js +1 -0
- package/dist/client/assets/dist-iKC7go4m.js +1 -0
- package/dist/client/assets/{dist-CKf7LlAo.js → dist-lw5TGjI6.js} +1 -1
- package/dist/client/assets/{dist-DGa-2MNX.js → dist-uk11ih8u.js} +1 -1
- package/dist/client/assets/{document-formatter-gO8qM2qY.js → document-formatter-6I63vstk.js} +1 -1
- package/dist/client/assets/{drawioEditor-DCkWweiy.js → drawioEditor-DNTjsjzJ.js} +1 -1
- package/dist/client/assets/{editor-session-DxRyr4EM.js → editor-session-D8GGkJak.js} +3 -3
- package/dist/client/assets/{embedpdf-DyOonRvx.js → embedpdf-TkbBYowM.js} +1 -1
- package/dist/client/assets/{embedpdf-DA4bA119-DsoNiPlQ.js → embedpdf-cl9qiF45-itpgqvGY.js} +2 -2
- package/dist/client/assets/{en-GNC3RJIS-CEy_oGTd.js → en-JTHJ2SIP-DBz9bRq4.js} +1 -1
- package/dist/client/assets/{estree-DCT3Jm65.js → estree-DGmLqopC.js} +17 -17
- package/dist/client/assets/{excalidraw-element-link-CGZ5934B.js → excalidraw-element-link-BRZOTIeI.js} +2 -2
- package/dist/client/assets/{excalidrawEditor-BVfSxjSO.js → excalidrawEditor-D0orhhku.js} +3 -3
- package/dist/client/assets/{export-page-BCo_e15t.js → export-page-CVJNMERq.js} +3 -3
- package/dist/client/assets/{exportDocument-DP6oE_or.js → exportDocument-DSshnmnZ.js} +2 -2
- package/dist/client/assets/{file-search-3hYF4cYa.js → file-search-BA8o_gs0.js} +1 -1
- package/dist/client/assets/{html-CBXMuS97.js → html-BryNQ_yx.js} +6 -6
- package/dist/client/assets/image-I42VHMUI-B2-c_ifV.js +1 -0
- package/dist/client/assets/index-BCgNcVNs.css +1 -0
- package/dist/client/assets/index-BpmR5Qqk.js +1140 -0
- package/dist/client/assets/{lobby-presence-Cz5jGOPg.js → lobby-presence-KJrYhMdN.js} +1 -1
- package/dist/client/assets/{markdown-Bo71X2X2.js → markdown-CZ1tYEW8.js} +17 -17
- package/dist/client/assets/{pdfium-RAgkpwfK.wasm → pdfium-BJ2Yip8Q.wasm} +0 -0
- package/dist/client/assets/{preview-render-compiler-ktU0SXxY.js → preview-render-compiler-BmWQStaL.js} +1 -1
- package/dist/client/assets/{preview-render-worker-BI2bFVqM.js → preview-render-worker-BA4VK_GY.js} +2 -2
- package/dist/client/assets/prod-CA0ie9yD.js +145 -0
- package/dist/client/assets/prod-yKJZ3E4s.js +1 -0
- package/dist/client/assets/{quick-switcher-controller-DSlOwOsU.js → quick-switcher-controller-B5vT9Vj5.js} +1 -1
- package/dist/client/assets/runtime-config-CvrkHb0n.js +1 -0
- package/dist/client/assets/runtime-paths-qQGhzNx4.js +1 -0
- package/dist/client/assets/{standalone-6z5x8CWe.js → standalone-DbyFjvTU.js} +1 -1
- package/dist/client/assets/{vault-api-client-BQxLVPeF.js → vault-api-client-NS_EVHJ3.js} +2 -2
- package/dist/client/assets/{worker-engine-m0rlHn8R-5h66k403.js → worker-engine-BCCrxWYm-CX0qJ_cG.js} +1 -1
- package/dist/client/assets/{workspace-sync-client-C2pdaQUN.js → workspace-sync-client-BrMtf6zN.js} +1 -1
- package/dist/client/drawio-editor.html +5 -5
- package/dist/client/excalidraw-editor.html +9 -9
- package/dist/client/export-document.html +1 -1
- package/dist/client/index.html +13 -2
- package/package.json +14 -14
- package/src/client/app/index.html +11 -0
- package/src/client/app/main-entry.js +30 -4
- package/src/client/bootstrap/collabmd-app-shell.js +3 -1
- package/src/client/browser-utils.js +21 -0
- package/src/client/domain/file-search.js +1 -1
- package/src/client/domain/runtime-paths.js +4 -0
- package/src/client/infrastructure/runtime-config.js +14 -0
- package/src/client/presentation/drawio-embed-controller.js +3 -1
- package/src/client/presentation/excalidraw-embed-controller.js +3 -1
- package/src/client/presentation/file-action-controller.js +21 -1
- package/src/client/presentation/file-explorer-view.js +24 -6
- package/src/client/presentation/vault-dashboard.js +63 -0
- package/src/client/styles/foundation/utilities.css +2 -0
- package/src/client/styles/layout/overlays.css +5 -0
- package/src/client/styles/layout/shell.css +152 -0
- package/src/server/config/env.js +39 -6
- package/src/server/infrastructure/http/create-static-handler.js +3 -1
- package/src/server/infrastructure/http/create-vault-api-query-handler.js +1 -1
- package/dist/client/assets/dist-BYBF4LtZ.js +0 -1
- package/dist/client/assets/dist-BnVaoRgZ.js +0 -1
- package/dist/client/assets/dist-CrkYYcOU.js +0 -1
- package/dist/client/assets/dist-D8LnhZzy.js +0 -1
- package/dist/client/assets/dist-DX6qtdxv.js +0 -1
- package/dist/client/assets/dist-DofvCYzJ.js +0 -1
- package/dist/client/assets/image-EJJKRVD3-BQfi5nWJ.js +0 -1
- package/dist/client/assets/index-BxAuGDoN.css +0 -1
- package/dist/client/assets/index-uw9O0z1c.js +0 -1112
- package/dist/client/assets/prod-DU-0VfI7.js +0 -145
- package/dist/client/assets/prod-cXUNdmYV.js +0 -1
- package/dist/client/assets/runtime-config-BFVdhnJu.js +0 -1
- package/dist/client/assets/runtime-paths-Cn0snt_9.js +0 -1
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import{i as e,t}from"./rolldown-runtime-Dd_uD5pT.js";import{t as n}from"./preload-helper-BAlEavIC.js";import{n as r,t as i}from"./jsx-runtime-DKj5X9O4.js";import{$ as a,$a as o,$c as s,$i as c,$l as l,$n as u,$o as d,$r as f,$s as p,$t as m,A as h,Aa as g,Ac as _,Ai as v,Al as y,An as b,Ao as x,Ar as S,As as C,At as w,Ba as T,Bc as E,Bi as D,Bl as ee,Bn as te,Bo as O,Br as k,Bs as A,Bt as ne,C as re,Ca as ie,Cc as ae,Ci as oe,Cl as se,Cn as ce,Co as le,Cr as ue,Cs as de,Ct as j,D as fe,Da as pe,Dc as me,Di as he,Dl as ge,Dn as _e,Do as ve,Dr as ye,Ds as be,Dt as xe,E as Se,Ea as Ce,Ec as we,Ei as Te,El as Ee,En as De,Eo as Oe,Er as ke,Es as Ae,Et as je,F as Me,Fa as Ne,Fc as Pe,Fi as Fe,Fl as Ie,Fn as Le,Fo as Re,Fr as ze,Fs as M,G as Be,Ga as Ve,Gc as He,Gi as Ue,Gl as We,Gn as Ge,Go as Ke,Gr as qe,Gs as Je,Gt as Ye,Ha as Xe,Hc as Ze,Hi as Qe,Hl as $e,Hn as et,Ho as tt,Hr as nt,Hs as rt,Ht as it,I as at,Ia as ot,Ic as st,Ii as ct,Il as lt,In as ut,Io as dt,Ir as ft,Is as pt,It as mt,J as ht,Ja as gt,Jc as _t,Ji as vt,Jl as yt,Jn as bt,Jo as xt,Jr as St,Js as Ct,Jt as wt,K as Tt,Ka as Et,Kc as Dt,Ki as Ot,Kl as kt,Kn as At,Ko as jt,Kr as Mt,Ks as Nt,Kt as Pt,L as Ft,La as It,Lc as Lt,Li as Rt,Ll as zt,Ln as Bt,Lo as Vt,Lr as Ht,Ls as Ut,Lt as Wt,M as Gt,Ma as Kt,Mc as qt,Mi as Jt,Ml as Yt,Mn as Xt,Mo as Zt,Mr as Qt,Ms as $t,Mt as en,N as tn,Na as nn,Nc as rn,Ni as an,Nl as on,Nn as sn,No as cn,Nr as ln,Ns as un,Nt as dn,O as fn,Oa as N,Oc as pn,Oi as mn,Ol as hn,On as gn,Oo as _n,Or as vn,Os as yn,Ot as bn,P as xn,Pa as Sn,Pc as Cn,Pi as wn,Pl as Tn,Pn as En,Po as P,Pr as Dn,Ps as On,Pt as kn,Q as An,Qa as jn,Qc as Mn,Qi as Nn,Ql as F,Qn as Pn,Qo as Fn,Qr as In,Qs as Ln,R as Rn,Ra as zn,Rc as Bn,Ri as Vn,Rl as Hn,Rn as Un,Ro as Wn,Rr as Gn,Rs as Kn,Rt as qn,S as Jn,Sa as Yn,Sc as Xn,Si as Zn,Sl as Qn,Sn as $n,So as er,Sr as tr,Ss as nr,St as rr,T as ir,Ta as ar,Tc as or,Ti as sr,Tl as cr,Tn as lr,To as ur,Tr as dr,Ts as fr,Tt as pr,U as mr,Ua as hr,Uc as gr,Ui as _r,Ul as vr,Un as yr,Uo as br,Ur as xr,Us as Sr,Ut as Cr,V as wr,Va as Tr,Vi as Er,Vl as Dr,Vn as Or,Vo as kr,Vr as Ar,Vs as jr,Vt as Mr,W as Nr,Wa as Pr,Wc as Fr,Wi as Ir,Wl as Lr,Wn as Rr,Wo as zr,Wr as Br,Ws as Vr,Wt as Hr,X as Ur,Xa as Wr,Xc as Gr,Xi as Kr,Xl as qr,Xn as Jr,Xo as Yr,Xr,Xs as Zr,Xt as Qr,Ya as $r,Yc as ei,Yi as ti,Yl as ni,Yn as ri,Yo as ii,Yr as ai,Ys as oi,Yt as si,Z as ci,Za as li,Zc as ui,Zi as di,Zl as fi,Zn as pi,Zo as mi,Zr as hi,Zs as gi,Zt as _i,_ as vi,_a as yi,_c as bi,_i as xi,_l as Si,_n as Ci,_o as wi,_r as Ti,_s as Ei,_t as Di,a as Oi,aa as ki,ac as Ai,ai as ji,al as Mi,an as Ni,ar as Pi,as as Fi,at as Ii,b as Li,ba as Ri,bc as zi,bi as Bi,bl as Vi,bn as Hi,bo as Ui,br as Wi,bs as Gi,bt as Ki,c as qi,ca as Ji,cc as Yi,ci as Xi,cl as Zi,cn as Qi,co as $i,cr as ea,cs as ta,ct as na,d as ra,da as ia,dc as aa,di as oa,dl as sa,dn as ca,do as la,dr as ua,ds as da,dt as fa,ea as pa,ec as ma,ei as ha,el as ga,en as _a,eo as va,er as ya,et as ba,eu as xa,f as Sa,fa as Ca,fc as wa,fi as Ta,fl as Ea,fn as Da,fo as Oa,fr as I,fs as L,ft as ka,g as Aa,ga as ja,gc as Ma,gi as Na,gl as Pa,gn as Fa,go as Ia,gr as La,gs as Ra,gt as za,h as Ba,ha as Va,hc as Ha,hi as Ua,hl as Wa,hn as Ga,ho as Ka,hr as qa,hs as Ja,ht as Ya,i as Xa,ia as Za,ic as Qa,ii as $a,il as eo,in as to,io as no,ir as ro,is as io,it as ao,j as oo,ja as so,jc as co,ji as lo,jl as uo,jn as fo,jo as po,jr as mo,js as ho,jt as go,k as _o,ka as R,kc as vo,ki as yo,kl as bo,kn as xo,ko as So,kr as Co,ks as wo,kt as To,l as Eo,la as Do,lc as Oo,li as ko,ll as Ao,ln as jo,lo as Mo,lr as No,ls as Po,lt as Fo,m as Io,ma as Lo,mc as Ro,mi as zo,ml as Bo,mn as Vo,mo as Ho,mr as Uo,ms as Wo,mt as Go,n as Ko,na as qo,nc as Jo,ni as Yo,nl as Xo,nn as Zo,no as Qo,nr as $o,ns as es,nt as ts,o as ns,oa as rs,oc as is,oi as as,ol as os,on as ss,oo as cs,or as ls,os as us,ot as ds,p as fs,pa as ps,pc as ms,pi as hs,pl as gs,pn as _s,po as vs,pr as ys,ps as bs,pt as xs,q as Ss,qa as Cs,qc as ws,qi as Ts,ql as Es,qn as Ds,qo as Os,qr as ks,qt as As,r as js,ra as z,rc as Ms,ri as Ns,rl as Ps,rn as Fs,ro as Is,rr as Ls,rs as Rs,rt as zs,sa as Bs,sc as Vs,si as Hs,sl as Us,sn as Ws,so as Gs,sr as Ks,ss as qs,st as Js,t as Ys,ta as Xs,tc as Zs,ti as Qs,tl as $s,tn as ec,to as tc,tr as nc,ts as rc,tt as ic,u as ac,ua as oc,uc as sc,ui as cc,ul as lc,un as uc,uo as dc,ur as fc,us as pc,ut as mc,v as hc,va as gc,vc as _c,vi as vc,vl as yc,vn as bc,vo as xc,vr as Sc,vs as Cc,vt as wc,wa as Tc,wc as Ec,wi as Dc,wl as Oc,wn as kc,wo as Ac,wr as jc,ws as B,wt as Mc,x as Nc,xa as Pc,xc as Fc,xi as Ic,xl as Lc,xn as Rc,xo as zc,xr as Bc,xs as Vc,xt as Hc,y as Uc,ya as Wc,yc as Gc,yi as Kc,yl as qc,yn as Jc,yo as Yc,yr as Xc,ys as Zc,yt as Qc,z as $c,za as el,zc as tl,zi as nl,zl as rl,zn as il,zo as al,zr as ol,zt as sl}from"./chunk-T5WUORNS-DD7KlyY6.js";import{i as V,n as cl,r as ll}from"./chunk-SRAX5OIU-KFQikY-4.js";import{v as ul}from"./chunk-ISPTBLVO-BMsDq9Ha.js";import{r as dl}from"./chunk-DYU5D34O-DN0WQZBm.js";import{t as fl}from"./dist-Ch6Sr9KF.js";var pl=t((e=>{var t=r();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;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.`}function i(){}var a={d:{f:i,r:function(){throw Error(n(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},o=Symbol.for(`react.portal`),s=Symbol.for(`react.recoverable`),c=Symbol.for(`react.optimistic_key`);function l(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:r===c?c:``+r,children:e,containerInfo:t,implementation:n}}var u=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,e.browser=function(e){return{$$typeof:s,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return l(e,t,null,r)},e.flushSync=function(e){var t=u.T,n=a.p;try{if(u.T=null,a.p=2,e)return e()}finally{u.T=t,a.p=n,a.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,a.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=d(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??a.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin);a.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=d(t.as,t.crossOrigin);a.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else a.d.m(e)}},e.requestFormReset=function(e){a.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return u.H.useFormState(e,t,n)},e.useFormStatus=function(){return u.H.useHostTransitionStatus()},e.version=`19.3.0`})),ml=t(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=pl()})),H=e(r(),1),hl=e(ml(),1);function gl(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=gl(e[t]))&&(r&&(r+=` `),r+=n);else for(t in e)e[t]&&(r&&(r+=` `),r+=t)}return r}function U(){for(var e=0,t,n,r=``;e<arguments.length;)(t=arguments[e++])&&(n=gl(t))&&(r&&(r+=` `),r+=n);return r}var _l=e(t(((e,t)=>{var n=`Expected a function`,r=NaN,i=/^\s+|\s+$/g,a=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,s=/^0o[0-7]+$/i,c=parseInt,l=typeof global==`object`&&global&&global.Object===Object&&global,u=typeof self==`object`&&self&&self.Object===Object&&self,d=l||u||Function(`return this`)(),f=Object.prototype.toString,p=Math.max,m=Math.min,h=function(){return d.Date.now()};function g(e,t,r){var i,a,o,s,c,l,u=0,d=!1,f=!1,g=!0;if(typeof e!=`function`)throw TypeError(n);t=x(t)||0,v(r)&&(d=!!r.leading,f=`maxWait`in r,o=f?p(x(r.maxWait)||0,t):o,g=`trailing`in r?!!r.trailing:g);function _(t){var n=i,r=a;return i=a=void 0,u=t,s=e.apply(r,n),s}function y(e){return u=e,c=setTimeout(C,t),d?_(e):s}function b(e){var n=e-l,r=e-u,i=t-n;return f?m(i,o-r):i}function S(e){var n=e-l,r=e-u;return l===void 0||n>=t||n<0||f&&r>=o}function C(){var e=h();if(S(e))return w(e);c=setTimeout(C,b(e))}function w(e){return c=void 0,g&&i?_(e):(i=a=void 0,s)}function T(){c!==void 0&&clearTimeout(c),u=0,i=l=a=c=void 0}function E(){return c===void 0?s:w(h())}function D(){var e=h(),n=S(e);if(i=arguments,a=this,l=e,n){if(c===void 0)return y(l);if(f)return c=setTimeout(C,t),_(l)}return c===void 0&&(c=setTimeout(C,t)),s}return D.cancel=T,D.flush=E,D}function _(e,t,r){var i=!0,a=!0;if(typeof e!=`function`)throw TypeError(n);return v(r)&&(i=`leading`in r?!!r.leading:i,a=`trailing`in r?!!r.trailing:a),g(e,t,{leading:i,maxWait:t,trailing:a})}function v(e){var t=typeof e;return!!e&&(t==`object`||t==`function`)}function y(e){return!!e&&typeof e==`object`}function b(e){return typeof e==`symbol`||y(e)&&f.call(e)==`[object Symbol]`}function x(e){if(typeof e==`number`)return e;if(b(e))return r;if(v(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=v(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=e.replace(i,``);var n=o.test(e);return n||s.test(e)?c(e.slice(2),n?2:8):a.test(e)?r:+e}t.exports=_}))(),1),vl=0;function yl(e,t){let n=`atom${++vl}`,r={toString(){return n}};return typeof e==`function`?r.read=e:(r.init=e,r.read=bl,r.write=xl),t&&(r.write=t),r}function bl(e){return e(this)}function xl(e,t,n){return t(this,typeof n==`function`?n(e(this)):n)}var Sl=(e,t)=>e.unstable_is?e.unstable_is(t):t===e,Cl=e=>`init`in e,wl=e=>!!e.write,Tl=new WeakMap,El=e=>kl(e)&&!Tl.get(e)?.[1],Dl=(e,t)=>{let n=Tl.get(e);n&&(n[1]=!0,n[0].forEach(e=>e(t)))},Ol=e=>{if(Tl.has(e))return;let t=[new Set,!1];Tl.set(e,t);let n=()=>{t[1]=!0};e.then(n,n),e.onCancel=e=>{t[0].add(e)}},kl=e=>typeof e?.then==`function`,Al=e=>`v`in e||`e`in e,jl=e=>{if(`e`in e)throw e.e;return e.v},Ml=(e,t,n)=>{n.p.has(e)||(n.p.add(e),t.then(()=>{n.p.delete(e)},()=>{n.p.delete(e)}))},Nl=(e,t,n,r,i)=>{var a;n.d.set(r,i.n),El(n.v)&&Ml(t,n.v,i),(a=i.m)==null||a.t.add(t),e&&Ll(e,r,t)},Pl=()=>({D:new Map,H:new Set,M:new Set,L:new Set}),Fl=(e,t,n)=>{e[t].add(n)},Il=(e,t,n)=>{e.D.has(t)||(e.D.set(t,new Set),Fl(e,`M`,()=>{var t;(t=n.m)==null||t.l.forEach(t=>Fl(e,`M`,t))}))},Ll=(e,t,n)=>{let r=e.D.get(t);r&&r.add(n)},Rl=(e,t)=>e.D.get(t),zl=e=>{let t,n=!1,r=e=>{try{e()}catch(e){n||=(t=e,!0)}};for(;e.H.size||e.M.size||e.L.size;)e.D.clear(),e.H.forEach(r),e.H.clear(),e.M.forEach(r),e.M.clear(),e.L.forEach(r),e.L.clear();if(n)throw t},Bl=(...[e,t,n,r])=>{let i=(t,n,r)=>{let i=`v`in n,a=n.v,o=El(n.v)?n.v:null;if(kl(r)){Ol(r);for(let i of n.d.keys())Ml(t,r,e(i));n.v=r}else n.v=r;delete n.e,delete n.x,(!i||!Object.is(a,n.v))&&(++n.n,o&&Dl(o,r))},a=(n,r)=>{var o;let s=e(r);if(Al(s)&&(s.m&&!s.x||Array.from(s.d).every(([e,t])=>a(n,e).n===t)))return s;s.d.clear();let c=!0,l=t=>{if(Sl(r,t)){let n=e(t);if(!Al(n)){if(Cl(t))i(t,n,t.init);else throw Error(`no atom init`)}return jl(n)}let o=a(n,t);try{return jl(o)}finally{if(c)Nl(n,r,s,t,o);else{let e=Pl();Nl(e,r,s,t,o),d(e,r,s),zl(e)}}},f,p,m={get signal(){return f||=new AbortController,f.signal},get setSelf(){return!p&&wl(r)&&(p=(...e)=>{if(!c)return u(r,...e)}),p}};try{let e=t(r,l,m);if(i(r,s,e),kl(e)){(o=e.onCancel)==null||o.call(e,()=>f?.abort());let t=()=>{if(s.m){let e=Pl();d(e,r,s),zl(e)}};e.then(t,t)}return s}catch(e){return delete s.v,s.e=e,delete s.x,++s.n,s}finally{c=!1}},o=e=>jl(a(void 0,e)),s=(t,n,r)=>{var i;let a=new Map;for(let t of r.m?.t||[]){let n=e(t);n.m&&a.set(t,n)}for(let t of r.p)a.set(t,e(t));return(i=Rl(t,n))==null||i.forEach(t=>{a.set(t,e(t))}),a},c=(e,t,n)=>{let r=[],i=new Set,o=new Set,c=[[t,n]];for(;c.length>0;){let[t,n]=c[c.length-1];if(o.has(t)){c.pop();continue}if(i.has(t)){r.push([t,n,n.n]),o.add(t),n.x=!0,c.pop();continue}i.add(t);for(let[r,a]of s(e,t,n))t!==r&&!i.has(r)&&c.push([r,a])}Fl(e,`H`,()=>{let n=new Set([t]);for(let t=r.length-1;t>=0;--t){let[i,o,s]=r[t],c=!1;for(let e of o.d.keys())if(e!==i&&n.has(e)){c=!0;break}c&&(a(e,i),d(e,i,o),s!==o.n&&(Il(e,i,o),n.add(i))),delete o.x}})},l=(t,r,...o)=>{let s=!0,u=e=>jl(a(t,e)),f=(n,...a)=>{let o=e(n);try{if(Sl(r,n)){if(!Cl(n))throw Error(`atom not writable`);let e=o.n,r=a[0];i(n,o,r),d(t,n,o),e!==o.n&&(Il(t,n,o),c(t,n,o));return}return l(t,n,...a)}finally{s||zl(t)}};try{return n(r,u,f,...o)}finally{s=!1}},u=(e,...t)=>{let n=Pl();try{return l(n,e,...t)}finally{zl(n)}},d=(t,n,r)=>{if(r.m&&!El(r.v)){for(let i of r.d.keys())r.m.d.has(i)||(f(t,i,e(i)).t.add(n),r.m.d.add(i));for(let i of r.m.d||[])r.d.has(i)||(r.m.d.delete(i),p(t,i,e(i))?.t.delete(n))}},f=(t,n,i)=>{if(!i.m){a(t,n);for(let r of i.d.keys())f(t,r,e(r)).t.add(n);if(i.m={l:new Set,d:new Set(i.d.keys()),t:new Set},wl(n)){let e=i.m,a,o=(e,t)=>{let r=!0;a=(...t)=>{try{return l(e,n,...t)}finally{r||zl(e)}};try{return t()}finally{r=!1}};Fl(t,`L`,()=>{let i=o(t,()=>r(n,(...e)=>a(...e)));i&&(e.u=e=>o(e,i))})}}return i.m},p=(t,n,r)=>{if(r.m&&!r.m.l.size&&!Array.from(r.m.t).some(t=>e(t).m?.d.has(n))){let i=r.m.u;i&&Fl(t,`L`,()=>i(t)),delete r.m;for(let i of r.d.keys())p(t,i,e(i))?.t.delete(n);return}return r.m};return{get:o,set:u,sub:(t,n)=>{let r=Pl(),i=e(t),a=f(r,t,i).l;return a.add(n),zl(r),()=>{a.delete(n);let e=Pl();p(e,t,i),zl(e)}},unstable_derive:i=>Bl(...i(e,t,n,r))}},Vl=()=>{let e=new WeakMap;return Bl(t=>{let n=e.get(t);return n||(n={d:new Map,p:new Set,n:0},e.set(t,n)),n},(e,...t)=>e.read(...t),(e,...t)=>e.write(...t),(e,...t)=>e.onMount?.call(e,...t))},Hl,Ul=()=>(Hl||=Vl(),Hl),Wl=(0,H.createContext)(void 0),Gl=e=>{let t=(0,H.useContext)(Wl);return e?.store||t||Ul()},Kl=e=>typeof e?.then==`function`,ql=e=>{e.status=`pending`,e.then(t=>{e.status=`fulfilled`,e.value=t},t=>{e.status=`rejected`,e.reason=t})},Jl=H.use||(e=>{if(e.status===`pending`)throw e;if(e.status===`fulfilled`)return e.value;throw e.status===`rejected`?e.reason:(ql(e),e)}),Yl=new WeakMap,Xl=e=>{let t=Yl.get(e);return t||(t=new Promise((n,r)=>{let i=e,a=e=>t=>{i===e&&n(t)},o=e=>t=>{i===e&&r(t)},s=e=>{`onCancel`in e&&typeof e.onCancel==`function`&&e.onCancel(e=>{Kl(e)?(Yl.set(e,t),i=e,e.then(a(e),o(e)),s(e)):n(e)})};e.then(a(e),o(e)),s(e)}),Yl.set(e,t)),t};function Zl(e,t){let n=Gl(t),[[r,i,a],o]=(0,H.useReducer)(t=>{let r=n.get(e);return Object.is(t[0],r)&&t[1]===n&&t[2]===e?t:[r,n,e]},void 0,()=>[n.get(e),n,e]),s=r;(i!==n||a!==e)&&(o(),s=n.get(e));let c=t?.delay;return(0,H.useEffect)(()=>{let t=n.sub(e,()=>{if(typeof c==`number`){let t=n.get(e);Kl(t)&&ql(Xl(t)),setTimeout(o,c);return}o()});return o(),t},[n,e,c]),(0,H.useDebugValue)(s),Kl(s)?Jl(Xl(s)):s}function Ql(e,t){let n=Gl(t);return(0,H.useCallback)((...t)=>n.set(e,...t),[n,e])}function $l(e,t){return[Zl(e,t),Ql(e,t)]}var W=i(),eu=new WeakMap;function tu(e,t){let n=Gl(t),r=nu(n);for(let[i,a]of e)(!r.has(i)||t?.dangerouslyForceHydrate)&&(r.add(i),n.set(i,a))}var nu=e=>{let t=eu.get(e);return t||(t=new WeakSet,eu.set(e,t)),t};function ru(){return ru=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},ru.apply(this,arguments)}function iu(){let e=(0,H.createContext)(null);function t({store:t,initialValues:n=[],children:r}){let i=(0,H.useRef)(t);return i.current||=Vl(),tu(n,{store:i.current}),(0,W.jsx)(e.Provider,{value:i.current,children:r})}let n=t=>{let n=(0,H.useContext)(e);if(!n)throw Error(`Missing Provider from createIsolation`);return Gl(ru({store:n},t))};return{Provider:t,useStore:n,useAtom:(e,t)=>{let r=n();return $l(e,ru({store:r},t))},useAtomValue:(e,t)=>{let r=n();return Zl(e,ru({store:r},t))},useSetAtom:(e,t)=>{let r=n();return Ql(e,ru({store:r},t))}}}var{read:au,write:ou}=yl(null);(0,H.createContext)({scope:void 0,baseStore:void 0});function su(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function cu(...e){return t=>{let n=!1,r=e.map(e=>{let r=su(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():su(e[t],null)}}}}function lu(...e){return H.useCallback(cu(...e),e)}function uu(e){let t=du(e),n=H.forwardRef((e,n)=>{let{children:r,...i}=e,a=H.Children.toArray(r),o=a.find(pu);if(o){let e=o.props.children,r=a.map(t=>t===o?H.Children.count(e)>1?H.Children.only(null):H.isValidElement(e)?e.props.children:null:t);return(0,W.jsx)(t,{...i,ref:n,children:H.isValidElement(e)?H.cloneElement(e,void 0,r):null})}return(0,W.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function du(e){let t=H.forwardRef((e,t)=>{let{children:n,...r}=e;if(H.isValidElement(n)){let e=hu(n),i=mu(r,n.props);return n.type!==H.Fragment&&(i.ref=t?cu(t,e):e),H.cloneElement(n,i)}return H.Children.count(n)>1?H.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var fu=Symbol(`radix.slottable`);function pu(e){return H.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===fu}function mu(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function hu(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var gu=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=uu(`Primitive.${t}`),r=H.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,W.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function _u(e,t){e&&hl.flushSync(()=>e.dispatchEvent(t))}function vu(e,t=[]){let n=[];function r(t,r){let i=H.createContext(r),a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=H.useMemo(()=>o,Object.values(o));return(0,W.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=H.useContext(s);if(c)return c;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>H.createContext(e));return function(n){let r=n?.[e]||t;return H.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,yu(i,...t)]}function yu(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return H.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}function bu(e){let t=e+`CollectionProvider`,[n,r]=vu(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=H.useRef(null),a=H.useRef(new Map).current;return(0,W.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=uu(s),l=H.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=lu(t,a(s,n).collectionRef);return(0,W.jsx)(c,{ref:i,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=uu(u),p=H.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=H.useRef(null),s=lu(t,o),c=a(u,n);return H.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,W.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return H.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:l,ItemSlot:p},m,r]}typeof window<`u`&&window.document&&window.document.createElement;function G(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}var xu=globalThis?.document?H.useLayoutEffect:()=>{},Su=H.useInsertionEffect||xu;function Cu({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=wu({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:i;{let t=H.useRef(e!==void 0);H.useEffect(()=>{let e=t.current;e!==s&&console.warn(`${r} is changing from ${e?`controlled`:`uncontrolled`} to ${s?`controlled`:`uncontrolled`}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),t.current=s},[s,r])}return[c,H.useCallback(t=>{if(s){let n=Tu(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function wu({defaultProp:e,onChange:t}){let[n,r]=H.useState(e),i=H.useRef(n),a=H.useRef(t);return Su(()=>{a.current=t},[t]),H.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function Tu(e){return typeof e==`function`}function Eu(e,t){return H.useReducer((e,n)=>t[e][n]??e,e)}var Du=e=>{let{present:t,children:n}=e,r=Ou(t),i=typeof n==`function`?n({present:r.isPresent}):H.Children.only(n),a=lu(r.ref,Au(i));return typeof n==`function`||r.isPresent?H.cloneElement(i,{ref:a}):null};Du.displayName=`Presence`;function Ou(e){let[t,n]=H.useState(),r=H.useRef(null),i=H.useRef(e),a=H.useRef(`none`),[o,s]=Eu(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return H.useEffect(()=>{let e=ku(r.current);a.current=o===`mounted`?e:`none`},[o]),xu(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=ku(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),xu(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=ku(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(s(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},c=e=>{e.target===t&&(a.current=ku(r.current))};return t.addEventListener(`animationstart`,c),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,c),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}s(`ANIMATION_END`)},[t,s]),{isPresent:[`mounted`,`unmountSuspended`].includes(o),ref:H.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function ku(e){return e?.animationName||`none`}function Au(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var ju=H.useId||(()=>void 0),Mu=0;function Nu(e){let[t,n]=H.useState(ju());return xu(()=>{e||n(e=>e??String(Mu++))},[e]),e||(t?`radix-${t}`:``)}var Pu=H.createContext(void 0);function Fu(e){let t=H.useContext(Pu);return e||t||`ltr`}function Iu(e){let t=H.useRef(e);return H.useEffect(()=>{t.current=e}),H.useMemo(()=>(...e)=>t.current?.(...e),[])}function Lu(e,t=globalThis?.document){let n=Iu(e);H.useEffect(()=>{let e=e=>{e.key===`Escape`&&n(e)};return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}var Ru=`DismissableLayer`,zu=`dismissableLayer.update`,Bu=`dismissableLayer.pointerDownOutside`,Vu=`dismissableLayer.focusOutside`,Hu,Uu=H.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Wu=H.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,onDismiss:s,...c}=e,l=H.useContext(Uu),[u,d]=H.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=H.useState({}),m=lu(t,e=>d(e)),h=Array.from(l.layers),[g]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),_=h.indexOf(g),v=u?h.indexOf(u):-1,y=l.layersWithOutsidePointerEventsDisabled.size>0,b=v>=_,x=qu(e=>{let t=e.target,n=[...l.branches].some(e=>e.contains(t));b&&!n&&(i?.(e),o?.(e),e.defaultPrevented||s?.())},f),S=Ju(e=>{let t=e.target;[...l.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||s?.())},f);return Lu(e=>{v===l.layers.size-1&&(r?.(e),!e.defaultPrevented&&s&&(e.preventDefault(),s()))},f),H.useEffect(()=>{if(u)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(Hu=f.body.style.pointerEvents,f.body.style.pointerEvents=`none`),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),Yu(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=Hu)}},[u,f,n,l]),H.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),Yu())},[u,l]),H.useEffect(()=>{let e=()=>p({});return document.addEventListener(zu,e),()=>document.removeEventListener(zu,e)},[]),(0,W.jsx)(gu.div,{...c,ref:m,style:{pointerEvents:y?b?`auto`:`none`:void 0,...e.style},onFocusCapture:G(e.onFocusCapture,S.onFocusCapture),onBlurCapture:G(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:G(e.onPointerDownCapture,x.onPointerDownCapture)})});Wu.displayName=Ru;var Gu=`DismissableLayerBranch`,Ku=H.forwardRef((e,t)=>{let n=H.useContext(Uu),r=H.useRef(null),i=lu(t,r);return H.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,W.jsx)(gu.div,{...e,ref:i})});Ku.displayName=Gu;function qu(e,t=globalThis?.document){let n=Iu(e),r=H.useRef(!1),i=H.useRef(()=>{});return H.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){Xu(Bu,n,a,{discrete:!0})},a={originalEvent:e};e.pointerType===`touch`?(t.removeEventListener(`click`,i.current),i.current=r,t.addEventListener(`click`,i.current,{once:!0})):r()}else t.removeEventListener(`click`,i.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener(`pointerdown`,e)},0);return()=>{window.clearTimeout(a),t.removeEventListener(`pointerdown`,e),t.removeEventListener(`click`,i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Ju(e,t=globalThis?.document){let n=Iu(e),r=H.useRef(!1);return H.useEffect(()=>{let e=e=>{e.target&&!r.current&&Xu(Vu,n,{originalEvent:e},{discrete:!1})};return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Yu(){let e=new CustomEvent(zu);document.dispatchEvent(e)}function Xu(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?_u(i,a):i.dispatchEvent(a)}var Zu=`focusScope.autoFocusOnMount`,Qu=`focusScope.autoFocusOnUnmount`,$u={bubbles:!1,cancelable:!0},ed=`FocusScope`,td=H.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=H.useState(null),l=Iu(i),u=Iu(a),d=H.useRef(null),f=lu(t,e=>c(e)),p=H.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;H.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:cd(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||cd(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&cd(s)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,p.paused]),H.useEffect(()=>{if(s){ld.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(Zu,$u);s.addEventListener(Zu,l),s.dispatchEvent(t),t.defaultPrevented||(nd(fd(id(s)),{select:!0}),document.activeElement===e&&cd(s))}return()=>{s.removeEventListener(Zu,l),setTimeout(()=>{let t=new CustomEvent(Qu,$u);s.addEventListener(Qu,u),s.dispatchEvent(t),t.defaultPrevented||cd(e??document.body,{select:!0}),s.removeEventListener(Qu,u),ld.remove(p)},0)}}},[s,l,u,p]);let m=H.useCallback(e=>{if(!n&&!r||p.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=rd(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&cd(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&cd(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,W.jsx)(gu.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});td.displayName=ed;function nd(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(cd(r,{select:t}),document.activeElement!==n)return}function rd(e){let t=id(e);return[ad(t,e),ad(t.reverse(),e)]}function id(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function ad(e,t){for(let n of e)if(!od(n,{upTo:t}))return n}function od(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 sd(e){return e instanceof HTMLInputElement&&`select`in e}function cd(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&sd(e)&&t&&e.select()}}var ld=ud();function ud(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=dd(e,t),e.unshift(t)},remove(t){e=dd(e,t),e[0]?.resume()}}}function dd(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function fd(e){return e.filter(e=>e.tagName!==`A`)}var pd=`Portal`,md=H.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=H.useState(!1);xu(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?hl.createPortal((0,W.jsx)(gu.div,{...r,ref:t}),o):null});md.displayName=pd;var hd=0;function gd(){H.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??_d()),document.body.insertAdjacentElement(`beforeend`,e[1]??_d()),hd++,()=>{hd===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),hd--}},[])}function _d(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var vd=function(){return vd=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},vd.apply(this,arguments)};function yd(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 bd(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var xd=`right-scroll-bar-position`,Sd=`width-before-scroll-bar`,Cd=`with-scroll-bars-hidden`,wd=`--removed-body-scroll-bar-size`;function Td(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function Ed(e,t){var n=(0,H.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var Dd=typeof window<`u`?H.useLayoutEffect:H.useEffect,Od=new WeakMap;function kd(e,t){var n=Ed(t||null,function(t){return e.forEach(function(e){return Td(e,t)})});return Dd(function(){var t=Od.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||Td(e,null)}),i.forEach(function(e){r.has(e)||Td(e,a)})}Od.set(n,e)},[e]),n}function Ad(e){return e}function jd(e,t){t===void 0&&(t=Ad);var n=[],r=!1;return{read:function(){if(r)throw 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(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function Md(e){e===void 0&&(e={});var t=jd(null);return t.options=vd({async:!0,ssr:!1},e),t}var Nd=function(e){var t=e.sideCar,n=yd(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return H.createElement(r,vd({},n))};Nd.isSideCarExport=!0;function Pd(e,t){return e.useMedium(t),Nd}var Fd=Md(),Id=function(){},Ld=H.forwardRef(function(e,t){var n=H.useRef(null),r=H.useState({onScrollCapture:Id,onWheelCapture:Id,onTouchMoveCapture:Id}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,y=e.gapMode,b=yd(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=kd([n,t]),C=vd(vd({},b),i);return H.createElement(H.Fragment,null,u&&H.createElement(x,{sideCar:Fd,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?H.cloneElement(H.Children.only(s),vd(vd({},C),{ref:S})):H.createElement(v,vd({},C,{className:c,ref:S}),s))});Ld.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Ld.classNames={fullWidth:Sd,zeroRight:xd};var Rd=function(){if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function zd(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=Rd();return t&&e.setAttribute(`nonce`,t),e}function Bd(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Vd(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var Hd=function(){var e=0,t=null;return{add:function(n){e==0&&(t=zd())&&(Bd(t,n),Vd(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Ud=function(){var e=Hd();return function(t,n){H.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Wd=function(){var e=Ud();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},Gd={left:0,top:0,right:0,gap:0},Kd=function(e){return parseInt(e||``,10)||0},qd=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[Kd(n),Kd(r),Kd(i)]},Jd=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return Gd;var t=qd(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])}},Yd=Wd(),Xd=`data-scroll-locked`,Zd=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
2
|
+
.${Cd} {
|
|
3
|
+
overflow: hidden ${r};
|
|
4
|
+
padding-right: ${s}px ${r};
|
|
5
|
+
}
|
|
6
|
+
body[${Xd}] {
|
|
7
|
+
overflow: hidden ${r};
|
|
8
|
+
overscroll-behavior: contain;
|
|
9
|
+
${[t&&`position: relative ${r};`,n===`margin`&&`
|
|
10
|
+
padding-left: ${i}px;
|
|
11
|
+
padding-top: ${a}px;
|
|
12
|
+
padding-right: ${o}px;
|
|
13
|
+
margin-left:0;
|
|
14
|
+
margin-top:0;
|
|
15
|
+
margin-right: ${s}px ${r};
|
|
16
|
+
`,n===`padding`&&`padding-right: ${s}px ${r};`].filter(Boolean).join(``)}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.${xd} {
|
|
20
|
+
right: ${s}px ${r};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.${Sd} {
|
|
24
|
+
margin-right: ${s}px ${r};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.${xd} .${xd} {
|
|
28
|
+
right: 0 ${r};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.${Sd} .${Sd} {
|
|
32
|
+
margin-right: 0 ${r};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
body[${Xd}] {
|
|
36
|
+
${wd}: ${s}px;
|
|
37
|
+
}
|
|
38
|
+
`},Qd=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},$d=function(){H.useEffect(function(){return document.body.setAttribute(Xd,(Qd()+1).toString()),function(){var e=Qd()-1;e<=0?document.body.removeAttribute(Xd):document.body.setAttribute(Xd,e.toString())}},[])},ef=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;$d();var a=H.useMemo(function(){return Jd(i)},[i]);return H.createElement(Yd,{styles:Zd(a,!t,i,n?``:`!important`)})},tf=!1;if(typeof window<`u`)try{var nf=Object.defineProperty({},"passive",{get:function(){return tf=!0,!0}});window.addEventListener(`test`,nf,nf),window.removeEventListener(`test`,nf,nf)}catch{tf=!1}var rf=tf?{passive:!1}:!1,af=function(e){return e.tagName===`TEXTAREA`},of=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!af(e)&&n[t]===`visible`)},sf=function(e){return of(e,`overflowY`)},cf=function(e){return of(e,`overflowX`)},lf=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),ff(e,r)){var i=pf(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},uf=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},df=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},ff=function(e,t){return e===`v`?sf(t):cf(t)},pf=function(e,t){return e===`v`?uf(t):df(t)},mf=function(e,t){return e===`h`&&t===`rtl`?-1:1},hf=function(e,t,n,r,i){var a=mf(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=pf(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&ff(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},gf=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},_f=function(e){return[e.deltaX,e.deltaY]},vf=function(e){return e&&`current`in e?e.current:e},yf=function(e,t){return e[0]===t[0]&&e[1]===t[1]},bf=function(e){return`
|
|
39
|
+
.block-interactivity-${e} {pointer-events: none;}
|
|
40
|
+
.allow-interactivity-${e} {pointer-events: all;}
|
|
41
|
+
`},xf=0,Sf=[];function Cf(e){var t=H.useRef([]),n=H.useRef([0,0]),r=H.useRef(),i=H.useState(xf++)[0],a=H.useState(Wd)[0],o=H.useRef(e);H.useEffect(function(){o.current=e},[e]),H.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=bd([e.lockRef.current],(e.shards||[]).map(vf),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=H.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=gf(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=lf(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=lf(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return hf(h,t,e,h===`h`?s:c,!0)},[]),c=H.useCallback(function(e){var n=e;if(Sf.length&&Sf[Sf.length-1]===a){var r=`deltaY`in n?_f(n):gf(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&yf(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(vf).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=H.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:wf(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=H.useCallback(function(e){n.current=gf(e),r.current=void 0},[]),d=H.useCallback(function(t){l(t.type,_f(t),t.target,s(t,e.lockRef.current))},[]),f=H.useCallback(function(t){l(t.type,gf(t),t.target,s(t,e.lockRef.current))},[]);H.useEffect(function(){return Sf.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,rf),document.addEventListener(`touchmove`,c,rf),document.addEventListener(`touchstart`,u,rf),function(){Sf=Sf.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,rf),document.removeEventListener(`touchmove`,c,rf),document.removeEventListener(`touchstart`,u,rf)}},[]);var p=e.removeScrollBar,m=e.inert;return H.createElement(H.Fragment,null,m?H.createElement(a,{styles:bf(i)}):null,p?H.createElement(ef,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function wf(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var Tf=Pd(Fd,Cf),Ef=H.forwardRef(function(e,t){return H.createElement(Ld,vd({},e,{ref:t,sideCar:Tf}))});Ef.classNames=Ld.classNames;var Df=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},Of=new WeakMap,kf=new WeakMap,Af={},jf=0,Mf=function(e){return e&&(e.host||Mf(e.parentNode))},Nf=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=Mf(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},Pf=function(e,t,n,r){var i=Nf(t,Array.isArray(e)?e:[e]);Af[n]||(Af[n]=new WeakMap);var a=Af[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(Of.get(e)||0)+1,l=(a.get(e)||0)+1;Of.set(e,c),a.set(e,l),o.push(e),c===1&&i&&kf.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),jf++,function(){o.forEach(function(e){var t=Of.get(e)-1,i=a.get(e)-1;Of.set(e,t),a.set(e,i),t||(kf.has(e)||e.removeAttribute(r),kf.delete(e)),i||e.removeAttribute(n)}),jf--,jf||(Of=new WeakMap,Of=new WeakMap,kf=new WeakMap,Af={})}},Ff=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||Df(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),Pf(r,i,n,`aria-hidden`)):function(){return null}},If=t((e=>{var t=r();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:n,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),Lf=t(((e,t)=>{t.exports=If()}));function Rf(e){let[t,n]=H.useState(void 0);return xu(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}var zf=[`top`,`right`,`bottom`,`left`],Bf=Math.min,Vf=Math.max,Hf=Math.round,Uf=Math.floor,Wf=e=>({x:e,y:e}),Gf={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function Kf(e,t,n){return Vf(e,Bf(t,n))}function qf(e,t){return typeof e==`function`?e(t):e}function Jf(e){return e.split(`-`)[0]}function Yf(e){return e.split(`-`)[1]}function Xf(e){return e===`x`?`y`:`x`}function Zf(e){return e===`y`?`height`:`width`}function Qf(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function $f(e){return Xf(Qf(e))}function ep(e,t,n){n===void 0&&(n=!1);let r=Yf(e),i=$f(e),a=Zf(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=lp(o)),[o,lp(o)]}function tp(e){let t=lp(e);return[np(e),t,np(t)]}function np(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var rp=[`left`,`right`],ip=[`right`,`left`],ap=[`top`,`bottom`],op=[`bottom`,`top`];function sp(e,t,n){switch(e){case`top`:case`bottom`:return n?t?ip:rp:t?rp:ip;case`left`:case`right`:return t?ap:op;default:return[]}}function cp(e,t,n,r){let i=Yf(e),a=sp(Jf(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(np)))),a}function lp(e){let t=Jf(e);return Gf[t]+e.slice(t.length)}function up(e){return{top:0,right:0,bottom:0,left:0,...e}}function dp(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:up(e)}function fp(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function pp(e,t,n){let{reference:r,floating:i}=e,a=Qf(t),o=$f(t),s=Zf(o),c=Jf(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(Yf(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1)}return p}async function mp(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=qf(t,e),p=dp(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=fp(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=fp(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var hp=50,gp=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:mp},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=pp(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<hp&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=pp(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},_p=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=qf(e,t)||{};if(l==null)return{};let d=dp(u),f={x:n,y:r},p=$f(i),m=Zf(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=Bf(d[_],T),D=Bf(d[v],T),ee=E,te=C-h[m]-D,O=C/2-h[m]/2+w,k=Kf(ee,O,te),A=!c.arrow&&Yf(i)!=null&&O!==k&&a.reference[m]/2-(O<ee?E:D)-h[m]/2<0,ne=A?O<ee?O-ee:O-te:0;return{[p]:f[p]+ne,data:{[p]:k,centerOffset:O-k-ne,...A&&{alignmentOffset:ne}},reset:A}}}),vp=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=qf(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=Jf(r),_=Qf(o),v=Jf(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[lp(o)]:tp(o)),x=p!==`none`;!d&&x&&b.push(...cp(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=ep(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===Qf(t)||T.every(e=>Qf(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=Qf(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function yp(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function bp(e){return zf.some(t=>e[t]>=0)}var xp=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=qf(e,t);switch(i){case`referenceHidden`:{let e=yp(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:bp(e)}}}case`escaped`:{let e=yp(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:bp(e)}}}default:return{}}}}},Sp=new Set([`left`,`top`]);async function Cp(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Jf(n),s=Yf(n),c=Qf(n)===`y`,l=Sp.has(o)?-1:1,u=a&&c?-1:1,d=qf(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var wp=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await Cp(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},Tp=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=qf(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=Qf(Jf(i)),p=Xf(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=Kf(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=Kf(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},Ep=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=qf(e,t),u={x:n,y:r},d=Qf(i),f=Xf(d),p=u[f],m=u[d],h=qf(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=Sp.has(Jf(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},Dp=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=qf(e,t),u=await o.detectOverflow(t,l),d=Jf(i),f=Yf(i),p=Qf(i)===`y`,{width:m,height:h}=a.floating,g,_;d===`top`||d===`bottom`?(g=d,_=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(_=d,g=f===`end`?`top`:`bottom`);let v=h-u.top-u.bottom,y=m-u.left-u.right,b=Bf(h-u[g],v),x=Bf(m-u[_],y),S=!t.middlewareData.shift,C=b,w=x;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(w=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=v),S&&!f){let e=Vf(u.left,0),t=Vf(u.right,0),n=Vf(u.top,0),r=Vf(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:Vf(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:Vf(u.top,u.bottom))}await c({...t,availableWidth:w,availableHeight:C});let T=await o.getDimensions(s.floating);return m!==T.width||h!==T.height?{reset:{rects:!0}}:{}}}};function Op(){return typeof window<`u`}function kp(e){return Mp(e)?(e.nodeName||``).toLowerCase():`#document`}function Ap(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function jp(e){return((Mp(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Mp(e){return Op()?e instanceof Node||e instanceof Ap(e).Node:!1}function Np(e){return Op()?e instanceof Element||e instanceof Ap(e).Element:!1}function Pp(e){return Op()?e instanceof HTMLElement||e instanceof Ap(e).HTMLElement:!1}function Fp(e){return!Op()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof Ap(e).ShadowRoot}function Ip(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=qp(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Lp(e){return/^(table|td|th)$/.test(kp(e))}function Rp(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var zp=/transform|translate|scale|rotate|perspective|filter/,Bp=/paint|layout|strict|content/,Vp=e=>!!e&&e!==`none`,Hp;function Up(e){let t=Np(e)?qp(e):e;return Vp(t.transform)||Vp(t.translate)||Vp(t.scale)||Vp(t.rotate)||Vp(t.perspective)||!Gp()&&(Vp(t.backdropFilter)||Vp(t.filter))||zp.test(t.willChange||``)||Bp.test(t.contain||``)}function Wp(e){let t=Yp(e);for(;Pp(t)&&!Kp(t);){if(Up(t))return t;if(Rp(t))return null;t=Yp(t)}return null}function Gp(){return Hp??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Hp}function Kp(e){return/^(html|body|#document)$/.test(kp(e))}function qp(e){return Ap(e).getComputedStyle(e)}function Jp(e){return Np(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Yp(e){if(kp(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Fp(e)&&e.host||jp(e);return Fp(t)?t.host:t}function Xp(e){let t=Yp(e);return Kp(t)?e.ownerDocument?e.ownerDocument.body:e.body:Pp(t)&&Ip(t)?t:Xp(t)}function Zp(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Xp(e),i=r===e.ownerDocument?.body,a=Ap(r);if(i){let e=Qp(a);return t.concat(a,a.visualViewport||[],Ip(r)?r:[],e&&n?Zp(e):[])}return t.concat(r,Zp(r,[],n))}function Qp(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function $p(e){let t=qp(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Pp(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Hf(n)!==a||Hf(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function em(e){return Np(e)?e:e.contextElement}function tm(e){let t=em(e);if(!Pp(t))return Wf(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=$p(t),o=(a?Hf(n.width):n.width)/r,s=(a?Hf(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var nm=Wf(0);function rm(e){let t=Ap(e);return!Gp()||!t.visualViewport?nm:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function im(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Ap(e)?!1:t}function am(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=em(e),o=Wf(1);t&&(r?Np(r)&&(o=tm(r)):o=tm(e));let s=im(a,n,r)?rm(a):Wf(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=Ap(a),t=r&&Np(r)?Ap(r):r,n=e,i=Qp(n);for(;i&&r&&t!==n;){let e=tm(i),t=i.getBoundingClientRect(),r=qp(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=Ap(i),i=Qp(n)}}return fp({width:u,height:d,x:c,y:l})}function om(e,t){let n=Jp(e).scrollLeft;return t?t.left+n:am(jp(e)).left+n}function sm(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-om(e,n),y:n.top+t.scrollTop}}function cm(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=jp(r),s=t?Rp(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Wf(1),u=Wf(0),d=Pp(r);if((d||!d&&!a)&&((kp(r)!==`body`||Ip(o))&&(c=Jp(r)),d)){let e=am(r);l=tm(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?sm(o,c):Wf(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function lm(e){return Array.from(e.getClientRects())}function um(e){let t=jp(e),n=Jp(e),r=e.ownerDocument.body,i=Vf(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=Vf(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+om(e),s=-n.scrollTop;return qp(r).direction===`rtl`&&(o+=Vf(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var dm=25;function fm(e,t){let n=Ap(e),r=jp(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=Gp();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=om(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=dm&&(a-=o)}else l<=dm&&(a+=l);return{width:a,height:o,x:s,y:c}}function pm(e,t){let n=am(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Pp(e)?tm(e):Wf(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function mm(e,t,n){let r;if(t===`viewport`)r=fm(e,n);else if(t===`document`)r=um(jp(e));else if(Np(t))r=pm(t,n);else{let n=rm(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return fp(r)}function hm(e,t){let n=Yp(e);return n===t||!Np(n)||Kp(n)?!1:qp(n).position===`fixed`||hm(n,t)}function gm(e,t){let n=t.get(e);if(n)return n;let r=Zp(e,[],!1).filter(e=>Np(e)&&kp(e)!==`body`),i=null,a=qp(e).position===`fixed`,o=a?Yp(e):e;for(;Np(o)&&!Kp(o);){let t=qp(o),n=Up(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||Ip(o)&&!n&&hm(e,o))?r=r.filter(e=>e!==o):i=t,o=Yp(o)}return t.set(e,r),r}function _m(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Rp(t)?[]:gm(t,this._c):[].concat(n),r],o=mm(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=mm(t,a[e],i);s=Vf(n.top,s),c=Bf(n.right,c),l=Bf(n.bottom,l),u=Vf(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function vm(e){let{width:t,height:n}=$p(e);return{width:t,height:n}}function ym(e,t,n){let r=Pp(t),i=jp(t),a=n===`fixed`,o=am(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=Wf(0);function l(){c.x=om(i)}if(r||!r&&!a){if((kp(t)!==`body`||Ip(i))&&(s=Jp(t)),r){let e=am(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l()}a&&!r&&i&&l();let u=i&&!r&&!a?sm(i,s):Wf(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function bm(e){return qp(e).position===`static`}function xm(e,t){if(!Pp(e)||qp(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return jp(e)===n&&(n=n.ownerDocument.body),n}function Sm(e,t){let n=Ap(e);if(Rp(e))return n;if(!Pp(e)){let t=Yp(e);for(;t&&!Kp(t);){if(Np(t)&&!bm(t))return t;t=Yp(t)}return n}let r=xm(e,t);for(;r&&Lp(r)&&bm(r);)r=xm(r,t);return r&&Kp(r)&&bm(r)&&!Up(r)?n:r||Wp(e)||n}var Cm=async function(e){let t=this.getOffsetParent||Sm,n=this.getDimensions,r=await n(e.floating);return{reference:ym(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function wm(e){return qp(e).direction===`rtl`}var Tm={convertOffsetParentRelativeRectToViewportRelativeRect:cm,getDocumentElement:jp,getClippingRect:_m,getOffsetParent:Sm,getElementRects:Cm,getClientRects:lm,getDimensions:vm,getScale:tm,isElement:Np,isRTL:wm};function Em(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Dm(e,t){let n=null,r,i=jp(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=Uf(d),h=Uf(i.clientWidth-(u+f)),g=Uf(i.clientHeight-(d+p)),_=Uf(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Vf(0,Bf(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(n!==c){if(!y)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!Em(l,e.getBoundingClientRect())&&o(),y=!1}try{n=new IntersectionObserver(b,{...v,root:i.ownerDocument})}catch{n=new IntersectionObserver(b,v)}n.observe(e)}return o(!0),a}function Om(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=em(e),u=i||a?[...l?Zp(l):[],...t?Zp(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?Dm(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?am(e):null;c&&g();function g(){let t=am(e);h&&!Em(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var km=wp,Am=Tp,jm=vp,Mm=Dp,Nm=xp,Pm=_p,Fm=Ep,Im=(e,t,n)=>{let r=new Map,i={platform:Tm,...n},a={...i.platform,_c:r};return gp(e,t,{...i,platform:a})},Lm=typeof document<`u`?H.useLayoutEffect:function(){};function Rm(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(!Rm(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(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!Rm(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function zm(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Bm(e,t){let n=zm(e);return Math.round(t*n)/n}function Vm(e){let t=H.useRef(e);return Lm(()=>{t.current=e}),t}function Hm(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=H.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=H.useState(r);Rm(f,r)||p(r);let[m,h]=H.useState(null),[g,_]=H.useState(null),v=H.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=H.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=H.useRef(null),C=H.useRef(null),w=H.useRef(u),T=c!=null,E=Vm(c),D=Vm(i),ee=Vm(l),te=H.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),Im(S.current,C.current,e).then(e=>{let t={...e,isPositioned:ee.current!==!1};O.current&&!Rm(w.current,t)&&(w.current=t,hl.flushSync(()=>{d(t)}))})},[f,t,n,D,ee]);Lm(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let O=H.useRef(!1);Lm(()=>(O.current=!0,()=>{O.current=!1}),[]),Lm(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,te);te()}},[b,x,te,E,T]);let k=H.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),A=H.useMemo(()=>({reference:b,floating:x}),[b,x]),ne=H.useMemo(()=>{let e={position:n,left:0,top:0};if(!A.floating)return e;let t=Bm(A.floating,u.x),r=Bm(A.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...zm(A.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,A.floating,u.x,u.y]);return H.useMemo(()=>({...u,update:te,refs:k,elements:A,floatingStyles:ne}),[u,te,k,A,ne])}var Um=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:Pm({element:r.current,padding:i}).fn(n):r?Pm({element:r,padding:i}).fn(n):{}}}},Wm=(e,t)=>{let n=km(e);return{name:n.name,fn:n.fn,options:[e,t]}},Gm=(e,t)=>{let n=Am(e);return{name:n.name,fn:n.fn,options:[e,t]}},Km=(e,t)=>({fn:Fm(e).fn,options:[e,t]}),qm=(e,t)=>{let n=jm(e);return{name:n.name,fn:n.fn,options:[e,t]}},Jm=(e,t)=>{let n=Mm(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ym=(e,t)=>{let n=Nm(e);return{name:n.name,fn:n.fn,options:[e,t]}},Xm=(e,t)=>{let n=Um(e);return{name:n.name,fn:n.fn,options:[e,t]}},Zm=`Arrow`,Qm=H.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,W.jsx)(gu.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,W.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});Qm.displayName=Zm;var $m=Qm,eh=`Popper`,[th,nh]=vu(eh),[rh,ih]=th(eh),ah=e=>{let{__scopePopper:t,children:n}=e,[r,i]=H.useState(null);return(0,W.jsx)(rh,{scope:t,anchor:r,onAnchorChange:i,children:n})};ah.displayName=eh;var oh=`PopperAnchor`,sh=H.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=ih(oh,n),o=H.useRef(null),s=lu(t,o),c=H.useRef(null);return H.useEffect(()=>{let e=c.current;c.current=r?.current||o.current,e!==c.current&&a.onAnchorChange(c.current)}),r?null:(0,W.jsx)(gu.div,{...i,ref:s})});sh.displayName=oh;var ch=`PopperContent`,[lh,uh]=th(ch),dh=H.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:m,...h}=e,g=ih(ch,n),[_,v]=H.useState(null),y=lu(t,e=>v(e)),[b,x]=H.useState(null),S=Rf(b),C=S?.width??0,w=S?.height??0,T=r+(a===`center`?``:`-`+a),E=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(l)?l:[l],ee=D.length>0,te={padding:E,boundary:D.filter(hh),altBoundary:ee},{refs:O,floatingStyles:k,placement:A,isPositioned:ne,middlewareData:re}=Hm({strategy:`fixed`,placement:T,whileElementsMounted:(...e)=>Om(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[Wm({mainAxis:i+w,alignmentAxis:o}),c&&Gm({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?Km():void 0,...te}),c&&qm({...te}),Jm({...te,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),b&&Xm({element:b,padding:s}),gh({arrowWidth:C,arrowHeight:w}),f&&Ym({strategy:`referenceHidden`,...te})]}),[ie,ae]=_h(A),oe=Iu(m);xu(()=>{ne&&oe?.()},[ne,oe]);let se=re.arrow?.x,ce=re.arrow?.y,le=re.arrow?.centerOffset!==0,[ue,de]=H.useState();return xu(()=>{_&&de(window.getComputedStyle(_).zIndex)},[_]),(0,W.jsx)(`div`,{ref:O.setFloating,"data-radix-popper-content-wrapper":``,style:{...k,transform:ne?k.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:ue,"--radix-popper-transform-origin":[re.transformOrigin?.x,re.transformOrigin?.y].join(` `),...re.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,W.jsx)(lh,{scope:n,placedSide:ie,onArrowChange:x,arrowX:se,arrowY:ce,shouldHideArrow:le,children:(0,W.jsx)(gu.div,{"data-side":ie,"data-align":ae,...h,ref:y,style:{...h.style,animation:ne?void 0:`none`}})})})});dh.displayName=ch;var fh=`PopperArrow`,ph={top:`bottom`,right:`left`,bottom:`top`,left:`right`},mh=H.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=uh(fh,n),a=ph[i.placedSide];return(0,W.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,W.jsx)($m,{...r,ref:t,style:{...r.style,display:`block`}})})});mh.displayName=fh;function hh(e){return e!==null}var gh=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=_h(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function _h(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var vh=ah,yh=sh,bh=dh,xh=mh,Sh=`rovingFocusGroup.onEntryFocus`,Ch={bubbles:!1,cancelable:!0},wh=`RovingFocusGroup`,[Th,Eh,Dh]=bu(wh),[Oh,kh]=vu(wh,[Dh]),[Ah,jh]=Oh(wh),Mh=H.forwardRef((e,t)=>(0,W.jsx)(Th.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,W.jsx)(Th.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,W.jsx)(Nh,{...e,ref:t})})}));Mh.displayName=wh;var Nh=H.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=H.useRef(null),p=lu(t,f),m=Fu(a),[h,g]=Cu({prop:o,defaultProp:s??null,onChange:c,caller:wh}),[_,v]=H.useState(!1),y=Iu(l),b=Eh(n),x=H.useRef(!1),[S,C]=H.useState(0);return H.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(Sh,y),()=>e.removeEventListener(Sh,y)},[y]),(0,W.jsx)(Ah,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:H.useCallback(e=>g(e),[g]),onItemShiftTab:H.useCallback(()=>v(!0),[]),onFocusableItemAdd:H.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:H.useCallback(()=>C(e=>e-1),[]),children:(0,W.jsx)(gu.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:G(e.onMouseDown,()=>{x.current=!0}),onFocus:G(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(Sh,Ch);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);zh([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:G(e.onBlur,()=>v(!1))})})}),Ph=`RovingFocusGroupItem`,Fh=H.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=Nu(),l=a||c,u=jh(Ph,n),d=u.currentTabStopId===l,f=Eh(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return H.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,W.jsx)(Th.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,W.jsx)(gu.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:G(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:G(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:G(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=Rh(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?Bh(n,r+1):n.slice(r+1)}setTimeout(()=>zh(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});Fh.displayName=Ph;var Ih={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function Lh(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function Rh(e,t,n){let r=Lh(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return Ih[r]}function zh(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Bh(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Vh=Mh,Hh=Fh,Uh=[`Enter`,` `],Wh=[`ArrowDown`,`PageUp`,`Home`],Gh=[`ArrowUp`,`PageDown`,`End`],Kh=[...Wh,...Gh],qh={ltr:[...Uh,`ArrowRight`],rtl:[...Uh,`ArrowLeft`]},Jh={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},Yh=`Menu`,[Xh,Zh,Qh]=bu(Yh),[$h,eg]=vu(Yh,[Qh,nh,kh]),tg=nh(),ng=kh(),[rg,ig]=$h(Yh),[ag,og]=$h(Yh),sg=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=tg(t),[c,l]=H.useState(null),u=H.useRef(!1),d=Iu(a),f=Fu(i);return H.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),(0,W.jsx)(vh,{...s,children:(0,W.jsx)(rg,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,W.jsx)(ag,{scope:t,onClose:H.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};sg.displayName=Yh;var cg=`MenuAnchor`,lg=H.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=tg(n);return(0,W.jsx)(yh,{...i,...r,ref:t})});lg.displayName=cg;var ug=`MenuPortal`,[dg,fg]=$h(ug,{forceMount:void 0}),pg=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=ig(ug,t);return(0,W.jsx)(dg,{scope:t,forceMount:n,children:(0,W.jsx)(Du,{present:n||a.open,children:(0,W.jsx)(md,{asChild:!0,container:i,children:r})})})};pg.displayName=ug;var mg=`MenuContent`,[hg,gg]=$h(mg),_g=H.forwardRef((e,t)=>{let n=fg(mg,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=ig(mg,e.__scopeMenu),o=og(mg,e.__scopeMenu);return(0,W.jsx)(Xh.Provider,{scope:e.__scopeMenu,children:(0,W.jsx)(Du,{present:r||a.open,children:(0,W.jsx)(Xh.Slot,{scope:e.__scopeMenu,children:o.modal?(0,W.jsx)(vg,{...i,ref:t}):(0,W.jsx)(yg,{...i,ref:t})})})})}),vg=H.forwardRef((e,t)=>{let n=ig(mg,e.__scopeMenu),r=H.useRef(null),i=lu(t,r);return H.useEffect(()=>{let e=r.current;if(e)return Ff(e)},[]),(0,W.jsx)(xg,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:G(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),yg=H.forwardRef((e,t)=>{let n=ig(mg,e.__scopeMenu);return(0,W.jsx)(xg,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),bg=uu(`MenuContent.ScrollLock`),xg=H.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,g=ig(mg,n),_=og(mg,n),v=tg(n),y=ng(n),b=Zh(n),[x,S]=H.useState(null),C=H.useRef(null),w=lu(t,C,g.onContentChange),T=H.useRef(0),E=H.useRef(``),D=H.useRef(0),ee=H.useRef(null),te=H.useRef(`right`),O=H.useRef(0),k=m?Ef:H.Fragment,A=m?{as:bg,allowPinchZoom:!0}:void 0,ne=e=>{let t=E.current+e,n=b().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=a_(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){E.current=t,window.clearTimeout(T.current),t!==``&&(T.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};H.useEffect(()=>()=>window.clearTimeout(T.current),[]),gd();let re=H.useCallback(e=>te.current===ee.current?.side&&s_(e,ee.current?.area),[]);return(0,W.jsx)(hg,{scope:n,searchRef:E,onItemEnter:H.useCallback(e=>{re(e)&&e.preventDefault()},[re]),onItemLeave:H.useCallback(e=>{re(e)||(C.current?.focus(),S(null))},[re]),onTriggerLeave:H.useCallback(e=>{re(e)&&e.preventDefault()},[re]),pointerGraceTimerRef:D,onPointerGraceIntentChange:H.useCallback(e=>{ee.current=e},[]),children:(0,W.jsx)(k,{...A,children:(0,W.jsx)(td,{asChild:!0,trapped:i,onMountAutoFocus:G(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,W.jsx)(Wu,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,W.jsx)(Vh,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:G(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,W.jsx)(bh,{role:`menu`,"aria-orientation":`vertical`,"data-state":e_(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:w,style:{outline:`none`,...h.style},onKeyDown:G(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&ne(e.key));let i=C.current;if(e.target!==i||!Kh.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);Gh.includes(e.key)&&a.reverse(),r_(a)}),onBlur:G(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(T.current),E.current=``)}),onPointerMove:G(e.onPointerMove,c_(e=>{let t=e.target,n=O.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>O.current?`right`:`left`;te.current=t,O.current=e.clientX}}))})})})})})})});_g.displayName=mg;var Sg=`MenuGroup`,Cg=H.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,W.jsx)(gu.div,{role:`group`,...r,ref:t})});Cg.displayName=Sg;var wg=`MenuLabel`,Tg=H.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,W.jsx)(gu.div,{...r,ref:t})});Tg.displayName=wg;var Eg=`MenuItem`,Dg=`menu.itemSelect`,Og=H.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=H.useRef(null),o=og(Eg,e.__scopeMenu),s=gg(Eg,e.__scopeMenu),c=lu(t,a),l=H.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(Dg,{bubbles:!0,cancelable:!0});e.addEventListener(Dg,e=>r?.(e),{once:!0}),_u(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,W.jsx)(kg,{...i,ref:c,disabled:n,onClick:G(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:G(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:G(e.onKeyDown,e=>{let t=s.searchRef.current!==``;n||t&&e.key===` `||Uh.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});Og.displayName=Eg;var kg=H.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=gg(Eg,n),s=ng(n),c=H.useRef(null),l=lu(t,c),[u,d]=H.useState(!1),[f,p]=H.useState(``);return H.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,W.jsx)(Xh.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,W.jsx)(Hh,{asChild:!0,...s,focusable:!r,children:(0,W.jsx)(gu.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:G(e.onPointerMove,c_(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:G(e.onPointerLeave,c_(e=>o.onItemLeave(e))),onFocus:G(e.onFocus,()=>d(!0)),onBlur:G(e.onBlur,()=>d(!1))})})})}),Ag=`MenuCheckboxItem`,jg=H.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,W.jsx)(zg,{scope:e.__scopeMenu,checked:n,children:(0,W.jsx)(Og,{role:`menuitemcheckbox`,"aria-checked":t_(n)?`mixed`:n,...i,ref:t,"data-state":n_(n),onSelect:G(i.onSelect,()=>r?.(t_(n)?!0:!n),{checkForDefaultPrevented:!1})})})});jg.displayName=Ag;var Mg=`MenuRadioGroup`,[Ng,Pg]=$h(Mg,{value:void 0,onValueChange:()=>{}}),Fg=H.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=Iu(r);return(0,W.jsx)(Ng,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,W.jsx)(Cg,{...i,ref:t})})});Fg.displayName=Mg;var Ig=`MenuRadioItem`,Lg=H.forwardRef((e,t)=>{let{value:n,...r}=e,i=Pg(Ig,e.__scopeMenu),a=n===i.value;return(0,W.jsx)(zg,{scope:e.__scopeMenu,checked:a,children:(0,W.jsx)(Og,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":n_(a),onSelect:G(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});Lg.displayName=Ig;var Rg=`MenuItemIndicator`,[zg,Bg]=$h(Rg,{checked:!1}),Vg=H.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=Bg(Rg,n);return(0,W.jsx)(Du,{present:r||t_(a.checked)||a.checked===!0,children:(0,W.jsx)(gu.span,{...i,ref:t,"data-state":n_(a.checked)})})});Vg.displayName=Rg;var Hg=`MenuSeparator`,Ug=H.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,W.jsx)(gu.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});Ug.displayName=Hg;var Wg=`MenuArrow`,Gg=H.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=tg(n);return(0,W.jsx)(xh,{...i,...r,ref:t})});Gg.displayName=Wg;var Kg=`MenuSub`,[qg,Jg]=$h(Kg),Yg=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=ig(Kg,t),o=tg(t),[s,c]=H.useState(null),[l,u]=H.useState(null),d=Iu(i);return H.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,W.jsx)(vh,{...o,children:(0,W.jsx)(rg,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,W.jsx)(qg,{scope:t,contentId:Nu(),triggerId:Nu(),trigger:s,onTriggerChange:c,children:n})})})};Yg.displayName=Kg;var Xg=`MenuSubTrigger`,Zg=H.forwardRef((e,t)=>{let n=ig(Xg,e.__scopeMenu),r=og(Xg,e.__scopeMenu),i=Jg(Xg,e.__scopeMenu),a=gg(Xg,e.__scopeMenu),o=H.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=H.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return H.useEffect(()=>u,[u]),H.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]),(0,W.jsx)(lg,{asChild:!0,...l,children:(0,W.jsx)(kg,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":e_(n.open),...e,ref:cu(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:G(e.onPointerMove,c_(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:G(e.onPointerLeave,c_(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:G(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||qh[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});Zg.displayName=Xg;var Qg=`MenuSubContent`,$g=H.forwardRef((e,t)=>{let n=fg(mg,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=ig(mg,e.__scopeMenu),o=og(mg,e.__scopeMenu),s=Jg(Qg,e.__scopeMenu),c=H.useRef(null),l=lu(t,c);return(0,W.jsx)(Xh.Provider,{scope:e.__scopeMenu,children:(0,W.jsx)(Du,{present:r||a.open,children:(0,W.jsx)(Xh.Slot,{scope:e.__scopeMenu,children:(0,W.jsx)(xg,{id:s.contentId,"aria-labelledby":s.triggerId,...i,ref:l,align:`start`,side:o.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{o.isUsingKeyboardRef.current&&c.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:G(e.onFocusOutside,e=>{e.target!==s.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:G(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:G(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=Jh[o.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});$g.displayName=Qg;function e_(e){return e?`open`:`closed`}function t_(e){return e===`indeterminate`}function n_(e){return t_(e)?`indeterminate`:e?`checked`:`unchecked`}function r_(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function i_(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function a_(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=i_(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function o_(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function s_(e,t){return t?o_({x:e.clientX,y:e.clientY},t):!1}function c_(e){return t=>t.pointerType===`mouse`?e(t):void 0}var l_=sg,u_=lg,d_=pg,f_=_g,p_=Cg,m_=Tg,h_=Og,g_=jg,__=Fg,v_=Lg,y_=Vg,b_=Ug,x_=Gg,S_=Yg,C_=Zg,w_=$g,T_=`ContextMenu`,[E_,D_]=vu(T_,[eg]),O_=eg(),[k_,A_]=E_(T_),j_=e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,dir:i,modal:a=!0}=e,[o,s]=H.useState(!1),c=O_(t),l=Iu(r),u=H.useCallback(e=>{s(e),l(e)},[l]);return(0,W.jsx)(k_,{scope:t,open:o,onOpenChange:u,modal:a,children:(0,W.jsx)(l_,{...c,dir:i,open:o,onOpenChange:u,modal:a,children:n})})};j_.displayName=T_;var M_=`ContextMenuTrigger`,N_=H.forwardRef((e,t)=>{let{__scopeContextMenu:n,disabled:r=!1,...i}=e,a=A_(M_,n),o=O_(n),s=H.useRef({x:0,y:0}),c=H.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...s.current})}),l=H.useRef(0),u=H.useCallback(()=>window.clearTimeout(l.current),[]),d=e=>{s.current={x:e.clientX,y:e.clientY},a.onOpenChange(!0)};return H.useEffect(()=>u,[u]),H.useEffect(()=>void(r&&u()),[r,u]),(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(u_,{...o,virtualRef:c}),(0,W.jsx)(gu.span,{"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,...i,ref:t,style:{WebkitTouchCallout:`none`,...e.style},onContextMenu:r?e.onContextMenu:G(e.onContextMenu,e=>{u(),d(e),e.preventDefault()}),onPointerDown:r?e.onPointerDown:G(e.onPointerDown,ov(e=>{u(),l.current=window.setTimeout(()=>d(e),700)})),onPointerMove:r?e.onPointerMove:G(e.onPointerMove,ov(u)),onPointerCancel:r?e.onPointerCancel:G(e.onPointerCancel,ov(u)),onPointerUp:r?e.onPointerUp:G(e.onPointerUp,ov(u))})]})});N_.displayName=M_;var P_=`ContextMenuPortal`,F_=e=>{let{__scopeContextMenu:t,...n}=e,r=O_(t);return(0,W.jsx)(d_,{...r,...n})};F_.displayName=P_;var I_=`ContextMenuContent`,L_=H.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=A_(I_,n),a=O_(n),o=H.useRef(!1);return(0,W.jsx)(f_,{...a,...r,ref:t,side:`right`,sideOffset:2,align:`start`,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),!t.defaultPrevented&&o.current&&t.preventDefault(),o.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),!t.defaultPrevented&&!i.modal&&(o.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-context-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-context-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-context-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-context-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});L_.displayName=I_;var R_=`ContextMenuGroup`,z_=H.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=O_(n);return(0,W.jsx)(p_,{...i,...r,ref:t})});z_.displayName=R_;var B_=`ContextMenuLabel`,V_=H.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=O_(n);return(0,W.jsx)(m_,{...i,...r,ref:t})});V_.displayName=B_;var H_=`ContextMenuItem`,U_=H.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=O_(n);return(0,W.jsx)(h_,{...i,...r,ref:t})});U_.displayName=H_;var W_=`ContextMenuCheckboxItem`,G_=H.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=O_(n);return(0,W.jsx)(g_,{...i,...r,ref:t})});G_.displayName=W_;var K_=`ContextMenuRadioGroup`,q_=H.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=O_(n);return(0,W.jsx)(__,{...i,...r,ref:t})});q_.displayName=K_;var J_=`ContextMenuRadioItem`,Y_=H.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=O_(n);return(0,W.jsx)(v_,{...i,...r,ref:t})});Y_.displayName=J_;var X_=`ContextMenuItemIndicator`,Z_=H.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=O_(n);return(0,W.jsx)(y_,{...i,...r,ref:t})});Z_.displayName=X_;var Q_=`ContextMenuSeparator`,$_=H.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=O_(n);return(0,W.jsx)(b_,{...i,...r,ref:t})});$_.displayName=Q_;var ev=`ContextMenuArrow`,tv=H.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=O_(n);return(0,W.jsx)(x_,{...i,...r,ref:t})});tv.displayName=ev;var nv=`ContextMenuSubTrigger`,rv=H.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=O_(n);return(0,W.jsx)(C_,{...i,...r,ref:t})});rv.displayName=nv;var iv=`ContextMenuSubContent`,av=H.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=O_(n);return(0,W.jsx)(w_,{...i,...r,ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-context-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-context-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-context-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-context-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});av.displayName=iv;function ov(e){return t=>t.pointerType===`mouse`?void 0:e(t)}var sv=j_,cv=N_,lv=F_,uv=L_,dv=U_,fv=`DropdownMenu`,[pv,mv]=vu(fv,[eg]),hv=eg(),[gv,_v]=pv(fv),vv=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=hv(t),l=H.useRef(null),[u,d]=Cu({prop:i,defaultProp:a??!1,onChange:o,caller:fv});return(0,W.jsx)(gv,{scope:t,triggerId:Nu(),triggerRef:l,contentId:Nu(),open:u,onOpenChange:d,onOpenToggle:H.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,W.jsx)(l_,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};vv.displayName=fv;var yv=`DropdownMenuTrigger`,bv=H.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=_v(yv,n),o=hv(n);return(0,W.jsx)(u_,{asChild:!0,...o,children:(0,W.jsx)(gu.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:cu(t,a.triggerRef),onPointerDown:G(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:G(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});bv.displayName=yv;var xv=`DropdownMenuContent`,Sv=H.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=_v(xv,n),a=hv(n),o=H.useRef(!1);return(0,W.jsx)(f_,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:G(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:G(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Sv.displayName=xv;var Cv=`DropdownMenuGroup`,wv=H.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=hv(n);return(0,W.jsx)(p_,{...i,...r,ref:t})});wv.displayName=Cv;var Tv=`DropdownMenuLabel`,Ev=H.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=hv(n);return(0,W.jsx)(m_,{...i,...r,ref:t})});Ev.displayName=Tv;var Dv=`DropdownMenuItem`,Ov=H.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=hv(n);return(0,W.jsx)(h_,{...i,...r,ref:t})});Ov.displayName=Dv;var kv=`DropdownMenuCheckboxItem`,Av=H.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=hv(n);return(0,W.jsx)(g_,{...i,...r,ref:t})});Av.displayName=kv;var jv=`DropdownMenuRadioGroup`,Mv=H.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=hv(n);return(0,W.jsx)(__,{...i,...r,ref:t})});Mv.displayName=jv;var Nv=`DropdownMenuRadioItem`,Pv=H.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=hv(n);return(0,W.jsx)(v_,{...i,...r,ref:t})});Pv.displayName=Nv;var Fv=`DropdownMenuItemIndicator`,Iv=H.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=hv(n);return(0,W.jsx)(y_,{...i,...r,ref:t})});Iv.displayName=Fv;var Lv=`DropdownMenuSeparator`,Rv=H.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=hv(n);return(0,W.jsx)(b_,{...i,...r,ref:t})});Rv.displayName=Lv;var zv=`DropdownMenuArrow`,Bv=H.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=hv(n);return(0,W.jsx)(x_,{...i,...r,ref:t})});Bv.displayName=zv;var Vv=e=>{let{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:a}=e,o=hv(t),[s,c]=Cu({prop:r,defaultProp:a??!1,onChange:i,caller:`DropdownMenuSub`});return(0,W.jsx)(S_,{...o,open:s,onOpenChange:c,children:n})},Hv=`DropdownMenuSubTrigger`,Uv=H.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=hv(n);return(0,W.jsx)(C_,{...i,...r,ref:t})});Uv.displayName=Hv;var Wv=`DropdownMenuSubContent`,Gv=H.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=hv(n);return(0,W.jsx)(w_,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Gv.displayName=Wv;var Kv=vv,qv=bv,Jv=Sv,Yv=Ov,Xv=Vv,Zv=Uv,Qv=Gv,$v=`Popover`,[ey,ty]=vu($v,[nh]),ny=nh(),[ry,iy]=ey($v),ay=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=ny(t),c=H.useRef(null),[l,u]=H.useState(!1),[d,f]=Cu({prop:r,defaultProp:i??!1,onChange:a,caller:$v});return(0,W.jsx)(vh,{...s,children:(0,W.jsx)(ry,{scope:t,contentId:Nu(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:H.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:H.useCallback(()=>u(!0),[]),onCustomAnchorRemove:H.useCallback(()=>u(!1),[]),modal:o,children:n})})};ay.displayName=$v;var oy=`PopoverAnchor`,sy=H.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=iy(oy,n),a=ny(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return H.useEffect(()=>(o(),()=>s()),[o,s]),(0,W.jsx)(yh,{...a,...r,ref:t})});sy.displayName=oy;var cy=`PopoverTrigger`,ly=H.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=iy(cy,n),a=ny(n),o=lu(t,i.triggerRef),s=(0,W.jsx)(gu.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":wy(i.open),...r,ref:o,onClick:G(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,W.jsx)(yh,{asChild:!0,...a,children:s})});ly.displayName=cy;var uy=`PopoverPortal`,[dy,fy]=ey(uy,{forceMount:void 0}),py=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=iy(uy,t);return(0,W.jsx)(dy,{scope:t,forceMount:n,children:(0,W.jsx)(Du,{present:n||a.open,children:(0,W.jsx)(md,{asChild:!0,container:i,children:r})})})};py.displayName=uy;var my=`PopoverContent`,hy=H.forwardRef((e,t)=>{let n=fy(my,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=iy(my,e.__scopePopover);return(0,W.jsx)(Du,{present:r||a.open,children:a.modal?(0,W.jsx)(_y,{...i,ref:t}):(0,W.jsx)(vy,{...i,ref:t})})});hy.displayName=my;var gy=uu(`PopoverContent.RemoveScroll`),_y=H.forwardRef((e,t)=>{let n=iy(my,e.__scopePopover),r=H.useRef(null),i=lu(t,r),a=H.useRef(!1);return H.useEffect(()=>{let e=r.current;if(e)return Ff(e)},[]),(0,W.jsx)(Ef,{as:gy,allowPinchZoom:!0,children:(0,W.jsx)(yy,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:G(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:G(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:G(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),vy=H.forwardRef((e,t)=>{let n=iy(my,e.__scopePopover),r=H.useRef(!1),i=H.useRef(!1);return(0,W.jsx)(yy,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),yy=H.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=iy(my,n),p=ny(n);return gd(),(0,W.jsx)(td,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,W.jsx)(Wu,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),children:(0,W.jsx)(bh,{"data-state":wy(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),by=`PopoverClose`,xy=H.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=iy(by,n);return(0,W.jsx)(gu.button,{type:`button`,...r,ref:t,onClick:G(e.onClick,()=>i.onOpenChange(!1))})});xy.displayName=by;var Sy=`PopoverArrow`,Cy=H.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=ny(n);return(0,W.jsx)(xh,{...i,...r,ref:t})});Cy.displayName=Sy;function wy(e){return e?`open`:`closed`}var Ty=ay,Ey=ly,Dy=py,Oy=hy,ky=xy,Ay=Cy,jy=`Tabs`,[My,Ny]=vu(jy,[kh]),Py=kh(),[Fy,Iy]=My(jy),Ly=H.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=Fu(s),[d,f]=Cu({prop:r,onChange:i,defaultProp:a??``,caller:jy});return(0,W.jsx)(Fy,{scope:n,baseId:Nu(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,W.jsx)(gu.div,{dir:u,"data-orientation":o,...l,ref:t})})});Ly.displayName=jy;var Ry=`TabsList`,zy=H.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=Iy(Ry,n),o=Py(n);return(0,W.jsx)(Vh,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,W.jsx)(gu.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})});zy.displayName=Ry;var By=`TabsTrigger`,Vy=H.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=Iy(By,n),s=Py(n),c=Wy(o.baseId,r),l=Gy(o.baseId,r),u=r===o.value;return(0,W.jsx)(Hh,{asChild:!0,...s,focusable:!i,active:u,children:(0,W.jsx)(gu.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:G(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:G(e.onKeyDown,e=>{[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:G(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})});Vy.displayName=By;var Hy=`TabsContent`,Uy=H.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=Iy(Hy,n),c=Wy(s.baseId,r),l=Gy(s.baseId,r),u=r===s.value,d=H.useRef(u);return H.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,W.jsx)(Du,{present:i||u,children:({present:n})=>(0,W.jsx)(gu.div,{"data-state":u?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?`0s`:void 0},children:n&&a})})});Uy.displayName=Hy;function Wy(e,t){return`${e}-trigger-${t}`}function Gy(e,t){return`${e}-content-${t}`}var Ky=Ly,qy=zy,Jy=Vy,Yy=Uy,Xy=e(t(((e,t)=>{(function(){var n=this,r={};e===void 0?n.fuzzy=r:t.exports=r,r.simpleFilter=function(e,t){return t.filter(function(t){return r.test(e,t)})},r.test=function(e,t){return r.match(e,t)!==null},r.match=function(e,t,n){n||={};var r=0,i=[],a=t.length,o=0,s=0,c=n.pre||``,l=n.post||``,u=n.caseSensitive&&t||t.toLowerCase(),d;e=n.caseSensitive&&e||e.toLowerCase();for(var f=0;f<a;f++)d=t[f],u[f]===e[r]?(d=c+d+l,r+=1,s+=1+s):s=0,o+=s,i[i.length]=d;return r===e.length?(o=u===e?1/0:o,{rendered:i.join(``),score:o}):null},r.filter=function(e,t,n){return!t||t.length===0?[]:typeof e==`string`?(n||={},t.reduce(function(t,i,a,o){var s=i;n.extract&&(s=n.extract(i));var c=r.match(e,s,n);return c!=null&&(t[t.length]={string:c.rendered,score:c.score,index:a,original:i}),t},[]).sort(function(e,t){return t.score-e.score||e.index-t.index})):t}})()}))(),1);function Zy(e,t){return(e[0]-t[0])**2+(e[1]-t[1])**2}function Qy(e,t,n){let r=Zy(t,n);if(r===0)return Zy(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)),Zy(e,$y(t,n,i))}function $y(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n]}function eb(e,t){return tb(e,0,e.length,t)}function tb(e,t,n,r,i){let a=i||[],o=e[t],s=e[n-1],c=0,l=1;for(let r=t+1;r<n-1;++r){let t=Qy(e[r],o,s);t>c&&(c=t,l=r)}return Math.sqrt(c)>r?(tb(e,t,l+1,r,a),tb(e,l,n,r,a)):(a.length||a.push(o),a.push(s)),a}function nb(e,t,n,r=e=>e){return e*r(.5-t*(.5-n))}function rb(e){return[-e[0],-e[1]]}function ib(e,t){return[e[0]+t[0],e[1]+t[1]]}function ab(e,t){return[e[0]-t[0],e[1]-t[1]]}function ob(e,t){return[e[0]*t,e[1]*t]}function sb(e,t){return[e[0]/t,e[1]/t]}function cb(e){return[e[1],-e[0]]}function lb(e,t){return e[0]*t[0]+e[1]*t[1]}function ub(e,t){return e[0]===t[0]&&e[1]===t[1]}function db(e){return Math.hypot(e[0],e[1])}function fb(e){return e[0]*e[0]+e[1]*e[1]}function pb(e,t){return fb(ab(e,t))}function mb(e){return sb(e,db(e))}function hb(e,t){return Math.hypot(e[1]-t[1],e[0]-t[0])}function gb(e,t,n){let r=Math.sin(n),i=Math.cos(n),a=e[0]-t[0],o=e[1]-t[1],s=a*i-o*r,c=a*r+o*i;return[s+t[0],c+t[1]]}function _b(e,t,n){return ib(e,ob(ab(t,e),n))}function vb(e,t,n){return ib(e,ob(t,n))}var{min:yb,PI:bb}=Math,xb=.275,Sb=bb+1e-4;function Cb(e,t={}){let{size:n=16,smoothing:r=.5,thinning:i=.5,simulatePressure:a=!0,easing:o=e=>e,start:s={},end:c={},last:l=!1}=t,{cap:u=!0,easing:d=e=>e*(2-e)}=s,{cap:f=!0,easing:p=e=>--e*e*e+1}=c;if(e.length===0||n<=0)return[];let m=e[e.length-1].runningLength,h=s.taper===!1?0:s.taper===!0?Math.max(n,m):s.taper,g=c.taper===!1?0:c.taper===!0?Math.max(n,m):c.taper,_=(n*r)**2,v=[],y=[],b=e.slice(0,10).reduce((e,t)=>{let r=t.pressure;if(a){let i=yb(1,t.distance/n);r=yb(1,e+(yb(1,1-i)-e)*(i*xb))}return(e+r)/2},e[0].pressure),x=nb(n,i,e[e.length-1].pressure,o),S,C=e[0].vector,w=e[0].point,T=w,E=w,D=T,ee=!1;for(let t=0;t<e.length;t++){let{pressure:r}=e[t],{point:s,vector:c,distance:l,runningLength:u}=e[t];if(t<e.length-1&&m-u<3)continue;if(i){if(a){let e=yb(1,l/n),t=yb(1,1-e);r=yb(1,b+(t-b)*(e*xb))}x=nb(n,i,r,o)}else x=n/2;S===void 0&&(S=x);let f=u<h?d(u/h):1,te=m-u<g?p((m-u)/g):1;x=Math.max(.01,x*Math.min(f,te));let O=(t<e.length-1?e[t+1]:e[t]).vector,k=t<e.length-1?lb(c,O):1,A=lb(c,C)<0&&!ee,ne=k!==null&&k<0;if(A||ne){let e=ob(cb(C),x);for(let t=0;t<=1;t+=.07692307692307693)E=gb(ab(s,e),s,Sb*t),v.push(E),D=gb(ib(s,e),s,Sb*-t),y.push(D);w=E,T=D,ne&&(ee=!0);continue}if(ee=!1,t===e.length-1){let e=ob(cb(c),x);v.push(ab(s,e)),y.push(ib(s,e));continue}let re=ob(cb(_b(O,c,k)),x);E=ab(s,re),(t<=1||pb(w,E)>_)&&(v.push(E),w=E),D=ib(s,re),(t<=1||pb(T,D)>_)&&(y.push(D),T=D),b=r,C=c}let te=e[0].point.slice(0,2),O=e.length>1?e[e.length-1].point.slice(0,2):ib(e[0].point,[1,1]),k=[],A=[];if(e.length===1){if(!(h||g)||l){let e=vb(te,mb(cb(ab(te,O))),-(S||x)),t=[];for(let n=1/13,r=n;r<=1;r+=n)t.push(gb(e,te,Sb*2*r));return t}}else{if(!(h||g&&e.length===1)){if(u)for(let e=1/13,t=e;t<=1;t+=e){let e=gb(y[0],te,Sb*t);k.push(e)}else{let e=ab(v[0],y[0]),t=ob(e,.5),n=ob(e,.51);k.push(ab(te,t),ab(te,n),ib(te,n),ib(te,t))}}let t=cb(rb(e[e.length-1].vector));if(g||h&&e.length===1)A.push(O);else if(f){let e=vb(O,t,x);for(let t=1/29,n=t;n<1;n+=t)A.push(gb(e,O,Sb*3*n))}else A.push(ib(O,ob(t,x)),ib(O,ob(t,x*.99)),ab(O,ob(t,x*.99)),ab(O,ob(t,x)))}return v.concat(A,y.reverse(),k)}function wb(e,t={}){let{streamline:n=.5,size:r=16,last:i=!1}=t;if(e.length===0)return[];let a=.15+(1-n)*.85,o=Array.isArray(e[0])?e:e.map(({x:e,y:t,pressure:n=.5})=>[e,t,n]);if(o.length===2){let e=o[1];o=o.slice(0,-1);for(let t=1;t<5;t++)o.push(_b(o[0],e,t/4))}o.length===1&&(o=[...o,[...ib(o[0],[1,1]),...o[0].slice(2)]]);let s=[{point:[o[0][0],o[0][1]],pressure:o[0][2]>=0?o[0][2]:.25,vector:[1,1],distance:0,runningLength:0}],c=!1,l=0,u=s[0],d=o.length-1;for(let e=1;e<o.length;e++){let t=i&&e===d?o[e].slice(0,2):_b(u.point,o[e],a);if(ub(u.point,t))continue;let n=hb(t,u.point);if(l+=n,e<d&&!c){if(l<r)continue;c=!0}u={point:t,pressure:o[e][2]>=0?o[e][2]:.5,vector:mb(ab(u.point,t)),distance:n,runningLength:l},s.push(u)}return s[0].vector=s[1]?.vector||[0,0],s}function Tb(e,t={}){return Cb(wb(e,t),t)}var Eb=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},Db=e=>e?Eb(e):Eb,Ob=t((e=>{var t=r(),n=Lf();function i(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:i,o=n.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),kb=e(t(((e,t)=>{t.exports=Ob()}))(),1),{useDebugValue:Ab}=H.default,{useSyncExternalStoreWithSelector:jb}=kb.default,Mb=e=>e;function Nb(e,t=Mb,n){let r=jb(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Ab(r),r}var Pb=e=>{let t=typeof e==`function`?Db(e):e,n=(e,n)=>Nb(t,e,n);return Object.assign(n,t),n},Fb=e=>e?Pb(e):Pb,Ib,Lb=typeof window<`u`&&((Ib=window.document)!=null&&Ib.createElement||window.navigator?.product===`ReactNative`)?H.useLayoutEffect:H.useEffect;function Rb(){let e=Fb(e=>({current:[],version:0,set:e}));return{In:({children:t})=>{let n=e(e=>e.set),r=e(e=>e.version);return Lb(()=>{n(e=>({version:e.version+1}))},[]),Lb(()=>(n(({current:e})=>({current:[...e,t]})),()=>n(({current:e})=>({current:e.filter(e=>e!==t)}))),[t,r]),null},Out:()=>{let t=e(e=>e.current);return H.createElement(H.Fragment,null,t)}}}var zb=e(t(((e,t)=>{var n=NaN,r=/^\s+|\s+$/g,i=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,o=/^0o[0-7]+$/i,s=parseInt,c=typeof global==`object`&&global&&global.Object===Object&&global,l=typeof self==`object`&&self&&self.Object===Object&&self,u=c||l||Function(`return this`)(),d=Object.prototype.toString,f=Math.max,p=Math.min,m=function(){return u.Date.now()};function h(e,t,n){var r,i,a,o,s,c,l=0,u=!1,d=!1,h=!0;if(typeof e!=`function`)throw TypeError(`Expected a function`);t=y(t)||0,g(n)&&(u=!!n.leading,d=`maxWait`in n,a=d?f(y(n.maxWait)||0,t):a,h=`trailing`in n?!!n.trailing:h);function _(t){var n=r,a=i;return r=i=void 0,l=t,o=e.apply(a,n),o}function v(e){return l=e,s=setTimeout(S,t),u?_(e):o}function b(e){var n=e-c,r=e-l,i=t-n;return d?p(i,a-r):i}function x(e){var n=e-c,r=e-l;return c===void 0||n>=t||n<0||d&&r>=a}function S(){var e=m();if(x(e))return C(e);s=setTimeout(S,b(e))}function C(e){return s=void 0,h&&r?_(e):(r=i=void 0,o)}function w(){s!==void 0&&clearTimeout(s),l=0,r=c=i=s=void 0}function T(){return s===void 0?o:C(m())}function E(){var e=m(),n=x(e);if(r=arguments,i=this,c=e,n){if(s===void 0)return v(c);if(d)return s=setTimeout(S,t),_(c)}return s===void 0&&(s=setTimeout(S,t)),o}return E.cancel=w,E.flush=T,E}function g(e){var t=typeof e;return!!e&&(t==`object`||t==`function`)}function _(e){return!!e&&typeof e==`object`}function v(e){return typeof e==`symbol`||_(e)&&d.call(e)==`[object Symbol]`}function y(e){if(typeof e==`number`)return e;if(v(e))return n;if(g(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=g(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=e.replace(r,``);var c=a.test(e);return c||o.test(e)?s(e.slice(2),c?2:8):i.test(e)?n:+e}t.exports=h}))(),1),Bb=iu(),{useAtom:Vb,useSetAtom:Hb,useAtomValue:Ub,useStore:Wb}=Bb,Gb=Bb.Provider,Kb=Vl(),qb=cl({"./locales/ar-SA.json":()=>n(()=>import(`./ar-SA-5WIASEJP-Di7OimCN.js`),[],import.meta.url),"./locales/az-AZ.json":()=>n(()=>import(`./az-AZ-V5EUQD6C-C19OGTT_.js`),[],import.meta.url),"./locales/bg-BG.json":()=>n(()=>import(`./bg-BG-EXASCMTR-BIt0xWyb.js`),[],import.meta.url),"./locales/bn-BD.json":()=>n(()=>import(`./bn-BD-U4SYNFCO-CdNaPy4Q.js`),[],import.meta.url),"./locales/bn-IN.json":()=>n(()=>import(`./bn-IN-HKDJIITE-CdNaPy4Q.js`),[],import.meta.url),"./locales/ca-ES.json":()=>n(()=>import(`./ca-ES-2KGUU5XB-C9t-c0cH.js`),[],import.meta.url),"./locales/cs-CZ.json":()=>n(()=>import(`./cs-CZ-VUCGPRML-BfCoYAgj.js`),[],import.meta.url),"./locales/da-DK.json":()=>n(()=>import(`./da-DK-NNDP2IVP-DBw9ZNTR.js`),[],import.meta.url),"./locales/de-CH.json":()=>n(()=>import(`./de-CH-I7RAVIZN-DYW18Vsr.js`),[],import.meta.url),"./locales/de-DE.json":()=>n(()=>import(`./de-DE-WBQ3DQLR-DYW18Vsr.js`),[],import.meta.url),"./locales/el-GR.json":()=>n(()=>import(`./el-GR-TYQHVGXW-Dx82YYAS.js`),[],import.meta.url),"./locales/en.json":()=>n(()=>import(`./en-JTHJ2SIP-DBz9bRq4.js`),[],import.meta.url),"./locales/es-ES.json":()=>n(()=>import(`./es-ES-JEUOREKJ-Rx0NUQDl.js`),[],import.meta.url),"./locales/eu-ES.json":()=>n(()=>import(`./eu-ES-SO5DEEAN-CDYm-BcK.js`),[],import.meta.url),"./locales/fa-IR.json":()=>n(()=>import(`./fa-IR-I4JNTJHK-CFtHZqoT.js`),[],import.meta.url),"./locales/fi-FI.json":()=>n(()=>import(`./fi-FI-REAEF6HQ-BIpjJqIb.js`),[],import.meta.url),"./locales/fr-FR.json":()=>n(()=>import(`./fr-FR-SUCL7J6B-DGAKE8jH.js`),[],import.meta.url),"./locales/gl-ES.json":()=>n(()=>import(`./gl-ES-KHCSOGVH-DWKh0CMu.js`),[],import.meta.url),"./locales/he-IL.json":()=>n(()=>import(`./he-IL-JYXVXV2Q-zqbcM-4g.js`),[],import.meta.url),"./locales/hi-IN.json":()=>n(()=>import(`./hi-IN-BU52H3BO-CY8v6eG9.js`),[],import.meta.url),"./locales/hu-HU.json":()=>n(()=>import(`./hu-HU-OWADXDQ3-CEl6Udfh.js`),[],import.meta.url),"./locales/id-ID.json":()=>n(()=>import(`./id-ID-2WY7E4VX-CCAeQpPr.js`),[],import.meta.url),"./locales/it-IT.json":()=>n(()=>import(`./it-IT-INVHSAJF-DytAgndh.js`),[],import.meta.url),"./locales/ja-JP.json":()=>n(()=>import(`./ja-JP-JBNTKYP4-BflWlGhw.js`),[],import.meta.url),"./locales/kaa.json":()=>n(()=>import(`./kaa-TC3VIB7V-B-xtZfy0.js`),[],import.meta.url),"./locales/kab-KAB.json":()=>n(()=>import(`./kab-KAB-UOUDSQKM-BmO0O4Y4.js`),[],import.meta.url),"./locales/kk-KZ.json":()=>n(()=>import(`./kk-KZ-P5H2X7YS-CSQFB8IN.js`),[],import.meta.url),"./locales/km-KH.json":()=>n(()=>import(`./km-KH-IHMV2US7-BxrjuEzr.js`),[],import.meta.url),"./locales/ko-KR.json":()=>n(()=>import(`./ko-KR-ZTMANIDF-BnNRXd5J.js`),[],import.meta.url),"./locales/ku-TR.json":()=>n(()=>import(`./ku-TR-GPJTRB5G-BZM7f2aT.js`),[],import.meta.url),"./locales/lt-LT.json":()=>n(()=>import(`./lt-LT-V3XDOK3P-MVQBOHmF.js`),[],import.meta.url),"./locales/lv-LV.json":()=>n(()=>import(`./lv-LV-DVQ3FADO-CrenwAhS.js`),[],import.meta.url),"./locales/mr-IN.json":()=>n(()=>import(`./mr-IN-VZ6HH5FE-B-PHPglH.js`),[],import.meta.url),"./locales/my-MM.json":()=>n(()=>import(`./my-MM-XYKWHRK6-Be5sYp5q.js`),[],import.meta.url),"./locales/nb-NO.json":()=>n(()=>import(`./nb-NO-UNO2GGZJ-BvSKGdja.js`),[],import.meta.url),"./locales/nl-NL.json":()=>n(()=>import(`./nl-NL-76EFHT4P-C2yNx1Cj.js`),[],import.meta.url),"./locales/nn-NO.json":()=>n(()=>import(`./nn-NO-CFKD7ABE-4NsqlDRP.js`),[],import.meta.url),"./locales/oc-FR.json":()=>n(()=>import(`./oc-FR-YBJTCJ3J-B4OTQsWW.js`),[],import.meta.url),"./locales/pa-IN.json":()=>n(()=>import(`./pa-IN-SNOXSMRV-CKj_sOG7.js`),[],import.meta.url),"./locales/percentages.json":()=>n(()=>import(`./percentages-LWOC67ZH-VhvllE7L.js`),[],import.meta.url),"./locales/pl-PL.json":()=>n(()=>import(`./pl-PL-BSY6YFZ3-CFuzA6L0.js`),[],import.meta.url),"./locales/pt-BR.json":()=>n(()=>import(`./pt-BR-CZDV62R3-CkPMtyNx.js`),[],import.meta.url),"./locales/pt-PT.json":()=>n(()=>import(`./pt-PT-JO57XJJW-CBSnfGtF.js`),[],import.meta.url),"./locales/ro-RO.json":()=>n(()=>import(`./ro-RO-UZ5ICYYN-BOuntc_r.js`),[],import.meta.url),"./locales/ru-RU.json":()=>n(()=>import(`./ru-RU-AN7JPREC-D-ow3SNR.js`),[],import.meta.url),"./locales/si-LK.json":()=>n(()=>import(`./si-LK-7CBLD6QQ-c91EepX0.js`),[],import.meta.url),"./locales/sk-SK.json":()=>n(()=>import(`./sk-SK-SWR6DKBI-D5vFMIL6.js`),[],import.meta.url),"./locales/sl-SI.json":()=>n(()=>import(`./sl-SI-QY5KCFGA-RZhwMpQL.js`),[],import.meta.url),"./locales/sv-SE.json":()=>n(()=>import(`./sv-SE-O3OFCY3J-DnS86_7q.js`),[],import.meta.url),"./locales/ta-IN.json":()=>n(()=>import(`./ta-IN-V6NHHU6Z-D5jy7_AE.js`),[],import.meta.url),"./locales/th-TH.json":()=>n(()=>import(`./th-TH-WLSZUSBX-DHehoYR2.js`),[],import.meta.url),"./locales/tr-TR.json":()=>n(()=>import(`./tr-TR-GUFYG22B-ClVaf8h1.js`),[],import.meta.url),"./locales/uk-UA.json":()=>n(()=>import(`./uk-UA-K6SV5NFQ-BLTTtyNB.js`),[],import.meta.url),"./locales/uz-UZ.json":()=>n(()=>import(`./uz-UZ-TVKTZO2G-Bm02Eg3D.js`),[],import.meta.url),"./locales/vi-VN.json":()=>n(()=>import(`./vi-VN-7FKFXJNO-CL3WPhmG.js`),[],import.meta.url),"./locales/zh-CN.json":()=>n(()=>import(`./zh-CN-AOKVLNNK-DGidDH2b.js`),[],import.meta.url),"./locales/zh-HK.json":()=>n(()=>import(`./zh-HK-CDKPF5DC-CRcNR3rk.js`),[],import.meta.url),"./locales/zh-TW.json":()=>n(()=>import(`./zh-TW-ZVGYESGW-C7Qji1y6.js`),[],import.meta.url)}),Jb=85,Yb={code:`en`,label:`English`},Xb=[Yb,...[{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=>dl[e.code]>=Jb).sort((e,t)=>e.label>t.label?1:-1)],Zb=`__test__`;rt()&&Xb.unshift({code:Zb,label:`test language`},{code:`${Zb}.rtl`,label:`test language (rtl)`,rtl:!0});var Qb=Yb,$b={},ex=async e=>{if(Qb=e,document.documentElement.dir=Qb.rtl?`rtl`:`ltr`,document.documentElement.lang=Qb.code,e.code.startsWith(Zb))$b={};else try{$b=await qb(`./locales/${Qb.code}.json`)}catch(t){console.error(`Failed to load language ${e.code}:`,t.message),$b=ul}Kb.set(rx,e.code)},tx=()=>Qb,nx=(e,t)=>{for(let n=0;n<t.length;++n){let r=t[n];if(e[r]===void 0)return;e=e[r]}if(typeof e==`string`)return e},K=(e,t,n)=>{if(Qb.code.startsWith(Zb))return`\u202A[[${t?`${e}(${JSON.stringify(t).slice(1,-1)})`:e}]]\u202C`;let r=e.split(`.`),i=nx($b,r)||nx(ul,r)||n;if(i===void 0){let t=`Can't find translation for ${e}`;if(xa.PROD)return console.warn(t),``;throw Error(t)}if(t)for(let e in t)i=i.replace(`{{${e}}}`,String(t[e]));return i},rx=yl(Yb.code),ix=()=>({t:K,langCode:Ub(rx)}),ax=e=>`var(--icon-fill-color)`,ox=e=>e===P.LIGHT?`#fff`:`#1e1e1e`,q=(e,t=512)=>{let{width:n=512,height:r=n,mirror:i,style:a,...o}=typeof t==`number`?{width:t}:t;return(0,W.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,role:`img`,viewBox:`0 0 ${n} ${r}`,className:U({"rtl-mirror":i}),style:a,...o,children:typeof e==`string`?(0,W.jsx)(`path`,{fill:`currentColor`,d:e}):e})},J={width:24,height:24,fill:`none`,strokeWidth:2,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`},Y={width:20,height:20,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`},sx={width:40,height:20};q((0,W.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`rect`,{x:3,y:8,width:18,height:4,rx:1}),(0,W.jsx)(`line`,{x1:12,y1:8,x2:12,y2:21}),(0,W.jsx)(`path`,{d:`M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7`}),(0,W.jsx)(`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`})]}),J);var cx=q((0,W.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0`}),(0,W.jsx)(`path`,{d:`M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0`}),(0,W.jsx)(`line`,{x1:`3`,y1:`6`,x2:`3`,y2:`19`}),(0,W.jsx)(`line`,{x1:`12`,y1:`6`,x2:`12`,y2:`19`}),(0,W.jsx)(`line`,{x1:`21`,y1:`6`,x2:`21`,y2:`19`})]}),J),lx=q((0,W.jsxs)(`svg`,{strokeWidth:`1.5`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`line`,{x1:`12`,y1:`5`,x2:`12`,y2:`19`}),(0,W.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`})]}),J),ux=q((0,W.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1`}),(0,W.jsx)(`circle`,{cx:`12`,cy:`19`,r:`1`}),(0,W.jsx)(`circle`,{cx:`12`,cy:`5`,r:`1`})]}),J),dx=q((0,W.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M5 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`}),(0,W.jsx)(`path`,{d:`M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`}),(0,W.jsx)(`path`,{d:`M19 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`})]}),J),fx=q((0,W.jsxs)(`svg`,{strokeWidth:`1.5`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M9 4v6l-2 4v2h10v-2l-2 -4v-6`}),(0,W.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12`,y2:`21`}),(0,W.jsx)(`line`,{x1:`8`,y1:`4`,x2:`16`,y2:`4`})]}),J),px=q((0,W.jsxs)(`g`,{strokeWidth:1.25,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,W.jsx)(`path`,{d:`M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,W.jsx)(`path`,{d:`M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,W.jsx)(`path`,{d:`M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,W.jsx)(`path`,{d:`M6.5 9.5l3.5 -3`}),(0,W.jsx)(`path`,{d:`M14 5.5l3 1.5`}),(0,W.jsx)(`path`,{d:`M18.5 10l-2.5 7`}),(0,W.jsx)(`path`,{d:`M13.5 17.5l-7 -5`})]}),J),mx=q((0,W.jsxs)(`g`,{children:[(0,W.jsx)(`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`}),(0,W.jsx)(`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`}),(0,W.jsx)(`mask`,{id:`UnlockedIcon`,style:{maskType:`alpha`},maskUnits:`userSpaceOnUse`,x:6,y:1,width:9,height:9,children:(0,W.jsx)(`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`})}),(0,W.jsx)(`g`,{mask:`url(#UnlockedIcon)`,children:(0,W.jsx)(`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`})})]}),Y),hx=q((0,W.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,W.jsx)(`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`}),(0,W.jsx)(`path`,{d:`M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z`}),(0,W.jsx)(`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`})]}),Y),gx=q((0,W.jsx)(`g`,{fill:`currentColor`,children:(0,W.jsx)(`path`,{d:`M12 2a5 5 0 0 1 5 5v3a3 3 0 0 1 3 3v6a3 3 0 0 1 -3 3h-10a3 3 0 0 1 -3 -3v-6a3 3 0 0 1 3 -3v-3a5 5 0 0 1 5 -5m0 12a2 2 0 0 0 -1.995 1.85l-.005 .15a2 2 0 1 0 2 -2m0 -10a3 3 0 0 0 -3 3v3h6v-3a3 3 0 0 0 -3 -3`})}),{width:24,height:24}),_x=q((0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`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`}),(0,W.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z`,fill:`currentColor`}),(0,W.jsx)(`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`}),vx=q((0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`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`}),(0,W.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z`,fill:`currentColor`}),(0,W.jsx)(`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`}),yx=q((0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`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`}),(0,W.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z`,fill:`currentColor`}),(0,W.jsx)(`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`});q((0,W.jsx)(`g`,{fill:`currentColor`,children:(0,W.jsx)(`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`});var bx=q((0,W.jsxs)(`g`,{stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`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`}),(0,W.jsx)(`path`,{d:`M13.5 13.5l4.5 4.5`})]}),{fill:`none`,width:22,height:22,strokeWidth:1.25}),xx=q((0,W.jsxs)(`g`,{stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.5,children:[(0,W.jsx)(`path`,{d:`M4.028 13.252c-.657 -.972 -1.028 -2.078 -1.028 -3.252c0 -3.866 4.03 -7 9 -7s9 3.134 9 7s-4.03 7 -9 7c-1.913 0 -3.686 -.464 -5.144 -1.255`}),(0,W.jsx)(`path`,{d:`M5 15m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,W.jsx)(`path`,{d:`M5 17c0 1.42 .316 2.805 1 4`})]}),{fill:`none`,width:22,height:22,strokeWidth:1.25}),Sx=q((0,W.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`})]}),J),Cx=q((0,W.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`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`})]}),J),wx=q((0,W.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`})]}),J),Tx=q((0,W.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,W.jsx)(`line`,{x1:`15`,y1:`16`,x2:`19`,y2:`12`}),(0,W.jsx)(`line`,{x1:`15`,y1:`8`,x2:`19`,y2:`12`})]}),J),Ex=q((0,W.jsx)(`path`,{d:`M4.167 10h11.666`,strokeWidth:`1.5`}),Y),Dx=q((0,W.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z`}),(0,W.jsx)(`path`,{d:`M16 7h4`}),(0,W.jsx)(`path`,{d:`M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3`})]}),J),Ox=q((0,W.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,W.jsx)(`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`}),(0,W.jsx)(`path`,{d:`m11.25 5.417 3.333 3.333`})]}),Y),kx=q((0,W.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`line`,{x1:`4`,y1:`20`,x2:`7`,y2:`20`}),(0,W.jsx)(`line`,{x1:`14`,y1:`20`,x2:`21`,y2:`20`}),(0,W.jsx)(`line`,{x1:`6.9`,y1:`15`,x2:`13.8`,y2:`15`}),(0,W.jsx)(`line`,{x1:`10.2`,y1:`6.3`,x2:`16`,y2:`20`}),(0,W.jsx)(`polyline`,{points:`5 20 11 4 13 4 20 20`})]}),J),Ax=q((0,W.jsxs)(`g`,{stroke:`currentColor`,strokeWidth:`1.5`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M3 7v-2h13v2`}),(0,W.jsx)(`path`,{d:`M10 5v14`}),(0,W.jsx)(`path`,{d:`M12 19h-4`}),(0,W.jsx)(`path`,{d:`M15 13v-1h6v1`}),(0,W.jsx)(`path`,{d:`M18 12v7`}),(0,W.jsx)(`path`,{d:`M17 19h2`})]}),J),jx=q((0,W.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,W.jsx)(`path`,{d:`M12.5 6.667h.01`}),(0,W.jsx)(`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`}),(0,W.jsx)(`path`,{d:`m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166`}),(0,W.jsx)(`path`,{d:`m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667`})]}),Y),Mx=q((0,W.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`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`}),(0,W.jsx)(`path`,{d:`M18 13.3l-6.3 -6.3`})]}),J),Nx=q((0,W.jsx)(`path`,{strokeWidth:`1.25`,d:`M10 4.167v11.666M4.167 10h11.666`}),Y),Px=q((0,W.jsx)(`path`,{d:`M5 10h10`,strokeWidth:`1.25`}),Y),Fx=q((0,W.jsxs)(`g`,{strokeWidth:1.25,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M21 21l-6 -6`}),(0,W.jsx)(`path`,{d:`M3.268 12.043a7.017 7.017 0 0 0 6.634 4.957a7.012 7.012 0 0 0 7.043 -6.131a7 7 0 0 0 -5.314 -7.672a7.021 7.021 0 0 0 -8.241 4.403`}),(0,W.jsx)(`path`,{d:`M3 4v4h4`})]}),J),Ix=q((0,W.jsx)(`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`}),Y),Lx=q((0,W.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,W.jsx)(`polyline`,{points:`12 16 18 10 12 4`}),(0,W.jsx)(`polyline`,{points:`8 4 2 10 8 16`})]}),Y),Rx=q((0,W.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,W.jsx)(`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`}),(0,W.jsx)(`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`})]}),Y),zx=q((0,W.jsx)(`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`}),Y),Bx=q((0,W.jsx)(`g`,{stroke:`currentColor`,strokeLinejoin:`round`,children:(0,W.jsx)(`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`})}),{...Y,strokeWidth:1.5}),Vx=q((0,W.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`line`,{x1:`4`,y1:`6`,x2:`20`,y2:`6`}),(0,W.jsx)(`line`,{x1:`4`,y1:`12`,x2:`20`,y2:`12`}),(0,W.jsx)(`line`,{x1:`4`,y1:`18`,x2:`20`,y2:`18`})]}),J),Hx=q((0,W.jsx)(`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`}),Y),Ux=q((0,W.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,W.jsx)(`line`,{x1:`12`,y1:`17`,x2:`12`,y2:`17.01`}),(0,W.jsx)(`path`,{d:`M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4`})]}),J),Wx=q((0,W.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,W.jsx)(`line`,{x1:`12`,y1:`17`,x2:`12`,y2:`17.01`}),(0,W.jsx)(`path`,{d:`M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4`})]}),J),Gx=q((0,W.jsx)(`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`}),Y),Kx=q((0,W.jsx)(`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`}),Y),qx=q((0,W.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,W.jsx)(`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`}),(0,W.jsx)(`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`})]}),Y),Jx=q((0,W.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M4 4l11.733 16h4.267l-11.733 -16z`}),(0,W.jsx)(`path`,{d:`M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772`})]}),J),Yx=q((0,W.jsx)(`polyline`,{fill:`none`,stroke:`currentColor`,points:`20 6 9 17 4 12`}),{width:24,height:24}),Xx=q((0,W.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,W.jsx)(`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`}),(0,W.jsx)(`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`})]}),Y),Zx=q(`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}),Qx=q(`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}),$x=q((0,W.jsx)(`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`}),Y);q(`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}),q(`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`);var eS=[`M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z`,`M13.737 9.737c2.299 -2.3 3.23 -5.095 2.081 -6.245c-1.15 -1.15 -3.945 -.217 -6.244 2.082c-2.3 2.299 -3.231 5.095 -2.082 6.244c1.15 1.15 3.946 .218 6.245 -2.081z`,`M7.492 11.818c.362 .362 .768 .676 1.208 .934l6.895 4.047c1.078 .557 2.255 -.075 3.692 -1.512c1.437 -1.437 2.07 -2.614 1.512 -3.692c-.372 -.718 -1.72 -3.017 -4.047 -6.895a6.015 6.015 0 0 0 -.934 -1.208`],tS=q((0,W.jsxs)(`g`,{strokeWidth:1.25,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),eS.map(e=>(0,W.jsx)(`path`,{d:e},e))]}),J),nS=q((0,W.jsx)(`g`,{strokeWidth:1.5,children:(0,W.jsx)(`path`,{d:`M6 18l12 -12`})}),J),rS=q((0,W.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M15 8h.01`}),(0,W.jsx)(`path`,{d:`M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5`}),(0,W.jsx)(`path`,{d:`M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4`}),(0,W.jsx)(`path`,{d:`M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598`}),(0,W.jsx)(`path`,{d:`M19 16v6`}),(0,W.jsx)(`path`,{d:`M22 19l-3 3l-3 -3`})]}),J),iS=q(`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});q(`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}),q(`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});var aS=q(`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`);q(`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`);var oS=q((0,W.jsx)(`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`}),Y),sS=q((0,W.jsx)(`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`}),Y),cS=q(`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}),lS=q((0,W.jsx)(`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`}),Y);q(`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`),q(`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}),q((0,W.jsxs)(`g`,{strokeWidth:1.25,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M8 9h-1a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-8a2 2 0 0 0 -2 -2h-1`}),(0,W.jsx)(`path`,{d:`M12 14v-11`}),(0,W.jsx)(`path`,{d:`M9 6l3 -3l3 3`})]}),J),q((0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`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`}),(0,W.jsx)(`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}),q((0,W.jsx)(`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});var uS=(0,W.jsxs)(`g`,{strokeWidth:1.5,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M12 10l0 10`}),(0,W.jsx)(`path`,{d:`M12 10l4 4`}),(0,W.jsx)(`path`,{d:`M12 10l-4 4`}),(0,W.jsx)(`path`,{d:`M4 4l16 0`})]}),dS=(0,W.jsxs)(`g`,{strokeWidth:1.5,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M12 5l0 14`}),(0,W.jsx)(`path`,{d:`M16 9l-4 -4`}),(0,W.jsx)(`path`,{d:`M8 9l4 -4`})]}),fS=q(dS,J),pS=q(dS,{...J,style:{transform:`rotate(180deg)`}}),mS=q(uS,J),hS=q(uS,{...J,style:{transform:`rotate(180deg)`}}),gS=q((0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`g`,{clipPath:`url(#a)`,stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,W.jsx)(`path`,{d:`M3.333 3.333h13.334`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,W.jsx)(`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`})]}),(0,W.jsx)(`defs`,{children:(0,W.jsx)(`clipPath`,{id:`a`,children:(0,W.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),Y),_S=q((0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`g`,{clipPath:`url(#a)`,stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,W.jsx)(`path`,{d:`M3.333 16.667h13.334`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,W.jsx)(`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`})]}),(0,W.jsx)(`defs`,{children:(0,W.jsx)(`clipPath`,{id:`a`,children:(0,W.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),Y),vS=q((0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`g`,{clipPath:`url(#a)`,stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,W.jsx)(`path`,{d:`M3.333 3.333v13.334`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,W.jsx)(`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`})]}),(0,W.jsx)(`defs`,{children:(0,W.jsx)(`clipPath`,{id:`a`,children:(0,W.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),Y),yS=q((0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`g`,{clipPath:`url(#a)`,stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,W.jsx)(`path`,{d:`M16.667 3.333v13.334`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,W.jsx)(`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`})]}),(0,W.jsx)(`defs`,{children:(0,W.jsx)(`clipPath`,{id:`a`,children:(0,W.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),Y),bS=q((0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`g`,{clipPath:`url(#a)`,stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,W.jsx)(`path`,{d:`M16.667 3.333v13.334M3.333 3.333v13.334`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,W.jsx)(`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`})]}),(0,W.jsx)(`defs`,{children:(0,W.jsx)(`clipPath`,{id:`a`,children:(0,W.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),Y),xS=q((0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`g`,{clipPath:`url(#a)`,stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,W.jsx)(`path`,{d:`M3.333 3.333h13.334M3.333 16.667h13.334`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,W.jsx)(`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`})]}),(0,W.jsx)(`defs`,{children:(0,W.jsx)(`clipPath`,{id:`a`,children:(0,W.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),Y),SS=q((0,W.jsxs)(`g`,{stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,W.jsx)(`path`,{d:`M1.667 10h2.916`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,W.jsx)(`path`,{d:`M8.333 10h3.334`,strokeLinejoin:`round`}),(0,W.jsx)(`path`,{d:`M15.417 10h2.916`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,W.jsx)(`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`})]}),Y),CS=q((0,W.jsxs)(`g`,{stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,W.jsx)(`path`,{d:`M10 18.333v-2.916`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,W.jsx)(`path`,{d:`M10 11.667V8.333`,strokeLinejoin:`round`}),(0,W.jsx)(`path`,{d:`M10 4.583V1.667`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,W.jsx)(`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`})]}),Y),wS=q((0,W.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`circle`,{cx:`9`,cy:`7`,r:`4`}),(0,W.jsx)(`path`,{d:`M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2`}),(0,W.jsx)(`path`,{d:`M16 3.13a4 4 0 0 1 0 7.75`}),(0,W.jsx)(`path`,{d:`M21 21v-2a4 4 0 0 0 -3 -3.85`})]}),J);q(`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`);var TS=q(`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`),ES=q((0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`g`,{clipPath:`url(#a)`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,W.jsx)(`path`,{d:`M15 5 5 15M5 5l10 10`})}),(0,W.jsx)(`defs`,{children:(0,W.jsx)(`clipPath`,{id:`a`,children:(0,W.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),Y);q(`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}),q(`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}),q(`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});var DS=H.memo(({theme:e})=>q((0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`M25 26H111V111H25`,fill:ax(e)}),(0,W.jsx)(`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:ax(e),strokeWidth:`2`}),(0,W.jsx)(`path`,{d:`M100 100H160V160H100`,fill:ax(e)}),(0,W.jsx)(`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:ax(e),strokeWidth:`2`}),(0,W.jsxs)(`g`,{fill:ox(e),stroke:ax(e),strokeWidth:`6`,children:[(0,W.jsx)(`rect`,{x:`2.5`,y:`2.5`,width:`30`,height:`30`}),(0,W.jsx)(`rect`,{x:`2.5`,y:`149.5`,width:`30`,height:`30`}),(0,W.jsx)(`rect`,{x:`147.5`,y:`149.5`,width:`30`,height:`30`}),(0,W.jsx)(`rect`,{x:`147.5`,y:`2.5`,width:`30`,height:`30`})]})]}),{width:182,height:182,mirror:!0})),OS=H.memo(({theme:e})=>q((0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`M25 26H111V111H25`,fill:ax(e)}),(0,W.jsx)(`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:ax(e),strokeWidth:`2`}),(0,W.jsx)(`path`,{d:`M100 100H160V160H100`,fill:ax(e)}),(0,W.jsx)(`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:ax(e),strokeWidth:`2`}),(0,W.jsxs)(`g`,{fill:ox(e),stroke:ax(e),strokeWidth:`6`,children:[(0,W.jsx)(`rect`,{x:`2.5`,y:`2.5`,width:`30`,height:`30`}),(0,W.jsx)(`rect`,{x:`78.5`,y:`149.5`,width:`30`,height:`30`}),(0,W.jsx)(`rect`,{x:`147.5`,y:`149.5`,width:`30`,height:`30`}),(0,W.jsx)(`rect`,{x:`147.5`,y:`78.5`,width:`30`,height:`30`}),(0,W.jsx)(`rect`,{x:`105.5`,y:`2.5`,width:`30`,height:`30`}),(0,W.jsx)(`rect`,{x:`2.5`,y:`102.5`,width:`30`,height:`30`})]})]}),{width:182,height:182,mirror:!0})),kS=q((0,W.jsx)(`g`,{strokeWidth:1.25,children:(0,W.jsx)(`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`})}),Y),AS=q((0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`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`}),(0,W.jsx)(`mask`,{id:`FillHachureIcon`,style:{maskType:`alpha`},maskUnits:`userSpaceOnUse`,x:2,y:2,width:16,height:16,children:(0,W.jsx)(`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`})}),(0,W.jsx)(`g`,{mask:`url(#FillHachureIcon)`,children:(0,W.jsx)(`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`})})]}),Y),jS=q((0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`g`,{clipPath:`url(#a)`,children:[(0,W.jsx)(`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`}),(0,W.jsx)(`mask`,{id:`FillCrossHatchIcon`,style:{maskType:`alpha`},maskUnits:`userSpaceOnUse`,x:-1,y:-1,width:22,height:22,children:(0,W.jsx)(`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`})}),(0,W.jsx)(`g`,{mask:`url(#FillCrossHatchIcon)`,children:(0,W.jsx)(`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`})})]}),(0,W.jsx)(`defs`,{children:(0,W.jsx)(`clipPath`,{id:`a`,children:(0,W.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),Y),MS=q((0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`g`,{clipPath:`url(#a)`,children:(0,W.jsx)(`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`})}),(0,W.jsx)(`defs`,{children:(0,W.jsx)(`clipPath`,{id:`a`,children:(0,W.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),{...Y,fill:`currentColor`}),NS=q((0,W.jsx)(W.Fragment,{children:(0,W.jsx)(`path`,{d:`M4.167 10h11.666`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`})}),Y),PS=q((0,W.jsx)(`path`,{d:`M5 10h10`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),Y),FS=q((0,W.jsx)(`path`,{d:`M5 10h10`,stroke:`currentColor`,strokeWidth:`3.75`,strokeLinecap:`round`,strokeLinejoin:`round`}),Y);H.memo(({theme:e})=>q((0,W.jsx)(`path`,{d:`M6 10H34`,stroke:ax(e),strokeWidth:2,fill:`none`,strokeLinecap:`round`}),{width:40,height:20}));var IS=q((0,W.jsxs)(`g`,{strokeWidth:`2`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M5 12h2`}),(0,W.jsx)(`path`,{d:`M17 12h2`}),(0,W.jsx)(`path`,{d:`M11 12h2`})]}),J),LS=q((0,W.jsxs)(`g`,{strokeWidth:`2`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M4 12v.01`}),(0,W.jsx)(`path`,{d:`M8 12v.01`}),(0,W.jsx)(`path`,{d:`M12 12v.01`}),(0,W.jsx)(`path`,{d:`M16 12v.01`}),(0,W.jsx)(`path`,{d:`M20 12v.01`})]}),J),RS=q((0,W.jsx)(`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`}),Y),zS=q((0,W.jsx)(`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`}),Y),BS=q((0,W.jsx)(`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`}),Y),VS=q((0,W.jsxs)(`g`,{children:[(0,W.jsx)(`path`,{d:`M4 12 C 5 8, 6 8, 8 12`,fill:`none`,strokeWidth:`1`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,W.jsx)(`path`,{d:`M8 12 C 9 16, 10 16, 12 12`,fill:`none`,strokeWidth:`1`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,W.jsx)(`path`,{d:`M12 12 C 14 8, 15 8, 16 12`,fill:`none`,strokeWidth:`1`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,W.jsx)(`path`,{d:`M16 12 C 17 16, 18 16, 19 12`,fill:`none`,strokeWidth:`1`,strokeLinecap:`round`,strokeLinejoin:`round`})]}),J),HS=q((0,W.jsxs)(`g`,{children:[(0,W.jsx)(`path`,{d:`M4 12 C 5 8, 6 8, 8 12`,fill:`none`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,W.jsx)(`path`,{d:`M8 12 C 9 16, 10 16, 12 12`,fill:`none`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,W.jsx)(`path`,{d:`M12 12 C 14 8, 15 8, 16 12`,fill:`none`,strokeWidth:`2.75`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,W.jsx)(`path`,{d:`M16 12 C 17 16, 18 16, 19 12`,fill:`none`,strokeWidth:`3.25`,strokeLinecap:`round`,strokeLinejoin:`round`})]}),J),US=q((0,W.jsxs)(`svg`,{strokeWidth:`1.5`,children:[(0,W.jsx)(`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`}),(0,W.jsx)(`path`,{d:`M13.3333 3.33331V3.34331`}),(0,W.jsx)(`path`,{d:`M16.6667 3.33331V3.34331`}),(0,W.jsx)(`path`,{d:`M16.6667 6.66669V6.67669`}),(0,W.jsx)(`path`,{d:`M16.6667 10V10.01`}),(0,W.jsx)(`path`,{d:`M3.33334 13.3333V13.3433`}),(0,W.jsx)(`path`,{d:`M16.6667 13.3333V13.3433`}),(0,W.jsx)(`path`,{d:`M3.33334 16.6667V16.6767`}),(0,W.jsx)(`path`,{d:`M6.66666 16.6667V16.6767`}),(0,W.jsx)(`path`,{d:`M10 16.6667V16.6767`}),(0,W.jsx)(`path`,{d:`M13.3333 16.6667V16.6767`}),(0,W.jsx)(`path`,{d:`M16.6667 16.6667V16.6767`})]}),Y),WS=q((0,W.jsxs)(`g`,{strokeWidth:`1.5`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M4 12v-4a4 4 0 0 1 4 -4h4`}),(0,W.jsx)(`line`,{x1:`16`,y1:`4`,x2:`16`,y2:`4.01`}),(0,W.jsx)(`line`,{x1:`20`,y1:`4`,x2:`20`,y2:`4.01`}),(0,W.jsx)(`line`,{x1:`20`,y1:`8`,x2:`20`,y2:`8.01`}),(0,W.jsx)(`line`,{x1:`20`,y1:`12`,x2:`20`,y2:`12.01`}),(0,W.jsx)(`line`,{x1:`4`,y1:`16`,x2:`4`,y2:`16.01`}),(0,W.jsx)(`line`,{x1:`20`,y1:`16`,x2:`20`,y2:`16.01`}),(0,W.jsx)(`line`,{x1:`4`,y1:`20`,x2:`4`,y2:`20.01`}),(0,W.jsx)(`line`,{x1:`8`,y1:`20`,x2:`8`,y2:`20.01`}),(0,W.jsx)(`line`,{x1:`12`,y1:`20`,x2:`12`,y2:`20.01`}),(0,W.jsx)(`line`,{x1:`16`,y1:`20`,x2:`16`,y2:`20.01`}),(0,W.jsx)(`line`,{x1:`20`,y1:`20`,x2:`20`,y2:`20.01`})]}),J),GS=H.memo(({flip:e=!1})=>q((0,W.jsxs)(`g`,{transform:e?`translate(40, 0) scale(-1, 1)`:``,stroke:`currentColor`,opacity:.3,strokeWidth:2,fill:`none`,strokeLinecap:`round`,children:[(0,W.jsx)(`path`,{d:`M7,11 H19`}),(0,W.jsx)(`path`,{d:`M25,6 L33,16 M33,6 L25,16`})]}),sx)),KS=H.memo(({flip:e=!1})=>q((0,W.jsx)(`g`,{transform:e?`translate(40, 0) scale(-1, 1)`:``,stroke:`currentColor`,strokeWidth:2,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,W.jsx)(`path`,{d:`M7,11 H33 M23,5 L33,11 L23,17`})}),sx)),qS=H.memo(({flip:e=!1})=>q((0,W.jsxs)(`g`,{stroke:`currentColor`,fill:`currentColor`,transform:e?`translate(40, 0) scale(-1, 1)`:``,strokeLinejoin:`round`,children:[(0,W.jsx)(`path`,{d:`M7,11 H23`,strokeWidth:2,strokeLinecap:`round`}),(0,W.jsx)(`path`,{d:`M23,5 L35,11 L23,17 Z`})]}),sx)),JS=H.memo(({flip:e=!1})=>q((0,W.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?`translate(40, 0) scale(-1, 1)`:``,strokeWidth:2,strokeLinejoin:`round`,strokeLinecap:`round`,children:[(0,W.jsx)(`path`,{d:`M7,11 H23`}),(0,W.jsx)(`path`,{d:`M23,5 L35,11 L23,17 Z`})]}),sx)),YS=H.memo(({flip:e=!1})=>q((0,W.jsxs)(`g`,{stroke:`currentColor`,fill:`currentColor`,transform:e?`translate(40, 0) scale(-1, 1)`:``,children:[(0,W.jsx)(`path`,{d:`M7,11 H25`,strokeWidth:2,strokeLinecap:`round`}),(0,W.jsx)(`circle`,{cx:`29`,cy:`11`,r:`4`})]}),sx)),XS=H.memo(({flip:e=!1})=>q((0,W.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?`translate(40, 0) scale(-1, 1)`:``,strokeWidth:2,children:[(0,W.jsx)(`path`,{d:`M7,11 H25`,strokeLinecap:`round`}),(0,W.jsx)(`circle`,{cx:`29`,cy:`11`,r:`4`})]}),sx)),ZS=H.memo(({flip:e=!1})=>q((0,W.jsxs)(`g`,{stroke:`currentColor`,fill:`currentColor`,transform:e?`translate(40, 0) scale(-1, 1)`:``,strokeLinejoin:`round`,children:[(0,W.jsx)(`path`,{d:`M7,11 H21`,strokeWidth:2,strokeLinecap:`round`}),(0,W.jsx)(`path`,{d:`M21,11 L28,5 L35,11 L28,17 Z`})]}),sx)),QS=H.memo(({flip:e=!1})=>q((0,W.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?`translate(40, 0) scale(-1, 1)`:``,strokeLinejoin:`round`,strokeWidth:2,strokeLinecap:`round`,children:[(0,W.jsx)(`path`,{d:`M7,11 H21`}),(0,W.jsx)(`path`,{d:`M21,11 L28,5 L35,11 L28,17 Z`})]}),sx)),$S=H.memo(({flip:e=!1})=>q((0,W.jsx)(`g`,{transform:e?`translate(40, 0) scale(-1, 1)`:``,stroke:`currentColor`,strokeWidth:2,fill:`none`,strokeLinecap:`round`,children:(0,W.jsx)(`path`,{d:`M11,11 H31 M31,5 V17`})}),sx)),eC=H.memo(({flip:e=!1})=>q((0,W.jsx)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?``:`translate(40, 0) scale(-1, 1)`,strokeLinejoin:`round`,strokeWidth:2,children:(0,W.jsx)(`path`,{d:`M35,11 H7 M15,5 V17`})}),sx)),tC=H.memo(({flip:e=!1})=>q((0,W.jsx)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?``:`translate(40, 0) scale(-1, 1)`,strokeLinejoin:`round`,strokeWidth:2,children:(0,W.jsx)(`path`,{d:`M35,11 H7 M15,11 L7,5 M15,11 L7,17`})}),sx)),nC=H.memo(({flip:e=!1})=>q((0,W.jsx)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?``:`translate(40, 0) scale(-1, 1)`,strokeLinejoin:`round`,strokeWidth:2,children:(0,W.jsx)(`path`,{d:`M35,11 H7 M23,5 V17 M15,11 L7,5 M15,11 L7,17`})}),sx)),rC=H.memo(({flip:e=!1})=>q((0,W.jsx)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?``:`translate(40, 0) scale(-1, 1)`,strokeLinejoin:`round`,strokeWidth:2,children:(0,W.jsx)(`path`,{d:`M35,11 H7 M15,5 V17 M7,5 V17`})}),sx)),iC=H.memo(({flip:e=!1})=>q((0,W.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?``:`translate(40, 0) scale(-1, 1)`,strokeLinejoin:`round`,strokeWidth:2,children:[(0,W.jsx)(`path`,{d:`M35,11 H19 M11,11 H7 M7,5 V17`}),(0,W.jsx)(`circle`,{cx:`15`,cy:`11`,r:`4`})]}),sx)),aC=H.memo(({flip:e=!1})=>q((0,W.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?``:`translate(40, 0) scale(-1, 1)`,strokeLinejoin:`round`,strokeWidth:2,children:[(0,W.jsx)(`path`,{d:`M35,11 H27 M19,11 H7 M15,11 L7,5 M15,11 L7,17`}),(0,W.jsx)(`circle`,{cx:`23`,cy:`11`,r:`4`})]}),sx)),oC=q((0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`g`,{clipPath:`url(#a)`,children:(0,W.jsx)(`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`})}),(0,W.jsx)(`defs`,{children:(0,W.jsx)(`clipPath`,{id:`a`,children:(0,W.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),Y),sC=q((0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`g`,{clipPath:`url(#a)`,children:(0,W.jsx)(`path`,{d:`M5 16.667V3.333L10 15l5-11.667v13.334`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,W.jsx)(`defs`,{children:(0,W.jsx)(`clipPath`,{id:`a`,children:(0,W.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),Y),cC=q((0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`g`,{clipPath:`url(#a)`,children:(0,W.jsx)(`path`,{d:`M5.833 3.333v13.334h8.334`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,W.jsx)(`defs`,{children:(0,W.jsx)(`clipPath`,{id:`a`,children:(0,W.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),Y),lC=q((0,W.jsx)(W.Fragment,{children:(0,W.jsx)(`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`})}),Y),uC=q((0,W.jsxs)(`g`,{strokeWidth:1.25,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M3 7v-2h13v2`}),(0,W.jsx)(`path`,{d:`M10 5v14`}),(0,W.jsx)(`path`,{d:`M12 19h-4`}),(0,W.jsx)(`path`,{d:`M15 13v-1h6v1`}),(0,W.jsx)(`path`,{d:`M18 12v7`}),(0,W.jsx)(`path`,{d:`M17 19h2`})]}),J),dC=q((0,W.jsx)(W.Fragment,{children:(0,W.jsxs)(`g`,{stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M7 12h10`}),(0,W.jsx)(`path`,{d:`M7 5v14`}),(0,W.jsx)(`path`,{d:`M17 5v14`}),(0,W.jsx)(`path`,{d:`M15 19h4`}),(0,W.jsx)(`path`,{d:`M15 5h4`}),(0,W.jsx)(`path`,{d:`M5 19h4`}),(0,W.jsx)(`path`,{d:`M5 5h4`})]})}),J),fC=q((0,W.jsx)(W.Fragment,{children:(0,W.jsx)(`g`,{stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,W.jsx)(`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`})})}),Y),pC=q((0,W.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M7 8l-4 4l4 4`}),(0,W.jsx)(`path`,{d:`M17 8l4 4l-4 4`}),(0,W.jsx)(`path`,{d:`M14 4l-4 16`})]}),J),mC=pC,hC=q((0,W.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`line`,{x1:`4`,y1:`8`,x2:`20`,y2:`8`}),(0,W.jsx)(`line`,{x1:`4`,y1:`12`,x2:`12`,y2:`12`}),(0,W.jsx)(`line`,{x1:`4`,y1:`16`,x2:`16`,y2:`16`})]}),J),gC=q((0,W.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`line`,{x1:`4`,y1:`8`,x2:`20`,y2:`8`}),(0,W.jsx)(`line`,{x1:`8`,y1:`12`,x2:`16`,y2:`12`}),(0,W.jsx)(`line`,{x1:`6`,y1:`16`,x2:`18`,y2:`16`})]}),J),_C=q((0,W.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`line`,{x1:`4`,y1:`8`,x2:`20`,y2:`8`}),(0,W.jsx)(`line`,{x1:`10`,y1:`12`,x2:`20`,y2:`12`}),(0,W.jsx)(`line`,{x1:`8`,y1:`16`,x2:`20`,y2:`16`})]}),J),vC=H.memo(({theme:e})=>q((0,W.jsxs)(`g`,{strokeWidth:`1.5`,stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`line`,{x1:`4`,y1:`4`,x2:`20`,y2:`4`}),(0,W.jsx)(`rect`,{x:`9`,y:`8`,width:`6`,height:`12`,rx:`2`})]}),J)),yC=H.memo(({theme:e})=>q((0,W.jsxs)(`g`,{strokeWidth:`2`,stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`line`,{x1:`4`,y1:`20`,x2:`20`,y2:`20`}),(0,W.jsx)(`rect`,{x:`9`,y:`4`,width:`6`,height:`12`,rx:`2`})]}),J)),bC=H.memo(({theme:e})=>q((0,W.jsxs)(`g`,{strokeWidth:`1.5`,stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`line`,{x1:`4`,y1:`12`,x2:`9`,y2:`12`}),(0,W.jsx)(`line`,{x1:`15`,y1:`12`,x2:`20`,y2:`12`}),(0,W.jsx)(`rect`,{x:`9`,y:`6`,width:`6`,height:`12`,rx:`2`})]}),J)),xC=q((0,W.jsxs)(`g`,{children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M21 19h-18l9 -15`}),(0,W.jsx)(`path`,{d:`M20.615 15.171h.015`}),(0,W.jsx)(`path`,{d:`M19.515 11.771h.015`}),(0,W.jsx)(`path`,{d:`M17.715 8.671h.015`}),(0,W.jsx)(`path`,{d:`M15.415 5.971h.015`})]}),J),SC=q((0,W.jsx)(`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});q((0,W.jsx)(`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`}));var CC=q((0,W.jsxs)(`g`,{strokeWidth:1.25,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5`}),(0,W.jsx)(`path`,{d:`M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5`}),(0,W.jsx)(`path`,{d:`M14 5.5a1.5 1.5 0 0 1 3 0v6.5`}),(0,W.jsx)(`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`})]}),J),wC=q((0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2`}),(0,W.jsx)(`path`,{d:`M7 11l5 5l5 -5`}),(0,W.jsx)(`path`,{d:`M12 4l0 12`})]}),J),TC=q((0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`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`}),(0,W.jsx)(`path`,{d:`M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2`})]}),J),EC=q((0,W.jsxs)(`g`,{strokeWidth:1.25,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0`}),(0,W.jsx)(`path`,{d:`M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0`}),(0,W.jsx)(`path`,{d:`M9.15 14.85l8.85 -10.85`}),(0,W.jsx)(`path`,{d:`M6 4l8.85 10.85`})]}),J),DC=q((0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0`}),(0,W.jsx)(`path`,{d:`M12 17l0 .01`}),(0,W.jsx)(`path`,{d:`M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4`})]}),J);q((0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M7 4v16l13 -8z`})]}),J),q((0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`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`})]}),J);var OC=q((0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M5 12l5 5l10 -10`})]}),J),kC=q((0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`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`}),(0,W.jsx)(`path`,{d:`M12 9v4`}),(0,W.jsx)(`path`,{d:`M12 17h.01`})]}),J),AC=[`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`,`M11 7l6 6`],jC=q((0,W.jsxs)(`g`,{strokeWidth:1.25,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),AC.map(e=>(0,W.jsx)(`path`,{d:e},e))]}),J),MC=q((0,W.jsxs)(`g`,{strokeWidth:1.5,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M4 7l16 0`}),(0,W.jsx)(`path`,{d:`M4 17l16 0`}),(0,W.jsx)(`path`,{d:`M7 4l0 16`}),(0,W.jsx)(`path`,{d:`M17 4l0 16`})]}),J),NC=q((0,W.jsxs)(`g`,{strokeWidth:1.5,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M6 4h12a2 2 0 0 1 2 2v9l-5 5h-9a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2z`}),(0,W.jsx)(`path`,{d:`M14 20v-4a2 2 0 0 1 2 -2h4`}),(0,W.jsx)(`path`,{d:`M8 9h8`}),(0,W.jsx)(`path`,{d:`M8 13h5`})]}),J),PC=q((0,W.jsx)(`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`})),FC=q((0,W.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4`}),(0,W.jsx)(`path`,{d:`M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4`})]}),J),IC=q((0,W.jsxs)(`g`,{children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M6 10l-2 1l8 4l8 -4l-2 -1`}),(0,W.jsx)(`path`,{d:`M4 15l8 4l8 -4`}),(0,W.jsx)(`path`,{d:`M12 4v7`}),(0,W.jsx)(`path`,{d:`M15 8l-3 3l-3 -3`})]}),J),LC=q((0,W.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,W.jsx)(`path`,{d:`M4.16602 10H15.8327`}),(0,W.jsx)(`path`,{d:`M12.5 13.3333L15.8333 10`}),(0,W.jsx)(`path`,{d:`M12.5 6.66666L15.8333 9.99999`})]}),Y),RC=q((0,W.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M3 9.5a6.5 6.5 0 1 0 13 0a6.5 6.5 0 1 0 -13 0`}),(0,W.jsx)(`path`,{d:`M10 12a2 2 0 0 1 2 -2h7a2 2 0 0 1 2 2v7a2 2 0 0 1 -2 2h-7a2 2 0 0 1 -2 -2l0 -7`})]}),J),zC=q((0,W.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`,transform:`rotate(90 10 10)`,children:[(0,W.jsx)(`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`}),(0,W.jsx)(`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),BC=q((0,W.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`}),(0,W.jsx)(`path`,{d:`M6 21l15 -15l-3 -3l-15 15l3 3`}),(0,W.jsx)(`path`,{d:`M15 6l3 3`}),(0,W.jsx)(`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`}),(0,W.jsx)(`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`})]}),J);q((0,W.jsxs)(`g`,{strokeWidth:1.25,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`}),(0,W.jsx)(`path`,{d:`M6 21l15 -15l-3 -3l-15 15l3 3`}),(0,W.jsx)(`path`,{d:`M15 6l3 3`}),(0,W.jsx)(`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`}),(0,W.jsx)(`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`})]}),J),q((0,W.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35`}),(0,W.jsx)(`path`,{d:`M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946`}),(0,W.jsx)(`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`}),(0,W.jsx)(`path`,{d:`M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45`}),(0,W.jsx)(`path`,{d:`M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946`}),(0,W.jsx)(`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`})]}),J);var VC=q((0,W.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M4 8v-2a2 2 0 0 1 2 -2h2`}),(0,W.jsx)(`path`,{d:`M4 16v2a2 2 0 0 0 2 2h2`}),(0,W.jsx)(`path`,{d:`M16 4h2a2 2 0 0 1 2 2v2`}),(0,W.jsx)(`path`,{d:`M16 20h2a2 2 0 0 0 2 -2v-2`})]}),J),HC=q((0,W.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,strokeWidth:1.5,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0`}),(0,W.jsx)(`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`})]}),J),UC=q((0,W.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M10.585 10.587a2 2 0 0 0 2.829 2.828`}),(0,W.jsx)(`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`}),(0,W.jsx)(`path`,{d:`M3 3l18 18`})]}),J),WC=q((0,W.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`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`}),(0,W.jsx)(`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`}),(0,W.jsx)(`path`,{d:`M17.5 16a3.5 3.5 0 0 0 0 -7h-.5`}),(0,W.jsx)(`path`,{d:`M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0`}),(0,W.jsx)(`path`,{d:`M6.5 16a3.5 3.5 0 0 1 0 -7h.5`}),(0,W.jsx)(`path`,{d:`M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10`})]}),J),GC=q((0,W.jsxs)(`g`,{strokeWidth:1.25,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`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`}),(0,W.jsx)(`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`}),(0,W.jsx)(`path`,{d:`M17.5 16a3.5 3.5 0 0 0 0 -7h-.5`}),(0,W.jsx)(`path`,{d:`M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0`}),(0,W.jsx)(`path`,{d:`M6.5 16a3.5 3.5 0 0 1 0 -7h.5`}),(0,W.jsx)(`path`,{d:`M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10`})]}),J),KC=q((0,W.jsxs)(`g`,{strokeWidth:1.5,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0`}),(0,W.jsx)(`path`,{d:`M21 21l-6 -6`})]}),J),qC=q((0,W.jsxs)(`g`,{strokeWidth:1.5,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M20.984 12.53a9 9 0 1 0 -7.552 8.355`}),(0,W.jsx)(`path`,{d:`M12 7v5l3 3`}),(0,W.jsx)(`path`,{d:`M19 16l-2 3h4l-2 3`})]}),J),JC=q((0,W.jsxs)(`g`,{strokeWidth:1.5,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M12 8l0 4l2 2`}),(0,W.jsx)(`path`,{d:`M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5`})]}),J),YC=q((0,W.jsxs)(`g`,{strokeWidth:1.5,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`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`}),(0,W.jsx)(`path`,{d:`M5 10a7 7 0 0 0 14 0`}),(0,W.jsx)(`path`,{d:`M8 21l8 0`}),(0,W.jsx)(`path`,{d:`M12 17l0 4`})]}),J),XC=q((0,W.jsxs)(`g`,{strokeWidth:1.5,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M3 3l18 18`}),(0,W.jsx)(`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`}),(0,W.jsx)(`path`,{d:`M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85`}),(0,W.jsx)(`path`,{d:`M8 21l8 0`}),(0,W.jsx)(`path`,{d:`M12 17l0 4`})]}),J),ZC=q((0,W.jsxs)(`g`,{strokeWidth:1.25,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11`})]}),J),QC=q((0,W.jsxs)(`g`,{children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M8 8m0 1a1 1 0 0 1 1 -1h6a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-6a1 1 0 0 1 -1 -1z`}),(0,W.jsx)(`path`,{d:`M12 20v.01`}),(0,W.jsx)(`path`,{d:`M16 20v.01`}),(0,W.jsx)(`path`,{d:`M8 20v.01`}),(0,W.jsx)(`path`,{d:`M4 20v.01`}),(0,W.jsx)(`path`,{d:`M4 16v.01`}),(0,W.jsx)(`path`,{d:`M4 12v.01`}),(0,W.jsx)(`path`,{d:`M4 8v.01`}),(0,W.jsx)(`path`,{d:`M4 4v.01`}),(0,W.jsx)(`path`,{d:`M8 4v.01`}),(0,W.jsx)(`path`,{d:`M12 4v.01`}),(0,W.jsx)(`path`,{d:`M16 4v.01`}),(0,W.jsx)(`path`,{d:`M20 4v.01`}),(0,W.jsx)(`path`,{d:`M20 8v.01`}),(0,W.jsx)(`path`,{d:`M20 12v.01`}),(0,W.jsx)(`path`,{d:`M20 16v.01`}),(0,W.jsx)(`path`,{d:`M20 20v.01`})]}),J),$C=q((0,W.jsxs)(`g`,{strokeWidth:1.25,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M5 3v18`}),(0,W.jsx)(`path`,{d:`M19 21v-18`}),(0,W.jsx)(`path`,{d:`M5 7h14`}),(0,W.jsx)(`path`,{d:`M5 15h14`}),(0,W.jsx)(`path`,{d:`M8 13v4`}),(0,W.jsx)(`path`,{d:`M11 13v4`}),(0,W.jsx)(`path`,{d:`M16 13v4`}),(0,W.jsx)(`path`,{d:`M14 5v4`}),(0,W.jsx)(`path`,{d:`M11 5v4`}),(0,W.jsx)(`path`,{d:`M8 5v4`}),(0,W.jsx)(`path`,{d:`M3 21h18`})]}),J),ew=q((0,W.jsxs)(`g`,{strokeWidth:1.25,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M3 12l18 0`}),(0,W.jsx)(`path`,{d:`M7 16l10 0l-10 5l0 -5`}),(0,W.jsx)(`path`,{d:`M7 8l10 0l-10 -5l0 5`})]}),J),tw=q((0,W.jsxs)(`g`,{strokeWidth:1.25,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M12 3l0 18`}),(0,W.jsx)(`path`,{d:`M16 7l0 10l5 0l-5 -10`}),(0,W.jsx)(`path`,{d:`M8 7l0 10l-5 0l5 -10`})]}),J),nw=q((0,W.jsxs)(`g`,{strokeWidth:1.25,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M5 3m0 2a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v2a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2z`}),(0,W.jsx)(`path`,{d:`M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2`}),(0,W.jsx)(`path`,{d:`M10 15m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z`})]}),J),rw=q((0,W.jsxs)(`g`,{strokeWidth:1.25,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0`}),(0,W.jsx)(`path`,{d:`M22 22l-3 -3`}),(0,W.jsx)(`path`,{d:`M6 18h-1a2 2 0 0 1 -2 -2v-1`}),(0,W.jsx)(`path`,{d:`M3 11v-1`}),(0,W.jsx)(`path`,{d:`M3 6v-1a2 2 0 0 1 2 -2h1`}),(0,W.jsx)(`path`,{d:`M10 3h1`}),(0,W.jsx)(`path`,{d:`M15 3h1a2 2 0 0 1 2 2v1`})]}),J),iw=q((0,W.jsxs)(`g`,{strokeWidth:1.25,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M14 3v4a1 1 0 0 0 1 1h4`}),(0,W.jsx)(`path`,{d:`M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4`}),(0,W.jsx)(`path`,{d:`M4 20.25c0 .414 .336 .75 .75 .75h1.25a1 1 0 0 0 1 -1v-1a1 1 0 0 0 -1 -1h-1a1 1 0 0 1 -1 -1v-1a1 1 0 0 1 1 -1h1.25a.75 .75 0 0 1 .75 .75`}),(0,W.jsx)(`path`,{d:`M10 15l2 6l2 -6`}),(0,W.jsx)(`path`,{d:`M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3`})]}),J),aw=q((0,W.jsxs)(`g`,{strokeWidth:1.25,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M14 3v4a1 1 0 0 0 1 1h4`}),(0,W.jsx)(`path`,{d:`M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4`}),(0,W.jsx)(`path`,{d:`M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3`}),(0,W.jsx)(`path`,{d:`M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6`}),(0,W.jsx)(`path`,{d:`M11 21v-6l3 6v-6`})]}),J),ow=q((0,W.jsxs)(`g`,{strokeWidth:1.25,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M4 13v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a2 2 0 0 0 6 0v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a8 8 0 0 1 -16 0`}),(0,W.jsx)(`path`,{d:`M4 8l5 0`}),(0,W.jsx)(`path`,{d:`M15 8l4 0`})]}),J),sw=q((0,W.jsxs)(`g`,{strokeWidth:1.25,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M3 14c.83 .642 2.077 1.017 3.5 1c1.423 .017 2.67 -.358 3.5 -1c.83 -.642 2.077 -1.017 3.5 -1c1.423 -.017 2.67 .358 3.5 1`}),(0,W.jsx)(`path`,{d:`M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2`}),(0,W.jsx)(`path`,{d:`M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2`}),(0,W.jsx)(`path`,{d:`M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z`}),(0,W.jsx)(`path`,{d:`M16.746 16.726a3 3 0 1 0 .252 -5.555`})]}),J),cw=q((0,W.jsxs)(`g`,{stroke:`currentColor`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M3 5a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-16a1 1 0 0 1-1-1v-10zM7 20h10M9 16v4M15 16v4`})]}),{...J,strokeWidth:1.5});q((0,W.jsxs)(`g`,{strokeWidth:1.5,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M15 8v-2a2 2 0 0 0 -2 -2h-7a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7a2 2 0 0 0 2 -2v-2`}),(0,W.jsx)(`path`,{d:`M21 12h-13l3 -3`}),(0,W.jsx)(`path`,{d:`M11 15l-3 -3`})]}),J);var lw=q((0,W.jsxs)(`g`,{children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M2 8a4 4 0 0 1 4 -4h12a4 4 0 0 1 4 4v8a4 4 0 0 1 -4 4h-12a4 4 0 0 1 -4 -4v-8z`}),(0,W.jsx)(`path`,{d:`M10 9l5 3l-5 3z`})]}),J),uw=q((0,W.jsxs)(`g`,{strokeWidth:1.5,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M3 6h18`}),(0,W.jsx)(`path`,{d:`M3 12h18`}),(0,W.jsx)(`path`,{d:`M3 18h18`}),(0,W.jsx)(`path`,{d:`M6 3v18`}),(0,W.jsx)(`path`,{d:`M12 3v18`}),(0,W.jsx)(`path`,{d:`M18 3v18`})]}),J),dw=q((0,W.jsxs)(`g`,{strokeWidth:1.5,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M17 3m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z`}),(0,W.jsx)(`path`,{d:`M3 17m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z`}),(0,W.jsx)(`path`,{d:`M17 5c-6.627 0 -12 5.373 -12 12`})]}),J),fw=q((0,W.jsxs)(`g`,{children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M6 18l12 -12`}),(0,W.jsx)(`path`,{d:`M18 10v-4h-4`})]}),J),pw=q((0,W.jsxs)(`g`,{children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7`}),(0,W.jsx)(`path`,{d:`M18 4l3 3l-3 3`})]}),J),mw=q((0,W.jsxs)(`g`,{children:[(0,W.jsx)(`path`,{d:`M16,12L20,9L16,6`}),(0,W.jsx)(`path`,{d:`M6 20c0 -6.075 4.925 -11 11 -11h3`})]}),J),hw=q((0,W.jsxs)(`g`,{children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M6 9l6 6l6 -6`})]}),J),gw=q((0,W.jsxs)(`g`,{children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M6 15l6 -6l6 6`})]}),J),_w=q((0,W.jsxs)(`g`,{children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M6 15l6 -6l6 6`})]}),J),vw=q((0,W.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M8 5v10a1 1 0 0 0 1 1h10`}),(0,W.jsx)(`path`,{d:`M5 8h10a1 1 0 0 1 1 1v10`})]}),J),yw=q((0,W.jsxs)(`g`,{children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,W.jsx)(`path`,{d:`M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,W.jsx)(`path`,{d:`M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,W.jsx)(`path`,{d:`M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,W.jsx)(`path`,{d:`M5 7l0 10`}),(0,W.jsx)(`path`,{d:`M7 5l10 0`}),(0,W.jsx)(`path`,{d:`M7 19l10 0`}),(0,W.jsx)(`path`,{d:`M19 7l0 10`})]}),J);q((0,W.jsxs)(`g`,{strokeWidth:1.5,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M4 11v8a1 1 0 0 0 1 1h8m-9 -14v-1a1 1 0 0 1 1 -1h1m5 0h2m5 0h1a1 1 0 0 1 1 1v1m0 5v2m0 5v1a1 1 0 0 1 -1 1h-1`}),(0,W.jsx)(`path`,{d:`M4 12h7a1 1 0 0 1 1 1v7`})]}),J);var bw=q((0,W.jsxs)(`g`,{strokeWidth:1.5,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,W.jsx)(`path`,{d:`M4 6l8 0`}),(0,W.jsx)(`path`,{d:`M16 6l4 0`}),(0,W.jsx)(`path`,{d:`M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,W.jsx)(`path`,{d:`M4 12l2 0`}),(0,W.jsx)(`path`,{d:`M10 12l10 0`}),(0,W.jsx)(`path`,{d:`M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,W.jsx)(`path`,{d:`M4 18l11 0`}),(0,W.jsx)(`path`,{d:`M19 18l1 0`})]}),J),xw=q((0,W.jsxs)(`g`,{strokeWidth:1,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M6 10l4 -4 L6 14l8 -8 L6 18l12 -12 L10 18l8 -8 L14 18l4 -4`})]}),J),Sw=q((0,W.jsxs)(`g`,{strokeWidth:1.25,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4`}),(0,W.jsx)(`path`,{d:`M13.5 6.5l4 4`})]}),J);q((0,W.jsxs)(`g`,{strokeWidth:1,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M11 7l-5 5l5 5`}),(0,W.jsx)(`path`,{d:`M17 7l-5 5l5 5`})]}),J);var Cw=q((0,W.jsxs)(`g`,{strokeWidth:`1.75`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M4 4m0 2a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2z`}),(0,W.jsx)(`path`,{d:`M15 4l0 16`})]}),J);q((0,W.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M3 20l1.3 -3.9c-2.324 -3.437 -1.426 -7.872 2.1 -10.374c3.526 -2.501 8.59 -2.296 11.845 .48c3.255 2.777 3.695 7.266 1.029 10.501c-2.666 3.235 -7.615 4.215 -11.574 2.293l-4.7 1`})]}),J),q((0,W.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M3 4l18 0`}),(0,W.jsx)(`path`,{d:`M4 4v10a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-10`}),(0,W.jsx)(`path`,{d:`M12 16l0 4`}),(0,W.jsx)(`path`,{d:`M9 20l6 0`}),(0,W.jsx)(`path`,{d:`M8 12l3 -3l2 2l3 -3`})]}),J);var ww=(0,W.jsx)(`div`,{style:{width:`1rem`,height:`1rem`}}),Tw=q((0,W.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`polyline`,{points:`6 9 12 15 18 9`})]}),J),Ew=q((0,W.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`polyline`,{points:`9 6 15 12 9 18`})]}),J),Dw=q((0,W.jsxs)(`g`,{strokeWidth:1.25,children:[(0,W.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,W.jsx)(`path`,{d:`M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,W.jsx)(`path`,{d:`M4 6l8 0`}),(0,W.jsx)(`path`,{d:`M16 6l4 0`}),(0,W.jsx)(`path`,{d:`M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,W.jsx)(`path`,{d:`M4 12l2 0`}),(0,W.jsx)(`path`,{d:`M10 12l10 0`}),(0,W.jsx)(`path`,{d:`M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,W.jsx)(`path`,{d:`M4 18l11 0`}),(0,W.jsx)(`path`,{d:`M19 18l1 0`})]}),J),Ow=({size:e=`1em`,circleWidth:t=8,synchronized:n=!1,className:r=``})=>{let i=-(H.useRef(Date.now()).current%1600);return(0,W.jsx)(`div`,{className:`Spinner ${r}`,children:(0,W.jsx)(`svg`,{viewBox:`0 0 100 100`,style:{width:e,height:e,"--spinner-delay":n?`${i}ms`:0},children:(0,W.jsx)(`circle`,{cx:`50`,cy:`50`,r:50-t/2,strokeWidth:t,fill:`none`,strokeMiterlimit:`10`})})})},kw=H.forwardRef(({size:e=`medium`,visible:t=!0,className:n=``,...r},i)=>{let a=H.useRef(null);H.useImperativeHandle(i,()=>a.current);let o=`ToolIcon_size_${e}`,[s,c]=(0,H.useState)(!1),l=(0,H.useRef)(!0),u=async e=>{let t=`onClick`in r&&r.onClick?.(e);if(Zs(t))try{c(!0),await t}catch(e){if(e instanceof Js)console.warn(e);else throw e}finally{l.current&&c(!1)}};(0,H.useEffect)(()=>(l.current=!0,()=>{l.current=!1}),[]);let d=(0,H.useRef)(null);return r.type===`button`||r.type===`icon`?(0,W.jsxs)(`button`,{className:U(`ToolIcon_type_button`,o,n,t&&!r.hidden?`ToolIcon_type_button--show`:`ToolIcon_type_button--hide`,{ToolIcon:!r.hidden,"ToolIcon--plain":r.type===`icon`}),style:r.style,"data-testid":r[`data-testid`],hidden:r.hidden,title:r.title,"aria-label":r[`aria-label`],type:`button`,onClick:u,ref:a,disabled:s||r.isLoading||!!r.disabled,children:[(r.icon||r.label)&&(0,W.jsxs)(`div`,{className:`ToolIcon__icon`,"aria-hidden":`true`,"aria-disabled":!!r.disabled,children:[r.icon||r.label,r.keyBindingLabel&&(0,W.jsx)(`span`,{className:`ToolIcon__keybinding`,children:r.keyBindingLabel}),r.isLoading&&(0,W.jsx)(Ow,{})]}),r.showAriaLabel&&(0,W.jsxs)(`div`,{className:`ToolIcon__label`,children:[r[`aria-label`],` `,s&&(0,W.jsx)(Ow,{})]}),r.children]}):(0,W.jsx)(`button`,{className:U(`ToolIcon`,`ToolIcon_type_toggle`,o,n,{"ToolIcon--checked":r.checked}),type:`button`,style:r.style,title:r.title,"aria-label":r[`aria-label`],"aria-keyshortcuts":r[`aria-keyshortcuts`],"aria-pressed":r.checked,"data-testid":r[`data-testid`],disabled:!!r.disabled,"aria-disabled":!!r.disabled,onPointerDown:e=>{d.current=e.pointerType||null,r.onPointerDown?.(e)},onPointerUp:()=>{requestAnimationFrame(()=>{d.current=null})},onClick:()=>{r.onSelect?.({pointerType:d.current})},ref:a,children:(0,W.jsxs)(`div`,{className:`ToolIcon__icon`,children:[r.icon,r.keyBindingLabel&&(0,W.jsx)(`span`,{className:`ToolIcon__keybinding`,children:r.keyBindingLabel})]})})});kw.displayName=`IconButton`;var Aw=[],X=e=>(Aw=Aw.concat(e),e),jw=(e,t,n)=>{let r=new Set(ot(e.filter(e=>R(e)),t).map(e=>e.id)),i={},a=n.scene.getNonDeletedElementsMap(),o=new Set;for(let t of r){let n=Ti(e,t);for(let e of n)if(!o.has(e.id)){if(_s(e)){let t=Ws(e,a);t&&(i[t.id]=!0)}else i[e.id]=!0;o.add(e.id)}}let s=!0,c=e.map(e=>{if(t.selectedElementIds[e.id]){let t=_s(e)?Ws(e,a):null;return e.frameId&&r.has(e.frameId)?(s=!1,i[e.id]=!0,e):t?.frameId&&r.has(t?.frameId)?e:(e.boundElements&&e.boundElements.forEach(t=>{let r=n.scene.getNonDeletedElementsMap().get(t.id);r&&Br(r)&&n.scene.mutateElement(r,{startBinding:e.id===r.startBinding?.elementId?null:r.startBinding,endBinding:e.id===r.endBinding?.elementId?null:r.endBinding})}),j(e,{isDeleted:!0}))}return e.frameId&&r.has(e.frameId)?(s=!1,_s(e)||(i[e.id]=!0),j(e,{frameId:null})):_s(e)&&t.selectedElementIds[e.containerId]?j(e,{isDeleted:!0}):e}),l=t.editingGroupId;if(s&&t.editingGroupId){let e=Er(c,t.editingGroupId).filter(e=>!e.isDeleted);if(e.length>1)e[0]&&(i[e[0].id]=!0);else{l=null,e[0]&&(i[e[0].id]=!0);let n=e[0];if(n){let e=n.groupIds.findIndex(e=>e===t.editingGroupId),r=n.groupIds[e+1];if(r){let e=Er(c,r).filter(e=>!e.isDeleted);e.length>1&&(l=r,e.forEach(e=>{i[e.id]=!0}))}}}}return{elements:c,appState:{...t,...To({selectedElementIds:i,editingGroupId:l},k(c),t,null)}}},Mw=(e,t)=>{if(e.editingGroupId){let n=Er(k(t),e.editingGroupId);if(n.length)return{...e,selectedElementIds:{[n[0].id]:!0}}}return e},Nw=X({name:`deleteSelectedElements`,label:`labels.delete`,icon:Ix,trackEvent:{category:`element`,action:`delete`},perform:(e,t,n,r)=>{if(t.selectedLinearElement?.isEditing){let{elementId:n,selectedPointsIndices:i}=t.selectedLinearElement,a=r.scene.getNonDeletedElementsMap(),o=I.getElement(n,a);if(!o||i==null)return!1;if(i.length>=o.points.length){let n=e.map(e=>e.id===o.id?j(e,{isDeleted:!0}):e);return{elements:n,appState:{...Mw(t,n),selectedLinearElement:null},captureUpdate:N.IMMEDIATELY}}return I.deletePoints(o,r,i),{elements:e,appState:{...t,selectedLinearElement:{...t.selectedLinearElement,selectedPointsIndices:i?.[0]>0?[i[0]-1]:[0]}},captureUpdate:N.IMMEDIATELY}}let{elements:i,appState:a}=jw(e,t,r);return jn(i,i.filter(e=>e.isDeleted)),a=Mw(a,i),{elements:i,appState:{...a,activeTool:ae(t,{type:r.state.preferredSelectionTool.type}),multiElement:null,newElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Jc(k(e),t)?N.IMMEDIATELY:N.EVENTUALLY}},keyTest:(e,t,n)=>(e.key===L.BACKSPACE||e.key===L.DELETE)&&!e[L.CTRL_OR_CMD],PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>{let i=pU()===`mobile`;return(0,W.jsx)(kw,{type:`button`,icon:Ix,title:K(`labels.delete`),"aria-label":K(`labels.delete`),onClick:()=>n(null),disabled:!Jc(k(e),t),style:{...i&&t.openPopup!==`compactOtherProperties`?ui:{}}})}}),Z=e=>e.replace(/\b(Opt(?:ion)?|Alt)\b/i,K(pc?`keys.option`:`keys.alt`)).replace(/\bShift\b/i,K(`keys.shift`)).replace(/\b(Enter|Return)\b/i,K(`keys.enter`)).replace(/\b(Ctrl|Cmd|Command|CtrlOrCmd)\b/gi,K(pc?`keys.cmd`:`keys.ctrl`)).replace(/\b(Esc(?:ape)?)\b/i,K(`keys.escape`)).replace(/\b(Space(?:bar)?)\b/i,K(`keys.spacebar`)).replace(/\b(Del(?:ete)?)\b/i,K(`keys.delete`)),Pw=X({name:`sendBackward`,label:`labels.sendBackward`,keywords:[`move down`,`zindex`,`layer`],icon:pS,trackEvent:{category:`element`},perform:(e,t,n,r)=>({elements:_a(e,t,r.scene),appState:t,captureUpdate:N.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[L.CTRL_OR_CMD]&&!e.shiftKey&&e.code===xt.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>(0,W.jsx)(`button`,{type:`button`,className:`zIndexButton`,onClick:()=>e(null),title:`${K(`labels.sendBackward`)} \u2014 ${Z(`CtrlOrCmd+[`)}`,children:pS})}),Fw=X({name:`bringForward`,label:`labels.bringForward`,keywords:[`move up`,`zindex`,`layer`],icon:fS,trackEvent:{category:`element`},perform:(e,t,n,r)=>({elements:Sc(e,t,r.scene),appState:t,captureUpdate:N.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[L.CTRL_OR_CMD]&&!e.shiftKey&&e.code===xt.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>(0,W.jsx)(`button`,{type:`button`,className:`zIndexButton`,onClick:()=>e(null),title:`${K(`labels.bringForward`)} \u2014 ${Z(`CtrlOrCmd+]`)}`,children:fS})}),Iw=X({name:`sendToBack`,label:`labels.sendToBack`,keywords:[`move down`,`zindex`,`layer`],icon:hS,trackEvent:{category:`element`},perform:(e,t)=>({elements:Na(e,t),appState:t,captureUpdate:N.IMMEDIATELY}),keyTest:e=>pc?e[L.CTRL_OR_CMD]&&e.altKey&&e.code===xt.BRACKET_LEFT:e[L.CTRL_OR_CMD]&&e.shiftKey&&e.code===xt.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>(0,W.jsx)(`button`,{type:`button`,className:`zIndexButton`,onClick:()=>e(null),title:`${K(`labels.sendToBack`)} \u2014 ${Z(pc?`CtrlOrCmd+Alt+[`:`CtrlOrCmd+Shift+[`)}`,children:hS})}),Lw=X({name:`bringToFront`,label:`labels.bringToFront`,keywords:[`move up`,`zindex`,`layer`],icon:mS,trackEvent:{category:`element`},perform:(e,t)=>({elements:_n(e,t),appState:t,captureUpdate:N.IMMEDIATELY}),keyTest:e=>pc?e[L.CTRL_OR_CMD]&&e.altKey&&e.code===xt.BRACKET_RIGHT:e[L.CTRL_OR_CMD]&&e.shiftKey&&e.code===xt.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>(0,W.jsx)(`button`,{type:`button`,className:`zIndexButton`,onClick:t=>e(null),title:`${K(`labels.bringToFront`)} \u2014 ${Z(pc?`CtrlOrCmd+Alt+]`:`CtrlOrCmd+Shift+]`)}`,children:mS})}),Rw=X({name:`selectAll`,label:`labels.selectAll`,icon:QC,trackEvent:{category:`canvas`},viewMode:!1,perform:(e,t,n,r)=>{if(t.selectedLinearElement?.isEditing)return!1;let i=e.filter(e=>!e.isDeleted&&!(z(e)&&e.containerId)&&!e.locked).reduce((e,t)=>(e[t.id]=!0,e),{});return{appState:{...t,...To({editingGroupId:null,selectedElementIds:i},k(e),t,r),selectedLinearElement:Object.keys(i).length===1&&ro(e[0])?new I(e[0],d(e)):null},captureUpdate:N.IMMEDIATELY}},keyTest:e=>e[L.CTRL_OR_CMD]&&e.key===L.A}),zw=X({name:`duplicateSelection`,label:`labels.duplicateSelection`,icon:Rx,trackEvent:{category:`element`},perform:(e,t,n,r)=>{if(t.selectedElementsAreBeingDragged)return!1;if(t.selectedLinearElement?.isEditing)try{return{elements:e,appState:I.duplicateSelectedPoints(t,r.scene),captureUpdate:N.IMMEDIATELY}}catch{return!1}let{duplicatedElements:i,elementsWithDuplicates:a}=g({type:`in-place`,elements:e,idsOfElementsToDuplicate:d(ot(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:t,randomizeSeed:!0,overrides:({origElement:e,origIdToDuplicateId:t})=>{let n=e.frameId&&t.get(e.frameId);return{x:e.x+10,y:e.y+10,frameId:n??e.frameId}}});if(r.props.onDuplicate&&a){let t=r.props.onDuplicate(a,e);t&&(a=t)}return{elements:ct(a,d(i)),appState:{...t,...so(i,k(a),t)},captureUpdate:N.IMMEDIATELY}},keyTest:e=>e[L.CTRL_OR_CMD]&&e.key===L.D,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>{let i=pU()===`mobile`;return(0,W.jsx)(kw,{type:`button`,icon:Rx,title:`${K(`labels.duplicateSelection`)} \u2014 ${Z(`CtrlOrCmd+D`)}`,"aria-label":K(`labels.duplicateSelection`),onClick:()=>n(null),disabled:!Jc(k(e),t),style:{...i&&t.openPopup!==`compactOtherProperties`?ui:{}}})}}),Bw=new Set([`command_palette`,`export`,`ai`]),Vw=(e,t,n,r)=>{try{if(typeof window>`u`||xa.VITE_WORKER_ID||xa.VITE_APP_ENABLE_TRACKING!==`true`||!Bw.has(e)||rt())return;xa.PROD||console.info(`trackEvent`,{category:e,action:t,label:n,value:r}),window.sa_event&&window.sa_event(t,{category:e,label:n,value:r})}catch(e){console.error(`error during analytics`,e)}},Hw=(0,H.forwardRef)((e,t)=>{let{title:n,className:r,testId:i,active:a,icon:o,onClick:s}=e;return(0,W.jsx)(`button`,{type:`button`,ref:t,title:n,"data-testid":i,className:U(r,{active:a}),onClick:s,style:e.style,children:o},n)}),Uw=e=>(0,W.jsx)(W.Fragment,{children:e.options.map(t=>e.type===`button`?(0,W.jsx)(Hw,{icon:t.icon,title:t.text,testId:t.testId,active:t.active??e.value===t.value,onClick:n=>e.onClick(t.value,n)},t.text):(0,W.jsxs)(`label`,{className:U({active:e.value===t.value}),title:t.text,children:[(0,W.jsx)(`input`,{type:`radio`,name:e.group,onChange:()=>e.onChange(t.value),checked:e.value===t.value,"data-testid":t.testId}),t.icon]},t.text))}),Ww=()=>(0,W.jsx)(`div`,{style:{width:1,height:`1rem`,backgroundColor:`var(--default-border-color)`,margin:`0 auto`}}),Gw=H.createContext(null),Kw=()=>H.useContext(Gw),qw=e=>{let[t,n]=(0,H.useState)(null),r=fU(),{theme:i}=Kw(),{container:a}=mU();return(0,H.useLayoutEffect)(()=>{t&&(t.className=``,t.classList.add(`excalidraw`,...e?.className?.split(/\s+/)||[]),t.classList.toggle(`excalidraw--mobile`,r.formFactor===`phone`),t.classList.toggle(`theme--dark`,i===P.DARK))},[t,i,r.formFactor,e?.className]),(0,H.useLayoutEffect)(()=>{let t=a?.ownerDocument,r=e?.parentSelector?a?.querySelector(e.parentSelector):t?.body;if(!r||!t)return;let i=t.createElement(`div`);return r.appendChild(i),n(i),()=>{r.removeChild(i)}},[a,e?.parentSelector]),t};function Jw(e,t,n){(0,H.useEffect)(()=>{let r=e.current?.ownerDocument;if(!r)return;let i=r;function a(r){let a=r;if(!e.current)return;let o=n?.(a,e.current);if(o!==!0){if(o===!1)return t(a);e.current.contains(a.target)||!i.documentElement.contains(a.target)||a.target.closest(`[data-radix-portal]`)||a.target===i.documentElement&&i.body.style.pointerEvents===`none`||a.target.closest(`[data-prevent-outside-click]`)||t(a)}}return i.addEventListener(B.POINTER_DOWN,a),i.addEventListener(B.TOUCH_START,a),()=>{i.removeEventListener(B.POINTER_DOWN,a),i.removeEventListener(B.TOUCH_START,a)}},[e,t,n])}var Yw=e=>{let t=(0,H.useRef)(e);return Object.assign(t.current,e),t.current},Xw=({cursorPosition:e,elementSize:t,containerSize:n,gap:r})=>{let i=e+r+t>n?e-r-t:e+r;return fi(i,0,Math.max(0,n-t))},Zw=({cursor:e,element:t,container:n,gap:r})=>({left:Xw({cursorPosition:e.x-n.left,elementSize:t.width,containerSize:n.width,gap:r}),top:Xw({cursorPosition:e.y-n.top,elementSize:t.height,containerSize:n.height,gap:r})}),Qw=AC.map((e,t)=>`<path fill="${t===0?`#fff`:``}" d="${e}" />`).join(``),$w=`url(data:${M.svg},${encodeURIComponent(`<svg viewBox="0 0 24 24" width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke-linecap="round" stroke-linejoin="round"><g stroke="#fff" stroke-width="5">${Qw}</g><g stroke="#1b1b1f" stroke-width="1.25">${Qw}</g></svg>`)}) 2 21, auto`,eT=yl(null),tT=({onCancel:e,onChange:t,onSelect:n,colorPickerType:r})=>{let i=qw({className:`excalidraw-eye-dropper-backdrop`,parentSelector:`.excalidraw-eye-dropper-container`}),a=Kw(),o=hU(),s=uU(),c=s.ownerWindow,l=Yw({app:s,onCancel:e,onChange:t,onSelect:n,selectedElements:ot(o,a)}),{container:u}=mU();(0,H.useLayoutEffect)(()=>{if(i)return i.style.cursor=$w,()=>{i.style.cursor=``}},[i]),(0,H.useEffect)(()=>{let e=d.current;if(!e||!s.canvas||!i)return;let t=!1,n=s.canvas.getContext(`2d`),o=({clientX:e,clientY:t})=>{let r=n.getImageData((e-a.offsetLeft)*c.devicePixelRatio,(t-a.offsetTop)*c.devicePixelRatio,1,1).data;return Ei(r[0],r[1],r[2])},f=e=>a.theme===P.DARK?st(e):e,p=({clientX:n,clientY:a,altKey:s})=>{let{top:c,left:u}=Zw({cursor:{x:n,y:a},element:{width:e.offsetWidth,height:e.offsetHeight},container:i.getBoundingClientRect(),gap:7});e.style.top=`${c}px`,e.style.left=`${u}px`;let d=o({clientX:n,clientY:a});t&&l.onChange(r,f(d),l.selectedElements,{altKey:s}),e.style.background=d,e.style.setProperty(`--eye-dropper-preview-border-color`,Gc(d)?`#fff`:`#222`)},m=()=>{l.onCancel()},h=(e,t)=>{l.onSelect(e,t)},g=e=>{t=!0,e.stopImmediatePropagation()},_=e=>{t=!1,u?.focus(),e.stopImmediatePropagation(),e.preventDefault(),h(f(o(e)),e)},v=e=>{e.key===L.ESCAPE&&(e.preventDefault(),e.stopImmediatePropagation(),m())};return i.tabIndex=-1,i.focus(),p({clientX:l.app.viewport.lastPosition.x,clientY:l.app.viewport.lastPosition.y,altKey:!1}),i.addEventListener(B.KEYDOWN,v),i.addEventListener(B.POINTER_DOWN,g),i.addEventListener(B.POINTER_UP,_),c.addEventListener(`pointermove`,p,{passive:!0}),c.addEventListener(B.BLUR,m),()=>{t=!1,i.removeEventListener(B.KEYDOWN,v),i.removeEventListener(B.POINTER_DOWN,g),i.removeEventListener(B.POINTER_UP,_),c.removeEventListener(`pointermove`,p),c.removeEventListener(B.BLUR,m)}},[l,s.canvas,i,r,u,a.offsetLeft,a.offsetTop,a.theme,c]);let d=(0,H.useRef)(null);return Jw(d,()=>{e()},e=>!!e.target.closest(`.excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop`)),i?(0,hl.createPortal)((0,W.jsx)(`div`,{ref:d,className:`excalidraw-eye-dropper-preview`}),i):null},nT=H.forwardRef(({children:e,padding:t,className:n,style:r,"data-viewport-ui":i,"data-viewport-ui-name":a},o)=>(0,W.jsx)(`div`,{className:U(`Island`,n),style:{"--padding":t,...r},"data-viewport-ui":i,"data-viewport-ui-name":a,ref:o,children:e})),rT=H.forwardRef(({className:e,container:t,children:n,style:r,onClose:i,onKeyDown:a,onFocusOutside:o,onPointerLeave:s,onPointerDownOutside:c,preventAutoFocusOnTouch:l=!1},u)=>{let d=fU(),f=d.formFactor===`phone`&&!d.isLandscape;return(0,W.jsx)(Dy,{container:t,children:(0,W.jsxs)(Oy,{ref:u,className:U(`focus-visible-none`,e),"data-prevent-outside-click":!0,side:f?`bottom`:`right`,align:f?`center`:`start`,alignOffset:-16,sideOffset:20,collisionBoundary:t??void 0,style:{zIndex:`var(--zIndex-ui-styles-popup)`,marginLeft:d.formFactor===`phone`?`0.5rem`:void 0},onPointerLeave:s,onKeyDown:a,onFocusOutside:o,onPointerDownOutside:c,onOpenAutoFocus:e=>{l&&d.isTouchScreen&&e.preventDefault()},onCloseAutoFocus:e=>{e.stopPropagation(),e.preventDefault(),t&&!Yi(document.activeElement)&&t.focus(),i()},children:[(0,W.jsx)(nT,{padding:3,style:r,children:n}),(0,W.jsx)(Ay,{width:20,height:10,style:{fill:`var(--popup-bg-color)`,filter:`drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)`}})]})})}),iT=e=>e.querySelector(`.excalidraw-wysiwyg`),aT=(e=document)=>{let t=iT(e);return t?{start:t.selectionStart,end:t.selectionEnd}:null},oT=(e,t=document)=>{(t.defaultView??window).setTimeout(()=>{let n=iT(t);n&&(n.focus(),e&&(n.selectionStart=e.start,n.selectionEnd=e.end))},0)},sT=(e,t,n,r,i=document)=>{t&&r&&r();let a=t&&n?aT(i):null;e(),t&&n&&oT(a,i)},cT=(e=document)=>{let[t,n]=(0,H.useState)(null);return{saveCaretPosition:(0,H.useCallback)(()=>{let t=aT(e);n(t)},[e]),restoreCaretPosition:(0,H.useCallback)(()=>{(e.defaultView??window).setTimeout(()=>{let r=iT(e);r&&(r.focus(),t&&(r.selectionStart=t.start,r.selectionEnd=t.end,n(null)))},0)},[e,t]),clearSavedPosition:(0,H.useCallback)(()=>{n(null)},[]),hasSavedPosition:!!t}},lT=(e=document,t=100)=>{let n=iT(e);if(n){let r=n.onblur;n.onblur=null,(e.defaultView??window).setTimeout(()=>{n.onblur=r},t)}},uT=({palette:e,color:t})=>{if(!t)return null;for(let[n,r]of Object.entries(e))if(Array.isArray(r)){let e=r.indexOf(t);if(e>-1)return{colorName:n,shade:e}}else if(r===t)return{colorName:n,shade:null};return null},dT=[[`q`,`w`,`e`,`r`,`t`],[`a`,`s`,`d`,`f`,`g`],[`z`,`x`,`c`,`v`,`b`]].flat(),fT=({color:e,palette:t})=>!Object.values(t).flat().includes(e),pT=(e,t,n)=>{let r={elementBackground:`backgroundColor`,elementStroke:`strokeColor`},i=e.filter(e=>{if(e.isDeleted)return!1;let i=e[r[t]];return!Ke(i)&&fT({color:i,palette:n})}),a=new Map;return i.forEach(e=>{let n=e[r[t]];a.has(n)?a.set(n,a.get(n)+1):a.set(n,1)}),[...a.entries()].sort((e,t)=>t[1]-e[1]).map(e=>e[0]).slice(0,5)},mT=yl(null),hT=({color:e,onChange:t,label:n,colorPickerType:r,placeholder:i})=>{let a=fU(),[o,s]=(0,H.useState)(e),[c,l]=(0,H.useState)(null),[u,d]=Vb(mT);(0,H.useEffect)(()=>{s(e)},[e]);let f=(0,H.useCallback)(e=>{let n=e.toLowerCase().trim(),r=Mi(n);r?(t(r),l(null)):n.length===0?l(null):/^#?[0-9a-f]+$/.test(n)?l(K(`colorPicker.invalidHexLength`)):l(K(`colorPicker.invalidColor`)),s(n)},[t]),p=(0,H.useRef)(null),m=(0,H.useRef)(null);(0,H.useEffect)(()=>{p.current&&p.current.focus()},[u]);let[h,g]=Vb(eT);return(0,H.useEffect)(()=>()=>{g(null)},[g]),(0,W.jsxs)(`div`,{className:`color-picker__input-label-container`,children:[(0,W.jsxs)(`div`,{className:U(`color-picker__input-label`,{"has-error":c}),children:[(0,W.jsx)(`div`,{className:`color-picker__input-hash`,children:`#`}),(0,W.jsx)(`input`,{ref:u===`hex`?p:void 0,style:{border:0,padding:0},spellCheck:!1,className:`color-picker-input`,"aria-label":n,"aria-invalid":!!c,onChange:e=>{f(e.target.value)},value:(o||``).replace(/^#/,``),onBlur:()=>{s(e),l(null)},tabIndex:-1,onFocus:()=>d(`hex`),onKeyDown:e=>{e.key!==L.TAB&&(e.key===L.ESCAPE&&m.current?.focus(),e.stopPropagation())},placeholder:i}),a.formFactor!==`phone`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{style:{width:`1px`,height:`1.25rem`,backgroundColor:`var(--default-border-color)`}}),(0,W.jsx)(`div`,{ref:m,className:U(`excalidraw-eye-dropper-trigger`,{selected:h}),onClick:()=>g(e=>e?null:{keepOpenOnAlt:!1,onSelect:e=>t(e),colorPickerType:r}),title:`${K(`labels.eyeDropper`)} \u2014 ${L.I.toLocaleUpperCase()} or ${Z(`Alt`)} `,children:jC})]})]}),c&&(0,W.jsx)(`div`,{className:`color-picker__error-message`,role:`alert`,children:c})]})},gT=({color:e,keyLabel:t,isShade:n=!1})=>(0,W.jsxs)(`div`,{className:`color-picker__button__hotkey-label`,style:{color:Gc(e)?`#fff`:`#000`},children:[n&&`⇧`,t]}),_T=`excalidraw-color-dnd-ghost`,vT=`excalidraw-color-dnd-active`,yT=10,bT=100,xT=(e,t)=>{if(e.toLowerCase()===t.toLowerCase())return!0;let n=Jo(e);return n!==null&&n===Jo(t)},ST=(0,H.createContext)(null),CT=()=>(0,H.useContext)(ST),wT=({enabled:e,picks:t,onPicksChange:n})=>{let[r,i]=(0,H.useState)(null),a=(0,H.useRef)(null),o=(0,H.useRef)({enabled:e,picks:t,onPicksChange:n});o.current={enabled:e,picks:t,onPicksChange:n};let s=(0,H.useMemo)(()=>{let e=null,t=()=>{e?.activated?i({color:e.color,origin:e.origin,overIndex:e.overIndex,duplicateIndex:e.duplicateIndex,slotSpan:e.slotSpan}):i(null)},n=()=>{let t=a.current;if(!t||!e)return!1;let n=Array.from(t.querySelectorAll(`[data-top-pick-index]`)).sort((e,t)=>Number(e.dataset.topPickIndex)-Number(t.dataset.topPickIndex));if(!n.length)return!1;e.slotRects=n.map(e=>e.getBoundingClientRect());let[r,i]=e.slotRects;e.slotSpan=i?i.left-r.left:r.width+4;let o=t.getBoundingClientRect(),s=Math.max(Math.abs(e.slotSpan)/2,10);return e.hitRect={left:o.left-s,right:o.right+s,top:o.top-14,bottom:o.bottom+14},!0},r=(t,n)=>{e?.ghost&&(e.ghost.style.transform=`translate(${t-e.ghostW/2}px, ${n-e.ghostH/2}px)`)},s=(t,n,i,a)=>{e?.ghost&&(e.ghostW!==t||e.ghostH!==n)&&(e.ghostW=t,e.ghostH=n,e.ghost.style.width=`${t}px`,e.ghost.style.height=`${n}px`,r(i,a))},c=(n,i)=>{if(!e)return;let{sourceRect:a,sourceEl:o,color:s}=e,c=document.createElement(`div`);c.className=_T;let l=document.createElement(`div`);if(l.className=`${_T}__swatch`,Ke(s))l.classList.add(`is-transparent`);else{let e=getComputedStyle(o).backgroundColor;l.style.backgroundColor=e&&e!==`rgba(0, 0, 0, 0)`?e:s}c.appendChild(l),document.body.appendChild(c),e.ghost=c,e.ghostW=a.width,e.ghostH=a.height,c.style.width=`${a.width}px`,c.style.height=`${a.height}px`,r(n,i),requestAnimationFrame(()=>{e?.ghost===c&&c.classList.add(`${_T}--lifted`)}),document.body.classList.add(vT),e.activated=!0,t()},l=(n,r)=>{if(!e?.hitRect)return;let{hitRect:i,slotRects:a}=e,c=null,l=null;if(n>=i.left&&n<=i.right&&r>=i.top&&r<=i.bottom){let t=0,r=1/0;if(a.forEach((e,i)=>{let a=Math.abs(n-(e.left+e.width/2));a<r&&(r=a,t=i)}),e.origin.kind===`swatch`){let n=o.current.picks.findIndex(t=>xT(t,e.color));n===-1?c=t:l=n}else c=t}if(c!==e.overIndex||l!==e.duplicateIndex){e.overIndex=c,e.duplicateIndex=l;let{ghost:n}=e;n&&(n.classList.toggle(`${_T}--over`,c!==null),n.classList.toggle(`${_T}--blocked`,l!==null)),t()}if(c!==null){let t=e.slotRects[c];s(t.width,t.height,n,r)}else s(e.sourceRect.width,e.sourceRect.height,n,r)},u=t=>{if(!e?.ghost)return;let{ghost:n}=e;e.ghost=null,n.classList.add(`${_T}--dropping`);let r=t.rect;r&&(n.style.width=`${r.width}px`,n.style.height=`${r.height}px`,n.style.transform=`translate(${r.left}px, ${r.top}px)`),window.setTimeout(()=>{n.classList.add(`${_T}--fade`)},160),window.setTimeout(()=>{n.remove()},340)},d=()=>{let t=a.current;if(!t||!e?.activated)return;let n=Array.from(t.querySelectorAll(`[data-top-pick-index]`));for(let e of n)e.style.transition=`none`,e.style.transform=`none`;t.offsetWidth;for(let e of n)e.style.transition=``},f=()=>{let e=e=>{e.preventDefault(),e.stopPropagation()};window.addEventListener(`click`,e,{capture:!0,once:!0}),window.setTimeout(()=>{window.removeEventListener(`click`,e,{capture:!0})},100)},p=()=>{window.removeEventListener(`pointermove`,_,!0),window.removeEventListener(`pointerup`,v,!0),window.removeEventListener(`pointercancel`,y,!0),window.removeEventListener(`keydown`,b,!0)},m=()=>{p(),document.body.classList.remove(vT),e?.activationTimer!=null&&window.clearTimeout(e.activationTimer),e=null,i(null)},h=t=>{e&&(d(),e.ghost&&(t?u({rect:e.sourceRect}):(e.ghost.remove(),e.ghost=null)),m())},g=(t,r)=>{if(e&&!e.activated){if(!n()){m();return}c(t,r),l(t,r)}},_=t=>{if(e&&t.pointerId===e.pointerId){if(e.lastX=t.clientX,e.lastY=t.clientY,!e.activated){if(Math.hypot(t.clientX-e.startX,t.clientY-e.startY)<yT){e.activationTimer!==null&&(window.clearTimeout(e.activationTimer),e.activationTimer=null);return}let n=performance.now()-e.startTime;if(n<bT){e.activationTimer===null&&(e.activationTimer=window.setTimeout(()=>{e&&(e.activationTimer=null,Math.hypot(e.lastX-e.startX,e.lastY-e.startY)>=yT&&g(e.lastX,e.lastY))},bT-n));return}if(g(t.clientX,t.clientY),!e?.activated)return}t.preventDefault(),r(t.clientX,t.clientY),l(t.clientX,t.clientY)}},v=t=>{if(!e||t.pointerId!==e.pointerId)return;if(!e.activated){m();return}t.preventDefault(),t.stopPropagation(),f();let{overIndex:n,origin:r,color:i,slotRects:a}=e,{picks:s,onPicksChange:c}=o.current;if(d(),n!==null){if(r.kind===`swatch`){if(!s.some(e=>xT(e,i))){let e=[...s];e[n]=i,c(e)}}else if(r.index!==n){let e=[...s],[t]=e.splice(r.index,1);e.splice(n,0,t),c(e)}u({rect:a[n]})}else u({rect:e.sourceRect});m()},y=t=>{e&&t.pointerId===e.pointerId&&h(!0)},b=t=>{e?.activated&&t.key===`Escape`&&(t.preventDefault(),t.stopPropagation(),h(!0))};return{begin:(t,n,r)=>{!o.current.enabled||e||t.button!==0||!n||(e={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,startTime:performance.now(),lastX:t.clientX,lastY:t.clientY,activationTimer:null,color:n,origin:r,sourceEl:t.currentTarget,sourceRect:t.currentTarget.getBoundingClientRect(),activated:!1,ghost:null,ghostW:0,ghostH:0,slotRects:[],slotSpan:0,hitRect:null,overIndex:null,duplicateIndex:null},window.addEventListener(`pointermove`,_,!0),window.addEventListener(`pointerup`,v,!0),window.addEventListener(`pointercancel`,y,!0),window.addEventListener(`keydown`,b,!0))},destroy:()=>h(!1)}},[]);return(0,H.useEffect)(()=>()=>s.destroy(),[s]),(0,H.useMemo)(()=>({dragState:r,startSwatchDrag:(e,t)=>s.begin(e,t,{kind:`swatch`}),startPickDrag:(e,t,n)=>s.begin(e,n,{kind:`pick`,index:t}),setStripEl:e=>{a.current=e}}),[r,s])},TT=({theme:e,colors:t,color:n,onChange:r,label:i})=>{let[a,o]=Vb(mT),s=CT(),c=(0,H.useRef)(null);return(0,H.useEffect)(()=>{c.current&&c.current.focus()},[n,a]),(0,W.jsx)(`div`,{className:`color-picker-content--default`,children:t.map((t,a)=>{let l=Zc(t,e===P.DARK);return(0,W.jsxs)(`button`,{ref:n===t?c:void 0,tabIndex:-1,type:`button`,className:U(`color-picker__button color-picker__button--large has-outline`,{active:n===t,"is-transparent":t===`transparent`||!t}),onClick:()=>{r(t),o(`custom`)},onPointerDown:s?e=>s.startSwatchDrag(e,t):void 0,title:t,"aria-label":i,style:{"--swatch-color":l},children:[(0,W.jsx)(`div`,{className:`color-picker__button-outline`}),(0,W.jsx)(gT,{color:l,keyLabel:a+1})]},a)})})},ET=({theme:e,palette:t,color:n,onChange:r,activeShade:i,showHotKey:a=!0,excludedColors:o})=>{let s=uT({color:n,palette:t}),[c,l]=Vb(mT),u=CT(),d=(0,H.useRef)(null);return(0,H.useEffect)(()=>{d.current&&c===`baseColors`&&d.current.focus()},[s?.colorName,c]),(0,W.jsx)(`div`,{className:`color-picker-content--default`,children:Object.entries(t).map(([t,n],c)=>{let f=(Array.isArray(n)?n[i]:n)||`transparent`;if(o?.includes(f))return(0,W.jsx)(`div`,{className:`color-picker__button color-picker__button--large`,style:{visibility:`hidden`},"aria-hidden":`true`},t);let p=dT[c],m=Zc(f,e===P.DARK),h=K(`colors.${t.replace(/\d+/,``)}`,null,``);return(0,W.jsxs)(`button`,{ref:s?.colorName===t?d:void 0,tabIndex:-1,type:`button`,className:U(`color-picker__button color-picker__button--large`,{"has-outline":!Gc(f,255),active:s?.colorName===t,"is-transparent":f===`transparent`||!f}),onClick:()=>{r(f),l(`baseColors`)},onPointerDown:u?e=>u.startSwatchDrag(e,f):void 0,title:`${h}${f.startsWith(`#`)?` ${f}`:``} \u2014 ${p}`,"aria-label":`${h} \u2014 ${p}`,style:f?{"--swatch-color":m}:void 0,"data-testid":`color-${t}`,children:[(0,W.jsx)(`div`,{className:`color-picker__button-outline`}),a&&(0,W.jsx)(gT,{color:m,keyLabel:p})]},t)})})},DT=({children:e})=>(0,W.jsx)(`div`,{className:`color-picker__heading`,children:e}),OT=({theme:e,color:t,onChange:n,palette:r,showHotKey:i})=>{let a=uT({color:t||`transparent`,palette:r}),[o,s]=Vb(mT),c=CT(),l=(0,H.useRef)(null);if((0,H.useEffect)(()=>{l.current&&o===`shades`&&l.current.focus()},[a,o]),a){let{colorName:t,shade:u}=a,d=r[t];if(Array.isArray(d))return(0,W.jsx)(`div`,{className:`color-picker-content--default shades`,children:d.map((r,a)=>{let d=Zc(r,e===P.DARK);return(0,W.jsxs)(`button`,{ref:a===u&&o===`shades`?l:void 0,tabIndex:-1,type:`button`,className:U(`color-picker__button color-picker__button--large`,{active:a===u}),"aria-label":`Shade`,title:`${t} - ${a+1}`,style:r?{"--swatch-color":d}:void 0,onClick:()=>{n(r),s(`shades`)},onPointerDown:c?e=>c.startSwatchDrag(e,r):void 0,children:[(0,W.jsx)(`div`,{className:`color-picker__button-outline`}),i&&(0,W.jsx)(gT,{color:d,keyLabel:a+1,isShade:!0})]},a)})})}return(0,W.jsxs)(`div`,{className:`color-picker-content--default`,style:{position:`relative`},tabIndex:-1,children:[(0,W.jsx)(`button`,{type:`button`,tabIndex:-1,className:`color-picker__button color-picker__button--large color-picker__button--no-focus-visible`}),(0,W.jsx)(`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:K(`colorPicker.noShades`)})]})},kT=(e,t,n)=>{let r=Math.ceil(n/5);switch(t??=-1,e){case`ArrowLeft`:{let e=t-1;return e<0?n-1:e}case`ArrowRight`:return(t+1)%n;case`ArrowDown`:{let e=t+5;return e>=n?t%5:e}case`ArrowUp`:{let e=t-5,i=e<0?5*r+e:e;return i>=n?void 0:i}}},AT=({e,colorObj:t,onChange:n,palette:r,customColors:i,setActiveColorPickerSection:a,activeShade:o,excludedColors:s})=>{if(t?.shade!=null&&[`Digit1`,`Digit2`,`Digit3`,`Digit4`,`Digit5`].includes(e.code)&&e.shiftKey){let i=Number(e.code.slice(-1))-1;return n(r[t.colorName][i]),a(`shades`),!0}if([`1`,`2`,`3`,`4`,`5`].includes(e.key)&&i[Number(e.key)-1])return n(i[Number(e.key)-1]),a(`custom`),!0;if(dT.includes(e.key)){let t=dT.indexOf(e.key),i=r[Object.keys(r)[t]],c=Array.isArray(i)?i[o]:i;return c==null||s?.includes(c)||(n(c),a(`baseColors`)),!0}return!1},jT=({event:e,activeColorPickerSection:t,palette:n,color:r,onChange:i,customColors:a,setActiveColorPickerSection:o,updateData:s,activeShade:c,onEyeDropperToggle:l,onEscape:u,excludedColors:d})=>{if(e[L.CTRL_OR_CMD])return!1;if(e.key===L.ESCAPE)return u(e),!0;if(e.key===L.ALT)return l(!0),!0;if(e.key===L.I)return l(),!0;let f=uT({color:r,palette:n});if(e.key===L.TAB){let s={custom:!!a.length,baseColors:!0,shades:f?.shade!=null,hex:!0},c=Object.entries(s).reduce((e,[t,n])=>(n&&e.push(t),e),[]),l=c.indexOf(t),u=e.shiftKey?-1:1,d=c[l+u>c.length-1?0:l+u<0?c.length-1:l+u];return d&&o(d),d===`custom`?i(a[0]):d===`baseColors`&&(Object.entries(n).find(([e,t])=>Array.isArray(t)?t.includes(r):t===r?e:null)||i(Ma.black)),e.preventDefault(),e.stopPropagation(),!0}if(AT({e,colorObj:f,onChange:i,palette:n,customColors:a,setActiveColorPickerSection:o,activeShade:c,excludedColors:d}))return!0;if(t===`shades`&&f){let{shade:t}=f,r=kT(e.key,t,5);if(r!==void 0)return i(n[f.colorName][r]),!0}if(t===`baseColors`&&f){let{colorName:t}=f,r=Object.keys(n),a=r.indexOf(t),o=kT(e.key,a,r.length),s=0;for(;o!==void 0&&s++<r.length;){let t=n[r[o]],i=Array.isArray(t)?t[c]:t;if(!d?.includes(i))break;o=kT(e.key,o,r.length)}if(o!==void 0){let e=n[r[o]];return i(Array.isArray(e)?e[c]:e),!0}}if(t===`custom`){let t=r==null?0:a.indexOf(r),n=kT(e.key,t,a.length);if(n!==void 0){let e=a[n];return i(e),!0}}return!1},MT=H.forwardRef(({theme:e,color:t,onChange:n,type:r,elements:i,palette:a,updateData:o,children:s,showTitle:c,onEyeDropperToggle:l,onEscape:u,showHotKey:d=!0,excludedColors:f},p)=>{let m=c?r===`elementStroke`?K(`labels.stroke`):r===`elementBackground`?K(`labels.background`):null:null,[h]=H.useState(()=>r===`canvasBackground`?[]:pT(i,r,a)),[g,_]=Vb(mT),v=CT(),y=uT({color:t,palette:a});(0,H.useEffect)(()=>{if(!g){let e=!!t&&fT({color:t,palette:a}),n=e&&!h.includes(t);_(n?null:e?`custom`:y?.shade==null?`baseColors`:`shades`)}},[g,t,a,_,y,h]);let[b,x]=(0,H.useState)(y?.shade??(r===`elementBackground`?1:4));(0,H.useEffect)(()=>{y?.shade!=null&&x(y.shade);let e=e=>{e.key===L.ALT&&l(!1)};return document.addEventListener(B.KEYUP,e,{capture:!0}),()=>{document.removeEventListener(B.KEYUP,e,{capture:!0})}},[y,l]);let S=H.useRef(null);return(0,H.useImperativeHandle)(p,()=>S.current),(0,H.useEffect)(()=>{S?.current?.focus()},[]),(0,W.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":K(`labels.colorPicker`),children:(0,W.jsxs)(`div`,{ref:S,onKeyDown:e=>{jT({event:e,activeColorPickerSection:g,palette:a,color:t,onChange:n,onEyeDropperToggle:l,customColors:h,setActiveColorPickerSection:_,updateData:o,activeShade:b,onEscape:u,excludedColors:f})&&(e.preventDefault(),e.stopPropagation())},className:`color-picker-content properties-content`,tabIndex:-1,children:[m&&(0,W.jsx)(`div`,{className:`color-picker__title`,children:m}),!!h.length&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(DT,{children:K(`colorPicker.mostUsedCustomColors`)}),(0,W.jsx)(TT,{theme:e,colors:h,color:t,label:K(`colorPicker.mostUsedCustomColors`),onChange:n})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(DT,{children:K(`colorPicker.colors`)}),(0,W.jsx)(ET,{theme:e,color:t,palette:a,onChange:n,activeShade:b,showHotKey:d,excludedColors:f})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(DT,{children:K(`colorPicker.shades`)}),(0,W.jsx)(OT,{theme:e,color:t,onChange:n,palette:a,showHotKey:d})]}),s,v&&(0,W.jsx)(`div`,{className:`color-picker__tip`,children:K(`colorPicker.topPicksTip`)})]})})}),NT=({theme:e,onChange:t,type:n,activeColor:r,topPicks:i,onReset:a,isCustomized:o})=>{let s=CT(),c=s?.dragState??null,{container:l}=mU(),u;if(n===`elementStroke`&&(u=mi),n===`elementBackground`&&(u=Vt),n===`canvasBackground`&&(u=x),i&&(u=i),!u)return console.error(`Invalid type for TopPicks`),null;let d=e=>{if(!c||c.origin.kind!==`pick`||c.overIndex===null)return 0;let t=c.origin.index,n=c.overIndex;if(t===n)return 0;let r=e;return e===t?r=n:(e>t&&--r,r>=n&&(r+=1)),(r-e)*c.slotSpan},f=(0,W.jsxs)(`div`,{className:U(`color-picker__top-picks`,{"is-dnd-active":!!c}),ref:s?.setStripEl,children:[c&&(0,W.jsx)(`svg`,{className:`color-picker__top-picks__dnd-outline`,"aria-hidden":`true`,children:(0,W.jsx)(`rect`,{})}),u.map((n,i)=>{let a=d(i),o=Zc(n,e===P.DARK);return(0,W.jsx)(`button`,{className:U(`color-picker__button`,{active:n===r,"is-transparent":n===`transparent`||!n,"has-outline":!Gc(n,240),"is-dnd-source":c?.origin.kind===`pick`&&c.origin.index===i,"is-dnd-target":c?.origin.kind===`swatch`&&c.overIndex===i,"is-dnd-duplicate":c?.duplicateIndex===i}),style:{"--swatch-color":o,transform:a?`translateX(${a}px)`:void 0},type:`button`,title:n,onClick:()=>t(n),onPointerDown:s?e=>s.startPickDrag(e,i,n):void 0,"data-testid":`color-top-pick-${n}`,"data-top-pick-index":i,children:(0,W.jsx)(`div`,{className:`color-picker__button-outline`})},n)})]});return a?(0,W.jsxs)(sv,{children:[(0,W.jsx)(cv,{asChild:!0,children:f}),(0,W.jsx)(lv,{container:l,children:(0,W.jsx)(uv,{className:`color-picker__context-menu`,style:{zIndex:`var(--zIndex-ui-styles-popup)`},children:(0,W.jsx)(dv,{className:`color-picker__context-menu-item`,disabled:!o,onSelect:a,children:K(`colorPicker.resetTopPicks`)})})})]}):f},PT=({type:e,color:t,onChange:n,label:r,elements:i,palette:a=Ma,updateData:o,getOpenPopup:s,appState:c,excludedColors:l})=>{let{container:u}=mU(),d=uU(),f=pU(),p=f!==`full`,m=f===`mobile`,[,h]=Vb(mT),[g,_]=Vb(eT),v=(0,W.jsxs)(`div`,{children:[(0,W.jsx)(DT,{children:K(`colorPicker.hexCode`)}),(0,W.jsx)(hT,{color:t||``,label:r,onChange:e=>{n(e)},colorPickerType:e,placeholder:K(`colorPicker.color`)})]}),y=(0,H.useRef)(null),b=()=>{y.current?.focus()};return(0,W.jsx)(rT,{container:u,style:{maxWidth:`13rem`},preventAutoFocusOnTouch:!!c.editingTextElement,onFocusOutside:e=>{let t=e.target;if(t instanceof d.ownerWindow.HTMLElement&&t.closest(`.color-picker__context-menu`)){e.preventDefault();return}tl(e.target)||(t instanceof d.ownerWindow.HTMLElement&&t.matches(`:active`)?d.ownerWindow.addEventListener(`pointerup`,b,{once:!0}):b()),e.preventDefault()},onPointerDownOutside:e=>{g&&e.preventDefault()},onClose:()=>{s()===e&&o({openPopup:null}),h(null),c.editingTextElement&&d.ownerWindow.setTimeout(()=>{let e=d.ownerDocument.querySelector(`.excalidraw-wysiwyg`);e&&e.focus()},0)},children:a?(0,W.jsx)(MT,{ref:y,palette:a,excludedColors:l,color:t,theme:c.theme,onChange:e=>{let t=c.editingTextElement?aT(d.ownerDocument):null;n(e),c.editingTextElement&&t&&oT(t,d.ownerDocument)},onEyeDropperToggle:t=>{_(r=>t?(r||={keepOpenOnAlt:!0,onSelect:n,colorPickerType:e},r.keepOpenOnAlt=!0,r):t===!1||r?null:{keepOpenOnAlt:!1,onSelect:n,colorPickerType:e})},onEscape:e=>{g?_(null):o({openPopup:null})},type:e,elements:i,updateData:o,showTitle:p,showHotKey:!m,children:v}):v})},FT=e=>e===`elementStroke`||e===`elementBackground`||e===`canvasBackground`,IT=({label:e,color:t,type:n,theme:r,mode:i=`background`,onToggle:a,editingTextElement:o})=>{let s=uU(),c=pU(),l=c!==`full`,u=c===`mobile`,d=CT(),f=t?Zc(t,r===P.DARK):null;return(0,W.jsxs)(Ey,{type:`button`,className:U(`color-picker__button active-color properties-trigger`,{"is-transparent":!t||t===`transparent`,"has-outline":!t||!Gc(t,240),"compact-sizing":l,"mobile-border":u}),"aria-label":e,style:f?{"--swatch-color":f}:void 0,title:K(n===`elementStroke`?`labels.showStroke`:`labels.showBackground`),"data-openpopup":n,onClick:e=>{e.preventDefault(),e.stopPropagation(),o&&lT(s.ownerDocument),a()},onPointerDown:d?e=>d.startSwatchDrag(e,t):void 0,children:[(0,W.jsx)(`div`,{className:`color-picker__button-outline`,children:!t&&nS}),l&&t&&i===`stroke`&&(0,W.jsx)(`div`,{className:`color-picker__button-background`,children:(0,W.jsx)(`span`,{style:{color:f&&Gc(f,240)?`#fff`:`#111`},children:xw})})]})},LT=(0,H.memo)(({type:e,color:t,onChange:n,label:r,elements:i,palette:a=Ma,topPicks:o,updateData:s,appState:c,excludedColors:l,customizableTopPicks:u})=>{let d=(0,H.useRef)(c.openPopup);(0,H.useEffect)(()=>{d.current=c.openPopup},[c.openPopup]);let f=pU()!==`full`,p=!!u&&!f,m=p&&u?c.colorTopPicks?.[u]:null,h=wT({enabled:p,picks:m?.length?m:o??(e===`elementStroke`?mi:Vt),onPicksChange:e=>{u&&s({colorTopPicks:{...c.colorTopPicks,[u]:e}})}});return(0,W.jsx)(ST.Provider,{value:p?h:null,children:(0,W.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,className:U(`color-picker-container`,{"color-picker-container--no-top-picks":f}),children:[!f&&(0,W.jsx)(NT,{theme:c.theme,activeColor:t,onChange:t=>{n(t),FT(c.openPopup)&&c.openPopup!==e&&setTimeout(()=>s({openPopup:e}),0)},type:e,topPicks:m?.length?m:o,isCustomized:!!m?.length,onReset:p&&u?()=>{s({colorTopPicks:{...c.colorTopPicks,[u]:null}})}:void 0}),!f&&(0,W.jsx)(Ww,{}),(0,W.jsxs)(Ty,{open:c.openPopup===e,onOpenChange:t=>{t&&s({openPopup:e})},children:[(0,W.jsx)(IT,{color:t,label:r,type:e,theme:c.theme,mode:e===`elementStroke`?`stroke`:`background`,editingTextElement:!!c.editingTextElement,onToggle:()=>{c.openPopup===e?s({openPopup:null}):(c.openPopup,s({openPopup:e}))}}),c.openPopup===e&&(0,W.jsx)(PT,{type:e,color:t,onChange:n,label:r,elements:i,palette:a,excludedColors:l,updateData:s,getOpenPopup:()=>d.current,appState:c})]})]})})},(e,t)=>e.appState.openPopup===e.type||t.appState.openPopup===t.type?!1:e.type===t.type&&e.color===t.color&&e.label===t.label&&e.appState.openPopup===t.appState.openPopup&&e.palette===t.palette&&e.topPicks===t.topPicks&&e.excludedColors===t.excludedColors&&e.customizableTopPicks===t.customizableTopPicks&&e.appState.theme===t.appState.theme&&e.appState.colorTopPicks===t.appState.colorTopPicks&&!!e.appState.editingTextElement==!!t.appState.editingTextElement),RT=H.forwardRef(({className:e,placeholder:t,onChange:n},r)=>(0,W.jsxs)(`div`,{className:U(`QuickSearch__wrapper`,e),children:[KC,(0,W.jsx)(`input`,{ref:r,className:`QuickSearch__input`,type:`text`,placeholder:t,onChange:e=>n(e.target.value.trim().toLowerCase())})]})),zT=({className:e,placeholder:t,children:n})=>{let r=!H.Children.count(n);return(0,W.jsx)(`div`,{className:U(`ScrollableList__wrapper`,e),role:`menu`,children:r?(0,W.jsx)(`div`,{className:`empty`,children:t}):n})},BT=({children:e,className:t=``,style:n,title:r})=>(0,W.jsxs)(`div`,{className:`dropdown-menu-group ${t}`,style:n,children:[r&&(0,W.jsx)(`p`,{className:`dropdown-menu-group-title`,children:r}),e]}),VT=BT;BT.displayName=`DropdownMenuGroup`;var HT=H.createContext({}),UT=(e=``,t=!1,n=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${t?`dropdown-menu-item--selected`:``} ${n?`dropdown-menu-item--hovered`:``}`.trim(),WT=e=>{let t=(0,H.useContext)(HT);return us(e,e=>{t.onSelect?.(e)})},GT=({children:e,...t})=>(0,W.jsx)(`span`,{...t,style:{textOverflow:`ellipsis`,overflow:`hidden`,whiteSpace:`nowrap`,...t.style},children:e}),KT=({textStyle:e,icon:t,shortcut:n,children:r,badge:i})=>{let a=fU();return(0,W.jsxs)(W.Fragment,{children:[t&&(0,W.jsx)(`div`,{className:`dropdown-menu-item__icon`,children:t}),(0,W.jsx)(`div`,{style:e,className:`dropdown-menu-item__text`,children:(0,W.jsx)(GT,{children:r})}),i&&(0,W.jsx)(`div`,{className:`dropdown-menu-item__badge`,children:i}),n&&a.formFactor!==`phone`&&(0,W.jsx)(`div`,{className:`dropdown-menu-item__shortcut`,children:n})]})},qT=({icon:e,badge:t,value:n,children:r,shortcut:i,className:a,selected:o,onSelect:s,...c})=>{let l=WT(s);return(0,W.jsx)(Yv,{className:`radix-menu-item`,onSelect:l,asChild:!0,children:(0,W.jsx)(`button`,{...c,value:n,className:UT(a,o),title:c.title??c[`aria-label`],children:(0,W.jsx)(KT,{icon:e,shortcut:i,badge:t,children:r})})})};qT.displayName=`DropdownMenuItem`;var JT={GREEN:`green`,RED:`red`,BLUE:`blue`},YT=({type:e=JT.BLUE,children:t})=>{let{theme:n}=gU(),r={display:`inline-flex`,marginLeft:`auto`,padding:`2px 4px`,borderRadius:6,fontSize:9,fontFamily:`Cascadia, monospace`,border:n===P.LIGHT?`1.5px solid white`:`none`};switch(e){case JT.GREEN:Object.assign(r,{backgroundColor:`var(--background-color-badge)`,color:`var(--color-badge)`});break;case JT.RED:Object.assign(r,{backgroundColor:`pink`,color:`darkred`});break;case JT.BLUE:default:Object.assign(r,{background:`var(--color-promo)`,color:`var(--color-surface-lowest)`})}return(0,W.jsx)(`div`,{className:`DropDownMenuItemBadge`,style:r,children:t})};YT.displayName=`DropdownMenuItemBadge`,qT.Badge=YT;var XT=qT,ZT=({event:e,inputRef:t,hoveredFont:n,filteredFonts:r,onClose:i,onSelect:a,onHover:o})=>{if(!e[L.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===L.F)return t.current?.focus(),!0;if(e.key===L.ESCAPE)return i(),!0;if(e.key===L.ENTER)return n?.value&&a(n.value),!0;if(e.key===L.ARROW_DOWN)return n?.next?o(n.next.value):r[0]?.value&&o(r[0].value),!0;if(e.key===L.ARROW_UP)return n?.prev?o(n.prev.value):r[r.length-1]?.value&&o(r[r.length-1].value),!0},QT=e=>{switch(e){case On.Excalifont:case On.Virgil:return Ox;case On.Nunito:case On.Helvetica:return fC;case On[`Lilita One`]:return dC;case On[`Comic Shanns`]:case On.Cascadia:return mC;default:return fC}},$T=(e,t)=>Object.entries(On).find(([,t])=>t===e)?.[0]??t[0]?.fontFace?.family??`Unknown`,eE=H.memo(({selectedFontFamily:e,hoveredFontFamily:t,onSelect:n,onHover:r,onLeave:i,onOpen:a,onClose:o})=>{let{container:s}=mU(),c=uU(),{fonts:l}=c,{showDeprecatedFonts:u}=dU(),d=pU(),[f,p]=(0,H.useState)(``),m=(0,H.useRef)(null),h=(0,H.useMemo)(()=>Array.from(xn.registered.entries()).filter(([e,{metadata:t}])=>!t.private&&!t.fallback).map(([e,{metadata:t,fontFaces:n}])=>{let r={value:e,icon:QT(e),text:$T(e,n)};return t.deprecated&&Object.assign(r,{deprecated:t.deprecated,badge:{type:JT.RED,placeholder:K(`fontList.badge.old`)}}),r}).sort((e,t)=>e.text.toLowerCase()>t.text.toLowerCase()?1:-1),[]),g=(0,H.useMemo)(()=>new Set(l.getSceneFamilies()),[e]),_=(0,H.useMemo)(()=>h.filter(e=>g.has(e.value)),[h,g]),v=(0,H.useMemo)(()=>h.filter(e=>!g.has(e.value)&&(u||!e.deprecated)),[h,g,u]),y=(0,H.useMemo)(()=>Vr([..._,...v].filter(e=>e.text?.toLowerCase().includes(f))),[_,v,f]),b=(0,H.useMemo)(()=>{let n;return t?n=y.find(e=>e.value===t):e&&(n=y.find(t=>t.value===e)),!n&&f&&(y[0]?.value?r(y[0].value):i()),n},[t,e,f,y,r,i]),x=(0,H.useCallback)(e=>{let t=null;if(c.state.editingTextElement){let e=document.querySelector(`.excalidraw-wysiwyg`);e&&(t={start:e.selectionStart,end:e.selectionEnd})}n(e),c.state.editingTextElement&&t&&setTimeout(()=>{let e=document.querySelector(`.excalidraw-wysiwyg`);e&&t&&(e.focus(),e.selectionStart=t.start,e.selectionEnd=t.end)},0)},[n,c.state.editingTextElement]),S=(0,H.useCallback)(e=>{ZT({event:e,inputRef:m,hoveredFont:b,filteredFonts:y,onSelect:x,onHover:r,onClose:o})&&(e.preventDefault(),e.stopPropagation())},[b,y,x,r,o]);(0,H.useEffect)(()=>(a(),()=>{o()}),[]);let C=(0,H.useMemo)(()=>y.filter(e=>g.has(e.value)),[y,g]),w=(0,H.useMemo)(()=>y.filter(e=>!g.has(e.value)),[y,g]),T=({font:t,order:n})=>{let i=(0,H.useRef)(null),a=t.value===b?.value,o=t.value===e;return(0,H.useEffect)(()=>{a&&(n===0?i.current?.scrollIntoView?.({block:`end`}):i.current?.scrollIntoView?.({block:`nearest`}))},[a,n]),(0,W.jsx)(`button`,{ref:i,type:`button`,value:t.value,className:UT(``,o,a),title:t.text,tabIndex:o?0:-1,onClick:e=>{x(Number(e.currentTarget.value))},onMouseMove:()=>{b?.value!==t.value&&r(t.value)},children:(0,W.jsx)(KT,{icon:t.icon,badge:t.badge&&(0,W.jsx)(YT,{type:t.badge.type,children:t.badge.placeholder}),textStyle:{fontFamily:ga({fontFamily:t.value})},children:t.text})})},E=[];return C.length&&E.push((0,W.jsx)(VT,{title:K(`fontList.sceneFonts`),children:C.map((e,t)=>(0,W.jsx)(T,{font:e,order:t},e.value))},`group_1`)),w.length&&E.push((0,W.jsx)(VT,{title:K(`fontList.availableFonts`),children:w.map((e,t)=>(0,W.jsx)(T,{font:e,order:t+C.length},e.value))},`group_2`)),(0,W.jsxs)(rT,{className:`properties-content`,container:s,style:{width:`15rem`},onClose:()=>{o(),c.state.editingTextElement&&setTimeout(()=>{let e=document.querySelector(`.excalidraw-wysiwyg`);e&&e.focus()},0)},onPointerLeave:i,onKeyDown:S,preventAutoFocusOnTouch:!!c.state.editingTextElement,children:[d===`full`&&(0,W.jsx)(RT,{ref:m,placeholder:K(`quickSearch.placeholder`),onChange:ws(p,20)}),(0,W.jsx)(zT,{className:`dropdown-menu fonts manual-hover`,placeholder:K(`fontList.empty`),children:E.length?E:null})]})},(e,t)=>e.selectedFontFamily===t.selectedFontFamily&&e.hoveredFontFamily===t.hoveredFontFamily),tE=({selectedFontFamily:e,isOpened:t=!1,compactMode:n=!1})=>{let r=_U(),i=n?{...ui,width:`2rem`,height:`2rem`}:{};return(0,W.jsx)(Ey,{asChild:!0,children:(0,W.jsx)(`div`,{"data-openpopup":`fontFamily`,className:`properties-trigger`,children:(0,W.jsx)(kw,{type:`toggle`,icon:kx,title:K(`labels.showFonts`),"aria-label":K(`labels.showFonts`),className:`standalone properties-trigger`,"data-testid":`font-family-show-fonts`,checked:t,onSelect:()=>{r(e=>({openPopup:e.openPopup===`fontFamily`?null:e.openPopup}))},style:{border:`none`,...i}})})})},nE=[{value:On.Excalifont,icon:Ox,text:K(`labels.handDrawn`),testId:`font-family-hand-drawn`},{value:On.Nunito,icon:fC,text:K(`labels.normal`),testId:`font-family-normal`},{value:On[`Comic Shanns`],icon:mC,text:K(`labels.code`),testId:`font-family-code`}];new Set(nE.map(e=>e.value));var rE=H.memo(({isOpened:e,selectedFontFamily:t,hoveredFontFamily:n,onSelect:r,onHover:i,onLeave:a,onPopupChange:o,compactMode:s=!1})=>{let c=(0,H.useMemo)(()=>nE,[]),l=(0,H.useCallback)(e=>{e&&r(e)},[r]);return(0,W.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,className:U(`FontPicker__container`,{"FontPicker__container--compact":s}),children:[!s&&(0,W.jsx)(`div`,{className:`buttonList`,children:(0,W.jsx)(Uw,{type:`button`,options:c,value:t,onClick:l})}),!s&&(0,W.jsx)(Ww,{}),(0,W.jsxs)(Ty,{open:e,onOpenChange:o,children:[(0,W.jsx)(tE,{selectedFontFamily:t,isOpened:e,compactMode:s}),e&&(0,W.jsx)(eE,{selectedFontFamily:t,hoveredFontFamily:n,onSelect:l,onHover:i,onLeave:a,onOpen:()=>o(!0),onClose:()=>o(!1)})]})]})},(e,t)=>e.isOpened===t.isOpened&&e.selectedFontFamily===t.selectedFontFamily&&e.hoveredFontFamily===t.hoveredFontFamily),iE=({className:e,icon:t,size:n=`1em`})=>(0,W.jsx)(`span`,{className:e,style:{width:n,height:`100%`,margin:`0 0.5ex 0 0.5ex`,display:`inline-flex`,lineHeight:0,verticalAlign:`middle`,flex:`0 0 auto`},children:t}),aE=({label:e,open:t,openTrigger:n,children:r,className:i,showCollapsedIcon:a=!0})=>(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{style:{cursor:`pointer`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},className:i,onClick:n,children:[e,a&&(0,W.jsx)(iE,{icon:t?gw:hw})]}),t&&(0,W.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`},children:r})]}),oE=yl(!1),sE=4,cE=`default`,lE=e=>e.flatMap(e=>e.options),uE=(e,t)=>{for(let n of e){let e=n.options.find(t);if(e)return e}return null},dE=(e,t)=>e.some(e=>e.options.some(t)),fE=e=>e.flatMap(e=>Array.from({length:Math.ceil(e.options.length/sE)},(t,n)=>e.options.slice(n*sE,n*sE+sE)));function pE({visibleSections:e,hiddenSections:t=[],value:n,label:r,onChange:i,onClose:a}){let{container:o}=mU(),[s,c]=Vb(oE),l=lE([...e,...t]),u=fE([...e,...s?t:[]]),d=e=>{let t=l.find(t=>t.keyBinding===e.key.toLowerCase());if(!(e.metaKey||e.altKey||e.ctrlKey)&&t)i(t.value),e.preventDefault();else if(e.key===L.TAB){let t=l.findIndex(e=>e.value===n),r=e.shiftKey?(l.length+t-1)%l.length:(t+1)%l.length;i(l[r].value)}else if(Yr(e.key)){let t=tx().rtl,r=l.findIndex(e=>e.value===n);if(r!==-1){let a=l.length,o=r;switch(e.key){case t?L.ARROW_LEFT:L.ARROW_RIGHT:o=(r+1)%a;break;case t?L.ARROW_RIGHT:L.ARROW_LEFT:o=(a+r-1)%a;break;case L.ARROW_DOWN:{let t=u.findIndex(e=>e.some(e=>e.value===n)),a=u[t];if(t!==-1&&a){let o=a.findIndex(e=>e.value===n),s=u[(t+1)%u.length];i((s[Math.min(o,s.length-1)]??l[r]).value),e.preventDefault(),e.nativeEvent.stopImmediatePropagation(),e.stopPropagation();return}break}case L.ARROW_UP:{let t=u.findIndex(e=>e.some(e=>e.value===n)),a=u[t];if(t!==-1&&a){let o=a.findIndex(e=>e.value===n),s=u[(u.length+t-1)%u.length];i((s[Math.min(o,s.length-1)]??l[r]).value),e.preventDefault(),e.nativeEvent.stopImmediatePropagation(),e.stopPropagation();return}break}}i(l[o].value)}e.preventDefault()}else(e.key===L.ESCAPE||e.key===L.ENTER)&&(e.preventDefault(),a());e.nativeEvent.stopImmediatePropagation(),e.stopPropagation()};(0,H.useEffect)(()=>{dE(t,e=>e.value===n)&&c(!0)},[n,t,c]);let f=e=>(0,W.jsx)(`div`,{className:`picker-content`,children:e.map(e=>(0,W.jsxs)(`button`,{type:`button`,className:U(`picker-option`,{active:n===e.value}),onClick:()=>{i(e.value)},title:e.keyBinding?`${e.text} \u2014 ${e.keyBinding.toUpperCase()}`:e.text,"aria-label":e.text||`none`,"aria-keyshortcuts":e.keyBinding||void 0,ref:t=>{n===e.value&&setTimeout(()=>{t?.focus()},0)},children:[e.icon,e.keyBinding&&(0,W.jsx)(`span`,{className:`picker-keybinding`,children:e.keyBinding})]},e.text))}),p=e=>e.map((e,t)=>e.name===cE?(0,W.jsx)(H.Fragment,{children:f(e.options)},`${e.name}-${t}`):(0,W.jsxs)(`div`,{className:`picker-section`,children:[(0,W.jsx)(`div`,{className:`picker-section-label`,children:e.name}),f(e.options)]},`${e.name}-${t}`));return(0,W.jsx)(Oy,{className:`picker`,role:`dialog`,"aria-modal":`true`,"aria-label":r,side:`bottom`,align:`start`,sideOffset:12,alignOffset:12,style:{zIndex:`var(--zIndex-ui-styles-popup)`},onKeyDown:d,collisionBoundary:o??void 0,children:(0,W.jsxs)(`div`,{className:`picker-sections`,children:[p(e),t.length>0&&(0,W.jsx)(aE,{label:K(`labels.more_options`),open:s,openTrigger:()=>{c(e=>!e)},className:`picker-collapsible`,children:(0,W.jsx)(`div`,{className:`picker-sections`,children:p(t)})})]})})}function mE({value:e,label:t,visibleSections:n,hiddenSections:r,onChange:i}){let[a,o]=H.useState(!1),s=(0,H.useMemo)(()=>uE(n,t=>t.value===e)??uE(r??[],t=>t.value===e),[n,r,e]);return(0,W.jsx)(`div`,{children:(0,W.jsxs)(Ty,{open:a,onOpenChange:e=>o(e),children:[(0,W.jsx)(Ey,{type:`button`,"aria-label":t,onClick:()=>o(!a),className:a?`active`:``,children:s?.icon}),a&&(0,W.jsx)(pE,{visibleSections:n,hiddenSections:r,value:e,label:t,onChange:i,onClose:()=>{o(!1)}})]})})}var hE=({label:e,value:t,onChange:n,min:r=0,max:i=100,step:a=10,minLabel:o=r,hasCommonValue:s=!0,testId:c})=>{let l=H.useRef(null),u=H.useRef(null);return(0,H.useEffect)(()=>{if(l.current&&u.current){let e=l.current,n=u.current,a=e.offsetWidth,o=parseFloat(getComputedStyle(e).getPropertyValue(`--slider-thumb-size`))||16,s=(t-r)/(i-r||1)*100,c=s/100*(a-o)+o/2;n.style.left=`${c}px`,e.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${s}%, var(--button-bg) ${s}%, var(--button-bg) 100%)`}},[i,r,t]),(0,W.jsxs)(`label`,{className:`control-label`,children:[e,(0,W.jsxs)(`div`,{className:`range-wrapper`,children:[(0,W.jsx)(`input`,{style:{"--color-slider-track":s?void 0:`var(--button-bg)`},ref:l,type:`range`,min:r,max:i,step:a,onChange:e=>{n(+e.target.value)},value:t,className:`range-input`,"data-testid":c}),(0,W.jsx)(`div`,{className:`value-bubble`,ref:u,children:t===r?null:t}),(0,W.jsx)(`div`,{className:`zero-label`,children:o})]})]})},gE={strokeColor:{regular:`currentItemStrokeColor`,sticky:`currentItemStickynoteStrokeColor`},backgroundColor:{regular:`currentItemBackgroundColor`,sticky:`currentItemStickynoteBackgroundColor`}},_E=[Ma.transparent],vE=(e,t)=>oe(e)||z(e)&&Rt(e,t),yE=(e,t,n)=>{let r=d(t),i=e=>n===`strokeColor`?dr(e.type):Ve(e.type),a=ot(t,e,{includeBoundTextElement:n===`strokeColor`}).filter(i),o=e.editingTextElement&&r.get(e.editingTextElement.id),s=o&&Yn(o,n,r);s&&!s.isDeleted&&i(s)&&!a.some(e=>e.id===s.id)&&a.push(s);let c;if(!a.length)c=e.activeTool.type===`stickynote`?`sticky`:`regular`;else{let e=a.filter(e=>vE(e,r)).length;c=e===0?`regular`:e===a.length?`sticky`:`mixed`}let l=gE[n],u=n===`strokeColor`;return{kind:c,property:n,appStateKeys:c===`mixed`?[l.regular,l.sticky]:[l[c]],currentValue:e[c===`sticky`?l.sticky:l.regular],palette:u?Ee:Zr,topPicks:c===`sticky`?u?Ln:Sr:u?mi:Vt,customizableTopPicks:c===`sticky`?u?`stickyNoteStroke`:`stickyNoteBackground`:u?`elementStroke`:`elementBackground`,excludedColors:c===`sticky`?_E:void 0}},bE=(e,t)=>{let n={};for(let r of e.appStateKeys)n[r]=r===`currentItemStickynoteStrokeColor`?Ds(t):r===`currentItemStickynoteBackgroundColor`?nt(t):t;return n},xE=.1,SE=e=>{let t=Ea(e.editorInterface);return{stylesPanelMode:t,isCompact:t!==`full`,isMobile:t===`mobile`}},CE=(e,t,n,r=!1)=>{let i=d(ot(e,t,{includeBoundTextElement:r}));return e.map(e=>{if(i.get(e.id)||e.id===t.editingTextElement?.id){ea(e)||console.error(`[NONDELETED][INVARIANT] changeProperty(): skipping deleted selected/editing element`);let t=n(e);return oe(t)?xi(t):t}return e})},wE=function(e,t,n,r,i){let a=t.state.editingTextElement,o=k(e),s=null;if(a&&(s=n(a)),!s){if(Jc(o,t.state)){let e=t.scene.getSelectedElements(t.state),a=r===!0?e:e.filter(e=>r(e));s=zi(a,n)??(typeof i==`function`?i(!0):i)}else s=typeof i==`function`?i(!1):i}return s},TE=(e,t,n)=>_s(t)||!t.autoResize?t:n.mutateElement(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}),EE=(e,t,n,r,i)=>{let a=new Set,o=n.scene.getNonDeletedElementsMap(),s=CE(e,t,e=>{if(z(e)){let t=r(e);a.add(t);let i=n.scene.getContainerElement(e),s=j(e,Lo(e,t,o));return gt(s,i,n.scene),s=TE(e,s,n.scene),s}return e},!0);return ot(e,t,{includeBoundTextElement:!0}).forEach(e=>{z(e)&&u(e,n.scene)}),{elements:s,appState:{...t,currentItemFontSize:a.size===1?[...a][0]:i??t.currentItemFontSize},captureUpdate:N.IMMEDIATELY}};X({name:`changeStrokeColor`,label:`labels.stroke`,trackEvent:!1,perform:(e,t,n)=>{let{color:r,...i}=n??{};if(r===void 0)return{appState:{...t,...i},captureUpdate:N.EVENTUALLY};let a=yE(t,e,`strokeColor`),o=d(e);return{elements:Tr(CE(e,t,e=>dr(e.type)?j(e,el(e,`strokeColor`,r,o)):e,!0),o),appState:{...t,...i,...bE(a,r)},captureUpdate:N.IMMEDIATELY}},PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>{let{stylesPanelMode:i}=SE(r),a=yE(t,e,`strokeColor`),o=a.kind===`sticky`?K(`labels.textColor`):K(`labels.stroke`);return(0,W.jsxs)(W.Fragment,{children:[i===`full`&&(0,W.jsx)(`h3`,{"aria-hidden":`true`,children:o}),(0,W.jsx)(LT,{topPicks:a.topPicks,palette:a.palette,customizableTopPicks:a.customizableTopPicks,excludedColors:a.excludedColors,type:`elementStroke`,label:o,color:wE(e,r,e=>e.strokeColor,!0,e=>e?null:a.currentValue),onChange:e=>n({color:e}),elements:e,appState:t,updateData:n})]})}}),X({name:`changeBackgroundColor`,label:`labels.changeBackground`,trackEvent:!1,perform:(e,t,n,r)=>{let{color:i,...a}=n??{};if(i===void 0)return{appState:{...t,...a},captureUpdate:N.EVENTUALLY};let o=yE(t,e,`backgroundColor`),s=d(e),c,l=r.scene.getSelectedElements(t);if(!Ke(i)&&l.length>0&&l.every(e=>oa(e)&&pa(e.points))){let t=d(l);c=e.map(e=>t.has(e.id)&&oa(e)?j(e,{backgroundColor:i,...Pt(e,!0)}):e)}else{c=CE(e,t,e=>Yn(e,`backgroundColor`,s)===e?j(e,el(e,`backgroundColor`,i,s)):e);let n=t.editingTextElement&&s.get(t.editingTextElement.id),r=n&&Yn(n,`backgroundColor`,s);r&&r!==n&&(c=c.map(e=>e.id===r.id?j(e,el(e,`backgroundColor`,i,s)):e))}return{elements:c,appState:{...t,...a,...bE(o,i)},captureUpdate:N.IMMEDIATELY}},PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>{let{stylesPanelMode:i}=SE(r),a=yE(t,e,`backgroundColor`),o=r.scene.getNonDeletedElementsMap();return(0,W.jsxs)(W.Fragment,{children:[i===`full`&&(0,W.jsx)(`h3`,{"aria-hidden":`true`,children:K(`labels.background`)}),(0,W.jsx)(LT,{topPicks:a.topPicks,palette:a.palette,customizableTopPicks:a.customizableTopPicks,excludedColors:a.excludedColors,type:`elementBackground`,label:K(`labels.background`),color:wE(e,r,e=>Yn(e,`backgroundColor`,o).backgroundColor,!0,e=>e?null:a.currentValue),onChange:e=>n({color:e}),elements:e,appState:t,updateData:n})]})}});var DE=X({name:`changeBucketFillBackgroundColor`,label:`labels.changeBackground`,trackEvent:!1,perform:(e,t,n)=>({appState:{...t,...n},captureUpdate:N.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>{let{stylesPanelMode:i}=SE(r);return(0,W.jsxs)(W.Fragment,{children:[i===`full`&&(0,W.jsx)(`h3`,{"aria-hidden":`true`,children:K(`labels.background`)}),(0,W.jsx)(LT,{topPicks:Je,palette:Zr,excludedColors:[Ma.transparent],customizableTopPicks:`bucketFill`,type:`elementBackground`,label:K(`labels.background`),color:r.bucketFill.getBucketFillBackgroundColor(t.currentItemBackgroundColor),onChange:e=>n({currentItemBackgroundColor:e}),elements:e,appState:t,updateData:n})]})}});X({name:`changeFillStyle`,label:`labels.fill`,trackEvent:!1,perform:(e,t,n,r)=>(Vw(`element`,`changeFillStyle`,`${n} (${r.editorInterface.formFactor===`phone`?`mobile`:`desktop`})`),{elements:CE(e,t,e=>Bt(e.type)?j(e,{fillStyle:n}):e),appState:{...t,currentItemFillStyle:n},captureUpdate:N.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>{let i=ot(e,t).filter(e=>Bt(e.type)),a=i.length>0&&i.every(e=>e.fillStyle===`zigzag`);return(0,W.jsxs)(`fieldset`,{children:[(0,W.jsx)(`legend`,{children:K(`labels.fill`)}),(0,W.jsx)(`div`,{className:`buttonList`,children:(0,W.jsx)(Uw,{type:`button`,options:[{value:`hachure`,text:`${K(a?`labels.zigzag`:`labels.hachure`)} (${Z(`Alt-Click`)})`,icon:a?kS:AS,active:a?!0:void 0,testId:`fill-hachure`},{value:`cross-hatch`,text:K(`labels.crossHatch`),icon:jS,testId:`fill-cross-hatch`},{value:`solid`,text:K(`labels.solid`),icon:MS,testId:`fill-solid`}],value:wE(e,r,e=>e.fillStyle,e=>Bt(e.type),e=>e?null:t.currentItemFillStyle),onClick:(e,t)=>{n(t.altKey&&e===`hachure`&&i.every(e=>e.fillStyle===`hachure`)?`zigzag`:e)}})})]})}});var OE=e=>ii.find(t=>al(e.type,t)===e.strokeWidth)??null,kE=(e,t)=>al(e.type,t);X({name:`changeStrokeWidth`,label:`labels.strokeWidth`,trackEvent:!1,perform:(e,t,n)=>(eo(n,`actionChangeStrokeWidth: value must be defined`),{elements:CE(e,t,e=>j(e,{strokeWidth:kE(e,n)})),appState:{...t,currentItemStrokeWidthKey:n},captureUpdate:N.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>(0,W.jsxs)(`fieldset`,{children:[(0,W.jsx)(`legend`,{children:K(`labels.strokeWidth`)}),(0,W.jsx)(`div`,{className:`buttonList`,children:(0,W.jsx)(Uw,{group:`stroke-width`,options:[{value:`thin`,text:K(`labels.thin`),icon:NS,testId:`strokeWidth-thin`},{value:`medium`,text:K(`labels.medium`),icon:PS,testId:`strokeWidth-medium`},{value:`bold`,text:K(`labels.bold`),icon:FS,testId:`strokeWidth-bold`}],value:wE(e,r,OE,e=>e.hasOwnProperty(`strokeWidth`),e=>e?null:t.currentItemStrokeWidthKey),onChange:e=>n(e)})})]})}),X({name:`changeSloppiness`,label:`labels.sloppiness`,trackEvent:!1,perform:(e,t,n)=>({elements:CE(e,t,e=>j(e,{seed:Zt(),roughness:n})),appState:{...t,currentItemRoughness:n},captureUpdate:N.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>(0,W.jsxs)(`fieldset`,{children:[(0,W.jsx)(`legend`,{children:K(`labels.sloppiness`)}),(0,W.jsx)(`div`,{className:`buttonList`,children:(0,W.jsx)(Uw,{group:`sloppiness`,options:[{value:0,text:K(`labels.architect`),icon:RS},{value:1,text:K(`labels.artist`),icon:zS},{value:2,text:K(`labels.cartoonist`),icon:BS}],value:wE(e,r,e=>e.roughness,e=>e.hasOwnProperty(`roughness`),e=>e?null:t.currentItemRoughness),onChange:e=>n(e)})})]})}),X({name:`changeFreedrawMode`,label:`labels.pressure`,trackEvent:!1,perform:(e,t,n)=>{let r=n||`constant`;return{elements:CE(e,t,e=>e.type===`freedraw`?j(e,{strokeOptions:{...e.strokeOptions,variability:r}}):e),appState:{...t,currentItemStrokeVariability:r},captureUpdate:N.IMMEDIATELY}},PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>{let a=wE(e,r,e=>e.strokeOptions?.variability,e=>e.type===`freedraw`,e=>e?null:t.currentItemStrokeVariability)??t.currentItemStrokeVariability;if(i?.cycle){let e=a===`variable`;return(0,W.jsx)(kw,{type:`button`,icon:e?HS:VS,title:K(`labels.pressure`),"aria-label":K(`labels.pressure`),onClick:()=>n(e?`constant`:`variable`)})}return(0,W.jsxs)(`fieldset`,{children:[(0,W.jsx)(`legend`,{children:K(`labels.pressure`)}),(0,W.jsx)(`div`,{className:`buttonList`,children:(0,W.jsx)(Uw,{group:`strokeOptions.variability`,options:[{value:`constant`,text:K(`labels.pressure_constant`),icon:VS},{value:`variable`,text:K(`labels.pressure_variable`),icon:HS}],value:a,onChange:e=>n(e)})})]})}}),X({name:`changeStrokeStyle`,label:`labels.strokeStyle`,trackEvent:!1,perform:(e,t,n)=>({elements:CE(e,t,e=>j(e,{strokeStyle:n})),appState:{...t,currentItemStrokeStyle:n},captureUpdate:N.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>(0,W.jsxs)(`fieldset`,{children:[(0,W.jsx)(`legend`,{children:K(`labels.strokeStyle`)}),(0,W.jsx)(`div`,{className:`buttonList`,children:(0,W.jsx)(Uw,{group:`strokeStyle`,options:[{value:`solid`,text:K(`labels.strokeStyle_solid`),icon:NS},{value:`dashed`,text:K(`labels.strokeStyle_dashed`),icon:IS},{value:`dotted`,text:K(`labels.strokeStyle_dotted`),icon:LS}],value:wE(e,r,e=>e.strokeStyle,e=>e.hasOwnProperty(`strokeStyle`),e=>e?null:t.currentItemStrokeStyle),onChange:e=>n(e)})})]})}),X({name:`changeOpacity`,label:`labels.opacity`,trackEvent:!1,perform:(e,t,n)=>({elements:CE(e,t,e=>j(e,{opacity:n}),!0),appState:{...t,currentItemOpacity:n},captureUpdate:N.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,app:n,updateData:r})=>{let i=wE(e,n,e=>e.opacity,!0,e=>e?null:t.currentItemOpacity);return(0,W.jsx)(hE,{label:K(`labels.opacity`),value:i??t.currentItemOpacity,hasCommonValue:i!==null,onChange:r,min:0,max:100,step:10,testId:`opacity`})}}),X({name:`changeFontSize`,label:`labels.fontSize`,trackEvent:!1,perform:(e,t,n,r)=>EE(e,t,r,()=>(eo(n,`actionChangeFontSize: Expected a font size value`),n),n),PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>{let{isCompact:a}=SE(r);return(0,W.jsxs)(`fieldset`,{children:[(0,W.jsx)(`legend`,{children:K(`labels.fontSize`)}),(0,W.jsx)(`div`,{className:`buttonList`,children:(0,W.jsx)(Uw,{group:`font-size`,options:[{value:qc.sm,text:K(`labels.small`),icon:oC,testId:`fontSize-small`},{value:qc.md,text:K(`labels.medium`),icon:sC,testId:`fontSize-medium`},{value:qc.lg,text:K(`labels.large`),icon:cC,testId:`fontSize-large`},{value:qc.xl,text:K(`labels.veryLarge`),icon:lC,testId:`fontSize-veryLarge`}],value:wE(e,r,e=>{let t=r.scene.getNonDeletedElementsMap();if(z(e))return vc(e,t);let n=Ga(e,t);return n?vc(n,t):null},e=>z(e)||Ga(e,r.scene.getNonDeletedElementsMap())!==null,e=>e?null:t.currentItemFontSize||20),onChange:e=>{sT(()=>n(e),a,!!t.editingTextElement,i?.onPreventClose)}})})]})}});var AE=X({name:`decreaseFontSize`,label:`labels.decreaseFontSize`,icon:uC,trackEvent:!1,perform:(e,t,n,r)=>EE(e,t,r,e=>Math.round(1/(1+xE)*vc(e,r.scene.getNonDeletedElementsMap()))),keyTest:e=>e[L.CTRL_OR_CMD]&&e.shiftKey&&(e.key===L.CHEVRON_LEFT||e.key===L.COMMA)}),jE=X({name:`increaseFontSize`,label:`labels.increaseFontSize`,icon:uC,trackEvent:!1,perform:(e,t,n,r)=>EE(e,t,r,e=>Math.round(vc(e,r.scene.getNonDeletedElementsMap())*(1+xE))),keyTest:e=>e[L.CTRL_OR_CMD]&&e.shiftKey&&(e.key===L.CHEVRON_RIGHT||e.key===L.PERIOD)});X({name:`changeFontFamily`,label:`labels.fontFamily`,trackEvent:!1,perform:(e,t,n,r)=>{let{cachedElements:i,resetAll:a,resetContainers:o,...s}=n;if(a)return{elements:CE(e,t,e=>{let t=i?.get(e.id);return t?j(e,{...t}):e},!0),appState:{...t,...s},captureUpdate:N.NEVER};eo(n,`actionChangeFontFamily: value must be defined`);let{currentItemFontFamily:c,currentHoveredFontFamily:l}=n,u=N.EVENTUALLY,d,f=!1;if(c)d=c,u=N.IMMEDIATELY;else if(l){d=l,u=N.EVENTUALLY;let n=ot(e,t,{includeBoundTextElement:!0}).filter(e=>z(e));if(n.length>200)f=!0;else{let e=0,t=0;for(;e<n.length&&t<5e3;){let r=n[e];t+=r?.originalText.length||0,e++}t>5e3&&(f=!0)}}let p={appState:{...t,...s},captureUpdate:u};if(d&&!f){let n=new Map,a=new Set,s=!1,u=Array.from(xn.loadedFontsCache.values()),f=Object.entries(On).find(([e,t])=>t===d)?.[0];l&&f&&u.some(e=>e.startsWith(f))&&(s=!0),Object.assign(p,{elements:CE(e,t,e=>{if(z(e)&&(e.fontFamily!==d||c)){let t=j(e,{fontFamily:d,lineHeight:qt(d)}),c=i?.get(e.containerId||``)||{},l=r.scene.getContainerElement(e);return o&&l&&c&&r.scene.mutateElement(l,{...c}),s||(a=new Set([...a,...Array.from(t.originalText)])),n.set(t,l),t}return e},!0)});let m=`10px ${ga({fontFamily:d})}`,h=Array.from(a.values()).join(),g=r.props.ownerDocument??document;if(s||g.fonts.check(m,h))for(let[e,t]of n)gt(e,t,r.scene);else g.fonts.load(m,h).then(e=>{for(let[e,t]of n){let n=r.scene.getElement(e.id),i=t?r.scene.getElement(t.id):null;n&>(n,i,r.scene)}r.fonts.onLoaded(e)})}return p},PanelComponent:({elements:e,appState:t,app:n,updateData:r})=>{let i=(0,H.useRef)(new Map),a=(0,H.useRef)(null),[o,s]=(0,H.useState)({}),c=(0,H.useRef)(!0),{stylesPanelMode:l,isCompact:u}=SE(n),d=(0,H.useMemo)(()=>{let r=(e,r)=>wE(e,n,e=>{if(z(e))return e.fontFamily;let t=Ga(e,r);return t?t.fontFamily:null},e=>z(e)||Ga(e,r)!==null,e=>e?null:t.currentItemFontFamily||jr);return o.openPopup===`fontFamily`&&t.openPopup===`fontFamily`?r(Array.from(i.current?.values()??[]),i.current):!o.openPopup&&t.openPopup!==`fontFamily`?r(e,n.scene.getNonDeletedElementsMap()):a.current},[o.openPopup,t,e,n]);return(0,H.useEffect)(()=>{a.current=d},[d]),(0,H.useEffect)(()=>{Object.keys(o).length&&(r(o),s({}))},[o]),(0,H.useEffect)(()=>(c.current=!1,()=>{c.current=!0}),[]),(0,W.jsxs)(W.Fragment,{children:[l===`full`&&(0,W.jsx)(`legend`,{children:K(`labels.fontFamily`)}),(0,W.jsx)(rE,{isOpened:t.openPopup===`fontFamily`,selectedFontFamily:d,hoveredFontFamily:t.currentHoveredFontFamily,compactMode:l!==`full`,onSelect:e=>{sT(()=>{s({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:e}),i.current.clear()},u,!!t.editingTextElement)},onHover:e=>{s({currentHoveredFontFamily:e,cachedElements:new Map(i.current),resetContainers:!0})},onLeave:()=>{s({currentHoveredFontFamily:null,cachedElements:new Map(i.current),resetAll:!0})},onPopupChange:r=>{if(r){i.current.clear();let{editingTextElement:r}=t;if(r?.type===`text`){let e=n.scene.getElement(r.id);i.current.set(r.id,j(e||r,{},!0))}else{let n=ot(e,t,{includeBoundTextElement:!0});for(let e of n)i.current.set(e.id,j(e,{},!0))}s({...o,openPopup:`fontFamily`})}else{let e={currentHoveredFontFamily:null,cachedElements:new Map(i.current),resetAll:!0};s({...e}),i.current.clear(),u&&t.editingTextElement&&oT(null,n.ownerDocument)}}})]})}}),X({name:`changeTextAlign`,label:`Change text alignment`,trackEvent:!1,perform:(e,t,n,r)=>({elements:CE(e,t,e=>{if(z(e)){let t=j(e,{textAlign:n});return gt(t,r.scene.getContainerElement(e),r.scene),t}return e},!0),appState:{...t,currentItemTextAlign:n},captureUpdate:N.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>{let a=r.scene.getNonDeletedElementsMap(),{isCompact:o}=SE(r);return(0,W.jsxs)(`fieldset`,{children:[(0,W.jsx)(`legend`,{children:K(`labels.textAlign`)}),(0,W.jsx)(`div`,{className:`buttonList`,children:(0,W.jsx)(Uw,{group:`text-align`,options:[{value:`left`,text:K(`labels.left`),icon:hC,testId:`align-left`},{value:`center`,text:K(`labels.center`),icon:gC,testId:`align-horizontal-center`},{value:`right`,text:K(`labels.right`),icon:_C,testId:`align-right`}],value:wE(e,r,e=>{if(z(e))return e.textAlign;let t=Ga(e,a);return t?t.textAlign:null},e=>z(e)||Ga(e,a)!==null,e=>e?null:t.currentItemTextAlign),onChange:e=>{sT(()=>n(e),o,!!t.editingTextElement,i?.onPreventClose)}})})]})}}),X({name:`changeVerticalAlign`,label:`Change vertical alignment`,trackEvent:{category:`element`},perform:(e,t,n,r)=>({elements:CE(e,t,e=>{if(z(e)){let t=j(e,{verticalAlign:n});return gt(t,r.scene.getContainerElement(e),r.scene),t}return e},!0),appState:{...t},captureUpdate:N.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>{let{isCompact:a}=SE(r);return(0,W.jsx)(`fieldset`,{children:(0,W.jsx)(`div`,{className:`buttonList`,children:(0,W.jsx)(Uw,{group:`text-align`,options:[{value:$t.TOP,text:K(`labels.alignTop`),icon:(0,W.jsx)(vC,{theme:t.theme}),testId:`align-top`},{value:$t.MIDDLE,text:K(`labels.centerVertically`),icon:(0,W.jsx)(bC,{theme:t.theme}),testId:`align-middle`},{value:$t.BOTTOM,text:K(`labels.alignBottom`),icon:(0,W.jsx)(yC,{theme:t.theme}),testId:`align-bottom`}],value:wE(e,r,e=>{if(z(e)&&e.containerId)return e.verticalAlign;let t=Ga(e,r.scene.getNonDeletedElementsMap());return t?t.verticalAlign:null},e=>z(e)||Ga(e,r.scene.getNonDeletedElementsMap())!==null,e=>e?null:$t.MIDDLE),onChange:e=>{sT(()=>n(e),a,!!t.editingTextElement,i?.onPreventClose)}})})})}}),X({name:`changeRoundness`,label:`Change edge roundness`,trackEvent:!1,perform:(e,t,n)=>({elements:CE(e,t,e=>Br(e)?e:j(e,{roundness:n===`round`?{type:In(e.type)?Pa.ADAPTIVE_RADIUS:Pa.PROPORTIONAL_RADIUS}:null})),appState:{...t,currentItemRoundness:n},captureUpdate:N.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r,renderAction:i})=>{let a=as(k(e),t).some(e=>e.roundness?.type===Pa.LEGACY);return(0,W.jsxs)(`fieldset`,{children:[(0,W.jsx)(`legend`,{children:K(`labels.edges`)}),(0,W.jsxs)(`div`,{className:`buttonList`,children:[(0,W.jsx)(Uw,{group:`edges`,options:[{value:`sharp`,text:K(`labels.sharp`),icon:US},{value:`round`,text:K(`labels.round`),icon:WS}],value:wE(e,r,e=>a?null:e.roundness?`round`:`sharp`,e=>!ye(e)&&e.hasOwnProperty(`roundness`),e=>e?null:t.currentItemRoundness),onChange:e=>n(e)}),i(`togglePolygon`)]})]})}});var ME=e=>({visibleSections:[{name:`default`,options:[{value:null,text:K(`labels.arrowhead_none`),keyBinding:`q`,icon:(0,W.jsx)(GS,{flip:e})},{value:`arrow`,text:K(`labels.arrowhead_arrow`),keyBinding:`w`,icon:(0,W.jsx)(KS,{flip:e})},{value:`triangle`,text:K(`labels.arrowhead_triangle`),icon:(0,W.jsx)(qS,{flip:e}),keyBinding:`e`},{value:`triangle_outline`,text:K(`labels.arrowhead_triangle_outline`),icon:(0,W.jsx)(JS,{flip:e}),keyBinding:`r`}]}],hiddenSections:[{name:`default`,options:[{value:`circle`,text:K(`labels.arrowhead_circle`),keyBinding:`a`,icon:(0,W.jsx)(YS,{flip:e})},{value:`circle_outline`,text:K(`labels.arrowhead_circle_outline`),keyBinding:`s`,icon:(0,W.jsx)(XS,{flip:e})},{value:`diamond`,text:K(`labels.arrowhead_diamond`),icon:(0,W.jsx)(ZS,{flip:e}),keyBinding:`d`},{value:`diamond_outline`,text:K(`labels.arrowhead_diamond_outline`),icon:(0,W.jsx)(QS,{flip:e}),keyBinding:`f`},{value:`bar`,text:K(`labels.arrowhead_bar`),keyBinding:`z`,icon:(0,W.jsx)($S,{flip:e})}]},{name:K(`labels.cardinality`),options:[{value:`cardinality_one`,text:K(`labels.arrowhead_cardinality_one`),icon:(0,W.jsx)(eC,{flip:e}),keyBinding:`x`},{value:`cardinality_many`,text:K(`labels.arrowhead_cardinality_many`),icon:(0,W.jsx)(tC,{flip:e}),keyBinding:`c`},{value:`cardinality_one_or_many`,text:K(`labels.arrowhead_cardinality_one_or_many`),icon:(0,W.jsx)(nC,{flip:e}),keyBinding:`v`},{value:`cardinality_exactly_one`,text:K(`labels.arrowhead_cardinality_exactly_one`),icon:(0,W.jsx)(rC,{flip:e}),keyBinding:null},{value:`cardinality_zero_or_one`,text:K(`labels.arrowhead_cardinality_zero_or_one`),icon:(0,W.jsx)(iC,{flip:e}),keyBinding:null},{value:`cardinality_zero_or_many`,text:K(`labels.arrowhead_cardinality_zero_or_many`),icon:(0,W.jsx)(aC,{flip:e}),keyBinding:null}]}]});X({name:`changeArrowhead`,label:`Change arrowheads`,trackEvent:!1,perform:(e,t,n)=>(eo(n,`actionChangeArrowhead: value must be defined`),{elements:CE(e,t,e=>{if(ro(e)){let{position:t,type:r}=n;if(t===`start`)return j(e,{startArrowhead:r});if(t===`end`)return j(e,{endArrowhead:r})}return e}),appState:{...t,[n.position===`start`?`currentItemStartArrowhead`:`currentItemEndArrowhead`]:n.type},captureUpdate:N.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>{let i=tx().rtl,a=(0,H.useMemo)(()=>ME(!i),[i]),o=(0,H.useMemo)(()=>ME(!!i),[i]);return(0,W.jsxs)(`fieldset`,{children:[(0,W.jsx)(`legend`,{children:K(`labels.arrowheads`)}),(0,W.jsxs)(`div`,{className:`iconSelectList buttonList`,children:[(0,W.jsx)(mE,{visibleSections:a.visibleSections,hiddenSections:a.hiddenSections,label:`arrowhead_start`,value:wE(e,r,e=>ro(e)&&_e(e.type)?dc(e.startArrowhead):t.currentItemStartArrowhead,!0,e=>e?null:t.currentItemStartArrowhead),onChange:e=>n({position:`start`,type:e})}),(0,W.jsx)(mE,{visibleSections:o.visibleSections,hiddenSections:o.hiddenSections,label:`arrowhead_end`,value:wE(e,r,e=>ro(e)&&_e(e.type)?dc(e.endArrowhead):t.currentItemEndArrowhead,!0,e=>e?null:t.currentItemEndArrowhead),onChange:e=>n({position:`end`,type:e})})]})]})}}),X({name:`changeArrowProperties`,label:`Change arrow properties`,trackEvent:!1,perform:(e,t,n,r)=>!1,PanelComponent:({elements:e,appState:t,updateData:n,app:r,renderAction:i})=>(0,W.jsxs)(`div`,{className:`selected-shape-actions`,children:[i(`changeArrowhead`),i(`changeArrowType`)]})}),X({name:`changeArrowType`,label:`Change arrow types`,trackEvent:!1,perform:(e,t,n,r)=>{let i=CE(e,t,e=>{if(!ye(e))return e;let i=r.scene.getNonDeletedElementsMap(),a=I.getPointAtIndexGlobalCoordinates(e,0,i),o=I.getPointAtIndexGlobalCoordinates(e,-1,i),s=j(e,{x:n===Nt.elbow?a[0]:e.x,y:n===Nt.elbow?a[1]:e.y,roundness:n===Nt.round?{type:Pa.PROPORTIONAL_RADIUS}:null,elbowed:n===Nt.elbow,angle:n===Nt.elbow?0:e.angle,points:n===Nt.elbow||e.elbowed?[I.pointFromAbsoluteCoords({...e,x:a[0],y:a[1],angle:0},a,i),I.pointFromAbsoluteCoords({...e,x:a[0],y:a[1],angle:0},o,i)]:e.points});if(Br(s)){s.fixedSegments=null;let e=r.scene.getNonDeletedElementsMap();r.dismissLinearEditor();let n=I.getPointAtIndexGlobalCoordinates(s,0,e),i=I.getPointAtIndexGlobalCoordinates(s,-1,e),a=s.startBinding&&e.get(s.startBinding.elementId),o=s.endBinding&&e.get(s.endBinding.elementId),c=a&&s.startBinding?{...s.startBinding,...Pr(s,a,`start`,e,t.isBindingEnabled)}:null,l=o&&s.endBinding?{...s.endBinding,...Pr(s,o,`end`,e,t.isBindingEnabled)}:null;s={...s,startBinding:c,endBinding:l,...Bc(s,e,{points:[n,i].map(e=>F(e[0]-s.x,e[1]-s.y)),startBinding:c,endBinding:l,fixedSegments:null})}}else{let e=r.scene.getNonDeletedElementsMap();if(s.startBinding){let n=e.get(s.startBinding.elementId);n&&kc(s,n,t.bindMode===`inside`?`inside`:`orbit`,`start`,r.scene)}if(s.endBinding){let n=e.get(s.endBinding.elementId);n&&kc(s,n,t.bindMode===`inside`?`inside`:`orbit`,`end`,r.scene)}}return s}),a={...t,currentItemArrowType:n},o=t.selectedLinearElement?.elementId;if(o){let t=i.find(e=>e.id===o);t&&(a.selectedLinearElement=new I(t,d(e)))}return{elements:i,appState:a,captureUpdate:N.IMMEDIATELY}},PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,W.jsxs)(`fieldset`,{children:[(0,W.jsx)(`legend`,{children:K(`labels.arrowtypes`)}),(0,W.jsx)(`div`,{className:`buttonList`,children:(0,W.jsx)(Uw,{group:`arrowtypes`,options:[{value:Nt.sharp,text:K(`labels.arrowtype_sharp`),icon:fw,testId:`sharp-arrow`},{value:Nt.round,text:K(`labels.arrowtype_round`),icon:mw,testId:`round-arrow`},{value:Nt.elbow,text:K(`labels.arrowtype_elbowed`),icon:pw,testId:`elbow-arrow`}],value:wE(e,r,e=>ye(e)?e.elbowed?Nt.elbow:e.roundness?Nt.round:Nt.sharp:null,e=>ye(e),e=>e?null:t.currentItemArrowType),onChange:e=>n(e)})})]})});var NE=()=>{let e=document.querySelector(`.excalidraw-tooltip`);if(e)return e;let t=document.createElement(`div`);return document.body.appendChild(t),t.classList.add(`excalidraw-tooltip`),t},PE=(e,t,n=`bottom`)=>{let r=e.getBoundingClientRect(),i=window.innerWidth,a=window.innerHeight,o=t.left+t.width/2-r.width/2;o<0?o=5:o+r.width>=i&&(o=i-r.width-5);let s;n===`bottom`?(s=t.top+t.height+5,s+r.height>=a&&(s=t.top-r.height-5)):(s=t.top-r.height-5,s<0&&(s=t.top+t.height+5)),Object.assign(e.style,{top:`${s}px`,left:`${o}px`})},FE=(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,PE(t,e.getBoundingClientRect())},IE=({children:e,label:t,long:n=!1,style:r,disabled:i})=>((0,H.useEffect)(()=>()=>NE().classList.remove(`excalidraw-tooltip--visible`),[]),i?null:(0,W.jsx)(`div`,{className:`excalidraw-tooltip-wrapper`,onPointerEnter:e=>FE(e.currentTarget,NE(),t,n),onPointerLeave:()=>NE().classList.remove(`excalidraw-tooltip--visible`),style:r,children:e})),LE=(e,t)=>typeof t==`function`?t(e):Array.isArray(t)?e:e[t],RE=(e,t,n)=>{if(e?.isDestroyed)return;let r=e?.getAppState();if(!r){if(!n)return;console.warn(`useAppStateValue: excalidrawAPI not defined yet for internal component while it should always be defined. Are you sure you're rendering inside of <Excalidraw/> component tree?`),r=Object.assign({width:0,height:0,offsetLeft:0,offsetTop:0},Gt())}return LE(r,t)};function zE(e,t=!0){let n=yU(),[,r]=(0,H.useState)(0),i=(0,H.useRef)(null);return i.current||={selector:e,isInitialized:!!n,latestValue:RE(n,e,t)},i.current.selector=e,!i.current.isInitialized&&n&&!n.isDestroyed&&(i.current.isInitialized=!0,i.current.latestValue=RE(n,e,t)),(0,H.useEffect)(()=>{let e=i.current;if(n&&!n.isDestroyed&&e)return n.onStateChange(e.selector,t=>{e.latestValue=t,r(e=>e+1)})},[n]),i.current.latestValue}function BE(e,t){let n=yU(),r=(0,H.useRef)({selector:e,callback:t});r.current.selector=e,r.current.callback=t,(0,H.useEffect)(()=>{if(n&&!n.isDestroyed)return r.current.callback(RE(n,r.current.selector,!0),n.getAppState()),n.onStateChange(r.current.selector,(e,t)=>{r.current.callback(e,t)})},[n])}X({name:`changeViewBackgroundColor`,label:`labels.canvasBackground`,trackEvent:!1,predicate:(e,t,n,r)=>!!r.props.UIOptions.canvasActions.changeViewBackgroundColor&&!t.viewModeEnabled,perform:(e,t,n)=>({appState:{...t,...n},captureUpdate:n?.viewBackgroundColor?N.IMMEDIATELY:N.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:n,appProps:r,data:i})=>(0,W.jsx)(LT,{palette:null,topPicks:x,label:K(`labels.canvasBackground`),type:`canvasBackground`,color:t.viewBackgroundColor,onChange:e=>n({viewBackgroundColor:e}),"data-testid":`canvas-background-picker`,elements:e,appState:t,updateData:n})});var VE=X({name:`clearCanvas`,label:`labels.clearCanvas`,icon:Ix,trackEvent:{category:`canvas`},predicate:(e,t,n,r)=>!!r.props.UIOptions.canvasActions.clearCanvas&&!t.viewModeEnabled&&t.openDialog?.name!==`elementLinkSelector`,perform:(e,t,n,r)=>(r.imageCache.clear(),{elements:e.map(e=>j(e,{isDeleted:!0})),appState:{...Gt(),files:{},theme:t.theme,penMode:t.penMode,penDetected:t.penDetected,exportBackground:t.exportBackground,exportEmbedScene:t.exportEmbedScene,gridSize:t.gridSize,gridStep:t.gridStep,gridModeEnabled:t.gridModeEnabled,stats:t.stats,colorTopPicks:t.colorTopPicks,activeTool:t.activeTool.type===`image`?{...t.activeTool,type:r.state.preferredSelectionTool.type}:t.activeTool},captureUpdate:N.IMMEDIATELY})}),HE=X({name:`zoomIn`,label:`buttons.zoomIn`,viewMode:!0,navigation:!0,icon:Nx,trackEvent:{category:`canvas`},predicate:(e,t,n,r)=>r.isNavigationEnabled(),perform:(e,t,n,r)=>(r.requestUnfollow(),{appState:{...t,...ba({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:Io(t.zoom.value+Dt)},t)},captureUpdate:N.EVENTUALLY}),PanelComponent:({updateData:e})=>{let t=zE(e=>e.zoom.value);return(0,W.jsx)(kw,{type:`button`,className:`zoom-in-button zoom-button`,icon:Nx,title:`${K(`buttons.zoomIn`)} \u2014 ${Z(`CtrlOrCmd++`)}`,"aria-label":K(`buttons.zoomIn`),disabled:t>=30,onClick:()=>{e(null)}})},keyTest:e=>(e.code===xt.EQUAL||e.code===xt.NUM_ADD)&&(e[L.CTRL_OR_CMD]||e.shiftKey)}),UE=X({name:`zoomOut`,label:`buttons.zoomOut`,icon:Px,viewMode:!0,navigation:!0,trackEvent:{category:`canvas`},predicate:(e,t,n,r)=>r.isNavigationEnabled(),perform:(e,t,n,r)=>(r.requestUnfollow(),{appState:{...t,...ba({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:Io(t.zoom.value-Dt)},t)},captureUpdate:N.EVENTUALLY}),PanelComponent:({updateData:e})=>{let t=zE(e=>e.zoom.value);return(0,W.jsx)(kw,{type:`button`,className:`zoom-out-button zoom-button`,icon:Px,title:`${K(`buttons.zoomOut`)} \u2014 ${Z(`CtrlOrCmd+-`)}`,"aria-label":K(`buttons.zoomOut`),disabled:t<=Ps,onClick:()=>{e(null)}})},keyTest:e=>(e.code===xt.MINUS||e.code===xt.NUM_SUBTRACT)&&(e[L.CTRL_OR_CMD]||e.shiftKey)}),WE=X({name:`resetZoom`,label:`buttons.resetZoom`,icon:Fx,viewMode:!0,navigation:!0,trackEvent:{category:`canvas`},predicate:(e,t,n,r)=>r.isNavigationEnabled(),perform:(e,t,n,r)=>{r.requestUnfollow();let i=t.scrollConstraints?.lockZoom?t.scrollConstraints.zoom:1;return{appState:{...t,...ba({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:Io(i)},t)},captureUpdate:N.EVENTUALLY}},PanelComponent:({updateData:e})=>{let t=zE(e=>e.zoom.value);return(0,W.jsx)(IE,{label:K(`buttons.resetZoom`),style:{height:`100%`},children:(0,W.jsxs)(kw,{type:`button`,className:`reset-zoom-button zoom-button`,title:K(`buttons.resetZoom`),"aria-label":K(`buttons.resetZoom`),onClick:()=>{e(null)},children:[(t*100).toFixed(0),`%`]})})},keyTest:e=>(e.code===xt.ZERO||e.code===xt.NUM_ZERO)&&(e[L.CTRL_OR_CMD]||e.shiftKey)}),GE=e=>[e.x,e.y,e.x+e.width,e.y+e.height];X({name:`zoomToFitSelectionInViewport`,label:`labels.zoomToFitViewport`,icon:rw,viewMode:!0,navigation:!0,trackEvent:{category:`canvas`},predicate:(e,t,n,r)=>r.isNavigationEnabled(),perform:(e,t,n,r)=>{r.requestUnfollow();let i=r.scene.getSelectedElements(t),a=i.length?Wr(k(i)):t.scrollConstraints?GE(t.scrollConstraints):Wr(k(e)),o=Ss({bounds:a,appState:t,fit:`scale-down`,canvasOffsets:r.viewport.getOffsets()});return{...o,appState:{...o.appState,...Eo(o.appState)}}},keyTest:e=>e.code===xt.TWO&&e.shiftKey&&!e.altKey&&!e[L.CTRL_OR_CMD]}),X({name:`zoomToFitSelection`,label:`helpDialog.zoomToSelection`,icon:rw,viewMode:!0,navigation:!0,trackEvent:{category:`canvas`},predicate:(e,t,n,r)=>r.isNavigationEnabled(),perform:(e,t,n,r)=>{r.requestUnfollow();let i=r.scene.getSelectedElements(t),a=i.length?Wr(k(i)):t.scrollConstraints?GE(t.scrollConstraints):Wr(k(e)),o=Ss({bounds:a,appState:t,fit:`contain`,canvasOffsets:r.viewport.getOffsets()});return{...o,appState:{...o.appState,...Eo(o.appState)}}},keyTest:e=>e.code===xt.THREE&&e.shiftKey&&!e.altKey&&!e[L.CTRL_OR_CMD]}),X({name:`zoomToFit`,label:`helpDialog.zoomToFit`,icon:rw,viewMode:!0,navigation:!0,trackEvent:{category:`canvas`},predicate:(e,t,n,r)=>r.isNavigationEnabled(),perform:(e,t,n,r)=>{r.requestUnfollow();let i=t.scrollConstraints?GE(t.scrollConstraints):Wr(k(e)),a=Ss({bounds:i,appState:t,fit:`scale-down`,canvasOffsets:r.viewport.getOffsets()});return{...a,appState:{...a.appState,...Eo(a.appState)}}},keyTest:e=>e.code===xt.ONE&&e.shiftKey&&!e.altKey&&!e[L.CTRL_OR_CMD]});var KE=X({name:`toggleTheme`,label:(e,t)=>t.theme===P.DARK?`buttons.lightMode`:`buttons.darkMode`,keywords:[`toggle`,`dark`,`light`,`mode`,`theme`],icon:(e,t)=>e.theme===P.LIGHT?zx:Bx,viewMode:!0,trackEvent:{category:`canvas`},perform:(e,t,n,r)=>{let i=n||(t.theme===P.LIGHT?P.DARK:P.LIGHT);return r.props.onThemeChange?(r.props.onThemeChange(i),!1):{appState:{...t,theme:i},captureUpdate:N.EVENTUALLY}},keyTest:e=>!e[L.CTRL_OR_CMD]&&e.altKey&&e.shiftKey&&e.code===xt.D,predicate:(e,t,n,r)=>!!r.props.UIOptions.canvasActions.toggleTheme}),qE=({app:e,options:t,activeTool:n,defaultOption:r,"data-testid":i,onToolChange:a,displayedOption:o})=>{let[s,c]=(0,H.useState)(!1),l=n.type,u=o.type===l,{container:d}=mU();return!t.some(e=>e.type===l)&&s&&c(!1),(0,H.useEffect)(()=>{let t=e.onPointerDownEmitter.on(()=>{c(!1)});return()=>t?.()},[e]),(0,W.jsxs)(Ty,{open:s,children:[(0,W.jsx)(Ey,{asChild:!0,children:(0,W.jsx)(kw,{className:U({fillable:o.fillable}),type:`toggle`,icon:o.icon,checked:u,disabled:t.every(t=>$E(e,t.type)),title:Xo(o.title),"aria-label":Xo(o.title),"data-testid":i,onSelect:()=>{c(e=>!e),a(r)}})}),(0,W.jsx)(Oy,{className:`tool-popover-content`,sideOffset:16,collisionBoundary:d??void 0,children:t.map(({type:t,icon:n,title:r,fillable:i})=>(0,W.jsx)(kw,{className:U({fillable:i}),type:`toggle`,icon:n,checked:l===t,disabled:$E(e,t),title:Xo(t),"aria-label":Xo(t),"data-testid":`toolbar-${t}`,onSelect:()=>{e.state.activeTool.type!==t&&(Vw(`toolbar`,t,`ui`),e.setActiveTool({type:t}),a?.(t))}},t))})]})},JE=(e=>e)({hand:{icon:CC,letterKey:L.H,toggle:!0},selection:{icon:bx,letterKey:L.V,numericKey:L[1],fillable:!0},rectangle:{icon:Sx,letterKey:L.R,numericKey:L[2],fillable:!0},diamond:{icon:Cx,letterKey:L.D,numericKey:L[3],fillable:!0},ellipse:{icon:wx,letterKey:L.O,numericKey:L[4],fillable:!0},arrow:{icon:Tx,letterKey:L.A,numericKey:L[5],fillable:!0},line:{icon:Ex,letterKey:L.L,numericKey:L[6],fillable:!0},freedraw:{icon:Ox,letterKey:[L.P,L.X],numericKey:L[7]},text:{icon:kx,letterKey:L.T,numericKey:L[8]},stickynote:{icon:NC,letterKey:L.N},image:{icon:jx,numericKey:L[9]},eraser:{icon:Mx,letterKey:L.E,numericKey:L[0],toggle:!0},frame:{icon:MC,letterKey:L.F},autoshape:{icon:RC,letterKey:L.X,shiftKey:!0,fillable:!1},embeddable:{icon:Lx},laser:{icon:zC,letterKey:L.K},bucketfill:{icon:tS,letterKey:L.B},lasso:{icon:xx,fillable:!1}}),YE=Object.keys(JE).filter(e=>JE[e].toggle),XE=e=>{let{letterKey:t,shiftKey:n}=JE[e];if(!t)return t;let r=Xo(typeof t==`string`?t:t[0]);return n?Z(`Shift+${r}`):r},ZE=e=>{let t=XE(e),{numericKey:n}=JE[e];return t&&n!=null?`${t} ${K(`helpDialog.or`)} ${n}`:`${t||n}`},QE=(e,t,n=!1)=>{let r=e.toLowerCase();for(let i of Object.keys(JE)){let{letterKey:a,numericKey:o,shiftKey:s}=JE[i];if(n===!!s&&(o!=null&&e===o||a&&(typeof a==`string`?a===r:a.includes(r))))return i===`selection`?t.state.preferredSelectionTool.type:i}return null},$E=(e,t)=>e.props.activeTool!=null&&e.props.activeTool.type!==t,eD=(e,t)=>{let n=JE[e],r=t?.shortcutType??e,i=({app:i,activeTool:a,hideKeyBinding:o,hideShortcut:s})=>{let c=Xo(K(`toolBar.${e}`)),l=s?null:ZE(r);return(0,W.jsx)(kw,{className:U({fillable:n.fillable}),type:`toggle`,icon:n.icon,checked:a.type===e,disabled:$E(i,e),title:l?`${c} \u2014 ${l}`:c,keyBindingLabel:o||s?void 0:XE(r)||JE[r].numericKey,"aria-label":c,"aria-keyshortcuts":l??void 0,"data-testid":`toolbar-${e}`,onPointerDown:t=>{i.toolDrag.handleButtonPointerDown(e,t.nativeEvent)},onSelect:({pointerType:n})=>{if(!i.state.penDetected&&n===`pen`&&i.togglePenMode(!0),t?.onSelect){t.onSelect(i,{pointerType:n});return}i.state.activeTool.type!==e&&(Vw(`toolbar`,e,`ui`),i.setActiveTool({type:e}))}})};return i.displayName=`${Xo(e)}IconButton`,i},tD=eD(`hand`),nD=eD(`rectangle`),rD=eD(`diamond`),iD=eD(`ellipse`),aD=eD(`arrow`),oD=eD(`line`),sD=eD(`freedraw`),cD=eD(`text`),lD=eD(`stickynote`),uD=eD(`image`),dD=eD(`eraser`),fD=eD(`frame`),pD=eD(`selection`,{onSelect:(e,{pointerType:t})=>{if(e.state.activeTool.type===`selection`&&t!==null){e.setActiveTool({type:`lasso`});return}e.state.activeTool.type!==`selection`&&(Vw(`toolbar`,`selection`,`ui`),e.setActiveTool({type:`selection`}))}}),mD=eD(`lasso`,{shortcutType:`selection`}),hD=({app:e,activeTool:t,setAppState:n})=>{let r=[{type:`selection`,icon:JE.selection.icon,fillable:JE.selection.fillable,title:Xo(K(`toolBar.selection`))},{type:`lasso`,icon:JE.lasso.icon,fillable:JE.lasso.fillable,title:Xo(K(`toolBar.lasso`))}],i=r.find(t=>t.type===e.state.preferredSelectionTool.type)||r[0];return(0,W.jsx)(qE,{app:e,options:r,activeTool:t,defaultOption:e.state.preferredSelectionTool.type,"data-testid":`toolbar-selection`,onToolChange:t=>{(t===`selection`||t===`lasso`)&&(e.setActiveTool({type:t}),n({preferredSelectionTool:{type:t,initialized:!0}}))},displayedOption:i})},gD=({app:e,activeTool:t})=>{let n=[{type:`freedraw`,icon:JE.freedraw.icon,fillable:JE.freedraw.fillable,title:Xo(K(`toolBar.freedraw`))},{type:`autoshape`,icon:JE.autoshape.icon,fillable:JE.autoshape.fillable,title:Xo(K(`toolBar.autoshape`))}],[r,i]=(0,H.useState)(t.type===`autoshape`?`autoshape`:`freedraw`);(0,H.useEffect)(()=>{(t.type===`freedraw`||t.type===`autoshape`)&&i(t.type)},[t.type]);let a=n.find(e=>e.type===r)||n[0];return(0,W.jsx)(qE,{app:e,options:n,activeTool:t,defaultOption:r,"data-testid":`toolbar-freedraw`,onToolChange:t=>{(t===`freedraw`||t===`autoshape`)&&(i(t),e.setActiveTool({type:t}))},displayedOption:a})},_D=X({name:`finalize`,label:``,trackEvent:!1,perform:(e,t,n,r)=>{let i=!0,a=e,{focusContainer:o,scene:s}=r,c=s.getNonDeletedElementsMap(),l=t.activeTool.type===`autoshape`;if(n&&t.selectedLinearElement){let{event:i,sceneCoords:o}=n,u=I.getElement(t.selectedLinearElement.elementId,c);eo(u,`Arrow element should exist if selectedLinearElement is set`),eo(o,`sceneCoords should be defined if actionFinalize is called with event`);let d=I.handlePointerUp(i,t.selectedLinearElement,t,r.scene);if(mo(u)&&!t.selectedLinearElement.segmentMidPointHoveredCoords&&!n.hitBoundText){let e=!!t.newElement,n=e||!t.selectedLinearElement.selectedPointsIndices?[u.points.length-1]:t.selectedLinearElement.selectedPointsIndices,a=br(i),l=i[L.CTRL_OR_CMD]?null:r.getEffectiveGridSize(),f=n.reduce((e,t)=>(e.set(t,{point:a?u.points[t]:I.createPointAt(u,c,o.x-d.pointerOffset.x,o.y-d.pointerOffset.y,l)}),e),new Map)??new Map;nn(u,f,o.x,o.y,s,t,{newArrow:e,altKey:i.altKey,angleLocked:a,gridSize:r.getEffectiveGridSize()})}else oa(u)&&t.selectedLinearElement?.isEditing&&!t.newElement&&!pe(u.points)&&s.mutateElement(u,{polygon:!1});if(d!==t.selectedLinearElement){u&&Dc(u)&&(a=a.map(e=>e.id===u.id?j(e,{isDeleted:!0}):e));let n=t.activeTool?.locked;return{elements:u.points.length<2||Dc(u)?e.map(e=>e.id===u.id?j(e,{isDeleted:!0}):e):a,appState:{...t,cursorButton:`up`,selectedElementIds:l?{}:t.selectedElementIds,selectedLinearElement:n||l?null:{...d,selectedPointsIndices:null,isEditing:!1,initialState:{...d.initialState,lastClickedPoint:-1},pointerOffset:{x:0,y:0}},selectionElement:null,suggestedBinding:null,hoveredArrowTextAnchor:null,newElement:null,multiElement:null},captureUpdate:N.IMMEDIATELY}}}o();let u=r.drawShape.hasPendingGesture();(u||l)&&(r.drawShape.finalize(),u&&(a=r.scene.getElementsIncludingDeleted()));let f=null;if(t.multiElement)f=t.multiElement;else if(!l&&!u&&(t.newElement?.type===`freedraw`||mo(t.newElement)))f=t.newElement;else if(Object.keys(t.selectedElementIds).length===1){let e=c.get(Object.keys(t.selectedElementIds)[0]);e&&(f=e)}if(f){if(t.selectedLinearElement&&t.multiElement&&f.type!==`freedraw`&&t.lastPointerDownWith!==`touch`){let{points:e}=f,{lastCommittedPoint:n}=t.selectedLinearElement;if((!n||e[e.length-1]!==n)&&(i=!1,s.mutateElement(f,{points:f.points.slice(0,-1)}),mo(f)&&f.endBinding&&f.points.length>1)){let e=!!t.newElement,n=new Map([[f.points.length-1,{point:f.points[f.points.length-1],isDragging:!1}]]),r=I.getPointAtIndexGlobalCoordinates(f,-1,c);nn(f,n,r[0],r[1],s,t,{newArrow:e})}}if(f&&Dc(f)&&(a=a.map(e=>e.id===f?.id?j(e,{isDeleted:!0}):e)),ro(f)||xc(f)){if(bt(f.points,t.zoom.value)&&(oa(f)||xc(f))){let e=f.points,t=e[0],n=e.map((n,r)=>r===e.length-1?F(t[0],t[1]):n);oa(f)?s.mutateElement(f,{points:n,polygon:!0}):s.mutateElement(f,{points:n})}oa(f)&&!pe(f.points)&&s.mutateElement(f,{polygon:!1})}}let p;p=YE.includes(t.activeTool.type)?ae(t,{...t.activeTool.lastActiveTool||{type:r.state.preferredSelectionTool.type},lastActiveTool:null}):ae(t,{type:r.state.preferredSelectionTool.type});let m=r.isToolLocked(),h=t.activeTool.type===`autoshape`||(m||t.activeTool.type===`freedraw`)&&!!f;h||r.cursor.applyForTool(p);let g=f&&ro(f)?new I(f,d(a)):t.selectedLinearElement;return g&&={...g,isEditing:!t.newElement&&g.isEditing,initialState:{...g.initialState,lastClickedPoint:-1,origin:null}},{elements:a,appState:{...t,cursorButton:`up`,activeTool:h?t.activeTool:p,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null,selectedElementIds:l?{}:f&&!m&&t.activeTool.type!==`freedraw`?{...t.selectedElementIds,[f.id]:!0}:t.selectedElementIds,selectedLinearElement:l?null:g},captureUpdate:i?N.IMMEDIATELY:N.NEVER}},keyTest:(e,t)=>e.key===L.ESCAPE&&t.selectedLinearElement?.isEditing||(e.key===L.ESCAPE||e.key===L.ENTER)&&t.multiElement!==null,PanelComponent:({appState:e,updateData:t,data:n})=>(0,W.jsx)(kw,{type:`button`,icon:aS,title:K(`buttons.done`),"aria-label":K(`buttons.done`),onClick:t,visible:e.multiElement!=null,size:n?.size||`medium`,style:{pointerEvents:`all`}})}),vD=(e,t)=>YE.includes(e.activeTool.type)?ae(e,{...e.activeTool.lastActiveTool||{type:t.state.preferredSelectionTool.type},lastActiveTool:null}):ae(e,{type:t.state.preferredSelectionTool.type}),yD=(e,t,n)=>{if(!e.editingGroupId)return null;let r=t.scene.getNonDeletedElements(),i=t.scene.getSelectedElements({selectedElementIds:n,elements:r}),a=i.length?i:Er(r,e.editingGroupId);for(let t of a){let n=t.groupIds.indexOf(e.editingGroupId);if(n!==-1&&t.groupIds[n+1])return t.groupIds[n+1]}return null};X({name:`deselect`,label:``,trackEvent:!1,perform:(e,t,n,r)=>{let i=vD(t,r);if(r.cursor.applyForTool(i),t.editingGroupId){let e=r.scene.getNonDeletedElements(),n=Object.keys(t.selectedElementIds).length>0?t.selectedElementIds:Er(e,t.editingGroupId).reduce((e,t)=>(e[t.id]=!0,e),{});return{appState:{...t,...To({editingGroupId:yD(t,r,n),selectedElementIds:n},e,t,r),activeEmbeddable:null,activeTool:i,selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null},captureUpdate:N.IMMEDIATELY}}return{appState:{...t,activeEmbeddable:null,activeTool:i,editingGroupId:null,selectedElementIds:yi({},t),selectedGroupIds:{},selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null},captureUpdate:N.IMMEDIATELY}},keyTest:(e,t,n,r)=>e.key!==L.ESCAPE||tl(e.target)?!1:!t.newElement&&t.multiElement===null&&!t.selectedLinearElement?.isEditing&&(t.activeEmbeddable!==null||t.activeTool.type!==r.state.preferredSelectionTool.type||!!t.editingGroupId||!!t.selectedLinearElement||Jc(r.scene.getNonDeletedElements(),t))});var bD=({children:e,checked:t,onChange:n,className:r})=>(0,W.jsxs)(`div`,{className:U(`Checkbox`,r,{"is-checked":t}),onClick:e=>{n(!t,e),e.currentTarget.querySelector(`.Checkbox-box`).focus()},children:[(0,W.jsx)(`button`,{type:`button`,className:`Checkbox-box`,role:`checkbox`,"aria-checked":t,children:Yx}),(0,W.jsx)(`div`,{className:`Checkbox-label`,children:e})]}),xD=e=>{let t=e.title||(e.value===P.DARK?K(`buttons.lightMode`):K(`buttons.darkMode`));return(0,W.jsx)(kw,{type:`icon`,icon:e.value===P.LIGHT?SD.MOON:SD.SUN,title:t,"aria-label":t,onClick:()=>e.onChange(e.value===P.DARK?P.LIGHT:P.DARK),"data-testid":`toggle-dark-mode`})},SD={SUN:(0,W.jsx)(`svg`,{width:`512`,height:`512`,className:`rtl-mirror`,viewBox:`0 0 512 512`,children:(0,W.jsx)(`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:(0,W.jsx)(`svg`,{width:`512`,height:`512`,className:`rtl-mirror`,viewBox:`0 0 512 512`,children:(0,W.jsx)(`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`})})},CD=e=>{let{id:t}=mU(),[n,r]=(0,H.useState)(e.value);return(0,W.jsxs)(`div`,{className:`ProjectName`,children:[(0,W.jsx)(`label`,{className:`ProjectName-label`,htmlFor:`filename`,children:`${e.label}:`}),(0,W.jsx)(`input`,{type:`text`,className:`TextInput`,onBlur:t=>{e.ignoreFocus||Cc(t.target);let n=t.target.value;n!==e.value&&e.onChange(n)},onKeyDown:e=>{if(e.key===L.ENTER){if(e.preventDefault(),e.nativeEvent.isComposing||e.keyCode===229)return;e.currentTarget.blur()}},id:`${t}-filename`,value:n,onChange:e=>r(e.target.value)})]})},wD=5e3,TD=Object.assign(({message:e,onClose:t,closable:n=!1,duration:r=wD,style:i})=>{let a=(0,H.useRef)(0),o=r!==1/0,s=(0,H.useCallback)(()=>{o&&(a.current=window.setTimeout(()=>t(),r))},[t,r,o]);return(0,H.useEffect)(()=>{if(o)return s(),()=>clearTimeout(a.current)},[s,e,r,o]),(0,W.jsxs)(`div`,{className:`Toast`,role:`status`,onMouseEnter:o?()=>clearTimeout(a?.current):void 0,onMouseLeave:o?s:void 0,style:i,children:[(0,W.jsx)(`div`,{className:`Toast__message`,children:e}),n&&(0,W.jsx)(kw,{icon:ES,"aria-label":`close`,type:`icon`,onClick:t,className:`close`})]})},{ProgressBar:({progress:e})=>(0,W.jsx)(`div`,{className:`Toast__progress-bar`,children:(0,W.jsx)(`div`,{className:`Toast__progress-bar-fill`,style:{width:`${Math.min(5,Math.round(e*100))}%`}})})});`clipboard`in navigator&&`readText`in navigator.clipboard;var ED=`clipboard`in navigator&&`writeText`in navigator.clipboard,DD=`clipboard`in navigator&&`write`in navigator.clipboard&&`ClipboardItem`in window&&`toBlob`in HTMLCanvasElement.prototype,OD=e=>!!([Mn.excalidraw,Mn.excalidrawClipboard,Mn.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),kD=({types:e,files:t})=>{!e&&!t&&console.warn(`createPasteEvent: no types or files provided`);let n=new ClipboardEvent(B.PASTE,{clipboardData:new DataTransfer});if(e)for(let[r,i]of Object.entries(e)){if(typeof i!=`string`){t||=[],t.push(i);continue}try{if(n.clipboardData?.items.add(i,r),n.clipboardData?.getData(r)!==i)throw Error(`Failed to set "${r}" as clipboardData item`)}catch(e){throw Error(e.message)}}if(t){let e=-1;for(let r of t){e++;try{if(n.clipboardData?.items.add(r),n.clipboardData?.files[e]!==r)throw Error(`Failed to set file "${r.name}" as clipboardData item`)}catch(e){throw Error(e.message)}}}return n},AD=({elements:e,files:t})=>{let n=d(e),r=new Set(e.filter(e=>R(e))),i=!1,a=e.reduce((e,n)=>(D(n)&&(i=!0,t&&t[n.fileId]&&(e[n.fileId]=t[n.fileId])),e),{});i&&!t&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let o={type:Mn.excalidrawClipboard,elements:e.map(e=>{if(Oe(e,n)&&!r.has(Oe(e,n))){let t=Gn(e);return Xr(t,n,{frameId:null}),t}return e}),files:t?a:void 0};return JSON.stringify(o)},jD=async(e,t,n)=>{let r=AD({elements:e,files:t});await UD({[M.excalidrawClipboard]:r,[M.text]:r},n)};function MD(e){let t=[];for(let n of e.childNodes)if(n.nodeType===3){let e=n.textContent?.trim();e&&t.push({type:`text`,value:e})}else if(n instanceof HTMLImageElement){let e=n.getAttribute(`src`);e&&e.startsWith(`http`)&&t.push({type:`imageUrl`,value:e})}else t=t.concat(MD(n));return t}var ND=e=>{let t=e.value;try{let e=MD(new DOMParser().parseFromString(t,M.html).body);if(e.length)return{type:`mixedContent`,value:e}}catch(e){console.error(`error in parseHTMLFromPaste: ${e.message}`)}return null},PD=async()=>{let e={},t;try{t=await navigator.clipboard?.read()}catch(t){try{if(navigator.clipboard?.readText){console.warn(`navigator.clipboard.readText() failed (${t.message}). Failling back to navigator.clipboard.read()`);let e=await navigator.clipboard?.readText();if(e)return{[M.text]:e}}}catch(t){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${t.message}). Failling back to navigator.clipboard.read()`);else{if(t.name===`DataError`)return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${t.message}`),e;throw t}}throw t}for(let n of t)for(let t of n.types)if(s(gi,t))try{if(t===M.text||t===M.html)e[t]=await(await n.getType(t)).text();else if(Sa(t)){let r=await n.getType(t);e[t]=a(r,t,void 0)}else throw new ts(`Unsupported clipboard type: ${t}`)}catch(e){console.warn(e instanceof ts?e.message:`Cannot retrieve ${t} from clipboardItem: ${e.message}`)}return Object.keys(e).length===0&&console.warn(`No clipboard data found from clipboard.read().`),e},FD=async(e,t=!1)=>{try{let n=e.findByType(M.html),r=!t&&n&&ND(n);return r?r.value.every(e=>e.type===`text`)?{type:`text`,value:e.getData(M.text)??r.value.map(e=>e.value).join(`
|
|
42
|
+
`).trim()}:r:{type:`text`,value:(e.getData(M.text)||``).trim()}}catch{return{type:`text`,value:``}}},ID=function(e){return this.find(t=>t.type===e)||null},LD=function(e){return this.find(t=>t.type===e)?.value??null},RD=function(){return this.filter(e=>e.kind===`file`)},zD=e=>{let t;t=GD(e)?e.clipboardData?.items:e.dataTransfer?.items;let n=new Set;for(let e of Array.from(t||[]))n.has(e.type)||n.add(e.type);return n},BD=async e=>{let t;t=GD(e)?e.clipboardData?.items:e.dataTransfer?.items;let n=(await Promise.all(Array.from(t||[]).map(async t=>{if(t.kind===`file`){let e=t.getAsFile();if(e){let n=await ds(t);return e=await fn(e),{type:e.type,kind:`file`,file:e,fileHandle:n}}}else if(t.kind===`string`){let{type:n}=t,r;return r=`clipboardData`in e&&e.clipboardData?e.clipboardData?.getData(n):await new Promise(e=>{t.getAsString(t=>e(t))}),{type:n,kind:`string`,value:r}}return null}))).filter(e=>e!=null);return Object.assign(n,{findByType:ID,getData:LD,getFiles:RD})},VD=async(e,t=!1)=>{let n=await FD(e,t);if(n.type===`mixedContent`)return{mixedContent:n.value};try{let e=JSON.parse(n.value),r=e.type===Mn.excalidrawClipboardWithAPI;if(OD(e))return{elements:e.elements,files:e.files,text:t?JSON.stringify(e.elements,null,2):void 0,programmaticAPI:r}}catch{}return{text:n.value}},HD=async e=>{try{await navigator.clipboard.write([new ClipboardItem({[M.png]:e})])}catch(t){if(Zs(e))await navigator.clipboard.write([new ClipboardItem({[M.png]:await e})]);else throw t}},UD=async(e,t)=>{e||=``;let n=Object.entries(typeof e==`string`?{[M.text]:e}:e);try{if(t){for(let[e,r]of n)if(t.clipboardData?.setData(e,r),t.clipboardData?.getData(e)!==r)throw Error(`Failed to setData on clipboardEvent`);return}}catch(e){console.error(e)}let r=n.find(([e])=>e===M.text);if(ED&&r)try{await navigator.clipboard.writeText(r[1]);return}catch(e){console.error(e)}if(r&&!WD(r[1]))throw Error(`Error copying to clipboard.`)},WD=e=>{e||=` `;let 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`;let 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(e){console.error(e)}return n.remove(),i},GD=e=>e.type===B.PASTE||e.type===B.COPY||e.type===B.CUT,KD=(e,{selectedElementIds:t},n)=>{let r=k(e),i=d(r),a=n&&Jc(r,{selectedElementIds:t}),o=null,s=a?ot(r,{selectedElementIds:t},{includeBoundTextElement:!0}):r;if(a){let e=s[0];s.length===1&&R(e)?(o=e,s=Ji(r,e,i)):s.length>1&&(s=ot(r,{selectedElementIds:t},{includeBoundTextElement:!0,includeElementsInFrames:!0}))}return{exportingFrame:o,exportedElements:Fr(s)}},qD=async(e,t,r,i,{exportBackground:a,exportPadding:o=10,viewBackgroundColor:s,name:c=r.name||`Untitled`,fileHandle:l=null,exportingFrame:u=null})=>{if(t.length===0)throw Error(K(`alerts.cannotExportEmptyCanvas`));if(e===`svg`||e===`clipboard-svg`){let n=js(t,{exportBackground:a,exportWithDarkMode:r.exportWithDarkMode,viewBackgroundColor:s,exportPadding:o,exportScale:r.exportScale,exportEmbedScene:r.exportEmbedScene&&e===`svg`},i,{exportingFrame:u});if(e===`svg`)return re(n.then(e=>new Blob([Ec+e.outerHTML],{type:M.svg})),{description:`Export to SVG`,name:c,extension:r.exportEmbedScene?`excalidraw.svg`:`svg`,mimeTypes:[Lc.svg],fileHandle:l});if(e===`clipboard-svg`){let e=await n.then(e=>e.outerHTML);try{await UD(e)}catch{throw Error(K(`errors.copyToSystemClipboardFailed`))}return}}let d=vi(t,r,i,{exportBackground:a,viewBackgroundColor:s,exportPadding:o,exportingFrame:u});if(e===`png`){let e=Xa(d);return r.exportEmbedScene&&(e=e.then(e=>n(async()=>{let{encodePngMetadata:e}=await import(`./image-I42VHMUI-B2-c_ifV.js`);return{encodePngMetadata:e}},[],import.meta.url).then(({encodePngMetadata:n})=>n({blob:e,metadata:Ys(t,r,i,`local`)})))),re(e,{description:`Export to PNG`,name:c,extension:r.exportEmbedScene?`excalidraw.png`:`png`,mimeTypes:[Lc.png],fileHandle:l})}if(e===`clipboard`)try{await HD(Xa(d))}catch(e){throw console.warn(e),e.name===`CANVAS_POSSIBLY_TOO_BIG`?Error(K(`canvasError.canvasTooBig`)):is&&e.name===`TypeError`?Error(`${K(`alerts.couldNotCopyToClipboard`)}
|
|
43
|
+
|
|
44
|
+
${K(`hints.firefox_clipboard_write`)}`):Error(K(`alerts.couldNotCopyToClipboard`))}else throw Error(`Unsupported export type`)},JD=async(e,t,n)=>{let r=Ko(t);if(!Li(r))throw Error(`fileHandle should exist and should be of type svg or png when resaving`);let{elements:i,appState:a,files:o}=await e,{exportBackground:s,viewBackgroundColor:c}=a;a={...a,exportEmbedScene:!0};let{exportedElements:l,exportingFrame:u}=KD(i,a,!1);return await qD(r,l,a,o,{exportBackground:s,viewBackgroundColor:c,name:n,fileHandle:t,exportingFrame:u}),{fileHandle:t}},YD=X({name:`changeProjectName`,label:`labels.fileTitle`,trackEvent:!1,perform:(e,t,n)=>({appState:{...t,name:n},captureUpdate:N.EVENTUALLY}),PanelComponent:({appState:e,updateData:t,appProps:n,data:r,app:i})=>(0,W.jsx)(CD,{label:K(`labels.fileTitle`),value:i.getName(),onChange:e=>t(e),ignoreFocus:r?.ignoreFocus??!1})}),XD=X({name:`changeExportScale`,label:`imageExportDialog.scale`,trackEvent:{category:`export`,action:`scale`},perform:(e,t,n)=>({appState:{...t,exportScale:n},captureUpdate:N.EVENTUALLY})}),ZD=X({name:`changeExportBackground`,label:`imageExportDialog.label.withBackground`,trackEvent:{category:`export`,action:`toggleBackground`},perform:(e,t,n)=>({appState:{...t,exportBackground:n},captureUpdate:N.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>(0,W.jsx)(bD,{checked:e.exportBackground,onChange:e=>t(e),children:K(`imageExportDialog.label.withBackground`)})}),QD=X({name:`changeExportEmbedScene`,label:`imageExportDialog.tooltip.embedScene`,trackEvent:{category:`export`,action:`embedScene`},perform:(e,t,n)=>({appState:{...t,exportEmbedScene:n},captureUpdate:N.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>(0,W.jsxs)(bD,{checked:e.exportEmbedScene,onChange:e=>t(e),children:[K(`imageExportDialog.label.embedScene`),(0,W.jsx)(IE,{label:K(`imageExportDialog.tooltip.embedScene`),long:!0,children:(0,W.jsx)(`div`,{className:`excalidraw-tooltip-icon`,children:cS})})]})}),$D=!1,eO=(e,t)=>{let n=t.message??K(`progressDialog.defaultMessage`);e.setAppState({toast:{message:t.progress==null?n:(0,W.jsxs)(W.Fragment,{children:[n,(0,W.jsx)(TD.ProgressBar,{progress:t.progress})]}),duration:1/0}})};async function tO(e,t){if(t.app.state.isLoading&&(eO(t.app,{progress:null}),await t.app.onStateChange({predicate:e=>!e.isLoading})),typeof e==`object`&&e&&Symbol.asyncIterator in e){for await(let n of e){if(t.signal.aborted){e.return();return}if(n.type===`progress`)eO(t.app,{message:n.message,progress:n.progress??null});else if(n.type===`done`)return}return}e instanceof Promise&&(eO(t.app,{progress:null}),await e)}function nO(e,t,n,r){let i=new AbortController,a=i.signal;return{abortController:i,data:new Promise(async i=>{try{r.props.onExport&&await tO(r.props.onExport(`json`,{elements:e,appState:t,files:n},{signal:a}),{app:r,signal:a})}catch(e){e?.name===`AbortError`?console.warn(`onExport() aborted by host app (signal aborted: ${a.aborted})`):console.error(`Error during props.onExport() handling`,e)}i({elements:e,appState:t,files:r.files})})}}var rO=X({name:`saveToActiveFile`,label:`buttons.save`,icon:Hx,trackEvent:{category:`export`},predicate:(e,t,n,r)=>!!r.props.UIOptions.canvasActions.saveToActiveFile&&!!t.fileHandle&&!t.viewModeEnabled,perform:async(e,t,n,r)=>{if($D)return!1;$D=!0;let i=t.fileHandle,a=r.getName(),{abortController:o,data:s}=nO(e,t,r.files,r);try{let{fileHandle:e}=ir(i)?await JD(s,i,a):await ci({data:s,filename:a,fileHandle:i});return{captureUpdate:N.NEVER,appState:{fileHandle:e,toast:{message:i&&e?.name?K(`toast.fileSavedToFilename`).replace(`{filename}`,`"${e.name}"`):K(`toast.fileSaved`),duration:1500}}}}catch(e){return o.abort(),e?.name===`AbortError`?console.warn(e):console.error(e),{captureUpdate:N.NEVER,appState:{toast:null}}}finally{$D=!1}},keyTest:e=>e.key===L.S&&e[L.CTRL_OR_CMD]&&!e.shiftKey}),iO=X({name:`saveFileToDisk`,label:`exportDialog.disk_title`,icon:Hx,viewMode:!0,trackEvent:{category:`export`},perform:async(e,t,n,r)=>{if($D)return!1;$D=!0;let{abortController:i,data:a}=nO(e,t,r.files,r);try{let{fileHandle:e}=await ci({data:a,filename:r.getName(),fileHandle:null});return{captureUpdate:N.NEVER,appState:{openDialog:null,fileHandle:e,toast:{message:K(`toast.fileSaved`),duration:3e3}}}}catch(e){return i.abort(),e?.name===`AbortError`?console.warn(e):console.error(e),{captureUpdate:N.NEVER,appState:{toast:null}}}finally{$D=!1}},keyTest:e=>e.key.toLowerCase()===L.S&&e.shiftKey&&e[L.CTRL_OR_CMD],PanelComponent:({updateData:e})=>(0,W.jsx)(kw,{type:`button`,icon:Qx,title:K(`buttons.saveAs`),"aria-label":K(`buttons.saveAs`),showAriaLabel:fU().formFactor===`phone`,hidden:!mc,onClick:()=>e(null),"data-testid":`save-as-button`})}),aO=X({name:`loadScene`,label:`buttons.load`,trackEvent:{category:`export`},predicate:(e,t,n,r)=>!!r.props.UIOptions.canvasActions.loadScene&&!t.viewModeEnabled,perform:async(e,t,n,r)=>{try{let{elements:n,appState:r,files:i}=await oo(t,e);return{elements:n,appState:r,files:i,captureUpdate:N.IMMEDIATELY}}catch(n){return n?.name===`AbortError`?(console.warn(n),!1):{elements:e,appState:{...t,errorMessage:n.message},files:r.files,captureUpdate:N.EVENTUALLY}}},keyTest:e=>e[L.CTRL_OR_CMD]&&e.key===L.O}),oO=X({name:`exportWithDarkMode`,label:`imageExportDialog.label.darkMode`,trackEvent:{category:`export`,action:`toggleTheme`},perform:(e,t,n,r)=>(r.sessionExportThemeOverride=n?P.DARK:P.LIGHT,{appState:{...t,exportWithDarkMode:n},captureUpdate:N.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>(0,W.jsx)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,marginTop:`-45px`,marginBottom:`10px`},children:(0,W.jsx)(xD,{value:e.exportWithDarkMode?P.DARK:P.LIGHT,onChange:e=>{t(e===P.DARK)},title:K(`imageExportDialog.label.darkMode`)})})}),sO=`{}`,cO=X({name:`copyStyles`,label:`labels.copyStyles`,icon:nw,trackEvent:{category:`element`},perform:(e,t,n,r)=>{let i=[],a=e.find(e=>t.selectedElementIds[e.id]);if(i.push(a),a&&xr(a)){let e=Ga(a,r.scene.getNonDeletedElementsMap());i.push(e)}return a&&(sO=JSON.stringify(i)),{appState:{...t,toast:{message:K(`toast.copyStyles`)}},captureUpdate:N.EVENTUALLY}},keyTest:e=>e[L.CTRL_OR_CMD]&&e.altKey&&e.code===xt.C}),lO=X({name:`pasteStyles`,label:`labels.pasteStyles`,icon:nw,trackEvent:{category:`element`},perform:(e,t,n,r)=>{let i=JSON.parse(sO),a=i[0],o=i[1];if(!nl(a))return{elements:e,captureUpdate:N.EVENTUALLY};let s=ot(e,t,{includeBoundTextElement:!0}),c=s.map(e=>e.id),l=d(e),f=d(i.filter(nl)),p=Fe(Tr(e.map(e=>{if(c.includes(e.id)){let t=a;if(z(e)&&e.containerId&&(t=o),!t)return e;let n=j(e,{backgroundColor:t?.backgroundColor,strokeWidth:t?.strokeWidth,strokeColor:t?.strokeColor,strokeStyle:t?.strokeStyle,fillStyle:t?.fillStyle,opacity:t?.opacity,roughness:t?.roughness,roundness:t.roundness?Ni(t.roundness.type,e)?t.roundness:pi(e):null});if(z(n)){let e=t,i=(z(t)?vc(t,f):e.fontSize)||20,a=e.fontFamily||jr,o=null,c=n.containerId;c&&(o=s.find(e=>e.id===c)||null);let u=j(n,{...Lo(n,i,l),fontFamily:a,textAlign:e.textAlign||`left`,lineHeight:e.lineHeight||qt(a)});n=u,Rt(u,l)?n=j(u,el(u,`strokeColor`,u.strokeColor,l)):gt(u,o,r.scene)}return n.type===`arrow`&&ye(t)&&(n=j(n,{startArrowhead:t.startArrowhead,endArrowhead:t.endArrowhead})),R(e)&&(n=j(n,{roundness:null,backgroundColor:`transparent`})),oe(n)&&(n=xi(n)),n}return e}),l),new Set(c),{prevElementsMap:l});for(let e of p){let t=l.get(e.id);oe(e)&&ea(e)&&t&&(t.height!==e.height||t.x!==e.x||t.y!==e.y)&&u(e,r.scene)}return{elements:p,captureUpdate:N.IMMEDIATELY}},keyTest:e=>e[L.CTRL_OR_CMD]&&e.altKey&&e.code===xt.V}),uO=X({name:`toggleShortcuts`,label:`welcomeScreen.defaults.helpHint`,icon:Wx,viewMode:!0,trackEvent:{category:`menu`,action:`toggleHelpDialog`},perform:(e,t,n,{focusContainer:r})=>(t.openDialog?.name===`help`&&r(),{appState:{...t,openDialog:t.openDialog?.name===`help`?null:{name:`help`},openMenu:null,openPopup:null},captureUpdate:N.EVENTUALLY}),keyTest:e=>e.key===L.QUESTION_MARK}),dO=(e,t)=>{if(e.length>=2){let n=t?e[0].groupIds.indexOf(t):-1,r=n>-1?e[0].groupIds.slice(0,n):e[0].groupIds;for(let t of r)if(e.every(e=>w(e,t)))return!0}return!1},fO=(e,t)=>{let n=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds,includeBoundTextElement:!1});return n.length>=2&&!dO(n,e.editingGroupId)&&!mt(n)},pO=X({name:`group`,label:`labels.group`,icon:e=>(0,W.jsx)(DS,{theme:e.theme}),trackEvent:{category:`element`},perform:(e,t,n,r)=>{if(!fO(t,r))return!1;let i=Da(r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}));if(i.length<2)return{appState:t,elements:e,captureUpdate:N.EVENTUALLY};let a=Is(t);if(a.length===1){let n=a[0],r=new Set(Er(e,n).map(e=>e.id)),o=new Set(i.map(e=>e.id));if(new Set([...Array.from(r),...Array.from(o)]).size===r.size)return{appState:t,elements:e,captureUpdate:N.EVENTUALLY}}let o=[...e];new Set(i.map(e=>e.frameId)).size>1&&Xc(i).forEach((e,t)=>{ai(e,r.scene.getNonDeletedElementsMap())});let s=Ao(),c=d(i);o=o.map(e=>c.get(e.id)?j(e,{groupIds:to(e.groupIds,s,t.editingGroupId)}):e);let l=Er(o,s),u=l[l.length-1],f=o.lastIndexOf(u),p=o.slice(f+1),m=o.slice(0,f).filter(e=>!w(e,s)),h=ct([...m,...l,...p],d(l));return{appState:{...t,...Mc(s,{...t,selectedGroupIds:{}},k(o))},elements:h,captureUpdate:N.IMMEDIATELY}},predicate:(e,t,n,r)=>fO(t,r),keyTest:e=>!e.shiftKey&&e[L.CTRL_OR_CMD]&&e.key===L.G,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,W.jsx)(kw,{hidden:!fO(t,r),type:`button`,icon:(0,W.jsx)(DS,{theme:t.theme}),onClick:()=>n(null),title:`${K(`labels.group`)} \u2014 ${Z(`CtrlOrCmd+G`)}`,"aria-label":K(`labels.group`),visible:Jc(k(e),t)})}),mO=X({name:`ungroup`,label:`labels.ungroup`,icon:e=>(0,W.jsx)(OS,{theme:e.theme}),trackEvent:{category:`element`},perform:(e,t,n,r)=>{let i=Is(t),a=d(e);if(i.length===0)return{appState:t,elements:e,captureUpdate:N.EVENTUALLY};let o=[...e],s=[];o=o.map(e=>{_s(e)&&s.push(e.id);let n=Jr(e.groupIds,t.selectedGroupIds);return n.length===e.groupIds.length?e:j(e,{groupIds:n})});let c=To(t,k(o),t,null),l=r.scene.getSelectedElements(t),u=new Set(l.filter(e=>e.frameId).map(e=>e.frameId));return Ia(e).filter(e=>u.has(e.id)).forEach(e=>{e&&(o=Cr(o,ut(o,e,t,a),e))}),c.selectedElementIds=Object.entries(c.selectedElementIds).reduce((e,[t,n])=>(n&&!s.includes(t)&&(e[t]=!0),e),{}),{appState:{...t,...c},elements:o,captureUpdate:N.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[L.CTRL_OR_CMD]&&e.key===L.G.toUpperCase(),predicate:(e,t)=>Is(t).length>0,PanelComponent:({elements:e,appState:t,updateData:n})=>(0,W.jsx)(kw,{type:`button`,hidden:Is(t).length===0,icon:(0,W.jsx)(OS,{theme:t.theme}),onClick:()=>n(null),title:`${K(`labels.ungroup`)} \u2014 ${Z(`CtrlOrCmd+Shift+G`)}`,"aria-label":K(`labels.ungroup`),visible:Jc(k(e),t)})}),hO=(e,t,n,r,i,a,o)=>{e.beginPath(),e.moveTo(t+a,n),e.lineTo(t+r-a,n),e.quadraticCurveTo(t+r,n,t+r,n+a),e.lineTo(t+r,n+i-a),e.quadraticCurveTo(t+r,n+i,t+r-a,n+i),e.lineTo(t+a,n+i),e.quadraticCurveTo(t,n+i,t,n+i-a),e.lineTo(t,n+a),e.quadraticCurveTo(t,n,t+a,n),e.closePath(),e.fill(),o&&(e.strokeStyle=o),e.stroke()};function gO(e){let t=0;if(e.length===0)return t;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r}return t}var _O=(e,t)=>`hsl(${Math.abs(gO(t?.id||e))%37*10}, 100%, 83%)`,vO=e=>{let t=e?.trim()?.codePointAt(0);return(t?String.fromCodePoint(t):`?`).toUpperCase()},yO=({context:e,renderConfig:t,appState:n,normalizedWidth:r,normalizedHeight:i})=>{for(let[a,o]of t.remotePointerViewportCoords){let{x:s,y:c}=o,l=n.collaborators.get(a);s-=n.offsetLeft,c-=n.offsetTop;let u=s<0||s>r-11||c<0||c>i-14;s=Math.max(s,0),s=Math.min(s,r-11),c=Math.max(c,0),c=Math.min(c,i-14);let d=_O(a,l);e.save(),e.strokeStyle=d,e.fillStyle=d;let f=t.remotePointerUserStates.get(a),p=u||f===ge.IDLE||f===ge.AWAY;p&&(e.globalAlpha=.3),t.remotePointerButton.get(a)===`down`&&(e.beginPath(),e.arc(s,c,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle=`#ffffff88`,e.stroke(),e.closePath(),e.beginPath(),e.arc(s,c,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=d,e.stroke(),e.closePath());let m=ma,h=l?.isSpeaking;h&&(e.fillStyle=m,e.strokeStyle=m,e.lineWidth=10,e.lineJoin=`round`,e.beginPath(),e.moveTo(s,c),e.lineTo(s+0,c+14),e.lineTo(s+4,c+9),e.lineTo(s+11,c+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=Wn,e.strokeStyle=Wn,e.lineWidth=6,e.lineJoin=`round`,e.beginPath(),e.moveTo(s,c),e.lineTo(s+0,c+14),e.lineTo(s+4,c+9),e.lineTo(s+11,c+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=d,e.strokeStyle=d,e.lineWidth=2,e.lineJoin=`round`,e.beginPath(),p?(e.moveTo(s-1,c-1),e.lineTo(s-1,c+15),e.lineTo(s+5,c+10),e.lineTo(s+12,c+9),e.closePath(),e.fill()):(e.moveTo(s,c),e.lineTo(s+0,c+14),e.lineTo(s+4,c+9),e.lineTo(s+11,c+8),e.closePath(),e.fill(),e.stroke());let g=t.remotePointerUsernames.get(a)||``;if(!u&&g){e.font=`600 12px sans-serif`;let t=(h?s+0:s)+11/2,n=(h?c+0:c)+14+2,r=e.measureText(g),i=r.actualBoundingBoxDescent+r.actualBoundingBoxAscent,a=Math.max(i,12),o=t-1,l=n-1,u=r.width+2+10+2,f=a+2+6+2;e.roundRect?(e.beginPath(),e.roundRect(o,l,u,f,8),e.fillStyle=d,e.fill(),e.strokeStyle=`#ffffff`,e.stroke(),h&&(e.beginPath(),e.roundRect(o-2,l-2,u+4,f+4,8),e.strokeStyle=m,e.stroke())):hO(e,o,l,u,f,8,`#ffffff`),e.fillStyle=`#1e1e1e`,e.fillText(g,t+5+1,n+3+r.actualBoundingBoxAscent+Math.floor((a-i)/2)+2),h&&(e.fillStyle=m,e.fillRect(o+u+8,l+(f/2-4),2,8),e.fillRect(o+u+8+5,l+(f/2-8),2,16),e.fillRect(o+u+8+10,l+(f/2-4),2,8))}e.restore(),e.closePath()}},bO=({color:e,onClick:t,name:n,src:r,className:i})=>{let a=vO(n),[o,s]=(0,H.useState)(!1),c=!o&&r,l=c?void 0:{background:e};return(0,W.jsx)(`div`,{className:U(`Avatar`,i),style:l,onClick:t,children:c?(0,W.jsx)(`img`,{className:`Avatar-img`,src:r,alt:a,referrerPolicy:`no-referrer`,onError:()=>s(!0)}):a})};X({name:`goToCollaborator`,label:`Go to a collaborator`,viewMode:!0,trackEvent:{category:`collab`},perform:(e,t,n,r)=>(eo(n,`actionGoToCollaborator: collaborator should be defined when actionGoToCollaborator is called`),!n.socketId||r.props.userToFollow?.socketId===n.socketId||n.isCurrentUser?(r.requestUnfollow(),{appState:t,captureUpdate:N.EVENTUALLY}):(r.emitUserFollowIntent({userToFollow:{socketId:n.socketId,username:n.username||``},action:`FOLLOW`}),{appState:{...t,openMenu:t.openMenu===`canvas`?null:t.openMenu},captureUpdate:N.EVENTUALLY})),PanelComponent:({updateData:e,data:t,appState:n})=>{let{socketId:r,collaborator:i,withName:a,isBeingFollowed:o}=t,s=_O(r,i),c=U({"is-followed":o,"is-current-user":i.isCurrentUser===!0,"is-speaking":i.isSpeaking,"is-in-call":i.isInCall,"is-muted":i.isMuted}),l=i.isInCall?i.isSpeaking?(0,W.jsxs)(`div`,{className:`UserList__collaborator-status-icon-speaking-indicator`,title:K(`userList.hint.isSpeaking`),children:[(0,W.jsx)(`div`,{}),(0,W.jsx)(`div`,{}),(0,W.jsx)(`div`,{})]}):i.isMuted?(0,W.jsx)(`div`,{className:`UserList__collaborator-status-icon-microphone-muted`,title:K(`userList.hint.micMuted`),children:XC}):(0,W.jsx)(`div`,{title:K(`userList.hint.inCall`),children:YC}):null;return a?(0,W.jsxs)(`div`,{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${c}`,style:{"--avatar-size":`1.5rem`},onClick:i.isCurrentUser?void 0:()=>e(i),children:[(0,W.jsx)(bO,{color:s,onClick:()=>{},name:i.username||``,src:i.avatarUrl,className:c}),(0,W.jsx)(`div`,{className:`UserList__collaborator-name`,children:i.username}),(0,W.jsxs)(`div`,{className:`UserList__collaborator-status-icons`,"aria-hidden":!0,children:[o&&(0,W.jsx)(`div`,{className:`UserList__collaborator-status-icon-is-followed`,title:K(`userList.hint.followStatus`),children:HC}),i.isCurrentUser&&` (${K(`labels.you`)})`,l]})]}):(0,W.jsxs)(`div`,{className:`UserList__collaborator UserList__collaborator--avatar-only ${c}`,children:[(0,W.jsx)(bO,{color:s,onClick:()=>{e(i)},name:i.username||``,src:i.avatarUrl,className:c}),l&&(0,W.jsx)(`div`,{className:`UserList__collaborator-status-icon`,children:l})]})}});var xO=X({name:`addToLibrary`,trackEvent:{category:`element`},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let e of Lt)if(i.some(t=>t.type===e))return{captureUpdate:N.EVENTUALLY,appState:{...t,errorMessage:K(`errors.libraryElementTypeError.${e}`)}};return r.library.getLatestLibrary().then(e=>r.library.setLibrary([{id:Ao(),status:`unpublished`,elements:i.map(Gn),created:Date.now()},...e])).then(()=>({captureUpdate:N.EVENTUALLY,appState:{...t,toast:{message:K(`toast.addedToLibrary`)}}})).catch(e=>({captureUpdate:N.EVENTUALLY,appState:{...t,errorMessage:e.message}}))},label:`labels.addToLibrary`}),SO=(e,t)=>{let n=t.scene.getSelectedElements(e);return Yc(n,t.scene.getNonDeletedElementsMap(),e).length>1&&!n.some(e=>R(e))},CO=(e,t,n,r)=>{let i=n.scene.getSelectedElements(t),a=Hs(i,r,n.scene,t),o=d(a);return tc(e.map(e=>o.get(e.id)||e),t,n)};X({name:`alignTop`,label:`labels.alignTop`,icon:gS,trackEvent:{category:`element`},predicate:(e,t,n,r)=>SO(t,r),perform:(e,t,n,r)=>({appState:t,elements:CO(e,t,r,{position:`start`,axis:`y`}),captureUpdate:N.IMMEDIATELY}),keyTest:e=>e[L.CTRL_OR_CMD]&&e.shiftKey&&e.key===L.ARROW_UP,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,W.jsx)(kw,{hidden:!SO(t,r),type:`button`,icon:gS,onClick:()=>n(null),title:`${K(`labels.alignTop`)} \u2014 ${Z(`CtrlOrCmd+Shift+Up`)}`,"aria-label":K(`labels.alignTop`),visible:Jc(k(e),t)})}),X({name:`alignBottom`,label:`labels.alignBottom`,icon:_S,trackEvent:{category:`element`},predicate:(e,t,n,r)=>SO(t,r),perform:(e,t,n,r)=>({appState:t,elements:CO(e,t,r,{position:`end`,axis:`y`}),captureUpdate:N.IMMEDIATELY}),keyTest:e=>e[L.CTRL_OR_CMD]&&e.shiftKey&&e.key===L.ARROW_DOWN,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,W.jsx)(kw,{hidden:!SO(t,r),type:`button`,icon:_S,onClick:()=>n(null),title:`${K(`labels.alignBottom`)} \u2014 ${Z(`CtrlOrCmd+Shift+Down`)}`,"aria-label":K(`labels.alignBottom`),visible:Jc(k(e),t)})}),X({name:`alignLeft`,label:`labels.alignLeft`,icon:vS,trackEvent:{category:`element`},predicate:(e,t,n,r)=>SO(t,r),perform:(e,t,n,r)=>({appState:t,elements:CO(e,t,r,{position:`start`,axis:`x`}),captureUpdate:N.IMMEDIATELY}),keyTest:e=>e[L.CTRL_OR_CMD]&&e.shiftKey&&e.key===L.ARROW_LEFT,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,W.jsx)(kw,{hidden:!SO(t,r),type:`button`,icon:vS,onClick:()=>n(null),title:`${K(`labels.alignLeft`)} \u2014 ${Z(`CtrlOrCmd+Shift+Left`)}`,"aria-label":K(`labels.alignLeft`),visible:Jc(k(e),t)})}),X({name:`alignRight`,label:`labels.alignRight`,icon:yS,trackEvent:{category:`element`},predicate:(e,t,n,r)=>SO(t,r),perform:(e,t,n,r)=>({appState:t,elements:CO(e,t,r,{position:`end`,axis:`x`}),captureUpdate:N.IMMEDIATELY}),keyTest:e=>e[L.CTRL_OR_CMD]&&e.shiftKey&&e.key===L.ARROW_RIGHT,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,W.jsx)(kw,{hidden:!SO(t,r),type:`button`,icon:yS,onClick:()=>n(null),title:`${K(`labels.alignRight`)} \u2014 ${Z(`CtrlOrCmd+Shift+Right`)}`,"aria-label":K(`labels.alignRight`),visible:Jc(k(e),t)})}),X({name:`alignVerticallyCentered`,label:`labels.centerVertically`,icon:SS,trackEvent:{category:`element`},predicate:(e,t,n,r)=>SO(t,r),perform:(e,t,n,r)=>({appState:t,elements:CO(e,t,r,{position:`center`,axis:`y`}),captureUpdate:N.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,W.jsx)(kw,{hidden:!SO(t,r),type:`button`,icon:SS,onClick:()=>n(null),title:K(`labels.centerVertically`),"aria-label":K(`labels.centerVertically`),visible:Jc(k(e),t)})}),X({name:`alignHorizontallyCentered`,label:`labels.centerHorizontally`,icon:CS,trackEvent:{category:`element`},predicate:(e,t,n,r)=>SO(t,r),perform:(e,t,n,r)=>({appState:t,elements:CO(e,t,r,{position:`center`,axis:`x`}),captureUpdate:N.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,W.jsx)(kw,{hidden:!SO(t,r),type:`button`,icon:CS,onClick:()=>n(null),title:K(`labels.centerHorizontally`),"aria-label":K(`labels.centerHorizontally`),visible:Jc(k(e),t)})});var wO=(e,t)=>{let n=t.scene.getSelectedElements(e);return Yc(n,t.scene.getNonDeletedElementsMap(),e).length>2&&!n.some(e=>R(e))},TO=(e,t,n,r)=>{let i=n.scene.getSelectedElements(t),a=Fs(i,n.scene.getNonDeletedElementsMap(),r,t,n.scene),o=d(a);return tc(e.map(e=>o.get(e.id)||e),t,n)};X({name:`distributeHorizontally`,label:`labels.distributeHorizontally`,trackEvent:{category:`element`},perform:(e,t,n,r)=>({appState:t,elements:TO(e,t,r,{space:`between`,axis:`x`}),captureUpdate:N.IMMEDIATELY}),keyTest:e=>!e[L.CTRL_OR_CMD]&&e.altKey&&e.code===xt.H,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,W.jsx)(kw,{hidden:!wO(t,r),type:`button`,icon:bS,onClick:()=>n(null),title:`${K(`labels.distributeHorizontally`)} \u2014 ${Z(`Alt+H`)}`,"aria-label":K(`labels.distributeHorizontally`),visible:Jc(k(e),t)})}),X({name:`distributeVertically`,label:`labels.distributeVertically`,trackEvent:{category:`element`},perform:(e,t,n,r)=>({appState:t,elements:TO(e,t,r,{space:`between`,axis:`y`}),captureUpdate:N.IMMEDIATELY}),keyTest:e=>!e[L.CTRL_OR_CMD]&&e.altKey&&e.code===xt.V,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,W.jsx)(kw,{hidden:!wO(t,r),type:`button`,icon:xS,onClick:()=>n(null),title:`${K(`labels.distributeVertically`)} \u2014 ${Z(`Alt+V`)}`,"aria-label":K(`labels.distributeVertically`),visible:Jc(k(e),t)})});var EO=X({name:`flipHorizontal`,label:`labels.flipHorizontal`,icon:tw,trackEvent:{category:`element`},perform:(e,t,n,r)=>({elements:tc(OO(e,r.scene.getNonDeletedElementsMap(),t,`horizontal`,r),t,r),appState:t,captureUpdate:N.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===xt.H}),DO=X({name:`flipVertical`,label:`labels.flipVertical`,icon:ew,trackEvent:{category:`element`},perform:(e,t,n,r)=>({elements:tc(OO(e,r.scene.getNonDeletedElementsMap(),t,`vertical`,r),t,r),appState:t,captureUpdate:N.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===xt.V&&!e[L.CTRL_OR_CMD]}),OO=(e,t,n,r,i)=>{let a=kO(ot(k(e),n,{includeBoundTextElement:!0,includeElementsInFrames:!0}),t,r,i),o=d(a);return e.map(e=>o.get(e.id)||e)},kO=(e,t,n,r)=>{if(e.every(e=>ye(e)&&(e.startBinding||e.endBinding)))return e.map(e=>{let t=e;return j(t,{startArrowhead:t.endArrowhead,endArrowhead:t.startArrowhead})});let{midX:i,midY:a}=Ue(e);Te(e,t,`nw`,r.scene,new Map(Array.from(t.values()).map(e=>[e.id,Gn(e)])),{flipByX:n===`horizontal`,flipByY:n===`vertical`,shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),wn(e.filter(ye),r.scene,r.state);let{elbowArrows:o,otherElements:s}=e.reduce((e,t)=>Br(t)?{...e,elbowArrows:e.elbowArrows.concat(t)}:{...e,otherElements:e.otherElements.concat(t)},{elbowArrows:[],otherElements:[]}),{midX:c,midY:l}=Ue(e),[u,d]=[i-c,a-l];return s.forEach(e=>r.scene.mutateElement(e,{x:e.x+u,y:e.y+d})),o.forEach(e=>r.scene.mutateElement(e,{x:e.x+u,y:e.y+d})),e},AO=X({name:`copy`,label:`labels.copy`,icon:Rx,trackEvent:{category:`element`},perform:async(e,t,n,r)=>{let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await jD(i,r.files,n)}catch(e){return{captureUpdate:N.EVENTUALLY,appState:{...t,errorMessage:e.message}}}return{captureUpdate:N.EVENTUALLY}},keyTest:void 0}),jO=X({name:`paste`,label:`labels.paste`,trackEvent:{category:`element`},perform:async(e,t,n,r)=>{let i;try{i=await PD()}catch(e){return e.name===`AbortError`||e.name===`NotAllowedError`?!1:(console.error(`actionPaste ${e.name}: ${e.message}`),is?{captureUpdate:N.EVENTUALLY,appState:{...t,errorMessage:K(`hints.firefox_clipboard_write`)}}:{captureUpdate:N.EVENTUALLY,appState:{...t,errorMessage:K(`errors.asyncPasteFailedOnRead`)}})}try{r.pasteFromClipboard(kD({types:i}))}catch(e){return console.error(e),{captureUpdate:N.EVENTUALLY,appState:{...t,errorMessage:K(`errors.asyncPasteFailedOnParse`)}}}return{captureUpdate:N.EVENTUALLY}},keyTest:void 0}),MO=X({name:`cut`,label:`labels.cut`,icon:EC,trackEvent:{category:`element`},perform:(e,t,n,r)=>(AO.perform(e,t,n,r),Nw.perform(e,t,null,r)),keyTest:e=>e[L.CTRL_OR_CMD]&&e.key===L.X}),NO=X({name:`copyAsSvg`,label:`labels.copyAsSvg`,icon:iw,trackEvent:{category:`element`},perform:async(e,t,n,r)=>{if(!r.canvas)return{captureUpdate:N.EVENTUALLY};let{exportedElements:i,exportingFrame:a}=KD(e,t,!0);try{return await qD(`clipboard-svg`,i,t,r.files,{...t,exportingFrame:a,name:r.getName()}),{appState:{toast:{message:K(`toast.copyToClipboardAsSvg`,{exportSelection:r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}).length?K(`toast.selection`):K(`toast.canvas`),exportColorScheme:t.exportWithDarkMode?K(`buttons.darkMode`):K(`buttons.lightMode`)})}},captureUpdate:N.EVENTUALLY}}catch(e){return console.error(e),{appState:{errorMessage:e.message},captureUpdate:N.EVENTUALLY}}},predicate:e=>ED&&e.length>0,keywords:[`svg`,`clipboard`,`copy`]}),PO=X({name:`copyAsPng`,label:`labels.copyAsPng`,icon:aw,trackEvent:{category:`element`},perform:async(e,t,n,r)=>{if(!r.canvas)return{captureUpdate:N.EVENTUALLY};let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:a,exportingFrame:o}=KD(e,t,!0);try{return await qD(`clipboard`,a,t,r.files,{...t,exportingFrame:o,name:r.getName()}),{appState:{...t,toast:{message:K(`toast.copyToClipboardAsPng`,{exportSelection:i.length?K(`toast.selection`):K(`toast.canvas`),exportColorScheme:t.exportWithDarkMode?K(`buttons.darkMode`):K(`buttons.lightMode`)})}},captureUpdate:N.EVENTUALLY}}catch(e){return console.error(e),{appState:{...t,errorMessage:e.message},captureUpdate:N.EVENTUALLY}}},predicate:e=>DD&&e.length>0,keyTest:e=>e.code===xt.C&&e.altKey&&e.shiftKey,keywords:[`png`,`clipboard`,`copy`]}),FO=X({name:`copyText`,label:`labels.copyText`,trackEvent:{category:`element`},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0});try{UD(xs(i))}catch{throw Error(K(`errors.copyToSystemClipboardFailed`))}return{captureUpdate:N.EVENTUALLY}},predicate:(e,t,n,r)=>ED&&r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}).some(z),keywords:[`text`,`clipboard`,`copy`]}),IO=X({name:`gridMode`,icon:uw,keywords:[`snap`],label:`labels.toggleGrid`,viewMode:!0,trackEvent:{category:`canvas`,predicate:e=>e.gridModeEnabled},perform(e,t){return{appState:{...t,gridModeEnabled:!this.checked(t),objectsSnapModeEnabled:!1},captureUpdate:N.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,t,n)=>n.gridModeEnabled===void 0,keyTest:e=>e[L.CTRL_OR_CMD]&&e.code===xt.QUOTE}),LO=X({name:`zenMode`,label:`buttons.zenMode`,icon:sw,viewMode:!0,trackEvent:{category:`canvas`,predicate:e=>!e.zenModeEnabled},perform(e,t){return{appState:{...t,zenModeEnabled:!this.checked(t)},captureUpdate:N.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,t,n,r)=>r.editorInterface.formFactor!==`phone`&&typeof n.zenModeEnabled>`u`,keyTest:e=>!e[L.CTRL_OR_CMD]&&e.altKey&&e.code===xt.Z}),RO=X({name:`objectsSnapMode`,label:`buttons.objectsSnapMode`,icon:ow,viewMode:!1,trackEvent:{category:`canvas`,predicate:e=>!e.objectsSnapModeEnabled},perform(e,t){return{appState:{...t,objectsSnapModeEnabled:!this.checked(t),gridModeEnabled:!1},captureUpdate:N.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,t,n)=>typeof n.objectsSnapModeEnabled>`u`,keyTest:e=>!e[L.CTRL_OR_CMD]&&e.altKey&&e.code===xt.S}),zO=X({name:`arrowBinding`,label:`labels.arrowBinding`,viewMode:!1,trackEvent:{category:`canvas`,predicate:e=>e.bindingPreference===`disabled`},perform(e,t){let n=t.bindingPreference===`enabled`?`disabled`:`enabled`;return{appState:{...t,bindingPreference:n,isBindingEnabled:n===`enabled`},captureUpdate:N.NEVER}},checked:e=>e.bindingPreference===`enabled`}),BO=X({name:`midpointSnapping`,label:`labels.midpointSnapping`,viewMode:!1,trackEvent:{category:`canvas`,predicate:e=>!e.isMidpointSnappingEnabled},perform(e,t){return{appState:{...t,isMidpointSnappingEnabled:!this.checked(t)},captureUpdate:N.NEVER}},checked:e=>e.isMidpointSnappingEnabled}),VO=X({name:`stats`,label:`stats.fullTitle`,icon:$C,viewMode:!0,trackEvent:{category:`menu`},keywords:[`edit`,`attributes`,`customize`],perform(e,t){return{appState:{...t,stats:{...t.stats,open:!this.checked(t)}},captureUpdate:N.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[L.CTRL_OR_CMD]&&e.altKey&&e.code===xt.SLASH}),HO=X({name:`unbindText`,label:`labels.unbindText`,trackEvent:{category:`element`},predicate:(e,t,n,r)=>r.scene.getSelectedElements(t).some(e=>xr(e)),perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t),a=r.scene.getNonDeletedElementsMap();return i.forEach(e=>{let t=Ga(e,a);if(t){let{width:n,height:i}=Di(t.originalText,Ro(t),t.lineHeight),o=ti(e.id);Ts(e.id);let{x:s,y:c}=ie(e,t,a);r.scene.mutateElement(t,{containerId:null,width:n,height:i,text:t.originalText,baseFontSize:null,x:s,y:c,labelPosition:null}),r.scene.mutateElement(e,{boundElements:e.boundElements?.filter(e=>e.id!==t.id)}),oe(e)?Un(e,r.scene):r.scene.mutateElement(e,{height:o||e.height})}}),{elements:e,appState:t,captureUpdate:N.IMMEDIATELY}}}),UO=X({name:`bindText`,label:`labels.bindText`,trackEvent:{category:`element`},predicate:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t);if(i.length===2){let e=z(i[0])||z(i[1]),t;if(Ne(i[0])?t=i[0]:Ne(i[1])&&(t=i[1]),e&&t&&Ga(t,r.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t),a,o;z(i[0])&&Ne(i[1])?(a=i[0],o=i[1]):(a=i[1],o=i[0]);let s=oe(o)?Ke(a.strokeColor)?o.strokeColor:a.strokeColor:null;r.scene.mutateElement(a,{containerId:o.id,verticalAlign:$t.MIDDLE,textAlign:Ja.CENTER,autoResize:!0,angle:ye(o)?0:o?.angle??0,labelPosition:ye(o)?Wi:null,...s?{baseFontSize:f(a.baseFontSize??a.fontSize),strokeColor:s}:null}),r.scene.mutateElement(o,{boundElements:(o.boundElements||[]).concat({type:`text`,id:a.id}),...s?{strokeColor:s}:null});let c=o.height;return gt(a,o,r.scene),di(o.id,c),{elements:WO(e,o,a),appState:{...t,selectedElementIds:{[o.id]:!0}},captureUpdate:N.IMMEDIATELY}}}),WO=(e,t,n)=>{let r=e.slice(),i=r.findIndex(e=>e.id===n.id);r.splice(i,1);let a=r.findIndex(e=>e.id===t.id);return r.splice(a+1,0,n),ct(r,d([t,n])),r},GO=(e,t,n)=>{let r=e.slice(),i=r.findIndex(e=>e.id===t.id);r.splice(i,1);let a=r.findIndex(e=>e.id===n.id);return r.splice(a,0,t),ct(r,d([t,n])),r},KO=X({name:`wrapTextInContainer`,label:`labels.createContainerFromText`,trackEvent:{category:`element`},predicate:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t),a=i.some(e=>z(e)&&!_s(e));return i.length>0&&a},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t),a=e.slice(),o={};for(let e of i)if(z(e)&&!_s(e)){let n=At({type:`rectangle`,backgroundColor:t.currentItemBackgroundColor,boundElements:[...e.boundElements||[],{id:e.id,type:`text`}],angle:e.angle,fillStyle:t.currentItemFillStyle,strokeColor:t.currentItemStrokeColor,roughness:t.currentItemRoughness,strokeWidth:al(`rectangle`,t.currentItemStrokeWidthKey),strokeStyle:t.currentItemStrokeStyle,roundness:t.currentItemRoundness===`round`?{type:In(`rectangle`)?Pa.ADAPTIVE_RADIUS:Pa.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:e.x-5,y:e.y-5,width:m(e.width,`rectangle`),height:m(e.height,`rectangle`),groupIds:e.groupIds,frameId:e.frameId});if(e.boundElements?.length){let t=e.boundElements.filter(e=>e.type===`arrow`).map(e=>e.id);a.filter(e=>t.includes(e.id)).forEach(t=>{let i=t.startBinding,a=t.endBinding;i?.elementId===e.id&&(i={...i,elementId:n.id}),a?.elementId===e.id&&(a={...a,elementId:n.id}),(i||a)&&r.scene.mutateElement(t,{startBinding:i,endBinding:a})})}r.scene.mutateElement(e,{containerId:n.id,verticalAlign:$t.MIDDLE,boundElements:null,textAlign:Ja.CENTER,autoResize:!0}),gt(e,n,r.scene),a=GO([...a,n],n,e),o[n.id]=!0}return{elements:a,appState:{...t,selectedElementIds:o},captureUpdate:N.IMMEDIATELY}}}),qO=380,JO=42,YO=5,XO=85,ZO=500,QO=!1,$O=new Map,ek=({element:e,scene:t,setAppState:n,onLinkOpen:r,setToast:i,updateEmbedValidationStatus:a})=>{let o=t.getNonDeletedElementsMap(),s=gU(),c=dU(),l=fU(),u=e.link||``,[d,f]=(0,H.useState)(u),p=(0,H.useRef)(null),m=s.showHyperlinkPopup===`editor`,h=(0,H.useCallback)(()=>{if(!p.current)return;let r=cn(p.current.value)||null;if(!e.link&&r&&Vw(`hyperlink`,`create`),Sn(e)){if(s.activeEmbeddable?.element===e&&n({activeEmbeddable:null}),!r){t.mutateElement(e,{link:null}),a(e,!1);return}if(!va(r,c.validateEmbeddable))r&&i({message:K(`toast.unableToEmbed`),closable:!0}),e.link&&$O.set(e.id,e.link),t.mutateElement(e,{link:r}),a(e,!1);else{let{width:n,height:o}=e,s=ja(r);s?.error instanceof URIError&&i({message:K(`toast.unrecognizedLinkFormat`),closable:!0});let c=s?s.intrinsicSize.w/s.intrinsicSize.h:1,l=$O.get(e.id)!==e.link;t.mutateElement(e,{...l?{width:s?.type===`video`?n>o?n:o*c:n,height:s?.type===`video`&&n>o?n/c:o}:{},link:r}),a(e,!0),$O.has(e.id)&&$O.delete(e.id)}}else t.mutateElement(e,{link:r})},[e,t,i,c.validateEmbeddable,s.activeEmbeddable,n,a]);(0,H.useLayoutEffect)(()=>()=>{h()},[h]),(0,H.useEffect)(()=>{m&&p?.current&&!(l.formFactor===`phone`||l.isTouchScreen)&&p.current.select()},[m,l.formFactor,l.isTouchScreen]),(0,H.useEffect)(()=>{let t=null,r=r=>{m||(t&&clearTimeout(t),sk(e,o,s,F(r.clientX,r.clientY))&&(t=window.setTimeout(()=>{n({showHyperlinkPopup:!1})},ZO)))};return window.addEventListener(B.POINTER_MOVE,r,!1),()=>{window.removeEventListener(B.POINTER_MOVE,r,!1),t&&clearTimeout(t)}},[s,e,m,n,o]);let g=(0,H.useCallback)(()=>{Vw(`hyperlink`,`delete`),t.mutateElement(e,{link:null}),n({showHyperlinkPopup:!1})},[n,e,t]),_=()=>{Vw(`hyperlink`,`edit`,`popup-ui`),n({showHyperlinkPopup:`editor`})},{x:v,y}=tk(e,s,o);return s.contextMenu||s.selectedElementsAreBeingDragged||s.resizingElement||s.isRotating||s.openMenu||s.viewModeEnabled?null:(0,W.jsxs)(`div`,{className:`excalidraw-hyperlinkContainer`,style:{top:`${y}px`,left:`${v}px`,width:qO,padding:YO},children:[m?(0,W.jsx)(`input`,{className:U(`excalidraw-hyperlinkContainer-input`),placeholder:K(`labels.link.hint`),ref:p,value:d,onChange:e=>f(e.target.value),autoFocus:!0,onKeyDown:e=>{e.stopPropagation(),e[L.CTRL_OR_CMD]&&e.key===L.K&&e.preventDefault(),(e.key===L.ENTER||e.key===L.ESCAPE)&&(h(),n({showHyperlinkPopup:`info`}))}}):e.link?(0,W.jsx)(`a`,{href:cn(e.link||``),className:`excalidraw-hyperlinkContainer-link`,target:gs(e.link)?`_self`:`_blank`,onClick:t=>{if(e.link&&r){let n=cr(B.EXCALIDRAW_LINK,t.nativeEvent);r({...e,link:cn(e.link)},n),n.defaultPrevented&&t.preventDefault()}},rel:`noopener noreferrer`,children:e.link}):(0,W.jsx)(`div`,{className:`excalidraw-hyperlinkContainer-link`,children:K(`labels.link.empty`)}),(0,W.jsxs)(`div`,{className:`excalidraw-hyperlinkContainer__buttons`,children:[!m&&(0,W.jsx)(kw,{type:`button`,title:K(`buttons.edit`),"aria-label":K(`buttons.edit`),label:K(`buttons.edit`),onClick:_,className:`excalidraw-hyperlinkContainer--edit`,icon:Ox}),(0,W.jsx)(kw,{type:`button`,title:K(`labels.linkToElement`),"aria-label":K(`labels.linkToElement`),label:K(`labels.linkToElement`),onClick:()=>{n({openDialog:{name:`elementLinkSelector`,sourceElementId:e.id}})},icon:yw}),u&&!Sn(e)&&(0,W.jsx)(kw,{type:`button`,title:K(`buttons.remove`),"aria-label":K(`buttons.remove`),label:K(`buttons.remove`),onClick:g,className:`excalidraw-hyperlinkContainer--remove`,icon:Ix})]})]})},tk=(e,t,n)=>{let[r,i]=ji(e,n),{x:a,y:o}=lc({sceneX:r+e.width/2,sceneY:i},t);return{x:a-t.offsetLeft-qO/2,y:o-t.offsetTop-XO}},nk=(e,t)=>{let n=ot(e,t);return Sn(n[0])?`labels.link.editEmbed`:n[0]?.link?`labels.link.edit`:`labels.link.create`},rk=null,ik=(e,t,n)=>{rk&&clearTimeout(rk),rk=window.setTimeout(()=>ak(e,t,n),300)},ak=(e,t,n)=>{if(!e.link)return;let r=NE();r.classList.add(`excalidraw-tooltip--visible`),r.style.maxWidth=`20rem`,r.textContent=Qe(e.link)?K(`labels.link.goToElement`):e.link;let[i,a,o,s]=ji(e,n),[c,l,u,d]=An([i,a,o,s],e.angle,t),f=lc({sceneX:c,sceneY:l},t);PE(r,{left:f.x,top:f.y,width:u,height:d},`top`),Vw(`hyperlink`,`tooltip`,`link-icon`),QO=!0},ok=()=>{rk&&clearTimeout(rk),QO&&(QO=!1,NE().classList.remove(`excalidraw-tooltip--visible`))},sk=(e,t,n,[r,i])=>{let{x:a,y:o}=Qn({clientX:r,clientY:i},n),s=15/n.zoom.value;if(Ta(F(a,o),e,t))return!1;let[c,l,u]=ji(e,t);if(a>=c&&a<=u&&o>=l-XO&&o<=l)return!1;let{x:d,y:f}=tk(e,n,t);return!(r>=d-s&&r<=d+qO+YO*2+s&&i>=f-s&&i<=f+s+YO*2+JO)},ck=X({name:`hyperlink`,label:(e,t)=>nk(k(e),t),icon:Xx,perform:(e,t)=>t.showHyperlinkPopup!==`editor`&&{elements:e,appState:{...t,showHyperlinkPopup:`editor`,openMenu:null},captureUpdate:N.IMMEDIATELY},trackEvent:{category:`hyperlink`,action:`click`},keyTest:e=>e[L.CTRL_OR_CMD]&&e.key===L.K,predicate:(e,t)=>ot(e,t).length===1,PanelComponent:({elements:e,appState:t,updateData:n})=>{let r=ot(e,t);return(0,W.jsx)(kw,{type:`toggle`,icon:Xx,"aria-label":K(nk(k(e),t)),title:`${Sn(e[0])?K(`labels.link.labelEmbed`):K(`labels.link.label`)} - ${Z(`CtrlOrCmd+K`)}`,onSelect:()=>n(null),checked:r.length===1&&!!r[0].link})}}),lk=e=>e.every(e=>!e.locked),uk=X({name:`toggleElementLock`,label:(e,t,n)=>lk(n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}))?`labels.elementLock.lock`:`labels.elementLock.unlock`,icon:(e,t)=>lk(ot(t,e))?hx:mx,trackEvent:{category:`element`},predicate:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t);return i.length>0&&!i.some(e=>e.locked&&e.frameId)},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!i.length)return!1;let a=lk(i),o=d(i),s=i.length>1&&ne(i),c=i.length===1||s?null:Ao(),l={...t.lockedMultiSelections};if(a)l={...t.lockedMultiSelections,...c?{[c]:!0}:{}};else if(s){let e=i[0].groupIds.at(-1);delete l[e]}let u=e.map(e=>{if(!o.has(e.id))return e;let n=e.groupIds;return a?c&&(n=[...n,c]):n=n.filter(e=>!t.lockedMultiSelections[e]),j(e,{locked:a,groupIds:n.length===e.groupIds.length?e.groupIds:n})}),f=d(u),p=a?{}:Object.fromEntries(i.map(e=>[e.id,!0])),m=i.map(e=>f.get(e.id)||e),h=a?{}:gn(k(m),t),g=a?c||(s?i[0].groupIds.at(-1):i[0].id):null;return{elements:u,appState:{...t,selectedElementIds:p,selectedGroupIds:h,selectedLinearElement:a?null:t.selectedLinearElement,lockedMultiSelections:l,activeLockedId:g},captureUpdate:N.IMMEDIATELY}},keyTest:(e,t,n,r)=>e.key.toLocaleLowerCase()===L.L&&e[L.CTRL_OR_CMD]&&e.shiftKey&&r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}).length>0}),dk=X({name:`unlockAllElements`,trackEvent:{category:`canvas`},viewMode:!1,icon:mx,predicate:(e,t)=>ot(e,t).length===0&&e.some(e=>e.locked),perform:(e,t)=>{let n=e.filter(e=>e.locked),r=e.map(e=>{if(e.locked){let n=e.groupIds.filter(e=>!t.lockedMultiSelections[e]);return j(e,{locked:!1,groupIds:e.groupIds.length===n.length?e.groupIds:n})}return e}),i=d(r),a=n.map(e=>i.get(e.id)||e),o=k(a);return{elements:r,appState:{...t,selectedElementIds:Object.fromEntries(o.map(e=>[e.id,!0])),selectedGroupIds:gn(o,t),lockedMultiSelections:{},activeLockedId:null},captureUpdate:N.IMMEDIATELY}},label:`labels.elementLock.unlockAll`}),fk=8,pk=10,mk=[`rectangle`,`diamond`,`ellipse`],hk=[`line`,`sharpArrow`,`curvedArrow`,`elbowArrow`],gk=new Set(mk),_k=new Set(hk),vk=e=>gk.has(e),yk=e=>e===`arrow`||_k.has(e),bk=yl(null),xk=new Map,Sk=new Map,Ck=({app:e})=>{let t=e.scene.getSelectedElements(e.state),n=(0,H.useRef)(null);return(0,H.useEffect)(()=>{if(t.length===0){e.updateEditorAtom(bk,null);return}let r=Dk(t);r&&!n.current?n.current=r:(n.current&&!r||n.current&&r!==n.current)&&(e.updateEditorAtom(bk,null),n.current=null)},[t,e]),(0,H.useEffect)(()=>()=>{xk.clear(),Sk.clear()},[]),(0,W.jsx)(wk,{app:e,elements:t})},wk=({app:e,elements:t})=>{let n=Dk(t),r=(0,H.useMemo)(()=>n===`generic`?Ak(t):[],[n,t]),i=(0,H.useMemo)(()=>n===`linear`?jk(t):[],[n,t]),a=n===`generic`?r.every(e=>e.type===r[0].type):n===`linear`&&i.every(e=>_i(e)===_i(i[0])),[o,s]=(0,H.useState)({x:0,y:0}),c=(0,H.useRef)(``),l=(0,H.useRef)(null);(0,H.useEffect)(()=>{let t=[...r,...i].sort((e,t)=>e.id.localeCompare(t.id)),n=`
|
|
45
|
+
${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${t.map(e=>e.id).join(`,`)}`;if(n===c.current)return;c.current=n;let a;if(t.length===1){let[n,,,r,i,o]=ji(t[0],e.scene.getNonDeletedElementsMap());a=rl(F(n,r),F(i,o),t[0].angle)}else{let{minX:e,maxY:n}=Ue(t);a=F(e,n)}let{x:o,y:l}=lc({sceneX:a[0],sceneY:a[1]},e.state);s({x:o,y:l})},[r,i,e.scene,e.state]),(0,H.useEffect)(()=>{for(let e of i){let t=kk(e.id,Bk(e));Sk.has(t)||Sk.set(t,e)}},[i]),(0,H.useEffect)(()=>{for(let t of r)if(!xk.has(t.id)){let n=Ga(t,e.scene.getNonDeletedElementsMap());n&&xk.set(t.id,{fontSize:n.fontSize})}},[r,e.scene]);let u=n===`linear`?[[`line`,Ex],[`sharpArrow`,fw],[`curvedArrow`,mw],[`elbowArrow`,pw]]:n===`generic`?[[`rectangle`,Sx],[`diamond`,Cx],[`ellipse`,wx]]:[];return(0,W.jsx)(`div`,{ref:l,tabIndex:-1,style:{position:`absolute`,top:`${o.y+(pk+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${o.x-e.state.offsetLeft-fk}px`,zIndex:2},className:Ai.CONVERT_ELEMENT_TYPE_POPUP,children:u.map(([o,s])=>{let c=a&&(n===`generic`&&r[0].type===o||n===`linear`&&_i(i[0])===o);return(0,W.jsx)(kw,{type:`toggle`,icon:s,checked:c,title:o,"aria-label":o,"data-testid":`toolbar-${o}`,onSelect:()=>{c||(e.state.activeTool.type!==o&&Vw(`convertElementType`,o,`ui`),Ek(e,{conversionType:n,nextType:o}),l.current?.focus())}},`${t[0].id}${t[0].version}_${o}`)})})},Tk=(e,t,n)=>{let r=Ca(e,t),i=Cs(e,t),a=En(t.text,Ro(t),r),o=Di(a,Ro(t),t.lineHeight),s=t.fontSize;for(;(o.width>r||o.height>i)&&s>0;){--s;let e={...t,fontSize:s};o=Di(t.text,Ro(e),t.lineHeight)}Xr(t,n.getNonDeletedElementsMap(),{fontSize:s,width:o.width,height:o.height}),gt(t,e,n)},Ek=(e,{conversionType:t,nextType:n,direction:r=`right`})=>{if(!t)return!1;let i=e.scene.getSelectedElements(e.state),a=i.reduce((e,t)=>({...e,[t.id]:!0}),{}),o=r===`right`?1:-1;if(t===`generic`){let t=Ak(i),r=t.every(e=>e.type===t[0].type)?mk.indexOf(t[0].type):-1;if(n??=mk[(r+mk.length+o)%mk.length],n&&vk(n)){let r={};for(let i of t){let t=Rk(i,n,e);r[t.id]=t}let i=[];for(let t of e.scene.getElementsIncludingDeleted())r[t.id]?i.push(r[t.id]):i.push(t);e.scene.replaceAllElements(i);for(let t of Object.values(r)){let n=Ga(t,e.scene.getNonDeletedElementsMap());n&&(xk.get(t.id)&&Xr(n,e.scene.getNonDeletedElementsMap(),{fontSize:xk.get(t.id)?.fontSize??n.fontSize}),Tk(t,n,e.scene))}e.setState(e=>({selectedElementIds:a,activeTool:ae(e,{type:`selection`})}))}}if(t===`linear`){let t=jk(i);if(!n){let e=zi(t,_i);n=hk[((e?hk.indexOf(e):-1)+hk.length+o)%hk.length]}if(yk(n)){let r=[],i=e.scene.getElementsMapIncludingDeleted();for(let a of t){let t=Sk.get(kk(a.id,n));if(t&&_i(t)===n)i.set(t.id,t),r.push(t);else{let t=Rk(a,n,e);i.set(t.id,t),r.push(t)}}e.scene.replaceAllElements(i);for(let t of r)if(ro(t)){if(Br(t)){let n=Ik(t);if(n.length<2)continue;let r=[];for(let e=1;e<n.length-2;e++)r.push({start:n[e],end:n[e+1],index:e+1});let i=Bc(t,e.scene.getNonDeletedElementsMap(),{points:n,fixedSegments:r});Xr(t,e.scene.getNonDeletedElementsMap(),{...i,endArrowhead:`arrow`})}else{let n=Wa([`line`,`sharpArrow`,`curvedArrow`],e=>Sk.get(kk(t.id,e)));if(n){let r=n.points;e.scene.mutateElement(t,{points:r})}}}}let r=jk(e.scene.getSelectedElements(e.state));e.setState(t=>({selectedElementIds:a,selectedLinearElement:r.length===1?new I(r[0],e.scene.getNonDeletedElementsMap()):null,activeTool:ae(t,{type:`selection`})}))}return!0},Dk=e=>{if(e.length===0)return null;let t=!1;for(let n of e){if(vk(n.type))return`generic`;Ok(n)&&(t=!0)}return t?`linear`:null},Ok=e=>ro(e)&&(!ye(e)||!et(e)&&!xr(e)),kk=(e,t)=>`${e}:${t}`,Ak=e=>e.filter(e=>vk(e.type)),jk=e=>e.filter(e=>Ok(e)),Mk=20,Nk=(e,t)=>e[0]===t[0],Pk=(e,t)=>e[1]===t[1],Fk=(e,t)=>Nk(e,t)?Math.abs(e[1]-t[1]):Math.abs(e[0]-t[0]),Ik=e=>{let t=[e.points[0]],n=Lk(e.points);for(let e=1;e<n.length;++e){let r=t[t.length-1],i=[...n[e]];Math.abs(i[0]-r[0])<Mk?i[0]=r[0]:Math.abs(i[1]-r[1])<Mk&&(i[1]=r[1]),Nk(r,i)||Pk(r,i)||t.push(F(r[0],i[1])),t.push(i)}let r=[t[0]];for(let e=1;e<t.length-1;++e)Nk(t[e-1],t[e])&&Nk(t[e],t[e+1])||Pk(t[e-1],t[e])&&Pk(t[e],t[e+1])||r.push(t[e]);r.push(t[t.length-1]);let i=[r[0]];for(let e=1;e<r.length-1;++e){let t=i[i.length-1],n=r[e],a=r[e+1],o=Nk(t,n),s=Nk(n,a);if(o!==s){let e=Fk(t,n),r=Fk(n,a);if(e<Mk||r<Mk){if(r<e)o?a[0]=t[0]:a[1]=t[1];else if(s)for(let e=i.length-1;e>=0&&i[e][0]===t[0];--e)i[e][0]=n[0];else for(let e=i.length-1;e>=0&&i[e][1]===t[1];--e)i[e][1]=n[1];continue}}i.push(n)}return i.push(r[r.length-1]),i},Lk=e=>{if(e.length===0)return[];let t=[e[0]];for(let n=1;n<e.length;n++){let[r,i]=t[t.length-1],[a,o]=e[n];(r!==a||i!==o)&&t.push(e[n])}return t},Rk=(e,t,n)=>{if(!zk(e.type,t)){if(!Fn())throw Error(`Invalid conversion from ${e.type} to ${t}.`);return e}if(e.type===t)return e;if(Nn.delete(e),vk(t)){let r=_r(At({...e,type:t,roundness:e.roundness?{type:In(t)?Pa.ADAPTIVE_RADIUS:Pa.PROPORTIONAL_RADIUS}:e.roundness}));return mn(r,n.scene,n.state),r}if(yk(t))switch(t){case`line`:return _r(wt({...e,type:`line`}));case`sharpArrow`:return _r(sn({...e,type:`arrow`,elbowed:!1,roundness:null,startArrowhead:n.state.currentItemStartArrowhead,endArrowhead:n.state.currentItemEndArrowhead}));case`curvedArrow`:return _r(sn({...e,type:`arrow`,elbowed:!1,roundness:{type:Pa.PROPORTIONAL_RADIUS},startArrowhead:n.state.currentItemStartArrowhead,endArrowhead:n.state.currentItemEndArrowhead}));case`elbowArrow`:return _r(sn({...e,type:`arrow`,elbowed:!0,fixedSegments:null,roundness:null}))}return _c(t,`unhandled conversion type: ${t}`),e},zk=(e,t)=>!!(vk(e)&&vk(t)||yk(e)&&yk(t)),Bk=e=>ro(e)?_i(e):e.type,Vk=Ck,Hk=X({name:`toggleShapeSwitch`,label:`labels.shapeSwitch`,icon:()=>null,viewMode:!0,trackEvent:{category:`shape_switch`,action:`toggle`},keywords:[`change`,`switch`,`swap`],perform(e,t,n,r){return Kb.set(bk,{type:`panel`}),{captureUpdate:N.NEVER}},checked:e=>e.gridModeEnabled,predicate:(e,t,n)=>Dk(e)!==null}),Uk=X({name:`copyElementLink`,label:`labels.copyElementLink`,icon:TC,trackEvent:{category:`element`},perform:async(e,t,n,r)=>{let i=ot(e,t);try{if(window.location){let n=Fa(i,t);return n?(await UD(r.props.generateLinkForSelection?r.props.generateLinkForSelection(n.id,n.type):Pi(n.id,n.type)),{appState:{toast:{message:K(`toast.elementLinkCopied`),closable:!0}},captureUpdate:N.EVENTUALLY}):{appState:t,elements:e,app:r,captureUpdate:N.EVENTUALLY}}}catch(e){console.error(e)}return{appState:t,elements:e,app:r,captureUpdate:N.EVENTUALLY}},predicate:(e,t)=>Rr(ot(e,t))}),Wk=X({name:`linkToElement`,label:`labels.linkToElement`,icon:yw,perform:(e,t,n,r)=>{let i=ot(e,t);return i.length!==1||!Rr(i)?{elements:e,appState:t,app:r,captureUpdate:N.EVENTUALLY}:{appState:{...t,openDialog:{name:`elementLinkSelector`,sourceElementId:ot(e,t)[0].id}},captureUpdate:N.IMMEDIATELY}},predicate:(e,t,n,r)=>{let i=ot(e,t);return t.openDialog?.name!==`elementLinkSelector`&&i.length===1&&Rr(i)},trackEvent:!1}),Gk={toggleTheme:[Z(`Shift+Alt+D`)],saveScene:[Z(`CtrlOrCmd+S`)],loadScene:[Z(`CtrlOrCmd+O`)],clearCanvas:[Z(`CtrlOrCmd+Delete`)],imageExport:[Z(`CtrlOrCmd+Shift+E`)],commandPalette:[Z(`CtrlOrCmd+/`),Z(`CtrlOrCmd+Shift+P`)],cut:[Z(`CtrlOrCmd+X`)],copy:[Z(`CtrlOrCmd+C`)],paste:[Z(`CtrlOrCmd+V`)],copyStyles:[Z(`CtrlOrCmd+Alt+C`)],pasteStyles:[Z(`CtrlOrCmd+Alt+V`)],selectAll:[Z(`CtrlOrCmd+A`)],deleteSelectedElements:[Z(`Delete`)],duplicateSelection:[Z(`CtrlOrCmd+D`),Z(`Alt+${K(`helpDialog.drag`)}`)],sendBackward:[Z(`CtrlOrCmd+[`)],bringForward:[Z(`CtrlOrCmd+]`)],sendToBack:[Z(pc?`CtrlOrCmd+Alt+[`:`CtrlOrCmd+Shift+[`)],bringToFront:[Z(pc?`CtrlOrCmd+Alt+]`:`CtrlOrCmd+Shift+]`)],copyAsPng:[Z(`Shift+Alt+C`)],group:[Z(`CtrlOrCmd+G`)],ungroup:[Z(`CtrlOrCmd+Shift+G`)],gridMode:[Z(`CtrlOrCmd+'`)],zenMode:[Z(`Alt+Z`)],objectsSnapMode:[Z(`Alt+S`)],stats:[Z(`Alt+/`)],addToLibrary:[],flipHorizontal:[Z(`Shift+H`)],flipVertical:[Z(`Shift+V`)],viewMode:[Z(`Alt+R`)],hyperlink:[Z(`CtrlOrCmd+K`)],toggleElementLock:[Z(`CtrlOrCmd+Shift+L`)],resetZoom:[Z(`CtrlOrCmd+0`)],zoomOut:[Z(`CtrlOrCmd+-`)],zoomIn:[Z(`CtrlOrCmd++`)],zoomToFitSelection:[Z(`Shift+3`)],zoomToFit:[Z(`Shift+1`)],zoomToFitSelectionInViewport:[Z(`Shift+2`)],saveFileToDisk:[Z(`CtrlOrCmd+S`)],saveToActiveFile:[Z(`CtrlOrCmd+S`)],toggleShortcuts:[Z(`?`)],searchMenu:[Z(`CtrlOrCmd+F`)],wrapSelectionInFrame:[],toolLock:[Z(`Q`)]},Kk=(e,t=0)=>{let n=Gk[e];return n&&n.length>0?n[t]||n[0]:``},qk=RegExp(`[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]`,`g`),Jk=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Yk={À:`A`,Á:`A`,Â:`A`,Ã:`A`,Ä:`A`,Å:`A`,à:`a`,á:`a`,â:`a`,ã:`a`,ä:`a`,å:`a`,Ç:`C`,ç:`c`,Ð:`D`,ð:`d`,È:`E`,É:`E`,Ê:`E`,Ë:`E`,è:`e`,é:`e`,ê:`e`,ë:`e`,Ì:`I`,Í:`I`,Î:`I`,Ï:`I`,ì:`i`,í:`i`,î:`i`,ï:`i`,Ñ:`N`,ñ:`n`,Ò:`O`,Ó:`O`,Ô:`O`,Õ:`O`,Ö:`O`,Ø:`O`,ò:`o`,ó:`o`,ô:`o`,õ:`o`,ö:`o`,ø:`o`,Ù:`U`,Ú:`U`,Û:`U`,Ü:`U`,ù:`u`,ú:`u`,û:`u`,ü:`u`,Ý:`Y`,ý:`y`,ÿ:`y`,Æ:`E`,æ:`e`,Þ:`T`,þ:`t`,ß:`s`,Ā:`A`,Ă:`A`,Ą:`A`,ā:`a`,ă:`a`,ą:`a`,Ć:`C`,Ĉ:`C`,Ċ:`C`,Č:`C`,ć:`c`,ĉ:`c`,ċ:`c`,č:`c`,Ď:`D`,Đ:`D`,ď:`d`,đ:`d`,Ē:`E`,Ĕ:`E`,Ė:`E`,Ę:`E`,Ě:`E`,ē:`e`,ĕ:`e`,ė:`e`,ę:`e`,ě:`e`,Ĝ:`G`,Ğ:`G`,Ġ:`G`,Ģ:`G`,ĝ:`g`,ğ:`g`,ġ:`g`,ģ:`g`,Ĥ:`H`,Ħ:`H`,ĥ:`h`,ħ:`h`,Ĩ:`I`,Ī:`I`,Ĭ:`I`,Į:`I`,İ:`I`,ĩ:`i`,ī:`i`,ĭ:`i`,į:`i`,ı:`i`,Ĵ:`J`,ĵ:`j`,Ķ:`K`,ķ:`k`,ĸ:`k`,Ĺ:`L`,Ļ:`L`,Ľ:`L`,Ŀ:`L`,Ł:`L`,ĺ:`l`,ļ:`l`,ľ:`l`,ŀ:`l`,ł:`l`,Ń:`N`,Ņ:`N`,Ň:`N`,Ŋ:`N`,ń:`n`,ņ:`n`,ň:`n`,ŋ:`n`,Ō:`O`,Ŏ:`O`,Ő:`O`,ō:`o`,ŏ:`o`,ő:`o`,Ŕ:`R`,Ŗ:`R`,Ř:`R`,ŕ:`r`,ŗ:`r`,ř:`r`,Ś:`S`,Ŝ:`S`,Ş:`S`,Š:`S`,ś:`s`,ŝ:`s`,ş:`s`,š:`s`,Ţ:`T`,Ť:`T`,Ŧ:`T`,ţ:`t`,ť:`t`,ŧ:`t`,Ũ:`U`,Ū:`U`,Ŭ:`U`,Ů:`U`,Ű:`U`,Ų:`U`,ũ:`u`,ū:`u`,ŭ:`u`,ů:`u`,ű:`u`,ų:`u`,Ŵ:`W`,ŵ:`w`,Ŷ:`Y`,ŷ:`y`,Ÿ:`Y`,Ź:`Z`,Ż:`Z`,Ž:`Z`,ź:`z`,ż:`z`,ž:`z`,IJ:`I`,ij:`i`,Œ:`E`,œ:`e`,ʼn:`n`,ſ:`s`},Xk=e=>e.replace(Jk,e=>Yk[e]||e).replace(qk,``),Zk=()=>{let[e,t]=(0,H.useState)(null);return[e,(0,H.useCallback)(e=>t(e),[])]},Qk=({elements:e,appState:t,files:n,maxWidthOrHeight:r,getDimensions:i,exportPadding:a,exportingFrame:o})=>{let s=k($c(e,null,{deleteInvisibleElements:!0})),c=at(t,null),{exportBackground:l,viewBackgroundColor:u}=c;return vi(s,{...c,offsetTop:0,offsetLeft:0,width:0,height:0},n||{},{exportBackground:l,exportPadding:a,viewBackgroundColor:u,exportingFrame:o},(e,n)=>{let a=document.createElement(`canvas`);if(r){typeof i==`function`&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let o=Math.max(e,n),s=r<o?r/o:t?.exportScale??1;return a.width=e*s,a.height=n*s,{canvas:a,scale:s}}let o=i?.(e,n)||{width:e,height:n};return a.width=o.width,a.height=o.height,{canvas:a,scale:o.scale??1}})},$k=async e=>{let{mimeType:t=M.png,quality:n}=e;t===M.png&&typeof n==`number`&&console.warn(`"quality" will be ignored for "${M.png}" mimeType`),t===`image/jpg`&&(t=M.jpg),t===M.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${M.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let r=await Qk(e);return n||=/image\/jpe?g/.test(t)?.92:.8,new Promise((i,a)=>{r.toBlob(async n=>{if(!n)return a(Error(`couldn't export to blob`));n&&t===M.png&&e.appState?.exportEmbedScene&&(n=await _o({blob:n,metadata:Ys($c(e.elements,null),e.appState,e.files||{},`local`)})),i(n)},t,n)})},eA=async({elements:e,appState:t=Gt(),files:n={},exportPadding:r,renderEmbeddables:i,exportingFrame:a,skipInliningFonts:o,reuseImages:s})=>{let c=k($c(e,null,{deleteInvisibleElements:!0})),l={...at(t,null),exportPadding:r};return js(c,l,n,{exportingFrame:a,renderEmbeddables:i,skipInliningFonts:o,reuseImages:s})},tA=async e=>{if(e.type===`svg`)await UD((await eA(e)).outerHTML);else if(e.type===`png`)await HD($k(e));else if(e.type===`json`)await jD(k($c(e.elements,null)),e.files);else throw Error(`Invalid export type`)},nA=yl(new Map),rA=async e=>await eA({elements:e,appState:{exportBackground:!1,viewBackgroundColor:Ma.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),iA=(e,t,n,r)=>{let[i,a]=(0,H.useState)();return(0,H.useEffect)(()=>{if(t){if(e){let r=n.get(e);r?a(r):(async()=>{let r=await rA(t);r.querySelector(`.style-fonts`)?.remove(),r&&(n.set(e,r),a(r))})()}else(async()=>{let e=await rA(t);a(e)})()}},[e,t,n,a]),(0,H.useEffect)(()=>{let e=r.current;if(e)return i&&(e.innerHTML=i.outerHTML),()=>{e.innerHTML=``}},[i,r]),i},aA=()=>{let[e]=Vb(nA);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:t=>{t.forEach(t=>e.delete(t))},svgCache:e}},oA=[`excalidraw.com`,`raw.githubusercontent.com/excalidraw/excalidraw-libraries`],sA=new dt,cA=yl({status:`loaded`,isInitialized:!1,libraryItems:[]}),lA=e=>Fr(e),uA=(e,t)=>!e.find(e=>e.elements.length===t.elements.length&&e.elements.every((e,n)=>e.id===t.elements[n].id&&e.versionNonce===t.elements[n].versionNonce)),dA=(e,t)=>{let n=[];for(let r of t)uA(e,r)&&n.push(r);return[...n,...e]},fA=(e,t)=>{let n=d(t),r={deletedItems:new Map,addedItems:new Map,updatedItems:new Map};for(let t of e)n.has(t.id)||r.deletedItems.set(t.id,t);let i=d(e);for(let e of t){let t=i.get(e.id);t?xA(t)!==xA(e)&&r.updatedItems.set(e.id,e):r.addedItems.set(e.id,e)}return r},pA=class{constructor(e){V(this,`currLibraryItems`,[]),V(this,`prevLibraryItems`,lA(this.currLibraryItems)),V(this,`app`),V(this,`updateQueue`,[]),V(this,`getLastUpdateTask`,()=>this.updateQueue[this.updateQueue.length-1]),V(this,`notifyListeners`,()=>{if(this.updateQueue.length>0)Kb.set(cA,e=>({status:`loading`,libraryItems:this.currLibraryItems,isInitialized:e.isInitialized}));else{Kb.set(cA,{status:`loaded`,libraryItems:this.currLibraryItems,isInitialized:!0});try{let e=this.prevLibraryItems;this.prevLibraryItems=lA(this.currLibraryItems);let t=lA(this.currLibraryItems);this.app.props.onLibraryChange?.(t),sA.trigger(fA(e,t),t)}catch(e){console.error(e)}}}),V(this,`destroy`,()=>{this.updateQueue=[],this.currLibraryItems=[],Kb.set(nA,new Map)}),V(this,`resetLibrary`,()=>this.setLibrary([])),V(this,`getLatestLibrary`,()=>new Promise(async e=>{try{let t=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?e(this.getLatestLibrary()):e(lA(t))}catch{return e(this.currLibraryItems)}})),V(this,`updateLibrary`,async({libraryItems:e,prompt:t=!1,merge:n=!1,openLibraryMenu:r=!1,defaultStatus:i=`unpublished`})=>(r&&this.app.setState({openSidebar:{name:Gi.name,tab:`library`}}),this.setLibrary(()=>new Promise(async(r,a)=>{try{let o=await(typeof e==`function`&&!(e instanceof Blob)?e(this.currLibraryItems):e),s;s=o instanceof Blob?await fs(o,i):ic(o,i),!t||window.confirm(K(`alerts.confirmAddLibrary`,{numShapes:s.length}))?(t&&this.app.focusContainer(),r(n?dA(this.currLibraryItems,s):s)):a(new Js)}catch(e){a(e)}})))),V(this,`setLibrary`,e=>{let t=new Promise(async(t,n)=>{try{await this.getLastUpdateTask(),typeof e==`function`&&(e=e(this.currLibraryItems)),this.currLibraryItems=lA(await e),t(this.currLibraryItems)}catch(e){n(e)}}).catch(e=>{if(e.name===`AbortError`)return console.warn(`Library update aborted by user`),this.currLibraryItems;throw e}).finally(()=>{this.updateQueue=this.updateQueue.filter(e=>e!==t),this.notifyListeners()});return this.updateQueue.push(t),this.notifyListeners(),t}),this.app=e}},mA=e=>{let t=Math.ceil(Math.sqrt(e.length)),n=[],r=n=>e.slice(n*t,n*t+t).reduce((e,t)=>{let{height:n}=Ue(t.elements);return Math.max(e,n)},0),i=n=>{let r=0,i=0,a=0;for(let o of e){if(r%t===0&&(i=0),i===n){let{width:e}=Ue(o.elements);a=Math.max(a,e)}r++,i++}return a},a=0,o=0,s=0,c=0,l=0,u=0,d=0;for(let f of e){l&&l%t===0&&(o+=s+50,a=0,u=0,d++),u===0&&(s=r(d)),c=i(u);let{minX:e,minY:p,width:m,height:h}=Ue(f.elements),g=(c-m)/2,_=(s-h)/2;n.push(...f.elements.map(t=>({...t,x:t.x+a+g-e,y:t.y+o+_-p}))),a+=c+50,l++,u++}return n},hA=(e,t=oA)=>{if(typeof t==`function`?t(e):t.some(t=>{let n=new URL(`https://${t.replace(/^https?:\/\//,``)}`),{hostname:r,pathname:i}=new URL(e);return RegExp(`(^|\\.)${n.hostname}$`).test(r)&&RegExp(`^${n.pathname.replace(/\/+$/,``)}(/+|$)`).test(i)}))return!0;throw Error(`Invalid or disallowed library URL: "${e}"`)},gA=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(_t.addLibrary)||new URLSearchParams(window.location.search).get(Zi.addLibrary),t=e?new URLSearchParams(window.location.hash.slice(1)).get(`token`):null;return e?{libraryUrl:e,idToken:t}:null},_A=class e{constructor(e){V(this,`adapter`),this.adapter=e}static async getLibraryItems(t,n,r=!0){let i=()=>new Promise(async(e,r)=>{try{let r=await t.load({source:n});e(ic(r?.libraryItems||[],`published`))}catch(e){r(e)}});return r?e.queue.push(i):i()}getLibraryItems(t){return e.getLibraryItems(this.adapter,t,!1)}};V(_A,`queue`,new C),V(_A,`run`,async(e,t)=>{let n=new _A(e);return _A.queue.push(()=>t(n))});var vA=_A,yA=0,bA=0,xA=e=>`${e.id}:${e.name||``}:${Bs(e.elements)}`,SA=e=>ft(e.map(e=>xA(e)).sort().join()),CA=async(e,t)=>{try{return bA++,await vA.run(e,async n=>{let r=d(await n.getLibraryItems(`save`));for(let[e]of t.deletedItems)r.delete(e);let i=[];for(let[e,n]of t.addedItems)r.has(e)?r.set(e,n):i.push(n);if(t.updatedItems)for(let[e,n]of t.updatedItems)r.set(e,n);let a=i.concat(Array.from(r.values())),o=SA(a);return o!==yA&&await e.save({libraryItems:a}),yA=o,a})}finally{bA--}},wA=e=>{let{excalidrawAPI:t}=e,n=(0,H.useRef)(e);n.current=e;let r=(0,H.useRef)(!1);(0,H.useEffect)(()=>{if(!t)return;r.current=!1;let e=async({libraryUrl:e,idToken:r})=>{let i=new Promise(async(t,r)=>{try{e=decodeURIComponent(e),e=Os(e),hA(e,n.current.validateLibraryUrl),t(await(await fetch(e)).blob())}catch(e){r(e)}}),a=r!==t.id;await(a&&document.hidden?new Promise(e=>{window.addEventListener(`focus`,()=>e(),{once:!0})}):null);try{await t.updateLibrary({libraryItems:i,prompt:a,merge:!0,defaultStatus:`published`,openLibraryMenu:!0})}catch(e){throw t.updateScene({appState:{errorMessage:e.message}}),e}finally{if(window.location.hash.includes(_t.addLibrary)){let e=new URLSearchParams(window.location.hash.slice(1));e.delete(_t.addLibrary),window.history.replaceState({},co,`#${e.toString()}`)}else if(window.location.search.includes(Zi.addLibrary)){let e=new URLSearchParams(window.location.search);e.delete(Zi.addLibrary),window.history.replaceState({},co,`?${e.toString()}`)}}},i=t=>{t.preventDefault();let n=gA();n&&(t.stopImmediatePropagation(),window.history.replaceState({},``,t.oldURL),e(n))},a=gA();if(a&&e(a),`getInitialLibraryItems`in n.current&&n.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(n.current.getInitialLibraryItems()).then(e=>{t.updateLibrary({libraryItems:e,merge:!0})}).catch(e=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${e?.message}`)})),`adapter`in n.current&&n.current.adapter){let e=n.current.adapter,i=n.current.migrationAdapter,a=bs();i?a.resolve(be(i.load).then(async t=>{let n=null;try{if(!t)return vA.getLibraryItems(e,`load`);n=ic(t.libraryItems||[],`published`);let r=await CA(e,fA([],n));try{await i.clear()}catch(e){console.error(`couldn't delete legacy library data: ${e.message}`)}return r}catch(e){return console.error(`couldn't migrate legacy library data: ${e.message}`),n}}).catch(t=>(console.error(`error during library migration: ${t.message}`),vA.getLibraryItems(e,`load`)))):a.resolve(be(vA.getLibraryItems,e,`load`)),t.updateLibrary({libraryItems:a.then(e=>{let t=e||[];return yA=SA(t),t}),merge:!0}).finally(()=>{r.current=!0})}return window.addEventListener(B.HASHCHANGE,i),()=>{window.removeEventListener(B.HASHCHANGE,i)}},[t]),(0,H.useEffect)(()=>{let e=sA.on(async(e,t)=>{let i=r.current,a=`adapter`in n.current&&n.current.adapter||null;try{a&&yA!==SA(t)&&await CA(a,e)}catch(t){console.error(`couldn't persist library update: ${t.message}`,e),i&&n.current.excalidrawAPI&&n.current.excalidrawAPI.updateScene({appState:{errorMessage:K(`errors.saveLibraryError`)}})}}),t=e=>{bA&&Pe(e)};return window.addEventListener(B.BEFORE_UNLOAD,t),()=>{window.removeEventListener(B.BEFORE_UNLOAD,t),e(),yA=0,bA=0}},[])},TA=({theme:e,id:t,libraryReturnUrl:n})=>{let r=n||window.location.origin+window.location.pathname;return(0,W.jsx)(`a`,{className:`library-menu-browse-button`,href:`${xa.VITE_APP_LIBRARY_URL}?target=${window.name||`_blank`}&referrer=${r}&useHash=true&token=${t}&theme=${e}&version=${yc.excalidrawLibrary}`,target:`_excalidraw_libraries`,children:K(`labels.libraries`)})},EA=({libraryReturnUrl:e,theme:t,id:n,style:r,children:i,className:a})=>(0,W.jsxs)(`div`,{className:U(`library-menu-control-buttons`,a),style:r,children:[(0,W.jsx)(TA,{id:n,libraryReturnUrl:e,theme:t}),i]}),DA=yl(0),OA=e=>{let[t,n]=Vb(DA);return(0,H.useEffect)(()=>{let{current:t}=e;if(!t)return;let r=(0,_l.default)(()=>{let{scrollTop:e}=t;n(e)},200);return t.addEventListener(`scroll`,r),()=>{r.cancel(),t.removeEventListener(`scroll`,r)}},[e,n]),t},kA=({label:e,onClick:t,className:n,children:r,actionType:i,type:a=`button`,isLoading:o,...s})=>{let c=i?`Dialog__action-button--${i}`:``;return(0,W.jsxs)(`button`,{className:U(`Dialog__action-button`,c,n),type:a,"aria-label":e,onClick:t,...s,children:[r&&(0,W.jsx)(`div`,{style:o?{visibility:`hidden`}:{},children:r}),(0,W.jsx)(`div`,{style:o?{visibility:`hidden`}:{},children:e}),o&&(0,W.jsx)(`div`,{style:{position:`absolute`,inset:0},children:(0,W.jsx)(Ow,{})})]})},AA=e=>{let{onConfirm:t,onCancel:n,children:r,confirmText:i=K(`buttons.confirm`),cancelText:a=K(`buttons.cancel`),className:o=``,...s}=e,c=_U(),l=Hb(Ej),{container:u}=mU();return(0,W.jsxs)(Pj,{onCloseRequest:n,size:`small`,...s,className:`confirm-dialog ${o}`,children:[r,(0,W.jsxs)(`div`,{className:`confirm-dialog-buttons`,children:[(0,W.jsx)(kA,{label:a,onClick:()=>{c({openMenu:null}),l(!1),(0,hl.flushSync)(()=>{n()}),u?.focus()}}),(0,W.jsx)(kA,{label:i,onClick:()=>{c({openMenu:null}),l(!1),(0,hl.flushSync)(()=>{t()}),u?.focus()},actionType:`danger`})]})]})},jA=class{static has(e){try{return!!window.localStorage.getItem(e)}catch(e){return console.warn(`localStorage.getItem error: ${e.message}`),!1}}static get(e){try{let t=window.localStorage.getItem(e);return t?JSON.parse(t):null}catch(e){return console.warn(`localStorage.getItem error: ${e.message}`),null}}};V(jA,`set`,(e,t)=>{try{return window.localStorage.setItem(e,JSON.stringify(t)),!0}catch(e){return console.warn(`localStorage.setItem error: ${e.message}`),!1}}),V(jA,`delete`,e=>{try{window.localStorage.removeItem(e)}catch(e){console.warn(`localStorage.removeItem error: ${e.message}`)}});var MA=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,NA=/{{([\w-]+)}}/,PA=/<([\w-]+)>/,FA=/<\/([\w-]+)>/,IA=(e,t)=>{let n=[{name:``,children:[]}];return e.split(MA).filter(Boolean).forEach(r=>{let i=r.match(PA),a=r.match(FA),o=r.match(NA);if(i!==null){let r=i[1];t.hasOwnProperty(r)?n.push({name:r,children:[]}):console.warn(`Trans: missed to pass in prop ${r} for interpolating ${e}`)}else if(a!==null){if(a[1]===n[n.length-1].name){let e=n.pop(),r=H.createElement(H.Fragment,{},...e.children),i=t[e.name];typeof i==`function`&&n[n.length-1].children.push(i(r))}else console.warn(`Trans: unexpected end tag ${r} for interpolating ${e}`)}else if(o!==null){let r=o[1];t.hasOwnProperty(r)?n[n.length-1].children.push(t[r]):console.warn(`Trans: key ${r} 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},LA=({i18nKey:e,children:t,...n})=>{let{t:r}=ix();return H.createElement(H.Fragment,{},...IA(r(e),n))},RA=async e=>{let t=pn(e,6),n=document.createElement(`canvas`);n.width=t[0].length*128+(t[0].length+1)*16-16,n.height=t.length*128+(t.length+1)*16-16;let r=n.getContext(`2d`);r.fillStyle=`#fff`,r.fillRect(0,0,n.width,n.height);for(let[t,n]of e.entries()){let e=await Qk({elements:n.elements,files:null,maxWidthOrHeight:128}),{width:i,height:a}=e,o=Math.floor(t/6)*144,s=t%6*144;r.drawImage(e,s+(128-i)/2+8,o+(128-a)/2+8),r.lineWidth=2,r.strokeStyle=`#ced4da`,r.strokeRect(s+4,o+4,136,136)}return await ra(new File([await Xa(n)],`preview`,{type:M.png}),{outputType:M.jpg,maxWidthOrHeight:5e3})},zA=({libItem:e,appState:t,index:n,onChange:r,onRemove:i})=>{let a=(0,H.useRef)(null),o=(0,H.useRef)(null);return(0,H.useEffect)(()=>{let n=a.current;n&&(async()=>{let r=await eA({elements:e.elements,appState:{...t,viewBackgroundColor:`#fff`,exportBackground:!0},files:null,skipInliningFonts:!0});n.innerHTML=r.outerHTML})()},[e.elements,t]),(0,W.jsxs)(`div`,{className:`single-library-item`,children:[e.status===`published`&&(0,W.jsx)(`span`,{className:`single-library-item-status`,children:K(`labels.statusPublished`)}),(0,W.jsx)(`div`,{ref:a,className:`single-library-item__svg`}),(0,W.jsx)(kw,{"aria-label":K(`buttons.remove`),type:`button`,icon:ES,className:`single-library-item--remove`,onClick:i.bind(null,e.id),title:K(`buttons.remove`)}),(0,W.jsxs)(`div`,{style:{display:`flex`,margin:`0.8rem 0`,width:`100%`,fontSize:`14px`,fontWeight:500,flexDirection:`column`},children:[(0,W.jsxs)(`label`,{style:{display:`flex`,justifyContent:`space-between`,flexDirection:`column`},children:[(0,W.jsxs)(`div`,{style:{padding:`0.5em 0`},children:[(0,W.jsx)(`span`,{style:{fontWeight:500,color:`#868e96`},children:K(`publishDialog.itemName`)}),(0,W.jsx)(`span`,{"aria-hidden":`true`,className:`required`,children:`*`})]}),(0,W.jsx)(`input`,{type:`text`,ref:o,style:{width:`80%`,padding:`0.2rem`},defaultValue:e.name,placeholder:`Item name`,onChange:e=>{r(e.target.value,n)}})]}),(0,W.jsx)(`span`,{className:`error`,children:e.error})]})]})},BA=({onClose:e,libraryItems:t,appState:n,onSuccess:r,onError:i,updateItemsInStorage:a,onRemove:o})=>{let[s,c]=(0,H.useState)({authorName:``,githubHandle:``,name:``,description:``,twitterHandle:``,website:``}),[l,u]=(0,H.useState)(!1);(0,H.useEffect)(()=>{let e=jA.get(es.PUBLISH_LIBRARY);e&&c(e)},[]);let[d,f]=(0,H.useState)(t.slice());(0,H.useEffect)(()=>{f(t.slice())},[t]);let p=e=>{c({...s,[e.target.name]:e.target.value})},m=async e=>{e.preventDefault(),u(!0);let t=[],n=!1;if(d.forEach(e=>{let r=``;e.name||(r=K(`publishDialog.errors.required`),n=!0),t.push({...e,error:r})}),n){f(t),u(!1);return}let a=await RA(d),o={type:Mn.excalidrawLibrary,version:yc.excalidrawLibrary,source:Qa(),libraryItems:d},c=JSON.stringify(o,null,2),l=new Blob([c],{type:`application/json`}),p=new FormData;p.append(`excalidrawLib`,l),p.append(`previewImage`,a),p.append(`previewImageType`,a.type),p.append(`title`,s.name),p.append(`authorName`,s.authorName),p.append(`githubHandle`,s.githubHandle),p.append(`name`,s.name),p.append(`description`,s.description),p.append(`twitterHandle`,s.twitterHandle),p.append(`website`,s.website),fetch(`${xa.VITE_APP_LIBRARY_BACKEND}/submit`,{method:`post`,body:p}).then(e=>e.ok?e.json().then(({url:e})=>{jA.delete(es.PUBLISH_LIBRARY),r({url:e,authorName:s.authorName,items:d})}):e.json().catch(()=>{throw Error(e.statusText||`something went wrong`)}).then(t=>{throw Error(t.message||e.statusText||`something went wrong`)}),e=>{console.error(e),i(e),u(!1)}).catch(e=>{console.error(e),i(e),u(!1)})},h=()=>{let e=[];return d.forEach((t,r)=>{e.push((0,W.jsx)(`div`,{className:`single-library-item-wrapper`,children:(0,W.jsx)(zA,{libItem:t,appState:n,index:r,onChange:(e,t)=>{let n=d.slice();n[t].name=e,f(n)},onRemove:o})},r))}),(0,W.jsx)(`div`,{className:`selected-library-items`,children:e})},g=(0,H.useCallback)(()=>{a(d),jA.set(es.PUBLISH_LIBRARY,s),e()},[d,e,a,s]),_=!!t.length,v=t.some(e=>e.status===`published`);return(0,W.jsx)(Pj,{onCloseRequest:g,title:K(`publishDialog.title`),className:`publish-library`,children:_?(0,W.jsxs)(`form`,{onSubmit:m,children:[(0,W.jsx)(`div`,{className:`publish-library-note`,children:(0,W.jsx)(LA,{i18nKey:`publishDialog.noteDescription`,link:e=>(0,W.jsx)(`a`,{href:`https://libraries.excalidraw.com`,target:`_blank`,rel:`noopener`,children:e})})}),(0,W.jsx)(`span`,{className:`publish-library-note`,children:(0,W.jsx)(LA,{i18nKey:`publishDialog.noteGuidelines`,link:e=>(0,W.jsx)(`a`,{href:`https://github.com/excalidraw/excalidraw-libraries#guidelines`,target:`_blank`,rel:`noopener noreferrer`,children:e})})}),(0,W.jsx)(`div`,{className:`publish-library-note`,children:K(`publishDialog.noteItems`)}),v&&(0,W.jsx)(`span`,{className:`publish-library-note publish-library-warning`,children:K(`publishDialog.republishWarning`)}),h(),(0,W.jsxs)(`div`,{className:`publish-library__fields`,children:[(0,W.jsxs)(`label`,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:K(`publishDialog.libraryName`)}),(0,W.jsx)(`span`,{"aria-hidden":`true`,className:`required`,children:`*`})]}),(0,W.jsx)(`input`,{type:`text`,name:`name`,required:!0,value:s.name,onChange:p,placeholder:K(`publishDialog.placeholder.libraryName`)})]}),(0,W.jsxs)(`label`,{style:{alignItems:`flex-start`},children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:K(`publishDialog.libraryDesc`)}),(0,W.jsx)(`span`,{"aria-hidden":`true`,className:`required`,children:`*`})]}),(0,W.jsx)(`textarea`,{name:`description`,rows:4,required:!0,value:s.description,onChange:p,placeholder:K(`publishDialog.placeholder.libraryDesc`)})]}),(0,W.jsxs)(`label`,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:K(`publishDialog.authorName`)}),(0,W.jsx)(`span`,{"aria-hidden":`true`,className:`required`,children:`*`})]}),(0,W.jsx)(`input`,{type:`text`,name:`authorName`,required:!0,value:s.authorName,onChange:p,placeholder:K(`publishDialog.placeholder.authorName`)})]}),(0,W.jsxs)(`label`,{children:[(0,W.jsx)(`span`,{children:K(`publishDialog.githubUsername`)}),(0,W.jsx)(`input`,{type:`text`,name:`githubHandle`,value:s.githubHandle,onChange:p,placeholder:K(`publishDialog.placeholder.githubHandle`)})]}),(0,W.jsxs)(`label`,{children:[(0,W.jsx)(`span`,{children:K(`publishDialog.twitterUsername`)}),(0,W.jsx)(`input`,{type:`text`,name:`twitterHandle`,value:s.twitterHandle,onChange:p,placeholder:K(`publishDialog.placeholder.twitterHandle`)})]}),(0,W.jsxs)(`label`,{children:[(0,W.jsx)(`span`,{children:K(`publishDialog.website`)}),(0,W.jsx)(`input`,{type:`text`,name:`website`,pattern:`https?://.+`,title:K(`publishDialog.errors.website`),value:s.website,onChange:p,placeholder:K(`publishDialog.placeholder.website`)})]}),(0,W.jsx)(`span`,{className:`publish-library-note`,children:(0,W.jsx)(LA,{i18nKey:`publishDialog.noteLicense`,link:e=>(0,W.jsx)(`a`,{href:`https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE`,target:`_blank`,rel:`noopener noreferrer`,children:e})})})]}),(0,W.jsxs)(`div`,{className:`publish-library__buttons`,children:[(0,W.jsx)(kA,{label:K(`buttons.saveLibNames`),onClick:g,"data-testid":`cancel-clear-canvas-button`}),(0,W.jsx)(kA,{type:`submit`,label:K(`buttons.submit`),actionType:`primary`,isLoading:l})]})]}):(0,W.jsx)(`p`,{style:{padding:`1em`,textAlign:`center`,fontWeight:500},children:K(`publishDialog.atleastOneLibItem`)})})},VA={Row:(0,H.forwardRef)(({children:e,gap:t,align:n,justifyContent:r,className:i,style:a},o)=>(0,W.jsx)(`div`,{className:U(`Stack Stack_horizontal`,i),style:{"--gap":t,alignItems:n,justifyContent:r,...a},ref:o,children:e})),Col:(0,H.forwardRef)(({children:e,gap:t,align:n,justifyContent:r,className:i,style:a},o)=>(0,W.jsx)(`div`,{className:U(`Stack Stack_vertical`,i),style:{"--gap":t,justifyItems:n,justifyContent:r,...a},ref:o,children:e}))},HA=({children:e,onClickOutside:t,className:n=``,onSelect:r,open:i=!0,align:a=`end`,style:o})=>{let s=fU(),[c,l]=Zk(),u=(0,H.useMemo)(()=>({current:c}),[c]),d=Yw({onClickOutside:t});Jw(u,(0,H.useCallback)(e=>{u.current?.closest(`.${Ai.DROPDOWN_MENU_EVENT_WRAPPER}`)?.contains(e.target)||d.onClickOutside?.()},[d,u])),(0,H.useEffect)(()=>{if(!i||!c)return;let e=e=>{e.key===L.ESCAPE&&(e.preventDefault(),e.stopImmediatePropagation(),d.onClickOutside?.())},t={capture:!0},n=c.ownerDocument;return n.addEventListener(B.KEYDOWN,e,t),()=>{n.removeEventListener(B.KEYDOWN,e,t)}},[d,i,c]);let f=U(`dropdown-menu ${n}`,{"dropdown-menu--mobile":s.formFactor===`phone`}).trim();return(0,W.jsx)(HT.Provider,{value:{onSelect:r},children:(0,W.jsx)(Jv,{ref:l,className:f,style:o,"data-testid":`dropdown-menu`,align:a,sideOffset:8,onCloseAutoFocus:e=>e.preventDefault(),children:s.formFactor===`phone`?(0,W.jsx)(VA.Col,{className:`dropdown-menu-container`,children:e}):(0,W.jsx)(nT,{className:`dropdown-menu-container`,padding:2,children:e})})})};HA.displayName=`DropdownMenuContent`;var UA=HA,WA=({children:e,className:t=``,selected:n,...r})=>(0,W.jsx)(`div`,{...r,className:`dropdown-menu-item-base dropdown-menu-item-custom ${t} ${n?`dropdown-menu-item--selected`:``}`.trim(),children:e}),GA=({icon:e,shortcut:t,href:n,children:r,onSelect:i,className:a=``,selected:o,rel:s=`noopener`,...c})=>{let l=WT(i);return(0,W.jsx)(Yv,{className:`radix-menu-item`,onSelect:l,asChild:!0,children:(0,W.jsx)(`a`,{...c,href:n,target:`_blank`,rel:`noopener ${s}`,className:UT(a,o),title:c.title??c[`aria-label`],children:(0,W.jsx)(KT,{icon:e,shortcut:t,children:r})})})},KA=GA;GA.displayName=`DropdownMenuItemLink`;var qA=()=>(0,W.jsx)(`div`,{style:{height:`1px`,backgroundColor:`var(--default-border-color)`,margin:`6px 0`,flex:`0 0 auto`}}),JA=qA;qA.displayName=`DropdownMenuSeparator`;var YA=-4,XA=4,ZA=({children:e,className:t})=>{let n=fU(),r=U(`dropdown-menu dropdown-submenu ${t}`,{"dropdown-menu--mobile":n.formFactor===`phone`}).trim(),i=(0,H.useCallback)(e=>{if(e){let t=e.closest(`.dropdown-menu-container`)?.getBoundingClientRect();if(t){let n=e.getBoundingClientRect().width,r=window.innerWidth-t.right;r<n+20&&(o(r-n+YA),c(YA+8))}}},[]),[a,o]=(0,H.useState)(XA),[s,c]=(0,H.useState)(YA);return(0,W.jsx)(Qv,{className:r,sideOffset:a,alignOffset:s,collisionPadding:8,ref:i,children:n.formFactor===`phone`?(0,W.jsx)(VA.Col,{className:`dropdown-menu-container`,children:e}):(0,W.jsx)(nT,{className:`dropdown-menu-container`,padding:2,style:{zIndex:1},children:e})})},QA=ZA;ZA.displayName=`DropdownMenuSubContent`;var $A=({children:e,icon:t,shortcut:n,className:r})=>(0,W.jsxs)(Zv,{className:`${UT(r)} dropdown-menu__submenu-trigger`,children:[(0,W.jsx)(KT,{icon:t,shortcut:n,children:e}),(0,W.jsx)(`div`,{className:`dropdown-menu__submenu-trigger-icon`,children:Ew})]}),ej=$A;$A.displayName=`DropdownMenuSubTrigger`;var tj=e=>t=>H.Children.toArray(t).find(t=>H.isValidElement(t)&&typeof t.type!=`string`&&t?.type.displayName&&t.type.displayName===e)||null,nj=tj(`DropdownMenuTrigger`),rj=tj(`DropdownMenuContent`),ij=tj(`DropdownMenuSubTrigger`),aj=tj(`DropdownMenuSubContent`),oj=({children:e})=>{let t=ij(e),n=aj(e);return(0,W.jsxs)(Xv,{children:[t,n]})};oj.Trigger=ej,oj.Content=QA,oj.displayName=`DropdownMenuSub`;var sj=oj,cj=({className:e=``,children:t,onToggle:n,title:r,...i})=>{let a=fU(),o=U(`dropdown-menu-button ${e}`,`zen-mode-transition`,{"dropdown-menu-button--mobile":a.formFactor===`phone`}).trim();return(0,W.jsx)(qv,{className:o,onClick:n,type:`button`,"data-testid":`dropdown-menu-button`,title:r,...i,children:t})},lj=cj;cj.displayName=`DropdownMenuTrigger`;var uj=e=>(0,W.jsx)(XT,{...e,icon:e.checked?Yx:ww}),dj=({children:e,open:t})=>{let n=nj(e),r=rj(e),i=r&&H.isValidElement(r)?H.cloneElement(r,{open:t}):r;return(0,W.jsx)(Kv,{open:t,modal:!1,children:(0,W.jsxs)(`div`,{className:Ai.DROPDOWN_MENU_EVENT_WRAPPER,style:{display:`contents`},children:[n,i]})})};dj.Trigger=lj,dj.Content=UA,dj.Item=XT,dj.ItemCheckbox=uj,dj.ItemLink=KA,dj.ItemCustom=WA,dj.Group=VT,dj.Separator=JA,dj.Sub=sj;var Q=dj;dj.displayName=`DropdownMenu`;var fj=(e,t)=>e.filter(e=>t.includes(e.id)),pj=({setAppState:e,selectedItems:t,library:n,onRemoveFromLibrary:r,resetLibrary:i,onSelectItems:a,appState:o,className:s})=>{let[c]=Vb(cA),[l,u]=Vb(Ej),d=()=>{let e=t.length?K(`alerts.removeItemsFromsLibrary`,{count:t.length}):K(`alerts.resetLibrary`),n=t.length?K(`confirmDialog.removeItemsFromLib`):K(`confirmDialog.resetLibrary`);return(0,W.jsx)(AA,{onConfirm:()=>{t.length?r():i(),p(!1)},onCancel:()=>{p(!1)},title:n,children:(0,W.jsx)(`p`,{children:e})})},[f,p]=(0,H.useState)(!1),m=!!t.length,h=m?c.libraryItems.filter(e=>t.includes(e.id)):c.libraryItems,g=K(m?`buttons.remove`:`buttons.resetLibrary`),[_,v]=(0,H.useState)(!1),[y,b]=(0,H.useState)(null),x=(0,H.useCallback)(()=>(0,W.jsxs)(Pj,{onCloseRequest:()=>b(null),title:K(`publishSuccessDialog.title`),className:`publish-library-success`,size:`small`,children:[(0,W.jsx)(`p`,{children:(0,W.jsx)(LA,{i18nKey:`publishSuccessDialog.content`,authorName:y.authorName,link:e=>(0,W.jsx)(`a`,{href:y?.url,target:`_blank`,rel:`noopener noreferrer`,children:e})})}),(0,W.jsx)(kw,{type:`button`,title:K(`buttons.close`),"aria-label":K(`buttons.close`),label:K(`buttons.close`),onClick:()=>b(null),"data-testid":`publish-library-success-close`,className:`publish-library-success-close`})]}),[b,y]),S=(e,r)=>{v(!1),b({url:e.url,authorName:e.authorName});let i=r.slice();i.forEach(e=>{t.includes(e.id)&&(e.status=`published`)}),n.setLibrary(i)};return(0,W.jsxs)(`div`,{className:U(`library-menu-dropdown-container`,s),children:[(0,W.jsxs)(Q,{open:l,children:[(0,W.jsx)(Q.Trigger,{onToggle:()=>u(!l),children:ux}),(0,W.jsxs)(Q.Content,{onClickOutside:()=>u(!1),onSelect:()=>u(!1),className:`library-menu`,children:[!m&&(0,W.jsx)(Q.Item,{onSelect:async()=>{try{await n.updateLibrary({libraryItems:Uc({description:`Excalidraw library files`}),merge:!0,openLibraryMenu:!0})}catch(t){if(t?.name===`AbortError`){console.warn(t);return}e({errorMessage:K(`errors.importLibraryError`)})}},icon:$x,"data-testid":`lib-dropdown--load`,children:K(`buttons.load`)}),!!h.length&&(0,W.jsx)(Q.Item,{onSelect:async()=>{let t=m?h:await n.getLatestLibrary();Me(t).catch(Vc).catch(t=>{e({errorMessage:t.message})})},icon:Hx,"data-testid":`lib-dropdown--export`,children:K(`buttons.export`)}),m&&(0,W.jsx)(Q.Item,{icon:SC,onSelect:()=>v(!0),"data-testid":`lib-dropdown--remove`,children:K(`buttons.publishLibrary`)}),!!h.length&&(0,W.jsx)(Q.Item,{onSelect:()=>p(!0),icon:Ix,children:g})]})]}),t.length>0&&(0,W.jsx)(`div`,{className:`library-actions-counter`,children:t.length}),f&&d(),_&&(0,W.jsx)(BA,{onClose:()=>v(!1),libraryItems:fj(c.libraryItems,t),appState:o,onSuccess:e=>S(e,c.libraryItems),onError:e=>window.alert(e),updateItemsInStorage:()=>n.setLibrary(c.libraryItems),onRemove:e=>a(t.filter(t=>t!==e))}),y&&x()]})},mj=({selectedItems:e,onSelectItems:t,className:n})=>{let{library:r}=uU(),{clearLibraryCache:i,deleteItemsFromLibraryCache:a}=aA(),o=Kw(),s=_U(),[c]=Vb(cA),l=async n=>{let i=n.filter(t=>!e.includes(t.id));r.setLibrary(i).catch(()=>{s({errorMessage:K(`alerts.errorRemovingFromLibrary`)})}),a(e),t([])};return(0,W.jsx)(pj,{appState:o,setAppState:s,selectedItems:e,onSelectItems:t,library:r,onRemoveFromLibrary:()=>l(c.libraryItems),resetLibrary:()=>{r.resetLibrary(),i()},className:n})};function hj(){return[!1,(0,H.useCallback)(e=>e(),[])]}var gj=H.useTransition||hj,_j=(0,H.memo)(({id:e,elements:t,isPending:n,onClick:r,selected:i,onToggle:a,onDrag:o,svgCache:s})=>{let c=(0,H.useRef)(null),l=iA(e,t,s,c),[u,d]=(0,H.useState)(!1),f=fU().formFactor===`phone`,p=n&&(0,W.jsx)(`div`,{className:`library-unit__adder`,children:lx});return(0,W.jsxs)(`div`,{className:U(`library-unit`,{"library-unit__active":t,"library-unit--hover":t&&u,"library-unit--selected":i,"library-unit--skeleton":!l}),onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[(0,W.jsx)(`div`,{className:U(`library-unit__dragger`,{"library-unit__pulse":!!n}),ref:c,draggable:!!t,onClick:t||n?t=>{e&&t.shiftKey?a(e,t):r(e)}:void 0,onDragStart:t=>{if(!e){t.preventDefault();return}d(!1),o(e,t)}}),p,e&&t&&(u||f||i)&&(0,W.jsx)(bD,{checked:i,onChange:(t,n)=>a(e,n),className:`library-unit__checkbox`})]})}),vj=()=>(0,W.jsx)(`div`,{className:`library-unit library-unit--skeleton`}),yj=({children:e})=>(0,W.jsx)(`div`,{className:`library-menu-items-container__grid`,children:e}),bj=(0,H.memo)(({items:e,onItemSelectToggle:t,onItemDrag:n,isItemSelected:r,onClick:i,svgCache:a,itemsRenderedPerBatch:o})=>{let[,s]=gj(),[c,l]=(0,H.useState)(0);return(0,H.useEffect)(()=>{c<e.length&&s(()=>{l(c+o)})},[c,e.length,s,o]),(0,W.jsx)(W.Fragment,{children:e.map((e,o)=>o<c?(0,W.jsx)(_j,{elements:e?.elements,isPending:!e?.id&&!!e?.elements,onClick:i,svgCache:a,id:e?.id,selected:r(e.id),onToggle:t,onDrag:n},e?.id??o):(0,W.jsx)(vj,{},o))})}),xj=({type:e=`button`,onSelect:t,selected:n,children:r,className:i=``,...a})=>(0,W.jsx)(`button`,{onClick:us(a.onClick,e=>{t()}),type:e,className:U(`excalidraw-button`,i,{selected:n}),...a,children:r}),Sj=(0,H.forwardRef)(({onChange:e,label:t,fullWidth:n,placeholder:r,readonly:i,selectOnRender:a,onKeyDown:o,isRedacted:s=!1,icon:c,className:l,type:u,...d},f)=>{let p=(0,H.useRef)(null);(0,H.useImperativeHandle)(f,()=>p.current),(0,H.useLayoutEffect)(()=>{a&&(p.current?.focus(),p.current?.select())},[a]);let[m,h]=(0,H.useState)(!1);return(0,W.jsxs)(`div`,{className:U(`ExcTextField`,l,{"ExcTextField--fullWidth":n,"ExcTextField--hasIcon":!!c}),onClick:()=>{p.current?.focus()},children:[c,t&&(0,W.jsx)(`div`,{className:`ExcTextField__label`,children:t}),(0,W.jsxs)(`div`,{className:U(`ExcTextField__input`,{"ExcTextField__input--readonly":i}),children:[(0,W.jsx)(`input`,{className:U({"is-redacted":`value`in d&&d.value&&s&&!m}),readOnly:i,value:`value`in d?d.value:void 0,defaultValue:`defaultValue`in d?d.defaultValue:void 0,placeholder:r,ref:p,onChange:t=>e?.(t.target.value),onKeyDown:o,type:u}),s&&(0,W.jsx)(xj,{onSelect:()=>h(!m),style:{border:0,userSelect:`none`},children:m?UC:HC})]})]})}),Cj=17,wj=64;function Tj({isLoading:e,libraryItems:t,onAddToLibrary:n,onInsertLibraryItems:r,pendingElements:i,theme:a,id:o,libraryReturnUrl:s,onSelectItems:c,selectedItems:l}){let u=fU(),f=(0,H.useRef)(null),p=OA(f);(0,H.useEffect)(()=>{p>0&&f.current?.scrollTo(0,p)},[]);let{svgCache:m}=aA(),[h,_]=(0,H.useState)(null),[v,y]=(0,H.useState)(``),b=!t.length&&!i.length,x=!b&&!!v.trim(),S=(0,H.useMemo)(()=>{let e=Xk(v.trim().toLowerCase());return e?t.filter(t=>{let n=t.name||``;return n.trim()&&Xk(n.toLowerCase()).includes(e)}):[]},[t,v]),C=(0,H.useMemo)(()=>t.filter(e=>e.status!==`published`),[t]),w=(0,H.useMemo)(()=>t.filter(e=>e.status===`published`),[t]),T=(0,H.useCallback)((e,t)=>{let n=!l.includes(e),r=[...C,...w];if(n){if(t.shiftKey&&h){let t=r.findIndex(e=>e.id===h),n=r.findIndex(t=>t.id===e);if(t===-1||n===-1){c([...l,e]);return}let i=d(l),a=Math.min(t,n),o=Math.max(t,n);c(r.reduce((e,t,n)=>((n>=a&&n<=o||i.has(t.id))&&e.push(t.id),e),[]))}else c([...l,e]);_(e)}else _(null),c(l.filter(t=>t!==e))},[h,c,w,l,C]);(0,H.useEffect)(()=>{l.length||_(null)},[l]);let E=(0,H.useCallback)(e=>{let n;return n=l.includes(e)?t.filter(e=>l.includes(e.id)):t.filter(t=>t.id===e),n.map(e=>({...e,elements:g({type:`everything`,elements:e.elements,randomizeSeed:!0,preserveFrameChildrenOrder:!0}).duplicatedElements}))},[t,l]),D=(0,H.useCallback)((e,t)=>{let n={itemIds:l.includes(e)?l:[e]};t.dataTransfer.setData(M.excalidrawlibIds,JSON.stringify(n))},[l]),ee=(0,H.useCallback)(e=>e?l.includes(e):!1,[l]),te=(0,H.useCallback)(()=>{n(i)},[i,n]),O=(0,H.useCallback)(e=>{e&&r(E(e))},[E,r]),k=m.size>=(S.length?S:t).length?wj:Cj,A=(0,H.useRef)(null);(0,H.useEffect)(()=>{os(()=>{A.current?.focus()})},[]);let ne=!x&&(0,W.jsxs)(W.Fragment,{children:[!b&&(0,W.jsx)(`div`,{className:`library-menu-items-container__header`,children:K(`labels.personalLib`)}),!i.length&&!C.length?(0,W.jsxs)(`div`,{className:`library-menu-items__no-items`,children:[!w.length&&(0,W.jsx)(`div`,{className:`library-menu-items__no-items__label`,children:K(`library.noItems`)}),(0,W.jsx)(`div`,{className:`library-menu-items__no-items__hint`,children:w.length>0?K(`library.hint_emptyPrivateLibrary`):K(`library.hint_emptyLibrary`)})]}):(0,W.jsxs)(yj,{children:[i.length>0&&(0,W.jsx)(bj,{itemsRenderedPerBatch:k,items:[{id:null,elements:i}],onItemSelectToggle:T,onItemDrag:D,onClick:te,isItemSelected:ee,svgCache:m}),(0,W.jsx)(bj,{itemsRenderedPerBatch:k,items:C,onItemSelectToggle:T,onItemDrag:D,onClick:O,isItemSelected:ee,svgCache:m})]}),w.length>0&&(0,W.jsx)(`div`,{className:`library-menu-items-container__header`,style:{marginTop:`0.75rem`},children:K(`labels.excalidrawLib`)}),w.length>0&&(0,W.jsx)(yj,{children:(0,W.jsx)(bj,{itemsRenderedPerBatch:k,items:w,onItemSelectToggle:T,onItemDrag:D,onClick:O,isItemSelected:ee,svgCache:m})})]}),re=x&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`library-menu-items-container__header`,children:[K(`library.search.heading`),!e&&(0,W.jsxs)(`div`,{className:`library-menu-items-container__header__hint`,style:{cursor:`pointer`},onPointerDown:e=>e.preventDefault(),onClick:e=>{y(``)},children:[(0,W.jsx)(`kbd`,{children:`esc`}),` to clear`]})]}),S.length>0?(0,W.jsx)(yj,{children:(0,W.jsx)(bj,{itemsRenderedPerBatch:k,items:S,onItemSelectToggle:T,onItemDrag:D,onClick:O,isItemSelected:ee,svgCache:m})}):(0,W.jsxs)(`div`,{className:`library-menu-items__no-items`,children:[(0,W.jsx)(`div`,{className:`library-menu-items__no-items__hint`,children:K(`library.search.noResults`)}),(0,W.jsx)(xj,{onPointerDown:e=>e.preventDefault(),onSelect:()=>{y(``)},style:{width:`auto`,marginTop:`1rem`},children:K(`library.search.clearSearch`)})]})]});return(0,W.jsxs)(`div`,{className:`library-menu-items-container`,style:i.length||C.length||w.length?{justifyContent:`flex-start`}:{borderBottom:0},children:[(0,W.jsxs)(`div`,{className:`library-menu-items-header`,children:[!b&&(0,W.jsx)(Sj,{ref:A,type:`search`,className:U(`library-menu-items-container__search`,{hideCancelButton:u.formFactor!==`phone`}),placeholder:K(`library.search.inputPlaceholder`),value:v,onChange:e=>y(e)}),(0,W.jsx)(mj,{selectedItems:l,onSelectItems:c,className:`library-menu-dropdown-container--in-heading`})]}),(0,W.jsxs)(VA.Col,{className:`library-menu-items-container__items`,align:`start`,gap:1,style:{flex:w.length>0?1:`0 1 auto`,margin:b?`auto`:0},ref:f,children:[e&&(0,W.jsx)(`div`,{style:{position:`absolute`,top:`var(--container-padding-y)`,right:`var(--container-padding-x)`,transform:`translateY(50%)`},children:(0,W.jsx)(Ow,{})}),ne,re,b&&(0,W.jsx)(EA,{style:{padding:`16px 0`,width:`100%`},id:o,libraryReturnUrl:s,theme:a})]})]})}var Ej=yl(!1),Dj=({children:e})=>(0,W.jsx)(`div`,{className:`layer-ui__library`,children:e}),Oj=(0,H.memo)(({onInsertLibraryItems:e,pendingElements:t,onAddToLibrary:n,setAppState:r,libraryReturnUrl:i,library:a,id:o,theme:s,selectedItems:c,onSelectItems:l})=>{let[u]=Vb(cA),d=(0,H.useCallback)(e=>{(async(e,t)=>{Vw(`element`,`addToLibrary`,`ui`);for(let t of Lt)if(e.some(e=>e.type===t))return r({errorMessage:K(`errors.libraryElementTypeError.${t}`)});let i=[{status:`unpublished`,elements:e,id:Ao(),created:Date.now()},...t];n(),a.setLibrary(i).catch(()=>{r({errorMessage:K(`alerts.errorAddingToLibrary`)})})})(e,u.libraryItems)},[n,a,r,u.libraryItems]),f=(0,H.useMemo)(()=>u.libraryItems,[u]);if(u.status===`loading`&&!u.isInitialized)return(0,W.jsx)(Dj,{children:(0,W.jsx)(`div`,{className:`layer-ui__library-message`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(Ow,{size:`2em`}),(0,W.jsx)(`span`,{children:K(`labels.libraryLoadingMessage`)})]})})});let p=u.libraryItems.length>0||t.length>0;return(0,W.jsxs)(Dj,{children:[(0,W.jsx)(Tj,{isLoading:u.status===`loading`,libraryItems:f,onAddToLibrary:d,onInsertLibraryItems:e,pendingElements:t,id:o,libraryReturnUrl:i,theme:s,onSelectItems:l,selectedItems:c}),p&&(0,W.jsx)(EA,{className:`library-menu-control-buttons--at-bottom`,style:{padding:`16px 12px 0 12px`},id:o,libraryReturnUrl:i,theme:s})]})}),kj=(e,t)=>({elements:e,pending:ot(e,{selectedElementIds:t},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:t}),Aj=(e,t)=>{let n=hU(),[r,i]=(0,H.useState)(()=>kj(n,e.selectedElementIds)),a=(0,H.useRef)(new Map);return(0,H.useEffect)(()=>{for(let e of r.pending)a.current.set(e.id,e.version)},[r.pending]),(0,H.useEffect)(()=>{t.state.cursorButton===`up`&&t.state.activeTool.type===`selection`&&i(r=>{if(!Us(r.selectedElementIds,e.selectedElementIds))return a.current.clear(),kj(n,e.selectedElementIds);let i=t.scene.getNonDeletedElementsMap();for(let t of Object.keys(e.selectedElementIds)){let r=i.get(t)?.version;if(r&&r!==a.current.get(t))return kj(n,e.selectedElementIds)}return r})},[t,t.state.cursorButton,t.state.activeTool.type,e.selectedElementIds,n]),r.pending},jj=(0,H.memo)(()=>{let e=uU(),{onInsertElements:t}=e,n=dU(),r=Kw(),i=_U(),[a,o]=(0,H.useState)([]),s=(0,H.useMemo)(()=>e.library,[e.library]),c=Aj(r,e);(0,H.useEffect)(()=>{let t=e.ownerDocument,n=e.ownerWindow;return vo(t,B.KEYDOWN,r=>{if(r.key===L.ESCAPE&&r.target instanceof n.HTMLElement){let s=r.target;if(s.closest(`.${Ai.SIDEBAR}`))a.length>0?(r.stopPropagation(),o([])):s instanceof n.HTMLInputElement&&tl(s)&&!s.value&&(r.stopPropagation(),i({openSidebar:null}),e.focusContainer());else if(a.length>0){let{x:n,y:i}=e.viewport.lastPosition;t.elementFromPoint(n,i)?.closest(`.${Ai.SIDEBAR}`)&&(r.stopPropagation(),o([]))}}},{capture:!0})},[a,i,e]);let l=(0,H.useCallback)(n=>{t(mA(n)),e.focusContainer()},[t,e]),u=(0,H.useCallback)(()=>{i({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[i]);return(0,W.jsx)(Oj,{pendingElements:c,onInsertLibraryItems:l,onAddToLibrary:u,setAppState:i,libraryReturnUrl:n.libraryReturnUrl,library:s,id:e.id,theme:r.theme,selectedItems:a,onSelectItems:o})}),Mj=e=>{let{closeOnClickOutside:t=!0}=e,n=qw({className:`excalidraw-modal-container`}),r=(0,H.useMemo)(()=>n?.ownerDocument.body.classList.contains(`excalidraw-animations-disabled`)??!1,[n]);return n?(0,hl.createPortal)((0,W.jsxs)(`div`,{className:U(`Modal`,e.className,{"animations-disabled":r}),role:`dialog`,"aria-modal":`true`,onKeyDown:t=>{t.key===L.ESCAPE&&(t.preventDefault(),t.nativeEvent.stopImmediatePropagation(),t.stopPropagation(),e.onCloseRequest())},"aria-labelledby":e.labelledBy,children:[(0,W.jsx)(`div`,{className:`Modal__background`,onClick:t?e.onCloseRequest:void 0}),(0,W.jsx)(`div`,{className:`Modal__content`,style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),n):null};function Nj(e){if(e&&typeof e==`number`)return e;switch(e){case`small`:return 550;case`wide`:return 1024;default:return 800}}var Pj=e=>{let[t,n]=Zk(),[r]=(0,H.useState)(document.activeElement),{id:i}=mU(),a=fU().formFactor===`phone`;(0,H.useEffect)(()=>{if(!t)return;let n=fr(t);setTimeout(()=>{n.length>0&&e.autofocus!==!1&&(n[1]||n[0]).focus()});let r=e=>{if(e.key===L.TAB){let n=fr(t),{activeElement:r}=document,i=n.findIndex(e=>e===r);i===0&&e.shiftKey?(n[n.length-1].focus(),e.preventDefault()):i===n.length-1&&!e.shiftKey&&(n[0].focus(),e.preventDefault())}};return t.addEventListener(`keydown`,r),()=>t.removeEventListener(`keydown`,r)},[t,e.autofocus]);let o=_U(),s=Hb(Ej),c=()=>{o({openMenu:null}),s(!1),r.focus(),e.onCloseRequest()};return(0,W.jsx)(Mj,{className:U(`Dialog`,e.className,{"Dialog--fullscreen":a}),labelledBy:`dialog-title`,maxWidth:Nj(e.size),onCloseRequest:c,closeOnClickOutside:e.closeOnClickOutside,children:(0,W.jsxs)(nT,{ref:n,children:[e.title&&(0,W.jsx)(`h2`,{id:`${i}-dialog-title`,className:`Dialog__title`,children:(0,W.jsx)(`span`,{className:`Dialog__titleContent`,children:e.title})}),a&&(0,W.jsx)(`button`,{className:`Dialog__close`,onClick:c,title:K(`buttons.close`),"aria-label":K(`buttons.close`),type:`button`,children:ES}),(0,W.jsx)(`div`,{className:`Dialog__content`,children:e.children})]})})},Fj=X({name:`viewMode`,label:`labels.viewMode`,icon:HC,viewMode:!0,trackEvent:{category:`canvas`,predicate:e=>!e.viewModeEnabled},perform(e,t){return{appState:{...t,viewModeEnabled:!this.checked(t)},captureUpdate:N.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,t,n,r)=>typeof n.viewModeEnabled>`u`&&r.isInteractionEnabled(),keyTest:e=>!e[L.CTRL_OR_CMD]&&e.altKey&&e.code===xt.R}),Ij=(e,t)=>{let n=t[0]?.type||null;for(let e of t)if(e.type!==n){n=null;break}return dr(e.activeTool.type)&&n!==`image`&&n!==`frame`&&n!==`magicframe`||t.some(e=>dr(e.type))},Lj=(e,t,n)=>Ve(e.activeTool.type)||t.some(e=>Ve(Yn(e,`backgroundColor`,n).type)),Rj=(e,t,n,r)=>{let i=e.activeTool.type,a=e=>e(i)||t.some(t=>e(t.type)),o=t.length===1,s=t.length===2&&(xr(t[0])||xr(t[1])),c=!!(e.editingTextElement||e.newElement),l=t.length>0;return{hasSelection:l,showExtraActions:l&&!c,strokeColor:Ij(e,t),backgroundColor:Lj(e,t,n),fill:i===`bucketfill`||Bt(i)&&!Ke(e.currentItemBackgroundColor)||t.some(e=>Bt(e.type)&&!Ke(e.backgroundColor)),strokeWidth:a(rr),freedrawMode:a(Qo),strokeStyle:a(fo),sloppiness:a(Ye),roundness:a(er),arrowType:a(bn),arrowheads:a(_e),text:i===`text`||t.some(z),textAlign:i===`text`||ha(t,n),verticalAlign:vn(t,n),opacity:i!==`autoshape`||l,layers:i!==`freedraw`&&i!==`autoshape`&&!t.some(e=>e.type===`freedraw`)||ot(n,e).some(e=>e.type===`freedraw`),align:!s&&SO(e,r),distribute:t.length>2,link:o||s,linkSingleOnly:o,cropEditor:!e.croppingElementId&&o&&La(t[0]),lineEditor:!e.selectedLinearElement?.isEditing&&o&&ro(t[0])&&!Br(t[0])}},zj=U([Ai.SHAPE_ACTIONS_THEME_SCOPE,`properties-content`]),Bj=({renderAction:e})=>(0,W.jsxs)(`fieldset`,{children:[(0,W.jsx)(`legend`,{children:K(`labels.layers`)}),(0,W.jsxs)(`div`,{className:`buttonList`,children:[e(`sendToBack`),e(`sendBackward`),e(`bringForward`),e(`bringToFront`)]})]}),Vj=({renderAction:e,showDistribute:t})=>{let n=document.documentElement.getAttribute(`dir`)===`rtl`;return(0,W.jsxs)(`fieldset`,{children:[(0,W.jsx)(`legend`,{children:K(`labels.align`)}),(0,W.jsxs)(`div`,{className:`buttonList`,children:[n?(0,W.jsxs)(W.Fragment,{children:[e(`alignRight`),e(`alignHorizontallyCentered`),e(`alignLeft`)]}):(0,W.jsxs)(W.Fragment,{children:[e(`alignLeft`),e(`alignHorizontallyCentered`),e(`alignRight`)]}),t&&e(`distributeHorizontally`),(0,W.jsx)(`div`,{style:{flexBasis:`100%`,height:0}}),(0,W.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:`.5rem`,marginTop:`-0.5rem`},children:[e(`alignTop`),e(`alignVerticallyCentered`),e(`alignBottom`),t&&e(`distributeVertically`)]})]})]})},Hj=({appState:e,elementsMap:t,renderAction:n,app:r})=>{let i=Rj(e,as(t,e),t,r);return e.activeTool.type===`bucketfill`?(0,W.jsxs)(`div`,{className:`selected-shape-actions`,children:[(0,W.jsx)(`div`,{children:n(`changeBucketFillBackgroundColor`)}),n(`changeFillStyle`),n(`changeOpacity`)]}):(0,W.jsxs)(`div`,{className:`selected-shape-actions`,children:[(0,W.jsx)(`div`,{children:i.strokeColor&&n(`changeStrokeColor`)}),i.backgroundColor&&(0,W.jsx)(`div`,{children:n(`changeBackgroundColor`)}),i.fill&&n(`changeFillStyle`),i.strokeWidth&&n(`changeStrokeWidth`),i.strokeStyle&&(0,W.jsx)(W.Fragment,{children:n(`changeStrokeStyle`)}),i.freedrawMode&&n(`changeFreedrawMode`),i.sloppiness&&(0,W.jsx)(W.Fragment,{children:n(`changeSloppiness`)}),i.roundness&&(0,W.jsx)(W.Fragment,{children:n(`changeRoundness`)}),i.arrowType&&(0,W.jsx)(W.Fragment,{children:n(`changeArrowType`)}),i.text&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`fieldset`,{children:n(`changeFontFamily`)}),n(`changeFontSize`),i.textAlign&&n(`changeTextAlign`)]}),i.verticalAlign&&n(`changeVerticalAlign`),i.arrowheads&&(0,W.jsx)(W.Fragment,{children:n(`changeArrowhead`)}),i.opacity&&n(`changeOpacity`),i.layers&&(0,W.jsx)(Bj,{renderAction:n}),i.align&&(0,W.jsx)(Vj,{renderAction:n,showDistribute:i.distribute}),i.showExtraActions&&(0,W.jsxs)(`fieldset`,{children:[(0,W.jsx)(`legend`,{children:K(`labels.actions`)}),(0,W.jsxs)(`div`,{className:`buttonList`,children:[n(`duplicateSelection`),n(`deleteSelectedElements`),n(`group`),n(`ungroup`),i.link&&n(`hyperlink`),i.cropEditor&&n(`cropEditor`),i.lineEditor&&n(`toggleLinearEditor`)]})]})]})},Uj=({appState:e,renderAction:t,setAppState:n,predicates:r,container:i})=>{let a=r.hasSelection||e.activeTool.type!==`selection`&&e.activeTool.type!==`eraser`&&e.activeTool.type!==`hand`&&e.activeTool.type!==`laser`&&e.activeTool.type!==`lasso`,o=e.openPopup===`compactStrokeStyles`;return a?(0,W.jsx)(`div`,{className:`compact-action-item`,children:(0,W.jsxs)(Ty,{open:o,onOpenChange:e=>{n(e?{openPopup:`compactStrokeStyles`}:{openPopup:null})},children:[(0,W.jsx)(Ey,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,className:U(`compact-action-button properties-trigger`,{active:o}),title:K(`labels.stroke`),onClick:e=>{e.preventDefault(),e.stopPropagation(),n({openPopup:o?null:`compactStrokeStyles`})},children:bw})}),o&&(0,W.jsx)(rT,{className:zj,container:i,style:{maxWidth:`13rem`},onClose:()=>{},children:(0,W.jsxs)(`div`,{className:`selected-shape-actions`,children:[r.fill&&t(`changeFillStyle`),r.strokeWidth&&t(`changeStrokeWidth`),r.freedrawMode&&t(`changeFreedrawMode`),r.strokeStyle&&(0,W.jsx)(W.Fragment,{children:t(`changeStrokeStyle`)}),r.sloppiness&&(0,W.jsx)(W.Fragment,{children:t(`changeSloppiness`)}),r.roundness&&t(`changeRoundness`),r.opacity&&t(`changeOpacity`)]})})]})}):null},Wj=({appState:e,renderAction:t,setAppState:n,targetElements:r,predicates:i,container:a,app:o})=>{if(!i.arrowType)return null;let s=e.openPopup===`compactArrowProperties`;return(0,W.jsx)(`div`,{className:`compact-action-item`,children:(0,W.jsxs)(Ty,{open:s,onOpenChange:e=>{n(e?{openPopup:`compactArrowProperties`}:{openPopup:null})},children:[(0,W.jsx)(Ey,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,className:U(`compact-action-button properties-trigger`,{active:s}),title:K(`labels.arrowtypes`),onClick:e=>{e.preventDefault(),e.stopPropagation(),n({openPopup:s?null:`compactArrowProperties`})},children:(()=>{let t=wE(r,o,e=>ye(e)?e.elbowed?`elbow`:e.roundness?`round`:`sharp`:null,e=>ye(e),t=>t?null:e.currentItemArrowType);return t===`elbow`?pw:t===`round`?mw:fw})()})}),s&&(0,W.jsx)(rT,{container:a,className:`properties-content`,style:{maxWidth:`13rem`},onClose:()=>{},children:t(`changeArrowProperties`)})]})})},Gj=({appState:e,renderAction:t,setAppState:n,predicates:r,container:i})=>{let{saveCaretPosition:a,restoreCaretPosition:o}=cT(i?.ownerDocument),s=e.openPopup===`compactTextProperties`;return(0,W.jsx)(`div`,{className:`compact-action-item`,children:(0,W.jsxs)(Ty,{open:s,onOpenChange:t=>{t?(e.editingTextElement&&a(),n({openPopup:`compactTextProperties`})):(n({openPopup:null}),e.editingTextElement&&o())},children:[(0,W.jsx)(Ey,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,className:U(`compact-action-button properties-trigger`,{active:s}),title:K(`labels.textAlign`),onClick:t=>{t.preventDefault(),t.stopPropagation(),s?n({openPopup:null}):(e.editingTextElement&&a(),n({openPopup:`compactTextProperties`}))},children:Ax})}),e.openPopup===`compactTextProperties`&&(0,W.jsx)(rT,{className:zj,container:i,style:{maxWidth:`13rem`},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&o()},children:(0,W.jsxs)(`div`,{className:`selected-shape-actions`,children:[r.text&&t(`changeFontSize`),r.textAlign&&t(`changeTextAlign`),r.verticalAlign&&t(`changeVerticalAlign`)]})})]})})},Kj=({appState:e,renderAction:t,predicates:n,setAppState:r,container:i,showDuplicate:a,showDelete:o})=>{let s=e.openPopup===`compactOtherProperties`;return n.showExtraActions?(0,W.jsx)(`div`,{className:`compact-action-item`,children:(0,W.jsxs)(Ty,{open:s,onOpenChange:e=>{r(e?{openPopup:`compactOtherProperties`}:{openPopup:null})},children:[(0,W.jsx)(Ey,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,className:U(`compact-action-button properties-trigger`,{active:s}),title:K(`labels.actions`),onClick:e=>{e.preventDefault(),e.stopPropagation(),r({openPopup:s?null:`compactOtherProperties`})},children:dx})}),s&&(0,W.jsx)(rT,{className:zj,container:i,style:{maxWidth:`12rem`,justifyContent:`center`,alignItems:`center`},onClose:()=>{},children:(0,W.jsxs)(`div`,{className:`selected-shape-actions`,children:[n.layers&&(0,W.jsx)(Bj,{renderAction:t}),n.align&&(0,W.jsx)(Vj,{renderAction:t,showDistribute:n.distribute}),(0,W.jsxs)(`fieldset`,{children:[(0,W.jsx)(`legend`,{children:K(`labels.actions`)}),(0,W.jsxs)(`div`,{className:`buttonList`,children:[t(`group`),t(`ungroup`),n.linkSingleOnly&&t(`hyperlink`),n.cropEditor&&t(`cropEditor`),a&&t(`duplicateSelection`),o&&t(`deleteSelectedElements`)]})]})]})})]})}):null},qj=({renderAction:e,predicates:t})=>t.lineEditor?(0,W.jsx)(`div`,{className:`compact-action-item`,children:e(`toggleLinearEditor`)}):null,Jj=({appState:e,elementsMap:t,renderAction:n,app:r,setAppState:i})=>{let a=as(t,e),o=Rj(e,a,t,r),{container:s}=mU();return(0,W.jsxs)(`div`,{className:`compact-shape-actions`,children:[o.strokeColor&&(0,W.jsx)(`div`,{className:U(`compact-action-item`),children:n(`changeStrokeColor`)}),o.backgroundColor&&(0,W.jsx)(`div`,{className:`compact-action-item`,children:n(e.activeTool.type===`bucketfill`?`changeBucketFillBackgroundColor`:`changeBackgroundColor`)}),o.freedrawMode&&(0,W.jsx)(`div`,{className:`compact-action-item`,children:n(`changeFreedrawMode`,{cycle:!0})}),(0,W.jsx)(Uj,{appState:e,renderAction:n,setAppState:i,predicates:o,container:s}),(0,W.jsx)(Wj,{appState:e,renderAction:n,setAppState:i,targetElements:a,predicates:o,container:s,app:r}),o.lineEditor&&(0,W.jsx)(`div`,{className:`compact-action-item`,children:n(`toggleLinearEditor`)}),o.text&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`compact-action-item`,children:n(`changeFontFamily`)}),(0,W.jsx)(Gj,{appState:e,renderAction:n,setAppState:i,predicates:o,container:s})]}),o.showExtraActions&&(0,W.jsx)(`div`,{className:`compact-action-item`,children:n(`duplicateSelection`)}),o.showExtraActions&&(0,W.jsx)(`div`,{className:`compact-action-item`,children:n(`deleteSelectedElements`)}),(0,W.jsx)(Kj,{appState:e,renderAction:n,predicates:o,setAppState:i,container:s})]})},Yj=({appState:e,elementsMap:t,renderAction:n,app:r,setAppState:i})=>{let a=as(t,e),o=Rj(e,a,t,r),{container:s}=mU(),c=(0,H.useRef)(null),l=c.current?.getBoundingClientRect()?.width??0,u=l>=374,d=l>=412;return(0,W.jsxs)(nT,{className:`compact-shape-actions mobile-shape-actions`,style:{flexDirection:`row`,boxShadow:`none`,padding:0,zIndex:2,backgroundColor:`transparent`,height:43.2,marginBottom:4,alignItems:`center`,gap:6,pointerEvents:`none`},ref:c,children:[(0,W.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,gap:6,flex:1},children:[o.strokeColor&&(0,W.jsx)(`div`,{className:U(`compact-action-item`),children:n(`changeStrokeColor`)}),o.backgroundColor&&(0,W.jsx)(`div`,{className:`compact-action-item`,children:n(e.activeTool.type===`bucketfill`?`changeBucketFillBackgroundColor`:`changeBackgroundColor`)}),(0,W.jsx)(Uj,{appState:e,renderAction:n,setAppState:i,predicates:o,container:s}),(0,W.jsx)(Wj,{appState:e,renderAction:n,setAppState:i,targetElements:a,predicates:o,container:s,app:r}),(0,W.jsx)(qj,{renderAction:n,predicates:o}),o.text&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`compact-action-item`,children:n(`changeFontFamily`)}),(0,W.jsx)(Gj,{appState:e,renderAction:n,setAppState:i,predicates:o,container:s})]}),(0,W.jsx)(Kj,{appState:e,renderAction:n,predicates:o,setAppState:i,container:s,showDuplicate:!d,showDelete:!u})]}),(0,W.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,gap:6},children:[(0,W.jsx)(`div`,{className:`compact-action-item`,children:n(`undo`)}),(0,W.jsx)(`div`,{className:`compact-action-item`,children:n(`redo`)}),d&&(0,W.jsx)(`div`,{className:`compact-action-item`,children:n(`duplicateSelection`)}),u&&(0,W.jsx)(`div`,{className:`compact-action-item`,children:n(`deleteSelectedElements`)})]})]})},Xj=({renderAction:e})=>(0,W.jsx)(VA.Col,{gap:1,className:Ai.ZOOM_ACTIONS,children:(0,W.jsxs)(VA.Row,{align:`center`,children:[e(`zoomOut`),e(`resetZoom`),e(`zoomIn`)]})}),Zj=({renderAction:e,className:t})=>(0,W.jsxs)(`div`,{className:`undo-redo-buttons ${t}`,children:[(0,W.jsx)(`div`,{className:`undo-button-container`,children:(0,W.jsx)(IE,{label:K(`buttons.undo`),children:e(`undo`)})}),(0,W.jsx)(`div`,{className:`redo-button-container`,children:(0,W.jsxs)(IE,{label:K(`buttons.redo`),children:[` `,e(`redo`)]})})]}),Qj=({actionManager:e,showExitZenModeBtn:t})=>(0,W.jsx)(`button`,{type:`button`,className:U(`disable-zen-mode`,{"disable-zen-mode--visible":t}),onClick:()=>e.executeAction(LO),children:K(`buttons.exitZenMode`)}),$j=({actionManager:e})=>(0,W.jsx)(`button`,{type:`button`,className:`disable-view-mode`,onClick:()=>e.executeAction(Fj),children:Sw}),eM=e=>{let t=(0,H.useRef)({userFn:e});return t.current.userFn=e,t.current.stableFn||(t.current.stableFn=(...e)=>t.current.userFn(...e)),t.current.stableFn},tM=yl(null),nM=()=>{let[e,t]=Vb(tM),n=vU();return e&&e===`clearCanvas`?(0,W.jsx)(AA,{onConfirm:()=>{n.executeAction(VE),t(null)},onCancel:()=>t(null),title:K(`clearCanvasDialog.title`),children:(0,W.jsxs)(`p`,{className:`clear-canvas__content`,children:[` `,K(`alerts.clearReset`)]})}):null},rM={},iM=yl(null),aM={app:`App`,export:`Export`,tools:`Tools`,editor:`Editor`,elements:`Elements`,links:`Links`,library:`Library`},oM=e=>{switch(e){case aM.app:return 1;case aM.export:return 2;case aM.editor:return 3;case aM.tools:return 4;case aM.elements:return 5;case aM.links:return 6;default:return 10}},sM=({shortcut:e,className:t,children:n})=>{let r=e.replace(`++`,`+$`).split(`+`);return(0,W.jsxs)(`div`,{className:U(`shortcut`,t),children:[r.map((e,t)=>(0,W.jsx)(`div`,{className:`shortcut-wrapper`,children:(0,W.jsx)(`div`,{className:`shortcut-key`,children:e===`$`?`+`:e})},e)),(0,W.jsx)(`div`,{className:`shortcut-desc`,children:n})]})},cM=e=>!e.altKey&&e[L.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===L.P||e.key===L.SLASH),lM=Object.assign(e=>{let t=Kw(),n=_U();return(0,H.useEffect)(()=>{let e=e=>{cM(e)&&(e.preventDefault(),e.stopPropagation(),n(e=>{let t=e.openDialog?.name===`commandPalette`?null:{name:`commandPalette`};return t&&Vw(`command_palette`,`open`,`shortcut`),{openDialog:t}}))};return window.addEventListener(B.KEYDOWN,e,{capture:!0}),()=>window.removeEventListener(B.KEYDOWN,e,{capture:!0})},[n]),t.openDialog?.name===`commandPalette`?(0,W.jsx)(uM,{...e}):null},{defaultItems:rM});function uM({customCommandPaletteItems:e}){let t=uU(),n=Kw(),r=_U(),i=dU(),a=vU(),[o,s]=Vb(iM),[c,l]=(0,H.useState)(null),u=(0,H.useRef)(null),f=Yw({uiAppState:n,customCommandPaletteItems:e,appProps:i}),[p]=Vb(cA),m=(0,H.useMemo)(()=>p.libraryItems?.filter(e=>!!e.name).map(e=>({label:e.name,icon:(0,W.jsx)(dM,{id:e.id,elements:e.elements}),category:`Library`,order:oM(`Library`),haystack:Xk(e.name),perform:()=>{t.onInsertElements(mA([e]))}}))||[],[t,p.libraryItems]);(0,H.useEffect)(()=>{let{uiAppState:e,customCommandPaletteItems:n,appProps:i}=f,c=n=>{let r=``;return n.label&&(r=typeof n.label==`function`?K(n.label(t.scene.getNonDeletedElements(),e,t)):K(n.label)),r},u=n=>typeof n.icon==`function`?n.icon(e,t.scene.getNonDeletedElements()):n.icon,p=[],h=(e,t,n)=>{let r={label:c(e),icon:u(e),category:t,shortcut:Kk(e.name),keywords:e.keywords,predicate:e.predicate,viewMode:e.viewMode,perform:()=>{a.executeAction(e,`commandPalette`)}};return n?n(r,e):r};if(e&&t.scene&&a){let f=[a.actions.group,a.actions.ungroup,a.actions.cut,a.actions.copy,a.actions.deleteSelectedElements,a.actions.wrapSelectionInFrame,a.actions.copyStyles,a.actions.pasteStyles,a.actions.bringToFront,a.actions.bringForward,a.actions.sendBackward,a.actions.sendToBack,a.actions.alignTop,a.actions.alignBottom,a.actions.alignLeft,a.actions.alignRight,a.actions.alignVerticallyCentered,a.actions.alignHorizontallyCentered,a.actions.duplicateSelection,a.actions.flipHorizontal,a.actions.flipVertical,a.actions.zoomToFitSelection,a.actions.zoomToFitSelectionInViewport,a.actions.increaseFontSize,a.actions.decreaseFontSize,a.actions.toggleLinearEditor,a.actions.cropEditor,a.actions.togglePolygon,ck,Uk,Wk].map(e=>h(e,aM.elements,(e,t)=>({...e,predicate:t.predicate?t.predicate:(e,t,n,r)=>ot(e,t).length>0}))),g=[a.actions.undo,a.actions.redo,a.actions.zoomIn,a.actions.zoomOut,a.actions.resetZoom,a.actions.zoomToFit,a.actions.zenMode,a.actions.viewMode,a.actions.gridMode,a.actions.objectsSnapMode,a.actions.toggleShortcuts,a.actions.selectAll,a.actions.toggleElementLock,a.actions.unlockAllElements,a.actions.stats].map(e=>h(e,aM.editor)),_=[a.actions.saveToActiveFile,a.actions.saveFileToDisk,a.actions.copyAsPng,a.actions.copyAsSvg].map(e=>h(e,aM.export));p=[...f,...g,{label:c(VE),icon:u(VE),shortcut:Kk(VE.name),category:aM.editor,keywords:[`delete`,`destroy`],viewMode:!1,perform:()=>{Kb.set(tM,`clearCanvas`)}},{label:K(`buttons.exportImage`),category:aM.export,icon:rS,shortcut:Kk(`imageExport`),keywords:[`export`,`image`,`png`,`jpeg`,`svg`,`clipboard`,`picture`],perform:()=>{r({openDialog:{name:`imageExport`}})}},..._];let v=[h(KE,aM.app),{label:K(`toolBar.library`),category:aM.app,icon:cx,viewMode:!1,perform:()=>{e.openSidebar?r({openSidebar:null}):r({openSidebar:{name:Gi.name,tab:Gi.defaultTab}})}},{label:K(`search.title`),category:aM.app,icon:KC,viewMode:!0,perform:()=>{a.executeAction(LN)}},{label:K(`labels.shapeSwitch`),category:aM.elements,icon:ZC,perform:()=>{a.executeAction(Hk)}},{label:K(`labels.changeStroke`),keywords:[`color`,`outline`],category:aM.elements,icon:tS,viewMode:!1,predicate:(e,t)=>{let n=ot(e,t);return n.length>0&&Ij(t,n)},perform:()=>{r(e=>({openPopup:`elementStroke`}))}},{label:K(`labels.changeBackground`),keywords:[`color`,`fill`],icon:tS,category:aM.elements,viewMode:!1,predicate:(e,t)=>{let n=ot(e,t);return n.length>0&&Lj(t,n,d(e))},perform:()=>{r(e=>({openPopup:`elementBackground`}))}},{label:K(`labels.canvasBackground`),keywords:[`color`],icon:tS,category:aM.editor,viewMode:!1,perform:()=>{r(e=>({openMenu:e.openMenu===`canvas`?null:`canvas`,openPopup:`canvasBackground`}))}},...Object.keys(JE).reduce((e,n)=>{let r=JE[n];if(i.UIOptions.tools?.[n]===!1)return e;let a=XE(n)||r.numericKey,o={label:K(`toolBar.${n}`),category:aM.tools,shortcut:a,icon:r.icon,keywords:[`toolbar`],viewMode:!1,perform:()=>{t.setActiveTool({type:n},{toggle:!1})}};return e.push(o),e},[]),{label:K(`toolBar.lock`),category:aM.tools,icon:e.activeTool.locked?hx:mx,shortcut:L.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{t.toggleLock()}},{label:`${K(`labels.textToDiagram`)}...`,category:aM.tools,icon:GC,viewMode:!1,predicate:i.aiEnabled,perform:()=>{r(e=>({...e,openDialog:{name:`ttd`,tab:`text-to-diagram`}}))}},{label:`${K(`toolBar.mermaidToExcalidraw`)}...`,category:aM.tools,icon:PC,viewMode:!1,predicate:i.aiEnabled,perform:()=>{r(e=>({...e,openDialog:{name:`ttd`,tab:`mermaid`}}))}}],y=[...p,...v,...n||[]].map(e=>({...e,icon:e.icon||ZC,order:e.order??oM(e.category),haystack:`${Xk(e.label.toLocaleLowerCase())} ${e.keywords?.join(` `)||``}`}));l(y),s([...y,...m].find(e=>e.label===o?.label)??null)}},[f,t,a,l,o?.label,s,r,m]);let[h,g]=(0,H.useState)(``),[_,v]=(0,H.useState)(null),[y,b]=(0,H.useState)({}),x=e=>{r({openDialog:null},e),g(``)},S=(e,t)=>{n.openDialog?.name===`commandPalette`&&(t.stopPropagation(),t.preventDefault(),document.body.classList.add(`excalidraw-animations-disabled`),x(()=>{e.perform({actionManager:a,event:t}),s(e),requestAnimationFrame(()=>{document.body.classList.remove(`excalidraw-animations-disabled`)})}))},C=eM(e=>e.viewMode===!1&&n.viewModeEnabled?!1:typeof e.predicate==`function`?e.predicate(t.scene.getNonDeletedElements(),n,i,t):e.predicate===void 0||e.predicate),w=eM(e=>{let t=tl(e.target)||cM(e)||e.key===L.ESCAPE;if(t&&e.key!==L.ARROW_UP&&e.key!==L.ARROW_DOWN&&e.key!==L.ENTER)return;let n=Object.values(y).flat(),r=o&&!h&&C(o);if(e.key===L.ARROW_UP){e.preventDefault();let t=n.findIndex(e=>e.label===_?.label);if(r){if(t===0){v(o);return}if(_===o){let e=n[n.length-1];e&&v(e);return}}let i;i=t===-1||t===0?n.length-1:(t-1)%n.length;let a=n[i];a&&v(a);return}if(e.key===L.ARROW_DOWN){e.preventDefault();let t=n.findIndex(e=>e.label===_?.label);if(r){if(!_||t===n.length-1){v(o);return}if(_===o){let e=n[0];e&&v(e);return}}let i=n[(t+1)%n.length];i&&v(i);return}if(e.key===L.ENTER&&_&&setTimeout(()=>{S(_,e)}),!t){if(e.stopPropagation(),/^[a-zA-Z0-9]$/.test(e.key)){u?.current?.focus();return}e.preventDefault()}});return(0,H.useEffect)(()=>(window.addEventListener(B.KEYDOWN,w,{capture:!0}),()=>window.removeEventListener(B.KEYDOWN,w,{capture:!0})),[w]),(0,H.useEffect)(()=>{if(!c)return;let e=e=>{let t={};for(let n of e)t[n.category]?t[n.category].push(n):t[n.category]=[n];return t},t=h?.length>1?[...c.filter(C).sort((e,t)=>e.order-t.order),...m]:c.filter(C).sort((e,t)=>e.order-t.order),n=!h&&o&&C(o);if(!h){b(e(n?t.filter(e=>e.label!==o?.label):t)),v(n?o:t[0]||null);return}let r=Xk(h.toLocaleLowerCase().replace(/[<>_| -]/g,``));t=Xy.default.filter(r,t,{extract:e=>e.haystack??``}).sort((e,t)=>t.score-e.score).map(e=>e.original),b(e(t)),v(t[0]??null)},[h,c,C,o,m]),(0,W.jsxs)(Pj,{onCloseRequest:()=>x(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:`command-palette-dialog`,children:[(0,W.jsx)(Sj,{value:h,placeholder:K(`commandPalette.search.placeholder`),onChange:e=>{g(e)},selectOnRender:!0,ref:u}),t.editorInterface.formFactor!==`phone`&&(0,W.jsxs)(`div`,{className:`shortcuts-wrapper`,children:[(0,W.jsx)(sM,{shortcut:`↑↓`,children:K(`commandPalette.shortcuts.select`)}),(0,W.jsx)(sM,{shortcut:`↵`,children:K(`commandPalette.shortcuts.confirm`)}),(0,W.jsx)(sM,{shortcut:Z(`Esc`),children:K(`commandPalette.shortcuts.close`)})]}),(0,W.jsxs)(`div`,{className:`commands`,children:[o&&!h&&(0,W.jsxs)(`div`,{className:`command-category`,children:[(0,W.jsxs)(`div`,{className:`command-category-title`,children:[K(`commandPalette.recents`),(0,W.jsx)(`div`,{className:`icon`,style:{marginLeft:`6px`},children:qC})]}),(0,W.jsx)(fM,{command:o,isSelected:o.label===_?.label,onClick:e=>S(o,e),disabled:!C(o),onMouseMove:()=>v(o),showShortcut:t.editorInterface.formFactor!==`phone`,appState:n})]}),Object.keys(y).length>0?Object.keys(y).map((e,r)=>(0,W.jsxs)(`div`,{className:`command-category`,children:[(0,W.jsx)(`div`,{className:`command-category-title`,children:e}),y[e].map(r=>(0,W.jsx)(fM,{command:r,isSelected:r.label===_?.label,onClick:e=>S(r,e),onMouseMove:()=>v(r),showShortcut:t.editorInterface.formFactor!==`phone`,appState:n,size:e===`Library`?`large`:`small`},r.label))]},e)):c?(0,W.jsxs)(`div`,{className:`no-match`,children:[(0,W.jsx)(`div`,{className:`icon`,children:KC}),` `,K(`commandPalette.search.noMatch`)]}):null]})]})}var dM=({id:e,elements:t})=>{let n=(0,H.useRef)(null),{svgCache:r}=aA();return iA(e,t,r,n),(0,W.jsx)(`div`,{className:`library-item-icon`,ref:n})},fM=({command:e,isSelected:t,disabled:n,onMouseMove:r,onClick:i,showShortcut:a,appState:o,size:s=`small`})=>{let c=()=>{};return(0,W.jsxs)(`div`,{className:U(`command-item`,{"item-selected":t,"item-disabled":n,"command-item-large":s===`large`}),ref:e=>{t&&!n&&e?.scrollIntoView?.({block:`nearest`})},onClick:n?c:i,onMouseMove:n?c:r,title:n?K(`commandPalette.itemNotAvailable`):``,children:[(0,W.jsxs)(`div`,{className:`name`,children:[e.icon&&(0,W.jsx)(iE,{className:`icon`,size:`var(--icon-size, 1rem)`,icon:typeof e.icon==`function`?e.icon(o,[]):e.icon}),(0,W.jsx)(GT,{children:e.label})]}),a&&e.shortcut&&(0,W.jsx)(sM,{shortcut:e.shortcut})]})};function pM([e,t,n],[r,i,a]){return[e+r,t+i,n+a]}function mM([e,t,n],[r,i,a]){return[e-r,t-i,n-a]}function hM([e,t,n],r){return[e*r,t*r,n*r]}function gM([e,t,n]){return[e/Math.sqrt(e**2+t**2),t/Math.sqrt(e**2+t**2),n]}function _M([e,t,n],r){return[Math.cos(r)*e-Math.sin(r)*t,Math.sin(r)*e+Math.cos(r)*t,n]}function vM(e,t,n){return pM(e,hM(mM(t,e),n))}function yM(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 bM(e){return Math.atan2(Math.sin(e),Math.cos(e))}function xM([e,t]){return Math.sqrt(e**2+t**2)}function SM([e,t],[n,r]){return Math.sqrt((n-e)**2+(r-t)**2)}function CM(e){if(e.length<2)return 0;let t=0;for(let n=1;n<=e.length-1;n++)t+=SM(e[n-1],e[n]);return t+=SM(e[e.length-2],e[e.length-1]),t}var wM=(e,t,n)=>Math.max(t,Math.min(n,e));function TM(e,t,n){let r=SM(t,n);if(r===0)return SM(e,t);let i=wM(((e[0]-t[0])*(n[0]-t[0])+(e[1]-t[1])*(n[1]-t[1]))/r**2,0,1);return SM([t[0]+i*(n[0]-t[0]),t[1]+i*(n[1]-t[1]),e[2]],e)}function EM(e,t){if(t===0||e.length<=2)return e;let n=e[0],r=e[e.length-1],[i,a]=e.reduce(([e,t],i,a)=>{let o=TM(i,n,r);return o>e?[o,a]:[e,t]},[0,-1]);if(i>=t){let i=e[a];return[...EM([n,...e.slice(1,a),i],t).slice(0,-1),i,...EM([i,...e.slice(a,-1),r],t).slice(1)]}return[n,r]}var DM=class e{constructor(t){V(this,`options`),V(this,`originalPoints`,[]),V(this,`stablePoints`,[]),V(this,`tailPoints`,[]),V(this,`isFresh`,!0),this.options=Object.assign({},e.defaults,t)}get lastPoint(){return this.tailPoints[this.tailPoints.length-1]??this.stablePoints[this.stablePoints.length-1]}addPoint(t){let 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=vM(this.lastPoint,t,1-this.options.streamline)),this.tailPoints.push(t),CM(this.tailPoints)>e.constants.maxTailLength&&this.stabilizeTail()}}close(){this.stabilizeTail()}stabilizeTail(){if(this.options.simplify>0&&this.options.simplifyPhase===`tail`)throw Error(`Not implemented yet`);this.stablePoints.push(...this.tailPoints),this.tailPoints=[]}getSize(e,t,n,r,i){return(e??this.options.size)*this.options.sizeMapping({pressure:t,runningLength:i,currentIndex:n,totalLength:r})}getStrokeOutline(t){if(this.isFresh)return[];let n=[...this.stablePoints,...this.tailPoints];this.options.simplify>0&&this.options.simplifyPhase===`input`&&(n=EM(n,this.options.simplify));let r=n.length;if(r===0)return[];if(r===1){let e=n[0],i=this.getSize(t,e[2],0,r,0);if(i<.5)return[];let a=[];for(let t=0;t<=Math.PI*2;t+=Math.PI/16)a.push(pM(e,hM(_M([1,0,0],t),i)));return a.push(pM(e,hM([1,0,0],this.getSize(t,e[2],0,r,0)))),a}if(r===2){let e=n[0],i=n[1],a=this.getSize(t,e[2],0,r,0),o=this.getSize(t,i[2],0,r,0);if(a<.5||o<.5)return[];let s=[],c=yM(e,[e[0],e[1]-100,e[2]],i);for(let t=c;t<=Math.PI+c;t+=Math.PI/16)s.push(pM(e,hM(_M([1,0,0],t),a)));for(let e=Math.PI+c;e<=Math.PI*2+c;e+=Math.PI/16)s.push(pM(i,hM(_M([1,0,0],e),o)));return s.push(s[0]),s}let i=[],a=[],o=0,s=0,c=0,l=0;for(let u=1;u<r-1;u++){let d=n[u-1],f=n[u],p=n[u+1],m=f[2],h=SM(d,f);l+=h,o=s+(h-s)*.2;let g=this.getSize(t,m,u,r,l);if(g===0){c=u+1;continue}let _=gM(mM(d,f)),v=gM(mM(p,f)),y=_M(_,Math.PI/2),b=_M(_,-Math.PI/2),x=_M(v,Math.PI/2),S=_M(v,-Math.PI/2),C=pM(f,hM(y,g)),w=pM(f,hM(b,g)),T=pM(f,hM(x,g)),E=pM(f,hM(S,g)),D=pM(y,S),ee=pM(b,x),te=pM(f,hM(xM(D)===0?_:gM(D),g)),O=pM(f,hM(xM(ee)===0?v:gM(ee),g)),k=bM(yM(f,d,p)),A=e.constants.cornerDetectionMaxAngle/180*Math.PI*e.constants.cornerDetectionVariance(o);if(Math.abs(k)<A){let e=Math.abs(bM(Math.PI-k));if(e===0)continue;if(k<0){a.push(w,O);for(let t=0;t<=e;t+=e/4)i.push(pM(f,_M(hM(y,g),t)));for(let t=e;t>=0;t-=e/4)a.push(pM(f,_M(hM(y,g),t)));a.push(O,T)}else{i.push(C,te);for(let t=0;t<=e;t+=e/4)a.push(pM(f,_M(hM(y,-g),-t)));for(let t=e;t>=0;t-=e/4)i.push(pM(f,_M(hM(y,-g),-t)));i.push(te,E)}}else i.push(te),a.push(O);s=o}if(c>=r-2){if(this.options.keepHead){let e=n[r-1],t=[];for(let n=0;n<=Math.PI*2;n+=Math.PI/16)t.push(pM(e,hM(_M([1,0,0],n),this.options.size)));return t.push(pM(e,hM([1,0,0],this.options.size))),t}return[]}let u=n[c],d=n[c+1],f=n[r-2],p=n[r-1],m=gM(mM(d,u)),h=gM(mM(f,p)),g=_M(m,-Math.PI/2),_=_M(h,Math.PI/2),v=this.getSize(t,u[2],0,r,0),y=[],b=this.options.keepHead?this.options.size:this.getSize(t,f[2],r-2,r,l),x=[];if(v>.1){for(let e=0;e<=Math.PI;e+=Math.PI/16)y.unshift(pM(u,_M(hM(g,v),-e)));y.unshift(pM(u,hM(g,-v)))}else y.push(u);for(let e=0;e<=Math.PI*3;e+=Math.PI/16)x.push(pM(p,_M(hM(_,-b),-e)));let S=[...y,...i,...x.reverse(),...a.reverse()];return y.length>0&&S.push(y[0]),this.options.simplify>0&&this.options.simplifyPhase===`output`?EM(S,this.options.simplify):S}};V(DM,`defaults`,{size:2,streamline:.45,simplify:.1,simplifyPhase:`output`,keepHead:!1,sizeMapping:()=>1}),V(DM,`constants`,{cornerDetectionMaxAngle:75,cornerDetectionVariance:e=>e>35?.5:1,maxTailLength:50});var OM=DM,kM=e=>{if(!e)return[];for(let t of e.sets)if(t.type===`path`)return t.ops;return e.sets[0].ops},AM=e=>!!e&&e.type===`embeddable`,jM=e=>!!e&&e.type===`iframe`,MM=e=>!!e&&(e.type===`iframe`||e.type===`embeddable`),NM=e=>e!=null&&e.type===`text`,PM=e=>e!=null&&(e.type===`frame`||e.type===`magicframe`),FM=e=>e!=null&&RM(e.type),IM=e=>e!=null&&e.type===`arrow`,LM=e=>IM(e)&&e.elbowed,RM=e=>e===`arrow`||e===`line`,zM=e=>e!==null&&`containerId`in e&&e.containerId!==null&&NM(e);`ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789`.toLocaleUpperCase();var BM=(e,t)=>{let n=[];for(let r of e.values())r.frameId===t&&n.push(r);return n};(function(){let e=null,t=null,n=null,r=(r,i)=>(n!=null&&r===e&&i.selectedElementIds===t||(n=r.some(e=>i.selectedElementIds[e.id]),e=r,t=i.selectedElementIds),n);return r.clearCache=()=>{e=null,t=null,n=null},r})();var VM=(e,t,n)=>{let r=new Set,i=[];for(let a of e.values()){if(t.selectedElementIds[a.id]){$M(a)?(i.push(a),r.add(a.id)):console.error(`[NONDELETED][INVARIANT] getSelectedElements skipping deleted selected element which should not be in the selection`);continue}if(n?.includeBoundTextElement&&zM(a)&&$M(a)&&t.selectedElementIds[a?.containerId]){i.push(a),r.add(a.id);continue}}if(n?.includeElementsInFrames){let t=[];return i.forEach(n=>{PM(n)&&BM(e,n.id).forEach(e=>!r.has(e.id)&&t.push(e)),t.push(n)}),t}return i},HM=(e,t)=>Us(t.selectedElementIds,e)?t.selectedElementIds:e;(function(){let e=null,t=null,n=null,r=(r,i,a,o)=>{if(n!==void 0&&i===t&&r===e&&a.editingGroupId===n?.editingGroupId)return n;let s={};for(let e of r){let t=e.groupIds;if(a.editingGroupId){let e=t.indexOf(a.editingGroupId);e>-1&&(t=t.slice(0,e))}if(t.length>0){let e=t[t.length-1];s[e]=!0}}let c={},l=i.reduce((e,t)=>{if(t.isDeleted)return e;let n=t.groupIds.find(e=>s[e]);return n&&(e[t.id]=!0,Array.isArray(c[n])?c[n].push(t.id):c[n]=[t.id]),e},{});for(let e of Object.keys(c))c[e].length<2&&s[e]&&(s[e]=!1);return t=i,e=r,n={editingGroupId:a.editingGroupId,selectedGroupIds:s,selectedElementIds:HM({...a.selectedElementIds,...l},o)},n},i=(e,t,n,i)=>{let a=i?i.scene.getSelectedElements({selectedElementIds:e.selectedElementIds,elements:t}):VM(t,e);return a.length?r(a,t,e,n):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:HM(e.selectedElementIds,n)}};return i.clearCache=()=>{t=null,e=null,n=null},i})();var UM=[1,0],WM=[0,1],GM=[-1,0],KM=[0,-1],qM=e=>{let[t,n]=e,r=Math.abs(t),i=Math.abs(n);return t>i?UM:t<=-i?GM:n>r?WM:KM},JM=(e,t)=>qM(Tn(e,t)),YM=(e,t)=>ZM(JM(e,t)),XM=(e,t)=>e[0]===t[0]&&e[1]===t[1],ZM=e=>XM(e,UM)||XM(e,GM),QM=e=>e===`rectangle`||e===`iframe`||e===`embeddable`||e===`line`||e===`diamond`||e===`stickynote`||e===`image`;(0,_l.default)(e=>{(rt()||ei()||window?.DEBUG_FRACTIONAL_INDICES)&&le(e,{shouldThrow:rt()||ei(),includeBoundTextValidation:!0})},6e4,{leading:!0,trailing:!1}),Math.PI/4;var $M=e=>!e.isDeleted,eN=(e,t=1)=>{if(e.length>=3){let[n,r]=[e[0],e[e.length-1]];return zt(n,r)<=8/t}return!1},tN=(e,t)=>{if(t.roundness?.type===Pa.PROPORTIONAL_RADIUS||t.roundness?.type===Pa.LEGACY)return e*da;if(t.roundness?.type===Pa.ADAPTIVE_RADIUS){let n=t.roundness?.value??32;return e<=n/.25?e*da:n}return 0},nN=e=>{let t=Math.floor(e.width/2)+1,n=e.width,r=Math.floor(e.height/2)+1;return[t,0,n,r,t,e.height,0,r]},rN=20,iN=15,aN=e=>{switch(e){case`arrow`:return 25;case`diamond`:case`diamond_outline`:return 12;case`cardinality_many`:case`cardinality_one_or_many`:case`cardinality_zero_or_many`:return iN;case`cardinality_one`:case`cardinality_exactly_one`:case`cardinality_zero_or_one`:return rN;default:return 15}},oN=e=>{switch(e){case`bar`:return 90;case`arrow`:return 20;default:return 25}},sN=(e,t,n,r,i=0)=>{if(r===null||t.length<1)return null;let a=kM(t[0]);if(a.length<1)return null;let o=n===`start`?1:a.length-1,s=a[o].data;eo(s.length===6,`Op data length is not 6`);let c=F(s[4],s[5]),l=F(s[2],s[3]),u=F(s[0],s[1]),d=a[o-1],f=F(0,0);if(d.op===`move`){let e=on(d.data);eo(e!=null,`Op data is not a point`),f=e}else d.op===`bcurveTo`&&(f=F(d.data[4],d.data[5]));let p=(e,t)=>(1-e)**3*c[t]+3*e*(1-e)**2*l[t]+3*e**2*(1-e)*u[t]+f[t]*e**3,[m,h]=n===`start`?f:c,[g,_]=[p(.3,0),p(.3,1)],v=Math.hypot(m-g,h-_),y=(m-g)/v,b=(h-_)/v,x=aN(r),S=0;{let[t,r]=n===`end`?e.points[e.points.length-1]:e.points[0],[i,a]=e.points.length>1?n===`end`?e.points[e.points.length-2]:e.points[1]:[0,0];S=Math.hypot(t-i,r-a)}let C=Math.min(x,S*(r===`diamond`||r===`diamond_outline`?.25:.5)),w=m-y*C*i,T=h-b*C*i,E=w-y*C,D=T-b*C;if(r===`circle`||r===`circle_outline`)return[w,T,Math.hypot(D-T,E-w)+e.strokeWidth-2];let ee=oN(r);if(r===`cardinality_many`||r===`cardinality_one_or_many`){let[e,t]=rl(F(w,T),F(E,D),We(-ee)),[n,r]=rl(F(w,T),F(E,D),We(ee));return[E,D,e,t,n,r]}let[te,O]=rl(F(E,D),F(w,T),-ee*Math.PI/180),[k,A]=rl(F(E,D),F(w,T),We(ee));if(r===`diamond`||r===`diamond_outline`){let t,r;if(n===`start`){let[n,i]=e.points.length>1?e.points[1]:[0,0];[t,r]=rl(F(w+C*2,T),F(w,T),Math.atan2(i-T,n-w))}else{let[n,i]=e.points.length>1?e.points[e.points.length-2]:[0,0];[t,r]=rl(F(w-C*2,T),F(w,T),Math.atan2(T-i,w-n))}return[w,T,te,O,t,r,k,A]}return[w,T,te,O,k,A]},cN=typeof document<`u`?document.createElement(`img`):{src:``};cN.src=`data:${M.svg},%3Csvg%20aria-hidden%3D%22true%22%20focusable%3D%22false%22%20data-prefix%3D%22fas%22%20data-icon%3D%22image%22%20class%3D%22svg-inline--fa%20fa-image%20fa-w-16%22%20role%3D%22img%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20512%20512%22%3E%3Cpath%20fill%3D%22%23888%22%20d%3D%22M464%20448H48c-26.51%200-48-21.49-48-48V112c0-26.51%2021.49-48%2048-48h416c26.51%200%2048%2021.49%2048%2048v288c0%2026.51-21.49%2048-48%2048zM112%20120c-30.928%200-56%2025.072-56%2056s25.072%2056%2056%2056%2056-25.072%2056-56-25.072-56-56-56zM64%20384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971%200L208%20320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971%200L64%20336v48z%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E`;var lN=typeof document<`u`?document.createElement(`img`):{src:``};lN.src=`data:${M.svg},%3Csvg%20viewBox%3D%220%200%20668%20668%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xml%3Aspace%3D%22preserve%22%20style%3D%22fill-rule%3Aevenodd%3Bclip-rule%3Aevenodd%3Bstroke-linejoin%3Around%3Bstroke-miterlimit%3A2%22%3E%3Cpath%20d%3D%22M464%20448H48c-26.51%200-48-21.49-48-48V112c0-26.51%2021.49-48%2048-48h416c26.51%200%2048%2021.49%2048%2048v288c0%2026.51-21.49%2048-48%2048ZM112%20120c-30.928%200-56%2025.072-56%2056s25.072%2056%2056%2056%2056-25.072%2056-56-25.072-56-56-56ZM64%20384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971%200L208%20320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971%200L64%20336v48Z%22%20style%3D%22fill%3A%23888%3Bfill-rule%3Anonzero%22%20transform%3D%22matrix(.81709%200%200%20.81709%20124.825%20145.825)%22%2F%3E%3Cpath%20d%3D%22M256%208C119.034%208%208%20119.033%208%20256c0%20136.967%20111.034%20248%20248%20248s248-111.034%20248-248S392.967%208%20256%208Zm130.108%20117.892c65.448%2065.448%2070%20165.481%2020.677%20235.637L150.47%20105.216c70.204-49.356%20170.226-44.735%20235.638%2020.676ZM125.892%20386.108c-65.448-65.448-70-165.481-20.677-235.637L361.53%20406.784c-70.203%2049.356-170.226%2044.736-235.638-20.676Z%22%20style%3D%22fill%3A%23888%3Bfill-rule%3Anonzero%22%20transform%3D%22matrix(.30366%200%200%20.30366%20506.822%2060.065)%22%2F%3E%3C%2Fsvg%3E`;var uN=new WeakMap,dN=class{};V(dN,`rg`,new ka),V(dN,`cache`,new WeakMap),V(dN,`get`,(e,t)=>{let n=dN.cache.get(e);if(n&&(t===null||n.theme===t))return n.shape}),V(dN,`delete`,e=>{dN.cache.delete(e),uN.delete(e)}),V(dN,`destroy`,()=>{dN.cache=new WeakMap}),V(dN,`generateElementShape`,(e,t)=>{let n=t?.isExporting?void 0:dN.get(e,t?t.theme:null);if(n!==void 0)return n;uN.delete(e);let r=SN(e,dN.rg,t||{isExporting:!1,canvasBackgroundColor:Ma.white,embedsValidationStatus:null,theme:P.LIGHT});return t?.isExporting||dN.cache.set(e,{shape:r,theme:t?.theme||P.LIGHT}),r});var fN=e=>[8,8+e],pN=e=>[1.5,6+e];function mN(e){let 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&&QM(e.type)||FM(e)&&n>=50?t:Math.min(t/(n<10?3:2),2.5)}var hN=(e,t=!1,n=!1)=>{let r={seed:e.seed,strokeLineDash:e.strokeStyle===`dashed`?fN(e.strokeWidth):e.strokeStyle===`dotted`?pN(e.strokeWidth):void 0,disableMultiStroke:e.strokeStyle!==`solid`,strokeWidth:e.strokeStyle===`solid`?e.strokeWidth:e.strokeWidth+.5,fillWeight:e.strokeWidth/2,hachureGap:e.strokeWidth*4,roughness:mN(e),stroke:Zc(e.strokeColor,n),preserveVertices:t||e.roughness<Ct.cartoonist};switch(e.type){case`rectangle`:case`iframe`:case`embeddable`:case`diamond`:case`ellipse`:return r.fillStyle=e.fillStyle,r.fill=Ke(e.backgroundColor)?void 0:Zc(e.backgroundColor,n),e.type===`ellipse`&&(r.curveFitting=1),r;case`line`:case`freedraw`:return eN(e.points)&&(r.fillStyle=e.fillStyle,r.fill=e.backgroundColor===`transparent`?void 0:Zc(e.backgroundColor,n)),r;case`arrow`:return r;default:throw Error(`Unimplemented type ${e.type}`)}},gN=(e,t,n)=>MM(e)&&(t||AM(e)&&n?.get(e.id)!==!0)&&Ke(e.backgroundColor)&&Ke(e.strokeColor)?{...e,roughness:0,backgroundColor:`#d3d3d3`,fillStyle:`solid`}:jM(e)?{...e,strokeColor:Ke(e.strokeColor)?`#000000`:e.strokeColor,backgroundColor:Ke(e.backgroundColor)?`#f4f4f6`:e.backgroundColor}:e,_N=(e,t,n)=>{if(t===null)return[];let[,,r,i,a,o]=t;return[e.line(r,i,a,o,n)]},vN=(e,t,n)=>{if(t===null)return[];let[r,i,a,o,s,c]=t;return[e.line(a,o,r,i,n),e.line(s,c,r,i,n)]},yN=(e,t)=>{let n={...t};if(e.strokeStyle===`dotted`){let t=pN(e.strokeWidth-1);n.strokeLineDash=[t[0],t[1]-1]}else delete n.strokeLineDash;return n.roughness=Math.min(1,n.roughness||0),n},bN=(e,t,n,r,i,a=1)=>{if(r===null)return[];let[o,s,c]=r,l={...t,fill:i,fillStyle:`solid`,stroke:n,roughness:Math.min(.5,t.roughness||0)};return delete l.strokeLineDash,[e.circle(o,s,c*a,l)]},xN=(e,t,n,r,i,a,o,s)=>{if(r===null)return[];let c=Zc(e.strokeColor,s),l=Zc(o,s),u=.8;switch(r){case`circle`:case`circle_outline`:return bN(i,a,c,sN(e,t,n,r),r===`circle_outline`?l:c);case`triangle`:case`triangle_outline`:{let o=sN(e,t,n,r);if(o===null)return[];let[s,u,d,f,p,m]=o,h={...a,fill:r===`triangle_outline`?l:c,fillStyle:`solid`,roughness:Math.min(1,a.roughness||0)};return delete h.strokeLineDash,[i.polygon([[s,u],[d,f],[p,m],[s,u]],h)]}case`diamond`:case`diamond_outline`:{let o=sN(e,t,n,r);if(o===null)return[];let[s,u,d,f,p,m,h,g]=o,_={...a,fill:r===`diamond_outline`?l:c,fillStyle:`solid`,roughness:Math.min(1,a.roughness||0)};return delete _.strokeLineDash,[i.polygon([[s,u],[d,f],[p,m],[h,g],[s,u]],_)]}case`cardinality_one`:return _N(i,sN(e,t,n,r),yN(e,a));case`cardinality_many`:return vN(i,sN(e,t,n,r),yN(e,a));case`cardinality_one_or_many`:{let r=yN(e,a);return[...vN(i,sN(e,t,n,`cardinality_many`),r),..._N(i,sN(e,t,n,`cardinality_one`,-.25),r)]}case`cardinality_exactly_one`:{let r=yN(e,a);return[..._N(i,sN(e,t,n,`cardinality_one`,-.5),r),..._N(i,sN(e,t,n,`cardinality_one`),r)]}case`cardinality_zero_or_one`:{let r=yN(e,a);return[...bN(i,a,c,sN(e,t,n,`circle_outline`,1.5),l,u),..._N(i,sN(e,t,n,`cardinality_one`,-.5),r)]}case`cardinality_zero_or_many`:{let r=yN(e,a);return[...vN(i,sN(e,t,n,`cardinality_many`),r),...bN(i,a,c,sN(e,t,n,`circle_outline`,1.5),l,u)]}default:return vN(i,sN(e,t,n,r),yN(e,a))}},SN=(e,t,{isExporting:n,canvasBackgroundColor:r,embedsValidationStatus:i,theme:a})=>{let o=a===P.DARK;switch(e.type){case`rectangle`:case`iframe`:case`embeddable`:{let r;if(e.roundness){let a=e.width,s=e.height,c=tN(Math.min(a,s),e);r=t.path(`M ${c} 0 L ${a-c} 0 Q ${a} 0, ${a} ${c} L ${a} ${s-c} Q ${a} ${s}, ${a-c} ${s} L ${c} ${s} Q 0 ${s}, 0 ${s-c} L 0 ${c} Q 0 0, ${c} 0`,hN(gN(e,n,i),!0,o))}else r=t.rectangle(0,0,e.width,e.height,hN(gN(e,n,i),!1,o));return r}case`diamond`:{let n,[r,i,a,s,c,l,u,d]=nN(e);if(e.roundness){let f=tN(Math.abs(r-u),e),p=tN(Math.abs(s-i),e);n=t.path(`M ${r+f} ${i+p} L ${a-f} ${s-p}
|
|
46
|
+
C ${a} ${s}, ${a} ${s}, ${a-f} ${s+p}
|
|
47
|
+
L ${c+f} ${l-p}
|
|
48
|
+
C ${c} ${l}, ${c} ${l}, ${c-f} ${l-p}
|
|
49
|
+
L ${u+f} ${d+p}
|
|
50
|
+
C ${u} ${d}, ${u} ${d}, ${u+f} ${d-p}
|
|
51
|
+
L ${r-f} ${i+p}
|
|
52
|
+
C ${r} ${i}, ${r} ${i}, ${r+f} ${i+p}`,hN(e,!0,o))}else n=t.polygon([[r,i],[a,s],[c,l],[u,d]],hN(e,!1,o));return n}case`ellipse`:return t.ellipse(e.width/2,e.height/2,e.width,e.height,hN(e,!1,o));case`line`:case`arrow`:{let n,i=hN(e,!1,o),a=e.points.length?e.points:[F(0,0)];if(LM(e)?a.every(e=>Math.abs(e[0])<=1e6&&Math.abs(e[1])<=1e6)?n=[t.path(CN(a,16),hN(e,!0,o))]:(console.error(`Elbow arrow with extreme point positions detected. Arrow not rendered.`,e.id,JSON.stringify(a)),n=[]):n=e.roundness?[t.curve(a,i)]:i.fill?[t.polygon(a,i)]:[t.linearPath(a,i)],e.type===`arrow`){let{startArrowhead:a=null,endArrowhead:s=`arrow`}=e;if(a!==null){let s=xN(e,n,`start`,a,t,i,r,o);n.push(...s)}if(s!==null){let a=xN(e,n,`end`,s,t,i,r,o);n.push(...a)}}return n}case`freedraw`:{let n=[];if(eN(e.points)){let r=eb(e.points,.75);n.push(t.curve(r,{...hN(e,!1,o),stroke:`none`}))}return n.push(wN(e)),n}case`stickynote`:case`frame`:case`magicframe`:case`text`:case`image`:return null;default:return _c(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},CN=(e,t)=>{let n=[];for(let r=1;r<e.length-1;r+=1){let i=e[r-1],a=e[r+1],o=e[r],s=YM(o,i),c=YM(a,o),l=Math.min(t,zt(e[r],a)/2,zt(e[r],i)/2);s?i[0]<o[0]?n.push([e[r][0]-l,e[r][1]]):n.push([e[r][0]+l,e[r][1]]):i[1]<o[1]?n.push([e[r][0],e[r][1]-l]):n.push([e[r][0],e[r][1]+l]),n.push(e[r]),c?a[0]<o[0]?n.push([e[r][0]-l,e[r][1]]):n.push([e[r][0]+l,e[r][1]]):a[1]<o[1]?n.push([e[r][0],e[r][1]-l]):n.push([e[r][0],e[r][1]+l])}let r=[`M ${e[0][0]} ${e[0][1]}`];for(let e=0;e<n.length;e+=3)r.push(`L ${n[e][0]} ${n[e][1]}`),r.push(`Q ${n[e+1][0]} ${n[e+1][1]}, ${n[e+2][0]} ${n[e+2][1]}`);return r.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),r.join(` `)},wN=e=>PN(jN(e)),TN={SIZE_FACTOR:4.25,THINNING:.6,SMOOTHING:.5},EN={SIZE_FACTOR:1.4},DN=e=>e.strokeOptions?.streamline??.5,ON=e=>Tb(e.simulatePressure?e.points:e.points.length?e.points.map(([t,n],r)=>[t,n,e.pressures[r]]):[[0,0,.5]],{simulatePressure:e.simulatePressure,size:e.strokeWidth*TN.SIZE_FACTOR,thinning:TN.THINNING,smoothing:TN.SMOOTHING,streamline:DN(e),easing:e=>Math.sin(e*Math.PI/2),last:!0}),kN=e=>new OM({size:e.strokeWidth*EN.SIZE_FACTOR,streamline:DN(e),simplify:0,sizeMapping:e=>Math.max(.1,e.pressure)}),AN=e=>{let t=kN(e);return e.points.map(([e,n])=>t.addPoint([e,n,1])),t.getStrokeOutline().map(([e,t])=>[e,t])},jN=e=>e.strokeOptions?.variability===`constant`?AN(e):ON(e),MN=(e,t)=>[(e[0]+t[0])/2,(e[1]+t[1])/2],NN=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g,PN=e=>{if(!e.length)return``;let t=e.length-1;return e.reduce((e,n,r,i)=>(r===t?e.push(n,MN(n,i[0]),`L`,i[0],`Z`):e.push(n,MN(n,i[r+1])),e),[`M`,e[0],`Q`]).join(` `).replace(NN,`$1`)},FN=(e,t,n=!1)=>{let r=!1;for(let n in t){let i=t[n];if(typeof i<`u`){if(e[n]===i&&(typeof i!=`object`||!i))continue;r=!0}}return!r&&!n?e:{...e,...t,version:t.version??e.version+1,versionNonce:t.versionNonce??Zt(),updated:rc()}},IN=X({name:`toggleLinearEditor`,category:aM.elements,label:(e,t,n)=>n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds})[0]?.type===`arrow`?`labels.lineEditor.editArrow`:`labels.lineEditor.edit`,keywords:[`line`],trackEvent:{category:`element`},predicate:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t);return!(t.selectedLinearElement?.isEditing||i.length!==1||!ro(i[0])||Br(i[0]))},perform(e,t,n,r){eo(t.selectedLinearElement,`No selected linear element found`);let i=r.scene.getElement(t.selectedLinearElement.elementId);eo(i,`No selected element found`);let a={...t.selectedLinearElement,isEditing:!t.selectedLinearElement.isEditing};return{appState:{...t,selectedLinearElement:a},captureUpdate:N.IMMEDIATELY}},PanelComponent:({appState:e,updateData:t,app:n})=>{let r=n.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0];if(!r)return null;let i=K(r.type===`arrow`?`labels.lineEditor.editArrow`:`labels.lineEditor.edit`);return(0,W.jsx)(kw,{type:`button`,icon:dw,title:i,"aria-label":i,onClick:()=>t(null)})}});X({name:`togglePolygon`,category:aM.elements,icon:px,keywords:[`loop`],label:(e,t,n)=>n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds}).some(e=>!oa(e)||!e.polygon)?`labels.polygon.convertToPolygon`:`labels.polygon.breakPolygon`,trackEvent:{category:`element`},predicate:(e,t,n,r)=>{let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds});return i.length>0&&i.every(e=>oa(e)&&e.points.length>=4)},perform(e,t,n,r){let i=r.scene.getSelectedElements(t);if(i.some(e=>!oa(e)))return!1;let a=i,o=a.some(e=>!e.polygon),s=d(a);return{elements:e.map(e=>!s.has(e.id)||!oa(e)?e:FN(e,{backgroundColor:o?e.backgroundColor:`transparent`,...Pt(e,o)})),appState:t,captureUpdate:N.IMMEDIATELY}},PanelComponent:({appState:e,updateData:t,app:n})=>{let r=n.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(r.length===0||r.some(e=>!oa(e)||!e.polygon||e.points.length<3))return null;let i=r.every(e=>oa(e)&&e.polygon),a=K(i?`labels.polygon.breakPolygon`:`labels.polygon.convertToPolygon`);return(0,W.jsx)(kw,{type:`toggle`,icon:px,title:a,"aria-label":a,checked:i,onSelect:()=>t(null),style:{marginLeft:`auto`}})}});var LN=X({name:`searchMenu`,icon:KC,keywords:[`search`,`find`],label:`search.title`,viewMode:!0,trackEvent:{category:`search_menu`,action:`toggle`,predicate:e=>e.gridModeEnabled},perform(e,t,n,r){if(t.openDialog)return!1;if(t.openSidebar?.name===Gi.name&&t.openSidebar.tab===`search`){let e=r.excalidrawContainerValue.container?.querySelector(`.${Ai.SEARCH_MENU_INPUT_WRAPPER} input`);return e?.focus(),e?.select(),!1}return{appState:{...t,openSidebar:{name:Gi.name,tab:tt},openDialog:null},captureUpdate:N.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,t,n)=>n.gridModeEnabled===void 0,keyTest:e=>e[L.CTRL_OR_CMD]&&e.key===L.F}),RN=X({name:`cropEditor`,label:`helpDialog.cropStart`,icon:vw,viewMode:!0,trackEvent:{category:`menu`},keywords:[`image`,`crop`],perform(e,t,n,r){let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...t,isCropping:!1,croppingElementId:i.id},captureUpdate:N.IMMEDIATELY}},predicate:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t);return!(t.croppingElementId||i.length!==1||!La(i[0]))},PanelComponent:({appState:e,updateData:t,app:n})=>{let r=K(`helpDialog.cropStart`);return(0,W.jsx)(kw,{type:`button`,icon:vw,title:r,"aria-label":r,onClick:()=>t(null)})}}),zN=(e,t)=>{let n=t.scene.getSelectedElements(e);return n.length===1&&R(n[0])},BN=X({name:`selectAllElementsInFrame`,label:`labels.selectAllElementsInFrame`,trackEvent:{category:`canvas`},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t).at(0)||null;if(R(i)){let n=Ti(k(e),i.id).filter(e=>!(e.type===`text`&&e.containerId));return{elements:e,appState:{...t,selectedElementIds:n.reduce((e,t)=>(e[t.id]=!0,e),{})},captureUpdate:N.IMMEDIATELY}}return{elements:e,appState:t,captureUpdate:N.EVENTUALLY}},predicate:(e,t,n,r)=>zN(t,r)}),VN=X({name:`removeAllElementsFromFrame`,label:`labels.removeAllElementsFromFrame`,trackEvent:{category:`history`},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t).at(0)||null;return R(i)?{elements:Dn(e,i),appState:{...t,selectedElementIds:{[i.id]:!0}},captureUpdate:N.IMMEDIATELY}:{elements:e,appState:t,captureUpdate:N.EVENTUALLY}},predicate:(e,t,n,r)=>zN(t,r)});X({name:`updateFrameRendering`,label:`labels.updateFrameRendering`,viewMode:!0,trackEvent:{category:`canvas`},perform:(e,t)=>({elements:e,appState:{...t,frameRendering:{...t.frameRendering,enabled:!t.frameRendering.enabled}},captureUpdate:N.EVENTUALLY}),checked:e=>e.frameRendering.enabled});var HN=X({name:`wrapSelectionInFrame`,label:`labels.wrapSelectionInFrame`,trackEvent:{category:`element`},predicate:(e,t,n,r)=>{let i=ot(e,t);return i.length>0&&!i.some(e=>R(e))},perform:(e,t,n,r)=>{let i=ot(e,t),a=r.scene.getNonDeletedElementsMap(),[o,s,c,l]=Wr(i,a),u=Vo({x:o-16,y:s-16,width:c-o+32,height:l-s+32});if(t.editingGroupId){let e=Er(i,t.editingGroupId);for(let n of e){let e=n.groupIds.indexOf(t.editingGroupId);Xr(n,a,{groupIds:n.groupIds.slice(0,e)})}}return{elements:ki([...r.scene.getElementsIncludingDeleted(),u],i,u),appState:{selectedElementIds:{[u.id]:!0}},captureUpdate:N.IMMEDIATELY}}}),UN=class extends St{applyTo(e,t,n){let[r,i]=this.elements.applyTo(e,n.elements,{excludedProperties:new Set([`version`,`versionNonce`])}),[a,o]=this.appState.applyTo(t,r);return[r,a,i||o]}static calculate(e,t){return super.calculate(e,t)}static inverse(e){return super.inverse(e)}static applyLatestChanges(e,t,n,r){return super.applyLatestChanges(e,t,n,r)}},WN=class{constructor(e=!0,t=!0){this.isUndoStackEmpty=e,this.isRedoStackEmpty=t}},GN=class e{constructor(e){this.store=e,V(this,`onHistoryChangedEmitter`,new dt),V(this,`undoStack`,[]),V(this,`redoStack`,[])}get isUndoStackEmpty(){return this.undoStack.length===0}get isRedoStackEmpty(){return this.redoStack.length===0}clear(){this.undoStack.length=0,this.redoStack.length=0}record(e){if(e.isEmpty()||e instanceof UN)return;let t=UN.inverse(e);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new WN(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(t,n){return this.perform(t,n,()=>e.pop(this.undoStack),t=>e.push(this.redoStack,t))}redo(t,n){return this.perform(t,n,()=>e.pop(this.redoStack),t=>e.push(this.undoStack,t))}perform(e,t,n,r){try{let i=n();if(i===null)return;let a=N.IMMEDIATELY,o=this.store.snapshot,s=e,c=t,l=!1;for(;i;){try{[s,c,l]=i.applyTo(s,c,o);let e=o.elements,t=o.maybeClone(a,s,c),n=$o.create(o,t),r=UN.applyLatestChanges(i,e,s);r.isEmpty()||(this.store.scheduleMicroAction({action:a,change:n,delta:r}),i=r),o=t}finally{r(i)}if(l)break;i=n()}return[s,c]}finally{this.onHistoryChangedEmitter.trigger(new WN(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(e){if(!e.length)return null;let t=e.pop();return t===void 0?null:t}static push(e,t){let n=UN.inverse(t);return e.push(n)}},KN=(e,t)=>{let[n,r]=(0,H.useState)(t);return(0,H.useEffect)(()=>{let t=e.on(e=>{r(e)});return()=>{t()}},[e]),n},qN=(e,t,n)=>{if(!t.multiElement&&!t.resizingElement&&!t.editingTextElement&&!t.newElement&&!t.selectedElementsAreBeingDragged&&!t.selectionElement&&!e.flowchart.isCreatingChart&&!e.drawShape.hasPendingGesture()){let e=n();if(!e)return{captureUpdate:N.EVENTUALLY};let[t,r]=e;return{appState:r,elements:zc(Array.from(t.values())),captureUpdate:N.NEVER}}return{captureUpdate:N.EVENTUALLY}},JN=e=>({name:`undo`,label:`buttons.undo`,icon:oS,trackEvent:{category:`history`},viewMode:!1,perform:(t,n,r,i)=>qN(i,n,()=>e.undo(d(t),n)),keyTest:e=>e[L.CTRL_OR_CMD]&&Si(e,L.Z)&&!e.shiftKey,PanelComponent:({appState:t,updateData:n,data:r,app:i})=>{let{isUndoStackEmpty:a}=KN(e.onHistoryChangedEmitter,new WN(e.isUndoStackEmpty,e.isRedoStackEmpty)),o=pU()===`mobile`;return(0,W.jsx)(kw,{type:`button`,icon:oS,"aria-label":K(`buttons.undo`),onClick:n,size:r?.size||`medium`,disabled:a,"data-testid":`button-undo`,style:{...o?ui:{}}})}}),YN=e=>({name:`redo`,label:`buttons.redo`,icon:sS,trackEvent:{category:`history`},viewMode:!1,perform:(t,n,r,i)=>qN(i,n,()=>e.redo(d(t),n)),keyTest:e=>e[L.CTRL_OR_CMD]&&e.shiftKey&&Si(e,L.Z)||e[L.CTRL_OR_CMD]&&!e.shiftKey&&Si(e,L.Y),PanelComponent:({appState:t,updateData:n,data:r,app:i})=>{let{isRedoStackEmpty:a}=KN(e.onHistoryChangedEmitter,new WN(e.isUndoStackEmpty,e.isRedoStackEmpty)),o=pU()===`mobile`;return(0,W.jsx)(kw,{type:`button`,icon:sS,"aria-label":K(`buttons.redo`),onClick:n,size:r?.size||`medium`,disabled:a,"data-testid":`button-redo`,style:{...o?ui:{}}})}}),XN=X({name:`autoResize`,label:`labels.autoResize`,icon:null,trackEvent:{category:`element`},predicate:(e,t,n)=>{let r=ot(e,t);return r.length===1&&z(r[0])&&!r[0].autoResize},perform:(e,t,n,r)=>{let i=ot(e,t),a=nl(n)&&z(n)?n:i[0],o=e.find(e=>e.id===a?.id);if(!o||!z(o))return!1;let s=Di(o.originalText,Ro(o),o.lineHeight),c=ss(o),l=j(o,{autoResize:!0,width:s.width,height:s.height,x:o.x+(o.width-s.width)*c.x,y:o.y+(o.height-s.height)*c.y,text:o.originalText});return ea(l)&&u(l,r.scene,{changedElements:new Map([[l.id,l]])}),{appState:t,elements:e.map(e=>e.id===l.id?l:e),captureUpdate:N.IMMEDIATELY}}}),ZN=(e,t,n,r,i,a)=>{if(e.trackEvent)try{typeof e.trackEvent==`object`&&(!e.trackEvent.predicate||e.trackEvent.predicate(n,r,a))&&Vw(e.trackEvent.category,e.trackEvent.action||e.name,`${t} (${i.editorInterface.formFactor===`phone`?`mobile`:`desktop`})`)}catch(e){console.error(`error while logging action:`,e)}},QN=class{constructor(e,t,n,r){V(this,`actions`,{}),V(this,`updater`),V(this,`getAppState`),V(this,`getElementsIncludingDeleted`),V(this,`app`),V(this,`isActionBlockedByViewportTransition`,e=>e.navigation===!0&&this.app.viewport.isLockedTransitionPending),V(this,`renderAction`,(e,t)=>{let n=this.app.props.UIOptions.canvasActions;if(this.actions[e]&&`PanelComponent`in this.actions[e]&&(!(e in n)||n[e])){let n=this.actions[e],r=n.PanelComponent;return r.displayName=`PanelComponent`,(0,W.jsx)(r,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:e=>{this.isActionBlockedByViewportTransition(n)||(ZN(n,`ui`,this.getAppState(),this.getElementsIncludingDeleted(),this.app,e),this.updater(n.perform(this.getElementsIncludingDeleted(),this.getAppState(),e,this.app)))},appProps:this.app.props,app:this.app,data:t,renderAction:this.renderAction})}return null}),V(this,`isActionEnabled`,e=>{let t=this.getElementsIncludingDeleted(),n=this.getAppState();return!e.predicate||e.predicate(t,n,this.app.props,this.app)}),this.updater=t=>{if(Zs(t))t.then(t=>e(t));else return e(t)},this.getAppState=t,this.getElementsIncludingDeleted=n,this.app=r}registerAction(e){this.actions[e.name]=e}registerAll(e){e.forEach(e=>this.registerAction(e))}handleKeyDown(e){if(!this.app.isInteractionEnabled()&&!this.app.isNavigationEnabled())return!1;let t=this.app.props.UIOptions.canvasActions,n=Object.values(this.actions).sort((e,t)=>(t.keyPriority||0)-(e.keyPriority||0)).filter(n=>(n.name in t?t[n.name]:!0)&&n.keyTest&&n.keyTest(e,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(n.length!==1)return n.length>1&&console.warn(`Canceling as multiple actions match this shortcut`,n),!1;let r=n[0];if(!this.app.isInteractionEnabled()&&r.navigation!==!0||this.getAppState().viewModeEnabled&&r.viewMode!==!0)return!1;if(this.isActionBlockedByViewportTransition(r))return e.preventDefault(),e.stopPropagation(),!0;let i=this.getElementsIncludingDeleted(),a=this.getAppState();return ZN(r,`keyboard`,a,i,this.app,null),e.preventDefault(),e.stopPropagation(),this.updater(n[0].perform(i,a,null,this.app)),!0}executeAction(e,t=`api`,n=null){if(t!==`api`&&!this.app.isInteractionEnabled()&&!(this.app.isNavigationEnabled()&&e.navigation===!0)||this.isActionBlockedByViewportTransition(e))return;let r=this.getElementsIncludingDeleted(),i=this.getAppState();ZN(e,t,i,r,this.app,n),this.updater(e.perform(r,i,n,this.app))}},$N=e=>{let t=Array.from(e.values());return{x:tP(t,e=>e.x)/t.length,y:tP(t,e=>e.y)/t.length}},eP=([e,t])=>Math.hypot(e.x-t.x,e.y-t.y),tP=(e,t)=>e.reduce((e,n)=>e+t(n),0),nP=e=>{let t=new Map;for(let[n,r]of e??[]){let{opacity:e,offset:i}=r;if(e!==void 0&&!Number.isFinite(e)||i!==void 0&&(i===null||!Number.isFinite(i.x)||!Number.isFinite(i.y)))throw TypeError(`Render overrides for ${n} must be finite numbers`);e===void 0&&i===void 0||t.set(n,{...e===void 0?{}:{opacity:fi(e,0,100)},...i?{offset:{x:i.x,y:i.y}}:{}})}return t},rP=(e,t)=>{let n=0,r=!1;for(let[i,{offset:a}]of e){if(!a)continue;n++;let e=t.get(i);if(!e||e.x!==a.x||e.y!==a.y){r=!0;break}}if(!r&&n===t.size)return t;let i=new Map;for(let[t,{offset:n}]of e)n&&i.set(t,n);return i},iP=8,aP=99999,oP=e=>iP/e,sP=class{};V(sP,`referenceSnapPoints`,null),V(sP,`visibleGaps`,null),V(sP,`setReferenceSnapPoints`,e=>{sP.referenceSnapPoints=e}),V(sP,`getReferenceSnapPoints`,()=>sP.referenceSnapPoints),V(sP,`setVisibleGaps`,e=>{sP.visibleGaps=e}),V(sP,`getVisibleGaps`,()=>sP.visibleGaps),V(sP,`destroy`,()=>{sP.referenceSnapPoints=null,sP.visibleGaps=null});var cP=sP,lP=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,uP=({event:e,app:t,selectedElements:n})=>{if(e){let n=t.state.activeTool.type===`lasso`&&t.state.selectedElementsAreBeingDragged;return(t.state.activeTool.type!==`lasso`||n)&&(t.state.objectsSnapModeEnabled&&!e[L.CTRL_OR_CMD]||!t.state.objectsSnapModeEnabled&&e[L.CTRL_OR_CMD]&&!lP(t))}return n.length===1&&n[0].type===`arrow`?!1:t.state.objectsSnapModeEnabled},dP=(e,t,n=.01)=>Math.abs(e-t)<=n,fP=(e,t,{omitCenter:n,boundingBoxCorners:r,dragOffset:i}={omitCenter:!1,boundingBoxCorners:!1})=>{let a=[];if(e.length===1){let o=e[0],[s,c,l,u,d,f]=ji(o,t);i&&(s+=i.x,l+=i.x,d+=i.x,c+=i.y,u+=i.y,f+=i.y);let p=(l-s)/2,m=(u-c)/2;if((o.type===`diamond`||o.type===`ellipse`)&&!r){let e=rl(F(s,c+m),F(d,f),o.angle),t=rl(F(s+p,c),F(d,f),o.angle),r=rl(F(l,c+m),F(d,f),o.angle),i=rl(F(s+p,u),F(d,f),o.angle),h=F(d,f);a=n?[e,t,r,i]:[e,t,r,i,h]}else{let e=rl(F(s,c),F(d,f),o.angle),t=rl(F(l,c),F(d,f),o.angle),r=rl(F(s,u),F(d,f),o.angle),i=rl(F(l,u),F(d,f),o.angle),p=F(d,f);a=n?[e,t,r,i]:[e,t,r,i,p]}}else if(e.length>1){let[t,r,o,s]=qn(e,i??{x:0,y:0}),c=o-t,l=s-r,u=F(t,r),d=F(o,r),f=F(t,s),p=F(o,s),m=F(t+c/2,r+l/2);a=n?[u,d,f,p]:[u,d,f,p,m]}return a.map(e=>F(yP(e[0]),yP(e[1])))},pP=(e,t,n,r)=>ln(e,t,n,r),mP=(e,t,n,r)=>{let i=pP(e,t,n,r),a=Qr(i,r).filter(e=>!(e.length===1&&_s(e[0]))).map(e=>Wr(e).map(e=>yP(e))),o=a.sort((e,t)=>e[0]-t[0]),s=[],c=0;e:for(let e=0;e<o.length;e++){let t=o[e];for(let n=e+1;n<o.length;n++){if(++c>aP)break e;let e=o[n],[,r,i,a]=t,[l,u,,d]=e;i<l&&Es(hn(r,a),hn(u,d))&&s.push({startBounds:t,endBounds:e,startSide:[F(i,r),F(i,a)],endSide:[F(l,u),F(l,d)],length:l-i,overlap:yt(hn(r,a),hn(u,d))})}}let l=a.sort((e,t)=>e[1]-t[1]),u=[];c=0;e:for(let e=0;e<l.length;e++){let t=l[e];for(let n=e+1;n<l.length;n++){if(++c>aP)break e;let e=l[n],[r,,i,a]=t,[o,s,d]=e;a<s&&Es(hn(r,i),hn(o,d))&&u.push({startBounds:t,endBounds:e,startSide:[F(r,a),F(i,a)],endSide:[F(o,s),F(d,s)],length:s-a,overlap:yt(hn(r,i),hn(o,d))})}}return{horizontalGaps:s,verticalGaps:u}},hP=(e,t,n,r,i,a,o)=>{if(!uP({app:n,event:r,selectedElements:e})||e.length===0)return[];let s=cP.getVisibleGaps();if(s){let{horizontalGaps:n,verticalGaps:r}=s,[c,l,u,d]=qn(e,t).map(e=>yP(e)),f=(c+u)/2,p=(l+d)/2;for(let e of n){if(!Es(hn(l,d),e.overlap))continue;let t=yP(e.startSide[0][0]+e.length/2-f);if(e.length>u-c&&Math.abs(t)<=o.x){Math.abs(t)<o.x&&(i.length=0),o.x=Math.abs(t);let n={type:`gap`,direction:`center_horizontal`,gap:e,offset:t};i.push(n);continue}let[,,n]=e.endBounds,r=c-n,a=yP(e.length-r);if(Math.abs(a)<=o.x){Math.abs(a)<o.x&&(i.length=0),o.x=Math.abs(a);let t={type:`gap`,direction:`side_right`,gap:e,offset:a};i.push(t);continue}let[s,,,]=e.startBounds,p=yP(s-u-e.length);if(Math.abs(p)<=o.x){Math.abs(p)<o.x&&(i.length=0),o.x=Math.abs(p);let t={type:`gap`,direction:`side_left`,gap:e,offset:p};i.push(t);continue}}for(let e of r){if(!Es(hn(c,u),e.overlap))continue;let t=yP(e.startSide[0][1]+e.length/2-p);if(e.length>d-l&&Math.abs(t)<=o.y){Math.abs(t)<o.y&&(a.length=0),o.y=Math.abs(t);let n={type:`gap`,direction:`center_vertical`,gap:e,offset:t};a.push(n);continue}let[,n,,]=e.startBounds,r=yP(n-d-e.length);if(Math.abs(r)<=o.y){Math.abs(r)<o.y&&(a.length=0),o.y=Math.abs(r);let t={type:`gap`,direction:`side_top`,gap:e,offset:r};a.push(t);continue}let[,,,i]=e.endBounds,s=yP(l-i),f=e.length-s;if(Math.abs(f)<=o.y){Math.abs(f)<o.y&&(a.length=0),o.y=Math.abs(f);let t={type:`gap`,direction:`side_bottom`,gap:e,offset:f};a.push(t);continue}}}},gP=(e,t,n,r)=>{let i=pP(e,t,n,r);return Qr(i,r).filter(e=>!(e.length===1&&_s(e[0]))).flatMap(e=>fP(e,r))},_P=(e,t,n,r,i,a,o)=>{if(!uP({app:n,event:r,selectedElements:e})||e.length===0&&t.length===0)return[];let s=cP.getReferenceSnapPoints();if(s)for(let e of t)for(let t of s){let n=t[0]-e[0],r=t[1]-e[1];Math.abs(n)<=o.x&&(Math.abs(n)<o.x&&(i.length=0),i.push({type:`point`,points:[e,t],offset:n}),o.x=Math.abs(n)),Math.abs(r)<=o.y&&(Math.abs(r)<o.y&&(a.length=0),a.push({type:`point`,points:[e,t],offset:r}),o.y=Math.abs(r))}},vP=(e,t,n,r,i)=>{let a=n.state,o=ot(e,a);if(!uP({app:n,event:r,selectedElements:o})||o.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};t.x=yP(t.x),t.y=yP(t.y);let s=[],c=[],l=oP(a.zoom.value),u={x:l,y:l};_P(o,fP(o,i,{dragOffset:t}),n,r,s,c,u),hP(o,t,n,r,s,c,u);let d={x:s[0]?.offset??0,y:c[0]?.offset??0};u.x=0,u.y=0,s.length=0,c.length=0;let f={x:yP(t.x+d.x),y:yP(t.y+d.y)};_P(o,fP(o,i,{dragOffset:f}),n,r,s,c,u),hP(o,f,n,r,s,c,u);let p=xP(s,c),m=CP(o,f,[...s,...c].filter(e=>e.type===`gap`));return{snapOffset:d,snapLines:[...p,...m]}},yP=e=>Math.round(e*10**6)/10**6,bP=e=>{let t=new Map;for(let n of e){let e=n.join(`,`);t.has(e)||t.set(e,n)}return Array.from(t.values())},xP=(e,t)=>{let n={},r={};if(e.length>0){for(let t of e)if(t.type===`point`){let e=yP(t.points[0][0]);n[e]||(n[e]=[]),n[e].push(...t.points.map(e=>F(yP(e[0]),yP(e[1]))))}}if(t.length>0){for(let e of t)if(e.type===`point`){let t=yP(e.points[0][1]);r[t]||(r[t]=[]),r[t].push(...e.points.map(e=>F(yP(e[0]),yP(e[1]))))}}return Object.entries(n).map(([e,t])=>({type:`points`,points:bP(t.map(t=>F(Number(e),t[1])).sort((e,t)=>e[1]-t[1]))})).concat(Object.entries(r).map(([e,t])=>({type:`points`,points:bP(t.map(t=>F(t[0],Number(e))).sort((e,t)=>e[0]-t[0]))})))},SP=e=>{let t=new Map;for(let n of e){let e=n.points.flat().map(e=>[yP(e)]).join(`,`);t.has(e)||t.set(e,n)}return Array.from(t.values())},CP=(e,t,n)=>{let[r,i,a,o]=qn(e,t),s=[];for(let e of n){let[t,n,c,l]=e.gap.startBounds,[u,d,f,p]=e.gap.endBounds,m=yt(hn(i,o),e.gap.overlap),h=yt(hn(r,a),e.gap.overlap);switch(e.direction){case`center_horizontal`:if(m){let t=(m[0]+m[1])/2;s.push({type:`gap`,direction:`horizontal`,points:[F(e.gap.startSide[0][0],t),F(r,t)]},{type:`gap`,direction:`horizontal`,points:[F(a,t),F(e.gap.endSide[0][0],t)]})}break;case`center_vertical`:if(h){let t=(h[0]+h[1])/2;s.push({type:`gap`,direction:`vertical`,points:[F(t,e.gap.startSide[0][1]),F(t,i)]},{type:`gap`,direction:`vertical`,points:[F(t,o),F(t,e.gap.endSide[0][1])]})}break;case`side_right`:if(m){let e=(m[0]+m[1])/2;s.push({type:`gap`,direction:`horizontal`,points:[F(c,e),F(u,e)]},{type:`gap`,direction:`horizontal`,points:[F(f,e),F(r,e)]})}break;case`side_left`:if(m){let e=(m[0]+m[1])/2;s.push({type:`gap`,direction:`horizontal`,points:[F(a,e),F(t,e)]},{type:`gap`,direction:`horizontal`,points:[F(c,e),F(u,e)]})}break;case`side_top`:if(h){let e=(h[0]+h[1])/2;s.push({type:`gap`,direction:`vertical`,points:[F(e,o),F(e,n)]},{type:`gap`,direction:`vertical`,points:[F(e,l),F(e,d)]})}break;case`side_bottom`:if(h){let e=(h[0]+h[1])/2;s.push({type:`gap`,direction:`vertical`,points:[F(e,l),F(e,d)]},{type:`gap`,direction:`vertical`,points:[F(e,p),F(e,i)]})}}}return SP(s.map(e=>({...e,points:e.points.map(e=>F(yP(e[0]),yP(e[1])))})))},wP=(e,t,n,r,i,a)=>{if(!uP({event:r,selectedElements:e,app:n})||e.length===0||e.length===1&&!dP(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[o,s,c,l]=Wr(t);a&&(a.includes(`e`)?c+=i.x:a.includes(`w`)&&(o+=i.x),a.includes(`n`)?s+=i.y:a.includes(`s`)&&(l+=i.y));let u=[];if(a)switch(a){case`e`:u.push(F(c,s),F(c,l));break;case`w`:u.push(F(o,s),F(o,l));break;case`n`:u.push(F(o,s),F(c,s));break;case`s`:u.push(F(o,l),F(c,l));break;case`ne`:u.push(F(c,s));break;case`nw`:u.push(F(o,s));break;case`se`:u.push(F(c,l));break;case`sw`:u.push(F(o,l))}let d=oP(n.state.zoom.value),f={x:d,y:d},p=[],m=[];_P(t,u,n,r,p,m,f);let h={x:p[0]?.offset??0,y:m[0]?.offset??0};f.x=0,f.y=0,p.length=0,m.length=0;let[g,_,v,y]=Wr(e).map(e=>yP(e));return _P(e,[F(g,_),F(g,y),F(v,_),F(v,y)],n,r,p,m,f),{snapOffset:h,snapLines:xP(p,m)}},TP=(e,t,n,r,i,a)=>{if(!uP({event:n,selectedElements:[e],app:t}))return{snapOffset:{x:0,y:0},snapLines:[]};let o=[F(r.x+i.x,r.y+i.y)],s=oP(t.state.zoom.value),c={x:s,y:s},l=[],u=[];_P([e],o,t,n,l,u,c);let d={x:l[0]?.offset??0,y:u[0]?.offset??0};c.x=0,c.y=0,l.length=0,u.length=0;let f=fP([e],a,{boundingBoxCorners:!0,omitCenter:!0});return _P([e],f,t,n,l,u,c),{snapOffset:d,snapLines:xP(l,u)}},EP=(e,t,n,r,i)=>{if(!uP({event:r,selectedElements:[],app:t}))return{originOffset:{x:0,y:0},snapLines:[]};let a=ln(e,[],t.state,i),o=oP(t.state.zoom.value),s={x:o,y:o},c=[],l=[];for(let e of a){let t=fP([e],i);for(let e of t){let t=e[0]-n.x;Math.abs(t)<=Math.abs(s.x)&&(Math.abs(t)<Math.abs(s.x)&&(l.length=0),l.push({type:`pointer`,points:[e,F(e[0],n.y)],direction:`vertical`}),s.x=t);let r=e[1]-n.y;Math.abs(r)<=Math.abs(s.y)&&(Math.abs(r)<Math.abs(s.y)&&(c.length=0),c.push({type:`pointer`,points:[e,F(n.x,e[1])],direction:`horizontal`}),s.y=r)}}return{originOffset:{x:l.length>0?l[0].points[0][0]-n.x:0,y:c.length>0?c[0].points[0][1]-n.y:0},snapLines:[...l,...c]}},DP=e=>e===A.rectangle||e===A.ellipse||e===A.diamond||e===A.frame||e===A.magicframe||e===A.image||e===A.text,OP=class{constructor(e){V(this,`scene`),V(this,`_getVisibleElementsWithRenderOffsets`,Ze(({visibleElements:e,elementsMap:t,offsets:n,selectedElements:r,frameToHighlight:i,...a})=>{let o=(e,n)=>Uo(e,a.width,a.height,{...a,scrollX:a.scrollX+n.x,scrollY:a.scrollY+n.y},t),s=this.getVisibleSet(e),c=new Set,l=new Set,u=(e,t)=>{s.has(e)!==t&&(t?c:l).add(e)};for(let[e,r]of n){let n=t.get(e);!n||z(n)&&Ws(n,t)||u(n,o(n,r))}if(!c.size&&!l.size)return e;let d=i&&hi(r)!==i.id;if(!c.size&&!d)return e.filter(e=>!l.has(e));let f=[];for(let e of t.values())(c.has(e)||s.has(e)&&!l.has(e))&&f.push(e);return d?this.sortSelectedElementsIntoHighlightedFrame({visibleElements:f,selectedElements:r,frameToHighlight:i}):f})),V(this,`visibleSets`,new WeakMap),V(this,`_getRenderableElements`,Ze(({canvasNonce:e,zoom:t,offsetLeft:n,offsetTop:r,scrollX:i,scrollY:a,height:o,width:s,editingTextElement:c,newElement:l})=>{let u=this.scene.getNonDeletedElements(),{elementsMap:d,newElementCanvasElement:f}=this.getRenderableElementsMap({elements:u,editingTextElement:c,newElement:l});return{elementsMap:d,visibleElements:this.getVisibleCanvasElements({elementsMap:d,zoom:t,offsetLeft:n,offsetTop:r,scrollX:i,scrollY:a,height:o,width:s}),newElementCanvasElement:f,canvasNonce:e}})),V(this,`getRenderableElements`,e=>{let{newElement:t}=e,n=`${this.scene.getSceneNonce()}${t?.frameId?`:${t.versionNonce}`:``}`,r=this._getRenderableElements({canvasNonce:n,zoom:e.zoom,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,scrollX:e.scrollX,scrollY:e.scrollY,height:e.height,width:e.width,editingTextElement:e.editingTextElement,newElement:e.newElement});if(e.frameToHighlight&&e.selectedElementsAreBeingDragged&&hi(e.selectedElements)!==e.frameToHighlight.id){let t=this.sortSelectedElementsIntoHighlightedFrame({visibleElements:r.visibleElements,selectedElements:e.selectedElements,frameToHighlight:e.frameToHighlight});return{...r,visibleElements:t}}return r}),this.scene=e}getVisibleElementsWithRenderOffsets(e,t,n,r){return this._getVisibleElementsWithRenderOffsets({visibleElements:e,elementsMap:t,offsets:r,zoom:n.zoom,scrollX:n.scrollX,scrollY:n.scrollY,offsetLeft:n.offsetLeft,offsetTop:n.offsetTop,width:n.width,height:n.height,selectedElements:this.scene.getSelectedElements(n),frameToHighlight:n.selectedElementsAreBeingDragged?n.frameToHighlight:null})}getVisibleSet(e){let t=this.visibleSets.get(e);return t||(t=new Set(e),this.visibleSets.set(e,t)),t}getVisibleCanvasElements({elementsMap:e,zoom:t,offsetLeft:n,offsetTop:r,scrollX:i,scrollY:a,height:o,width:s}){let c=[];for(let l of e.values())Uo(l,s,o,{zoom:t,offsetLeft:n,offsetTop:r,scrollX:i,scrollY:a},e)&&c.push(l);return c}getRenderableElementsMap({elements:e,editingTextElement:t,newElement:n}){let r=ms(new Map),i=n?.frameId?null:n;for(let n of e)i?.id!==n.id&&(!t||t.type!==`text`||n.id!==t.id)&&r.set(n.id,n);return{elementsMap:r,newElementCanvasElement:i}}sortSelectedElementsIntoHighlightedFrame({visibleElements:e,selectedElements:t,frameToHighlight:n}){if(!t.length)return e;let r=d(t),i=e.filter(e=>!r.has(e.id)),a=wc(i,n.id);return a===null?e:[...i.slice(0,a),...t,...i.slice(a)]}destroy(){Aa.cancel(),this._getRenderableElements.clear(),this._getVisibleElementsWithRenderOffsets.clear()}},kP=5,AP=(e,t,n)=>{let[r,i]=ji(e,n),{x:a,y:o}=lc({sceneX:r+e.width,sceneY:i},t);return{x:a-t.offsetLeft+10,y:o-t.offsetTop}},jP=({children:e,element:t,elementsMap:n})=>{let r=gU();if(r.contextMenu||r.newElement||r.resizingElement||r.isRotating||r.openMenu||r.viewModeEnabled)return null;let{x:i,y:a}=AP(t,r,n);return(0,W.jsx)(`div`,{className:`excalidraw-canvas-buttons`,style:{top:`${a}px`,left:`${i}px`,padding:kP},children:e})},MP=e=>t=>{(0,hl.unstable_batchedUpdates)(e,t)},NP=e=>bi(t=>{(0,hl.unstable_batchedUpdates)(e,t)}),PP=(()=>{let e;try{let t=H.version.split(`.`);e=Number(t[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})(),FP=class e{static start(t,n){if(e.animations.has(t))return;let r={animation:n,lastTime:0,state:void 0};e.animations.set(t,r);let i;try{i=n({deltaTime:0,state:void 0})}catch(n){throw e.animations.get(t)===r&&(e.animations.delete(t),e.cancelScheduledFrameIfIdle()),n}if(e.animations.get(t)===r){if(!i){e.animations.delete(t),e.cancelScheduledFrameIfIdle();return}r.state=i,e.scheduleNextFrame()}}static scheduleNextFrame(){e.scheduledFrame||(PP()?e.scheduledFrame={id:requestAnimationFrame(e.tick),type:`raf`}:e.scheduledFrame={id:setTimeout(e.tick,0),type:`timeout`})}static cancelScheduledFrame(){e.scheduledFrame&&=(e.scheduledFrame.type===`raf`?cancelAnimationFrame(e.scheduledFrame.id):clearTimeout(e.scheduledFrame.id),null)}static cancelScheduledFrameIfIdle(){return e.animations.size>0?!1:(e.cancelScheduledFrame(),!0)}static tick(){if(e.scheduledFrame=null,e.animations.size>0){let t=[...e.animations];for(let[n,r]of t){if(e.animations.get(n)!==r)continue;let t=performance.now(),i=r.lastTime===0?0:t-r.lastTime,a=r.animation({deltaTime:i,state:r.state});if(e.animations.get(n)===r){if(a)r.lastTime=t,r.state=a;else if(e.animations.delete(n),e.cancelScheduledFrameIfIdle())return}}if(e.cancelScheduledFrameIfIdle())return;e.scheduleNextFrame()}}static running(t){return e.animations.has(t)}static cancel(t){e.animations.delete(t),e.cancelScheduledFrameIfIdle()}static reset(){e.animations.clear(),e.cancelScheduledFrame()}};V(FP,`scheduledFrame`,null),V(FP,`animations`,new Map);var IP=FP,LP=class e{constructor(t,n){this.app=t,this.options=n,V(this,`currentTrail`),V(this,`pastTrails`,[]),V(this,`container`),V(this,`trailElement`),V(this,`trailAnimation`),V(this,`key`),this.key=`animated-trail-${e.counter++}`,this.trailElement=document.createElementNS(sc,`path`),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(`http://www.w3.org/2000/svg`,`animate`),this.trailAnimation.setAttribute(`attributeName`,`stroke-dashoffset`),this.trailElement.setAttribute(`stroke-dasharray`,`7 7`),this.trailElement.setAttribute(`stroke-dashoffset`,`10`),this.trailAnimation.setAttribute(`from`,`0`),this.trailAnimation.setAttribute(`to`,`-14`),this.trailAnimation.setAttribute(`dur`,`0.3s`),this.trailElement.appendChild(this.trailAnimation))}get hasCurrentTrail(){return!!this.currentTrail}hasLastPoint(e,t){if(this.currentTrail){let n=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[n-1][0]===e&&this.currentTrail.originalPoints[n-1][1]===t}return!1}cleanup(){this.pastTrails=[],this.currentTrail=void 0,this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}start(e){e&&(this.container=e),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),IP.running(this.key)||IP.start(this.key,()=>this.onFrame()?{keep:!0}:(this.cleanup(),null))}stop(){IP.cancel(this.key),this.cleanup()}startPath(e,t){this.currentTrail=new OM(this.options),this.currentTrail.addPoint([e,t,performance.now()]),this.update()}addPointToPath(e,t){this.currentTrail&&(this.currentTrail.addPoint([e,t,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())}getCurrentTrail(){return this.currentTrail}clearTrails(){this.pastTrails=[],this.currentTrail=void 0,this.update()}update(){this.start(),this.trailAnimation&&(this.trailAnimation.setAttribute(`begin`,`indefinite`),this.trailAnimation.setAttribute(`repeatCount`,`indefinite`))}onFrame(){let e=[];for(let t of this.pastTrails)e.push(this.drawTrail(t,this.app.state));if(this.currentTrail){let t=this.drawTrail(this.currentTrail,this.app.state);e.push(t)}if(this.pastTrails=this.pastTrails.filter(e=>e.getStrokeOutline(e.options.size/this.app.state.zoom.value).length!==0),e.length===0)return this.trailElement.setAttribute(`d`,``),!1;let t=e.join(` `).trim();return this.trailElement.setAttribute(`d`,t),this.trailAnimation?(this.trailElement.setAttribute(`fill`,(this.options.fill??(()=>`black`))(this)),this.trailElement.setAttribute(`stroke`,(this.options.stroke??(()=>`black`))(this))):this.trailElement.setAttribute(`fill`,(this.options.fill??(()=>`black`))(this)),!0}drawTrail(e,t){let n=e.getStrokeOutline(e.options.size/t.zoom.value).map(([e,n])=>{let r=lc({sceneX:e,sceneY:n},t);return[r.x,r.y]}),r=this.trailAnimation?n.slice(0,n.length/2):n;return Vs(r,!0)}};V(LP,`counter`,0);var RP=LP,zP=class{constructor(e){this.app=e,V(this,`localTrail`),V(this,`collabTrails`,new Map),V(this,`container`),this.localTrail=new RP(e,{...this.getTrailOptions(),fill:()=>`red`})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:e=>{let t=Math.max(0,1-(performance.now()-e.pressure)/1e3),n=(50-Math.min(50,e.totalLength-e.currentIndex))/50;return Math.min(Fc(n),Fc(t))}}}startPath(e,t){this.localTrail.startPath(e,t)}addPointToPath(e,t){this.localTrail.addPointToPath(e,t)}endPath(){this.localTrail.endPath()}start(e){this.container=e,this.localTrail.start(e)}stop(){this.localTrail.stop(),this.stopCollabTrails(),this.container=void 0}stopCollabTrails(e){for(let[t,n]of this.collabTrails)e?.get(t)||(n.stop(),this.collabTrails.delete(t))}updateCollabTrails(e){if(this.stopCollabTrails(e),this.container&&e.size!==0)for(let[t,n]of e.entries()){if(n.isCurrentUser)continue;let e=this.collabTrails.get(t);if(e||(e=new RP(this.app,{...this.getTrailOptions(),fill:()=>n.pointer?.laserColor||_O(t,n)}),e.start(this.container),this.collabTrails.set(t,e)),n.pointer&&n.pointer.tool===`laser`){let t=n.button===`down`,r=n.button===`up`,i=e.hasCurrentTrail;t&&!i&&e.startPath(n.pointer.x,n.pointer.y);let a=!e.hasLastPoint(n.pointer.x,n.pointer.y);t&&a&&e.addPointToPath(n.pointer.x,n.pointer.y),r&&i&&(e.addPointToPath(n.pointer.x,n.pointer.y),e.endPath())}}}},BP=12,VP=16,HP=10,UP=VP+2,WP=.8,GP=e=>4/e,KP=(e,t,n)=>{let r=GP(t);if(n!==`desktop`||VP>(e.height+r*2)*t*WP)return null;let i=BP/t,a=VP/t,o=F(e.x+e.width/2,e.y+e.height/2),s=rl(F(o[0]+e.width/2+r+i,o[1]),o,e.angle);return{center:s,start:rl(F(s[0],s[1]-a/2),s,e.angle),end:rl(F(s[0],s[1]+a/2),s,e.angle),hitboxWidth:HP/t,hitboxHeight:UP/t}},qP=(e,t,n,r)=>{let i=KP(t,n,r);if(!i)return!1;let a=rl(F(e.x,e.y),i.center,-t.angle);return Math.abs(a[0]-i.center[0])<=i.hitboxWidth/2&&Math.abs(a[1]-i.center[1])<=i.hitboxHeight/2},JP=(e,t,n,r,i,a)=>{let{zoom:o}=r,s=180*n/Math.PI,c=e*(o.value-1)/2,l=t*(o.value-1)/2;return e>i&&o.value!==1&&(c=i*(o.value-1)/2),t>a&&o.value!==1&&(l=a*(o.value-1)/2),`translate(${c}px, ${l}px) scale(${o.value}) rotate(${s}deg)`},YP=(e,t)=>{let n=e.lastIndexOf(`
|
|
53
|
+
`,Math.max(0,t-1))+1,r=e.indexOf(`
|
|
54
|
+
`,t),i=e.slice(n,r===-1?e.length:r);return Wo(i)?`rtl`:`ltr`},XP=e=>{let t=[0],n=0;for(let r of Array.from(e))n+=r.length,t.push(n);return t},ZP=({text:e,font:t,lineHeightPx:n,direction:r,targetX:i,ownerDocument:a})=>{if(!e||!a.body||typeof a.createRange!=`function`)return null;let o=XP(e),s=a.createElement(`div`),c=a.createTextNode(e),l=a.createRange(),u=[];s.dir=r,Object.assign(s.style,{position:`fixed`,top:`0`,left:`0`,margin:0,padding:0,border:0,opacity:`0`,pointerEvents:`none`,whiteSpace:`pre`,font:t,lineHeight:`${n}px`}),s.append(c),a.body.append(s);try{for(let e of o){l.setStart(c,e),l.setEnd(c,e);let t=l.getBoundingClientRect();if(!Number.isFinite(t.left))return null;u.push(t.left)}}catch{return null}finally{s.remove()}let d=Math.min(...u),f=o[0],p=1/0;for(let e=0;e<o.length;e++){let t=Math.abs(u[e]-d-i);t<p&&(p=t,f=o[e])}return f},QP=({onChange:e,onSubmit:t,getViewportCoords:n,element:r,canvas:i,excalidrawContainer:a,app:o,autoSelect:s=!0,initialCaretSceneCoords:c=null})=>{let l=a?.ownerDocument??document,d=l.defaultView??window,f=null,p=(e,t)=>{if(!t.style.fontFamily||!t.style.fontSize)return!1;let n=t.style.fontFamily.replace(/"/g,``);return ga({fontFamily:e.fontFamily})!==n||`${e.fontSize}px`!==t.style.fontSize},h=o.state.theme,g=()=>{h=o.state.theme;let e=o.state,t=o.scene.getElement(r.id);if(!t)return;let{textAlign:i,verticalAlign:a}=t,s=o.scene.getNonDeletedElementsMap();if(t&&z(t)){let r=t.x,c=t.y,l=Ws(t,o.scene.getNonDeletedElementsMap()),d=t.width,h=t.height,g=t.width,v=t.height;if(l&&t.containerId){if(ye(l)){let e=I.getBoundTextElementPosition(l,t,s);r=e.x,c=e.y}if(g=Ca(l,t),v=Cs(l,t),oe(l)){let{x:e,y:n}=ie(l,t,s);r=e,c=n}else{let e=p(t,_),n;if(e?n=di(l.id,l.height):(n=Tc[l.id],n||=di(l.id,l.height)),!ye(l)&&h>v){let e=m(h,l.type);o.scene.mutateElement(l,{height:e}),u(l,o.scene);return}if(!ye(l)&&l.height>n.height&&h<v){let e=m(h,l.type);o.scene.mutateElement(l,{height:e}),u(l,o.scene)}else{let{x:e,y:n}=ie(l,t,s);r=e,c=n}}}let[y,b]=n(r,c);l?d+=.5:(g=(e.width-8-y)/e.zoom.value,d=Math.min(d,g)),h*=1.05;let x=Ro(t),S=jo(t,l),C=(e.height-b)/e.zoom.value;Object.assign(_.style,{font:x,lineHeight:t.lineHeight,width:`${d}px`,height:`${h}px`,left:`${y}px`,top:`${b}px`,transform:JP(d,h,S,e,g,C),textAlign:i,verticalAlign:a,color:Zc(t.strokeColor,e.theme===P.DARK),opacity:t.opacity/100,maxHeight:`${C}px`}),f={angle:S,font:x,height:t.height,lineHeightPx:qo(t.fontSize,t.lineHeight),textAlign:i,width:t.width,x:r,y:c},_.scrollTop=0,ei()&&(_.style.fontFamily=ga(t)),o.scene.mutateElement(t,{x:r,y:c})}},_=l.createElement(`textarea`);_.dir=`auto`,_.tabIndex=0,_.dataset.type=`wysiwyg`,_.wrap=`off`,_.classList.add(`excalidraw-wysiwyg`);let v=`pre`,y=`normal`;(_s(r)||!r.autoResize)&&(v=`pre-wrap`,y=`break-word`),Object.assign(_.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:y,whiteSpace:v,overflowWrap:`break-word`,boxSizing:`content-box`}),_.value=r.originalText,g();let b=()=>{if(!c||!f)return null;let e=f,t=F(e.x+e.width/2,e.y+e.height/2),[n,r]=rl(F(c.x,c.y),t,-e.angle),i=n-e.x,a=r-e.y,o=ol(_.value,e.font,v===`pre-wrap`?e.width:1/0),s=o[Math.max(0,Math.min(o.length-1,Math.floor(a/e.lineHeightPx)))],u=YP(_.value,s.start),d=Xt(s.text,e.font),p=i-(e.textAlign===`center`?(e.width-d)/2:e.textAlign===`right`?e.width-d:0);if(!s.text)return s.start;let m=ZP({text:s.text,font:e.font,lineHeightPx:e.lineHeightPx,direction:u,targetX:p,ownerDocument:l});return s.start+(m||0)},x=(()=>{let e=b();return e===null?null:{start:e,end:e}})();e&&(_.onpaste=async e=>{let t=zD(e),n=null;if(t.has(M.excalidrawClipboard)||t.has(M.excalidraw)){e.preventDefault(),n=await BD(e);try{let e=await VD(n);if(e.elements){let t=xs(e.elements);if(t){let{selectionStart:e,selectionEnd:n,value:r}=_;_.value=r.slice(0,e)+t+r.slice(n);let i=e+t.length;_.selectionStart=_.selectionEnd=i,_.dispatchEvent(new Event(`input`))}}return}catch{console.warn(`failed to parse excalidraw clipboard data`)}}n||=await BD(e);let i=n.findByType(M.text);if(!i)return;let a=T(i.value);if(!a)return;let s=Ws(r,o.scene.getNonDeletedElementsMap());if(s){let e=Ga(s,o.scene.getNonDeletedElementsMap()),t=Ro({fontSize:oe(s)&&e?e.fontSize:o.state.currentItemFontSize,fontFamily:oe(s)&&e?e.fontFamily:o.state.currentItemFontFamily}),n=Ca(s,e),{selectionStart:r,selectionEnd:i,value:c}=_,l=c.slice(0,r)+a+c.slice(i),u=En(l,t,n),d=Math.min(wi(u,t),n);_.style.width=`${d}px`}},_.oninput=()=>{let t=T(_.value);if(_.value!==t){let e=_.selectionStart;_.value=t,_.selectionStart=e,_.selectionEnd=e}e(_.value)}),_.onkeydown=e=>{if(!e.shiftKey&&HE.keyTest(e))e.preventDefault(),o.actionManager.executeAction(HE),g();else if(!e.shiftKey&&UE.keyTest(e))e.preventDefault(),o.actionManager.executeAction(UE),g();else if(!e.shiftKey&&WE.keyTest(e))e.preventDefault(),o.actionManager.executeAction(WE),g();else if(AE.keyTest(e))o.actionManager.executeAction(AE);else if(jE.keyTest(e))o.actionManager.executeAction(jE);else if(e.key===L.ESCAPE)e.preventDefault(),te=!0,O();else if(rO.keyTest(e))e.preventDefault(),O(),o.actionManager.executeAction(rO);else if(e.key===L.ENTER&&e[L.CTRL_OR_CMD]){if(e.preventDefault(),e.isComposing||e.keyCode===229)return;te=!0,O()}else if(e.key===L.TAB||e[L.CTRL_OR_CMD]&&(e.code===xt.BRACKET_LEFT||e.code===xt.BRACKET_RIGHT)){if(e.preventDefault(),e.isComposing)return;e.shiftKey||e.code===xt.BRACKET_LEFT?E():w(),_.dispatchEvent(new Event(`input`))}};let S=` `.repeat(4),C=RegExp(`^ {1,4}`),w=()=>{let{selectionStart:e,selectionEnd:t}=_,n=D(),r=_.value;n.forEach(e=>{let t=r.slice(0,e),n=r.slice(e);r=`${t}${S}${n}`}),_.value=r,_.selectionStart=e+4,_.selectionEnd=t+4*n.length},E=()=>{let{selectionStart:e,selectionEnd:t}=_,n=D(),r=[],i=_.value;n.forEach(e=>{let t=i.slice(e,e+4).match(C);t&&(i=`${i.slice(0,e)}${i.slice(e+t[0].length)}`,r.push(e))}),_.value=i,r.length&&(e>r[r.length-1]?_.selectionStart=Math.max(e-4,r[r.length-1]):_.selectionStart=e,_.selectionEnd=Math.max(_.selectionStart,t-4*r.length))},D=()=>{let{selectionStart:e,selectionEnd:t,value:n}=_,r=n.slice(0,e).match(/[^\n]*$/)[0].length;return e-=r,n.slice(e,t).split(`
|
|
55
|
+
`).reduce((t,n,r,i)=>t.concat(r?t[r-1]+i[r-1].length+1:e),[]).reverse()},ee=e=>{e.target instanceof d.HTMLCanvasElement&&(e.preventDefault(),e.stopPropagation())},te=!1,O=()=>{if(le)return;le=!0,k();let e=o.scene.getElement(r.id);if(!e)return;let n=Ws(e,o.scene.getNonDeletedElementsMap());if(n){if(_.value.trim()){let e=Mr(n);!e||e!==r.id?o.scene.mutateElement(n,{boundElements:(n.boundElements||[]).concat({type:`text`,id:r.id})}):ye(n)&&_r(n)}else o.scene.mutateElement(n,{boundElements:n.boundElements?.filter(e=>!z(e))});gt(e,n,o.scene)}t({viaKeyboard:te,nextOriginalText:_.value})},k=()=>{_.onblur=null,_.oninput=null,_.onkeydown=null,ue&&ue.disconnect(),d.removeEventListener(`resize`,g),d.removeEventListener(`wheel`,ee,!0),d.removeEventListener(`pointerdown`,re),d.removeEventListener(`pointerup`,A),d.removeEventListener(`blur`,O),d.removeEventListener(`beforeunload`,O),se(),ae(),ce(),_.remove()},A=e=>{d.removeEventListener(`pointerup`,A);let t=e?.target,n=t instanceof d.HTMLElement&&t.classList.contains(`properties-trigger`),r=(t instanceof d.HTMLElement||t instanceof d.SVGElement)&&!!t.closest(`.properties-content`),i=(t instanceof d.HTMLElement||t instanceof d.SVGElement)&&(!!t.closest(`.${Ai.SHAPE_ACTIONS_MENU}`)||!!t.closest(`.compact-shape-actions-island`));d.setTimeout(()=>{i||n||r||(_.onblur=O,_.focus(),x&&=(_.setSelectionRange(x.start,x.end),null))})},ne=()=>{_.onblur=null,d.addEventListener(`pointerup`,A),d.addEventListener(`blur`,O)},re=e=>{let t=e?.target;if(e.button===Kn.WHEEL){t instanceof d.HTMLTextAreaElement&&(e.preventDefault(),o.pan.start(e)),ne();return}let n=t instanceof d.HTMLElement&&t.classList.contains(`properties-trigger`),r=(t instanceof d.HTMLElement||t instanceof d.SVGElement)&&!!t.closest(`.properties-content`);(e.target instanceof d.HTMLElement||e.target instanceof d.SVGElement)&&(e.target.closest(`.${Ai.SHAPE_ACTIONS_MENU}, .${Ai.ZOOM_ACTIONS}`)||e.target.closest(`.compact-shape-actions-island`))&&!tl(e.target)||n||r?ne():e.target instanceof d.HTMLCanvasElement&&!ei()&&d.requestAnimationFrame(()=>{O()})},ae=o.onChangeEmitter.on(e=>{o.state.theme!==h&&g()}),se=o.scene.onUpdate(()=>{g(),l.activeElement?.closest(`.properties-content`)||_.focus()}),ce=o.onScrollChangeEmitter.on(()=>{g()}),le=!1;s&&!x&&_.select(),A();let ue=null;return i&&`ResizeObserver`in d?(ue=new d.ResizeObserver(()=>{g()}),ue.observe(i)):d.addEventListener(`resize`,g),_.onpointerdown=e=>e.stopPropagation(),d.requestAnimationFrame(()=>{d.addEventListener(`pointerdown`,re,{capture:!0})}),d.addEventListener(`beforeunload`,O),a?.querySelector(`.excalidraw-textEditorContainer`).appendChild(_),O},$P=4,eF=6,tF=`rgba(0,0,0,0.3)`,nF=(e,t,n,r)=>{if(!e.size)return{horizontal:null,vertical:null};let[i,a,o,s]=Wr(e),c=t/r.zoom.value,l=n/r.zoom.value,u={top:parseInt(ho(`sat`))||0,bottom:parseInt(ho(`sab`))||0,left:parseInt(ho(`sal`))||0,right:parseInt(ho(`sar`))||0},d=tx().rtl,f=-r.scrollX+u.left,p=-r.scrollY+u.top,m=f+c-u.right,h=p+l-u.bottom,g=Math.min(i,f),_=Math.min(a,p),v=Math.max(o,m),y=Math.max(s,h),b=o-i,x=s-a,S=v-g,C=y-_,w=Math.max($P*2,u.left+u.right)+eF*2,T=c/S*t-w,E=Math.max($P*2,u.top+u.bottom)+eF*2,D=l/C*n-E,ee=S>b?S*r.zoom.value/(T+w):t/(T+w),te=C>x?C*r.zoom.value/(D+E):n/(D+E);return{horizontal:f===g&&m===v?null:{x:Math.max(u.left,$P)+eF+(f-g)/S*t,y:n-eF-Math.max($P,u.bottom),width:T,height:eF,deltaMultiplier:ee},vertical:p===_&&h===y?null:{x:d?Math.max(u.left,$P):t-eF-Math.max(u.right,$P),y:Math.max(u.top,$P)+eF+(p-_)/C*n,width:eF,height:D,deltaMultiplier:te}}},rF=(e,t,n)=>{let[r,i]=[e.horizontal,e.vertical].map(e=>e!=null&&e.x<=t&&t<=e.x+e.width&&e.y<=n&&n<=e.y+e.height);return{isOverEither:r||i,isOverHorizontal:r,isOverVertical:i}},iF=e=>RegExp(`^(?:%%{.*?}%%[\\s\\n]*)?\\b(?:${[`flowchart`,`graph`,`sequenceDiagram`,`classDiagram`,`stateDiagram`,`stateDiagram-v2`,`erDiagram`,`journey`,`gantt`,`pie`,`quadrantChart`,`requirementDiagram`,`gitGraph`,`C4Context`,`mindmap`,`timeline`,`zenuml`,`sankey`,`xychart`,`block`].map(e=>`\\s*${e}(-beta)?`).join(`|`)})\\b`).test(e.trim()),aF=e=>{let{lassoPath:t,elements:n,elementsMap:r,elementsSegments:i,intersectedElements:a,enclosedElements:s,simplifyDistance:c,mode:l=`contain`}=e,u=t;c&&(u=eb(t,c));let d=n.filter(e=>!e.locked&&!_s(e));s.clear(),a.clear();let f=t.reduce((e,t)=>[Math.min(e[0],t[0]),Math.min(e[1],t[1]),Math.max(e[2],t[0]),Math.max(e[3],t[1])],[1/0,1/0,-1/0,-1/0]),p=vr(u),m=[f[0]-kt,f[1]-kt,f[2]+kt,f[3]+kt];for(let e of d){let t=o(e,r),n=oF(e,t,r),c=sF(t,n);if(vs(f,c)&&!a.has(e.id)&&!s.has(e.id)){if(l===`contain`&&!Gs(m,c))continue;let t=dF(p,cF(e,r,i,n),c,l);l===`contain`?t&&!mF(u,e,r,n)&&s.add(e.id):t?s.add(e.id):mF(u,e,r,n)&&a.add(e.id)}}return{selectedElementIds:l===`contain`?uF([...s],r):[...a,...s]}},oF=(e,t,n)=>{let r=Oe(e,n);if(!r)return null;let i=o(r,n);return Gs(i,t)?null:zo(e,r,n)?i:null},sF=(e,t)=>t?[Math.max(e[0],t[0]),Math.max(e[1],t[1]),Math.min(e[2],t[2]),Math.min(e[3],t[3])]:e,cF=(e,t,n,r)=>{let i=n.get(e.id)??[],a=Ga(e,t),o=a?n.get(a.id):null,s=o?.length?[...i,...o]:i;return r?lF(s,r):s},lF=(e,t)=>{let[n,r,i,a]=t,o=[];for(let[[t,s],[c,l]]of e){let e=c-t,u=l-s,d=0,f=1,p=!0;for(let[o,c]of[[-e,t-n],[e,i-t],[-u,s-r],[u,a-s]]){if(o===0){if(c<0){p=!1;break}continue}let e=c/o;if(o<0){if(e>f){p=!1;break}d=Math.max(d,e)}else{if(e<d){p=!1;break}f=Math.min(f,e)}}p&&o.push(Ie(F(t+d*e,s+d*u),F(t+f*e,s+f*u)))}return o},uF=(e,t)=>{if(!e.some(e=>t.get(e)?.groupIds.length))return e;let n=new Map;for(let e of t.values()){let t=e.groupIds.at(-1);if(!t||e.locked||_s(e))continue;let r=n.get(t);r?r.push(e.id):n.set(t,[e.id])}if(!n.size)return e;let r=new Set(e);return e.filter(e=>{let i=t.get(e)?.groupIds.at(-1),a=i?n.get(i):null;return!a||a.every(e=>r.has(e))})},dF=(e,t,n,r)=>{let i=r===`contain`?`every`:`some`,a=t=>ee(t,e)||r===`contain`&&pF(t,e);return t.length===0?fF(n)[i](a):t[i](e=>e[i](a))},fF=([e,t,n,r])=>[F(e,t),F(n,t),F(n,r),F(e,r)],pF=(e,t)=>t.some((n,r)=>r>0&&qr(e,Ie(t[r-1],n))),mF=(e,t,n,r)=>{let i=e.slice(1).map((t,n)=>Ie(e[n],t)).concat([Ie(e[e.length-1],e[0])]),a=Ga(t,n),o=(e,t)=>{let i=Jt(e,n,t,0,!r);return r?i.some(e=>Yo(e,r)):i.length>0};return i.some(e=>o(t,e)||!!a&&o({...a,...ie(t,a,n)},e))},hF=class extends RP{constructor(e){super(e,{animateTrail:!0,streamline:.4,sizeMapping:e=>{let t=Math.max(0,1-(performance.now()-e.pressure)/(1/0)),n=(5e3-Math.min(5e3,e.totalLength-e.currentIndex))/5e3;return Math.min(Fc(n),Fc(t))},fill:()=>Gr(Fo(e.interactiveCanvas),.05),stroke:()=>Fo(e.interactiveCanvas)}),V(this,`intersectedElements`,new Set),V(this,`enclosedElements`,new Set),V(this,`elementsSegments`,null),V(this,`canvasTranslate`,null),V(this,`keepPreviousSelection`,!1),V(this,`selectElementsFromIds`,e=>{this.app.setState(t=>{let n=e.reduce((e,t)=>(e[t]=!0,e),{});if(this.keepPreviousSelection)for(let e of Object.keys(t.selectedElementIds))n[e]=!0;for(let[e]of Object.entries(n)){let t=this.app.scene.getNonDeletedElement(e);if(t&&R(t)){let e=Ti(this.app.scene.getNonDeletedElementsMap(),t.id);for(let t of e)delete n[t.id]}}let r=To({editingGroupId:t.editingGroupId,selectedElementIds:n},this.app.scene.getNonDeletedElements(),t,this.app),i=[...Object.keys(r.selectedElementIds)],a=[...Object.keys(r.selectedGroupIds)];return{selectedElementIds:r.selectedElementIds,selectedGroupIds:r.selectedGroupIds,selectedLinearElement:i.length===1&&!a.length&&ro(this.app.scene.getNonDeletedElement(i[0]))?new I(this.app.scene.getNonDeletedElement(i[0]),this.app.scene.getNonDeletedElementsMap()):null}})}),V(this,`addPointToPath`,(e,t,n=!1)=>{super.addPointToPath(e,t),this.keepPreviousSelection=n,this.updateSelection()}),V(this,`updateSelection`,()=>{let e=super.getCurrentTrail()?.originalPoints?.map(e=>F(e[0],e[1])),t={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!Us(t,this.canvasTranslate??{})){this.canvasTranslate=t,this.elementsSegments=new Map;let e=d(this.app.visibleElements);for(let t of this.app.visibleElements){let n=oc(t,e);this.elementsSegments.set(t.id,n)}}if(e){let{selectedElementIds:t}=aF({lassoPath:e,elements:this.app.visibleElements,elementsMap:this.app.scene.getNonDeletedElementsMap(),elementsSegments:this.elementsSegments,intersectedElements:this.intersectedElements,enclosedElements:this.enclosedElements,simplifyDistance:5/this.app.state.zoom.value,mode:this.app.state.boxSelectionMode});this.selectElementsFromIds(t)}})}startPath(e,t,n=!1){this.endPath(),super.startPath(e,t),this.intersectedElements.clear(),this.enclosedElements.clear(),this.keepPreviousSelection=n,this.keepPreviousSelection||this.app.setState({selectedElementIds:{},selectedGroupIds:{},selectedLinearElement:null})}endPath(){super.endPath(),super.clearTrails(),this.intersectedElements.clear(),this.enclosedElements.clear(),this.elementsSegments=null}},gF=class extends RP{constructor(e){super(e,{streamline:.2,size:5,keepHead:!0,sizeMapping:e=>{let t=Math.max(0,1-(performance.now()-e.pressure)/200),n=(10-Math.min(10,e.totalLength-e.currentIndex))/10;return Math.min(Fc(n),Fc(t))},fill:()=>e.state.theme===P.LIGHT?`rgba(0, 0, 0, 0.2)`:`rgba(255, 255, 255, 0.2)`}),V(this,`elementsToErase`,new Set),V(this,`groupsToErase`,new Set)}startPath(e,t){this.endPath(),super.startPath(e,t),this.elementsToErase.clear()}addPointToPath(e,t,n=!1){return super.addPointToPath(e,t),this.updateElementsToBeErased(n)}updateElementsToBeErased(e){let t=super.getCurrentTrail()?.originalPoints?.map(e=>F(e[0],e[1]))||[];if(t.length<2)return[];let n=Ie(t[t.length-1],t[t.length-2]),r=this.app.visibleElements.filter(e=>!e.locked),i=d(r);for(let t of r)if(e&&this.elementsToErase.has(t.id)){if(_F(n,t,i,this.app.state.zoom.value)){let e=t.groupIds.at(-1);if(this.groupsToErase.has(e)){let t=Er(this.app.scene.getNonDeletedElementsMap(),e);for(let e of t)this.elementsToErase.delete(e.id);this.groupsToErase.delete(e)}if(_s(t)&&this.elementsToErase.delete(t.containerId),xr(t)){let e=Mr(t);e&&this.elementsToErase.delete(e)}this.elementsToErase.delete(t.id)}}else if(!e&&!this.elementsToErase.has(t.id)&&_F(n,t,i,this.app.state.zoom.value)){let e=t.groupIds.at(-1);if(!this.groupsToErase.has(e)){let t=Er(this.app.scene.getNonDeletedElementsMap(),e);for(let e of t)this.elementsToErase.add(e.id);this.groupsToErase.add(e)}if(xr(t)){let e=Mr(t);e&&this.elementsToErase.add(e)}_s(t)&&this.elementsToErase.add(t.containerId),this.elementsToErase.add(t.id)}return Array.from(this.elementsToErase)}endPath(){super.endPath(),super.clearTrails(),this.elementsToErase.clear(),this.groupsToErase.clear()}},_F=(e,t,n,r)=>{let i=e[1],a=xc(t)?15:t.strokeWidth/2,s=[Math.min(e[0][0],e[1][0])-a,Math.min(e[0][1],e[1][1])-a,Math.max(e[0][0],e[1][0])+a,Math.max(e[0][1],e[1][1])+a],c=o(t,n),u=[c[0]-a,c[1]-a,c[2]+a,c[3]+a];if(!vs(s,u))return!1;if(lo(t)&&Vn(i,t,n))return!0;if(xc(t)){let i=lr(t),a=Ci(t,i,n),o=Math.max(2.25,5/r);for(let t of a)if(l(t,e)<=o)return!0;let s=Dr(...i.map(([e,n])=>F(t.x+e,t.y+n)));return!!ee(e[0],s)}let d=Ga(t,n);if(ye(t)||oa(t)&&!t.polygon){let i=Math.max(t.strokeWidth,t.strokeWidth*2/r),a=oc(t,n);for(let t of a)if(l(t,e)<=i)return!0;return!1}return Jt(t,n,e,0,!0).length>0||!!d&&Jt({...d,...ie(t,d,n)},n,e,0,!0).length>0},vF=44,yF=22,bF=66,xF=48,SF=14,CF=304,wF=320,TF=5.87,EF=28,DF=4,OF=2,kF=10,AF=10,jF=8,MF=12,NF=256,PF=10,FF=4,IF=MF*2,LF=MF*2,RF=100,zF=140,BF=.35,VF=MF/2,HF=20,UF=MF*2,WF=MF,GF={fillStyle:`hachure`,fontFamily:jr,fontSize:20,opacity:100,roughness:1,strokeColor:Ma.black,roundness:null,strokeStyle:`solid`,strokeWidth:1,verticalAlign:$t.MIDDLE,locked:!1},KF=rn(4),qF=e=>e.labels?.length??e.series[0]?.values.length??0,JF=(e,t)=>{if(!e)return!1;let n=qF(e);return n<2?!1:t!==`radar`||n>=3},YF=(e,t)=>e+(t<=1?0:Math.min(bF,(t-1)*yF)),XF=(e,t)=>{if(e===`line`){let e=YF(xF,t);return{slotWidth:e,gap:SF,chartHeight:wF,xLabelMaxWidth:e+SF*3+kF}}let n=YF(vF,t);return{slotWidth:n,gap:SF,chartHeight:CF,xLabelMaxWidth:n+SF*3+kF}},ZF=(e,t)=>({chartWidth:(t.slotWidth+t.gap)*e.series[0].values.length+t.gap,chartHeight:t.chartHeight+t.gap*2}),QF=()=>({chartWidth:NF+LF*2,chartHeight:NF+LF*2}),$F=(e,t,n)=>{let r=Math.abs(e-t);return Math.min(r,n-r)},eI=(e,t)=>{if(e<=0||KF.length===0)return[];let n=KF.length,r=(t%n+n)%n,i=[r],a=Math.min(e,n),o=new Set(Array.from({length:n},(e,t)=>t).filter(e=>e!==r));for(;i.length<a;){let e=-1,t=-1,r=-1;for(let a of o){let o=i.map(e=>$F(a,e,n)),s=Math.min(...o),c=o.reduce((e,t)=>e+t,0)/o.length;(s>t||s===t&&c>r)&&(e=a,t=s,r=c)}i.push(e),o.delete(e)}return Array.from({length:e},(e,t)=>KF[i[t%i.length]])},tI=e=>{if(KF.length===0)return 0;if(typeof e!=`number`||!Number.isFinite(e))return Math.floor(Math.random()*KF.length);let t=e.toString(),n=0;for(let e=0;e<t.length;e++)n=n*31+t.charCodeAt(e)|0;return Math.abs(n)%KF.length},nI=e=>KF[e],rI=(e,t)=>{let n=e.flatMap(e=>e.values.map(e=>Math.max(0,e))),r=n.filter(e=>e>0),i=Math.max(1,...n),a=r.length>0?Math.min(...r):1,o=e.length===1&&a>0&&i/a>=RF;return{renderSteps:!1,normalize:(e,t)=>{let n=Math.max(0,e);return o?Math.log10(n+1)/Math.log10(i+1):n/i}}},iI=e=>/\s/.test(e.trim()),aI=(e,t,n)=>iI(e)?En(e,t,n):e,oI=(e,t,n,r,i,a)=>{let o=On.Excalifont,s=qc.sm,c=qt(o),l=Ro({fontFamily:o,fontSize:s}),u=Math.min(zF,i*(e.length>8?.56:.72)),d=la(l,c),f=e.map((e,f)=>{let p=t[f],m=Math.max(0,...e.trim().split(/\s+/).filter(Boolean).map(e=>Di(e,l,c).width)),h=aI(e,l,Math.max(d,u,m)),g=Di(h,l,c),_=Math.cos(p),v=Math.sin(p),y=_>BF?`left`:_<-BF?`right`:`center`,b=y===`center`?g.width/2:0,x=IF+(Math.abs(_)*b+Math.abs(v)*(g.height/2))+VF,S=n+_*(i+x),C=r+v*(i+x),w=v>BF?MF/3:v<-BF?-MF/3:0;return Ir({backgroundColor:a,...GF,text:h,originalText:e,x:S,y:C+w,fontFamily:o,fontSize:s,lineHeight:c,textAlign:y,verticalAlign:`middle`})});return{axisLabels:f,axisLabelTopY:Math.min(...f.map(e=>e.y)),axisLabelBottomY:Math.max(...f.map(e=>e.y+e.height))}},sI=(e,t,n,r,i,a)=>{if(e.length<=1)return[];let o=On[`Lilita One`],s=qc.lg,c=qt(o),l=Ro({fontFamily:o,fontSize:s}),u=e.map((e,n)=>{let r=e.title?.trim()||`Series ${n+1}`,i=aI(r,l,NF),a=Di(i,l,c),o=HF+WF+a.width;return{label:r,displayLabel:i,color:t[n],width:o,height:a.height}}),d=Math.max(HF/2,...u.map(e=>e.height/2)),f=Math.max(i,r+d+IF),p=UF,m=HF*.6,h=u.reduce((e,t)=>e+t.width,0)+UF*Math.max(0,u.length-1),g=h+p*2,_=d*2+m*2,v=[];v.push(At({...GF,backgroundColor:`transparent`,type:`rectangle`,fillStyle:`solid`,strokeColor:Ma.black,x:n-g/2,y:f-_/2,width:g,height:_,roughness:Ct.architect,roundness:{type:Pa.PROPORTIONAL_RADIUS}}));let y=n-h/2;return u.forEach(e=>{v.push(At({...GF,backgroundColor:e.color,type:`rectangle`,x:y,y:f-HF/2,width:HF,height:HF,fillStyle:`solid`,strokeColor:e.color,roughness:Ct.architect,roundness:{type:Pa.PROPORTIONAL_RADIUS}})),v.push(Ir({...GF,text:e.displayLabel,originalText:e.label,autoResize:!1,x:y+HF+WF,y:f,fontFamily:o,fontSize:s,lineHeight:c,textAlign:`left`,verticalAlign:`middle`})),y+=e.width+UF}),v},cI=(e,t,n,r)=>{if(Di(e,n,r).width<=t)return e;let i=e.length;for(;i>1;){let a=`${e.slice(0,i)}...`;if(Di(a,n,r).width<=t)return a;i--}return e[0]?`${e[0]}...`:e},lI=(e,t,n,r)=>{if(Di(e,n,r).width<=t)return{wrapped:!1,text:e};let i=e.trim().split(/\s+/).filter(Boolean);return i.length>1&&!i.some(e=>Di(e,n,r).width>t)&&t>=la(n,r)?{wrapped:!0,text:En(e,n,t)}:{wrapped:!1,text:cI(e,t,n,r)}},uI=(e,t,n)=>{let r=Math.abs(Math.cos(n)),i=Math.abs(Math.sin(n));return{width:e*r+t*i,height:e*i+t*r}},dI=e=>e.includes(`...`),fI=(e,t,n,r,i)=>{let a=Math.max(EF,Math.ceil(la(r,i))),o=Math.max(a,Math.floor(t)),s=[];for(let e=o;e>=a;e-=4)s.push(e);s[s.length-1]!==a&&s.push(a);let c=e=>({ellipsified:dI(e.text),visibleChars:e.text.replace(/\.\.\./g,``).replace(/\n/g,``).length,lineCount:e.text.split(`
|
|
56
|
+
`).length}),l=(e,t)=>{let n=c(e),r=c(t);return n.ellipsified===r.ellipsified?n.visibleChars===r.visibleChars?n.lineCount===r.lineCount?e.rotatedHeight<t.rotatedHeight:n.lineCount<r.lineCount:n.visibleChars>r.visibleChars:!n.ellipsified},u=null,d=null,f=null;for(let t of s){let{wrapped:a,text:o}=lI(e,t,r,i),s=Di(o,r,i),c=uI(s.width,s.height,TF),p={originalText:e,text:o,metrics:s,rotatedWidth:c.width,rotatedHeight:c.height,wrapped:a},m=c.width-n;if(m<=0){(!u||l(p,u))&&(u=p);continue}(!d||m<d.overflow||m===d.overflow&&l(p,d.spec))&&(d={overflow:m,spec:p}),!dI(p.text)&&(!f||m<f.overflow||m===f.overflow&&l(p,f.spec))&&(f={overflow:m,spec:p})}return u||(f&&d&&f.overflow<=d.overflow+jF?f.spec:d.spec)},pI=e=>{if(e.type!==`text`)return e.y+e.height;let t=uI(e.width,e.height,e.angle);return e.y+e.height/2+t.height/2},mI=(e,t,n,r,i)=>{let a=GF.fontFamily,o=qc.sm,s=qt(a),c=Ro({fontFamily:a,fontSize:o}),l=Math.max(1,i.slotWidth+i.gap-DF*2+AF),u=n;return e.labels?.map((e,n)=>{let a=fI(e,i.xLabelMaxWidth,l,c,s),d=t+n*(i.slotWidth+i.gap)+i.gap+i.slotWidth/2,f=u+OF+(a.rotatedHeight-a.metrics.height)/2;return Ir({backgroundColor:r,...GF,text:a.text,originalText:a.wrapped?e:a.text,autoResize:!a.wrapped,x:d,y:f,angle:TF,fontSize:o,lineHeight:s,textAlign:`center`,verticalAlign:`top`})})||[]},hI=(e,t,n,r,i,a=Math.max(...e.series[0].values))=>{let o=Ir({backgroundColor:r,...GF,x:t-i.gap,y:n-i.gap,text:`0`,textAlign:`right`});return[o,Ir({backgroundColor:r,...GF,x:t-i.gap,y:n-i.chartHeight-o.height/2,text:a.toLocaleString(),textAlign:`right`})]},gI=(e,t,n,r,i)=>{let{chartWidth:a,chartHeight:o}=ZF(e,i);return[wt({backgroundColor:r,...GF,type:`line`,x:t,y:n,width:a,points:[F(0,0),F(a,0)]}),wt({backgroundColor:r,...GF,type:`line`,x:t,y:n,height:o,points:[F(0,0),F(0,-o)]}),wt({backgroundColor:r,...GF,type:`line`,x:t,y:n-i.chartHeight-i.gap,strokeStyle:`dotted`,width:a,opacity:PF,points:[F(0,0),F(a,0)]})]},_I=(e,t,n,r,i,a=Math.max(...e.series[0].values),o)=>{let{chartWidth:s,chartHeight:c}=ZF(e,i),l=e.title?Ir({backgroundColor:r,...GF,text:e.title,x:t+s/2,y:n-i.chartHeight-i.gap*2-20,roundness:null,textAlign:`center`,fontSize:qc.xl,fontFamily:On[`Lilita One`]}):null,u=o?At({backgroundColor:r,...GF,type:`rectangle`,x:t,y:n-c,width:s,height:c,strokeColor:Ma.black,fillStyle:`solid`,opacity:6}):null;return[...u?[u]:[],...l?[l]:[],...mI(e,t,n,r,i),...hI(e,t,n,r,i,a),...gI(e,t,n,r,i)]},vI=(e,t,n,r)=>{let i=e.series,a=XF(`bar`,i.length),o=Math.max(1,...i.flatMap(e=>e.values.map(e=>Math.max(0,e)))),s=tI(r),c=nI(s),l=eI(i.length,s),u=i.length>1?Math.max(1,Math.floor(a.gap/(i.length+1))):0,d=i.length>1?Math.max(2,(a.slotWidth-u*(i.length-1))/i.length):a.slotWidth,f=i.length*d+u*(i.length-1),p=(a.slotWidth-f)/2,m=i[0].values.flatMap((e,r)=>i.map((e,s)=>{let f=Math.max(0,e.values[r]??0)/o*a.chartHeight,m=i.length>1?l[s]:c;return At({backgroundColor:m,...GF,type:`rectangle`,fillStyle:i.length>1?`solid`:GF.fillStyle,strokeColor:i.length>1?m:GF.strokeColor,x:t+r*(a.slotWidth+a.gap)+a.gap+p+s*(d+u),y:n-f-a.gap,width:d,height:f})})),h=_I(e,t,n,c,a,o,rt()),g=mI(e,t,n,c,a),_=Math.max(n+a.gap/2,...g.map(e=>pI(e))),{chartWidth:v}=ZF(e,a),y=sI(i,l,t+v/2,_,n+a.gap*5,c);return[...h,...m,...y]},yI=(e,t,n,r)=>{let i=e.series,a=XF(`line`,i.length),o=Math.max(1,...i.flatMap(e=>e.values)),s=tI(r),c=nI(s),l=eI(i.length,s),u=i.map((e,r)=>{let i=e.values.map((e,t)=>F(t*(a.slotWidth+a.gap),-(e/o)*a.chartHeight)),s=Math.max(...i.map(e=>e[0])),c=Math.max(...i.map(e=>e[1])),u=Math.min(...i.map(e=>e[0])),d=Math.min(...i.map(e=>e[1]));return wt({backgroundColor:`transparent`,...GF,type:`line`,x:t+a.gap+a.slotWidth/2,y:n-a.gap,height:c-d,width:s-u,strokeColor:l[r],strokeWidth:2,points:i})}),d=i.flatMap((e,r)=>e.values.map((e,i)=>{let s=i*(a.slotWidth+a.gap)+a.gap/2,c=-(e/o)*a.chartHeight+a.gap/2;return At({backgroundColor:l[r],...GF,fillStyle:`solid`,strokeColor:l[r],strokeWidth:2,type:`ellipse`,x:t+s+a.slotWidth/2,y:n+c-a.gap*2,width:a.gap,height:a.gap})})),f=i[0].values.map((e,t)=>Math.max(0,...i.map(e=>e.values[t]??0))).map((e,r)=>{let i=r*(a.slotWidth+a.gap)+a.gap/2,s=e/o*a.chartHeight+a.gap/2+a.gap;return wt({backgroundColor:c,...GF,type:`line`,x:t+i+a.slotWidth/2+a.gap/2,y:n-s,height:s,strokeStyle:`dotted`,opacity:PF,points:[F(0,0),F(0,s)]})}),p=_I(e,t,n,c,a,o,rt()),m=mI(e,t,n,c,a),h=Math.max(n+a.gap/2,...m.map(e=>pI(e))),{chartWidth:g}=ZF(e,a),_=sI(i,l,t+g/2,h,n+a.gap*5,c);return[...p,...u,...f,...d,..._]},bI=e=>{let t=/^([-+]?)[$\u20AC\u00A3\u00A5\u20A9]?([-+]?)([\d.,]+)[%]?$/.exec(e);return t?parseFloat(`${(t[1]||t[2])+t[3]}`.replace(/,/g,``)):null},xI=(e,t)=>e.slice(1).every(e=>bI(e[t])!==null),SI=e=>{let t=e[0].length;if(t>2){let n=e[0].every(e=>bI(e)===null),r=n?e.slice(1):e;if(r.length<1)return{ok:!1,reason:`No data rows`};if(r.some(e=>e.slice(1).some(e=>bI(e)===null)))return{ok:!1,reason:`Value is not numeric`};if(t-1>r.length){let t=n?e[0].slice(1).map(e=>e.trim()):null,i=r.map(e=>({title:e[0]?.trim()||null,values:e.slice(1).map(e=>bI(e))}));return{ok:!0,data:{title:i.length===1?i[0].title:n&&e[0][0].trim()||null,labels:t,series:i}}}let i=e[0].slice(1).map((e,t)=>{let i=t+1,a=`Series ${i}`;return{title:n&&e.trim()||a,values:r.map(e=>bI(e[i]))}});return{ok:!0,data:{title:n&&e[0][0].trim()||null,labels:r.map(e=>e[0]),series:i}}}if(t===1){if(!xI(e,0))return{ok:!1,reason:`Value is not numeric`};let t=bI(e[0][0])===null,n=t?e[0][0]:null,r=(t?e.slice(1):e).map(e=>bI(e[0]));return r.length<2?{ok:!1,reason:`Less than two rows`}:{ok:!0,data:{title:n,labels:null,series:[{title:n,values:r}]}}}let n=bI(e[0][1])===null,r=n?e.slice(1):e;if(r.length<2)return{ok:!1,reason:`Less than 2 rows`};if(r.some(e=>bI(e[1])===null))return{ok:!1,reason:`Value is not numeric`};let i=n?e[0][1]:null;return{ok:!0,data:{title:i,labels:r.map(e=>e[0]),series:[{title:i,values:r.map(e=>bI(e[1]))}]}}},CI=e=>{let t=t=>e.replace(/\r\n?/g,`
|
|
57
|
+
`).split(`
|
|
58
|
+
`).filter(e=>e.trim().length>0).map(e=>e.split(t).map(e=>e.trim())),n=[` `,`,`,`;`].map(e=>{let n=t(e),r=n[0]?.length??0;return{delimiter:e,parsed:n,numCols:r,isConsistent:n.length>0&&n.every(e=>e.length===r)}}),r=(n.find(e=>e.isConsistent&&e.numCols>1)??n.find(e=>e.isConsistent)??n[0]).parsed;if(r.length===0)return{ok:!1,reason:`No values`};let i=r[0].length;return r.every(e=>e.length===i)?SI(r):{ok:!1,reason:`All rows don't have same number of columns`}},wI=(e,t,n,r)=>{if(!JF(e,`radar`))return null;let i=e.labels??e.series[0].values.map((e,t)=>`Value ${t+1}`),a=e.series,{normalize:o,renderSteps:s}=rI(a,i.length),c=tI(r),l=nI(c),u=eI(a.length,c),{chartWidth:d,chartHeight:f}=QF(),p=t+d/2,m=n-f/2,h=NF/2,g=i.map((e,t)=>-Math.PI/2+Math.PI*2*t/i.length),{axisLabels:_,axisLabelTopY:v,axisLabelBottomY:y}=oI(i,g,p,m,h,l),b=On[`Lilita One`],x=qc.xl,S=qt(b),C=Ro({fontFamily:b,fontSize:x}),w=e.title?aI(e.title,C,d+IF*2):null,T=w?Di(w,C,S):null,E=w?Ir({backgroundColor:l,...GF,text:w,originalText:e.title??w,x:t+d/2,y:v-IF-T.height/2,fontFamily:b,fontSize:x,lineHeight:S,textAlign:`center`}):null,D=s?Array.from({length:FF},(e,t)=>{let n=(t+1)/FF,r=h*n,i=g.map(e=>F(Math.cos(e)*r,Math.sin(e)*r));return i.push(F(i[0][0],i[0][1])),wt({backgroundColor:`transparent`,...GF,type:`line`,x:p,y:m,width:r*2,height:r*2,strokeStyle:`solid`,roughness:Ct.architect,opacity:PF,polygon:!0,points:i})}):[],ee=g.map(e=>{let t=Math.cos(e)*h,n=Math.sin(e)*h;return wt({backgroundColor:`transparent`,...GF,type:`line`,x:p,y:m,width:Math.abs(t),height:Math.abs(n),strokeStyle:`solid`,roughness:Ct.architect,opacity:PF,points:[F(0,0),F(t,n)]})}),te=a.map((e,t)=>{let n=g.map((t,n)=>{let r=e.values[n]??0,i=o(r,n)*h;return F(Math.cos(t)*i,Math.sin(t)*i)});return n.push(F(n[0][0],n[0][1])),wt({backgroundColor:`transparent`,...GF,type:`line`,x:p,y:m,width:h*2,height:h*2,strokeColor:u[t],strokeWidth:2,polygon:!0,points:n})}),O=sI(a,u,p,y,n+MF*5,l);return[...E?[E]:[],..._,...D,...ee,...te,...O]},TI=(e,t,n,r,i)=>e===`line`?yI(t,n,r,i):e===`radar`?wI(t,n,r,i):vI(t,n,r,i),EI=class{constructor(e){this.app=e,V(this,`updateHoveredAnchor`,e=>{let t=this.app.state.activeTool.type===`text`&&!this.app.state.editingTextElement&&!this.app.state.newElement?this.getAnchorAtPosition(e.x,e.y):null,n=this.app.state.hoveredArrowTextAnchor;return(n?.elementId!==t?.elementId||n?.anchor!==t?.anchor)&&this.app.setState({hoveredArrowTextAnchor:t}),t}),V(this,`refresh`,()=>{this.app.lastPointerMoveCoords&&this.updateHoveredAnchor(this.app.lastPointerMoveCoords)})}getBindableEndpointAtPosition(e,t){if(!ze(this.app.state))return null;let n=Mo(F(e,t),this.app.scene.getNonDeletedElements(),this.app.scene.getNonDeletedElementsMap(),this.app.state.zoom);if(!n||this.app.getTextElementAtPosition(e,t))return null;let r=this.app.getElementAtPosition(e,t,{includeLockedElements:!0});return r&&r.id!==n.arrow.id&&this.app.scene.getElementIndex(r.id)>this.app.scene.getElementIndex(n.arrow.id)?null:n}getAnchorAtPosition(e,t){let n=this.getBindableEndpointAtPosition(e,t);if(n)return{elementId:n.arrow.id,anchor:n.startOrEnd};let r=this.app.getTextBindableContainerAtPosition(e,t);return!ye(r)||Ga(r,this.app.scene.getNonDeletedElementsMap())?null:this.app.getTextWysiwygSnappedToCenterPosition(e,t,this.app.state,r)?{elementId:r.id,anchor:`label`}:null}getTextBinding({arrow:e,startOrEnd:t},n){return Ic(e,t,this.app.scene.getNonDeletedElementsMap(),n)}bindText({arrow:e,startOrEnd:t},n,r){Ce(e,n,t,r,this.app.scene)}maybeDragNewText(e,t){return!z(e)||!Ho(e,this.app.scene.getNonDeletedElementsMap())?!1:(sl({newElement:e,...cs(e),pointerX:t.x,zoom:this.app.state.zoom.value,scene:this.app.scene}),!0)}isBoundTextGrabbable(e,t,n){if(!ye(e)||!Ac(F(t,n),e,this.app.scene.getNonDeletedElementsMap()))return!1;let r=this.app.getElementsAtPosition(t,n),i=r.findIndex(t=>t.id===e.id);return i!==-1&&!r.slice(i+1).some(e=>this.app.hitElement(t,n,e,!1))}maybeDragLabel(e,t,n){if(!t.hit.arrowLabel)return!1;if(this.app.cursor.set(jt.GRABBING),e.isDragging||zt(F(t.origin.x,t.origin.y),F(n.x,n.y))>=10/this.app.state.zoom.value){let r=I.handleBoundTextDragging(e,this.app.scene,n.x,n.y);r&&(t.drag.hasOccurred=!0,this.app.setState({selectedLinearElement:r}))}return!0}getLabelCenter(e){let t=this.app.scene.getNonDeletedElementsMap();if(!ye(e))return null;let n=Ga(e,t);if(!n)return null;let{x:r,y:i}=I.getBoundTextElementPosition(e,n,t);return{x:r+n.width/2,y:i+n.height/2}}},DI=Je.filter(e=>e!==Ma.white),OI=class{constructor(e){this.app=e,V(this,`temporaryEyeDropper`,null),V(this,`pending`,null),V(this,`handlePointerDown`,e=>{this.pending=e}),V(this,`handlePointerUp`,()=>{let e=this.pending;this.pending=null,e&&this.fill(e)}),V(this,`cancel`,()=>{this.pending=null}),V(this,`cycleBackgroundColor`,()=>{let e=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor),t=DI[(DI.indexOf(e)+1)%DI.length];this.app.actionManager.executeAction(DE,`keyboard`,{currentItemBackgroundColor:t})}),V(this,`openTemporaryEyeDropper`,()=>{if(Kb.get(eT))return;let e={colorPickerType:`elementBackground`,keepOpenOnAlt:!0,onSelect:e=>{this.app.actionManager.executeAction(DE,`ui`,{currentItemBackgroundColor:e})}};this.temporaryEyeDropper=e,this.app.updateEditorAtom(eT,e)}),V(this,`closeTemporaryEyeDropper`,()=>{let e=this.temporaryEyeDropper;this.temporaryEyeDropper=null,e&&Kb.get(eT)===e&&this.app.updateEditorAtom(eT,null)}),V(this,`restyle`,e=>{let t=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor);e.backgroundColor===t&&e.fillStyle===this.app.state.currentItemFillStyle&&e.opacity===this.app.state.currentItemOpacity||(this.app.scene.mutateElement(e,{backgroundColor:t,fillStyle:this.app.state.currentItemFillStyle,opacity:this.app.state.currentItemOpacity}),Nn.delete(e),this.app.scheduleCapture())}),V(this,`fill`,e=>{let t=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor),n=this.app.scene.getNonDeletedElements(),r=this.app.scene.getNonDeletedElementsMap(),i=F(e.x,e.y),a=this.app.getElementAtPosition(i[0],i[1]),o=ec({point:i,elements:n,elementsMap:r});if(!o.ok){if(a&&ve(a)){this.restyle(a);return}o.reason===`too_complex`?this.app.setToast({message:K(`bucketfill.tooComplex`),duration:3e3}):(o.reason===`open_region`||o.reason===`too_small`||o.reason===`invalid_polygon`)&&this.app.setToast({message:K(`bucketfill.noRegion`),duration:3e3});return}if(a&&ri({hitElement:a,scenePoints:o.scenePoints,elementsMap:r})){this.restyle(a);return}let{width:s,height:c}=io(o.scenePoints),[l,u]=o.scenePoints[0],d=o.scenePoints.map(e=>F(e[0]-l,e[1]-u)),f=o.ownerId?r.get(o.ownerId):null,p=f?R(f)?f.id:f.frameId:this.app.getTopLayerFrameAtSceneCoords(e)?.id??null,m=f?f.groupIds:o.boundaryElementIds.map(e=>r.get(e)?.groupIds).filter(e=>!!e).reduce((e,t)=>e===null?t:e.filter(e=>t.includes(e)),null)??[],h=wt({type:`line`,x:l,y:u,width:s,height:c,points:d,polygon:!0,strokeColor:`transparent`,backgroundColor:t,fillStyle:this.app.state.currentItemFillStyle,strokeWidth:1,strokeStyle:`solid`,roughness:0,roundness:null,opacity:this.app.state.currentItemOpacity,frameId:p,groupIds:m}),g=this.app.scene.getElementsIncludingDeleted().findIndex(e=>e.id===o.insertion.elementId);this.app.scene.insertElementsAtIndex([h],g<0?null:o.insertion.placement===`above`?g+1:g),this.app.scheduleCapture()}),V(this,`getBucketFillBackgroundColor`,(e,t)=>Ke(e)?Ma.green[1]:Zc(e,t===P.DARK))}},kI=(e,t,n)=>({x:e.x-t/2,y:e.y-n/2,width:t,height:n}),AI={stickynote:{createElement:(e,t)=>{let{state:n}=e;return dn({type:`stickynote`,...kI(t,250,250),baseHeight:250,strokeColor:n.currentItemStickynoteStrokeColor,backgroundColor:n.currentItemStickynoteBackgroundColor,fillStyle:n.currentItemFillStyle,strokeWidth:e.getCurrentItemStrokeWidth(`stickynote`),strokeStyle:n.currentItemStrokeStyle,roughness:n.currentItemRoughness,opacity:n.currentItemOpacity,roundness:e.getCurrentItemRoundness(`stickynote`),locked:!1,frameId:e.getTopLayerFrameAtSceneCoords(t)?.id??null})},onDrop:(e,t)=>{oe(t)&&e.startTextEditing({sceneX:t.x+t.width/2,sceneY:t.y+t.height/2,container:t})}}},jI=.5,MI=class{constructor(e){this.app=e,V(this,`preview`,null),V(this,`armed`,null),V(this,`tool`,null),V(this,`type`,null),V(this,`isDragging`,()=>this.preview!==null),V(this,`handleButtonPointerDown`,(e,t)=>{let n=AI[e];return!n||t.button!==0||!this.app.isInteractionEnabled()?!1:(this.cancel(),this.armed={type:e,pointerId:t.pointerId,clientX:t.clientX,clientY:t.clientY},this.tool=n,this.type=e,this.addListeners(),!0)}),V(this,`onPointerMove`,e=>{if(!this.armed||e.pointerId!==this.armed.pointerId)return;if(!this.preview){if(Math.hypot(e.clientX-this.armed.clientX,e.clientY-this.armed.clientY)<10)return;Vw(`toolbar`,this.armed.type,`drag`)}let t=this.tool.createElement(this.app,Qn(e,this.app.state)),[n,r]=Po(t.x,t.y,e[L.CTRL_OR_CMD]?null:this.app.getEffectiveGridSize());this.preview={...t,x:n,y:r},this.app.triggerRender()}),V(this,`onPointerUp`,e=>{if(!this.armed||e.pointerId!==this.armed.pointerId)return;let{preview:t,tool:n,type:r}=this;if(!t){this.cancel();return}if(this.cancel(),!this.isOverCanvas(e))return;let{app:i}=this;i.insertNewElement(t),i.store.scheduleCapture(),i.setState({selectedElementIds:{[t.id]:!0},selectedGroupIds:{}}),i.setActiveTool({type:i.state.preferredSelectionTool.type},{keepSelection:!0}),Vw(`toolbar`,r,`drop`),n.onDrop?.(i,t)}),V(this,`onKeyDown`,e=>{e.key===L.ESCAPE&&(e.stopPropagation(),this.cancel())}),V(this,`cancel`,()=>{let e=this.preview!==null;this.armed=null,this.tool=null,this.type=null,this.preview=null,this.removeListeners(),e&&this.app.triggerRender()}),V(this,`isOverCanvas`,e=>!!(this.app.ownerDocument.elementFromPoint?.(e.clientX,e.clientY)??e.target)?.closest?.(`.excalidraw__canvas`)),V(this,`addListeners`,()=>{let{ownerWindow:e}=this.app;e.addEventListener(B.POINTER_MOVE,this.onPointerMove),e.addEventListener(B.POINTER_UP,this.onPointerUp),e.addEventListener(B.POINTER_CANCEL,this.cancel),e.addEventListener(B.BLUR,this.cancel),e.addEventListener(B.KEYDOWN,this.onKeyDown,!0)}),V(this,`removeListeners`,()=>{let{ownerWindow:e}=this.app;e.removeEventListener(B.POINTER_MOVE,this.onPointerMove),e.removeEventListener(B.POINTER_UP,this.onPointerUp),e.removeEventListener(B.POINTER_CANCEL,this.cancel),e.removeEventListener(B.BLUR,this.cancel),e.removeEventListener(B.KEYDOWN,this.onKeyDown,!0)})}};V(MI,`isDraggable`,e=>e in AI);var NI=`<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">`,PI=`<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"/>`,FI=`<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"/>`,II=`data:${M.svg},${encodeURIComponent(`${NI}${FI}</svg>`)}`,LI=`data:${M.svg},${encodeURIComponent(`${NI}${PI}${FI}</svg>`)}`,RI=e=>{let t=eS.map((t,n)=>`<path d="${t}" ${n<2?`fill="${e}"`:``} />`).join(``);return`data:${M.svg},${encodeURIComponent(`<svg viewBox="0 0 24 24" width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke-linecap="round" stroke-linejoin="round"><g stroke="#fff" fill="#fff" stroke-width="5">${t}</g><g stroke="#1b1b1f" stroke-width="1.25">${t}</g></svg>`)}`},zI=class{constructor(e){this.app=e,V(this,`toolCursorMemo`,null),V(this,`eraserCanvasCache`,null),V(this,`eraserPreviewDataURL`,null),V(this,`set`,e=>{this.toolCursorMemo=null,this.canvas&&(this.canvas.style.cursor=e)}),V(this,`reset`,()=>{this.app.state.viewModeEnabled&&!this.app.isActiveToolPointerCapturing()?this.app.isNavigationEnabled()?this.set(jt.GRAB):this.clear():this.applyForTool()}),V(this,`applyForTool`,(e=this.app.state.activeTool)=>{let t=this.canvas;if(!t)return;let n=e.type===`eraser`||e.type===`laser`||e.type===`bucketfill`?this.app.state.theme:void 0,r=e.type===`bucketfill`?this.app.bucketFill.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor,n):void 0,i=this.toolCursorMemo;if(i?.canvas!==t||i.type!==e.type||i.bucketFillColor!==r||i.theme!==n){if(e.type===`selection`)this.clear();else if(wr({activeTool:e}))this.set(jt.GRAB);else if(Ba({activeTool:e}))this.applyEraser();else if(e.type===`autoshape`)this.set(jt.CROSSHAIR);else if(e.type===`bucketfill`)this.set(`url(${RI(r)}) 5 18, auto`);else if(e.type===`laser`){let e=this.app.state.theme===P.LIGHT?II:LI;this.set(`url(${e}), auto`)}else[`image`,`custom`].includes(e.type)?e.type!==`image`&&this.set(jt.AUTO):this.set(jt.CROSSHAIR);this.toolCursorMemo={canvas:t,type:e.type,bucketFillColor:r,theme:n}}}),V(this,`refreshHover`,()=>{let e=this.app.lastPointerMoveEvent??this.app.lastPointerUpEvent;if(!e||!this.canvas)return;let t=e.pointerType;if(t&&t!==`mouse`)return;let n=typeof PointerEvent<`u`?PointerEvent:MouseEvent;this.canvas.dispatchEvent(new n(`pointermove`,{bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY}))}),V(this,`clear`,()=>{this.set(``)}),V(this,`applyEraser`,()=>{let e=this.app.state.theme;if(!this.eraserCanvasCache||this.eraserCanvasCache.theme!==e){let t=e===P.DARK;this.eraserCanvasCache=document.createElement(`canvas`),this.eraserCanvasCache.theme=e,this.eraserCanvasCache.height=20,this.eraserCanvasCache.width=20;let n=this.eraserCanvasCache.getContext(`2d`);n.lineWidth=1,n.beginPath(),n.arc(this.eraserCanvasCache.width/2,this.eraserCanvasCache.height/2,5,0,2*Math.PI),n.fillStyle=t?`#000`:`#fff`,n.fill(),n.strokeStyle=t?`#fff`:`#000`,n.stroke(),this.eraserPreviewDataURL=this.eraserCanvasCache.toDataURL(M.svg)}this.set(`url(${this.eraserPreviewDataURL}) 10 10, auto`)})}get canvas(){return this.app.interactiveCanvas}},BI=class{constructor(e){this.app=e,V(this,`trail`),this.trail=new RP(this.app,{...this.getTrailOptions(),fill:()=>e.state.theme===P.LIGHT?`rgba(0, 0, 0, 0.2)`:`rgba(255, 255, 255, 0.2)`})}getTrailOptions(){return{simplify:0,streamline:.4,size:1,sizeMapping:()=>fi(al(`line`,this.app.state.currentItemStrokeWidthKey)*.65*this.app.state.zoom.value,1.25,4)}}startPath(e,t){this.trail.startPath(e,t)}addPointToPath(e,t){this.trail.addPointToPath(e,t)}endPath(){this.trail.endPath()}clearTrails(){this.trail.clearTrails()}getCurrentPoints(){let e=this.trail.getCurrentTrail();return e?e.originalPoints.map(([e,t])=>F(e,t)):[]}start(e){this.trail.start(e)}stop(){this.trail.stop()}},VI=class{constructor(e){this.app=e,V(this,`trail`),V(this,`gestureInProgress`,!1),V(this,`stop`,()=>{this.trail.stop()}),V(this,`hasPendingGesture`,()=>this.gestureInProgress),V(this,`handlePointerDown`,e=>{this.gestureInProgress&&this.app.actionManager.executeAction(_D),this.gestureInProgress=!0,this.trail.startPath(e.lastCoords.x,e.lastCoords.y)}),V(this,`handlePointerMove`,e=>it(this.app,e)),V(this,`bindRecognizedArrow`,e=>{let{app:t}=this,n=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=kn(t.state.zoom),a=[`start`,`end`].map(t=>{let a=I.getPointAtIndexGlobalCoordinates(e,t===`start`?0:-1,n);return{startOrEnd:t,globalPoint:a,target:Et(a,r,n,i)}}),o=!!a[0].target&&a[0].target===a[1].target,s=t.state.isMidpointSnappingEnabled&&!t.state.gridModeEnabled;for(let{startOrEnd:n,globalPoint:r,target:i}of a)i&&kc(e,i,o?`inside`:`orbit`,n,t.scene,r,t.state.isBindingEnabled,s);if(o)return;let c=new Map;for(let{startOrEnd:t,target:r}of a){if(!r)continue;let i=Qi(e,t===`start`?`startBinding`:`endBinding`,t===`start`?e.startBinding:e.endBinding,r,n);i&&c.set(t===`start`?0:e.points.length-1,{point:i})}c.size&&I.movePoints(e,t.scene,c)}),V(this,`maybeUpgradeLineToArrow`,e=>{let{app:t}=this,n=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=kn(t.state.zoom),[a,o]=[0,-1].map(t=>Et(I.getPointAtIndexGlobalCoordinates(e,t,n),r,n,i));return!a&&!o||a===o?null:sn({type:`arrow`,x:e.x,y:e.y,width:e.width,height:e.height,startArrowhead:null,endArrowhead:t.state.currentItemEndArrowhead,points:e.points,groupIds:e.groupIds,frameId:e.frameId,locked:!1,angle:e.angle,strokeColor:e.strokeColor,backgroundColor:e.backgroundColor,fillStyle:e.fillStyle,roughness:e.roughness,opacity:e.opacity,strokeStyle:e.strokeStyle,strokeWidth:e.strokeWidth})}),V(this,`finalize`,()=>{let{app:e}=this,t=this.gestureInProgress?this.trail.getCurrentPoints():[];if(this.gestureInProgress=!1,this.trail.endPath(),t.length>=3){let n=e.state.newElement||sr(t,e.state,e.scene.getNonDeletedElementsMap(),e.state.newElement,e.scene.getNonDeletedFramesLikes());if(n){let t={...n,seed:Zt(),opacity:e.state.currentItemOpacity};e.state.isBindingEnabled&&oa(t)&&(t=this.maybeUpgradeLineToArrow(t)??t),e.insertNewElement(t),e.state.isBindingEnabled&&mo(t)&&this.bindRecognizedArrow(t)}}this.trail.clearTrails()}),this.trail=new BI(e)}},HI=class e{constructor(e){this.app=e,V(this,`creator`,new Oa),V(this,`navigator`,new si),V(this,`clear`,()=>{this.creator.clear(),this.navigator.clear()}),V(this,`handleKeyEvent`,e=>{let t=this.resolveKeyboardEventToOperation(e);switch(t.type){case`none`:return!1;case`canceled`:return this.app.triggerRender(!0),!0;case`creating`:return e.preventDefault(),t.pending.length&&this.app.revealIfHidden(t.pending),!0;case`navigating`:{e.preventDefault();let n=t.nodeId&&this.app.scene.getNonDeletedElementsMap().get(t.nodeId);return n&&this.selectAndReveal(n),!0}case`committed`:{t.nodes.length&&this.app.insertNewElements(t.nodes);let e=t.nodes[0];return e&&this.selectAndReveal(e),this.captureUpdate(),!0}case`navigationEnded`:return this.captureUpdate(),!0}})}get pendingNodes(){return this.creator.pendingNodes}get isCreatingChart(){return this.creator.isCreatingChart}resolveKeyboardEventToOperation(t){let{creator:n,navigator:r,app:i}=this;if(t.type===`keydown`){if(t.key===L.ESCAPE&&n.isCreatingChart)return n.clear(),{type:`canceled`};if(!Yr(t.key))return{type:`none`};if(t[L.CTRL_OR_CMD]&&!t.shiftKey){let r=ot(i.scene.getNonDeletedElementsMap(),i.state);return r.length===1&&$r(r[0])&&n.createNodes(r[0],i.state,e.getLinkDirectionFromKey(t.key),i.scene),{type:`creating`,pending:n.pendingNodes??[]}}if(t.altKey){let n=i.scene.getNonDeletedElementsMap(),a=ot(n,i.state);if(a.length===1)return{type:`navigating`,nodeId:r.exploreByDirection(a[0],n,e.getLinkDirectionFromKey(t.key))}}return{type:`none`}}let a=!t.altKey&&r.isExploring;if(a&&r.clear(),!t[L.CTRL_OR_CMD]&&n.isCreatingChart){let e=n.pendingNodes??[];return n.clear(),{type:`committed`,nodes:e}}return a?{type:`navigationEnded`}:{type:`none`}}selectAndReveal(e){this.app.setState(t=>({selectedElementIds:yi({[e.id]:!0},t)})),this.app.revealIfHidden([e])}captureUpdate(){this.app.syncActionResult({captureUpdate:N.IMMEDIATELY})}static getLinkDirectionFromKey(e){switch(e){case L.ARROW_UP:return`up`;case L.ARROW_DOWN:return`down`;case L.ARROW_RIGHT:return`right`;case L.ARROW_LEFT:return`left`;default:return`right`}}},UI=5,WI=class{constructor(e,t){this.app=e,this.dependencies=t,V(this,`spaceHeld`,!1),V(this,`active`,!1),V(this,`secondary`,null),V(this,`suppressNextContextMenu`,!1),V(this,`pendingMoveFlush`,null),V(this,`teardown`,null),V(this,`isActive`,()=>this.active),V(this,`isSpaceHeld`,()=>this.spaceHeld),V(this,`setSpaceHeld`,e=>{this.spaceHeld=e}),V(this,`flushMove`,()=>{this.pendingMoveFlush?.()}),V(this,`end`,()=>{this.teardown?.()}),V(this,`consumesContextMenuEvent`,()=>this.secondary?(this.secondary.nativeMenuSeen=!0,!0):this.suppressNextContextMenu?(this.suppressNextContextMenu=!1,!0):!1),V(this,`start`,e=>{let{app:t}=this;this.suppressNextContextMenu=!1;let n=e.button===Kn.SECONDARY;if(!(this.dependencies.getPointerCount()<=1&&((e.button===Kn.WHEEL||n||e.button===Kn.MAIN&&this.spaceHeld||wr(t.state))&&(t.isInteractionEnabled()||t.isNavigationEnabled())||t.state.viewModeEnabled&&!t.isActiveToolPointerCapturing())))return!1;this.active=!0,this.secondary=n?{engaged:!1,nativeMenuSeen:!1}:null,t.focusContainer(),t.state.editingTextElement||e.preventDefault();let r=!1,i=/Linux/.test(t.ownerWindow.navigator.platform);this.secondary||t.cursor.set(jt.GRABBING);let{clientX:a,clientY:o}=e,{clientX:s,clientY:c}=e,l=NP(e=>{if(this.secondary&&!this.secondary.engaged){if(Math.hypot(e.clientX-a,e.clientY-o)<=UI)return;this.secondary.engaged=!0,t.cursor.set(jt.GRABBING),s=e.clientX,c=e.clientY;return}let n=s-e.clientX,l=c-e.clientY;if(s=e.clientX,c=e.clientY,i&&!r&&(Math.abs(n)>1||Math.abs(l)>1)){r=!0;let e=n=>{t.ownerDocument.body.removeEventListener(B.PASTE,e),n.stopPropagation()},n=()=>{setTimeout(()=>{t.ownerDocument.body.removeEventListener(B.PASTE,e),t.ownerWindow.removeEventListener(B.POINTER_UP,n)},100)};t.ownerDocument.body.addEventListener(B.PASTE,e),t.ownerWindow.addEventListener(B.POINTER_UP,n)}t.viewport.translate(e=>({scrollX:e.scrollX-n/e.zoom.value,scrollY:e.scrollY-l/e.zoom.value}))});this.pendingMoveFlush=l.flush;let u=MP(e=>{let{secondary:n}=this;this.teardown=null,this.pendingMoveFlush=null,this.active=!1,this.secondary=null,n?.engaged&&!n.nativeMenuSeen&&(this.suppressNextContextMenu=!0),this.spaceHeld||t.cursor.reset(),t.setState({cursorButton:`up`},()=>{if(t.state.cursorButton===`up`){let n=e&&`clientX`in e?e:{clientX:s,clientY:c};t.savePointer(n.clientX,n.clientY,`up`)}t.viewport.releaseOverscroll()}),t.ownerWindow.removeEventListener(B.POINTER_MOVE,l),t.ownerWindow.removeEventListener(B.POINTER_UP,u),t.ownerWindow.removeEventListener(B.BLUR,u),l.flush(),n&&!n.engaged&&n.nativeMenuSeen&&e&&`clientX`in e&&t.openContextMenu({clientX:e.clientX,clientY:e.clientY,button:e.button,pointerType:e.pointerType})});return this.teardown=u,t.ownerWindow.addEventListener(B.BLUR,u),t.ownerWindow.addEventListener(B.POINTER_MOVE,l,{passive:!0}),t.ownerWindow.addEventListener(B.POINTER_UP,u),!0})}},GI=`animateScrollToContent`,KI=`animateScrollConstraintsSnapBack`,qI=500,JI=250,YI=200,XI=302,ZI={full:216,compact:64},QI=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return typeof t.x==`number`&&typeof t.y==`number`&&(t.width==null||typeof t.width==`number`)&&(t.height==null||typeof t.height==`number`)},$I=(e,t)=>{let n=t.get(e);return n?[n]:Er(t,e)},eL=(e,t,n)=>{if(typeof e==`string`){let n=Qe(e),r=n?`link`:`element`,i=n?li(e):e,a=i?$I(i,t):[];return a.length?{bounds:Wr(a,t),type:r}:{bounds:null,type:r}}if(nr(e))return{bounds:e,type:`area`};if(QI(e)&&!nl(e)){let t=e.width??n.width,r=e.height??n.height;return{bounds:[e.x,e.y,e.x+t,e.y+r],type:`area`}}let r=Array.isArray(e)?e:[e],i=r.reduce((e,n)=>{if(n&&!n.isDeleted){let r=t.get(n.id);r&&e.push(r)}return e},[]),a=!i.length;return(i.length!==r.length||a)&&console.warn(`supplied element target(s) for setViewport contain deleted or non-existent elements which have been filtered out`),a?{bounds:null,type:`element`}:{bounds:Wr(i,t),type:`element`}},tL=e=>e===!1?0:e===!0||e==null?150:Math.max(e,0),nL=(e,t,n=`scale-down`,r)=>{let{appState:i}=Ss({bounds:t,appState:e,fit:n,canvasOffsets:r,steppedZoom:!1});return{scrollX:i.scrollX,scrollY:i.scrollY,zoom:i.zoom}},rL=(e,t,{fit:n,offsets:r,lock:i})=>{let a=nL(e,t,n,r);if(!i?.scroll&&!i?.zoom)return{...a,scrollConstraints:null};let[o,s,c,l]=t,u={x:o,y:s,width:c-o,height:l-s,lockScroll:!!i.scroll,lockZoom:!!i.zoom,zoom:a.zoom.value,overscroll:tL(i.overscroll),offsets:r};return{...Eo({...e,...a,scrollConstraints:u}),scrollConstraints:u}},iL=({from:e,target:t,factor:n})=>{if(n>=1)return{...t};let r=e.zoom.value*(t.zoom.value/e.zoom.value)**+n,i=t.zoom.value===e.zoom.value?n:(r-e.zoom.value)/(t.zoom.value-e.zoom.value);return{scrollX:((1-i)*e.scrollX*e.zoom.value+i*t.scrollX*t.zoom.value)/r,scrollY:((1-i)*e.scrollY*e.zoom.value+i*t.scrollY*t.zoom.value)/r,zoom:{value:r}}},aL=e=>e===!1?null:e===!0||e==null?qI:e.duration??qI,oL=(e,t,n,r,i)=>{IP.start(GI,({deltaTime:a,state:o})=>{let s=(o?.elapsed??0)+a,c=Math.min(s/n,1),l=Fc(fi(c,0,1));return c<1?(r({...iL({from:e,target:t,factor:l}),shouldCacheIgnoreZoom:!0}),{elapsed:s}):(i(),null)})},sL=(e,t,n=JI)=>{let r=Eo(e);if(r.scrollX===e.scrollX&&r.scrollY===e.scrollY&&r.zoom.value===e.zoom.value||IP.running(GI))return;let i=(e.scrollX-r.scrollX)*e.zoom.value,a=(e.scrollY-r.scrollY)*e.zoom.value;IP.start(KI,({deltaTime:e,state:r})=>{let o=(r?.elapsed??0)+e,s=Math.min(o/n,1),c=1-Fc(fi(s,0,1));return t(e=>{if(!e.scrollConstraints)return null;let t=Eo(e),n=t.zoom.value;return{scrollX:t.scrollX+i*c/n,scrollY:t.scrollY+a*c/n,zoom:t.zoom}}),s<1?{elapsed:o}:null})},cL=class{constructor(e,t){this.app=e,this.dependencies=t,V(this,`lastPosition`,{x:0,y:0}),V(this,`activeTransition`,null),V(this,`uiLastMeasured`,new Map),V(this,`invalidateUIOffset`,e=>{this.uiLastMeasured.delete(e)}),V(this,`resolveOffsets`,e=>{if(!e)return e;let{ui:t,...n}=e;if(!t)return n;let r=this.getOffsets(t===!0?void 0:t);return{top:n.top??r.top,right:n.right??r.right,bottom:n.bottom??r.bottom,left:n.left??r.left}}),V(this,`getOffsets`,e=>{let t=this.dependencies.getContainer(),n=t?.getBoundingClientRect(),r=tx().rtl,i={top:0,right:0,bottom:0,left:0},a=new Set;if(t&&n)for(let e of t.querySelectorAll(`[data-viewport-ui]`)){let t=e.getBoundingClientRect(),r={top:t.top-n.top,right:t.right-n.left,bottom:t.bottom-n.top,left:t.left-n.left,width:t.width};switch(e.dataset.viewportUi){case`top`:i.top=Math.max(i.top,r.bottom);break;case`bottom`:i.bottom=Math.max(i.bottom,this.app.state.height-r.top);break;case`side`:{let[t,n]=r.left+r.width/2<this.app.state.width/2?[`left`,r.right]:[`right`,this.app.state.width-r.left];i[t]=Math.max(i[t],n);let o=e.dataset.viewportUiName;o&&(a.add(o),n>0&&this.uiLastMeasured.set(o,{side:t,offset:n}));break}}}if(e?.reserve&&this.app.editorInterface.formFactor!==`phone`){let t=(e,t)=>{if(a.has(e))return;let{side:n,offset:r}=this.uiLastMeasured.get(e)??t;i[n]=Math.max(i[n],r)};e.reserve.stylesPanel&&t(`stylesPanel`,{side:r?`right`:`left`,offset:this.dependencies.getStylesPanelMode()===`compact`?ZI.compact:ZI.full}),e.reserve.sidebar&&t(`sidebar`,{side:r?`left`:`right`,offset:XI})}let o=e?.padding??24,s=e?.paddingTop??o,c=(r?e?.paddingLeft:e?.paddingRight)??o,l=e?.paddingBottom??o,u=(r?e?.paddingRight:e?.paddingLeft)??o,d={top:i.top+s,right:i.right+c,bottom:i.bottom+l,left:i.left+u};return{top:e?.top??d.top,right:(r?e?.left:e?.right)??d.right,bottom:e?.bottom??d.bottom,left:(r?e?.right:e?.left)??d.left}}),V(this,`resolveInitialViewport`,(e,t,n)=>{let{bounds:r}=eL(e.target,t,n);return r?rL(n,r,{...e,offsets:this.resolveOffsets(e.offsets)}):null}),V(this,`setViewport`,e=>{if(e===null){this.cancelTransition(),IP.cancel(KI),this.snapBackDebounced.cancel(),this.app.setState({scrollConstraints:null,shouldCacheIgnoreZoom:!1});return}let{target:t,fit:n,lock:r,animation:i}=e,a=this.resolveOffsets(e.offsets),{bounds:o,type:s}=eL(t,this.app.scene.getNonDeletedElementsMap(),this.app.state);if(!o){s===`link`&&this.app.setState({toast:{message:K(`elementLink.notFound`),duration:3e3,closable:!0}});return}let c=rL(this.app.state,o,{fit:n,offsets:a,lock:r}),l=aL(i),u={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom};if(this.cancelTransition(),IP.cancel(KI),this.snapBackDebounced.cancel(),l===null){this.app.setState({...c,shouldCacheIgnoreZoom:!1});return}let d={target:c};this.activeTransition=d,this.app.state.scrollConstraints&&this.app.setState({scrollConstraints:null}),oL(u,c,l,e=>{this.activeTransition===d&&this.app.setState(e)},()=>{this.activeTransition===d&&(this.activeTransition=null,this.app.setState({...d.target,shouldCacheIgnoreZoom:!1}))})}),V(this,`translate`,(e,t)=>!this.isLockedTransitionPending&&(this.activeTransition&&this.app.setState({shouldCacheIgnoreZoom:!1}),this.cancelTransition(),t?.preserveScrollConstraintsSnapBack||IP.cancel(KI),this.app.requestUnfollow(),this.app.setState((n,r)=>{let i=typeof e==`function`?e(n,r):e;if(!i)return null;let a={...n,...i};if(!a.scrollConstraints)return i;let o=!t?.zoomPreConstrained&&a.zoom.value!==n.zoom.value?0:a.scrollConstraints.overscroll;return o>0&&this.snapBackDebounced(),{...a,...Eo(a,o)}}),!0)),V(this,`constrain`,(e=0)=>{this.app.setState(t=>t.scrollConstraints?Eo(t,e):null)}),V(this,`releaseOverscroll`,()=>{this.app.state.scrollConstraints&&(this.snapBackDebounced.cancel(),this.snapBack())}),V(this,`snapBack`,()=>{this.app.unmounted||this.dependencies.isGestureActive()||sL(this.app.state,e=>this.app.setState(t=>e(t)))}),V(this,`snapBackDebounced`,ws(this.snapBack,YI)),V(this,`cancelTransition`,()=>{this.activeTransition=null,IP.cancel(GI)}),V(this,`destroy`,()=>{this.cancelTransition(),IP.cancel(KI),this.snapBackDebounced.cancel()})}get isAnimating(){return IP.running(GI)||IP.running(KI)}get isLockedTransitionPending(){return!!this.activeTransition?.target.scrollConstraints}},lL=4,uL=class{constructor(e){this.app=e,V(this,`isOverEditorSurface`,e=>{let{ownerWindow:t}=this.app;return e.target instanceof t.HTMLCanvasElement||e.target instanceof t.HTMLTextAreaElement||e.target instanceof t.HTMLIFrameElement||e.target instanceof t.HTMLElement&&e.target.classList.contains(Ai.FRAME_NAME)}),V(this,`handle`,MP(e=>{if(!this.app.isNavigationEnabled())return;if(!this.isOverEditorSurface(e)){e[L.CTRL_OR_CMD]&&e.preventDefault();return}e.preventDefault();let t=!!(e.buttons&lL);if(this.app.pan.isActive()){if(!t)return;this.app.pan.flushMove()}let{deltaX:n,deltaY:r}=e;if(!n&&!r)return;let i=e.metaKey||e.ctrlKey;if(r!==0&&(t||!e.shiftKey&&(i||na(this.app.state.inputDevice)===`mouse`))){this.zoomBy(r);return}if(e.shiftKey){let e=r||n;this.app.viewport.translate(({zoom:t,scrollX:n,scrollY:r})=>({scrollX:i?n:n-e/t.value,scrollY:i?r-e/t.value:r}));return}this.app.viewport.translate(({zoom:e,scrollX:t,scrollY:i})=>({scrollX:t-n/e.value,scrollY:i-r/e.value}))})),V(this,`preventBrowserZoom`,e=>{e[L.CTRL_OR_CMD]&&e.preventDefault()}),V(this,`zoomBy`,e=>{let{viewport:t}=this.app,n=Math.sign(e),r=Dt*100,i=Math.abs(e),a=e;i>r&&(a=r*n);let{x:o,y:s}=t.lastPosition;t.translate(e=>{let t=e.zoom.value-a/100;t+=Math.log10(Math.max(1,e.zoom.value))*-n*Math.min(1,i/20);let r=e.scrollConstraints?.lockZoom?e.scrollConstraints.zoom:.1,c=Io(Math.max(t,r));return c===e.zoom.value?null:{...ba({viewportX:o,viewportY:s,nextZoom:c},e),shouldCacheIgnoreZoom:!0}},{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})&&this.app.resetShouldCacheIgnoreZoomDebounced()})}},dL=()=>(0,W.jsxs)(`div`,{"data-testid":`brave-measure-text-error`,children:[(0,W.jsx)(`p`,{children:(0,W.jsx)(LA,{i18nKey:`errors.brave_measure_text_error.line1`,bold:e=>(0,W.jsx)(`span`,{style:{fontWeight:600},children:e})})}),(0,W.jsx)(`p`,{children:(0,W.jsx)(LA,{i18nKey:`errors.brave_measure_text_error.line2`,bold:e=>(0,W.jsx)(`span`,{style:{fontWeight:600},children:e})})}),(0,W.jsx)(`p`,{children:(0,W.jsx)(LA,{i18nKey:`errors.brave_measure_text_error.line3`,link:e=>(0,W.jsx)(`a`,{href:`http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser`,children:e})})}),(0,W.jsx)(`p`,{children:(0,W.jsx)(LA,{i18nKey:`errors.brave_measure_text_error.line4`,issueLink:e=>(0,W.jsx)(`a`,{href:`https://github.com/excalidraw/excalidraw/issues/new`,children:e}),discordLink:e=>(0,W.jsxs)(`a`,{href:`https://discord.gg/UexuTaE`,children:[e,`.`]})})})]}),fL=10,pL=({children:e,left:t,top:n,onCloseRequest:r,fitInViewport:i=!1,viewportWidth:a=window.innerWidth,viewportHeight:o=window.innerHeight,className:s})=>{let c=(0,H.useRef)(null);(0,H.useEffect)(()=>{let e=c.current;if(!e)return;e.contains(document.activeElement)||e.focus();let t=t=>{if(t.key===L.TAB){let n=fr(e),{activeElement:r}=document,i=n.findIndex(e=>e===r);r===e?(t.shiftKey?n[n.length-1]?.focus():n[0].focus(),t.preventDefault(),t.stopImmediatePropagation()):i===0&&t.shiftKey?(n[n.length-1]?.focus(),t.preventDefault(),t.stopImmediatePropagation()):i===n.length-1&&!t.shiftKey&&(n[0]?.focus(),t.preventDefault(),t.stopImmediatePropagation())}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[]);let l=(0,H.useRef)(null);return(0,H.useLayoutEffect)(()=>{if(i&&c.current&&n!=null&&t!=null){let e=c.current,{width:r,height:i}=e.getBoundingClientRect();if(l.current?.top===n&&l.current?.left===t)return;l.current={top:n,left:t};let s=Math.max(0,a-fL*2);r>=s?(e.style.width=`${s}px`,e.style.left=`${fL}px`,e.style.overflowX=`scroll`):e.style.left=`${fi(t,fL,a-fL-r)}px`;let u=Math.max(0,o-fL*2);i>=u?(e.style.height=`${u}px`,e.style.top=`${fL}px`,e.style.overflowY=`scroll`):e.style.top=`${fi(n,fL,o-fL-i)}px`}},[n,t,i,a,o]),(0,H.useEffect)(()=>{if(r){let e=e=>{c.current?.contains(e.target)||(0,hl.unstable_batchedUpdates)(()=>r(e))};return document.addEventListener(`pointerdown`,e,!1),()=>document.removeEventListener(`pointerdown`,e,!1)}},[r]),(0,W.jsx)(`div`,{className:U(`popover`,s),ref:c,tabIndex:-1,children:e})},mL=`separator`,hL=H.memo(({actionManager:e,items:t,top:n,left:r,onClose:i})=>{let a=gU(),o=hU(),s=t.reduce((t,n)=>(n&&(n===mL||!n.predicate||n.predicate(o,a,e.app.props,e.app))&&t.push(n),t),[]);return(0,W.jsx)(pL,{onCloseRequest:()=>{i()},top:n,left:r,fitInViewport:!0,viewportWidth:a.width,viewportHeight:a.height,className:`context-menu-popover`,children:(0,W.jsx)(`ul`,{className:`context-menu`,onContextMenu:e=>e.preventDefault(),children:s.map((t,n)=>{if(t===mL)return!s[n-1]||s[n-1]===mL?null:(0,W.jsx)(`hr`,{className:`context-menu-item-separator`},n);let r=t.name,c=``;return t.label&&(c=typeof t.label==`function`?K(t.label(o,a,e.app)):K(t.label)),(0,W.jsx)(`li`,{"data-testid":r,onClick:()=>{i(()=>{e.executeAction(t,`contextMenu`)})},children:(0,W.jsxs)(`button`,{type:`button`,className:U(`context-menu-item`,{dangerous:r===`deleteSelectedElements`,checkmark:t.checked?.(a)}),children:[(0,W.jsx)(`div`,{className:`context-menu-item__label`,children:c}),(0,W.jsx)(`kbd`,{className:`context-menu-item__shortcut`,children:r?Kk(r):``})]})},n)})})})}),gL=({border:e,style:t})=>(0,W.jsx)(`div`,{className:`viewport-status-frame__border`,style:{borderColor:e,...t}}),_L=({label:e,border:t})=>{let n=(0,H.useId)(),r=(0,W.jsxs)(W.Fragment,{children:[e.icon&&(0,W.jsx)(`span`,{className:`viewport-status-frame__badge-icon`,children:e.icon}),e.label]});return(0,W.jsxs)(`div`,{className:U(`viewport-status-frame__badge`,{"viewport-status-frame__badge--clickable":e.onClick}),role:`status`,style:{"--viewport-status-frame-badge-background":e.background||t||`var(--color-primary)`,color:e.color},children:[e.onClick&&(0,W.jsx)(`button`,{type:`button`,className:`viewport-status-frame__badge-action`,"aria-labelledby":n,onClick:e.onClick}),(0,W.jsx)(`div`,{className:`viewport-status-frame__badge-label`,id:e.onClick?n:void 0,children:r}),e.onClose&&(0,W.jsx)(`button`,{type:`button`,className:`viewport-status-frame__badge-close`,"aria-label":K(`buttons.close`),onClick:e.onClose,children:ES})]})},vL=H.createContext(null),yL=()=>H.useContext(vL),bL=iu(),xL=()=>H.useMemo(()=>({MainMenuTunnel:Rb(),WelcomeScreenMenuHintTunnel:Rb(),WelcomeScreenToolbarHintTunnel:Rb(),WelcomeScreenHelpHintTunnel:Rb(),WelcomeScreenCenterTunnel:Rb(),FooterCenterTunnel:Rb(),DefaultSidebarTriggerTunnel:Rb(),DefaultSidebarTabTriggersTunnel:Rb(),OverwriteConfirmDialogTunnel:Rb(),TTDDialogTriggerTunnel:Rb(),tunnelsJotai:bL}),[]),SL=({delay:e,theme:t})=>{let[n,r]=(0,H.useState)(!!e);return(0,H.useEffect)(()=>{if(!e)return;let t=setTimeout(()=>{r(!1)},e);return()=>clearTimeout(t)},[e]),n?null:(0,W.jsxs)(`div`,{className:U(`LoadingMessage`,{"LoadingMessage--dark":t===P.DARK}),children:[(0,W.jsx)(`div`,{children:(0,W.jsx)(Ow,{})}),(0,W.jsx)(`div`,{className:`LoadingMessage-text`,children:K(`labels.loadingScene`)})]})},CL=({app:e,setAppState:t})=>{let n=e.state.activeTool,[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)(`rectangle`),[s,c]=(0,H.useState)(`arrow`);(0,H.useEffect)(()=>{(n.type===`rectangle`||n.type===`diamond`||n.type===`ellipse`)&&o(n.type)},[n.type]),(0,H.useEffect)(()=>{(n.type===`arrow`||n.type===`line`)&&c(n.type)},[n.type]);let l=n.type===`frame`,u=n.type===`autoshape`,d=n.type===`laser`,f=n.type===`embeddable`,p=n.type===`bucketfill`,m=n.type===`stickynote`,{TTDDialogTriggerTunnel:h}=yL(),g=[`rectangle`,`diamond`,`ellipse`].map(e=>({type:e,icon:JE[e].icon,title:Xo(K(`toolBar.${e}`)),fillable:JE[e].fillable})),_=[`arrow`,`line`].map(e=>({type:e,icon:JE[e].icon,title:Xo(K(`toolBar.${e}`)),fillable:JE[e].fillable})),[v,y]=(0,H.useState)(0),b=v>=316,x=v>=356,S=v>=396,C=[`text`,`stickynote`,`frame`,`embeddable`,`laser`,`bucketfill`,`magicframe`].filter(e=>!(b&&e===`text`||S&&e===`frame`)).includes(n.type),w=C?n.type===`text`?kx:n.type===`image`?jx:n.type===`frame`?MC:n.type===`stickynote`?NC:n.type===`embeddable`?Lx:n.type===`laser`?zC:n.type===`bucketfill`?tS:n.type===`magicframe`?BC:ux:ux,T={app:e,activeTool:n};return(0,W.jsxs)(`div`,{className:`mobile-toolbar`,ref:e=>{e&&y(e.getBoundingClientRect().width)},children:[(0,W.jsx)(tD,{...T,hideKeyBinding:!0}),(0,W.jsx)(hD,{...T,setAppState:t}),(0,W.jsx)(gD,{...T}),(0,W.jsx)(dD,{...T,hideShortcut:!0}),(0,W.jsx)(qE,{app:e,options:g,activeTool:n,defaultOption:a,"data-testid":`toolbar-rectangle`,onToolChange:t=>{(t===`rectangle`||t===`diamond`||t===`ellipse`)&&(o(t),e.setActiveTool({type:t}))},displayedOption:g.find(e=>e.type===a)||g[0]}),(0,W.jsx)(qE,{app:e,options:_,activeTool:n,defaultOption:s,"data-testid":`toolbar-arrow`,onToolChange:t=>{(t===`arrow`||t===`line`)&&(c(t),e.setActiveTool({type:t}))},displayedOption:_.find(e=>e.type===s)||_[0]}),b&&(0,W.jsx)(cD,{...T,hideShortcut:!0}),x&&(0,W.jsx)(uD,{...T,hideShortcut:!0}),S&&(0,W.jsx)(fD,{...T,hideShortcut:!0}),(0,W.jsxs)(Q,{open:r,children:[(0,W.jsx)(Q.Trigger,{className:U(`App-toolbar__extra-tools-trigger App-toolbar__extra-tools-trigger--mobile`,{"App-toolbar__extra-tools-trigger--selected":C||r}),onToggle:()=>{i(!r),t({openMenu:null,openPopup:null})},title:K(`toolBar.extraTools`),style:{width:36,height:36,display:`flex`,alignItems:`center`,justifyContent:`center`},children:w}),(0,W.jsxs)(Q.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:`App-toolbar__extra-tools-dropdown`,align:`start`,children:[!b&&(0,W.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`text`}),icon:kx,shortcut:L.T.toLocaleUpperCase(),"data-testid":`toolbar-text`,selected:n.type===`text`,disabled:$E(e,`text`),children:K(`toolBar.text`)}),!x&&(0,W.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`image`}),icon:jx,"data-testid":`toolbar-image`,selected:n.type===`image`,disabled:$E(e,`image`),children:K(`toolBar.image`)}),(0,W.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`stickynote`}),icon:NC,shortcut:L.N.toLocaleUpperCase(),"data-testid":`toolbar-stickynote`,selected:m,disabled:$E(e,`stickynote`),children:K(`toolBar.stickynote`)}),!S&&(0,W.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`frame`}),icon:MC,shortcut:L.F.toLocaleUpperCase(),"data-testid":`toolbar-frame`,selected:l,disabled:$E(e,`frame`),children:K(`toolBar.frame`)}),(0,W.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`embeddable`}),icon:Lx,"data-testid":`toolbar-embeddable`,selected:f,disabled:$E(e,`embeddable`),children:K(`toolBar.embeddable`)}),(0,W.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`autoshape`}),icon:RC,shortcut:ZE(`autoshape`),"data-testid":`toolbar-autoshape`,selected:u,disabled:$E(e,`autoshape`),children:K(`toolBar.autoshape`)}),(0,W.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`laser`}),icon:zC,"data-testid":`toolbar-laser`,selected:d,shortcut:L.K.toLocaleUpperCase(),disabled:$E(e,`laser`),children:K(`toolBar.laser`)}),(0,W.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`bucketfill`}),icon:tS,"data-testid":`toolbar-bucketfill`,selected:p,shortcut:L.B.toLocaleUpperCase(),disabled:$E(e,`bucketfill`),children:K(`toolBar.bucketfill`)}),(0,W.jsx)(`div`,{style:{margin:`6px 0`,fontSize:14,fontWeight:600},children:`Generate`}),e.props.aiEnabled!==!1&&(0,W.jsx)(h.Out,{}),(0,W.jsx)(Q.Item,{onSelect:()=>e.setOpenDialog({name:`ttd`,tab:`mermaid`}),icon:PC,"data-testid":`toolbar-embeddable`,children:K(`toolBar.mermaidToExcalidraw`)}),e.props.aiEnabled!==!1&&e.plugins.diagramToCode&&(0,W.jsx)(W.Fragment,{children:(0,W.jsx)(Q.Item,{onSelect:()=>e.onMagicframeToolSelect(),icon:BC,"data-testid":`toolbar-magicframe`,badge:(0,W.jsx)(Q.Item.Badge,{children:`AI`}),disabled:$E(e,`magicframe`),children:K(`toolBar.magicframe`)})})]})]})]})},wL=({children:e,side:t,className:n})=>(0,W.jsx)(`div`,{className:U(`FixedSideContainer`,`FixedSideContainer_side_${t}`,n),children:e}),TL=e=>e.penDetected?(0,W.jsx)(kw,{className:U(`ToolIcon__penMode`,{"is-mobile":e.isMobile}),type:`toggle`,icon:Dx,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,onSelect:()=>e.onChange?.()}):null,EL=({appState:e,elements:t,actionManager:n,setAppState:r,renderTopLeftUI:i,renderTopRightUI:a,renderSidebars:o,renderWelcomeScreen:s,defaultUIEnabled:c,scrollBackToContentUIEnabled:l,app:u,onPenModeToggle:d})=>{let{WelcomeScreenCenterTunnel:f,MainMenuTunnel:p,DefaultSidebarTriggerTunnel:m}=yL(),h=()=>{if(e.openDialog?.name===`elementLinkSelector`)return null;let t=(0,W.jsxs)(`div`,{className:`excalidraw-ui-top-right`,children:[a?.(!0,e)??(!e.viewModeEnabled&&(0,W.jsxs)(W.Fragment,{children:[c&&(0,W.jsx)(TL,{checked:e.penMode,onChange:()=>d(null),title:K(`toolBar.penMode`),isMobile:!0,penDetected:e.penDetected}),(0,W.jsx)(m.Out,{})]})),c&&e.viewModeEnabled&&u.isInteractionEnabled()&&(0,W.jsx)($j,{actionManager:n})]}),r=(0,W.jsxs)(`div`,{className:`excalidraw-ui-top-left`,children:[i?.(!0,e),(0,W.jsx)(p.Out,{})]});return(0,W.jsxs)(`div`,{className:`App-toolbar-content`,style:{display:`flex`,flexDirection:`row`,justifyContent:`space-between`},children:[r,t]})},g=()=>(0,W.jsx)(CL,{app:u,setAppState:r}),_=l&&e.scrolledOutside,v=c&&!e.viewModeEnabled,y=_&&!e.openMenu&&!e.openSidebar?(0,W.jsx)(`button`,{type:`button`,className:`scroll-back-to-content`,onClick:()=>{r(e=>({...hc(t,e)}))},children:K(`buttons.scrollBackToContent`)}):null,b=u.props.viewportStatusFrame?.label,x=b?(0,W.jsx)(_L,{label:b,border:u.props.viewportStatusFrame?.border}):null;return(0,W.jsxs)(W.Fragment,{children:[o(),(0,W.jsx)(`div`,{className:`App-welcome-screen`,children:s&&(0,W.jsx)(f.Out,{})}),v&&(0,W.jsxs)(`div`,{className:`App-bottom-bar`,style:{marginBottom:eF+$P},"data-viewport-ui":`bottom`,children:[y&&(0,W.jsx)(`div`,{className:`floating-status-stack`,children:y}),(0,W.jsx)(Yj,{appState:e,elementsMap:u.scene.getNonDeletedElementsMap(),renderAction:n.renderAction,app:u,setAppState:r}),(0,W.jsx)(nT,{className:`App-toolbar`,children:e.openDialog?.name!==`elementLinkSelector`&&g()})]}),!v&&y&&(0,W.jsx)(`div`,{className:`floating-status-stack`,children:y}),x&&(0,W.jsx)(`div`,{className:`viewport-status-frame__badge-row`,children:x}),(0,W.jsx)(wL,{side:`top`,className:`App-top-bar`,children:h()})]})},DL=e=>{switch(e){case`bar`:return K(`labels.chartType_bar`);case`line`:return K(`labels.chartType_line`);case`radar`:return K(`labels.chartType_radar`);default:return e}},OL=e=>{let t=(0,H.useRef)(null),[n,r]=(0,H.useState)(null),{theme:i}=Kw();(0,H.useLayoutEffect)(()=>{if(!e.spreadsheet){r(null);return}let n=TI(e.chartType,e.spreadsheet,0,0,e.colorSeed);if(!n){r(null),t.current?.replaceChildren();return}r(n);let a,o=t.current;return(async()=>(a=await js(n,{exportBackground:!1,viewBackgroundColor:`#fff`,exportWithDarkMode:i===`dark`},null,{skipInliningFonts:!0}),a.querySelector(`.style-fonts`)?.remove(),o.replaceChildren(),o.appendChild(a)))(),()=>{o.replaceChildren()}},[e.spreadsheet,e.chartType,e.colorSeed,i]);let a=DL(e.chartType);return(0,W.jsxs)(`button`,{type:`button`,className:`ChartPreview`,"aria-label":a,onClick:()=>{n&&e.onClick(e.chartType,n)},children:[(0,W.jsx)(`div`,{className:`ChartPreview__canvas`,ref:t}),(0,W.jsx)(`div`,{className:`ChartPreview__label`,children:a})]})},kL=e=>{let t=(0,H.useRef)(null),{theme:n}=Kw();return(0,H.useLayoutEffect)(()=>{if(!e.rawText)return;let r=Ir({text:e.rawText,x:0,y:0}),i=t.current;return(async()=>{let e=await js([r],{exportBackground:!1,viewBackgroundColor:`#fff`,exportWithDarkMode:n===`dark`},null,{skipInliningFonts:!0});e.querySelector(`.style-fonts`)?.remove(),i.replaceChildren(),i.appendChild(e)})(),()=>{i.replaceChildren()}},[e.rawText,n]),(0,W.jsxs)(`button`,{type:`button`,className:`ChartPreview`,"aria-label":K(`labels.chartType_plaintext`),onClick:()=>{e.onClick(e.rawText)},children:[(0,W.jsx)(`div`,{className:`ChartPreview__canvas`,ref:t}),(0,W.jsx)(`div`,{className:`ChartPreview__label`,children:K(`labels.chartType_plaintext`)})]})},AL=({data:e,rawText:t,onClose:n})=>{let{onInsertElements:r,focusContainer:i}=uU(),[a,o]=(0,H.useState)(Math.random()),s=H.useCallback(()=>{o(Math.random())},[]),c=H.useCallback(()=>{n&&n()},[n]),l=(e,t)=>{r(t),Vw(`paste`,`chart`,e),n(),i()};return(0,W.jsx)(Pj,{size:`regular`,onCloseRequest:c,title:(0,W.jsxs)(`div`,{className:`PasteChartDialog__title`,children:[(0,W.jsx)(`div`,{className:`PasteChartDialog__titleText`,children:K(`labels.pasteCharts`)}),(0,W.jsx)(`div`,{className:`PasteChartDialog__reshuffleBtn`,onClick:s,role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s())},children:tS})]}),className:`PasteChartDialog`,autofocus:!1,children:(0,W.jsxs)(`div`,{className:`container`,children:[[`bar`,`line`,`radar`].map(t=>JF(e,t)?(0,W.jsx)(OL,{chartType:t,spreadsheet:e,colorSeed:a,onClick:l},t):null),t&&(0,W.jsx)(kL,{rawText:t,onClick:e=>{let t=Ir({text:e,x:0,y:0});r([t]),Vw(`paste`,`chart`,`plaintext`),n(),i()}})]})})},jL=({heading:e,children:t,...n})=>{let{id:r}=mU(),i=(0,W.jsx)(`h2`,{className:`visually-hidden`,id:`${r}-${e}-title`,children:K(`headings.${e}`)});return(0,W.jsx)(`section`,{...n,"aria-labelledby":`${r}-${e}-title`,children:typeof t==`function`?t(i):(0,W.jsxs)(W.Fragment,{children:[i,t]})})},ML=4,NL=8,PL=38,FL=21,IL=({shouldWrap:e,children:t,username:n})=>e?(0,W.jsx)(IE,{label:n||`Unknown user`,children:t}):(0,W.jsx)(W.Fragment,{children:t}),LL=({actionManager:e,collaborator:t,socketId:n,withName:r=!1,shouldWrapWithTooltip:i=!1,isBeingFollowed:a})=>{let o={socketId:n,collaborator:t,withName:r,isBeingFollowed:a},s=e.renderAction(`goToCollaborator`,o);return(0,W.jsx)(IL,{username:t.username,shouldWrap:i,children:s},n)},RL=[`avatarUrl`,`id`,`socketId`,`username`,`isInCall`,`isSpeaking`,`isMuted`,`isCurrentUser`],zL=H.memo(({className:e,mobile:t,collaborators:n,userToFollow:r,currentUserControls:i})=>{let a=vU(),o=typeof i==`function`?i(!!t):i,s=Array.from(n,([e,t])=>({...t,socketId:e})).filter(e=>e.username?.trim()),c=s.find(e=>e.isCurrentUser),l=s.filter(e=>!e.isCurrentUser),[u,d]=H.useState(``),f=s.filter(e=>e.username?.toLowerCase().includes(u)),p=H.useRef(null);(0,H.useLayoutEffect)(()=>{if(p.current){let e=p.current.ownerDocument.defaultView,t=e=>{h(e)};if(t(p.current.clientWidth),!e||typeof e.ResizeObserver!=`function`)return;let n=new e.ResizeObserver(e=>{for(let n of e){let{width:e}=n.contentRect;t(e)}});return n.observe(p.current),()=>{n.disconnect()}}},[]);let[m,h]=H.useState(ML*PL),g=c?m-FL:m,_=Math.max(1,Math.min(8,Math.floor(g/PL))),v=c?Math.max(0,_-1):_,y=l.slice(0,v),b=c?[...y,c]:y,x=b.map(e=>{let t=LL({actionManager:a,collaborator:e,socketId:e.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:e.socketId===r});return e.isCurrentUser?(0,W.jsxs)(Ty,{children:[(0,W.jsx)(Ey,{asChild:!0,children:(0,W.jsxs)(`div`,{className:`UserList__pill`,children:[t,(0,W.jsx)(`div`,{className:`UserList__pill-chevron`,children:Tw})]})}),(0,W.jsx)(Oy,{className:`focus-visible-none`,style:{zIndex:2,width:`15rem`,textAlign:`left`},align:`end`,sideOffset:10,children:(0,W.jsxs)(nT,{padding:2,children:[s.length>=NL&&(0,W.jsx)(RT,{placeholder:K(`quickSearch.placeholder`),onChange:d}),(0,W.jsx)(zT,{className:`dropdown-menu UserList__collaborators`,placeholder:K(`userList.empty`),children:f.length>0?[(0,W.jsx)(`div`,{className:`hint`,children:K(`userList.hint.text`)},`hint`),f.map(e=>LL({actionManager:a,collaborator:e,socketId:e.socketId,withName:!0,isBeingFollowed:e.socketId===r}))]:[]}),o&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`UserList__menu-divider`}),(0,W.jsx)(ky,{asChild:!0,children:(0,W.jsx)(`div`,{className:`dropdown-menu`,children:o})})]}),(0,W.jsx)(Ay,{width:20,height:10,style:{fill:`var(--popup-bg-color)`,filter:`drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)`}})]})})]},e.socketId):t});return t?(0,W.jsxs)(`div`,{className:U(`UserList UserList_mobile`,e),children:[(0,W.jsx)(`div`,{className:`UserList_mobile__avatars`,children:s.map(e=>LL({actionManager:a,collaborator:e,socketId:e.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:e.socketId===r}))}),o&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`UserList__menu-divider`}),o]})]}):(0,W.jsx)(`div`,{className:`UserList__wrapper`,ref:p,children:(0,W.jsx)(`div`,{className:U(`UserList`,e),style:{"--max-avatars":b.length+(c?FL/PL:0)},children:x})})},(e,t)=>{if(e.collaborators.size!==t.collaborators.size||e.mobile!==t.mobile||e.className!==t.className||e.userToFollow!==t.userToFollow||e.currentUserControls!==t.currentUserControls)return!1;let n=t.collaborators.keys();for(let[r,i]of e.collaborators){let e=t.collaborators.get(r);if(!e||r!==n.next().value||!Us(i,e,RL))return!1}return!0}),BL=e=>(0,W.jsx)(IE,{label:`${K(`helpDialog.title`)} \u2014 ?`,children:(0,W.jsx)(`button`,{className:`help-icon`,onClick:e.onClick,type:`button`,"aria-label":K(`helpDialog.title`),children:Ux})}),VL=({appState:e,actionManager:t,showExitZenModeBtn:n,renderWelcomeScreen:r,defaultUIEnabled:i,zoomUIEnabled:a})=>{let{FooterCenterTunnel:o,WelcomeScreenHelpHintTunnel:s}=yL(),c=uU();return(0,W.jsxs)(`footer`,{role:`contentinfo`,className:`layer-ui__wrapper__footer App-menu App-menu_bottom`,children:[(i||a&&c.isNavigationEnabled())&&(0,W.jsx)(`div`,{className:U(`layer-ui__wrapper__footer-left zen-mode-transition`,{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:(0,W.jsx)(VA.Col,{gap:2,children:(0,W.jsxs)(jL,{heading:`canvasActions`,children:[a&&c.isNavigationEnabled()&&(0,W.jsx)(Xj,{renderAction:t.renderAction}),i&&!e.viewModeEnabled&&(0,W.jsx)(Zj,{renderAction:t.renderAction,className:U(`zen-mode-transition`,{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),(0,W.jsx)(o.Out,{}),(i||r)&&(0,W.jsx)(`div`,{className:U(`layer-ui__wrapper__footer-right zen-mode-transition`,{"transition-right":e.zenModeEnabled}),children:(0,W.jsxs)(`div`,{style:{position:`relative`},children:[r&&(0,W.jsx)(s.Out,{}),i&&(0,W.jsx)(BL,{onClick:()=>t.executeAction(uO)})]})}),i&&(0,W.jsx)(Qj,{actionManager:t,showExitZenModeBtn:n})]})},HL=VL;VL.displayName=`Footer`;var UL=H.createContext({}),WL=({children:e,className:t})=>{let n=fU(),r=(0,H.useContext)(UL),i=!!(n.canFitSidebar&&r.shouldRenderDockButton);return(0,W.jsxs)(`div`,{className:U(`sidebar__header`,t),"data-testid":`sidebar-header`,children:[e,(0,W.jsxs)(`div`,{className:`sidebar__header__buttons`,children:[i&&(0,W.jsx)(IE,{label:K(`labels.sidebarLock`),children:(0,W.jsx)(xj,{onSelect:()=>r.onDock?.(!r.docked),selected:!!r.docked,className:`sidebar__dock`,"data-testid":`sidebar-dock`,"aria-label":K(`labels.sidebarLock`),children:fx})}),(0,W.jsx)(xj,{"data-testid":`sidebar-close`,className:`sidebar__close`,onSelect:r.onCloseRequest,"aria-label":K(`buttons.close`),children:ES})]})]})};WL.displayName=`SidebarHeader`;var GL=({children:e,tab:t,onSelect:n,...r})=>(0,W.jsx)(Jy,{value:t,asChild:!0,onSelect:n,children:(0,W.jsx)(`button`,{type:`button`,className:`excalidraw-button sidebar-tab-trigger`,...r,children:e})});GL.displayName=`SidebarTabTrigger`;var KL=({children:e,...t})=>(0,W.jsx)(qy,{className:`sidebar-triggers`,...t,children:e});KL.displayName=`SidebarTabTriggers`;var qL=({name:e,tab:t,icon:n,title:r,children:i,onToggle:a,className:o,style:s})=>{let c=_U(),l=Kw().openSidebar?.name===e;return(0,W.jsx)(`button`,{type:`button`,title:r,className:`sidebar-trigger__label-element`,"aria-label":r,"aria-keyshortcuts":`0`,"aria-pressed":l,onClick:()=>{document.querySelector(`.layer-ui__wrapper`)?.classList.remove(`animate`);let n=!l;c({openSidebar:n?{name:e,tab:t}:null,openMenu:null,openPopup:null}),a?.(n)},children:(0,W.jsxs)(`div`,{className:U(`sidebar-trigger`,o),style:s,children:[n&&(0,W.jsx)(`div`,{children:n}),i&&(0,W.jsx)(`div`,{className:`sidebar-trigger__label`,children:i})]})})};qL.displayName=`SidebarTrigger`;var JL=({children:e,...t})=>{let n=Kw(),r=_U();if(!n.openSidebar)return null;let{name:i}=n.openSidebar;return(0,W.jsx)(Ky,{className:`sidebar-tabs-root`,value:n.openSidebar.tab,onValueChange:e=>r(t=>({...t,openSidebar:{...t.openSidebar,name:i,tab:e}})),...t,children:e})};JL.displayName=`SidebarTabs`;var YL=({tab:e,children:t,...n})=>(0,W.jsx)(Yy,{...n,value:e,"data-testid":e,children:t});YL.displayName=`SidebarTab`;var XL=yl(!1),ZL=(0,H.forwardRef)(({name:e,children:t,onDock:n,docked:r,className:i,...a},o)=>{rt()&&n&&r==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let s=_U(),c=Hb(XL);(0,H.useLayoutEffect)(()=>(c(!!r),()=>{c(!1)}),[c,r]);let l=(0,H.useRef)({});l.current.onCloseRequest=()=>{s({openSidebar:null})},l.current.onDock=e=>n?.(e),l.current=oi(l.current,{docked:r,shouldRenderDockButton:!!n&&r!=null});let u=(0,H.useRef)(null);(0,H.useImperativeHandle)(o,()=>u.current);let d=fU(),f=(0,H.useCallback)(()=>{document.querySelector(`.Dialog`)||s({openSidebar:null})},[s]);return Jw(u,(0,H.useCallback)(e=>{e.target.closest(`.sidebar-trigger`)||(!r||!d.canFitSidebar)&&f()},[f,r,d.canFitSidebar])),(0,H.useEffect)(()=>{let e=e=>{e.key===L.ESCAPE&&(!r||!d.canFitSidebar)&&f()};return document.addEventListener(B.KEYDOWN,e),()=>{document.removeEventListener(B.KEYDOWN,e)}},[f,r,d.canFitSidebar]),(0,W.jsx)(nT,{...a,className:U(Ai.SIDEBAR,{"sidebar--docked":r},i),"data-viewport-ui":d.formFactor===`phone`?void 0:`side`,"data-viewport-ui-name":d.formFactor===`phone`?void 0:`sidebar`,ref:u,children:(0,W.jsx)(UL.Provider,{value:l.current,children:t})})});ZL.displayName=`SidebarInner`;var QL=Object.assign((0,H.forwardRef)((e,t)=>{let n=Kw(),{onStateChange:r}=e,i=(0,H.useRef)(n.openSidebar);(0,H.useEffect)(()=>{(!n.openSidebar&&i?.current?.name===e.name||n.openSidebar?.name===e.name&&i?.current?.name!==e.name||i.current?.name===e.name)&&n.openSidebar!==i.current&&r?.(n.openSidebar?.name===e.name?n.openSidebar:null),i.current=n.openSidebar},[n.openSidebar,r,e.name]);let[a,o]=(0,H.useState)(!1);return(0,H.useLayoutEffect)(()=>(o(!0),()=>o(!1)),[]),a&&n.openSidebar?.name===e.name?(0,H.createElement)(ZL,{...e,ref:t,key:e.name}):null}),{Header:WL,TabTriggers:KL,TabTrigger:GL,Tabs:JL,Tab:YL,Trigger:qL});QL.displayName=`Sidebar`;var $L=(e,t)=>{let n=yl(0),r=e=>{let{tunnelsJotai:{useAtom:r}}=yL(),[,i]=r(n),a=(0,H.useRef)({preferHost:!1,counter:0});return(0,H.useLayoutEffect)(()=>{let e=a.current;return i(t=>{let n=t+1;return e.counter=n,n}),()=>{i(t=>{let n=t-1;return e.counter=n,n||(e.preferHost=!1),n})}},[i]),e.__fallback||(a.current.preferHost=!0),!a.current.counter&&e.__fallback&&a.current.preferHost||a.current.counter>1&&e.__fallback?null:(0,W.jsx)(t,{...e})};return r.displayName=e,r},eR={};ll(eR,{ChangeCanvasBackground:()=>mR,ClearCanvas:()=>fR,CommandPalette:()=>lR,Export:()=>hR,Help:()=>dR,LiveCollaborationTrigger:()=>_R,LoadScene:()=>oR,Preferences:()=>OR,PreferencesToggleGridModeItem:()=>wR,PreferencesToggleZenModeItem:()=>TR,SaveAsImage:()=>cR,SaveToActiveFile:()=>sR,SearchMenu:()=>uR,Socials:()=>gR,ToggleTheme:()=>pR});var tR=yl({active:!1});async function nR({title:e,description:t,actionLabel:n,color:r}){return new Promise(i=>{Kb.set(tR,{active:!0,onConfirm:()=>i(!0),onClose:()=>i(!1),onReject:()=>i(!1),title:e,description:t,actionLabel:n,color:r})})}var rR=function({onChange:e,value:t,choices:n,name:r}){return(0,W.jsx)(`div`,{className:`RadioGroup`,children:n.map(n=>(0,W.jsxs)(`div`,{className:U(`RadioGroup__choice`,{active:n.value===t}),title:n.ariaLabel,children:[(0,W.jsx)(`input`,{name:r,type:`radio`,checked:n.value===t,onChange:()=>e(n.value),"aria-label":n.ariaLabel}),n.label]},String(n.value)))})},iR=({value:e,shortcut:t,onChange:n,choices:r,children:i,name:a,icon:o})=>{let s=fU();return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`dropdown-menu-item-base dropdown-menu-item-bare`,children:[o&&(0,W.jsx)(`div`,{className:`dropdown-menu-item__icon`,children:o}),(0,W.jsx)(`label`,{className:`dropdown-menu-item__text`,children:(0,W.jsx)(GT,{children:i})}),(0,W.jsx)(rR,{name:a,value:e,onChange:n,choices:r})]}),t&&s.formFactor!==`phone`&&(0,W.jsx)(`div`,{className:`dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned`,children:t})]})};iR.displayName=`DropdownMenuItemContentRadio`;var aR=iR,oR=()=>{let{t:e}=ix(),t=vU(),n=hU();return t.isActionEnabled(aO)?(0,W.jsx)(XT,{icon:$x,onSelect:async()=>{(!n.length||await nR({title:e(`overwriteConfirm.modal.loadFromFile.title`),actionLabel:e(`overwriteConfirm.modal.loadFromFile.button`),color:`warning`,description:(0,W.jsx)(LA,{i18nKey:`overwriteConfirm.modal.loadFromFile.description`,bold:e=>(0,W.jsx)(`strong`,{children:e}),br:()=>(0,W.jsx)(`br`,{})})}))&&t.executeAction(aO)},"data-testid":`load-button`,shortcut:Kk(`loadScene`),"aria-label":e(`buttons.load`),children:e(`buttons.load`)}):null};oR.displayName=`LoadScene`;var sR=()=>{let{t:e}=ix(),t=vU();return t.isActionEnabled(rO)?(0,W.jsx)(XT,{shortcut:Kk(`saveScene`),"data-testid":`save-button`,onSelect:()=>t.executeAction(rO),icon:Zx,"aria-label":`${e(`buttons.save`)}`,children:`${e(`buttons.save`)}`}):null};sR.displayName=`SaveToActiveFile`;var cR=()=>{let e=_U(),{t}=ix();return(0,W.jsx)(XT,{icon:rS,"data-testid":`image-export-button`,onSelect:()=>e({openDialog:{name:`imageExport`}}),shortcut:Kk(`imageExport`),"aria-label":t(`buttons.exportImage`),children:t(`buttons.exportImage`)})};cR.displayName=`SaveAsImage`;var lR=e=>{let t=_U(),{t:n}=ix();return(0,W.jsx)(XT,{icon:ZC,"data-testid":`command-palette-button`,onSelect:()=>{Vw(`command_palette`,`open`,`menu`),t({openDialog:{name:`commandPalette`}})},shortcut:Kk(`commandPalette`),"aria-label":n(`commandPalette.title`),className:e?.className,children:n(`commandPalette.title`)})};lR.displayName=`CommandPalette`;var uR=e=>{let{t}=ix(),n=vU();return(0,W.jsx)(XT,{icon:KC,"data-testid":`search-menu-button`,onSelect:()=>{n.executeAction(LN)},shortcut:Kk(`searchMenu`),"aria-label":t(`search.title`),className:e?.className,children:t(`search.title`)})};uR.displayName=`SearchMenu`;var dR=()=>{let{t:e}=ix(),t=vU();return(0,W.jsx)(XT,{"data-testid":`help-menu-item`,icon:Ux,onSelect:()=>t.executeAction(uO),shortcut:`?`,"aria-label":e(`helpDialog.title`),children:e(`helpDialog.title`)})};dR.displayName=`Help`;var fR=()=>{let{t:e}=ix(),t=Hb(tM);return vU().isActionEnabled(VE)?(0,W.jsx)(XT,{icon:Ix,onSelect:()=>t(`clearCanvas`),"data-testid":`clear-canvas-button`,"aria-label":e(`buttons.clearReset`),children:e(`buttons.clearReset`)}):null};fR.displayName=`ClearCanvas`;var pR=e=>{let{t}=ix(),n=Kw(),r=vU(),i=Kk(`toggleTheme`),a=dU();return r.isActionEnabled(KE)?e?.allowSystemTheme?(0,W.jsx)(aR,{name:`theme`,value:e.theme,onChange:e=>{if(a.onThemeChange){a.onThemeChange(e);return}console.warn("MainMenu.DefaultItems.ToggleTheme: `<Excalidraw/> props.onThemeChange` must be defined to use system theme selection.")},choices:[{value:P.LIGHT,label:Bx,ariaLabel:`${t(`buttons.lightMode`)} - ${i}`},{value:P.DARK,label:zx,ariaLabel:`${t(`buttons.darkMode`)} - ${i}`},{value:`system`,label:cw,ariaLabel:t(`buttons.systemMode`)}],children:t(`labels.theme`)}):(0,W.jsx)(XT,{onSelect:e=>{e.preventDefault(),r.executeAction(KE)},icon:n.theme===P.DARK?Bx:zx,"data-testid":`toggle-dark-mode`,shortcut:i,"aria-label":n.theme===P.DARK?t(`buttons.lightMode`):t(`buttons.darkMode`),children:n.theme===P.DARK?t(`buttons.lightMode`):t(`buttons.darkMode`)}):null};pR.displayName=`ToggleTheme`;var mR=()=>{let{t:e}=ix(),t=Kw(),n=vU(),r=dU();return t.viewModeEnabled||!r.UIOptions.canvasActions.changeViewBackgroundColor?null:(0,W.jsxs)(`div`,{style:{marginTop:`0.75rem`},children:[(0,W.jsx)(`div`,{"data-testid":`canvas-background-label`,style:{fontSize:`0.875rem`,marginBottom:`0.25rem`,marginLeft:`0.5rem`},children:e(`labels.canvasBackground`)}),(0,W.jsx)(`div`,{style:{padding:`0 0.625rem`},children:n.renderAction(`changeViewBackgroundColor`)})]})};mR.displayName=`ChangeCanvasBackground`;var hR=()=>{let{t:e}=ix(),t=_U();return(0,W.jsx)(XT,{icon:Hx,onSelect:()=>{t({openDialog:{name:`jsonExport`}})},"data-testid":`json-export-button`,"aria-label":e(`buttons.export`),children:e(`buttons.export`)})};hR.displayName=`Export`;var gR=()=>{let{t:e}=ix();return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(KA,{icon:Kx,href:`https://github.com/excalidraw/excalidraw`,"aria-label":`GitHub`,children:`GitHub`}),(0,W.jsx)(KA,{icon:Jx,href:`https://x.com/excalidraw`,"aria-label":`X`,children:e(`labels.followUs`)}),(0,W.jsx)(KA,{icon:qx,href:`https://discord.gg/UexuTaE`,"aria-label":`Discord`,children:e(`labels.discordChat`)})]})};gR.displayName=`Socials`;var _R=({onSelect:e,isCollaborating:t})=>{let{t:n}=ix();return(0,W.jsx)(XT,{"data-testid":`collab-button`,icon:wS,className:U({"active-collab":t}),onSelect:e,children:n(`labels.liveCollaboration`)})};_R.displayName=`LiveCollaborationTrigger`;var vR=()=>{let{t:e}=ix(),t=uU(),n=Kw();return(0,W.jsx)(uj,{checked:n.activeTool.locked,shortcut:Kk(`toolLock`),onSelect:e=>{t.toggleLock(),e.preventDefault()},children:e(`labels.preferences_toolLock`)})},yR=()=>{let{t:e}=ix(),t=Kw(),n=_U();return(0,W.jsx)(aR,{name:`boxSelectionMode`,icon:ww,value:t.boxSelectionMode,onChange:e=>{n({boxSelectionMode:e})},choices:[{value:`contain`,label:e(`labels.boxSelectionContain`),ariaLabel:e(`labels.boxSelectionContain`)},{value:`overlap`,label:e(`labels.boxSelectionOverlap`),ariaLabel:e(`labels.boxSelectionOverlap`)}],children:e(`labels.boxSelectionMode`)})},bR=()=>{let{t:e}=ix(),t=Kw(),n=_U();return(0,W.jsx)(aR,{name:`inputDevice`,icon:ww,value:na(t.inputDevice),onChange:e=>{n({inputDevice:e})},choices:[{value:`trackpad`,label:e(`labels.inputDeviceTrackpad`),ariaLabel:e(`labels.inputDeviceTrackpad`)},{value:`mouse`,label:e(`labels.inputDeviceMouse`),ariaLabel:e(`labels.inputDeviceMouse`)}],children:e(`labels.inputDevice`)})},xR=()=>{let{t:e}=ix(),t=vU(),n=Kw();return(0,W.jsx)(uj,{checked:n.objectsSnapModeEnabled,shortcut:Kk(`objectsSnapMode`),onSelect:e=>{t.executeAction(RO),e.preventDefault()},children:e(`buttons.objectsSnapMode`)})},SR=()=>{let{t:e}=ix(),t=vU(),n=Kw();return(0,W.jsx)(uj,{checked:n.bindingPreference===`enabled`,onSelect:e=>{t.executeAction(zO),e.preventDefault()},children:e(`labels.arrowBinding`)})},CR=()=>{let{t:e}=ix(),t=vU(),n=Kw();return(0,W.jsx)(uj,{checked:n.isMidpointSnappingEnabled,onSelect:e=>{t.executeAction(BO),e.preventDefault()},children:e(`labels.midpointSnapping`)})},wR=()=>{let{t:e}=ix(),t=vU(),n=Kw();return(0,W.jsx)(uj,{checked:n.gridModeEnabled,shortcut:Kk(`gridMode`),onSelect:e=>{t.executeAction(IO),e.preventDefault()},children:e(`labels.toggleGrid`)})},TR=()=>{let{t:e}=ix(),t=vU(),n=Kw();return(0,W.jsx)(uj,{checked:n.zenModeEnabled,shortcut:Kk(`zenMode`),onSelect:e=>{t.executeAction(LO),e.preventDefault()},children:e(`buttons.zenMode`)})},ER=()=>{let{t:e}=ix(),t=vU(),n=Kw();return t.isActionEnabled(Fj)?(0,W.jsx)(uj,{checked:n.viewModeEnabled,shortcut:Kk(`viewMode`),onSelect:e=>{t.executeAction(Fj),e.preventDefault()},children:e(`labels.viewMode`)}):null},DR=()=>{let{t:e}=ix(),t=vU(),n=Kw();return(0,W.jsx)(uj,{checked:n.stats.open,shortcut:Kk(`stats`),onSelect:e=>{t.executeAction(VO),e.preventDefault()},children:e(`stats.fullTitle`)})},OR=({children:e,additionalItems:t})=>{let{t:n}=ix();return(0,W.jsxs)(sj,{children:[(0,W.jsx)(sj.Trigger,{icon:Dw,children:n(`labels.preferences`)}),(0,W.jsxs)(sj.Content,{className:`excalidraw-main-menu-preferences-submenu`,children:[e||(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(yR,{}),(0,W.jsx)(bR,{}),(0,W.jsx)(vR,{}),(0,W.jsx)(xR,{}),(0,W.jsx)(wR,{}),(0,W.jsx)(TR,{}),(0,W.jsx)(ER,{}),(0,W.jsx)(DR,{}),(0,W.jsx)(SR,{}),(0,W.jsx)(CR,{})]}),t]})]})};OR.ToggleToolLock=vR,OR.BoxSelectionMode=yR,OR.InputDevice=bR,OR.ToggleSnapMode=xR,OR.ToggleArrowBinding=SR,OR.ToggleMidpointSnapping=CR,OR.ToggleGridMode=wR,OR.ToggleZenMode=TR,OR.ToggleViewMode=ER,OR.ToggleElementProperties=DR,OR.displayName=`Preferences`;var kR=Object.assign($L(`MainMenu`,({children:e,onSelect:t})=>{let{MainMenuTunnel:n}=yL(),r=fU(),i=Kw(),a=dU(),o=_U();return(0,W.jsx)(n.In,{children:(0,W.jsxs)(Q,{open:i.openMenu===`canvas`,children:[(0,W.jsx)(Q.Trigger,{onToggle:()=>{o({openMenu:i.openMenu===`canvas`?null:`canvas`,openPopup:null,openDialog:null})},"data-testid":`main-menu-trigger`,className:`main-menu-trigger`,children:Vx}),(0,W.jsxs)(Q.Content,{onClickOutside:()=>o({openMenu:null}),onSelect:us(t,()=>{o({openMenu:null})}),className:`main-menu`,align:`start`,children:[e,r.formFactor===`phone`&&i.collaborators.size>0&&(0,W.jsxs)(`fieldset`,{className:`UserList-Wrapper`,children:[(0,W.jsx)(`legend`,{children:K(`labels.collaborators`)}),(0,W.jsx)(zL,{mobile:!0,collaborators:i.collaborators,userToFollow:a.userToFollow?.socketId||null,currentUserControls:a.currentUserControls})]})]})]})})}),{Trigger:Q.Trigger,Item:Q.Item,ItemLink:Q.ItemLink,ItemCustom:Q.ItemCustom,Group:Q.Group,Separator:Q.Separator,Sub:sj,DefaultItems:eR}),AR=(0,H.forwardRef)(({children:e,icon:t,onClick:n,label:r,variant:i=`filled`,color:a=`primary`,size:o=`medium`,fullWidth:s,className:c,status:l,disabled:u},d)=>{let[f,p]=(0,H.useState)(!1),m=async e=>{let t=n?.(e);if(Zs(t)){let e=window.setTimeout(()=>{p(!0)},50);try{await t}catch(e){if(e instanceof Js)console.warn(e);else throw e}finally{clearTimeout(e),p(!1)}}},h=f?`loading`:l;return a=h===`success`?`success`:a,(0,W.jsx)(`button`,{className:U(`ExcButton`,`ExcButton--color-${a}`,`ExcButton--variant-${i}`,`ExcButton--size-${o}`,`ExcButton--status-${h}`,{"ExcButton--fullWidth":s},c),onClick:m,type:`button`,"aria-label":r,ref:d,disabled:u||h===`loading`||h===`success`,children:(0,W.jsxs)(`div`,{className:`ExcButton__contents`,children:[h===`loading`?(0,W.jsx)(Ow,{className:`ExcButton__statusIcon`}):h===`success`&&(0,W.jsx)(`div`,{className:`ExcButton__statusIcon`,children:OC}),t&&(0,W.jsx)(`div`,{className:`ExcButton__icon`,"aria-hidden":!0,children:t}),i!==`icon`&&(e??r)]})})}),jR=({title:e,children:t,actionLabel:n,onClick:r})=>(0,W.jsxs)(`div`,{className:`OverwriteConfirm__Actions__Action`,children:[(0,W.jsx)(`h4`,{children:e}),(0,W.jsx)(`div`,{className:`OverwriteConfirm__Actions__Action__content`,children:t}),(0,W.jsx)(AR,{variant:`outlined`,color:`muted`,label:n,size:`large`,fullWidth:!0,onClick:r})]}),MR=Object.assign(({children:e})=>(0,W.jsx)(`div`,{className:`OverwriteConfirm__Actions`,children:e}),{ExportToImage:()=>{let{t:e}=ix(),t=vU(),n=_U();return(0,W.jsx)(jR,{title:e(`overwriteConfirm.action.exportToImage.title`),actionLabel:e(`overwriteConfirm.action.exportToImage.button`),onClick:()=>{t.executeAction(QD,`ui`,!0),n({openDialog:{name:`imageExport`}})},children:e(`overwriteConfirm.action.exportToImage.description`)})},SaveToDisk:()=>{let{t:e}=ix(),t=vU();return(0,W.jsx)(jR,{title:e(`overwriteConfirm.action.saveToDisk.title`),actionLabel:e(`overwriteConfirm.action.saveToDisk.button`),onClick:()=>{t.executeAction(iO,`ui`)},children:e(`overwriteConfirm.action.saveToDisk.description`)})}}),NR=Object.assign($L(`OverwriteConfirmDialog`,({children:e})=>{let{OverwriteConfirmDialogTunnel:t}=yL(),[n,r]=Vb(tR);return n.active?(0,W.jsx)(t.In,{children:(0,W.jsx)(Pj,{onCloseRequest:()=>{n.onClose(),r(e=>({...e,active:!1}))},title:!1,size:916,children:(0,W.jsxs)(`div`,{className:`OverwriteConfirm`,children:[(0,W.jsx)(`h3`,{children:n.title}),(0,W.jsxs)(`div`,{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${n.color}`,children:[(0,W.jsx)(`div`,{className:`OverwriteConfirm__Description__icon`,children:kC}),(0,W.jsx)(`div`,{children:n.description}),(0,W.jsx)(`div`,{className:`OverwriteConfirm__Description__spacer`}),(0,W.jsx)(AR,{color:n.color,size:`large`,label:n.actionLabel,onClick:()=>{n.onConfirm(),r(e=>({...e,active:!1}))}})]}),(0,W.jsx)(MR,{children:e})]})})}):null}),{Actions:MR,Action:jR}),PR=yl(``),FR=yl(null),IR=350,LR=()=>{let e=uU(),t=_U(),n=(0,H.useRef)(null),[r,i]=Vb(PR),a=r.trim(),[o,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)({nonce:null,items:[]}),u=(0,H.useRef)(null),d=(0,H.useRef)(void 0),[f,p]=Vb(FR),m=e.scene.getNonDeletedElementsMap();(0,H.useEffect)(()=>{o||(a!==u.current||e.scene.getSceneNonce()!==d.current)&&(u.current=null,GR(a,e,(n,r)=>{l({nonce:Zt(),items:n}),u.current=a,d.current=e.scene.getSceneNonce(),t({searchMatches:n.length?{focusedId:null,matches:n.map(e=>({id:e.element.id,focus:!1,matchedLines:e.matchedLines}))}:null})}))},[o,a,m,e,t,p,d]);let h=()=>{c.items.length>0&&p(e=>e===null?0:(e+1)%c.items.length)},g=()=>{c.items.length>0&&p(e=>e===null?0:e-1<0?c.items.length-1:e-1)};(0,H.useEffect)(()=>{t(e=>e.searchMatches?{searchMatches:{focusedId:f!==null&&e.searchMatches?.matches[f]?.id||null,matches:e.searchMatches.matches.map((e,t)=>t===f?{...e,focus:!0}:{...e,focus:!1})}}:null)},[f,t]),(0,H.useEffect)(()=>{if(c.items.length>0&&f!==null){let t=c.items[f];if(t){let n=e.state.zoom.value,r=Ir({text:t.searchQuery,x:t.element.x+(t.matchedLines[0]?.offsetX??0),y:t.element.y+(t.matchedLines[0]?.offsetY??0),width:t.matchedLines[0]?.width,height:t.matchedLines[0]?.height,fontSize:R(t.element)?sa.nameFontSize:t.element.fontSize,fontFamily:R(t.element)?On.Assistant:t.element.fontFamily}),i=r.fontSize,a=i*n<14;if(!Ht([r],e.canvas.width/e.ownerWindow.devicePixelRatio,e.canvas.height/e.ownerWindow.devicePixelRatio,{offsetLeft:e.state.offsetLeft,offsetTop:e.state.offsetTop,scrollX:e.state.scrollX,scrollY:e.state.scrollY,zoom:e.state.zoom},e.scene.getNonDeletedElementsMap(),e.viewport.getOffsets())||a){let t=a&&i<14?`contain`:`scale-down`;e.viewport.setViewport({target:Wr([r]),fit:t,animation:{duration:300},offsets:{ui:!0}})}}}},[f,c,e]),(0,H.useEffect)(()=>()=>{p(null),u.current=null,d.current=void 0,t({searchMatches:null}),s(!1)},[t,p]);let _=Yw({goToNextItem:h,goToPreviousItem:g,searchMatches:c});(0,H.useEffect)(()=>vo(e.ownerWindow,B.KEYDOWN,r=>{let i=r.target;if(r.key===L.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){r.preventDefault(),r.stopPropagation(),t({openSidebar:null});return}if(r[L.CTRL_OR_CMD]&&r.key===L.F){if(r.preventDefault(),r.stopPropagation(),e.state.openDialog)return;n.current?.matches(`:focus`)||(e.state.openDialog&&t({openDialog:null}),n.current?.focus(),n.current?.select())}i instanceof e.ownerWindow.HTMLElement&&i.closest(`.layer-ui__search`)&&_.searchMatches.items.length&&(r.key===L.ENTER&&(r.stopPropagation(),_.goToNextItem()),r.key===L.ARROW_UP?(r.stopPropagation(),_.goToPreviousItem()):r.key===L.ARROW_DOWN&&(r.stopPropagation(),_.goToNextItem()))},{capture:!0,passive:!1}),[t,_,e]);let v=`${c.items.length} ${c.items.length===1?K(`search.singleResult`):K(`search.multipleResults`)}`;return(0,W.jsxs)(`div`,{className:`layer-ui__search`,children:[(0,W.jsx)(`div`,{className:`layer-ui__search-header`,children:(0,W.jsx)(Sj,{className:Ai.SEARCH_MENU_INPUT_WRAPPER,value:r,ref:n,placeholder:K(`search.placeholder`),icon:KC,onChange:n=>{i(n),s(!0);let r=n.trim();GR(r,e,(n,i)=>{l({nonce:Zt(),items:n}),p(i),u.current=r,d.current=e.scene.getSceneNonce(),t({searchMatches:n.length?{focusedId:null,matches:n.map(e=>({id:e.element.id,focus:!1,matchedLines:e.matchedLines}))}:null}),s(!1)})},selectOnRender:!0})}),(0,W.jsxs)(`div`,{className:`layer-ui__search-count`,children:[c.items.length>0&&(0,W.jsxs)(W.Fragment,{children:[f!==null&&f>-1?(0,W.jsxs)(`div`,{children:[f+1,` / `,v]}):(0,W.jsx)(`div`,{children:v}),(0,W.jsxs)(`div`,{className:`result-nav`,children:[(0,W.jsx)(xj,{onSelect:()=>{h()},className:`result-nav-btn`,children:hw}),(0,W.jsx)(xj,{onSelect:()=>{g()},className:`result-nav-btn`,children:_w})]})]}),c.items.length===0&&a&&u.current&&(0,W.jsx)(`div`,{style:{margin:`1rem auto`},children:K(`search.noMatch`)})]}),(0,W.jsx)(zR,{matches:c,onItemClick:p,focusIndex:f,searchQuery:a})]})},RR=e=>{let t=[e.preview.moreBefore?`...`:``,e.preview.previewText.slice(0,e.preview.indexInSearchQuery),e.preview.previewText.slice(e.preview.indexInSearchQuery,e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.previewText.slice(e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.moreAfter?`...`:``];return(0,W.jsx)(`div`,{tabIndex:-1,className:U(`layer-ui__result-item`,{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:`auto`,block:`nearest`})},children:(0,W.jsx)(`div`,{className:`preview-text`,children:t.flatMap((e,t)=>(0,W.jsx)(H.Fragment,{children:t===2?(0,W.jsx)(`b`,{children:e}):e},t))})})},zR=(0,H.memo)(e=>{let t=(0,H.useMemo)(()=>e.matches.items.filter(e=>R(e.element)),[e.matches]),n=(0,H.useMemo)(()=>e.matches.items.filter(e=>z(e.element)),[e.matches]);return(0,W.jsxs)(`div`,{children:[t.length>0&&(0,W.jsxs)(`div`,{className:`layer-ui__search-result-container`,children:[(0,W.jsxs)(`div`,{className:`layer-ui__search-result-title`,children:[(0,W.jsx)(`div`,{className:`title-icon`,children:MC}),(0,W.jsx)(`div`,{children:K(`search.frames`)})]}),t.map((t,n)=>(0,W.jsx)(RR,{searchQuery:e.searchQuery,preview:t.preview,highlighted:n===e.focusIndex,onClick:()=>e.onItemClick(n)},t.element.id+t.index)),n.length>0&&(0,W.jsx)(`div`,{className:`layer-ui__divider`})]}),n.length>0&&(0,W.jsxs)(`div`,{className:`layer-ui__search-result-container`,children:[(0,W.jsxs)(`div`,{className:`layer-ui__search-result-title`,children:[(0,W.jsx)(`div`,{className:`title-icon`,children:kx}),(0,W.jsx)(`div`,{children:K(`search.texts`)})]}),n.map((n,r)=>(0,W.jsx)(RR,{searchQuery:e.searchQuery,preview:n.preview,highlighted:r+t.length===e.focusIndex,onClick:()=>e.onItemClick(r+t.length)},n.element.id+n.index))]})]})},(e,t)=>e.matches.nonce===t.matches.nonce&&e.focusIndex===t.focusIndex),BR=(e,t,n)=>{let r=e.slice(0,t),i=r.split(/\s+/),a=r.endsWith(` `),o=i.length-2-1-!a,s=i.slice(o<=0?0:o).join(` `)+(a?` `:``);s=s.length>20?s.slice(-20):s;let c=e.slice(t+n.length),l=c.split(/\s+/),u=!c.startsWith(` `),d=u?6:5,f=(u?``:` `)+l.slice(0,d).join(` `);return{indexInSearchQuery:s.length,previewText:s+n+f,moreBefore:o>0,moreAfter:l.length>d}},VR=(e,t)=>{let n=e.split(`
|
|
59
|
+
`),r=[],i=0;for(let e=0;e<n.length;e++){let a=n[e],o=n[e+1];if(o){let e=t.indexOf(o,i);if(e>a.length+i){let t=e-(a.length+i);for(;t>0;)a+=` `,t--}}r.push(a),i+=a.length}return r.join(`
|
|
60
|
+
`)},HR=(e,t,n)=>{let r=VR(e.text,e.originalText).split(`
|
|
61
|
+
`),i=[],a=0,o=0;for(let e of r){let t=a,n=t+e.length-1;i.push({line:e,startIndex:t,endIndex:n,lineNumber:o}),a=n+1,o++}let s=n,c=e.originalText.slice(n,n+t.length),l=[];for(let t of i){if(c===``)break;if(s>=t.startIndex&&s<=t.endIndex){let n=t.endIndex+1-s,r=t.line.slice(0,s-t.startIndex),i=c.slice(0,n);c=c.slice(n);let a=Di(r,Ro(e),e.lineHeight);if(r===``&&(a.width=0),e.textAlign!==`left`&&t.line.length>0){let n=Di(t.line,Ro(e),e.lineHeight),r=e.textAlign===`center`?(e.width-n.width)/2:e.width-n.width;a.width+=r}let{width:o,height:u}=Di(i,Ro(e),e.lineHeight),d=a.width,f=t.lineNumber*a.height;l.push({offsetX:d,offsetY:f,width:o,height:u,showOnCanvas:!0}),s+=n}}return l},UR=(e,t,n,r)=>{let i=e.name??No(e),a=i.slice(n,n+t.length),o=i.slice(0,n),s=Ro({fontSize:sa.nameFontSize,fontFamily:On.Assistant}),c=qt(On.Assistant),l=Di(o,s,c);o===``&&(l.width=0);let u=Di(a,s,c),d=l.width,f=-l.height-sa.strokeWidth,p=u.width;return[{offsetX:d,offsetY:f,width:p,height:u.height,showOnCanvas:d+p<=e.width*r}]},WR=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,`\\$&`),GR=(0,zb.default)((e,t,n)=>{if(!e||e===``){n([],null);return}let r=t.scene.getNonDeletedElements(),i=r.filter(e=>z(e)),a=r.filter(e=>R(e));i.sort((e,t)=>e.y-t.y),a.sort((e,t)=>e.y-t.y);let o=[],s=new RegExp(WR(e),`gi`);for(let t of i){let n=null,r=t.originalText;for(;(n=s.exec(r))!==null;){let i=BR(r,n.index,e),a=HR(t,e,n.index);a.length>0&&o.push({element:t,searchQuery:e,preview:i,index:n.index,matchedLines:a})}}let c=[];for(let n of a){let r=null,i=n.name??No(n);for(;(r=s.exec(i))!==null;){let a=BR(i,r.index,e),o=UR(n,e,r.index,t.state.zoom.value);o.length>0&&c.push({element:n,searchQuery:e,preview:a,index:r.index,matchedLines:o})}}let l=new Set(t.visibleElements.map(e=>e.id)),u=[...c,...o];n(u,u.findIndex(e=>l.has(e.element.id))??null)},IR),KR=$L(`DefaultSidebarTrigger`,e=>{let{DefaultSidebarTriggerTunnel:t}=yL();return(0,W.jsx)(t.In,{children:(0,W.jsx)(QL.Trigger,{...e,className:`default-sidebar-trigger`,name:Gi.name})})});KR.displayName=`DefaultSidebarTrigger`;var qR=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:t}=yL();return(0,W.jsx)(t.In,{children:e})};qR.displayName=`DefaultTabTriggers`;var JR=Object.assign($L(`DefaultSidebar`,({children:e,className:t,onDock:n,docked:r,...i})=>{let a=Kw(),o=_U(),{DefaultSidebarTabTriggersTunnel:s}=yL(),c=a.openSidebar?.tab===tt;return(0,H.createElement)(QL,{...i,name:`default`,key:`default`,className:U(`default-sidebar`,t),docked:c||(r??a.defaultSidebarDockedPreference),onDock:c||n===!1||!n&&r!=null?void 0:us(n,e=>{o({defaultSidebarDockedPreference:e})})},(0,W.jsxs)(QL.Tabs,{children:[(0,W.jsx)(QL.Header,{children:(0,W.jsxs)(QL.TabTriggers,{children:[(0,W.jsx)(QL.TabTrigger,{tab:tt,children:KC}),(0,W.jsx)(QL.TabTrigger,{tab:po,children:cx}),(0,W.jsx)(s.Out,{})]})}),(0,W.jsx)(QL.Tab,{tab:po,children:(0,W.jsx)(jj,{})}),(0,W.jsx)(QL.Tab,{tab:tt,children:(0,W.jsx)(LR,{})}),e]}))}),{Trigger:KR,TabTriggers:qR}),YR=300,XR=({input:e,placeholder:t,onChange:r,onKeyboardSubmit:i,errorLine:a})=>{let o=(0,H.useRef)(null),s=(0,H.useRef)(i);s.current=i;let[c,l]=(0,H.useState)({type:`loading`}),[u,d]=(0,H.useState)(!1),{theme:f}=Kw();if((0,H.useEffect)(()=>{let e=!1,t=setTimeout(()=>{e||d(!0)},YR);return n(()=>import(`./CodeMirrorEditor-UCMRAMCV-kJfwukbn.js`).then(t=>{e||l({type:`ready`,component:t.default})}),[],import.meta.url).catch(()=>{e||l({type:`fallback`})}).finally(()=>{clearTimeout(t)}),()=>{e=!0,clearTimeout(t)}},[]),(0,H.useEffect)(()=>{if(c.type!==`fallback`||!s.current)return;let e=o.current;if(e){let t=e=>{e[L.CTRL_OR_CMD]&&e.key===L.ENTER&&(e.preventDefault(),s.current?.())};return e.focus(),e.addEventListener(B.KEYDOWN,t),()=>{e.removeEventListener(B.KEYDOWN,t)}}},[c.type]),c.type===`ready`){let n=c.component;return(0,W.jsx)(n,{value:e,onChange:r,onKeyboardSubmit:i,placeholder:t,theme:f,errorLine:a})}return c.type===`fallback`?(0,W.jsx)(`textarea`,{className:`ttd-dialog-input`,onChange:e=>r(e.target.value),value:e,placeholder:t,ref:o}):u?(0,W.jsx)(`div`,{className:`ttd-dialog-input ttd-dialog-input--loading`,children:(0,W.jsx)(Ow,{})}):null},ZR=/(?:Parse|Lexical) error on line (\d+)[.:]/i,QR=/Trying to inactivate an inactive participant \((.+)\)/i,$R=/^\s*-+\^\s*$/,ez=e=>ZR.test(e),tz=e=>ez(e)||QR.test(e),nz=e=>$R.test(e),rz=e=>{let t=e.match(QR);return t?.[1]?t[1].trim():null},iz=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),az=(e,t)=>{let n=rz(e);if(!n)return null;let r=RegExp(`^\\s*deactivate\\s+${iz(n)}(?:\\s+%%.*)?\\s*$`),i=t.split(/\r?\n/);for(let e=i.length-1;e>=0;e--)if(r.test(i[e]))return e+1;return null},oz=(e,t)=>{let n=e.match(ZR);return n?Number.parseInt(n[1],10):t?az(e,t):null},sz=(e,t)=>(e.match(t)||[]).length,cz=(e,t)=>{if(!ez(e))return null;let n=oz(e,t),r=n?`Syntax error near line ${n}.`:`Syntax error in Mermaid diagram.`,i=[];return t&&(sz(t,/\[/g)!==sz(t,/\]/g)&&i.push(`Unbalanced square brackets in a node label.`),sz(t,/\(/g)!==sz(t,/\)/g)&&i.push(`Unbalanced parentheses in a node shape.`),sz(t,/\{/g)!==sz(t,/\}/g)&&i.push(`Unbalanced braces in a decision node.`),sz(t,/^\s*subgraph\b/gm)>sz(t,/^\s*end\s*$/gm)&&i.push("A block is missing an `end` statement.")),(/got 'NODE_STRING'/.test(e)||/got 'PS'/.test(e))&&i.push(`An extra character/token may appear after a node or label definition.`),i.length===0&&(i.push(`A node or edge line is malformed (missing/extra delimiters).`),i.push("A block (`subgraph`, `class`, etc.) may be incomplete.")),{summary:r,likelyCauses:[...new Set(i)]}},lz=e=>ez(e)?e.replace(/\n\s*Expecting[\s\S]*$/,``).trimEnd():e,uz=({error:e,canvasRef:t,loaded:n,hideErrorDetails:r,sourceText:i,autoFixAvailable:a,onApplyAutoFix:o})=>{let s=e?r?K(`chat.errors.mermaidParseError`):lz(e.message):null,c=e&&!r?cz(e.message,i):null,l=!!a&&!!o&&!r,u=s?.split(/\r?\n/)??[];return(0,W.jsxs)(`div`,{className:`ttd-dialog-output-wrapper ${e?`ttd-dialog-output-wrapper--error`:``}`,children:[e&&(0,W.jsx)(`div`,{"data-testid":`ttd-dialog-output-error`,className:`ttd-dialog-output-error`,children:(0,W.jsxs)(`div`,{className:`ttd-dialog-output-error-content`,children:[(0,W.jsx)(`div`,{className:`ttd-dialog-output-error-icon`,children:kC}),c&&(0,W.jsxs)(`div`,{className:`ttd-dialog-output-error-summary`,children:[(0,W.jsx)(`div`,{className:`ttd-dialog-output-error-summary__headline`,children:c.summary}),(0,W.jsx)(`div`,{className:`ttd-dialog-output-error-summary__label`,children:`Likely causes:`}),(0,W.jsx)(`ul`,{className:`ttd-dialog-output-error-summary__causes`,children:c.likelyCauses.map(e=>(0,W.jsx)(`li`,{children:e},e))})]}),(0,W.jsx)(`div`,{className:`ttd-dialog-output-error-message`,children:u.map((e,t)=>(0,W.jsxs)(`span`,{className:nz(e)?`ttd-dialog-output-error-message__caret`:void 0,children:[e,t<u.length-1?`
|
|
62
|
+
`:``]},`error-line-${t}`))}),!r&&(0,W.jsx)(`div`,{className:`ttd-dialog-output-error-autofix-slot`,children:l?(0,W.jsx)(xj,{className:`ttd-dialog-panel-button ttd-dialog-output-error-autofix`,onSelect:o,children:K(`mermaid.autoFixAvailable`)}):null})]})},`error`),n?(0,W.jsx)(`div`,{className:U(`ttd-dialog-output-canvas-container`,{invisible:!!e}),children:(0,W.jsx)(`div`,{ref:t,className:`ttd-dialog-output-canvas-content`})},`canvas`):(0,W.jsx)(Ow,{size:`2rem`})]})},dz=({label:e,children:t,panelActions:n=[],onTextSubmitInProgess:r,renderTopRight:i,renderSubmitShortcut:a,className:o,panelActionJustifyContent:s=`flex-start`})=>{let c=e=>{if(e?.variant===`link`)return(0,W.jsxs)(`button`,{className:U(`ttd-dialog-panel-action-link`,e.className),onClick:e.action,disabled:e?.disabled||r,type:`button`,children:[e.label,e.icon&&(0,W.jsx)(`span`,{className:`ttd-dialog-panel-action-link__icon`,children:e.icon})]});if(e?.variant===`button`)return(0,W.jsxs)(xj,{className:U(`ttd-dialog-panel-button`,e.className),onSelect:e.action?e.action:()=>{},disabled:e?.disabled||r,children:[(0,W.jsxs)(`div`,{className:U({invisible:r}),children:[e?.label,e?.icon&&(0,W.jsx)(`span`,{children:e.icon})]}),r&&(0,W.jsx)(Ow,{})]});if(e?.variant===`rateLimit`)return(0,W.jsx)(`div`,{className:U(`ttd-dialog-panel__rate-limit`,e.className),children:e.label})};return(0,W.jsxs)(`div`,{className:U(`ttd-dialog-panel`,o),children:[(e||i)&&(0,W.jsxs)(`div`,{className:`ttd-dialog-panel__header`,children:[typeof e==`string`?(0,W.jsx)(`label`,{children:e}):e,i?.()]}),t,(0,W.jsxs)(`div`,{className:U(`ttd-dialog-panel-button-container`,{invisible:!n.length}),style:{justifyContent:s},children:[n.filter(Boolean).map(e=>(0,W.jsx)(H.Fragment,{children:c(e)},e.label)),!r&&a?.()]})]})},fz=({children:e})=>(0,W.jsx)(`div`,{className:`ttd-dialog-panels`,children:e}),pz=()=>(0,W.jsxs)(`div`,{className:`ttd-dialog-submit-shortcut`,children:[(0,W.jsx)(`div`,{className:`ttd-dialog-submit-shortcut__key`,children:Z(`CtrlOrCmd`)}),(0,W.jsx)(`div`,{className:`ttd-dialog-submit-shortcut__key`,children:Z(`Enter`)})]}),mz=(e,t)=>{let n=oz(e,t);return n==null?null:n-1},hz=(e,t,n)=>{if(t<0||t>=e.length)return null;let r=n(e[t]);if(r===e[t])return null;let i=[...e];return i[t]=r,i.join(`
|
|
63
|
+
`)},gz=e=>{let t=e.match(/^(.*(?:\[[^\]]*]|\([^)]*\)|\{[^}]*}|"(?:[^"]*)"|'(?:[^']*)'))([A-Za-z]+)\s*$/);if(t)return t[1];let n=e.match(/^(.*(?:\[[^\]]*]|\([^)]*\)|\{[^}]*}|"(?:[^"]*)"|'(?:[^']*)'))([,;:])\s*$/);return n?n[1]:e},_z=e=>e.replace(/(\|[^|\n]+\|)\s*>\s*(?=[A-Za-z0-9_("[{'`])/g,`$1 `),vz=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),yz=(e,t)=>{let n=RegExp(`^\\s*deactivate\\s+${vz(t)}(?:\\s+%%.*)?\\s*$`),r=e.split(/\r?\n/);for(let e=r.length-1;e>=0;e--)if(n.test(r[e]))return r.filter((t,n)=>n!==e).join(`
|
|
64
|
+
`);return null},bz=(e,t)=>{let n=RegExp(`^\\s*deactivate\\s+${vz(t)}(?:\\s+%%.*)?\\s*$`),r=e.split(/\r?\n/),i=!1,a=r.filter(e=>!n.test(e)||(i=!0,!1));return i?a.join(`
|
|
65
|
+
`):null},xz=e=>{let t=(e.match(/^\s*subgraph\b/gm)||[]).length-(e.match(/^\s*end\s*$/gm)||[]).length;if(t<=0)return null;let n=Array.from({length:t},()=>`end`).join(`
|
|
66
|
+
`);return`${e.trimEnd()}
|
|
67
|
+
${n}`},Sz=e=>e.replace(/[“”]/g,`"`).replace(/[‘’]/g,`'`),Cz=(e,t)=>{if(!tz(t)||!e.trim())return[];let n=[],r=new Set,i=t=>{!t||t===e||r.has(t)||(r.add(t),n.push(t))},a=rz(t);if(a&&(i(yz(e,a)),i(bz(e,a))),ez(t)){let n=e.split(/\r?\n/),r=mz(t,e),a=r==null?[]:[r,r-1,r+1];for(let e of a)i(hz(n,e,e=>gz(e))),i(hz(n,e,e=>_z(e)));i(_z(e)),i(xz(e));let o=Sz(e);i(o===e?null:o)}return n},wz=({canvasRef:e,setError:t})=>{let n=e.current;if(!n)return;let r=n.parentElement;r&&(r.style.background=``,t(null),n.replaceChildren())},Tz=async({canvasRef:e,mermaidToExcalidrawLib:t,mermaidDefinition:n,setError:r,data:i,theme:a})=>{let o=e.current,s=o?.parentElement;if(!o||!s)return{success:!1};if(!n)return wz({canvasRef:e,setError:r}),{success:!1};let c;try{let e=await t.api;try{c=await e.parseMermaidToExcalidraw(n)}catch(t){let r=t;if(!n.includes(`"`))return{success:!1,error:r};try{c=await e.parseMermaidToExcalidraw(n.replace(/"/g,`'`))}catch{return{success:!1,error:r}}}let{elements:l,files:u={}}=c;r(null),i.current={elements:yo(l,{regenerateIds:!0}),files:u};let d=await Qk({elements:i.current.elements,files:i.current.files,exportPadding:10,maxWidthOrHeight:Math.max(s.offsetWidth,s.offsetHeight)*window.devicePixelRatio,appState:{exportWithDarkMode:a===P.DARK}});return s.style.background=`var(--default-bg-color)`,o.replaceChildren(d),{success:!0}}catch(e){return s.style.background=`var(--default-bg-color)`,n&&r(e),{success:!1,error:e}}},Ez=e=>{jA.set(es.MERMAID_TO_EXCALIDRAW,e)},Dz=({app:e,data:t,text:n,shouldSaveMermaidDataToStorage:r})=>{let{elements:i,files:a}=t.current;i.length&&(e.addElementsFromPasteOrLibrary({elements:i,files:a,position:`center`,fit:`scale-down`}),e.setOpenDialog(null),r&&n&&Ez(n))},Oz=`flowchart TD
|
|
68
|
+
A[Christmas] -->|Get money| B(Go shopping)
|
|
69
|
+
B --> C{Let me think}
|
|
70
|
+
C -->|One| D[Laptop]
|
|
71
|
+
C -->|Two| E[iPhone]
|
|
72
|
+
C -->|Three| F[Car]`,kz=ws(Ez,300),Az=500,jz=4,Mz=30,Nz=e=>e instanceof Error?e.message:typeof e==`string`?e:e&&typeof e==`object`&&`message`in e&&typeof e.message==`string`?e.message:``,Pz=({mermaidToExcalidrawLib:e,isActive:t})=>{let[n,r]=(0,H.useState)(()=>jA.get(es.MERMAID_TO_EXCALIDRAW)||Oz),i=(0,H.useDeferredValue)(n),[a,o]=(0,H.useState)(null),[s,c]=(0,H.useState)(null),l=a?.message?oz(a.message,i):null,u=(0,H.useRef)(null),d=(0,H.useRef)({elements:[],files:null}),f=uU(),{theme:p}=Kw();(0,H.useEffect)(()=>{t&&((async()=>{try{if(!i.trim()){wz({canvasRef:u,setError:o});return}let t=await Tz({canvasRef:u,data:d,mermaidToExcalidrawLib:e,setError:o,mermaidDefinition:i,theme:p});if(!t.success){let e=t.error??Error(`Invalid mermaid definition`);o(e)}}catch(e){rt()&&console.error(`Failed to parse mermaid definition`,e)}})(),kz(i))},[i,e,t,p]),(0,H.useEffect)(()=>()=>{kz.flush()},[]),(0,H.useEffect)(()=>{let n=a?.message??``,r=i;if(!(t&&tz(n)&&r.trim()&&e.loaded)){c(null);return}let o=Cz(r,n);if(!o.length){c(null);return}let s=!1,l=setTimeout(async()=>{try{let t=await e.api,n=new Set([r]),i=o.map(e=>({text:e,depth:1})),a=0;for(;i.length>0&&a<Mz;){let e=i.shift();if(e&&!n.has(e.text)){n.add(e.text),a+=1;try{await t.parseMermaidToExcalidraw(e.text),s||c(e.text);return}catch(t){if(e.depth>=jz)continue;let r=Nz(t);if(!r)continue;let a=Cz(e.text,r);for(let t of a)n.has(t)||i.push({text:t,depth:e.depth+1})}}}}catch{}s||c(null)},Az);return()=>{s=!0,clearTimeout(l)}},[i,a?.message,t,e]);let m=()=>{Dz({app:f,data:d,text:n,shouldSaveMermaidDataToStorage:!0})};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`ttd-dialog-desc`,children:(0,W.jsx)(LA,{i18nKey:`mermaid.description`,flowchartLink:e=>(0,W.jsx)(`a`,{href:`https://mermaid.js.org/syntax/flowchart.html`,target:`_blank`,rel:`noreferrer`,children:e}),sequenceLink:e=>(0,W.jsx)(`a`,{href:`https://mermaid.js.org/syntax/sequenceDiagram.html`,target:`_blank`,rel:`noreferrer`,children:e}),classLink:e=>(0,W.jsx)(`a`,{href:`https://mermaid.js.org/syntax/classDiagram.html`,target:`_blank`,rel:`noreferrer`,children:e}),erdLink:e=>(0,W.jsx)(`a`,{href:`https://mermaid.js.org/syntax/entityRelationshipDiagram.html`,target:`_blank`,rel:`noreferrer`,children:e})})}),(0,W.jsxs)(fz,{children:[(0,W.jsx)(dz,{children:(0,W.jsx)(XR,{input:n,placeholder:K(`mermaid.inputPlaceholder`),onChange:e=>r(e),errorLine:l,onKeyboardSubmit:()=>{m()}})}),(0,W.jsx)(dz,{panelActions:[{action:()=>{m()},label:K(`mermaid.button`),icon:LC,variant:`button`}],renderSubmitShortcut:()=>(0,W.jsx)(pz,{}),children:(0,W.jsx)(uz,{canvasRef:u,loaded:e.loaded,error:a,sourceText:n,autoFixAvailable:!!s,onApplyAutoFix:()=>{s&&r(s)}})})]})]})},Fz=()=>(0,W.jsxs)(`div`,{className:`chat-interface__welcome-screen__welcome-message`,children:[(0,W.jsx)(`h3`,{children:K(`chat.placeholder.title`)}),(0,W.jsx)(`p`,{children:K(`chat.placeholder.description`)}),(0,W.jsx)(`p`,{children:K(`chat.placeholder.hint`)})]}),Iz=({message:e,onMermaidTabClick:t,onAiRepairClick:n,onDeleteMessage:r,onInsertMessage:i,onRetry:a,rateLimitRemaining:o,isLastMessage:s,renderWarning:c,allowFixingParseError:l})=>{let[u,d]=(0,H.useState)(!1);(0,H.useEffect)(()=>{if(!e.error||!s)return;if(e.error&&!e.lastAttemptAt){d(!0);return}let t=Date.now()-e.lastAttemptAt,n=Math.max(0,5e3-t);if(n===0){d(!0);return}d(!1);let r=setTimeout(()=>{d(!0)},n);return()=>clearTimeout(r)},[e.error,e.lastAttemptAt,s]);let f=e=>e.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});if(e.type===`warning`){let t=c?.(e);return(0,W.jsx)(`div`,{className:`chat-message chat-message--system`,children:(0,W.jsxs)(`div`,{className:`chat-message__content`,children:[(0,W.jsxs)(`div`,{className:`chat-message__header`,children:[(0,W.jsx)(`span`,{className:`chat-message__role`,children:K(`chat.role.system`)}),(0,W.jsx)(`span`,{className:`chat-message__timestamp`,children:f(e.timestamp)})]}),(0,W.jsx)(`div`,{className:`chat-message__body`,children:(0,W.jsx)(`div`,{className:`chat-message__text`,children:t||(e.warningType===`messageLimitExceeded`?(0,W.jsxs)(W.Fragment,{children:[K(`chat.rateLimit.messageLimit`),(0,W.jsx)(`div`,{style:{marginTop:`10px`},children:(0,W.jsx)(AR,{onClick:()=>{window.open(`${xa.VITE_APP_PLUS_LP}/plus?utm_source=excalidraw&utm_medium=app&utm_content=ttdChatBanner#excalidraw-redirect`,`_blank`,`noopener`)},children:K(`chat.upsellBtnLabel`)})})]}):K(`chat.rateLimit.generalRateLimit`))})})]})})}return(0,W.jsxs)(`div`,{className:`chat-message chat-message--${e.type}`,children:[(0,W.jsxs)(`div`,{className:`chat-message__content`,children:[(0,W.jsxs)(`div`,{className:`chat-message__header`,children:[(0,W.jsx)(`span`,{className:`chat-message__role`,children:e.type===`user`?K(`chat.role.user`):K(`chat.role.assistant`)}),(0,W.jsx)(`span`,{className:`chat-message__timestamp`,children:f(e.timestamp)})]}),(0,W.jsx)(`div`,{className:`chat-message__body`,children:e.error?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`chat-message__error`,children:e.content}),e.errorType!==`parse`&&(0,W.jsxs)(`div`,{className:`chat-message__error_message`,children:[`Error: `,e.error||K(`chat.errors.generationFailed`)]}),e.errorType===`parse`&&l&&(0,W.jsxs)(`div`,{className:`chat-message__error_message`,children:[(0,W.jsx)(`p`,{children:K(`chat.errors.invalidDiagram`)}),(0,W.jsxs)(`div`,{className:`chat-message__error-actions`,children:[t&&(0,W.jsx)(`button`,{className:`chat-message__error-link`,onClick:()=>t(e),type:`button`,children:K(`chat.errors.fixInMermaid`)}),n&&(0,W.jsx)(`button`,{className:`chat-message__error-link`,onClick:()=>n(e),disabled:o===0,type:`button`,children:K(`chat.errors.aiRepair`)})]})]})]}):(0,W.jsxs)(`div`,{className:`chat-message__text`,children:[e.content,e.isGenerating&&(0,W.jsx)(`span`,{className:`chat-message__cursor`,children:`▋`})]})})]}),e.type===`assistant`&&!e.isGenerating&&(0,W.jsxs)(`div`,{className:`chat-message__actions`,children:[!e.error&&i&&(0,W.jsx)(`button`,{className:`chat-message__action`,onClick:()=>i(e),type:`button`,"aria-label":K(`chat.insert`),title:K(`chat.insert`),children:IC}),t&&e.content&&(0,W.jsx)(`button`,{className:`chat-message__action`,onClick:()=>t(e),type:`button`,"aria-label":K(`chat.viewAsMermaid`),title:K(`chat.viewAsMermaid`),children:pC}),r&&e.errorType!==`network`&&(0,W.jsx)(`button`,{className:`chat-message__action chat-message__action--danger`,onClick:()=>r(e.id),type:`button`,"aria-label":K(`chat.deleteMessage`),title:K(`chat.deleteMessage`),children:Ix}),e.errorType===`network`&&a&&s&&(0,W.jsx)(`button`,{className:U(`chat-message__action`,{invisible:!u}),onClick:()=>a(e),type:`button`,"aria-label":K(`chat.retry`),title:K(`chat.retry`),children:FC})]})]})},Lz=({chatId:e,messages:t,currentPrompt:n,onPromptChange:r,onGenerate:i,isGenerating:a,rateLimits:o,onAbort:s,onMermaidTabClick:c,onAiRepairClick:l,onDeleteMessage:u,onInsertMessage:d,onRetry:f,renderWelcomeScreen:p,renderWarning:m})=>{let h=(0,H.useRef)(null),g=(0,H.useRef)(null);(0,H.useLayoutEffect)(()=>{h.current?.scrollIntoView()},[t]),(0,H.useEffect)(()=>{g.current&&g.current.focus()},[e]);let _=e=>{let t=e.target.value;r(t)},v=()=>{if(a&&s){s();return}let e=n.trim();e&&(i({prompt:e}),r(``))},y=e=>{e.key===L.ENTER&&!e.shiftKey&&(e.preventDefault(),a||v())},b=n.trim().length>3&&!a&&(o?.rateLimitRemaining??1)>0,x=a&&!!s;return(0,W.jsxs)(`div`,{className:`chat-interface`,children:[(0,W.jsxs)(`div`,{className:`chat-interface__messages`,children:[t.length===0?(0,W.jsx)(`div`,{className:`chat-interface__welcome-screen`,children:p?p({rateLimits:o??null}):(0,W.jsx)(Fz,{})}):t.map((e,n)=>(0,W.jsx)(Iz,{message:e,onMermaidTabClick:c,onAiRepairClick:l,onDeleteMessage:u,onInsertMessage:d,onRetry:f,rateLimitRemaining:o?.rateLimitRemaining,isLastMessage:n===t.length-1,renderWarning:m,allowFixingParseError:e.errorType===`parse`&&n===t.length-1},e.id)),(0,W.jsx)(`div`,{ref:h,id:`messages-end`})]}),(0,W.jsx)(`div`,{className:`chat-interface__input-container`,children:(0,W.jsx)(`div`,{className:`chat-interface__input-outer`,children:(0,W.jsxs)(`div`,{className:`chat-interface__input-wrapper`,style:{borderColor:a?`var(--dialog-border-color)`:void 0},children:[(0,W.jsx)(`textarea`,{ref:g,autoFocus:!0,className:`chat-interface__input`,value:n,onChange:_,onKeyDown:y,placeholder:a?K(`chat.generating`):o?.rateLimitRemaining===0?K(`chat.rateLimit.messageLimitInputPlaceholder`):t.length>0?K(`chat.inputPlaceholderWithMessages`):K(`chat.inputPlaceholder`,{shortcut:`Shift + Enter`}),disabled:o?.rateLimitRemaining===0,rows:1,cols:30,onInput:e=>{let t=e.target;t.style.height=`auto`,t.style.height=`${Math.min(t.scrollHeight,120)}px`}}),(0,W.jsx)(`button`,{className:`chat-interface__send-button`,onClick:v,disabled:!b&&!x,type:`button`,children:(0,W.jsx)(iE,{size:`1.5em`,icon:a?TS:LC})})]})})})]})},Rz=yl(null),zz=yl(!1),Bz=yl(null),Vz=yl({id:Ao(),messages:[],currentPrompt:``}),Hz=(e,t)=>{let{messages:n}=e,r=Fi(n,e=>e.type===`assistant`);if(r===-1)return e;let i=n[r],a=n.slice();return a[r]={...i,...t},{...e,messages:a}},Uz=e=>{let{messages:t}=e;return t[Fi(t,e=>e.type===`assistant`)]},Wz=(e,t)=>{let n=t.map(e=>({...e,id:Ao(),timestamp:new Date}));return{...e,messages:[...e.messages,...n]}},Gz=e=>{let t=Fi(e.messages??[],e=>e.type===`assistant`);return t===-1?e:{...e,messages:e.messages.filter((e,n)=>n!==t)}},Kz=e=>{let t=[];for(let n of e.messages)n.content&&(n.type===`user`||n.type===`assistant`)&&t.push({role:n.type,content:n.content});return t},qz=()=>{let[e,t]=Vb(Vz);return{addUserMessage:e=>{t(t=>Wz(t,[{type:`user`,content:e}]))},addAssistantMessage:()=>{t(e=>Wz(e,[{type:`assistant`,content:``,isGenerating:!0}]))},setAssistantError:(e,n=`other`,r)=>{let i=r?JSON.stringify({name:r instanceof Error?r.name:`Error`,message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:void 0}):void 0;t(t=>Hz(t,{isGenerating:!1,error:e,errorType:n,errorDetails:i}))},chatHistory:e,setChatHistory:t,setLastRetryAttempt:()=>{t(e=>Hz(e,{lastAttemptAt:Date.now()}))}}},Jz=e=>{let t=e.trim();return t.length<=50?t:`${t.substring(0,47)}...`},Yz=yl([]),Xz=yl(!1),Zz=yl(!1),Qz=({persistenceAdapter:e})=>{let[t]=Vb(Vz),[n,r]=Vb(Yz),[i,a]=Vb(Xz),[o,s]=Vb(Zz),c=(0,H.useRef)(n);c.current=n;let l=t?.messages[t?.messages.length-1],u=(0,H.useCallback)(async()=>{if(!(o||i)){a(!0);try{let t=await e.loadChats();r(t),s(!0)}catch(e){console.warn(`Failed to load chats:`,e),r([]),s(!0)}finally{a(!1)}}},[o,i,r,a,s,e]);(0,H.useEffect)(()=>{u()},[]);let d=(0,H.useCallback)(async()=>{if(t.messages.length===0)return;let n=t.messages.find(e=>e.type===`user`);if(!n||typeof n.content!=`string`)return;let i=Jz(n.content),a=c.current,o=a.find(e=>e.id===t.id),s=!o||o.messages.length!==t.messages.length||o.messages.some((e,n)=>e.id!==t.messages[n]?.id||e.content!==t.messages[n]?.content),l={id:t.id,title:i,messages:t.messages.filter(e=>e.type===`user`||e.type===`assistant`).map(e=>({...e,timestamp:e.timestamp instanceof Date?e.timestamp:new Date(e.timestamp)})),currentPrompt:t.currentPrompt,timestamp:s?Date.now():o?.timestamp??Date.now()},u=[...a.filter(e=>e.id!==t.id),l].sort((e,t)=>t.timestamp-e.timestamp).slice(0,10);r(u);try{await e.saveChats(u)}catch(e){console.warn(`Failed to save chats:`,e)}},[t,r,e]);return(0,H.useEffect)(()=>{l?.isGenerating||d()},[t.messages?.length,l?.id,l?.isGenerating]),{savedChats:n,saveCurrentChat:d,deleteChat:(0,H.useCallback)(async t=>{let n=c.current.filter(e=>e.id!==t);r(n);try{await e.saveChats(n)}catch(e){console.warn(`Failed to save after delete:`,e)}return n},[r,e]),restoreChat:(0,H.useCallback)(e=>e,[]),createNewChatId:(0,H.useCallback)(async()=>(await d(),Ao()),[d])}},$z=e=>{let t=e.trim();if(!t)return!1;let n=(t.match(/\[/g)||[]).length,r=(t.match(/\]/g)||[]).length,i=(t.match(/\{/g)||[]).length,a=(t.match(/\}/g)||[]).length,o=(t.match(/\(/g)||[]).length,s=(t.match(/\)/g)||[]).length;if(n!==r||i!==a||o!==s)return!1;let c=t.split(`
|
|
73
|
+
`).pop()?.trim()||``;return![/-->$/,/--$/,/-\.$/,/==>$/,/==$/,/~~$/,/::$/,/:$/,/\|$/,/&$/].some(e=>e.test(c))},eB=300,tB=3e3,nB=100,rB=100,iB=({mermaidToExcalidrawLib:e,canvasRef:t})=>{let[n]=Vb(Vz),[,r]=Vb(Bz),[i,a]=Vb(zz),o=(0,H.useRef)(!1),s=(0,H.useMemo)(()=>Uz(n),[n]),c=(0,H.useRef)(s);(0,H.useEffect)(()=>{c.current=s},[s]);let l=(0,H.useRef)({elements:[],files:null}),u=(0,H.useRef)(0),d=(0,H.useRef)(null),f=(0,H.useRef)(!1),p=(0,H.useRef)(eB),{theme:m}=Kw(),h=(0,H.useCallback)(async n=>{if(!n.trim()||!e.loaded||o.current)return!1;o.current=!0;let i=performance.now(),a=await Tz({canvasRef:t,data:l,mermaidToExcalidrawLib:e,setError:r,mermaidDefinition:n,theme:m});return performance.now()-i<nB?p.current=eB:p.current=tB,o.current=!1,a.success},[t,e,r,m]),g=(0,H.useMemo)(()=>{let e=async e=>{let t=Date.now(),n=t-u.current,r=p.current;if(!$z(e)){f.current||=(u.current=Math.max(u.current,t-r+rB),!0),d.current=e;return}if(f.current=!1,n<r){d.current=e;return}d.current=null;let i=await h(e);u.current=Date.now(),i||(u.current=u.current-r+rB,f.current=!0)};return e.flush=async()=>{if(d.current){let e=d.current;d.current=null,await h(e),u.current=Date.now()}},e.cancel=()=>{d.current=null},e},[h]),_=(0,H.useCallback)(()=>{u.current=0,d.current=null,f.current=!1,p.current=eB},[]);return(0,H.useEffect)(()=>{s?.content&&s?.isGenerating?g(s.content):s?.isGenerating||(g.flush(),_(),s?.content&&g(s.content))},[_,g,s?.isGenerating,s?.content]),(0,H.useEffect)(()=>{let e=c.current;!e?.content||e.error||i&&h(e.content)},[n?.id,h,i]),(0,H.useEffect)(()=>{if(n.messages?.filter(e=>e.type===`assistant`).length)i||a(!0);else{let e=t.current;if(e){let t=e.parentElement;t&&(t.style.background=``,e.replaceChildren())}a(!1)}},[n.messages,a,t,i]),{data:l}},aB=3,oB=1e4,sB=({onTextSubmit:e})=>{let[,t]=Vb(Bz),[n,r]=Vb(Rz),[i,a]=Vb(Vz),{addUserMessage:o,addAssistantMessage:s,setAssistantError:c}=qz(),l=(0,H.useRef)(null),u=e=>e.length>oB||e.length<aB||n?.rateLimitRemaining===0?(e.length<aB&&t(Error(K(`chat.errors.promptTooShort`,{min:aB}))),e.length>oB&&t(Error(K(`chat.errors.promptTooLong`,{max:oB}))),!1):!0;return{onGenerate:async({prompt:n,isRepairFlow:d=!1})=>{if(!u(n))return;l.current&&l.current.abort(),t(null);let f=new AbortController;l.current=f,d?a(e=>Hz(e,{isGenerating:!0,content:``,error:void 0,errorType:void 0,errorDetails:void 0})):(o(n),s());try{Vw(`ai`,`generate`,`ttd`);let{generatedResponse:o,error:s,rateLimit:l,rateLimitRemaining:u}=await e({messages:[...Kz(i).slice(-3),{role:`user`,content:n}],onStreamCreated:()=>{d&&a(e=>Hz(e,{content:``,error:``,isGenerating:!0}))},onChunk:e=>{a(t=>Hz(t,{content:Uz(t).content+e}))},signal:f.signal});if(a(e=>Hz(e,{isGenerating:!1})),uo(l)&&uo(u)&&r({rateLimit:l,rateLimitRemaining:u}),(s?.status===429||u===0)&&a(e=>(s?.status===429&&(e=Gz(e)),e={...e,messages:e.messages.filter(e=>e.type!==`warning`||e.warningType===`rateLimitExceeded`||e.warningType===`messageLimitExceeded`)},Wz(e,[{type:`warning`,warningType:u===0?`messageLimitExceeded`:`rateLimitExceeded`}]))),s){if(s.name===`AbortError`||s.message===`Aborted`||f.signal.aborted)return;let e=Error(s.message||K(`chat.errors.requestFailed`));s.status!==429&&c(e.message,`network`),t(e);return}try{await fl(o??``),Vw(`ai`,`mermaid parse success`,`ttd`)}catch(e){Vw(`ai`,`mermaid parse failed`,`ttd`);let n=Error(e.message||K(`chat.errors.mermaidParseError`));c(n.message,`parse`),t(n)}}catch(e){let n=Error(e.message||K(`chat.errors.generationFailed`));c(n.message,`other`),t(n)}finally{l.current=null}},handleAbort:()=>{l.current&&l.current.abort()}}},cB=({persistenceAdapter:e})=>{let t=Hb(Bz),[n,r]=Vb(Vz),[i,a]=(0,H.useState)(!1),{restoreChat:o,deleteChat:s,createNewChatId:c}=Qz({persistenceAdapter:e}),l=(0,H.useCallback)(e=>{let n=e.messages.map(e=>({...e,timestamp:e.timestamp instanceof Date?e.timestamp:new Date(e.timestamp)})),i={id:e.id,messages:n,currentPrompt:``},a=Uz(i);t(a?.error?Error(a?.error):null),r(i)},[t,r]),u=(0,H.useCallback)(async()=>{let e=await c();r({id:e,messages:[],currentPrompt:``}),t(null)},[c,r,t]);return{isMenuOpen:i,onRestoreChat:(0,H.useCallback)(e=>{let t=o(e);l(t),a(!1)},[o,l]),handleDeleteChat:(0,H.useCallback)(async(e,t)=>{t.stopPropagation();let r=e===n.id,i=await s(e);if(r){if(i.length>0){let e=i[0];l(e)}else await u()}},[n.id,s,l,u]),handleNewChat:(0,H.useCallback)(async()=>{await u(),a(!1)},[u]),handleMenuToggle:(0,H.useCallback)(()=>{a(e=>!e)},[]),handleMenuClose:(0,H.useCallback)(()=>{a(!1)},[])}},lB=({isOpen:e,onToggle:t,onClose:n,onNewChat:r,onRestoreChat:i,onDeleteChat:a,isNewChatBtnVisible:o,savedChats:s,activeSessionId:c,disabled:l})=>(0,W.jsxs)(`div`,{className:`ttd-chat-history-menu`,children:[o&&(0,W.jsx)(AR,{onClick:r,disabled:l,children:K(`chat.newChat`)}),s.length>0&&(0,W.jsx)(`div`,{className:`ttd-dialog-panel__menu-wrapper`,children:(0,W.jsxs)(Q,{open:e,children:[(0,W.jsx)(Q.Trigger,{onToggle:t,className:`ttd-dialog-menu-trigger`,disabled:l,title:K(`chat.menu`),"aria-label":K(`chat.menu`),children:JC}),(0,W.jsx)(Q.Content,{onClickOutside:n,onSelect:n,children:(0,W.jsx)(W.Fragment,{children:s.map(e=>(0,W.jsxs)(Q.ItemCustom,{className:U(`ttd-chat-menu-item`,{"ttd-chat-menu-item--active":e.id===c}),onClick:()=>{i(e)},children:[(0,W.jsx)(`span`,{className:`ttd-chat-menu-item__title`,children:e.title}),(0,W.jsx)(`button`,{className:`ttd-chat-menu-item__delete`,onClick:t=>a(e.id,t),title:K(`chat.deleteChat`),"aria-label":K(`chat.deleteChat`),type:`button`,children:Ix})]},e.id))})})]})})]}),uB=({chatId:e,messages:t,currentPrompt:n,onPromptChange:r,onGenerate:i,isGenerating:a,generatedResponse:o,isMenuOpen:s,onMenuToggle:c,onMenuClose:l,onNewChat:u,onRestoreChat:d,onDeleteChat:f,savedChats:p,activeSessionId:m,onAbort:h,onMermaidTabClick:g,onAiRepairClick:_,onDeleteMessage:v,onInsertMessage:y,onRetry:b,onViewAsMermaid:x,renderWelcomeScreen:S,renderWarning:C})=>{let[w]=Vb(Rz),T=(()=>{let e=[];return w&&e.push({label:K(`chat.rateLimitRemaining`,{count:w.rateLimitRemaining}),variant:`rateLimit`,className:w.rateLimitRemaining<5?`ttd-dialog-panel__rate-limit--danger`:``}),o&&e.push({action:x,label:K(`chat.viewAsMermaid`),icon:(0,W.jsx)(iE,{icon:LC}),variant:`link`}),e})();return(0,W.jsx)(dz,{label:(0,W.jsxs)(`div`,{className:`ttd-dialog-panel__label-wrapper`,children:[(0,W.jsx)(`div`,{className:`ttd-dialog-panel__label-group`}),(0,W.jsx)(`div`,{className:`ttd-dialog-panel__header-right`,children:(0,W.jsx)(lB,{isNewChatBtnVisible:!!t.length,isOpen:s,onToggle:c,onClose:l,onNewChat:u,onRestoreChat:d,onDeleteChat:f,savedChats:p,activeSessionId:m,disabled:a})})]}),className:`ttd-dialog-chat-panel`,panelActionJustifyContent:T.length===2?`space-between`:T.length===1&&T[0].variant===`rateLimit`?`flex-start`:`flex-end`,panelActions:T,children:(0,W.jsx)(Lz,{chatId:e,messages:t,currentPrompt:n,onPromptChange:r,onGenerate:i,isGenerating:a,generatedResponse:o,onAbort:h,onMermaidTabClick:g,onAiRepairClick:_,onDeleteMessage:v,onInsertMessage:y,onRetry:b,rateLimits:w,renderWelcomeScreen:S,renderWarning:C})})},dB=({canvasRef:e,error:t,loaded:n,onInsert:r,hideErrorDetails:i})=>{let a=[{action:r,label:K(`chat.insert`),icon:LC,variant:`button`}];return(0,W.jsx)(dz,{panelActionJustifyContent:`flex-end`,panelActions:a,className:`ttd-dialog-preview-panel`,children:(0,W.jsx)(uz,{canvasRef:e,error:t,loaded:n,hideErrorDetails:i})})},fB=({mermaidToExcalidrawLib:e,onTextSubmit:t,renderWelcomeScreen:n,renderWarning:r,persistenceAdapter:i})=>{let a=uU(),o=_U(),s=(0,H.useRef)(null),[c,l]=Vb(Bz),[u,d]=Vb(Vz),f=Ub(zz),{savedChats:p}=Qz({persistenceAdapter:i}),m=Uz(u),{setLastRetryAttempt:h}=qz(),{data:g}=iB({canvasRef:s,mermaidToExcalidrawLib:e}),{onGenerate:_,handleAbort:v}=sB({onTextSubmit:t}),{isMenuOpen:y,onRestoreChat:b,handleDeleteChat:x,handleNewChat:S,handleMenuToggle:C,handleMenuClose:w}=cB({persistenceAdapter:i});return(0,W.jsxs)(`div`,{className:`ttd-dialog-layout ${f?`ttd-dialog-layout--split`:`ttd-dialog-layout--chat-only`}`,children:[(0,W.jsx)(uB,{chatId:u.id,messages:u.messages,currentPrompt:u.currentPrompt,onPromptChange:e=>{d(t=>({...t,currentPrompt:e}))},onGenerate:_,isGenerating:m?.isGenerating??!1,generatedResponse:m?.content,isMenuOpen:y,onMenuToggle:C,onMenuClose:w,onNewChat:S,onRestoreChat:b,onDeleteChat:x,savedChats:p,activeSessionId:u.id,onAbort:v,onMermaidTabClick:e=>{let t=e.content||``;t&&(Ez(t),o({openDialog:{name:`ttd`,tab:`mermaid`}}))},onAiRepairClick:async e=>{let t=e.content||``,n=e.error||``;if(!t)return;let r=`Fix the error in this Mermaid diagram. The diagram is:
|
|
74
|
+
|
|
75
|
+
\`\`\`mermaid
|
|
76
|
+
${t}
|
|
77
|
+
\`\`\`
|
|
78
|
+
|
|
79
|
+
The exception/error is: ${n}
|
|
80
|
+
|
|
81
|
+
Please fix the Mermaid syntax and regenerate a valid diagram.`;await _({prompt:r,isRepairFlow:!0})},onDeleteMessage:e=>{let t=u.messages.findIndex(t=>t.id===e&&t.type===`assistant`),n=u.messages.slice(0,t-1);d({...u,messages:n})},onInsertMessage:async t=>{let n=t.content||``;if(!n.trim()||!e.loaded)return;let r={current:{elements:[],files:null}};(await Tz({canvasRef:s,data:r,mermaidToExcalidrawLib:e,setError:l,mermaidDefinition:n,theme:a.state.theme})).success&&Dz({app:a,data:r,text:n,shouldSaveMermaidDataToStorage:!0})},onRetry:async e=>{let t=u.messages.findIndex(t=>t.id===e.id);if(t>0){let e=u.messages[t-1];e.type===`user`&&typeof e.content==`string`&&(h(),await _({prompt:e.content,isRepairFlow:!0}))}},onViewAsMermaid:()=>{typeof m?.content==`string`&&(Ez(m.content),o({openDialog:{name:`ttd`,tab:`mermaid`}}))},renderWarning:r,renderWelcomeScreen:n}),f&&(0,W.jsx)(dB,{canvasRef:s,hideErrorDetails:m?.errorType===`parse`,error:c,loaded:e.loaded,onInsert:()=>{Dz({app:a,data:g})}})]})},pB=({mermaidToExcalidrawLib:e,onTextSubmit:t,renderWelcomeScreen:n,renderWarning:r,persistenceAdapter:i})=>(0,W.jsx)(fB,{mermaidToExcalidrawLib:e,onTextSubmit:t,renderWelcomeScreen:n,renderWarning:r,persistenceAdapter:i}),mB=e=>{let t=_U(),n=(0,H.useRef)(null),r=(0,H.useRef)(0);return(0,W.jsx)(Ky,{ref:n,className:`ttd-dialog-tabs-root`,value:e.tab,onValueChange:i=>{if(!i)return;let a=n.current?.closest(`.Modal__content`);if(a){let e=a.offsetHeight||0;e>r.current&&(r.current=e,a.style.minHeight=`min(${r.current}px, 100%)`)}e.dialog===`ttd`&&s([`text-to-diagram`,`mermaid`],i)&&t({openDialog:{name:e.dialog,tab:i}})},children:e.children})};mB.displayName=`TTDDialogTabs`;var hB=mB,gB=({children:e,...t})=>(0,W.jsx)(qy,{className:`ttd-dialog-triggers`,...t,children:e});gB.displayName=`TTDDialogTabTriggers`;var _B=({children:e,tab:t,onSelect:n,...r})=>(0,W.jsx)(Jy,{value:t,asChild:!0,onSelect:n,children:(0,W.jsx)(`button`,{type:`button`,className:`ttd-dialog-tab-trigger`,...r,children:e})});_B.displayName=`TTDDialogTabTrigger`;var vB=({tab:e,children:t,...n})=>(0,W.jsx)(Yy,{...n,value:e,children:t});vB.displayName=`TTDDialogTab`;var yB=e=>{let t=Kw();return t.openDialog?.name===`ttd`?(0,W.jsx)(bB,{...e,tab:t.openDialog.tab}):null};yB.WelcomeMessage=Fz;var bB=$L(`TTDDialogBase`,({tab:e,...t})=>{let r=uU(),[i,a]=(0,H.useState)({loaded:!1,api:n(()=>import(`./dist-CYfPeupF.js`),[],import.meta.url)});return(0,H.useEffect)(()=>{(async()=>{await i.api,a(e=>({...e,loaded:!0}))})()},[i.api]),(0,W.jsx)(Pj,{className:`ttd-dialog`,onCloseRequest:()=>{r.setOpenDialog(null)},size:1520,title:!1,...t,autofocus:!1,children:(0,W.jsxs)(hB,{dialog:`ttd`,tab:e,children:[`__fallback`in t&&t.__fallback?(0,W.jsx)(`p`,{className:`dialog-mermaid-title`,children:K(`mermaid.title`)}):(0,W.jsxs)(gB,{children:[(0,W.jsx)(_B,{tab:`text-to-diagram`,children:(0,W.jsxs)(`div`,{className:`ttd-dialog-tab-trigger__content`,children:[K(`labels.textToDiagram`),(0,W.jsx)(`div`,{className:`ttd-dialog-tab-trigger__badge`,children:K(`chat.aiBeta`)})]})}),(0,W.jsx)(_B,{tab:`mermaid`,children:K(`mermaid.label`)})]}),!(`__fallback`in t)&&(0,W.jsx)(vB,{className:`ttd-dialog-content`,tab:`text-to-diagram`,children:(0,W.jsx)(pB,{mermaidToExcalidrawLib:i,onTextSubmit:t.onTextSubmit,renderWelcomeScreen:t.renderWelcomeScreen,renderWarning:t.renderWarning,persistenceAdapter:t.persistenceAdapter})}),(0,W.jsx)(vB,{className:`ttd-dialog-content`,tab:`mermaid`,children:(0,W.jsx)(Pz,{mermaidToExcalidrawLib:i,isActive:e===`mermaid`})})]})})}),xB=.01,SB=10,CB=(e,t)=>!(t===`angle`&&R(e)),wB=(e,t)=>{let n=e+t/2;return n-n%t},TB=(e,t,n)=>Object.keys(e).map(e=>({original:(n??t).get(e),latest:t.get(e)})).filter(e=>e.original!==void 0&&e.latest!==void 0),EB=(e,t,n,r,i,a,o=!0)=>{if(mo(n)&&(n.startBinding||n.endBinding)){if(Math.abs(e-n.x)<10&&Math.abs(t-n.y)<10)return;Rc(n,`start`,r),Rc(n,`end`,r)}let s=r.getNonDeletedElementsMap(),c=s.get(n.id);if(!c)return;let[l,u]=[n.x+n.width/2,n.y+n.height/2],[d,f]=rl(F(n.x,n.y),F(l,u),n.angle),p=e-d,m=t-f,[h,g]=rl(F(e,t),F(l+p,u+m),-n.angle);r.mutateElement(c,{x:h,y:g},{informMutation:o,isDragging:!1}),mn(c,r,i);let _=Ga(n,a);if(_){let e=s.get(_.id);e&&r.mutateElement(e,{x:_.x+p,y:_.y+m},{informMutation:o,isDragging:!1})}if(R(n)){let e=Ti(a,n.id);e.forEach(t=>{let n=s.get(t.id);if(!n)return;let[a,c]=[t.x+t.width/2,t.y+t.height/2],[l,u]=rl(F(t.x,t.y),F(a,c),t.angle),d=Math.round(l+p),f=Math.round(u+m),[h,g]=rl(F(d,f),F(a+p,c+m),-t.angle);r.mutateElement(n,{x:h,y:g},{informMutation:o,isDragging:!1}),mn(n,r,i,{simultaneouslyUpdated:k(e)})})}},DB=(e,t)=>{let n=Is(t).map(t=>Er(e,t).reduce((e,t)=>(e[t.id]=!0,e),{}));return e.filter(e=>!Ge(e)).forEach(e=>{n.push({[e.id]:!0})}),n},OB=({label:e,icon:t,dragInputCallback:n,value:r,elements:i,editable:a=!0,shouldKeepAspectRatio:o,property:s,scene:c,appState:l,sensitivity:u=1,dragFinishedCallback:d})=>{let f=uU(),p=f.ownerDocument,m=f.ownerWindow,h=_U(),g=(0,H.useRef)(null),_=(0,H.useRef)(null),[v,y]=(0,H.useState)(r.toString()),b=(0,H.useRef)(null);b.current||={originalAppState:Fr(l),originalElements:i,lastUpdatedValue:v,updatePending:!1},(0,H.useEffect)(()=>{let e=r.toString();y(e),b.current.lastUpdatedValue=e},[r]);let x=(e,t,i)=>{if(!b.current.updatePending)return!1;b.current.updatePending=!1;let a=Number(e);if(!Number.isFinite(a)){y(r.toString());return}let l=Number(a.toFixed(2)),u=Number(r);if(isNaN(u)||Math.abs(l-u)>=xB){b.current.lastUpdatedValue=e;let r=new Map;for(let e of f.scene.getNonDeletedElements())r.set(e.id,Gn(e));n({accumulatedChange:0,instantChange:0,originalElements:t,originalElementsMap:r,shouldKeepAspectRatio:o,shouldChangeByStepSize:!1,scene:c,nextValue:l,property:s,originalAppState:i,setInputValue:e=>y(String(e)),app:f,setAppState:h}),f.syncActionResult({captureUpdate:N.IMMEDIATELY})}},S=(0,H.useRef)({});return S.current.handleInputValue=x,(0,H.useEffect)(()=>{let e=g.current,t=S.current;return()=>{let n=e?.value;n&&t.handleInputValue?.(n,b.current.originalElements,b.current.originalAppState),m.removeEventListener(B.POINTER_MOVE,t.onPointerMove,!1),m.removeEventListener(B.POINTER_UP,t.onPointerUp,!1)}},[a,m]),a?(0,W.jsxs)(`div`,{className:U(`drag-input-container`,!a&&`disabled`),"data-testid":e,children:[(0,W.jsx)(`div`,{className:`drag-input-label`,ref:_,onPointerDown:e=>{if(g.current&&a){p.body.classList.add(`excalidraw-cursor-resize`);let e=Number(g.current.value);isNaN(e)&&(e=0);let t=null,r=f.scene.getNonDeletedElements().reduce((e,t)=>(e.set(t.id,Gn(t)),e),new Map),a=i.map(e=>r.get(e.id)),_=Fr(l),v=0,b=0,x=e=>{if(t&&r!==null&&a!==null){let i=e.clientX-t.x;i!==0&&(b+=i,Math.abs(b)>=u&&(b=Math.sign(b)*Math.floor(Math.abs(b)/u),v+=b,n({accumulatedChange:v,instantChange:b,originalElements:a,originalElementsMap:r,shouldKeepAspectRatio:o,shouldChangeByStepSize:e.shiftKey,property:s,scene:c,originalAppState:_,setInputValue:e=>y(String(e)),app:f,setAppState:h}),b=0))}t={x:e.clientX,y:e.clientY}},C=()=>{m.removeEventListener(B.POINTER_MOVE,x,!1),f.syncActionResult({captureUpdate:N.IMMEDIATELY}),d?.({app:f,setAppState:h,originalElements:a,originalAppState:_}),t=null,v=0,b=0,a=null,r=null,p.body.classList.remove(`excalidraw-cursor-resize`),m.removeEventListener(B.POINTER_UP,C,!1)};S.current.onPointerMove=x,S.current.onPointerUp=C,m.addEventListener(B.POINTER_MOVE,x,!1),m.addEventListener(B.POINTER_UP,C,!1)}},onPointerEnter:()=>{_.current&&(_.current.style.cursor=`ew-resize`)},children:t?(0,W.jsx)(iE,{icon:t}):e}),(0,W.jsx)(`input`,{className:`drag-input`,autoComplete:`off`,spellCheck:`false`,onKeyDown:e=>{if(a){let t=e.currentTarget;t instanceof m.HTMLInputElement&&e.key===L.ENTER&&(x(t.value,i,l),f.focusContainer())}},ref:g,value:v,onChange:e=>{b.current.updatePending=!0,y(e.target.value)},onFocus:e=>{e.target.select(),b.current.originalElements=i,b.current.originalAppState=Fr(l)},onBlur:e=>{v?a&&x(e.target.value,b.current.originalElements,b.current.originalAppState):y(r.toString())},disabled:!a})]}):null},kB=15,AB=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:n,nextValue:r,scene:i,app:a})=>{let o=i.getNonDeletedElementsMap(),s=t[0];if(s&&!Br(s)){let t=o.get(s.id);if(!t)return;if(r!==void 0){let e=We(r);i.mutateElement(t,{angle:e}),mn(t,i,a.state);let n=Ga(t,o);n&&!ye(t)&&i.mutateElement(n,{angle:e});return}let c=(Math.round(ni(s.angle)*100)/100+Math.round(e))%360;n&&(c=wB(c,kB)),c=c<0?c+360:c;let l=We(c);i.mutateElement(t,{angle:l}),mn(t,i,a.state);let u=Ga(t,o);u&&!ye(t)&&i.mutateElement(u,{angle:l})}},jB=({element:e,scene:t,appState:n,property:r})=>(0,W.jsx)(OB,{label:`A`,icon:xC,value:Math.round(ni(e.angle)%360*100)/100,elements:[e],dragInputCallback:AB,editable:CB(e,`angle`),scene:t,appState:n,property:r}),MB=5,NB=({property:e,scene:t,appState:n,setAppState:r})=>(0,W.jsx)(OB,{label:`Grid step`,sensitivity:8,elements:[],dragInputCallback:({nextValue:e,instantChange:t,shouldChangeByStepSize:n,setInputValue:i})=>{r(r=>{let a;return e?a=e:t&&(a=n?wB(r.gridStep+MB*Math.sign(t),MB):r.gridStep+t),a?(a=Ii(a),i(a),{gridStep:a}):(i(r.gridStep),null)})},scene:t,value:n.gridStep,property:e,appState:n}),PB=10,FB=e=>e.type===`image`,IB=({accumulatedChange:e,originalElements:t,originalElementsMap:n,shouldKeepAspectRatio:r,shouldChangeByStepSize:i,nextValue:a,property:o,originalAppState:s,instantChange:c,scene:l,app:u,setAppState:d})=>{let f=l.getNonDeletedElementsMap(),p=t[0],m=f.get(p.id);if(p&&m){let t=r||FB(p),u=p.width/p.height;if(s.croppingElementId===p.id){let e=f.get(p.id);if(!e||!La(e)||!e.crop)return;let t=e.crop,n={...t},r=e.scale[0]===-1,i=e.scale[1]===-1,{width:s,height:u}=Wc(e),d=t.naturalWidth/s,m=t.naturalHeight/u,h=r?t.width+t.x:t.naturalWidth-t.x,g=i?t.height+t.y:t.naturalHeight-t.y,_=10*d,v=10*m;if(a!==void 0){if(o===`width`){let e=a*d,i=fi(e,_,h);n={...n,width:i,x:r?t.x+t.width-i:t.x}}else if(o===`height`){let e=a*m,r=fi(e,v,g);n={...n,height:r,y:i?t.y+t.height-r:t.y}}l.mutateElement(e,{crop:n,width:n.width/(t.naturalWidth/s),height:n.height/(t.naturalHeight/u)});return}let y=o===`width`?c:0,b=o===`height`?c:0,x=fi(t.width+y,_,h),S=fi(t.height+b,_,g);n={...t,x:r?t.x+t.width-x:t.x,y:i?t.y+t.height-S:t.y,width:x,height:S},l.mutateElement(e,{crop:n,width:n.width/(t.naturalWidth/s),height:n.height/(t.naturalHeight/u)});return}if(a!==void 0){let e=Math.max(o===`width`?a:t?a*u:p.width,1),r=Math.max(o===`height`?a:t?a/u:p.height,1);if(vt(e,r,m,p,n,l,o===`width`?`e`:`s`,{shouldMaintainAspectRatio:t}),R(m)){let e=ut(l.getElementsIncludingDeleted(),m,s,l.getNonDeletedElementsMap()),t=Cr(l.getElementsIncludingDeleted(),e,m);l.replaceAllElements(t)}return}{let r=o===`width`?e:0,a=o===`height`?e:0,c=Math.max(0,p.width+r);o===`width`&&(c=i?wB(c,PB):Math.round(c));let f=Math.max(0,p.height+a);o===`height`&&(f=i?wB(f,PB):Math.round(f)),t&&(o===`width`?f=Math.round(c/u*100)/100:c=Math.round(f*u*100)/100),f=Math.max(1,f),c=Math.max(1,c),vt(c,f,m,p,n,l,o===`width`?`e`:`s`,{shouldMaintainAspectRatio:t}),R(m)&&d({elementsToHighlight:k(ut(l.getElementsIncludingDeleted(),m,s,l.getNonDeletedElementsMap()))})}}},LB=({setAppState:e,app:t,originalElements:n,originalAppState:r})=>{let i=t.scene.getNonDeletedElementsMap(),a=n?.[0],o=a&&i.get(a.id);if(o&&R(o)){let n=ut(t.scene.getElementsIncludingDeleted(),o,r,t.scene.getNonDeletedElementsMap()),i=Cr(t.scene.getElementsIncludingDeleted(),n,o);t.scene.replaceAllElements(i),e({elementsToHighlight:null})}},RB=({property:e,element:t,scene:n,appState:r})=>{let i=Hn(e===`width`?t.width:t.height,2);if(r.croppingElementId&&r.croppingElementId===t.id&&La(t)&&t.crop){let{width:n,height:r}=Wc(t);if(e===`width`){let e=n/t.crop.naturalWidth;i=Hn(t.crop.width*e,2)}if(e===`height`){let e=r/t.crop.naturalHeight;i=Hn(t.crop.height*e,2)}}return(0,W.jsx)(OB,{label:e===`width`?`W`:`H`,elements:[t],dragInputCallback:IB,value:i,editable:CB(t,e),scene:n,appState:r,property:e,dragFinishedCallback:LB})},zB=4,BB=4,VB=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:n,nextValue:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),o=t[0];if(o){let t=a.get(o.id);if(!t||!z(t))return;let s;if(r!==void 0)s=Math.max(Math.round(r),zB);else if(o.type===`text`){let t=Math.round(vc(o,a));s=Math.max(t+Math.round(e),zB),n&&(s=wB(s,BB))}s&&(i.mutateElement(t,Lo(t,s,a)),gt(t,i.getContainerElement(t),i))}},HB=({element:e,scene:t,appState:n,property:r})=>{let i=z(e)?e:xr(e)?Ga(e,t.getNonDeletedElementsMap()):null;return i?(0,W.jsx)(OB,{label:`F`,value:Math.round(vc(i,t.getNonDeletedElementsMap())*10)/10,elements:[i],dragInputCallback:VB,icon:uC,appState:n,scene:t,property:r}):null},UB=15,WB=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:n,nextValue:r,property:i,scene:a})=>{let o=a.getNonDeletedElementsMap(),s=t.map(e=>o.get(e.id)).filter(e=>e&&!Ge(e)&&CB(e,i)),c=t.filter(e=>!Ge(e)&&CB(e,i));if(r!==void 0){let e=We(r);for(let t of s){if(!t)continue;a.mutateElement(t,{angle:e});let n=Ga(t,o);n&&!ye(t)&&a.mutateElement(n,{angle:e})}a.triggerUpdate();return}for(let t=0;t<s.length;t++){let r=s[t];if(!r)continue;let i=c[t],l=(Math.round(ni(i.angle)*100)/100+Math.round(e))%360;n&&(l=wB(l,UB)),l=l<0?l+360:l;let u=We(l);a.mutateElement(r,{angle:u});let d=Ga(r,o);d&&!ye(r)&&a.mutateElement(d,{angle:u})}a.triggerUpdate()},GB=({elements:e,scene:t,appState:n,property:r})=>{let i=e.filter(e=>!Ge(e)&&CB(e,`angle`)),a=i.map(e=>Math.round(ni(e.angle)%360*100)/100),o=new Set(a).size===1?a[0]:`Mixed`,s=i.some(e=>CB(e,`angle`));return(0,W.jsx)(OB,{label:`A`,icon:xC,value:o,elements:e,dragInputCallback:WB,editable:s,appState:n,scene:t,property:r})},KB=10,qB=(e,t,n,r)=>{let i=r.x-e,a=r.y-t,o=r.width*n,s=r.height*n;return{width:o,height:s,x:e+i*n,y:t+a*n,...nc(r,o,s,!1),...z(r)?{fontSize:r.fontSize*n}:{}}},JB=(e,t,n,r,i,a,o,s)=>{let c=s.getNonDeletedElementsMap();if(z(i)&&Rt(i,c))return;let l=qB(e,t,r,a);if(s.mutateElement(i,l),oe(i)){Un(i,s,{...Qc(i,o,n===`width`?`e`:`s`,{proportional:!0,fromCenter:!1}),anchor:`top`});return}let d=Ga(a,o);if(d){let e=d.fontSize*r;u(i,s);let t=c.get(d.id);t&&z(t)&&(s.mutateElement(t,{fontSize:e}),Xs(i,s,n===`width`?`e`:`s`,!0))}},YB=(e,t,n,r,i,a,o,s,c,l)=>{a===`width`?t=Math.round(e/r*100)/100:e=Math.round(t*r*100)/100;let u=t/n;for(let e=0;e<s.length;e++){let t=s[e],n=o[e];JB(i[0],i[1],a,u,n,t,c,l)}},XB=({accumulatedChange:e,originalElements:t,originalElementsMap:n,originalAppState:r,shouldChangeByStepSize:i,nextValue:a,scene:o,property:s,setAppState:c,app:l})=>{let u=o.getNonDeletedElementsMap(),d=DB(t,r);if(a!==void 0){for(let e of d){let t=TB(e,u,n);if(t.length>1){let e=t.map(e=>e.latest),r=t.map(e=>e.original),[i,c,l,u]=Wr(r),d=l-i,f=u-c,p=d/f;YB(Math.max(1,s===`width`?Math.max(0,a):d),Math.max(1,s===`height`?Math.max(0,a):f),f,p,F(i,c),s,e,r,n,o)}else{let[e]=t,c=e?.latest,l=e?.original;if(c&&l&&CB(c,s)){let e=s===`width`?Math.max(0,a):c.width;s===`width`&&(e=i?wB(e,KB):Math.round(e));let t=s===`height`?Math.max(0,a):c.height;if(s===`height`&&(t=i?wB(t,KB):Math.round(t)),e=Math.max(1,e),t=Math.max(1,t),vt(e,t,c,l,n,o,s===`width`?`e`:`s`,{shouldInformMutation:!1}),R(c)){let e=ut(o.getElementsIncludingDeleted(),c,r,o.getNonDeletedElementsMap()),t=Cr(o.getElementsIncludingDeleted(),e,c);o.replaceAllElements(t)}}}}o.triggerUpdate();return}let f=s===`width`?e:0,p=s===`height`?e:0,m=[];for(let e of d){let t=TB(e,u,n);if(t.length>1){let e=t.map(e=>e.latest),r=t.map(e=>e.original),[a,c,l,u]=Wr(r),d=l-a,m=u-c,h=d/m,g=Math.max(0,d+f);s===`width`&&(g=i?wB(g,KB):Math.round(g));let _=Math.max(0,m+p);s===`height`&&(_=i?wB(_,KB):Math.round(_)),g=Math.max(1,g),_=Math.max(1,_),YB(g,_,m,h,F(a,c),s,e,r,n,o)}else{let[e]=t,a=e?.latest,c=e?.original;if(a&&c&&CB(a,s)){let e=Math.max(0,c.width+f);s===`width`&&(e=i?wB(e,KB):Math.round(e));let t=Math.max(0,c.height+p);if(s===`height`&&(t=i?wB(t,KB):Math.round(t)),e=Math.max(1,e),t=Math.max(1,t),vt(e,t,a,c,n,o,s===`width`?`e`:`s`,{shouldInformMutation:!1}),R(a)){let e=k(ut(o.getElementsIncludingDeleted(),a,r,o.getNonDeletedElementsMap()));m.push(...e)}}}}c({elementsToHighlight:m}),o.triggerUpdate()},ZB=({setAppState:e,app:t,originalElements:n,originalAppState:r})=>{let i=t.scene.getNonDeletedElementsMap(),a=n?.[0],o=a&&i.get(a.id);if(o&&R(o)){let n=ut(t.scene.getElementsIncludingDeleted(),o,r,t.scene.getNonDeletedElementsMap()),i=Cr(t.scene.getElementsIncludingDeleted(),n,o);t.scene.replaceAllElements(i),e({elementsToHighlight:null})}},QB=({property:e,elements:t,elementsMap:n,atomicUnits:r,scene:i,appState:a})=>{let o=(0,H.useMemo)(()=>r.map(t=>{let r=TB(t,n);if(r.length>1){let[t,n,i,a]=Wr(r.map(e=>e.latest));return Math.round((e===`width`?i-t:a-n)*100)/100}let[i]=r;return Math.round((e===`width`?i.latest.width:i.latest.height)*100)/100}),[n,r,e]),s=new Set(o).size===1?Math.round(o[0]*100)/100:`Mixed`,c=o.length>0;return(0,W.jsx)(OB,{label:e===`width`?`W`:`H`,elements:t,dragInputCallback:XB,value:s,editable:c,appState:a,property:e,scene:i,dragFinishedCallback:ZB})},$B=4,eV=4,tV=(e,t)=>e.reduce((e,n)=>{if(!n||Ge(n))return e;if(z(n))return e.push(n),e;if(xr(n)){let r=Ga(n,t);if(r)return e.push(r),e}return e},[]),nV=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:n,nextValue:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),o=t.map(e=>a.get(e.id)),s;if(r){s=Math.max(Math.round(r),$B);for(let e of o)i.mutateElement(e,Lo(e,s,a)),gt(e,i.getContainerElement(e),i);i.triggerUpdate()}else{let r=t;for(let t=0;t<o.length;t++){let s=o[t],c=r[t],l=Math.round(vc(c,a)),u=Math.max(l+Math.round(e),$B);n&&(u=wB(u,eV)),i.mutateElement(s,Lo(s,u,a)),gt(s,i.getContainerElement(s),i)}i.triggerUpdate()}},rV=({elements:e,scene:t,appState:n,property:r,elementsMap:i})=>{let a=tV(e,i);if(!a.length)return null;let o=a.map(e=>Math.round(vc(e,i)*10)/10),s=new Set(o).size===1?o[0]:`Mixed`,c=o.length>0;return(0,W.jsx)(OB,{label:`F`,icon:uC,elements:a,dragInputCallback:nV,value:s,editable:c,scene:t,property:r,appState:n})},iV=(e,t,n,r,i,a,o)=>{for(let s=0;s<r.length;s++){let c=r[s],[l,u]=[c.x+c.width/2,c.y+c.height/2],[d,f]=rl(F(c.x,c.y),F(l,u),c.angle);EB(e===`x`?Math.round(d+t):d,e===`y`?Math.round(f+n):f,c,a,o,i,!1)}},aV=(e,t,n,r,i,a)=>{let o=i.getNonDeletedElementsMap(),[s,c,,]=Wr(n),l=e-s,u=t-c;for(let e=0;e<n.length;e++){let t=n[e],s=o.get(t.id);if(s&&(!z(s)||!s.containerId)){let[e,n]=[s.x+s.width/2,s.y+s.height/2],[o,c]=rl(F(s.x,s.y),F(e,n),s.angle);EB(o+l,c+u,t,i,a,r,!1)}}},oV=({accumulatedChange:e,originalElements:t,originalElementsMap:n,shouldChangeByStepSize:r,nextValue:i,property:a,scene:o,originalAppState:s,app:c})=>{let l=o.getNonDeletedElementsMap();if(i!==void 0){for(let e of DB(t,s)){let t=TB(e,l,n);if(t.length>1){let[e,r,,]=Wr(t.map(e=>e.latest));aV(a===`x`?i:e,a===`y`?i:r,t.map(e=>e.original),n,o,c.state)}else{let e=t[0]?.original,r=t[0]?.latest;if(e&&r&&CB(r,a)){let[t,r]=[e.x+e.width/2,e.y+e.height/2],[s,l]=rl(F(e.x,e.y),F(t,r),e.angle);EB(a===`x`?i:s,a===`y`?i:l,e,o,c.state,n,!1)}}}o.triggerUpdate();return}let u=r?wB(e,SB):e;iV(a,a===`x`?u:0,a===`y`?u:0,t,n,o,c.state),o.triggerUpdate()},sV=({property:e,elements:t,elementsMap:n,atomicUnits:r,scene:i,appState:a})=>{let o=(0,H.useMemo)(()=>r.map(t=>{let r=Object.keys(t).map(e=>n.get(e)).filter(e=>e!==void 0);if(r.length>1){let[t,n]=Wr(r);return Math.round((e===`x`?t:n)*100)/100}let[i]=r,[a,o]=[i.x+i.width/2,i.y+i.height/2],[s,c]=rl(F(i.x,i.y),F(a,o),i.angle);return Math.round((e===`x`?s:c)*100)/100}),[r,n,e]),s=new Set(o).size===1?o[0]:`Mixed`;return(0,W.jsx)(OB,{label:e===`x`?`X`:`Y`,elements:t,dragInputCallback:oV,value:s,property:e,scene:i,appState:a})},cV=({accumulatedChange:e,instantChange:t,originalElements:n,originalElementsMap:r,shouldChangeByStepSize:i,nextValue:a,property:o,scene:s,originalAppState:c,app:l})=>{let u=s.getNonDeletedElementsMap(),d=n[0],[f,p]=[d.x+d.width/2,d.y+d.height/2],[m,h]=rl(F(d.x,d.y),F(f,p),d.angle);if(c.croppingElementId===d.id){let e=u.get(d.id);if(!e||!La(e)||!e.crop)return;let n=e.crop,r=n,i=e.scale[0]===-1,c=e.scale[1]===-1,{width:l,height:f}=Wc(e);if(a!==void 0){if(o===`x`){let e=a*(n.naturalWidth/l);r=i?{...n,x:fi(n.naturalWidth-e-n.width,0,n.naturalWidth-n.width)}:{...n,x:fi(a*(n.naturalWidth/l),0,n.naturalWidth-n.width)}}o===`y`&&(r={...n,y:fi(a*(n.naturalHeight/f),0,n.naturalHeight-n.height)}),s.mutateElement(e,{crop:r});return}let p=(o===`x`?t:0)*(i?-1:1),m=(o===`y`?t:0)*(c?-1:1);r={...n,x:fi(n.x+p,0,n.naturalWidth-n.width),y:fi(n.y+m,0,n.naturalHeight-n.height)},s.mutateElement(e,{crop:r});return}if(a!==void 0){EB(o===`x`?a:m,o===`y`?a:h,d,s,l.state,r);return}let g=o===`x`?e:0,_=o===`y`?e:0;EB(o===`x`?Math.round(i?wB(d.x+g,SB):m+g):m,o===`y`?Math.round(i?wB(d.y+_,SB):h+_):h,d,s,l.state,r)},lV=({property:e,element:t,scene:n,appState:r})=>{let[i,a]=rl(F(t.x,t.y),F(t.x+t.width/2,t.y+t.height/2),t.angle),o=Hn(e===`x`?i:a,2);if(r.croppingElementId===t.id&&La(t)&&t.crop){let n=Hr(t);n&&(o=Hn(e===`x`?n.x:n.y,2))}return(0,W.jsx)(OB,{label:e===`x`?`X`:`Y`,elements:[t],dragInputCallback:cV,scene:n,value:o,property:e,appState:r})},uV=50,dV=e=>{let t=gU(),n=e.app.scene.getSceneNonce()||1,r=e.app.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}),i=lP(e.app);return(0,W.jsx)(mV,{...e,appState:t,sceneNonce:n,selectedElements:r,gridModeEnabled:i})},fV=({children:e,columns:t=1,heading:n,style:r,...i})=>(0,W.jsx)(`div`,{className:U(`exc-stats__row`,{"exc-stats__row--heading":n}),style:{gridTemplateColumns:`repeat(${t}, 1fr)`,...r},...i,children:e});fV.displayName=`StatsRow`;var pV=({children:e,order:t,style:n,...r})=>(0,W.jsx)(`div`,{className:`exc-stats__rows`,style:{order:t,...n},...r,children:e});pV.displayName=`StatsRows`,dV.StatsRow=fV,dV.StatsRows=pV;var mV=(0,H.memo)(({app:e,onClose:t,renderCustomStats:n,selectedElements:r,appState:i,sceneNonce:a,gridModeEnabled:o})=>{let s=e.scene,c=s.getNonDeletedElements(),l=s.getNonDeletedElementsMap(),u=_U(),d=r.length===1?r[0]:null,f=r.length>1?r:null,p=i.croppingElementId&&La(d),m=p?Wc(d):null,[h,g]=(0,H.useState)({width:0,height:0}),_=(0,H.useMemo)(()=>(0,_l.default)(e=>{let t=Wr(e);g({width:Math.round(t[2])-Math.round(t[0]),height:Math.round(t[3])-Math.round(t[1])})},uV),[]);(0,H.useEffect)(()=>{_(c)},[a,c,_]),(0,H.useEffect)(()=>()=>_.cancel(),[_]);let v=(0,H.useMemo)(()=>DB(r,i),[r,i]),y=(0,H.useMemo)(()=>mt(r),[r]);return(0,W.jsx)(`div`,{className:`exc-stats`,children:(0,W.jsxs)(nT,{padding:3,children:[(0,W.jsxs)(`div`,{className:`title`,children:[(0,W.jsx)(`h2`,{children:K(`stats.title`)}),(0,W.jsx)(`div`,{className:`close`,onClick:t,children:ES})]}),(0,W.jsxs)(aE,{label:(0,W.jsx)(`h3`,{children:K(`stats.generalStats`)}),open:!!(i.stats.panels&qs.generalStats),openTrigger:()=>u(e=>({stats:{open:!0,panels:e.stats.panels^qs.generalStats}})),children:[(0,W.jsxs)(pV,{children:[(0,W.jsx)(fV,{heading:!0,children:K(`stats.scene`)}),(0,W.jsxs)(fV,{columns:2,children:[(0,W.jsx)(`div`,{children:K(`stats.shapes`)}),(0,W.jsx)(`div`,{children:c.length})]}),(0,W.jsxs)(fV,{columns:2,children:[(0,W.jsx)(`div`,{children:K(`stats.width`)}),(0,W.jsx)(`div`,{children:h.width})]}),(0,W.jsxs)(fV,{columns:2,children:[(0,W.jsx)(`div`,{children:K(`stats.height`)}),(0,W.jsx)(`div`,{children:h.height})]}),o&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(fV,{heading:!0,children:`Canvas`}),(0,W.jsx)(fV,{children:(0,W.jsx)(NB,{property:`gridStep`,scene:s,appState:i,setAppState:u})})]})]}),n?.(c,i)]}),!y&&r.length>0&&(0,W.jsx)(`div`,{id:`elementStats`,style:{marginTop:12},children:(0,W.jsx)(aE,{label:(0,W.jsx)(`h3`,{children:K(`stats.elementProperties`)}),open:!!(i.stats.panels&qs.elementProperties),openTrigger:()=>u(e=>({stats:{open:!0,panels:e.stats.panels^qs.elementProperties}})),children:(0,W.jsxs)(pV,{children:[d&&(0,W.jsxs)(W.Fragment,{children:[p&&(0,W.jsx)(fV,{heading:!0,children:K(`labels.unCroppedDimension`)}),i.croppingElementId&&La(d)&&m&&(0,W.jsxs)(fV,{columns:2,children:[(0,W.jsx)(`div`,{children:K(`stats.width`)}),(0,W.jsx)(`div`,{children:Hn(m.width,2)})]}),i.croppingElementId&&La(d)&&m&&(0,W.jsxs)(fV,{columns:2,children:[(0,W.jsx)(`div`,{children:K(`stats.height`)}),(0,W.jsx)(`div`,{children:Hn(m.height,2)})]}),(0,W.jsx)(fV,{heading:!0,"data-testid":`stats-element-type`,style:{margin:`0.3125rem 0`},children:i.croppingElementId?K(`labels.imageCropping`):K(`element.${d.type}`)}),(0,W.jsx)(fV,{children:(0,W.jsx)(lV,{element:d,property:`x`,elementsMap:l,scene:s,appState:i})}),(0,W.jsx)(fV,{children:(0,W.jsx)(lV,{element:d,property:`y`,elementsMap:l,scene:s,appState:i})}),(0,W.jsx)(fV,{children:(0,W.jsx)(RB,{property:`width`,element:d,scene:s,appState:i})}),(0,W.jsx)(fV,{children:(0,W.jsx)(RB,{property:`height`,element:d,scene:s,appState:i})}),(0,W.jsx)(fV,{children:(0,W.jsx)(jB,{property:`angle`,element:d,scene:s,appState:i})}),(0,W.jsx)(fV,{children:(0,W.jsx)(HB,{property:`fontSize`,element:d,scene:s,appState:i})})]}),f&&(0,W.jsxs)(W.Fragment,{children:[ne(f)&&(0,W.jsx)(fV,{heading:!0,children:K(`element.group`)}),(0,W.jsxs)(fV,{columns:2,style:{margin:`0.3125rem 0`},children:[(0,W.jsx)(`div`,{children:K(`stats.shapes`)}),(0,W.jsx)(`div`,{children:r.length})]}),(0,W.jsx)(fV,{children:(0,W.jsx)(sV,{property:`x`,elements:f,elementsMap:l,atomicUnits:v,scene:s,appState:i})}),(0,W.jsx)(fV,{children:(0,W.jsx)(sV,{property:`y`,elements:f,elementsMap:l,atomicUnits:v,scene:s,appState:i})}),(0,W.jsx)(fV,{children:(0,W.jsx)(QB,{property:`width`,elements:f,elementsMap:l,atomicUnits:v,scene:s,appState:i})}),(0,W.jsx)(fV,{children:(0,W.jsx)(QB,{property:`height`,elements:f,elementsMap:l,atomicUnits:v,scene:s,appState:i})}),(0,W.jsx)(fV,{children:(0,W.jsx)(GB,{property:`angle`,elements:f,scene:s,appState:i})}),(0,W.jsx)(fV,{children:(0,W.jsx)(rV,{property:`fontSize`,elements:f,scene:s,appState:i,elementsMap:l})})]})]})})})]})})},(e,t)=>e.sceneNonce===t.sceneNonce&&e.selectedElements===t.selectedElements&&e.appState.stats.panels===t.appState.stats.panels&&e.gridModeEnabled===t.gridModeEnabled&&e.appState.gridStep===t.appState.gridStep&&e.appState.croppingElementId===t.appState.croppingElementId),hV=({sourceElementId:e,onClose:t,appState:n,scene:r,generateLinkForSelection:i=Pi})=>{let a=r.getNonDeletedElementsMap(),o=a.get(e)?.link??null,[s,c]=(0,H.useState)(o),[l,u]=(0,H.useState)(!1);(0,H.useEffect)(()=>{let e=ot(a,n),t=o;if(e.length>0&&i){let r=Fa(e,n);r&&(t=cn(i(r.id,r.type)))}c(t)},[a,n,n.selectedElementIds,o,i]);let d=(0,H.useCallback)(()=>{if(s&&s!==a.get(e)?.link){let t=a.get(e);t&&r.mutateElement(t,{link:s})}if(!s&&l&&e){let t=a.get(e);t&&r.mutateElement(t,{link:null})}t?.()},[e,s,a,l,r,t]);return(0,H.useEffect)(()=>{let e=e=>{n.openDialog?.name===`elementLinkSelector`&&e.key===L.ENTER&&d(),n.openDialog?.name===`elementLinkSelector`&&e.key===L.ESCAPE&&t?.()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[n,t,d]),(0,W.jsxs)(`div`,{className:`ElementLinkDialog`,children:[(0,W.jsxs)(`div`,{className:`ElementLinkDialog__header`,children:[(0,W.jsx)(`h2`,{children:K(`elementLink.title`)}),(0,W.jsx)(`p`,{children:K(`elementLink.desc`)})]}),(0,W.jsxs)(`div`,{className:`ElementLinkDialog__input`,children:[(0,W.jsx)(Sj,{value:s??``,onChange:e=>{l||u(!0),c(e)},onKeyDown:e=>{e.key===L.ENTER&&d()},className:`ElementLinkDialog__input-field`,selectOnRender:!0}),o&&s&&(0,W.jsx)(kw,{type:`button`,title:K(`buttons.remove`),"aria-label":K(`buttons.remove`),label:K(`buttons.remove`),onClick:()=>{c(null),u(!0)},className:`ElementLinkDialog__remove`,icon:Ix})]}),(0,W.jsxs)(`div`,{className:`ElementLinkDialog__actions`,children:[(0,W.jsx)(kA,{label:K(`buttons.cancel`),onClick:()=>{t?.()},style:{marginRight:10}}),(0,W.jsx)(kA,{label:K(`buttons.confirm`),onClick:d,actionType:`primary`})]})]})},gV=({children:e,onClose:t})=>{let[n,r]=(0,H.useState)(!!e),{container:i}=mU(),a=H.useCallback(()=>{r(!1),t&&t(),i?.focus()},[t,i]);return(0,W.jsx)(W.Fragment,{children:n&&(0,W.jsx)(Pj,{size:`small`,onCloseRequest:a,title:K(`errorDialog.title`),children:(0,W.jsx)(`div`,{style:{whiteSpace:`pre-wrap`},children:e})})})},_V=()=>(0,W.jsxs)(`div`,{className:`HelpDialog__header`,children:[(0,W.jsxs)(`a`,{className:`HelpDialog__btn`,href:`https://docs.excalidraw.com`,target:`_blank`,rel:`noopener`,children:[(0,W.jsx)(`div`,{className:`HelpDialog__link-icon`,children:Gx}),K(`helpDialog.documentation`)]}),(0,W.jsxs)(`a`,{className:`HelpDialog__btn`,href:`https://plus.excalidraw.com/blog`,target:`_blank`,rel:`noopener`,children:[(0,W.jsx)(`div`,{className:`HelpDialog__link-icon`,children:Gx}),K(`helpDialog.blog`)]}),(0,W.jsxs)(`a`,{className:`HelpDialog__btn`,href:`https://github.com/excalidraw/excalidraw/issues`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,W.jsx)(`div`,{className:`HelpDialog__link-icon`,children:Kx}),K(`helpDialog.github`)]}),(0,W.jsxs)(`a`,{className:`HelpDialog__btn`,href:`https://youtube.com/@excalidraw`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,W.jsx)(`div`,{className:`HelpDialog__link-icon`,children:lw}),`YouTube`]})]}),vV=e=>(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h3`,{children:e.title}),(0,W.jsx)(`div`,{className:`HelpDialog__islands-container`,children:e.children})]}),yV=e=>(0,W.jsxs)(`div`,{className:`HelpDialog__island ${e.className}`,children:[(0,W.jsx)(`h4`,{className:`HelpDialog__island-title`,children:e.caption}),(0,W.jsx)(`div`,{className:`HelpDialog__island-content`,children:e.children})]});function*bV(e,t){let n=!0;for(let r of e)n||(yield t),n=!1,yield r}var xV=e=>e.replace(/\b[a-z]\b/,e=>e.toUpperCase()),$=({label:e,shortcuts:t,isOr:n=!0})=>{let r=t.map(e=>(e.endsWith(`++`)?[...e.slice(0,-2).split(`+`),`+`]:e.split(`+`)).map(e=>(0,W.jsx)(SV,{children:xV(e)},e)));return(0,W.jsxs)(`div`,{className:`HelpDialog__shortcut`,children:[(0,W.jsx)(`div`,{children:e}),(0,W.jsx)(`div`,{className:`HelpDialog__key-container`,children:[...bV(r,n?K(`helpDialog.or`):``)]})]})},SV=e=>(0,W.jsx)(`kbd`,{className:`HelpDialog__key`,...e}),CV=({onClose:e})=>{let t=vU(),n=H.useCallback(()=>{e&&e()},[e]);return(0,W.jsx)(W.Fragment,{children:(0,W.jsxs)(Pj,{onCloseRequest:n,title:K(`helpDialog.title`),className:`HelpDialog`,children:[(0,W.jsx)(_V,{}),(0,W.jsxs)(vV,{title:K(`helpDialog.shortcuts`),children:[(0,W.jsxs)(yV,{className:`HelpDialog__island--tools`,caption:K(`helpDialog.tools`),children:[(0,W.jsx)($,{label:K(`toolBar.hand`),shortcuts:[L.H]}),(0,W.jsx)($,{label:K(`toolBar.selection`),shortcuts:[L.V,L[1]]}),(0,W.jsx)($,{label:K(`toolBar.rectangle`),shortcuts:[L.R,L[2]]}),(0,W.jsx)($,{label:K(`toolBar.diamond`),shortcuts:[L.D,L[3]]}),(0,W.jsx)($,{label:K(`toolBar.ellipse`),shortcuts:[L.O,L[4]]}),(0,W.jsx)($,{label:K(`toolBar.arrow`),shortcuts:[L.A,L[5]]}),(0,W.jsx)($,{label:K(`toolBar.line`),shortcuts:[L.L,L[6]]}),(0,W.jsx)($,{label:K(`toolBar.freedraw`),shortcuts:[L.P,L[7]]}),(0,W.jsx)($,{label:K(`toolBar.text`),shortcuts:[L.T,L[8]]}),(0,W.jsx)($,{label:K(`toolBar.stickynote`),shortcuts:[L.N]}),(0,W.jsx)($,{label:K(`toolBar.image`),shortcuts:[L[9]]}),(0,W.jsx)($,{label:K(`toolBar.eraser`),shortcuts:[L.E,L[0]]}),(0,W.jsx)($,{label:K(`toolBar.frame`),shortcuts:[L.F]}),(0,W.jsx)($,{label:K(`toolBar.laser`),shortcuts:[L.K]}),(0,W.jsx)($,{label:K(`toolBar.bucketfill`),shortcuts:[L.B]}),(0,W.jsx)($,{label:K(`labels.eyeDropper`),shortcuts:[L.I,`Shift+S`,`Shift+G`]}),(0,W.jsx)($,{label:K(`helpDialog.editLineArrowPoints`),shortcuts:[Z(`CtrlOrCmd+Enter`)]}),(0,W.jsx)($,{label:K(`helpDialog.editText`),shortcuts:[Z(`Enter`)]}),(0,W.jsx)($,{label:K(`helpDialog.textNewLine`),shortcuts:[Z(`Enter`),Z(`Shift+Enter`)]}),(0,W.jsx)($,{label:K(`helpDialog.textFinish`),shortcuts:[Z(`Esc`),Z(`CtrlOrCmd+Enter`)]}),(0,W.jsx)($,{label:K(`helpDialog.curvedArrow`),shortcuts:[`A`,K(`helpDialog.click`),K(`helpDialog.click`),K(`helpDialog.click`)],isOr:!1}),(0,W.jsx)($,{label:K(`helpDialog.curvedLine`),shortcuts:[`L`,K(`helpDialog.click`),K(`helpDialog.click`),K(`helpDialog.click`)],isOr:!1}),(0,W.jsx)($,{label:K(`helpDialog.cropStart`),shortcuts:[K(`helpDialog.doubleClick`),Z(`Enter`)],isOr:!0}),(0,W.jsx)($,{label:K(`helpDialog.cropFinish`),shortcuts:[Z(`Enter`),Z(`Escape`)],isOr:!0}),(0,W.jsx)($,{label:K(`toolBar.lock`),shortcuts:[L.Q]}),(0,W.jsx)($,{label:K(`helpDialog.preventBinding`),shortcuts:[Z(`CtrlOrCmd`)]}),(0,W.jsx)($,{label:K(`toolBar.link`),shortcuts:[Z(`CtrlOrCmd+K`)]}),(0,W.jsx)($,{label:K(`toolBar.convertElementType`),shortcuts:[`Tab`,`Shift+Tab`],isOr:!0})]}),(0,W.jsxs)(yV,{className:`HelpDialog__island--view`,caption:K(`helpDialog.view`),children:[(0,W.jsx)($,{label:K(`buttons.zoomIn`),shortcuts:[Z(`CtrlOrCmd++`)]}),(0,W.jsx)($,{label:K(`buttons.zoomOut`),shortcuts:[Z(`CtrlOrCmd+-`)]}),(0,W.jsx)($,{label:K(`buttons.resetZoom`),shortcuts:[Z(`CtrlOrCmd+0`)]}),(0,W.jsx)($,{label:K(`helpDialog.zoomToFit`),shortcuts:[`Shift+1`]}),(0,W.jsx)($,{label:K(`helpDialog.zoomToSelection`),shortcuts:[`Shift+2`]}),(0,W.jsx)($,{label:K(`helpDialog.movePageUpDown`),shortcuts:[`PgUp/PgDn`]}),(0,W.jsx)($,{label:K(`helpDialog.movePageLeftRight`),shortcuts:[`Shift+PgUp/PgDn`]}),(0,W.jsx)($,{label:K(`buttons.zenMode`),shortcuts:[Z(`Alt+Z`)]}),(0,W.jsx)($,{label:K(`buttons.objectsSnapMode`),shortcuts:[Z(`Alt+S`)]}),(0,W.jsx)($,{label:K(`labels.toggleGrid`),shortcuts:[Z(`CtrlOrCmd+'`)]}),(0,W.jsx)($,{label:K(`labels.viewMode`),shortcuts:[Z(`Alt+R`)]}),t.isActionEnabled(KE)&&(0,W.jsx)($,{label:K(`labels.toggleTheme`),shortcuts:[Z(`Alt+Shift+D`)]}),(0,W.jsx)($,{label:K(`stats.fullTitle`),shortcuts:[Z(`Alt+/`)]}),(0,W.jsx)($,{label:K(`search.title`),shortcuts:[Kk(`searchMenu`)]}),(0,W.jsx)($,{label:K(`commandPalette.title`),shortcuts:is?[Kk(`commandPalette`)]:[Kk(`commandPalette`),Kk(`commandPalette`,1)]})]}),(0,W.jsxs)(yV,{className:`HelpDialog__island--editor`,caption:K(`helpDialog.editor`),children:[(0,W.jsx)($,{label:K(`helpDialog.createFlowchart`),shortcuts:[Z(`CtrlOrCmd+Arrow Key`)],isOr:!0}),(0,W.jsx)($,{label:K(`helpDialog.navigateFlowchart`),shortcuts:[Z(`Alt+Arrow Key`)],isOr:!0}),(0,W.jsx)($,{label:K(`labels.moveCanvas`),shortcuts:[Z(`Space+${K(`helpDialog.drag`)}`),Z(`Wheel+${K(`helpDialog.drag`)}`)],isOr:!0}),(0,W.jsx)($,{label:K(`buttons.clearReset`),shortcuts:[Z(`CtrlOrCmd+Delete`)]}),(0,W.jsx)($,{label:K(`labels.delete`),shortcuts:[Z(`Delete`)]}),(0,W.jsx)($,{label:K(`labels.cut`),shortcuts:[Z(`CtrlOrCmd+X`)]}),(0,W.jsx)($,{label:K(`labels.copy`),shortcuts:[Z(`CtrlOrCmd+C`)]}),(0,W.jsx)($,{label:K(`labels.paste`),shortcuts:[Z(`CtrlOrCmd+V`)]}),(0,W.jsx)($,{label:K(`labels.pasteAsPlaintext`),shortcuts:[Z(`CtrlOrCmd+Shift+V`)]}),(0,W.jsx)($,{label:K(`labels.selectAll`),shortcuts:[Z(`CtrlOrCmd+A`)]}),(0,W.jsx)($,{label:K(`labels.multiSelect`),shortcuts:[Z(`Shift+${K(`helpDialog.click`)}`)]}),(0,W.jsx)($,{label:K(`helpDialog.deepSelect`),shortcuts:[Z(`CtrlOrCmd+${K(`helpDialog.click`)}`)]}),(0,W.jsx)($,{label:K(`helpDialog.deepBoxSelect`),shortcuts:[Z(`CtrlOrCmd+${K(`helpDialog.drag`)}`)]}),(DD||is)&&(0,W.jsx)($,{label:K(`labels.copyAsPng`),shortcuts:[Z(`Shift+Alt+C`)]}),(0,W.jsx)($,{label:K(`labels.copyStyles`),shortcuts:[Z(`CtrlOrCmd+Alt+C`)]}),(0,W.jsx)($,{label:K(`labels.pasteStyles`),shortcuts:[Z(`CtrlOrCmd+Alt+V`)]}),(0,W.jsx)($,{label:K(`labels.sendToBack`),shortcuts:[Z(pc?`CtrlOrCmd+Alt+[`:`CtrlOrCmd+Shift+[`)]}),(0,W.jsx)($,{label:K(`labels.bringToFront`),shortcuts:[Z(pc?`CtrlOrCmd+Alt+]`:`CtrlOrCmd+Shift+]`)]}),(0,W.jsx)($,{label:K(`labels.sendBackward`),shortcuts:[Z(`CtrlOrCmd+[`)]}),(0,W.jsx)($,{label:K(`labels.bringForward`),shortcuts:[Z(`CtrlOrCmd+]`)]}),(0,W.jsx)($,{label:K(`labels.alignTop`),shortcuts:[Z(`CtrlOrCmd+Shift+Up`)]}),(0,W.jsx)($,{label:K(`labels.alignBottom`),shortcuts:[Z(`CtrlOrCmd+Shift+Down`)]}),(0,W.jsx)($,{label:K(`labels.alignLeft`),shortcuts:[Z(`CtrlOrCmd+Shift+Left`)]}),(0,W.jsx)($,{label:K(`labels.alignRight`),shortcuts:[Z(`CtrlOrCmd+Shift+Right`)]}),(0,W.jsx)($,{label:K(`labels.duplicateSelection`),shortcuts:[Z(`CtrlOrCmd+D`),Z(`Alt+${K(`helpDialog.drag`)}`)]}),(0,W.jsx)($,{label:K(`helpDialog.toggleElementLock`),shortcuts:[Z(`CtrlOrCmd+Shift+L`)]}),(0,W.jsx)($,{label:K(`buttons.undo`),shortcuts:[Z(`CtrlOrCmd+Z`)]}),(0,W.jsx)($,{label:K(`buttons.redo`),shortcuts:we?[Z(`CtrlOrCmd+Y`),Z(`CtrlOrCmd+Shift+Z`)]:[Z(`CtrlOrCmd+Shift+Z`)]}),(0,W.jsx)($,{label:K(`labels.group`),shortcuts:[Z(`CtrlOrCmd+G`)]}),(0,W.jsx)($,{label:K(`labels.ungroup`),shortcuts:[Z(`CtrlOrCmd+Shift+G`)]}),(0,W.jsx)($,{label:K(`labels.flipHorizontal`),shortcuts:[Z(`Shift+H`)]}),(0,W.jsx)($,{label:K(`labels.flipVertical`),shortcuts:[Z(`Shift+V`)]}),(0,W.jsx)($,{label:K(`labels.showStroke`),shortcuts:[Z(`S`)]}),(0,W.jsx)($,{label:K(`labels.showBackground`),shortcuts:[Z(`G`)]}),(0,W.jsx)($,{label:K(`labels.showFonts`),shortcuts:[Z(`Shift+F`)]}),(0,W.jsx)($,{label:K(`labels.decreaseFontSize`),shortcuts:[Z(`CtrlOrCmd+Shift+<`)]}),(0,W.jsx)($,{label:K(`labels.increaseFontSize`),shortcuts:[Z(`CtrlOrCmd+Shift+>`)]})]})]})]})})},wV=2e3,TV=()=>{let[e,t]=(0,H.useState)(null),n=(0,H.useRef)(0);return{copyStatus:e,resetCopyStatus:(0,H.useCallback)(()=>{t(null)},[]),onCopy:()=>{clearTimeout(n.current),t(`success`),n.current=window.setTimeout(()=>{t(null)},wV)}}},EV=({title:e,name:t,checked:n,onChange:r,disabled:i=!1})=>(0,W.jsx)(`div`,{className:U(`Switch`,{toggled:n,disabled:i}),children:(0,W.jsx)(`input`,{name:t,id:t,title:e,type:`checkbox`,checked:n,disabled:i,onChange:()=>r(!n),onKeyDown:e=>{e.key===` `&&r(!n)}})}),DV=()=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{children:K(`canvasError.cannotShowPreview`)}),(0,W.jsx)(`p`,{children:(0,W.jsx)(`span`,{children:K(`canvasError.canvasTooBig`)})}),(0,W.jsxs)(`em`,{children:[`(`,K(`canvasError.canvasTooBigTip`),`)`]})]}),OV=({appStateSnapshot:e,elementsSnapshot:t,files:n,actionManager:r,onExportImage:i,name:a,exportWithDarkMode:o})=>{let s=Jc(t,e),[c,l]=(0,H.useState)(a),[u,d]=(0,H.useState)(s),[f,p]=(0,H.useState)(e.exportBackground),[m,h]=(0,H.useState)(e.exportEmbedScene),[g,_]=(0,H.useState)(e.exportScale),v=(0,H.useRef)(null),y=(0,H.useRef)(0),[b,x]=(0,H.useState)(null),{onCopy:S,copyStatus:C,resetCopyStatus:w}=TV();(0,H.useEffect)(()=>{w()},[c,f,o,g,m,w]);let{exportedElements:T,exportingFrame:D}=KD(t,e,u);return(0,H.useEffect)(()=>{let t=v.current;if(!t)return;let r=t.offsetWidth,i=t.offsetHeight;if(!r)return;let a=++y.current,s=()=>a!==y.current;return Qk({elements:T,appState:{...e,name:c,exportBackground:f,exportWithDarkMode:o,exportScale:g,exportEmbedScene:m},files:n,exportPadding:10,maxWidthOrHeight:Math.max(r,i),exportingFrame:D}).then(async e=>{if(!s()){try{await Xa(e)}catch(e){throw e.name===`CANVAS_POSSIBLY_TOO_BIG`?Error(K(`canvasError.canvasTooBig`)):e}s()||(x(null),t.replaceChildren(e))}}).catch(e=>{s()||(console.error(e),x(e))}),()=>{y.current+=1}},[e,n,T,D,c,f,o,g,m]),(0,W.jsxs)(`div`,{className:`ImageExportModal`,children:[(0,W.jsx)(`h3`,{children:K(`imageExportDialog.header`)}),(0,W.jsxs)(`div`,{className:`ImageExportModal__preview`,children:[(0,W.jsx)(`div`,{className:`ImageExportModal__preview__canvas`,ref:v,children:b&&(0,W.jsx)(DV,{})}),(0,W.jsx)(`div`,{className:`ImageExportModal__preview__filename`,children:!mc&&(0,W.jsx)(`input`,{type:`text`,className:`TextInput`,value:c,style:{width:`30ch`},onChange:e=>{l(e.target.value),r.executeAction(YD,`ui`,e.target.value)}})})]}),(0,W.jsxs)(`div`,{className:`ImageExportModal__settings`,children:[(0,W.jsx)(`h3`,{children:K(`imageExportDialog.header`)}),s&&(0,W.jsx)(kV,{label:K(`imageExportDialog.label.onlySelected`),name:`exportOnlySelected`,children:(0,W.jsx)(EV,{name:`exportOnlySelected`,checked:u,onChange:e=>{d(e)}})}),(0,W.jsx)(kV,{label:K(`imageExportDialog.label.withBackground`),name:`exportBackgroundSwitch`,children:(0,W.jsx)(EV,{name:`exportBackgroundSwitch`,checked:f,onChange:e=>{p(e),r.executeAction(ZD,`ui`,e)}})}),(0,W.jsx)(kV,{label:K(`imageExportDialog.label.darkMode`),name:`exportDarkModeSwitch`,children:(0,W.jsx)(EV,{name:`exportDarkModeSwitch`,checked:o,onChange:e=>{r.executeAction(oO,`ui`,e)}})}),(0,W.jsx)(kV,{label:K(`imageExportDialog.label.embedScene`),tooltip:K(`imageExportDialog.tooltip.embedScene`),name:`exportEmbedSwitch`,children:(0,W.jsx)(EV,{name:`exportEmbedSwitch`,checked:m,onChange:e=>{h(e),r.executeAction(QD,`ui`,e)}})}),(0,W.jsx)(kV,{label:K(`imageExportDialog.label.scale`),name:`exportScale`,children:(0,W.jsx)(rR,{name:`exportScale`,value:g,onChange:e=>{_(e),r.executeAction(XD,`ui`,e)},choices:E.map(e=>({value:e,label:`${e}\xD7`}))})}),(0,W.jsxs)(`div`,{className:`ImageExportModal__settings__buttons`,children:[(0,W.jsx)(AR,{className:`ImageExportModal__settings__buttons__button`,label:K(`imageExportDialog.title.exportToPng`),onClick:()=>i(Cn.png,T,{exportingFrame:D}),icon:wC,children:K(`imageExportDialog.button.exportToPng`)}),(0,W.jsx)(AR,{className:`ImageExportModal__settings__buttons__button`,label:K(`imageExportDialog.title.exportToSvg`),onClick:()=>i(Cn.svg,T,{exportingFrame:D}),icon:wC,children:K(`imageExportDialog.button.exportToSvg`)}),(DD||is)&&(0,W.jsx)(AR,{className:`ImageExportModal__settings__buttons__button`,label:K(`imageExportDialog.title.copyPngToClipboard`),status:C,onClick:async()=>{await i(Cn.clipboard,T,{exportingFrame:D}),S()},icon:TC,children:K(`imageExportDialog.button.copyPngToClipboard`)})]})]})]})},kV=({label:e,children:t,tooltip:n,name:r})=>(0,W.jsxs)(`div`,{className:`ImageExportModal__settings__setting`,title:e,children:[(0,W.jsxs)(`label`,{htmlFor:r,className:`ImageExportModal__settings__setting__label`,children:[e,n&&(0,W.jsx)(IE,{label:n,long:!0,children:DC})]}),(0,W.jsx)(`div`,{className:`ImageExportModal__settings__setting__content`,children:t})]}),AV=({elements:e,appState:t,files:n,actionManager:r,onExportImage:i,onCloseRequest:a,name:o})=>{let[{appStateSnapshot:s,elementsSnapshot:c}]=(0,H.useState)(()=>({appStateSnapshot:Fr(t),elementsSnapshot:Fr(e)}));return(0,W.jsx)(Pj,{onCloseRequest:a,size:`wide`,title:!1,children:(0,W.jsx)(OV,{elementsSnapshot:c,appStateSnapshot:s,files:n,actionManager:r,onExportImage:i,name:o,exportWithDarkMode:t.exportWithDarkMode})})},jV={primary:{base:`var(--color-primary)`,darker:`var(--color-primary-darker)`,darkest:`var(--color-primary-darkest)`},lime:{base:`#74b816`,darker:`#66a80f`,darkest:`#5c940d`},pink:{base:`#d6336c`,darker:`#c2255c`,darkest:`#a61e4d`}},MV=({children:e,color:t})=>(0,W.jsx)(`div`,{className:`Card`,style:{"--card-color":jV[t].base,"--card-color-darker":jV[t].darker,"--card-color-darkest":jV[t].darkest},children:e}),NV=({elements:e,appState:t,setAppState:n,files:r,actionManager:i,exportOpts:a,canvas:o,onCloseRequest:s})=>{let{onExportToBackend:c}=a;return(0,W.jsx)(`div`,{className:`ExportDialog ExportDialog--json`,children:(0,W.jsxs)(`div`,{className:`ExportDialog-cards`,children:[a.saveFileToDisk&&(0,W.jsxs)(MV,{color:`lime`,children:[(0,W.jsx)(`div`,{className:`Card-icon`,children:iS}),(0,W.jsx)(`h2`,{children:K(`exportDialog.disk_title`)}),(0,W.jsxs)(`div`,{className:`Card-details`,children:[K(`exportDialog.disk_details`),!mc&&i.renderAction(`changeProjectName`)]}),(0,W.jsx)(kw,{className:`Card-button`,type:`button`,title:K(`exportDialog.disk_button`),"aria-label":K(`exportDialog.disk_button`),showAriaLabel:!0,onClick:()=>{i.executeAction(iO,`ui`)}})]}),c&&(0,W.jsxs)(MV,{color:`pink`,children:[(0,W.jsx)(`div`,{className:`Card-icon`,children:Xx}),(0,W.jsx)(`h2`,{children:K(`exportDialog.link_title`)}),(0,W.jsx)(`div`,{className:`Card-details`,children:K(`exportDialog.link_details`)}),(0,W.jsx)(kw,{className:`Card-button`,type:`button`,title:K(`exportDialog.link_button`),"aria-label":K(`exportDialog.link_button`),showAriaLabel:!0,onClick:async()=>{try{Vw(`export`,`link`,`ui (${Ha()})`),await c(e,t,r),s()}catch(e){n({errorMessage:e.message})}}})]}),a.renderCustomUI&&a.renderCustomUI(e,t,r,o)]})})},PV=({elements:e,appState:t,files:n,actionManager:r,exportOpts:i,canvas:a,setAppState:o})=>{let s=H.useCallback(()=>{o({openDialog:null})},[o]);return(0,W.jsx)(W.Fragment,{children:t.openDialog?.name===`jsonExport`&&(0,W.jsx)(Pj,{onCloseRequest:s,title:K(`buttons.export`),children:(0,W.jsx)(NV,{elements:e,appState:t,setAppState:o,files:n,actionManager:r,onCloseRequest:s,exportOpts:i,canvas:a})})})},FV=e=>(0,W.jsx)(kw,{className:U(`ToolIcon__LaserPointer`,{"is-mobile":e.isMobile}),type:`toggle`,size:`small`,icon:zC,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,"data-testid":`toolbar-LaserPointer`,onSelect:()=>e.onChange?.()}),IV=e=>Array.isArray(e)?`<kbd>${e.map(Z).join(` + `)}</kbd>`:`<kbd>${Z(e)}</kbd>`,LV=({appState:e,isMobile:t,editorInterface:n,app:r})=>{let{activeTool:i,isResizing:a,isRotating:o,lastPointerDownWith:s}=e,c=e.multiElement!==null;if(e.openSidebar?.name===Gi.name&&e.openSidebar.tab===`search`&&e.searchMatches?.matches.length)return K(`hints.dismissSearch`,{shortcut:IV(`Escape`)});if(e.openSidebar&&!n.canFitSidebar)return null;if(Ba(e))return K(`hints.eraserRevert`,{shortcut:IV(`Alt`)});let l=r.scene.getSelectedElements(e);if(e.selectedLinearElement?.isDragging&&l[0]?.type===`arrow`)return K(`hints.arrowBindModifiers`,{shortcut_1:IV(`Ctrl`),shortcut_2:IV(`Alt`)});if(i.type===`arrow`||i.type===`line`)return c?K(`hints.linearElementMulti`,{shortcut_1:IV(`Escape`),shortcut_2:IV(`Enter`)}):i.type===`arrow`?K(`hints.arrowTool`,{shortcut:IV(`A`)}):K(`hints.linearElement`);if(i.type===`freedraw`)return K(`hints.freeDraw`);if(i.type===`text`)return K(`hints.text`);if(i.type===`embeddable`)return K(`hints.embeddable`);if(i.type===`stickynote`)return K(`hints.stickynote`);if(i.type===`autoshape`)return K(`hints.autoshape`);if(a&&s===`mouse`&&l.length===1){let e=l[0];return ro(e)&&e.points.length===2?K(`hints.lockAngle`,{shortcut:IV(`Shift`)}):oe(e)&&r.activeResizeHandle?.length===2?K(`hints.resizeStickyNote`,{shortcut_1:IV(`Shift`),shortcut_2:IV(`Alt`)}):La(e)?K(`hints.resizeImage`,{shortcut_1:IV(`Shift`),shortcut_2:IV(`Alt`)}):K(`hints.resize`,{shortcut_1:IV(`Shift`),shortcut_2:IV(`Alt`)})}if(o&&s===`mouse`)return K(`hints.rotate`,{shortcut:IV(`Shift`)});if(l.length===1&&z(l[0]))return K(`hints.text_selected`,{shortcut:IV(`Enter`)});if(e.editingTextElement)return K(`hints.text_editing`,{shortcut_1:IV(`Escape`),shortcut_2:IV([`CtrlOrCmd`,`Enter`])});if(e.croppingElementId)return K(`hints.leaveCropEditor`,{shortcut_1:IV(`Enter`),shortcut_2:IV(`Escape`)});if(l.length===1&&La(l[0]))return K(`hints.enterCropEditor`,{shortcut:IV(`Enter`)});if(i.type===`selection`){if(e.selectionElement&&!l.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return K(`hints.deepBoxSelect`,{shortcut:IV(`CtrlOrCmd`)});if(lP(r)&&e.selectedElementsAreBeingDragged)return K(`hints.disableSnapping`,{shortcut:IV(`CtrlOrCmd`)});if(!l.length&&!t)return K(`hints.canvasPanning`,{shortcut_1:IV(K(`keys.mmb`)),shortcut_2:IV(`Space`)});if(l.length===1){if(ro(l[0]))return ye(l[0])&&e.selectedLinearElement?.elementId===l[0].id&&(e.selectedLinearElement.hoverPointIndex===0||e.selectedLinearElement.hoverPointIndex===l[0].points.length-1)?K(`hints.toggleArrowhead`):e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?K(`hints.lineEditor_pointSelected`,{shortcut_1:IV(`Delete`),shortcut_2:IV([`CtrlOrCmd`,`D`])}):K(`hints.lineEditor_nothingSelected`,{shortcut_1:IV(`Shift`),shortcut_2:IV(`Alt`)}):oa(l[0])?K(`hints.lineEditor_line_info`,{shortcut:IV(`Enter`)}):K(`hints.lineEditor_info`,{shortcut_1:IV(`CtrlOrCmd`),shortcut_2:IV([`CtrlOrCmd`,`Enter`])});if(!e.newElement&&!e.selectedElementsAreBeingDragged&&Ne(l[0])){let e=K(`hints.bindTextToElement`,{shortcut:IV(`Enter`)}),t=K(`hints.createFlowchart`,{shortcut:IV([`CtrlOrCmd`,`↑↓`])});return $r(l[0])?(te(l[0],r.scene.getNonDeletedElementsMap()),[e,t]):e}}}return null},RV=({appState:e,isMobile:t,editorInterface:n,app:r})=>{let i=LV({appState:e,isMobile:t,editorInterface:n,app:r});if(!i)return null;let a=(Array.isArray(i)?i.map(e=>e.replace(/\. ?$/,``)).join(`, `):i).split(/(<kbd>[^<]+<\/kbd>)/g).map((e,t)=>{if(t%2==1){let n=e[0]===`<`&&e.match(/^<kbd>([^<]+)<\/kbd>$/);return(0,W.jsx)(`kbd`,{children:n?n[1]:e},t)}return e});return(0,W.jsx)(`div`,{className:`HintViewer`,children:(0,W.jsx)(`span`,{children:a})})},zV=e=>(0,W.jsx)(kw,{className:U(`ToolIcon__lock`,{"is-mobile":e.isMobile}),type:`toggle`,icon:e.checked?hx:mx,checked:e.checked,disabled:e.disabled,title:`${e.title} \u2014 Q`,"aria-label":`${e.title}`,"data-testid":`toolbar-lock`,onSelect:()=>e.onChange?.()}),BV=({app:e,activeTool:t,setAppState:n,UIOptions:r})=>{let[i,a]=(0,H.useState)(!1),o=pU()===`full`,{TTDDialogTriggerTunnel:s}=yL(),c=t.type===`image`,l=t.type===`frame`,u=t.type===`autoshape`,d=t.type===`laser`,f=t.type===`bucketfill`,p=o&&t.type===`lasso`&&e.state.preferredSelectionTool.type!==`lasso`,m=t.type===`embeddable`;return(0,W.jsxs)(Q,{open:i,children:[(0,W.jsx)(Q.Trigger,{className:U(`App-toolbar__extra-tools-trigger`,{"App-toolbar__extra-tools-trigger--selected":c||l||m||o&&u||p||f||d&&!e.props.isCollaborating}),onToggle:()=>{a(!i),n({openMenu:null,openPopup:null})},title:K(`toolBar.extraTools`),children:c?jx:l?MC:m?Lx:o&&u?RC:d&&!e.props.isCollaborating?zC:p?xx:f?tS:ux}),(0,W.jsxs)(Q.Content,{onClickOutside:()=>a(!1),onSelect:()=>a(!1),className:`App-toolbar__extra-tools-dropdown`,children:[r.tools?.image!==!1&&(0,W.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`image`}),icon:jx,shortcut:L[9],"data-testid":`toolbar-image`,selected:c,disabled:$E(e,`image`),children:K(`toolBar.image`)}),(0,W.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`frame`}),icon:MC,shortcut:L.F.toLocaleUpperCase(),"data-testid":`toolbar-frame`,selected:l,disabled:$E(e,`frame`),children:K(`toolBar.frame`)}),(0,W.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`embeddable`}),icon:Lx,"data-testid":`toolbar-embeddable`,selected:m,disabled:$E(e,`embeddable`),children:K(`toolBar.embeddable`)}),(0,W.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`autoshape`}),icon:RC,shortcut:ZE(`autoshape`),"data-testid":`toolbar-autoshape`,selected:u,disabled:$E(e,`autoshape`),children:K(`toolBar.autoshape`)}),(0,W.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`laser`}),icon:zC,"data-testid":`toolbar-laser`,selected:d,shortcut:L.K.toLocaleUpperCase(),disabled:$E(e,`laser`),children:K(`toolBar.laser`)}),(0,W.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`bucketfill`}),icon:tS,"data-testid":`toolbar-bucketfill`,selected:f,shortcut:L.B.toLocaleUpperCase(),disabled:$E(e,`bucketfill`),children:K(`toolBar.bucketfill`)}),o&&(0,W.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`lasso`}),icon:xx,"data-testid":`toolbar-lasso`,selected:p,disabled:$E(e,`lasso`),children:K(`toolBar.lasso`)}),(0,W.jsx)(`div`,{style:{margin:`6px 0`,fontSize:14,fontWeight:600},children:`Generate`}),e.props.aiEnabled!==!1&&(0,W.jsx)(s.Out,{}),(0,W.jsx)(Q.Item,{onSelect:()=>e.setOpenDialog({name:`ttd`,tab:`mermaid`}),icon:PC,"data-testid":`toolbar-embeddable`,children:K(`toolBar.mermaidToExcalidraw`)}),e.props.aiEnabled!==!1&&e.plugins.diagramToCode&&(0,W.jsx)(Q.Item,{onSelect:()=>e.onMagicframeToolSelect(),icon:BC,"data-testid":`toolbar-magicframe`,badge:(0,W.jsx)(Q.Item.Badge,{children:`AI`}),disabled:$E(e,`magicframe`),children:K(`toolBar.magicframe`)})]})]})},VV=({app:e,appState:t,setAppState:n,UIOptions:r,onPenModeToggle:i,onLockToggle:a,heading:o})=>{let s=fU(),c=pU()===`compact`,l=t.activeTool,u={app:e,activeTool:l};return(0,W.jsxs)(nT,{padding:1,className:U(`App-toolbar`,{"zen-mode":t.zenModeEnabled,"App-toolbar--compact":c}),"data-viewport-ui":`top`,children:[(0,W.jsx)(RV,{appState:t,isMobile:s.formFactor===`phone`,editorInterface:s,app:e}),o,(0,W.jsxs)(VA.Row,{gap:c?.5:1,children:[!c&&(0,W.jsx)(TL,{checked:t.penMode,onChange:()=>i(null),title:K(`toolBar.penMode`),penDetected:t.penDetected}),e.props.activeTool==null&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(zV,{checked:t.activeTool.locked,onChange:a,title:K(`toolBar.lock`),disabled:e.props.activeTool!=null}),(0,W.jsx)(`div`,{className:`App-toolbar__divider`,style:{marginRight:`0.25rem`}})]}),(0,W.jsx)(tD,{...u,hideKeyBinding:!0}),c?(0,W.jsx)(hD,{...u,setAppState:n}):t.preferredSelectionTool.type===`lasso`?(0,W.jsx)(mD,{...u}):(0,W.jsx)(pD,{...u}),(0,W.jsx)(nD,{...u}),(0,W.jsx)(rD,{...u}),(0,W.jsx)(iD,{...u}),(0,W.jsx)(aD,{...u}),(0,W.jsx)(oD,{...u}),c?(0,W.jsx)(gD,{...u}):(0,W.jsx)(sD,{...u}),(0,W.jsx)(cD,{...u}),(0,W.jsx)(lD,{...u}),(0,W.jsx)(dD,{...u}),(0,W.jsx)(`div`,{className:`App-toolbar__divider`,style:{marginLeft:`0.25rem`}}),(0,W.jsx)(BV,{app:e,activeTool:l,setAppState:n,UIOptions:r})]})]})},HV=({UIOptions:e})=>(0,W.jsxs)(kR,{__fallback:!0,children:[(0,W.jsx)(kR.DefaultItems.LoadScene,{}),(0,W.jsx)(kR.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&(0,W.jsx)(kR.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&(0,W.jsx)(kR.DefaultItems.SaveAsImage,{}),(0,W.jsx)(kR.DefaultItems.SearchMenu,{}),(0,W.jsx)(kR.DefaultItems.Help,{}),(0,W.jsx)(kR.DefaultItems.ClearCanvas,{}),(0,W.jsx)(kR.Separator,{}),(0,W.jsx)(kR.Group,{title:`Excalidraw links`,children:(0,W.jsx)(kR.DefaultItems.Socials,{})}),(0,W.jsx)(kR.Separator,{}),(0,W.jsx)(kR.DefaultItems.ToggleTheme,{allowSystemTheme:!1}),(0,W.jsx)(kR.DefaultItems.ChangeCanvasBackground,{})]}),UV=()=>(0,W.jsxs)(NR,{__fallback:!0,children:[(0,W.jsx)(NR.Actions.SaveToDisk,{}),(0,W.jsx)(NR.Actions.ExportToImage,{})]}),WV=({actionManager:e,appState:t,files:n,setAppState:r,elements:i,canvas:a,onLockToggle:o,onPenModeToggle:s,showExitZenModeBtn:c,renderTopLeftUI:l,renderTopRightUI:u,renderCustomStats:f,UIOptions:p,onExportImage:m,renderWelcomeScreen:h,children:g,app:_,defaultUIEnabled:v,zoomUIEnabled:y,scrollBackToContentUIEnabled:b,isCollaborating:x,generateLinkForSelection:S,currentUserControls:C})=>{let w=fU(),T=dU(),E=pU()===`compact`,D=xL(),ee=E?{menuTopGap:4,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:.5,islandPadding:1,collabMarginLeft:8}:{menuTopGap:6,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:1,islandPadding:1,collabMarginLeft:8},te=D.tunnelsJotai.Provider,[O,k]=Vb(eT),ne=()=>p.canvasActions.export?(0,W.jsx)(PV,{elements:i,appState:t,files:n,actionManager:e,exportOpts:p.canvasActions.export,canvas:a,setAppState:r}):null,re=()=>!p.canvasActions.saveAsImage||t.openDialog?.name!==`imageExport`?null:(0,W.jsx)(AV,{elements:i,appState:t,files:n,actionManager:e,onExportImage:m,onCloseRequest:()=>r({openDialog:null}),name:_.getName()}),ie=()=>(0,W.jsxs)(`div`,{style:{position:`relative`},children:[(0,W.jsxs)(`div`,{className:`excalidraw-ui-top-left`,children:[l?.(!1,t),(0,W.jsx)(D.MainMenuTunnel.Out,{})]}),h&&(0,W.jsx)(D.WelcomeScreenMenuHintTunnel.Out,{})]}),ae=()=>(0,W.jsx)(jL,{heading:`selectedShapeActions`,className:U(`selected-shape-actions zen-mode-transition`,{"transition-left":t.zenModeEnabled}),children:E?(0,W.jsx)(nT,{className:U(`compact-shape-actions-island`),padding:0,"data-viewport-ui":`side`,"data-viewport-ui-name":`stylesPanel`,style:{maxHeight:`${t.height-166}px`},children:(0,W.jsx)(Jj,{appState:t,elementsMap:_.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:_,setAppState:r})}):(0,W.jsx)(nT,{className:Ai.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${t.height-166}px`},"data-viewport-ui":`side`,"data-viewport-ui-name":`stylesPanel`,children:(0,W.jsx)(Hj,{appState:t,elementsMap:_.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:_})})}),oe=()=>{let n=v&&bc(t,i),a=v&&t.stats.open&&!t.zenModeEnabled&&!t.viewModeEnabled&&t.openDialog?.name!==`elementLinkSelector`;return(0,W.jsx)(wL,{side:`top`,children:(0,W.jsxs)(`div`,{className:`App-menu App-menu_top`,children:[(0,W.jsxs)(VA.Col,{gap:ee.menuTopGap,className:U(`App-menu_top__left`),children:[ie(),v&&(0,W.jsx)(`div`,{className:U(`selected-shape-actions-container`,{"selected-shape-actions-container--compact":E}),children:n&&ae()}),v&&E&&!t.viewModeEnabled&&n&&(0,W.jsx)(TL,{checked:t.penMode,onChange:()=>s(null),title:K(`toolBar.penMode`),isMobile:!0,penDetected:t.penDetected})]}),v&&!t.viewModeEnabled&&t.openDialog?.name!==`elementLinkSelector`&&(0,W.jsx)(jL,{heading:`shapes`,className:`shapes-section`,children:e=>(0,W.jsxs)(`div`,{style:{position:`relative`},children:[h&&(0,W.jsx)(D.WelcomeScreenToolbarHintTunnel.Out,{}),(0,W.jsx)(VA.Col,{gap:ee.toolbarColGap,align:`start`,children:(0,W.jsxs)(VA.Row,{gap:ee.toolbarRowGap,className:U(`App-toolbar-container`,{"zen-mode":t.zenModeEnabled}),children:[(0,W.jsx)(VV,{app:_,appState:t,setAppState:r,UIOptions:p,onPenModeToggle:s,onLockToggle:o,heading:e}),x&&(0,W.jsx)(nT,{style:{marginLeft:ee.collabMarginLeft,alignSelf:`center`,height:`fit-content`},children:(0,W.jsx)(FV,{title:K(`toolBar.laser`),checked:t.activeTool.type===A.laser,onChange:()=>_.setActiveTool({type:A.laser}),isMobile:!0})})]})})]})}),(0,W.jsxs)(`div`,{className:U(`layer-ui__wrapper__top-right zen-mode-transition`,{"transition-right":t.zenModeEnabled,"layer-ui__wrapper__top-right--compact":E}),children:[v&&t.collaborators.size>0&&(0,W.jsx)(zL,{collaborators:t.collaborators,userToFollow:T.userToFollow?.socketId||null,currentUserControls:C}),u?.(w.formFactor===`phone`,t),!t.viewModeEnabled&&t.openDialog?.name!==`elementLinkSelector`&&(!ce||t.openSidebar?.name!==Gi.name)&&(0,W.jsx)(D.DefaultSidebarTriggerTunnel.Out,{}),a&&(0,W.jsx)(dV,{app:_,onClose:()=>{e.executeAction(VO)},renderCustomStats:f})]})]})})},se=()=>v?(0,W.jsx)(JR,{__fallback:!0,onDock:e=>{Vw(`sidebar`,`toggleDock (${e?`dock`:`undock`})`,`(${w.formFactor===`phone`?`mobile`:`desktop`})`)}}):null,ce=Ub(XL),le=!!(t.openSidebar&&ce&&w.canFitSidebar),ue=(0,W.jsxs)(W.Fragment,{children:[g,v&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(HV,{UIOptions:p}),(0,W.jsx)(JR.Trigger,{__fallback:!0,icon:Cw,title:Xo(K(`toolBar.library`)),onToggle:e=>{e&&Vw(`sidebar`,`${Gi.name} (open)`,`button (${w.formFactor===`phone`?`mobile`:`desktop`})`)},tab:Gi.defaultTab})]}),(0,W.jsx)(UV,{}),t.openDialog?.name===`ttd`&&(0,W.jsx)(yB,{__fallback:!0}),v&&t.isLoading&&(0,W.jsx)(SL,{delay:250}),v&&t.errorMessage&&(0,W.jsx)(gV,{onClose:()=>r({errorMessage:null}),children:t.errorMessage}),v&&O&&w.formFactor!==`phone`&&(0,W.jsx)(tT,{colorPickerType:O.colorPickerType,onCancel:()=>{k(null)},onChange:(e,n,a,{altKey:o})=>{if(e!==`elementBackground`&&e!==`elementStroke`)return;let s=o&&O.swapPreviewOnAlt?e===`elementBackground`?`strokeColor`:`backgroundColor`:e===`elementBackground`?`backgroundColor`:`strokeColor`;if(a.length){let e=d(i),r=ot(i,t,{includeBoundTextElement:s===`strokeColor`});for(let t of r)Xr(t,e,el(t,s,n,e)),Nn.delete(t);_.scene.triggerUpdate()}else r(bE(yE(t,i,s),n))},onSelect:(e,t)=>{k(e=>e?.keepOpenOnAlt&&t.altKey?e:null),O?.onSelect?.(e,t)}}),t.openDialog?.name===`help`&&(0,W.jsx)(CV,{onClose:()=>{r({openDialog:null})}}),(0,W.jsx)(nM,{}),v&&t.openDialog?.name===`elementLinkSelector`&&(0,W.jsx)(hV,{sourceElementId:t.openDialog.sourceElementId,onClose:()=>{r({openDialog:null})},scene:_.scene,appState:t,generateLinkForSelection:S}),(0,W.jsx)(D.OverwriteConfirmDialogTunnel.Out,{}),re(),ne(),v&&t.openDialog?.name===`charts`&&(0,W.jsx)(AL,{data:t.openDialog.data,rawText:t.openDialog.rawText,onClose:()=>r({openDialog:null})}),w.formFactor===`phone`&&(0,W.jsx)(EL,{app:_,appState:t,elements:i,actionManager:e,renderJSONExportDialog:ne,renderImageExportDialog:re,setAppState:r,onPenModeToggle:s,renderTopLeftUI:l,renderTopRightUI:u,renderSidebars:se,renderWelcomeScreen:h,defaultUIEnabled:v,scrollBackToContentUIEnabled:b}),w.formFactor!==`phone`&&(0,W.jsxs)(W.Fragment,{children:[T.viewportStatusFrame?.border&&(0,W.jsx)(gL,{border:T.viewportStatusFrame.border,style:le?{right:`calc(var(--right-sidebar-width) - var(--space-factor) * 2)`}:void 0}),(0,W.jsxs)(`div`,{className:`layer-ui__wrapper`,style:le?{width:`calc(100% - var(--right-sidebar-width))`}:{},children:[h&&(0,W.jsx)(D.WelcomeScreenCenterTunnel.Out,{}),oe(),(0,W.jsx)(HL,{appState:t,actionManager:e,showExitZenModeBtn:c,renderWelcomeScreen:h,defaultUIEnabled:v,zoomUIEnabled:y}),(t.toast||b&&t.scrolledOutside||T.viewportStatusFrame?.label)&&(0,W.jsxs)(`div`,{className:`floating-status-stack`,children:[t.toast&&(0,W.jsx)(TD,{message:t.toast.message,onClose:()=>r({toast:null}),duration:t.toast.duration,closable:t.toast.closable}),!t.toast&&b&&t.scrolledOutside&&(0,W.jsx)(`button`,{type:`button`,className:`scroll-back-to-content`,onClick:()=>{r(e=>({...hc(i,e)}))},children:K(`buttons.scrollBackToContent`)}),T.viewportStatusFrame?.label&&(0,W.jsx)(_L,{label:T.viewportStatusFrame.label,border:T.viewportStatusFrame.border})]})]}),se()]})]});return(0,W.jsx)(Gw.Provider,{value:t,children:(0,W.jsx)(te,{children:(0,W.jsx)(vL.Provider,{value:D,children:ue})})})},GV=e=>{let{cursorButton:t,scrollX:n,scrollY:r,zoom:i,shouldCacheIgnoreZoom:a,snapLines:o,originSnapOffset:s,suggestedBinding:c,frameToHighlight:l,elementsToHighlight:u,...d}=e;return d},KV=H.memo(WV,(e,t)=>{if(e.children!==t.children)return!1;let{canvas:n,appState:r,...i}=e,{canvas:a,appState:o,...s}=t;return Us(GV(r),GV(o),{selectedElementIds:Us,selectedGroupIds:Us})&&Us(i,s)}),qV=e=>(0,W.jsx)(kw,{className:U(`ToolIcon__MagicButton`,{"is-mobile":e.isMobile}),type:`toggle`,size:`small`,icon:e.icon,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,onSelect:()=>e.onChange?.()}),JV=({trails:e})=>{let t=(0,H.useRef)(null);return(0,H.useEffect)(()=>{if(t.current)for(let n of e)n.start(t.current);return()=>{for(let t of e)t.stop()}},e),(0,W.jsx)(`div`,{className:`SVGLayer`,children:(0,W.jsx)(`svg`,{ref:t})})},YV=`#ff6b6b`,XV=`#ff9090`,ZV=`#da5b5b`,QV=1,$V=2,eH=(e,t)=>{if(!t.snapLines.length)return;let n=t.theme===P.LIGHT?YV:t.zenModeEnabled?ZV:XV,r=(t.zenModeEnabled?QV*1.5:QV)/t.zoom.value;e.save(),e.translate(t.scrollX,t.scrollY);for(let i of t.snapLines)i.type===`pointer`?(e.lineWidth=r,e.strokeStyle=n,nH(i,e,t)):i.type===`gap`?(e.lineWidth=r,e.strokeStyle=n,aH(i.points[0],i.points[1],i.direction,t,e)):i.type===`points`&&(e.lineWidth=r,e.strokeStyle=n,tH(i,e,t));e.restore()},tH=(e,t,n)=>{if(!n.zenModeEnabled){let n=e.points[0],r=e.points[e.points.length-1];iH(n,r,t)}for(let r of e.points)rH(r,n,t)},nH=(e,t,n)=>{rH(e.points[0],n,t),n.zenModeEnabled||iH(e.points[0],e.points[1],t)},rH=([e,t],n,r)=>{r.save();let i=(n.zenModeEnabled?$V*1.5:$V)/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()},iH=(e,t,n)=>{n.beginPath(),n.lineTo(e[0],e[1]),n.lineTo(t[0],t[1]),n.stroke()},aH=(e,t,n,r,i)=>{let a=8/r.zoom.value,o=a/2,s=a/4;if(n===`horizontal`){let n=[(e[0]+t[0])/2,e[1]];r.zenModeEnabled||iH(F(e[0],e[1]-a),F(e[0],e[1]+a),i),iH(F(n[0]-s,n[1]-o),F(n[0]-s,n[1]+o),i),iH(F(n[0]+s,n[1]-o),F(n[0]+s,n[1]+o),i),r.zenModeEnabled||(iH(F(t[0],t[1]-a),F(t[0],t[1]+a),i),iH(e,t,i))}else{let n=[e[0],(e[1]+t[1])/2];r.zenModeEnabled||iH(F(e[0]-a,e[1]),F(e[0]+a,e[1]),i),iH(F(n[0]-o,n[1]-s),F(n[0]+o,n[1]-s),i),iH(F(n[0]-o,n[1]+s),F(n[0]+o,n[1]+s),i),r.zenModeEnabled||(iH(F(t[0]-a,t[1]),F(t[0]+a,t[1]),i),iH(e,t,i))}},oH={[P.LIGHT]:`106, 189, 252`,[P.DARK]:`104, 182, 240`},sH={[P.LIGHT]:`rgba(65, 65, 65, 0.5)`,[P.DARK]:`rgba(237, 237, 237, 0.8)`},cH={[P.LIGHT]:{focus:`rgba(255, 124, 0, 0.4)`,match:`rgba(255, 226, 0, 0.4)`},[P.DARK]:{focus:`rgba(250, 123, 53, 0.4)`,match:`rgba(221, 181, 136, 0.4)`}},lH=(e,t)=>Zc(e,t===P.DARK),uH=(e,t)=>{eo(t.selectedLinearElement,`selectedLinearElement is null`);let{segmentMidPointHoveredCoords:n}=t.selectedLinearElement;eo(n,`midPointCoords is null`),fH(n,e,t)},dH=(e,t,n)=>{let{elementId:r,hoverPointIndex:i}=t.selectedLinearElement;if(t.selectedLinearElement?.isEditing&&t.selectedLinearElement?.selectedPointsIndices?.includes(i)||t.selectedLinearElement?.isDragging)return;let a=I.getElement(r,n);a&&fH(I.getPointAtIndexGlobalCoordinates(a,i,n),e,t)},fH=(e,t,n)=>{t.save(),t.translate(n.scrollX,n.scrollY),t.fillStyle=lH(`rgba(105, 101, 219, 0.4)`,n.theme),Ft(t,e[0],e[1],I.POINT_HANDLE_SIZE/n.zoom.value,!1),t.restore()},pH=(e,t,n)=>{let{elementId:r,anchor:i}=t.hoveredArrowTextAnchor,a=n.get(r);a&&ye(a)&&!a.isDeleted&&fH(i===`label`?I.getBoundTextElementCenter(a,n):I.getPointAtIndexGlobalCoordinates(a,i===`start`?0:-1,n),e,t)},mH=(e,t,n,r,i,a,o)=>{e.strokeStyle=lH(`#5e5ad8`,t.theme),e.setLineDash([]),e.fillStyle=lH(`rgba(255, 255, 255, 0.9)`,t.theme),i?e.fillStyle=lH(`rgba(134, 131, 226, 0.9)`,t.theme):a&&(e.fillStyle=lH(`rgba(177, 151, 252, 0.7)`,t.theme)),Ft(e,n[0],n[1],(o?r*(t.selectedLinearElement?.isEditing?1.5:2):r)/t.zoom.value,!a,!o||i)},hH=(e,t,n,r,i,a=!1)=>{let o=t.element.frameId&&n.get(t.element.frameId);switch(o&&R(o)&&(e.translate(o.x,o.y),e.beginPath(),sa.radius&&e.roundRect?e.roundRect(-1,-1,o.width+1,o.height+1,sa.radius/r.zoom.value):e.rect(-1,-1,o.width+1,o.height+1),e.clip(),e.translate(-o.x,-o.y)),t.element.type){case`magicframe`:case`frame`:e.save(),e.translate(t.element.x,t.element.y),e.lineWidth=sa.strokeWidth/r.zoom.value,e.strokeStyle=`rgba(${oH[r.theme]}, 1)`,sa.radius&&e.roundRect?(e.beginPath(),e.roundRect(0,0,t.element.width,t.element.height,sa.radius/r.zoom.value),e.stroke(),e.closePath()):e.strokeRect(0,0,t.element.width,t.element.height),e.restore();break;default:e.save();let i=hr(t.element,n);switch(e.translate(i[0],i[1]),e.rotate(t.element.angle),e.translate(-i[0],-i[1]),e.translate(t.element.x,t.element.y),e.lineWidth=fi(1.75,t.element.strokeWidth,4)/Math.max(.25,r.zoom.value),e.strokeStyle=`rgba(${oH[r.theme]}, 1)`,t.element.type){case`ellipse`:e.beginPath(),e.ellipse(t.element.width/2,t.element.height/2,t.element.width/2,t.element.height/2,0,0,2*Math.PI),e.closePath(),e.stroke();break;case`diamond`:{let[n,r]=pr(t.element);n.forEach(n=>{e.beginPath(),e.moveTo(n[0][0]-t.element.x,n[0][1]-t.element.y),e.lineTo(n[1][0]-t.element.x,n[1][1]-t.element.y),e.stroke()}),r.forEach(n=>{let[r,i,a,o]=n;e.beginPath(),e.moveTo(r[0]-t.element.x,r[1]-t.element.y),e.bezierCurveTo(i[0]-t.element.x,i[1]-t.element.y,a[0]-t.element.x,a[1]-t.element.y,o[0]-t.element.x,o[1]-t.element.y),e.stroke()})}break;default:{let[n,r]=ke(t.element);n.forEach(n=>{e.beginPath(),e.moveTo(n[0][0]-t.element.x,n[0][1]-t.element.y),e.lineTo(n[1][0]-t.element.x,n[1][1]-t.element.y),e.stroke()}),r.forEach(n=>{let[r,i,a,o]=n;e.beginPath(),e.moveTo(r[0]-t.element.x,r[1]-t.element.y),e.bezierCurveTo(i[0]-t.element.x,i[1]-t.element.y,a[0]-t.element.x,a[1]-t.element.y,o[0]-t.element.x,o[1]-t.element.y),e.stroke()})}}e.restore()}if(r.isMidpointSnappingEnabled&&!r.gridModeEnabled&&!a&&(R(t.element)||$i(t.element))){let a=r.selectedLinearElement,o=a?.elementId&&I.getElement(a?.elementId,n),s=i&&rs({point:i,element:t.element,elementsMap:n,threshold:0,overrideShouldTestInside:!0}),c=o&&Br(o)||r.activeTool.type===`arrow`&&r.currentItemArrowType===`elbow`;if(!s||c){e.save();let a=hr(t.element,n),o;if(t.element.type===`diamond`){let e=hr(t.element,n);o=qa(t.element).map(n=>{let r=Yt(n,.5),i=rl(r,e,t.element.angle);return F(i[0],i[1])})}else o=[{x:t.element.width,y:t.element.height/2},{x:t.element.width/2,y:t.element.height},{x:0,y:t.element.height/2},{x:t.element.width/2,y:0}].map(e=>{let n=F(e.x+t.element.x,e.y+t.element.y),r=rl(n,a,t.element.angle);return F(r[0],r[1])});let l=i&&o.reduce((e,t,n)=>{let r=zt(t,i);return n===-1||r<e.distance?{idx:n,distance:r}:e},{idx:-1,distance:1/0}),u=4/r.zoom.value,d=kn(r.zoom)+t.element.strokeWidth/2;o.forEach((t,n)=>{let i=(!s||c)&&l?.idx===n&&l.distance<=d,a=!i&&(c||n===l?.idx&&l.distance<=d*2);i?(e.fillStyle=`rgba(${oH[r.theme]}, 1)`,e.beginPath(),e.arc(t[0],t[1],u,0,2*Math.PI),e.fill()):a&&(e.fillStyle=sH[r.theme],e.beginPath(),e.arc(t[0],t[1],u,0,2*Math.PI),e.fill())}),e.restore()}}},gH=(e,t,n,r,i,a,o)=>{let s=e.state.bindMode===`orbit`&&e.bindModeHandler!==null,c=700-(o?.runtime??(s?0:700)),l=fi(1/700*c,1e-4,1),u=n.strokeWidth/2,d=n.frameId&&r.get(n.frameId);switch(d&&R(d)&&(t.translate(d.x,d.y),t.beginPath(),sa.radius&&t.roundRect?t.roundRect(-1,-1,d.width+1,d.height+1,sa.radius/i.zoom.value):t.rect(-1,-1,d.width+1,d.height+1),t.clip(),t.translate(-d.x,-d.y)),n.type){case`magicframe`:case`frame`:t.save(),t.translate(n.x,n.y),t.lineWidth=sa.strokeWidth/i.zoom.value,t.strokeStyle=`rgba(${oH[i.theme]}, ${l})`,sa.radius&&t.roundRect?(t.beginPath(),t.roundRect(0,0,n.width,n.height,sa.radius/i.zoom.value),t.stroke(),t.closePath()):t.strokeRect(0,0,n.width,n.height),t.restore();break;default:t.save();let e=hr(n,r),a=e[0]+i.scrollX,o=e[1]+i.scrollY;switch(t.translate(a,o),t.rotate(n.angle),t.translate(-a,-o),t.translate(n.x+i.scrollX-u,n.y+i.scrollY-u),t.lineWidth=fi(2.5,n.strokeWidth*1.75,4)/Math.max(.25,i.zoom.value),t.strokeStyle=`rgba(${oH[i.theme]}, ${l/2})`,n.type){case`ellipse`:t.beginPath(),t.ellipse((n.width+u*2)/2,(n.height+u*2)/2,(n.width+u*2)/2,(n.height+u*2)/2,0,0,2*Math.PI),t.closePath(),t.stroke();break;case`diamond`:{let[e,r]=pr(n,u);e.forEach(e=>{t.beginPath(),t.moveTo(e[0][0]-n.x+u,e[0][1]-n.y+u),t.lineTo(e[1][0]-n.x+u,e[1][1]-n.y+u),t.stroke()}),r.forEach(e=>{let[r,i,a,o]=e;t.beginPath(),t.moveTo(r[0]-n.x+u,r[1]-n.y+u),t.bezierCurveTo(i[0]-n.x+u,i[1]-n.y+u,a[0]-n.x+u,a[1]-n.y+u,o[0]-n.x+u,o[1]-n.y+u),t.stroke()})}break;default:{let[e,r]=ke(n,u);e.forEach(e=>{t.beginPath(),t.moveTo(e[0][0]-n.x+u,e[0][1]-n.y+u),t.lineTo(e[1][0]-n.x+u,e[1][1]-n.y+u),t.stroke()}),r.forEach(e=>{let[r,i,a,o]=e;t.beginPath(),t.moveTo(r[0]-n.x+u,r[1]-n.y+u),t.bezierCurveTo(i[0]-n.x+u,i[1]-n.y+u,a[0]-n.x+u,a[1]-n.y+u,o[0]-n.x+u,o[1]-n.y+u),t.stroke()})}}t.restore()}if(!s||(o?.runtime??0)>700)return;let f=.5*(Math.min(n.width,n.height)/2);if(!R(n)){t.save(),t.translate(n.x+i.scrollX,n.y+i.scrollY);let a=1/700*c;if(t.strokeStyle=lH(`rgba(0, 0, 0, 0.2)`,i.theme),t.lineWidth=1/i.zoom.value,t.setLineDash([4/i.zoom.value,4/i.zoom.value]),t.lineDashOffset=-a*10/i.zoom.value,t.beginPath(),t.ellipse(n.width/2,n.height/2,f,f,0,0,2*Math.PI),t.stroke(),t.fillStyle=lH(`rgba(0, 0, 0, 0.04)`,i.theme),t.beginPath(),t.ellipse(n.width/2,n.height/2,f*(1-l),f*(1-l),0,0,2*Math.PI),t.fill(),t.restore(),i.isMidpointSnappingEnabled&&!i.gridModeEnabled&&(!e.lastPointerMoveEvent||!br(e.lastPointerMoveEvent))){t.save(),t.translate(n.x+i.scrollX,n.y+i.scrollY);let e=5/i.zoom.value,a=e+5/i.zoom.value,o;if(n.type===`diamond`){let[,e]=pr(n),t=hr(n,r);o=e.map(e=>{let r=Yt(e,.5),i=rl(r,t,n.angle);return{x:i[0]-n.x,y:i[1]-n.y}})}else{let e=hr(n,r);o=[{x:n.width/2,y:0},{x:n.width,y:n.height/2},{x:n.width/2,y:n.height},{x:0,y:n.height/2}].map(t=>{let r=F(t.x+n.x,t.y+n.y),i=rl(r,e,n.angle);return{x:i[0]-n.x,y:i[1]-n.y}})}o.forEach(e=>{t.clearRect(e.x-a,e.y-a,a*2,a*2)}),t.fillStyle=`rgba(${oH[i.theme]}, ${l})`,o.forEach(n=>{t.beginPath(),t.arc(n.x,n.y,e,0,2*Math.PI),t.fill()}),t.restore()}}return{runtime:(o?.runtime??0)+a}},_H=(e,t,n,r,i,a,o)=>{if(n!==null){if(me(`COMPLEX_BINDINGS`))return gH(e,t,n.element,r,i,a,o);t.save(),t.translate(i.scrollX,i.scrollY),hH(t,n,r,i,e.lastPointerMoveCoords?F(e.lastPointerMoveCoords.x,e.lastPointerMoveCoords.y):null,!!e.lastPointerMoveEvent&&br(e.lastPointerMoveEvent)),t.restore()}},vH=(e,t,n)=>{let{angle:r,x1:i,y1:a,x2:o,y2:s,selectionColors:c,cx:l,cy:u,dashed:d,activeEmbeddable:f}=n,p=o-i,m=s-a,h=(n.padding??4)/t.zoom.value,g=8/t.zoom.value,_=4/t.zoom.value;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=(f?4:1)/t.zoom.value;let v=c.length;for(let t=0;t<v;++t)e.strokeStyle=c[t],d&&e.setLineDash([g,_+(g+_)*(v-1)]),e.lineDashOffset=(g+_)*t,Nc(e,i-h,a-h,p+h*2,m+h*2,l,u,r);e.restore()},yH=(e,t,n,r)=>{let[i,a,o,s]=ji(n,r),c=o-i,l=s-a;e.strokeStyle=lH(`rgb(0,118,255)`,t.theme),e.lineWidth=sa.strokeWidth/t.zoom.value,e.save(),e.translate(t.scrollX,t.scrollY),Nc(e,i,a,c,l,i+c/2,a+l/2,n.angle,!1,sa.radius/t.zoom.value),e.restore()},bH=(e,t,n,r)=>{let{colors:i=[lH(`rgb(0,118,255)`,t.theme)],dashed:a=!1}=r||{},o=n.filter(e=>e.groupIds.length===0),s=n.filter(e=>e.groupIds.length>0),c=e=>{let[t,n,r,o]=Wr(e);return{angle:0,x1:t,x2:r,y1:n,y2:o,selectionColors:i,dashed:a,cx:t+(r-t)/2,cy:n+(o-n)/2,activeEmbeddable:!1}},l=e=>{let t=Er(n,e);return c(t)};Object.entries(gn(s,t)).filter(([e,t])=>t).map(([e,t])=>e).map(e=>l(e)).concat(o.map(e=>c([e]))).forEach(n=>vH(e,t,n))},xH=(e,t,n,r)=>{if(!t.selectedLinearElement)return;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=1/t.zoom.value;let i=I.getPointsGlobalCoordinates(n,r),{POINT_HANDLE_SIZE:a}=I,o=t.selectedLinearElement?.isEditing?a:a/2,s=Br(n),c=oa(n);if(i.forEach((r,a)=>{if(s&&a!==0&&a!==i.length-1)return;let l=a>0&&(a!==i.length-1||!c||!n.polygon)&&bo(r,a===i.length-1?i[0]:i[a-1],2/t.zoom.value),u=!!t.selectedLinearElement?.isEditing&&!!t.selectedLinearElement?.selectedPointsIndices?.includes(a);c&&n.polygon&&!u&&a===n.points.length-1&&t.selectedLinearElement?.isEditing&&t.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(u=!0),mH(e,t,r,o,u,!1,l)}),Br(n)){let o=n.fixedSegments?.map(e=>e.index)||[];i.slice(0,-1).forEach((s,c)=>{I.isSegmentTooShort(n,i[c+1],i[c],c,t.zoom,r)||mH(e,t,F((s[0]+i[c+1][0])/2,(s[1]+i[c+1][1])/2),a/2,!1,!o.includes(c+1),!1)})}else I.getEditorMidPoints(n,r,t).filter((e,t,r)=>e!==null&&(!Br(n)||t!==0&&t!==r.length-1)).forEach(n=>{(t.selectedLinearElement?.isEditing||i.length===2)&&mH(e,t,n,a/2,!1,!0,!1)});e.restore()},SH=(e,t,n,r)=>{e.save(),e.translate(t.scrollX,t.scrollY),e.strokeStyle=lH(`rgba(134, 131, 226, 0.6)`,t.theme),e.lineWidth=1/t.zoom.value,e.setLineDash([4/t.zoom.value,4/t.zoom.value]),e.beginPath(),e.moveTo(n[0],n[1]),e.lineTo(r[0],r[1]),e.stroke(),e.restore()},CH=(e,t,n,r,i)=>{e.save(),e.translate(t.scrollX,t.scrollY),e.strokeStyle=lH(`rgba(134, 131, 226, 0.6)`,t.theme),e.lineWidth=1/t.zoom.value,e.setLineDash([]),e.fillStyle=lH(i?`rgba(134, 131, 226, 0.9)`:`rgba(255, 255, 255, 0.9)`,t.theme),Ft(e,n[0],n[1],r/t.zoom.value,!0,!0),e.restore()},wH=({arrow:e,appState:t,type:n,context:r,elementsMap:i})=>{let a=n===`start`?e.startBinding:e.endBinding,o=a?.elementId&&i.get(a.elementId);if(!o||!$i(o)||o.isDeleted)return;let s=Ns(a.fixedPoint,o,i);if(!Ua(s,e,o,i,t,n))return;let c=t.selectedLinearElement,l=!!c?.isDragging,u=n===`start`?0:e.points.length-1,d=!!c?.selectedPointsIndices?.includes(u);if(c?.hoveredFocusPointBinding===n&&!c.draggedFocusPointBinding&&fH(s,r,t),!(d&&l)){let s=Ns(a.fixedPoint,o,i),l=c?.hoveredFocusPointBinding===n;SH(r,t,I.getPointAtIndexGlobalCoordinates(e,u,i),s),CH(r,t,s,gc/1.5,l)}},TH=(e,t,n,r,i)=>{Object.keys(r).forEach(a=>{let o=r[a];if(o!==void 0){let[r,s,c,l]=o;e.save(),e.lineWidth=1/n.zoom.value,t.selectionColor&&(e.strokeStyle=t.selectionColor),a===`rotation`?Ft(e,r+c/2,s+l/2,c/2,!0):e.roundRect?(e.beginPath(),e.roundRect(r,s,c,l,2/n.zoom.value),e.fill(),e.stroke()):Nc(e,r,s,c,l,r+c/2,s+l/2,i,!0),e.restore()}})},EH=(e,t,n,r,i)=>{let[a,o,,,s,c]=ji(r,i),l=3/n.zoom.value,u=l/2,d=s-a+l,f=c-o+l,p=Math.min(20/n.zoom.value,d),m=Math.min(20/n.zoom.value,f);e.save(),e.fillStyle=t.selectionColor,e.strokeStyle=t.selectionColor,e.lineWidth=l,[[[-d,-f],[0,u],[p,u],[u,0],[u,m]],[[d-u,-f],[u,u],[-p+u,u],[0,0],[0,m]],[[-d,f],[0,-u],[p,-u],[u,0],[u,-m]],[[d-u,f],[u,-u],[-p+u,-u],[0,0],[0,-m]]].forEach(t=>{let[[n,i],[a,o],[l,u],[d,f],[p,m]]=t;e.save(),e.translate(s,c),e.rotate(r.angle),e.beginPath(),e.moveTo(n+a,i+o),e.lineTo(n+l,i+u),e.stroke(),e.beginPath(),e.moveTo(n+d,i+f),e.lineTo(n+p,i+m),e.stroke(),e.restore()}),e.restore()},DH=(e,t,n,r)=>{t.save();let i=GP(n.zoom.value),a=e.width+i*2,o=e.height+i*2,s=e.x+e.width/2,c=e.y+e.height/2,l=-(e.width/2+i),u=-(e.height/2+i);t.translate(s+n.scrollX,c+n.scrollY),t.rotate(e.angle),t.lineWidth=1/n.zoom.value,t.strokeStyle=r,t.globalAlpha=.5,t.setLineDash([6/n.zoom.value,4/n.zoom.value]),t.strokeRect(l,u,a,o),t.restore()},OH=(e,t,n,r,i)=>{let a=KP(e,n.zoom.value,i);a&&(t.save(),t.globalAlpha=.5,t.lineWidth=1.5/n.zoom.value,t.lineCap=`round`,t.strokeStyle=r,t.beginPath(),t.moveTo(a.start[0]+n.scrollX,a.start[1]+n.scrollY),t.lineTo(a.end[0]+n.scrollX,a.end[1]+n.scrollY),t.stroke(),t.restore())},kH=({app:e,canvas:t,elementsMap:n,visibleElements:r,selectedElements:i,allElementsMap:a,scale:o,appState:s,renderConfig:c,editorInterface:l,animationState:u,deltaTime:f})=>{if(t===null)return{};let p=Nr(s,o),[m,h]=ht(t,o),g=u,_=Oi({canvas:t,scale:o,normalizedWidth:m,normalizedHeight:h});_.save(),_.scale(p.zoom.value,p.zoom.value);let v;if(r.forEach(e=>{p.selectedLinearElement?.isEditing&&p.selectedLinearElement.elementId===e.id&&e&&(v=e)}),v&&xH(_,p,v,n),p.selectionElement&&!p.isCropping)try{Kt(p.selectionElement,_,p,c.selectionColor)}catch(e){console.error(e)}let y=ls(i,p);if(y&&!y.autoResize&&OH(y,_,p,c.selectionColor,l.formFactor),p.editingTextElement){let e=a.get(p.editingTextElement.id);e&&!e.autoResize&&DH(e,_,p,c.selectionColor)}if(g=p.isBindingEnabled&&p.suggestedBinding?{...u,bindingHighlight:_H(e,_,p.suggestedBinding,a,p,f,u?.bindingHighlight)}:{...u,bindingHighlight:void 0},p.hoveredArrowTextAnchor&&pH(_,p,a),p.frameToHighlight&&yH(_,p,p.frameToHighlight,n),p.elementsToHighlight&&bH(_,p,p.elementsToHighlight),p.activeLockedId){let e=a.get(p.activeLockedId);bH(_,p,e?[e]:Er(a,p.activeLockedId),{colors:[lH(`#ced4da`,p.theme)],dashed:!0})}let b=i.some(e=>R(e));i.length===1&&p.selectedLinearElement?.isEditing&&p.selectedLinearElement.elementId===i[0].id&&xH(_,p,i[0],n);let x=p.selectedLinearElement,S=x&&I.getElement(x.elementId,a);if(S&&(p.selectedLinearElement.isDragging||(x.segmentMidPointHoveredCoords?uH(_,p):(Br(S)?x.hoverPointIndex===0||x.hoverPointIndex===S.points.length-1:x.hoverPointIndex>=0)&&dH(_,p,n)),ye(S)&&(wH({arrow:S,elementsMap:a,appState:p,context:_,type:`start`}),wH({arrow:S,elementsMap:a,appState:p,context:_,type:`end`}))),!p.multiElement&&!p.newElement&&!p.selectedLinearElement?.isEditing){let e=Zo(i,p,l),t=i.length===1&&ro(i[0]);t&&p.selectedLinearElement?.elementId===i[0].id&&!i[0].locked&&xH(_,p,i[0],n);let r=c.selectionColor||lH(`#000`,p.theme),a=lH(`#ced4da`,p.theme),o=lH(`#000`,p.theme);if(e){let e=d(i),s=[];for(let i of n.values()){let o=[],l=c.remoteSelectedElementIds.get(i.id);if(t&&Br(i)&&(i.startBinding||i.endBinding)||(e.has(i.id)&&!As(p,i)&&o.push(r),l&&o.push(...l.map(e=>_O(e,p.collaborators.get(e))))),o.length){let[e,t,r,c,u,d]=ji(i,n,!0);s.push({angle:i.angle,x1:e,y1:t,x2:r,y2:c,selectionColors:i.locked?[a]:o,dashed:!!l||i.locked,cx:u,cy:d,activeEmbeddable:p.activeEmbeddable?.element===i&&p.activeEmbeddable.state===`active`,padding:i.id===p.croppingElementId||La(i)?0:void 0})}}let l=e=>{let t=Er(n,e),[r,i,c,l]=Wr(t);s.push({angle:0,x1:r,x2:c,y1:i,y2:l,selectionColors:t.some(e=>e.locked)?[a]:[o],dashed:!0,cx:r+(c-r)/2,cy:i+(l-i)/2,activeEmbeddable:!1})};for(let e of Is(p))l(e);p.editingGroupId&&l(p.editingGroupId),s.forEach(e=>vH(_,p,e))}if(_.save(),_.translate(p.scrollX,p.scrollY),i.length===1){_.fillStyle=lH(`#fff`,p.theme);let t=uc(i[0],p.zoom,n,`mouse`,Kc(l));if(!p.viewModeEnabled&&e&&!z(p.editingTextElement)&&!p.croppingElementId&&TH(_,c,p,t,i[0].angle),p.croppingElementId&&!p.isCropping){let e=n.get(p.croppingElementId);e&&La(e)&&EH(_,c,p,e,n)}}else if(i.length>1&&!p.isRotating&&!i.some(e=>e.locked)){let e=4/p.zoom.value;_.fillStyle=lH(`#fff`,p.theme);let[t,a,o,s]=Wr(i,n),u=_.getLineDash();_.setLineDash([2/p.zoom.value]);let d=_.lineWidth;_.lineWidth=1/p.zoom.value,_.strokeStyle=r,Nc(_,t-e,a-e,o-t+e*2,s-a+e*2,(t+o)/2,(a+s)/2,0),_.lineWidth=d,_.setLineDash(u);let f=Va([t,a,o,s,(t+o)/2,(a+s)/2],0,p.zoom,`mouse`,b?{...Kc(l),rotation:!0}:Kc(l));i.some(e=>!e.locked)&&TH(_,c,p,f,0)}_.restore()}p.searchMatches?.matches.forEach(({id:e,focus:t,matchedLines:r})=>{let i=n.get(e);if(i){let[e,a,,,o,s]=ji(i,n,!0);_.save(),_.fillStyle=cH[p.theme][t?`focus`:`match`];let c=R(i)?p.zoom.value:1;_.translate(p.scrollX,p.scrollY),_.translate(o,s),_.rotate(i.angle),r.forEach(n=>{(n.showOnCanvas||t)&&_.fillRect(e+n.offsetX/c-o,a+n.offsetY/c-s,n.width/c,n.height/c)}),_.restore()}}),eH(_,p),_.restore(),yO({context:_,renderConfig:c,appState:p,normalizedWidth:m,normalizedHeight:h});let C;return c.renderScrollbars&&(C=nF(n,m,h,p),_.save(),_.fillStyle=lH(tF,p.theme),_.strokeStyle=lH(`rgba(255,255,255,0.8)`,p.theme),[C.horizontal,C.vertical].forEach(e=>{e&&hO(_,e.x,e.y,e.width,e.height,eF/2)}),_.restore()),{scrollBars:C,animationState:g}},AH=e=>{let t=kH(e);return e.callback(t),t},jH=`animateInteractiveScene`,MH=e=>{let t=(0,H.useRef)(!1),n=(0,H.useRef)(null);return(0,H.useEffect)(()=>{if(!t.current){t.current=!0;return}let r=new Map,i=new Map,a=new Map,o=new Map,s=new Map;e.appState.collaborators.forEach((t,n)=>{if(t.selectedElementIds)for(let e of Object.keys(t.selectedElementIds))a.has(e)||a.set(e,[]),a.get(e).push(n);!t.pointer||t.pointer.renderCursor===!1||(t.username&&o.set(n,t.username),t.userState&&s.set(n,t.userState),i.set(n,lc({sceneX:t.pointer.x,sceneY:t.pointer.y},e.appState)),r.set(n,t.button))});let c=Fo(e.containerRef?.current);n.current={app:e.app,canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:i,remotePointerButton:r,remoteSelectedElementIds:a,remotePointerUsernames:o,remotePointerUserStates:s,selectionColor:c,renderScrollbars:e.renderScrollbars,lastViewportPosition:e.app.viewport.lastPosition},editorInterface:e.editorInterface,callback:e.renderInteractiveSceneCallback,animationState:{bindingHighlight:void 0},deltaTime:0},IP.running(jH)||IP.start(jH,({deltaTime:e,state:t})=>{let r=AH({...n.current,deltaTime:e,animationState:t}).animationState;if(r){for(let e in r)if(r[e]!==void 0)return r}})}),(0,W.jsx)(`canvas`,{className:`excalidraw__canvas interactive`,style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onClick:e.onClick,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.appState.viewModeEnabled?void 0:e.onDoubleClick,children:K(`labels.drawingCanvas`)})},NH=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,activeTool:e.activeTool,openDialog:e.openDialog,editingGroupId:e.editingGroupId,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,newElement:e.newElement,isBindingEnabled:e.isBindingEnabled,isMidpointSnappingEnabled:e.isMidpointSnappingEnabled,gridModeEnabled:e.gridModeEnabled,suggestedBinding:e.suggestedBinding,hoveredArrowTextAnchor:e.hoveredArrowTextAnchor,isRotating:e.isRotating,elementsToHighlight:e.elementsToHighlight,collaborators:e.collaborators,activeEmbeddable:e.activeEmbeddable,snapLines:e.snapLines,zenModeEnabled:e.zenModeEnabled,editingTextElement:e.editingTextElement,isCropping:e.isCropping,croppingElementId:e.croppingElementId,searchMatches:e.searchMatches,activeLockedId:e.activeLockedId,hoveredElementIds:e.hoveredElementIds,frameRendering:e.frameRendering,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,exportScale:e.exportScale,currentItemArrowType:e.currentItemArrowType}),PH=H.memo(MH,(e,t)=>e.selectionNonce!==t.selectionNonce||e.canvasNonce!==t.canvasNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements||e.selectedElements!==t.selectedElements||e.renderScrollbars!==t.renderScrollbars||e.interactionEnabled!==t.interactionEnabled||e.navigationEnabled!==t.navigationEnabled?!1:Us(NH(e.appState),NH(t.appState))),FH=e=>{let t=(0,H.useRef)(null),n=(0,H.useRef)(!1);return(0,H.useEffect)(()=>{e.canvas.style.width=`${e.appState.width}px`,e.canvas.style.height=`${e.appState.height}px`,e.canvas.width=e.appState.width*e.scale,e.canvas.height=e.appState.height*e.scale},[e.appState.height,e.appState.width,e.canvas,e.scale]),(0,H.useEffect)(()=>{let r=t.current;if(!r)return;let i=e.canvas;n.current||(n.current=!0,r.replaceChildren(i),i.classList.add(`excalidraw__canvas`,`static`)),Be({canvas:i,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},PP())}),(0,W.jsx)(`div`,{className:`excalidraw__canvas-wrapper`,ref:t})},IH=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,openDialog:e.openDialog,hoveredElementIds:e.hoveredElementIds,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,viewBackgroundColor:e.viewBackgroundColor,exportScale:e.exportScale,selectedElementsAreBeingDragged:e.selectedElementsAreBeingDragged,gridSize:e.gridSize,gridStep:e.gridStep,frameRendering:e.frameRendering,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,editingGroupId:e.editingGroupId,currentHoveredFontFamily:e.currentHoveredFontFamily,croppingElementId:e.croppingElementId,suggestedBinding:e.suggestedBinding}),LH=H.memo(FH,(e,t)=>e.canvasNonce!==t.canvasNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements?!1:Us(IH(e.appState),IH(t.appState))&&Us(e.renderConfig,t.renderConfig)),RH=({canvas:e,rc:t,newElement:n,elementsMap:r,allElementsMap:i,scale:a,appState:o,renderConfig:s})=>{if(e){let c=Nr(o,a),[l,u]=ht(e,a),d=Oi({canvas:e,scale:a,normalizedWidth:l,normalizedHeight:u});if(d.save(),d.scale(c.zoom.value,c.zoom.value),n&&n.type!==`selection`){if(Dc(n))return;if((n.frameId||c.frameToHighlight?.id)&&c.frameRendering.enabled&&c.frameRendering.clip){let e=$n(n,r,c);e&&xe(n,e,c,r)&&mr(e,d,s,c)}Ks(n,r,i,t,d,s,c)}else d.clearRect(0,0,l,u);d.restore()}},zH=bi(e=>{RH(e)}),BH=(e,t)=>{if(t){zH(e);return}RH(e)},VH=e=>{let t=(0,H.useRef)(null);return(0,H.useEffect)(()=>{t.current&&BH({canvas:t.current,scale:e.scale,newElement:e.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},PP())}),(0,W.jsx)(`canvas`,{className:`excalidraw__canvas`,style:{width:e.appState.width,height:e.appState.height,opacity:e.opacity},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:t})},HH=700,UH=100,WH=16,GH=3e5,KH=yl(null),qH=e=>e===Nt.elbow?pw:e===Nt.round?mw:fw,JH=class{constructor(e){V(this,`app`),V(this,`lastShownAt`,0),V(this,`show`,e=>{let{x:t,y:n}=this.app.viewport.lastPosition;t===0&&n===0||(this.lastShownAt=Date.now(),this.app.updateEditorAtom(KH,{content:e,nonce:Math.random()}))}),V(this,`isOnCooldown`,()=>Date.now()-this.lastShownAt<GH),V(this,`onArrowTypeCycled`,e=>{this.show(qH(e))}),V(this,`onToolShortcut`,(e,t)=>{(t===`digit`||!this.isOnCooldown())&&this.show(e===`line`?Ex:qH(this.app.state.currentItemArrowType))}),this.app=e}},YH=()=>{let[e,t]=Vb(KH),n=uU(),{container:r}=mU(),i=(0,H.useRef)(null),[a,o]=(0,H.useState)(!1),s=e?.nonce;return(0,H.useLayoutEffect)(()=>{if(s==null||!r)return;let e=(e,t)=>{let n=i.current;if(!n)return;let{left:a,top:o}=Zw({cursor:{x:e,y:t},element:{width:n.offsetWidth,height:n.offsetHeight},container:r.getBoundingClientRect(),gap:WH});n.style.transform=`translate(${a}px, ${o}px)`};e(n.viewport.lastPosition.x,n.viewport.lastPosition.y);let t=t=>{e(t.clientX,t.clientY)};return window.addEventListener(B.POINTER_MOVE,t),()=>{window.removeEventListener(B.POINTER_MOVE,t)}},[s,r,n]),(0,H.useEffect)(()=>()=>{t(null)},[t]),(0,H.useEffect)(()=>{if(s==null)return;o(!1);let e=window.setTimeout(()=>{o(!0)},HH),n=window.setTimeout(()=>{t(null)},HH+UH),r=()=>{t(null)};return window.addEventListener(B.POINTER_DOWN,r,{capture:!0}),()=>{window.clearTimeout(e),window.clearTimeout(n),window.removeEventListener(B.POINTER_DOWN,r,{capture:!0})}},[s,t]),e?(0,W.jsx)(`div`,{ref:i,className:U(`CursorHint`,{"CursorHint--fade-out":a}),"data-testid":`cursor-hint`,children:e.content}):null},XH=class{constructor(e){this.getState=e,V(this,`listeners`,[]),V(this,`onStateChange`,(e,t,n)=>{let{predicate:r,getValue:i,callback:a,once:o,matchesImmediately:s}=this.normalize(e,t,n);return a?s&&(queueMicrotask(()=>{let e=this.getState();a(i(e),e)}),o)?()=>{}:this.subscribe({predicate:r,getValue:i,callback:a,once:o}):s?Promise.resolve(i(this.getState())):new Promise(e=>{this.subscribe({predicate:r,getValue:i,callback:t=>e(t),once:!0})})})}isStateChangePredicateOptions(e){return typeof e==`object`&&!Array.isArray(e)&&`predicate`in e}subscribe(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(t=>t!==e)}}normalize(e,t,n){let r,i,a=t,o=n?.once??!1,s=!1;if(this.isStateChangePredicateOptions(e)){let{predicate:t,callback:n,once:c}=e;r=t,i=e=>e,a=n?(e,t)=>n(t):void 0,o=c??!1,s=t(this.getState())}else if(typeof e==`function`){let t=e;r=(e,n)=>t(e)!==t(n),i=e=>t(e)}else if(Array.isArray(e)){let t=e;r=(e,n)=>t.some(t=>e[t]!==n[t]),i=e=>e}else{let t=e;r=(e,n)=>e[t]!==n[t],i=e=>e[t]}return{predicate:r,getValue:i,callback:a,once:o,matchesImmediately:s}}flush(e){if(!this.listeners.length)return;let t=this.getState(),n=[];for(let r of this.listeners)r.predicate(t,e)?(r.callback(r.getValue(t),t),r.once||n.push(r)):n.push(r);this.listeners=n}clear(){this.listeners=[]}},ZH=({app:e,activeLockedId:t})=>{let n=e.scene.getElement(t);n&&!ea(n)&&console.error(`[NONDELETED][INVARIANT] UnlockPopup: activeLockedId points to a deleted element`);let r=n&&ea(n)?n:null,i=r?[r]:Er(e.scene.getNonDeletedElementsMap(),t);if(i.length===0)return null;let[a,o]=Wr(i),{x:s,y:c}=lc({sceneX:a,sceneY:o},e.state);return(0,W.jsx)(`div`,{className:`UnlockPopup`,style:{bottom:`${e.state.height+12-c+e.state.offsetTop}px`,left:`${s-e.state.offsetLeft}px`},onClick:()=>{(0,hl.flushSync)(()=>{let t=gn(i,e.state);e.setState({selectedElementIds:i.reduce((e,t)=>({...e,[t.id]:!0}),{}),selectedGroupIds:t,activeLockedId:null})}),e.actionManager.executeAction(uk)},title:K(`labels.elementLock.unlock`),children:gx})},QH=H.createContext(null),$H=H.createContext(null),eU={formFactor:`desktop`,desktopUIMode:`full`,userAgent:un(typeof navigator<`u`?navigator.userAgent:``),isTouchScreen:!1,canFitSidebar:!1,isLandscape:!0},tU=H.createContext(eU);tU.displayName=`EditorInterfaceContext`;var nU={"editor:mount":{cardinality:`once`,replay:`last`},"editor:initialize":{cardinality:`once`,replay:`last`},"editor:unmount":{cardinality:`once`,replay:`last`}},rU=H.createContext({container:null,id:null});rU.displayName=`ExcalidrawContainerContext`;var iU=H.createContext([]);iU.displayName=`ExcalidrawElementsContext`;var aU=H.createContext({...Gt(),width:0,height:0,offsetLeft:0,offsetTop:0});aU.displayName=`ExcalidrawAppStateContext`;var oU=H.createContext(()=>{console.warn(`Uninitialized ExcalidrawSetAppStateContext context!`)});oU.displayName=`ExcalidrawSetAppStateContext`;var sU=H.createContext(null);sU.displayName=`ExcalidrawActionManagerContext`;var cU=H.createContext(null);cU.displayName=`ExcalidrawAPIContext`;var lU=H.createContext(null);lU.displayName=`ExcalidrawAPISetContext`;var uU=()=>(0,H.useContext)(QH),dU=()=>(0,H.useContext)($H),fU=()=>(0,H.useContext)(tU),pU=()=>Ea(fU()),mU=()=>(0,H.useContext)(rU),hU=()=>(0,H.useContext)(iU),gU=()=>(0,H.useContext)(aU),_U=()=>(0,H.useContext)(oU),vU=()=>(0,H.useContext)(sU),yU=()=>(0,H.useContext)(cU),bU=!1,xU=0,SU=null,CU=!1,wU={horizontal:null,vertical:null},TU=0,EU=!1,DU=new Map,OU=4,kU=!1,AU=0,jU=!1,MU=null,NU={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},PU=class e extends H.Component{constructor(t){super(t),V(this,`canvas`),V(this,`interactiveCanvas`,null),V(this,`sessionExportThemeOverride`),V(this,`rc`),V(this,`unmounted`,!1),V(this,`actionManager`),V(this,`editorInterface`,eU),V(this,`stylesPanelMode`,Ea(eU)),V(this,`excalidrawContainerRef`,H.createRef()),V(this,`scene`),V(this,`fonts`),V(this,`renderer`),V(this,`visibleElements`),V(this,`hasRenderableElements`,!1),V(this,`resizeObserver`),V(this,`library`),V(this,`libraryItemsFromStorage`),V(this,`id`),V(this,`store`),V(this,`history`),V(this,`excalidrawContainerValue`),V(this,`files`,{}),V(this,`imageCache`,new Map),V(this,`iFrameRefs`,new Map),V(this,`embedsValidationStatus`,new Map),V(this,`initializedEmbeds`,new Set),V(this,`elementsPendingErasure`,new Set),V(this,`_initialized`,!1),V(this,`editorLifecycleEvents`,new Oc(nU)),V(this,`onEvent`,this.editorLifecycleEvents.on.bind(this.editorLifecycleEvents)),V(this,`appStateObserver`,new XH(()=>this.state)),V(this,`onStateChange`,this.appStateObserver.onStateChange),V(this,`bucketFill`,new OI(this)),V(this,`toolDrag`,new MI(this)),V(this,`flowchart`,new HI(this)),V(this,`cursor`,new zI(this)),V(this,`arrowText`,new EI(this)),V(this,`pan`,new WI(this,{getPointerCount:()=>NU.pointers.size})),V(this,`viewport`,new cL(this,{getContainer:()=>this.excalidrawContainerRef.current,getStylesPanelMode:()=>this.stylesPanelMode,isGestureActive:()=>NU.pointers.size>=2||this.pan.isActive()})),V(this,`wheel`,new uL(this)),V(this,`bindModeHandler`,null),V(this,`textWysiwygSubmitHandler`,null),V(this,`hitLinkElement`),V(this,`lastPointerDownEvent`,null),V(this,`activeResizeHandle`,null),V(this,`lastPointerUpEvent`,null),V(this,`lastPointerUpIsDoubleClick`,!1),V(this,`lastPointerMoveEvent`,null),V(this,`lastPointerMoveCoords`,null),V(this,`lastCompletedCanvasClicks`,[]),V(this,`previousPointerMoveCoords`,null),V(this,`drawShape`,new VI(this)),V(this,`laserTrails`,new zP(this)),V(this,`eraserTrail`,new gF(this)),V(this,`lassoTrail`,new hF(this)),V(this,`cursorHints`,new JH(this)),V(this,`onChangeEmitter`,new dt),V(this,`onPointerDownEmitter`,new dt),V(this,`onPointerUpEmitter`,new dt),V(this,`onUserFollowEmitter`,new dt),V(this,`onScrollChangeEmitter`,new dt),V(this,`missingPointerEventCleanupEmitter`,new dt),V(this,`onRemoveEventListenersEmitter`,new dt),V(this,`api`),V(this,`elementRenderOverrides`,new Map),V(this,`elementRenderOffsets`,new Map),V(this,`renderOverridesUpdatePending`,!1),V(this,`getRenderOverrideConfig`,()=>({elementRenderOverrides:this.elementRenderOverrides})),V(this,`getElementRenderState`,(e,t=this.elementRenderOverrides)=>ar(e,this.scene.getNonDeletedElementsMap(),{elementRenderOverrides:t??void 0,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null})),V(this,`isToolSupported`,(e,t=this.props)=>{if(t.UIOptions.tools?.[e]===!1)return!1;if(this.isInteractionEnabled(t))return!0;let n=typeof t.interaction==`object`&&t.interaction!==null?t.interaction.enabled?.tools:void 0;return e===`laser`?n?.laser===!0:e===`custom`&&n?.custom===!0}),V(this,`updateEditorAtom`,(e,...t)=>{let n=Kb.set(e,...t);return this.triggerRender(),n}),V(this,`onWindowMessage`,e=>{if(e.origin!==`https://player.vimeo.com`&&e.origin!==`https://www.youtube.com`)return;let t=null;try{t=JSON.parse(e.data)}catch{}if(t)switch(e.origin){case`https://player.vimeo.com`:if(t.method===`paused`){let n=null,r=this.ownerDocument.body.querySelectorAll(`iframe.excalidraw__embeddable`);if(!r)break;for(let t of r)t.contentWindow===e.source&&(n=t.contentWindow);n?.postMessage(JSON.stringify({method:t.value?`play`:`pause`,value:!0}),`*`)}break;case`https://www.youtube.com`:if(t.event===`infoDelivery`&&t.info&&t.id&&typeof t.info.playerState==`number`){let e=t.id,n=t.info.playerState;Object.values(or).includes(n)&&DU.set(e,n)}}}),V(this,`previousHoveredBindableElement`,null),V(this,`getEffectiveGridSize`,()=>lP(this)?this.state.gridSize:null),V(this,`getTextCreationGridPoint`,(e,t)=>{let n=this.getEffectiveGridSize();if(n===null)return null;let r=e=>Math.floor(e/n)*n;return{x:r(e),y:r(t)}}),V(this,`handleIframeLikeElementHover`,({hitElement:e,scenePointer:t,moveEvent:n})=>e&&Qt(e)&&this.isIframeLikeInteractive(e)&&(this.state.viewModeEnabled||this.state.activeTool.type===`laser`||this.isIframeLikeElementCenter(e,n,t.x,t.y))?(this.cursor.set(jt.POINTER),this.setState({activeEmbeddable:{element:e,state:`hover`}}),!0):(this.state.activeEmbeddable?.state===`hover`&&this.setState({activeEmbeddable:null}),!1)),V(this,`isDoubleClick`,(e,t)=>e!=null&&t.timeStamp-e.timeStamp<=300),V(this,`updateEmbedValidationStatus`,(e,t)=>{this.embedsValidationStatus.set(e.id,t),Nn.delete(e)}),V(this,`updateEmbeddables`,()=>{let e=new Set,t=!1;this.scene.getNonDeletedElements().filter(n=>{if(Sn(n)){if(e.add(n.id),!this.embedsValidationStatus.has(n.id)){t=!0;let e=va(n.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(n,e)}}else Ar(n)&&e.add(n.id);return!1}),t&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((t,n)=>{e.has(n)||this.iFrameRefs.delete(n)})}),V(this,`getFrameNameDOMId`,e=>`${this.id}-frame-name-${e.id}`),V(this,`frameNameBoundsCache`,{get:e=>{let t=this.frameNameBoundsCache._cache.get(e.id);if(!t||t.zoom!==this.state.zoom.value||t.versionNonce!==e.versionNonce){let n=this.ownerDocument.getElementById(this.getFrameNameDOMId(e));if(n){let r=n.getBoundingClientRect(),i=this.state.zoom.value;return t={x:e.x,y:e.y-(r.height+sa.nameOffsetY)/i,width:r.width/i,height:r.height/i,zoom:i,versionNonce:e.versionNonce},this.frameNameBoundsCache._cache.set(e.id,t),t}return null}return t},_cache:new Map}),V(this,`resetEditingFrame`,e=>{e&&this.scene.mutateElement(e,{name:e.name?.trim()||null}),this.setState({editingFrame:null})}),V(this,`renderFrameNames`,()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let e=this.state.theme===P.DARK,t=this.scene.getNonDeletedFramesLikes(),n=t.length>0&&this.state.searchMatches?.focusedId&&R(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(e=>e.focus):null;return t.map(t=>{let r=this.getElementRenderState(t,t.id===this.state.editingFrame?null:this.elementRenderOverrides);if(!Uo(Hi(t,r.offset),this.canvas.width/this.ownerWindow.devicePixelRatio,this.canvas.height/this.ownerWindow.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 this.state.editingFrame===t.id&&this.resetEditingFrame(t),null;let{x:i,y:a}=lc({sceneX:t.x+r.offset.x,sceneY:t.y+r.offset.y},this.state),o,s=De(t);if(t.id===this.state.editingFrame){let n=s;o=(0,W.jsx)(`input`,{autoFocus:!0,value:n,onChange:e=>{this.scene.mutateElement(t,{name:e.target.value})},onFocus:e=>e.target.select(),onBlur:()=>this.resetEditingFrame(t),onKeyDown:e=>{(e.key===L.ESCAPE||e.key===L.ENTER)&&this.resetEditingFrame(t)},style:{background:Zc(this.state.viewBackgroundColor,e),zIndex:2,border:`none`,display:`block`,padding:`6px`,borderRadius:4,boxShadow:`inset 0 0 0 1px var(--color-primary)`,fontFamily:`Assistant`,fontSize:`${sa.nameFontSize}px`,transform:`translate(-6px, 6px)`,color:e?sa.nameColorDarkTheme:sa.nameColorLightTheme,overflow:`hidden`,maxWidth:`${this.ownerDocument.body.clientWidth-i-6}px`},size:n.length+1||1,dir:`auto`,autoComplete:`off`,autoCapitalize:`off`,autoCorrect:`off`})}else o=s;return(0,W.jsx)(`div`,{id:this.getFrameNameDOMId(t),className:Ai.FRAME_NAME,style:{position:`absolute`,opacity:r.opacity,bottom:`${this.state.height+sa.nameOffsetY-a+this.state.offsetTop}px`,left:`${i-this.state.offsetLeft}px`,zIndex:2,fontSize:sa.nameFontSize,color:e?sa.nameColorDarkTheme:sa.nameColorLightTheme,lineHeight:sa.nameLineHeight,width:`max-content`,maxWidth:n?.id===t.id&&n?.focus?`none`:`${t.width*this.state.zoom.value}px`,overflow:t.id===this.state.editingFrame?`visible`:`hidden`,whiteSpace:`nowrap`,textOverflow:`ellipsis`,cursor:jt.MOVE,pointerEvents:this.state.viewModeEnabled?aa.disabled:aa.enabled},onPointerDown:e=>this.handleCanvasPointerDown(e),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:t.id})},children:o},t.id)})}),V(this,`toggleOverscrollBehavior`,e=>{this.ownerDocument.documentElement.style.overscrollBehaviorX=e.type===`pointerenter`?`none`:`auto`}),V(this,`focusContainer`,()=>{this.excalidrawContainerRef.current?.focus()}),V(this,`getSceneElementsIncludingDeleted`,()=>this.scene.getElementsIncludingDeleted()),V(this,`getSceneElementsMapIncludingDeleted`,()=>this.scene.getElementsMapIncludingDeleted()),V(this,`getSceneElements`,()=>this.scene.getNonDeletedElements()),V(this,`onInsertElements`,e=>{this.addElementsFromPasteOrLibrary({elements:e,position:`center`,files:null})}),V(this,`onExportImage`,async(e,t,n)=>{Vw(`export`,e,`ui`);let r=await qD(e,t,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:n.exportingFrame}).catch(Vc).catch(e=>{console.error(e),this.setState({errorMessage:e.message})});this.state.exportEmbedScene&&r&&ir(r)&&this.setState({fileHandle:r})}),V(this,`magicGenerations`,new Map),V(this,`updateMagicGeneration`,({frameElement:e,data:t})=>{t.status===`pending`?this.scene.mutateElement(e,{customData:{generationData:void 0}},{informMutation:!1,isDragging:!1}):this.scene.mutateElement(e,{customData:{generationData:t}},{informMutation:!1,isDragging:!1}),this.magicGenerations.set(e.id,t),this.triggerRender()}),V(this,`plugins`,{}),V(this,`onMagicframeToolSelect`,()=>{let e=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(e.length===0)this.setActiveTool({type:A.magicframe}),Vw(`ai`,`tool-select (empty-selection)`,`d2c`);else{let t=e.length===1&&fc(e[0])&&e[0];if(!t&&e.some(e=>R(e)||e.frameId)){this.setActiveTool({type:A.magicframe});return}Vw(`ai`,`tool-select (existing selection)`,`d2c`);let n;if(t)n=t;else{let[t,r,i,a]=Wr(e);n=il({...sa,x:t-50,y:r-50,width:i-t+100,height:a-r+100,opacity:100,locked:!1}),this.insertNewElement(n);for(let t of e)this.scene.mutateElement(t,{frameId:n.id});this.setState({selectedElementIds:{[n.id]:!0}})}this.onMagicFrameGenerate(n,`upstream`)}}),V(this,`openEyeDropper`,({type:e})=>{this.updateEditorAtom(eT,{swapPreviewOnAlt:!0,colorPickerType:e===`stroke`?`elementStroke`:`elementBackground`,onSelect:(t,n)=>{let r=e===`background`&&n.altKey||e===`stroke`&&!n.altKey?`strokeColor`:`backgroundColor`;if(!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!==`selection`)this.syncActionResult({appState:{...this.state,...bE(yE(this.state,this.scene.getNonDeletedElements(),r),t)},captureUpdate:N.IMMEDIATELY});else{let e=this.scene.getNonDeletedElementsMap(),n=new Set(this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:r===`strokeColor`}).map(e=>e.id));this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(i=>n.has(i.id)?j(i,el(i,r,t,e)):i),captureUpdate:N.IMMEDIATELY})}},keepOpenOnAlt:!1})}),V(this,`dismissLinearEditor`,()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})}),V(this,`syncActionResult`,MP(e=>{if(this.unmounted||e===!1)return;this.store.scheduleAction(e.captureUpdate);let t=!1,n=null;if(e.elements&&(this.scene.replaceAllElements(e.elements),t=!0),e.files&&(this.addMissingFiles(e.files,e.replaceFiles),this.addNewImagesToImageCache()),e.appState||n||this.state.contextMenu){let r=e?.appState?.viewModeEnabled||!1,i=e?.appState?.zenModeEnabled||!1,a=e?.appState?.theme||this.props.theme||P.LIGHT,o=e?.appState?.name??this.state.name,s=e?.appState?.errorMessage??this.state.errorMessage;if(typeof this.props.viewModeEnabled<`u`&&(r=this.props.viewModeEnabled),this.isInteractionEnabled()||(r=!0),typeof this.props.zenModeEnabled<`u`&&(i=this.props.zenModeEnabled),n=e.appState?.editingTextElement||null,e.elements&&n){let t=n.id,r=e.elements.find(e=>e.id===t);n=r&&ea(r)&&z(r)?r:null}this.setState(t=>{let c=e.appState||{};return{...t,...c,contextMenu:null,editingTextElement:n,viewModeEnabled:r,zenModeEnabled:i,theme:a,name:o,errorMessage:s}}),t=!0}t||this.scene.triggerUpdate()})),V(this,`scheduleCapture`,()=>this.store.scheduleCapture()),V(this,`onBlur`,MP(()=>{this.pan.setSpaceHeld(!1),this.setState({isBindingEnabled:this.state.bindingPreference===`enabled`})})),V(this,`onUnload`,()=>{this.onBlur()}),V(this,`disableEvent`,e=>{e.preventDefault()}),V(this,`handleNavigationModeKeyDown`,e=>{if(this.maybeHandlePageScrollKeyDown(e)){e.preventDefault();return}this.actionManager.handleKeyDown(e)}),V(this,`maybeHandlePageScrollKeyDown`,e=>{if(e.key!==L.PAGE_UP&&e.key!==L.PAGE_DOWN)return!1;let t=(e.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;return e.key===L.PAGE_DOWN&&(t=-t),e.shiftKey?this.viewport.translate(e=>({scrollX:e.scrollX+t})):this.viewport.translate(e=>({scrollY:e.scrollY+t})),!0}),V(this,`preventBrowserZoomKeyDown`,e=>{e[L.CTRL_OR_CMD]&&(e.code===xt.EQUAL||e.code===xt.MINUS||e.code===xt.ZERO||e.code===xt.NUM_ADD||e.code===xt.NUM_SUBTRACT||e.code===xt.NUM_ZERO)&&e.preventDefault()}),V(this,`terminateActiveInteraction`,()=>{if(this.maybeCleanupAfterMissingPointerUp(null),this.pan.setSpaceHeld(!1),CU=!1,MU=null,NU.pointers.clear(),NU.lastCenter=null,NU.initialDistance=null,NU.initialScale=null,clearTimeout(xU),xU=0,e.resetTapTwice(),this.resetContextMenuTimer(),clearTimeout(AU),AU=0,kU=!1,this.bindModeHandler&&=(clearTimeout(this.bindModeHandler),null),this.flowchart.clear(),Kb.set(eT,null),Kb.set(bk,null),this.state.editingFrame){let e=this.scene.getNonDeletedElement(this.state.editingFrame);this.resetEditingFrame(e&&R(e)?e:null)}queueMicrotask(()=>{(!this.isInteractionEnabled()||this.state.viewModeEnabled)&&this.textWysiwygSubmitHandler?.()}),this.setState({contextMenu:null,openMenu:null,openPopup:null,cursorButton:`up`,bindMode:`orbit`,activeEmbeddable:null,activeLockedId:null,selectedElementsAreBeingDragged:!1,selectionElement:null,resizingElement:null,isResizing:!1,isRotating:!1,isCropping:!1,croppingElementId:null,suggestedBinding:null,frameToHighlight:null,elementsToHighlight:null,snapLines:[],showHyperlinkPopup:!1}),this.deselectElements(),this.isInteractionEnabled()||(this.setState({originSnapOffset:null}),this.cursor.reset())}),V(this,`handleInteractionStateChange`,(e,t)=>{let n=this.isInteractionEnabled(e),r=n!==this.isInteractionEnabled(),i=e.viewModeEnabled!==this.props.viewModeEnabled,a=this.state.viewModeEnabled;this.isInteractionEnabled()?(i||r)&&(a=!!this.props.viewModeEnabled):a=!0,a!==this.state.viewModeEnabled&&this.setState({viewModeEnabled:a});let o=n&&!t.viewModeEnabled,s=this.isInteractionEnabled()&&!this.state.viewModeEnabled;(r&&!this.isInteractionEnabled()||o&&!s)&&this.terminateActiveInteraction(),r&&this.addEventListeners(),this.isLinksEnabled(e)!==this.isLinksEnabled()&&(this.isLinksEnabled()||(this.hitLinkElement=void 0,ok(),this.cursor.reset())),this.isEmbedsEnabled(e)!==this.isEmbedsEnabled()&&(this.isEmbedsEnabled()||this.setState({activeEmbeddable:null})),this.isToolSupported(t.activeTool.type,e)!==this.isToolSupported(this.state.activeTool.type)&&(this.isToolSupported(this.state.activeTool.type)||this.laserTrails.endPath(),this.cursor.reset()),!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)&&this.state.activeTool.type!==`selection`&&this.setState({activeTool:ae(this.state,{type:`selection`})}),(this.isBrowserZoomEnabled(e)!==this.isBrowserZoomEnabled()||this.isNavigationEnabled(e)!==this.isNavigationEnabled())&&(this.addEventListeners(),this.cursor.reset()),t.viewModeEnabled!==this.state.viewModeEnabled&&(this.isInteractionEnabled()&&this.addEventListeners(),this.state.viewModeEnabled||this.deselectElements(),this.cursor.reset())}),V(this,`isSameForcedTool`,(e,t)=>e?.type===t?.type&&(e?.type===`custom`?e.customType??null:null)===(t?.type===`custom`?t.customType??null:null)),V(this,`handleForcedToolChange`,(e,t)=>{let n=this.props.activeTool;if(!n)return;let r=!this.isSameForcedTool(e.activeTool,n);if(n.type===`image`){r&&console.warn(`"image" tool cannot be forced via "props.activeTool"`);return}this.isSameForcedTool(n,this.state.activeTool)||(r||t.activeTool!==this.state.activeTool||this.isToolSupported(n.type,e)!==this.isToolSupported(n.type,this.props))&&this.setActiveTool(n)}),V(this,`resetHistory`,()=>{this.history.clear()}),V(this,`resetStore`,()=>{this.store.clear()}),V(this,`resetScene`,MP(e=>{this.elementRenderOverrides=new Map,this.elementRenderOffsets=new Map,this.scene.replaceAllElements([]),this.setState(t=>({...Gt(),isLoading:!e?.resetLoadingState&&t.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()})),V(this,`initializeScene`,async()=>{`launchQueue`in this.ownerWindow&&`LaunchParams`in this.ownerWindow&&this.ownerWindow.launchQueue.setConsumer(async e=>{if(!e.files.length)return;let t=e.files[0],n=await t.getFile();this.loadFileToCanvas(new File([n],n.name||``,{type:n.type}),t)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let e=null;try{e=typeof this.props.initialData==`function`?await this.props.initialData()||null:await this.props.initialData||null,e?.libraryItems&&this.library.updateLibrary({libraryItems:e.libraryItems,merge:!0}).catch(e=>{console.error(e)})}catch(t){console.error(t),e={appState:{errorMessage:t.message||`Encountered an error during importing or restoring scene data`}}}let t=$c(e?.elements,null,{repairBindings:!0,deleteInvisibleElements:!0}),n=at(e?.appState,null),r=n.activeTool;n.preferredSelectionTool.initialized||(n.preferredSelectionTool={type:this.editorInterface.formFactor===`phone`?`lasso`:`selection`,initialized:!0}),n={...n,theme:this.props.theme||n.theme,openSidebar:n?.openSidebar||this.state.openSidebar,activeTool:r.type===`image`||r.type===`lasso`||r.type===`selection`?{...r,type:n.preferredSelectionTool.type}:n.activeTool,isLoading:!1,toast:this.state.toast};let i={...n,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft},a=this.props.initialState?.viewport;if(a){let e=t.filter(e=>!e.isDeleted),r=d(e),o=this.viewport.resolveInitialViewport(a,r,i);o&&(n={...n,...o})}else e?.scrollToContent&&(n={...n,...hc(t,i)});this.resetStore(),this.resetHistory(),this.syncActionResult({elements:t,appState:n,files:e?.files,captureUpdate:N.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(e=>{this.fonts.onLoaded(e)}),Qe(this.ownerWindow.location.href)&&this.viewport.setViewport({target:this.ownerWindow.location.href,fit:`scale-down`,animation:!1})}),V(this,`getFormFactor`,(e,t)=>this.props.UIOptions.getFormFactor?.(e,t)??se(e,t)),V(this,`refreshEditorInterface`,()=>{let e=this.excalidrawContainerRef.current;if(!e)return;let{width:t,height:n}=e.getBoundingClientRect(),r=Ra(),i=un(typeof navigator<`u`?navigator.userAgent:``),a=this.props.UIOptions.dockedSidebarBreakpoint==null?wa:this.props.UIOptions.dockedSidebarBreakpoint,o=oi(this.editorInterface,{desktopUIMode:r??this.editorInterface.desktopUIMode,formFactor:this.getFormFactor(t,n),userAgent:i,canFitSidebar:t>a,isLandscape:t>n});this.editorInterface=o,this.reconcileStylesPanelMode(o)}),V(this,`reconcileStylesPanelMode`,e=>{let t=Ea(e);if(t===this.stylesPanelMode)return;let n=this.stylesPanelMode;this.stylesPanelMode=t,this.viewport.invalidateUIOffset(`stylesPanel`),n!==`full`&&t===`full`&&this.setState(e=>({preferredSelectionTool:{type:`selection`,initialized:!0}}))}),V(this,`setDesktopUIMode`,e=>{let t=wo(e);this.editorInterface=oi(this.editorInterface,{desktopUIMode:t}),this.reconcileStylesPanelMode(this.editorInterface)}),V(this,`onResize`,MP(()=>{this.scene.getElementsIncludingDeleted().forEach(e=>Nn.delete(e)),this.refreshEditorInterface(),this.updateDOMRect(),this.setState({})})),V(this,`onFullscreenChange`,()=>{!this.ownerDocument.fullscreenElement&&this.state.activeEmbeddable?.state===`active`&&this.setState({activeEmbeddable:null})}),V(this,`renderInteractiveSceneCallback`,({scrollBars:e})=>{e&&(wU=e),this.scheduleImageRefresh()}),V(this,`onScroll`,ws(()=>{let{offsetTop:e,offsetLeft:t}=this.getCanvasOffsets();this.setState(n=>n.offsetLeft===t&&n.offsetTop===e?null:{offsetTop:e,offsetLeft:t})},100)),V(this,`onCut`,MP(e=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(this.ownerDocument.activeElement)||tl(e.target)||(this.actionManager.executeAction(MO,`keyboard`,e),e.preventDefault(),e.stopPropagation())})),V(this,`onCopy`,MP(e=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(this.ownerDocument.activeElement)||tl(e.target)||(this.actionManager.executeAction(AO,`keyboard`,e),e.preventDefault(),e.stopPropagation())})),V(this,`onTouchStart`,t=>{if(this.isInteractionEnabled()){if(Bo&&t.preventDefault(),!bU){bU=!0,t.touches.length===1&&(SU={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(xU),xU=this.ownerWindow.setTimeout(e.resetTapTwice,300);return}if(bU&&t.touches.length===1&&SU){let e=t.touches[0];zt(F(e.clientX,e.clientY),F(SU.x,SU.y))<=35&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:e.clientX,clientY:e.clientY,type:`touch`,altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1})),bU=!1,clearTimeout(xU)}t.touches.length===2&&this.setState({selectedElementIds:yi({},this.state),activeEmbeddable:null})}}),V(this,`onTouchEnd`,e=>{this.isInteractionEnabled()&&(this.resetContextMenuTimer(),e.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:yi(this.state.previousSelectedElementIds,this.state)}):NU.pointers.clear())}),V(this,`pasteFromClipboard`,MP(async e=>{if(!this.isInteractionEnabled())return;let t=!!kU,n=this.ownerDocument.activeElement,r=this.excalidrawContainerRef.current?.contains(n);if(e&&!r)return;let i=this.ownerDocument.elementFromPoint(this.viewport.lastPosition.x,this.viewport.lastPosition.y);if(e&&(!(i instanceof this.ownerWindow.HTMLCanvasElement)||tl(n)))return;let a=await BD(e),o=a.getFiles(),s=await VD(a,t);if(this.props.onPaste)try{if(await this.props.onPaste(s,e)===!1)return}catch(e){console.error(e)}await this.insertClipboardContent(s,o,t),this.setActiveTool({type:this.state.preferredSelectionTool.type},{keepSelection:!0}),e?.preventDefault()})),V(this,`addElementsFromPasteOrLibrary`,e=>{let t=$c(e.elements,null,{deleteInvisibleElements:!0}),[n,r,i,a]=Wr(t),o=pt(n,i)/2,s=pt(r,a)/2,c=typeof e.position==`object`?e.position.clientX:e.position===`cursor`?this.viewport.lastPosition.x:this.state.width/2+this.state.offsetLeft,l=typeof e.position==`object`?e.position.clientY:e.position===`cursor`?this.viewport.lastPosition.y:this.state.height/2+this.state.offsetTop,{x:u,y:f}=Qn({clientX:c,clientY:l},this.state),p=u-o,m=f-s,[h,_]=Po(p,m,this.getEffectiveGridSize()),{duplicatedElements:v}=g({type:`everything`,elements:t.map(e=>j(e,{x:e.x+h-n,y:e.y+_-r})),randomizeSeed:!e.retainSeed,preserveFrameChildrenOrder:e.preserveFrameChildrenOrder}),y=this.scene.getElementsIncludingDeleted(),b=[...y,...v];b=this.props.onDuplicate?.(b,y)||b,ct(b,d(v));let x=this.getTopLayerFrameAtSceneCoords({x:u,y:f});if(x){let e=Ki(v,x);b=ki(b,e,x)}this.scene.replaceAllElements(b),v.forEach(e=>{if(z(e)&&_s(e)){let t=Ws(e,this.scene.getElementsMapIncludingDeleted());gt(e,t,this.scene)}}),Vi&&xn.loadElementsFonts(v,this.ownerDocument).then(e=>{this.fonts.onLoaded(e)}),e.files&&this.addMissingFiles(e.files);let S=ya(v);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.editorInterface.canFitSidebar&&Kb.get(XL)?this.state.openSidebar:null,...so(S,this.scene.getNonDeletedElements(),this.state)},()=>{e.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:this.state.preferredSelectionTool.type},{keepSelection:!0}),e.fit&&this.viewport.setViewport({target:v,fit:e.fit,animation:!1,offsets:{ui:!0}})}),V(this,`setAppState`,(e,t)=>{this.setState(e,t)}),V(this,`removePointer`,e=>{TU&&this.resetContextMenuTimer(),e.type===`pointercancel`&&this.bucketFill.cancel();let t=NU.pointers.size>=2;NU.pointers.delete(e.pointerId),t&&NU.pointers.size<2&&this.state.scrollConstraints&&this.viewport.releaseOverscroll()}),V(this,`toggleLock`,(e=`ui`)=>{this.props.activeTool||(this.state.activeTool.locked||Vw(`toolbar`,`toggleLock`,`${e} (${this.editorInterface.formFactor===`phone`?`mobile`:`desktop`})`),this.setState(e=>({activeTool:{...e.activeTool,...ae(this.state,e.activeTool.locked?{type:this.state.preferredSelectionTool.type}:e.activeTool),locked:!e.activeTool.locked}})))}),V(this,`updateFrameRendering`,e=>{this.setState(t=>{let n=typeof e==`function`?e(t.frameRendering):e;return{frameRendering:{enabled:n?.enabled??t.frameRendering.enabled,clip:n?.clip??t.frameRendering.clip,name:n?.name??t.frameRendering.name,outline:n?.outline??t.frameRendering.outline}}})}),V(this,`togglePenMode`,e=>{this.setState(t=>({penMode:e??!t.penMode,penDetected:!0,currentItemStrokeVariability:t.penDetected?t.currentItemStrokeVariability:`variable`}))}),V(this,`revealIfHidden`,e=>{!e.length||Ht(e,this.canvas.width/this.ownerWindow.devicePixelRatio,this.canvas.height/this.ownerWindow.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.viewport.getOffsets())||this.viewport.setViewport({target:Wr(e),fit:`scale-down`,animation:{duration:300},offsets:{ui:!0}})}),V(this,`emitUserFollowIntent`,e=>{this.onUserFollowEmitter.trigger(e),this.props.onUserFollow?.(e)}),V(this,`requestUnfollow`,()=>{this.props.userToFollow&&this.emitUserFollowIntent({userToFollow:this.props.userToFollow,action:`UNFOLLOW`})}),V(this,`setToast`,e=>{this.setState({toast:e})}),V(this,`restoreFileFromShare`,async()=>{try{let e=await caches.open(`web-share-target`),t=await e.match(`shared-file`);if(t){let n=await t.blob(),r=new File([n],n.name||``,{type:n.type});this.loadFileToCanvas(r,null),await e.delete(`shared-file`),this.ownerWindow.history.replaceState(null,co,this.ownerWindow.location.pathname)}}catch(e){this.setState({errorMessage:e.message})}}),V(this,`addFiles`,MP(e=>{let{addedFiles:t}=this.addMissingFiles(e);this.clearImageShapeCache(t),this.scene.triggerUpdate(),this.addNewImagesToImageCache()})),V(this,`addMissingFiles`,(e,t=!1)=>{let n=t?{}:{...this.files},r={},i=Array.isArray(e)?e:Object.values(e);for(let e of i)if(!n[e.id]&&(r[e.id]=e,n[e.id]=e,e.mimeType===M.svg))try{let t=Ur(zn(Se(e.dataURL)),M.svg);e.dataURL!==t&&(e.version=(e.version??1)+1,e.dataURL=t)}catch(e){console.error(e)}return this.files=n,{addedFiles:r}}),V(this,`updateScene`,MP(e=>{let{elements:t,appState:n,collaborators:r,captureUpdate:i}=e;if(i){let e=t||void 0,r=n?hs({...this.store.snapshot.appState,...n}):void 0;this.store.scheduleMicroAction({action:i,elements:e,appState:r})}n&&this.setState(n),t&&this.scene.replaceAllElements(t),r&&(this.laserTrails.updateCollabTrails(r),this.setState({collaborators:r}))})),V(this,`setElementRenderOverrides`,e=>{if(this.unmounted)return;let t=nP(e);!t.size&&!this.elementRenderOverrides.size||(this.elementRenderOverrides=t,this.elementRenderOffsets=rP(this.elementRenderOverrides,this.elementRenderOffsets),this.renderOverridesUpdatePending=!0,this.forceUpdate())}),V(this,`applyDeltas`,(e,t)=>{let n=St.squash(...e),r={...this.state},i=new Map(this.scene.getElementsMapIncludingDeleted());return St.applyTo(n,i,r,t)}),V(this,`mutateElement`,(e,t,n=!0)=>this.scene.mutateElement(e,t,{informMutation:n,isDragging:!1})),V(this,`triggerRender`,e=>{e===!0?this.scene.triggerUpdate():this.setState({})}),V(this,`toggleSidebar`,({name:e,tab:t,force:n})=>{let r;r=n===void 0?this.state.openSidebar?.name===e&&this.state.openSidebar?.tab===t?null:e:n?e:null;let i=r?{name:r}:null;return i&&t&&(i.tab=t),this.setState({openSidebar:i}),!!r}),V(this,`updateCurrentCursorPosition`,MP(e=>{this.viewport.lastPosition.x=e.clientX,this.viewport.lastPosition.y=e.clientY})),V(this,`onKeyDown`,MP(e=>{if(!this.isInteractionEnabled())return;if(`Proxy`in this.ownerWindow&&(!e.shiftKey&&/^[A-Z]$/.test(e.key)||e.shiftKey&&/^[a-z]$/.test(e.key))&&(e=new Proxy(e,{get(t,n){let r=t[n];return typeof r==`function`?r.bind(t):n===`key`?e.shiftKey?t.key.toUpperCase():t.key.toLowerCase():r}})),!gr(e.target)){if((e.key===L.ESCAPE||e.key===L.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let t=ot(this.scene.getNonDeletedElementsMap(),this.state);if(t.length===1&&La(t[0])&&e.key===L.ENTER){this.startImageCropping(t[0]);return}if(e.key===L.ESCAPE)this.updateEditorAtom(bk,null);else if(e.key===L.TAB&&(this.ownerDocument.activeElement===this.excalidrawContainerRef?.current||this.ownerDocument.activeElement?.classList.contains(Ai.CONVERT_ELEMENT_TYPE_POPUP))){e.preventDefault();let n=Dk(t);Kb.get(bk)?.type===`panel`&&Ek(this,{conversionType:n,direction:e.shiftKey?`left`:`right`})&&this.store.scheduleCapture(),n&&this.updateEditorAtom(bk,{type:`panel`})}if(this.flowchart.handleKeyEvent(e))return}if(e[L.CTRL_OR_CMD]&&e.key===L.P&&!e.shiftKey&&!e.altKey){this.setToast({message:K(`commandPalette.shortcutHint`,{shortcut:Kk(`commandPalette`)})}),e.preventDefault();return}if(e[L.CTRL_OR_CMD]&&e.key.toLowerCase()===L.V&&(kU=e.shiftKey,clearTimeout(AU),AU=this.ownerWindow.setTimeout(()=>{kU=!1},100)),e[L.CTRL_OR_CMD]&&tl(e.target)&&(e.code===xt.MINUS||e.code===xt.EQUAL)){e.preventDefault();return}if(tl(e.target)&&e.key!==L.ESCAPE||Yr(e.key)&&gr(e.target))return;if(e.key===L.QUESTION_MARK){this.setState({openDialog:{name:`help`}});return}if(e.key.toLowerCase()===L.E&&e.shiftKey&&e[L.CTRL_OR_CMD]){e.preventDefault(),this.setState({openDialog:{name:`imageExport`}});return}if(this.maybeHandlePageScrollKeyDown(e)){e.preventDefault();return}if(this.state.openDialog?.name===`elementLinkSelector`)return;if(e.key===L.ALT){if(this.state.activeTool.type===`bucketfill`){this.bucketFill.openTemporaryEyeDropper(),e.preventDefault();return}me(`COMPLEX_BINDINGS`)?this.handleSkipBindMode():Kr({app:this,event:e})}if(this.actionManager.handleKeyDown(e))return;let t=this.props.viewModeEnabled===!0;if(!t&&this.state.viewModeEnabled&&e.key===L.ESCAPE){this.setActiveTool({type:`selection`});return}if(!t&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let t=QE(e.key,this,e.shiftKey);if(this.state.viewModeEnabled&&!zr(t,[`laser`,`hand`]))return;if(t){if(this.state.activeTool.type!==t&&Vw(`toolbar`,t,`keyboard (${this.editorInterface.formFactor===`phone`?`mobile`:`desktop`})`),t===`arrow`&&this.state.activeTool.type===`arrow`){let e=this.state.currentItemArrowType===Nt.sharp?Nt.round:this.state.currentItemArrowType===Nt.round?Nt.elbow:Nt.sharp;this.setState({currentItemArrowType:e}),this.cursorHints.onArrowTypeCycled(e)}else(t===`arrow`||t===`line`)&&this.cursorHints.onToolShortcut(t,/^\d$/.test(e.key)?`digit`:`letter`);t===`bucketfill`&&this.state.activeTool.type===`bucketfill`?this.bucketFill.cycleBackgroundColor():t===`lasso`&&this.state.activeTool.type===`laser`?this.setActiveTool({type:this.state.preferredSelectionTool.type}):this.setActiveTool({type:t},{toggle:!0}),e.stopPropagation();return}if(e.key===L.Q){this.toggleLock(`keyboard`),e.stopPropagation();return}}if(this.state.viewModeEnabled)return;if(e[L.CTRL_OR_CMD]&&!e.repeat&&(me(`COMPLEX_BINDINGS`)&&this.resetDelayedBindMode(),(0,hl.flushSync)(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!==`enabled`})}),this.arrowText.refresh(),Kr({app:this,event:e})),Yr(e.key)){let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),n=new Set;t.filter(e=>mo(e)).filter(e=>{let n=e.startBinding&&!t.some(t=>t.id===e.startBinding?.elementId),r=e.endBinding&&!t.some(t=>t.id===e.endBinding?.elementId);return n||r}).forEach(e=>n.add(e.id)),t=t.filter(e=>!n.has(e.id));let r=this.getEffectiveGridSize()&&(e.shiftKey?1:this.getEffectiveGridSize())||(e.shiftKey?5:1),i=0,a=0;e.key===L.ARROW_LEFT?i=-r:e.key===L.ARROW_RIGHT?i=r:e.key===L.ARROW_UP?a=-r:e.key===L.ARROW_DOWN&&(a=r),t.forEach(e=>{this.scene.mutateElement(e,{x:e.x+i,y:e.y+a},{informMutation:!1,isDragging:!1}),u(e,this.scene,{simultaneouslyUpdated:t})}),this.scene.triggerUpdate(),e.preventDefault()}else if(e.key===L.ENTER){let t=this.scene.getSelectedElements(this.state);if(t.length===1){let n=t[0];if(e[L.CTRL_OR_CMD]||oa(n))ro(n)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==n.id)&&(this.store.scheduleCapture(),Br(n)||this.actionManager.executeAction(IN));else if(z(n)||qe(n)){let t;z(n)||(t=n);let r=Ui(n,this.scene.getNonDeletedElementsMap()),i=r.x,a=r.y;this.startTextEditing({sceneX:i,sceneY:a,container:t}),e.preventDefault();return}else R(n)&&this.setState({editingFrame:n.id})}}if(e.key===L.SPACE&&NU.pointers.size===0&&(this.pan.setSpaceHeld(!0),this.cursor.set(jt.GRAB),e.preventDefault()),(e.key===L.G||e.key===L.S)&&!e.altKey&&!e[L.CTRL_OR_CMD]){let t=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type===`selection`&&!t.length)return;e.key===L.G&&(Ve(this.state.activeTool.type)||t.some(e=>Ve(e.type)))&&(this.setState({openPopup:`elementBackground`}),e.stopPropagation()),e.key===L.S&&(this.setState({openPopup:`elementStroke`}),e.stopPropagation())}if(!e[L.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===L.F){let t=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type===`selection`&&!t.length)return;(this.state.activeTool.type===`text`||t.find(e=>z(e)||Ga(e,this.scene.getNonDeletedElementsMap())))&&(e.preventDefault(),this.setState({openPopup:`fontFamily`}))}e[L.CTRL_OR_CMD]&&(e.key===L.BACKSPACE||e.key===L.DELETE)&&this.updateEditorAtom(tM,`clearCanvas`);let n=e.key.toLocaleLowerCase(),r=n===L.S&&e.shiftKey&&!e[L.CTRL_OR_CMD],i=e.key===L.I||n===L.G&&e.shiftKey;(r||i)&&this.openEyeDropper({type:r?`stroke`:`background`})})),V(this,`onKeyUp`,MP(e=>{if(this.isInteractionEnabled()){if(e.key===L.SPACE&&(this.state.viewModeEnabled&&this.state.activeTool.type!==`laser`||this.state.openDialog?.name===`elementLinkSelector`?this.cursor.set(jt.GRAB):Oo(this.state.activeTool.type)?this.cursor.reset():(this.cursor.applyForTool(),this.setState({selectedElementIds:yi({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),this.pan.setSpaceHeld(!1)),e.key===L.ALT&&(this.bucketFill.closeTemporaryEyeDropper(),Kr({app:this,event:e})),(e.key===L.ALT&&this.state.bindMode===`skip`||!e[L.CTRL_OR_CMD]&&!ze(this.state))&&(this.setState({bindMode:`orbit`}),this.lastPointerMoveEvent&&me(`COMPLEX_BINDINGS`))){let e=Qn({clientX:this.lastPointerMoveEvent.clientX,clientY:this.lastPointerMoveEvent.clientY},this.state),t=Et(F(e.x,e.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(this.state.selectedLinearElement){let e=I.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());mo(e)&&this.handleDelayedBindModeChange(e,t)}}if(!e[L.CTRL_OR_CMD]){let t=this.state.bindingPreference===`enabled`;this.state.isBindingEnabled!==t&&((0,hl.flushSync)(()=>{this.setState({isBindingEnabled:t})}),this.arrowText.refresh()),Kr({app:this,event:e})}if(Yr(e.key)){wn(this.scene.getSelectedElements(this.state).filter(ye),this.scene,this.state);let e=this.scene.getNonDeletedElementsMap();this.scene.getSelectedElements(this.state).filter(Wt).forEach(t=>{t.startBinding&&this.scene.mutateElement(t,{startBinding:{...t.startBinding,...en(t,e.get(t.startBinding.elementId),`start`,e)}}),t.endBinding&&this.scene.mutateElement(t,{endBinding:{...t.endBinding,...en(t,e.get(t.endBinding.elementId),`end`,e)}})}),this.setState({suggestedBinding:null})}this.flowchart.handleKeyEvent(e)}})),V(this,`setActiveTool`,(e,t={})=>{let{keepSelection:n=!1}=t;if(!this.isToolSupported(e.type)){console.warn(this.isInteractionEnabled()?`"${e.type}" tool is disabled via "UIOptions.canvasActions.tools.${e.type}"`:`"${e.type}" tool cannot be activated while the editor is non-interactive (see "interaction.enabled.tools")`);return}if(this.props.activeTool&&!this.isSameForcedTool(this.props.activeTool,e)){console.warn(`"${e.type}" tool activation ignored \u2014 the active tool is controlled by the host via "props.activeTool"`);return}this.drawShape.hasPendingGesture()&&this.actionManager.executeAction(_D);let r=YE.includes(e.type),i=t.toggle===!0&&r&&this.state.activeTool.type===e.type?ae(this.state,{...this.state.activeTool.lastActiveTool||{type:this.state.preferredSelectionTool.type},lastActiveTool:null}):r&&this.state.activeTool.type!==e.type?ae(this.state,{...e,lastActiveTool:this.state.activeTool}):ae(this.state,e);i.type===`hand`?this.cursor.set(jt.GRAB):this.pan.isSpaceHeld()||this.cursor.applyForTool(i),_(this.ownerDocument.activeElement)&&this.focusContainer(),ce(i.type)||this.setState({suggestedBinding:null}),i.type===`image`&&this.onImageToolbarButtonClick(),this.setState(e=>{let t={snapLines:e.snapLines.length?[]:e.snapLines,originSnapOffset:null,activeEmbeddable:null,selectedLinearElement:Oo(i.type)?e.selectedLinearElement:null,frameToHighlight:null,hoveredArrowTextAnchor:null};return i.type===`freedraw`&&this.store.scheduleCapture(),i.type===`lasso`?{...e,...t,activeTool:i,...n?{}:{selectedElementIds:yi({},e),selectedGroupIds:yi({},e),editingGroupId:null,multiElement:null}}:i.type===`selection`?{...e,...t,activeTool:i}:{...e,...t,activeTool:i,selectedElementIds:yi({},e),selectedGroupIds:yi({},e),editingGroupId:null,multiElement:null}})}),V(this,`setOpenDialog`,e=>{this.setState({openDialog:e})}),V(this,`isTouchScreenMultiTouchGesture`,()=>NU.pointers.size>=2),V(this,`getName`,()=>this.state.name||this.props.name||`${K(`labels.untitled`)}-${He()}`),V(this,`onGestureStart`,MP(e=>{this.isNavigationEnabled()&&(e.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:yi({},this.state),activeEmbeddable:null}),NU.initialScale=this.state.zoom.value)})),V(this,`onGestureChange`,MP(e=>{if(!this.isNavigationEnabled()||(e.preventDefault(),this.isTouchScreenMultiTouchGesture()))return;let t=NU.initialScale;t&&this.viewport.translate(n=>({...ba({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:Io(t*e.scale)},n)}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})})),V(this,`onGestureEnd`,MP(e=>{this.isNavigationEnabled()&&(e.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:yi(this.state.previousSelectedElementIds,this.state)}),NU.initialScale=null)})),V(this,`isHittingTextAutoResizeHandle`,(e,t)=>{let n=ls(e,this.state);return!(!n||n.isDeleted||n.autoResize||!qP(t,n,this.state.zoom.value,this.editorInterface.formFactor))}),V(this,`handleTextAutoResizeHandlePointerDown`,(e,t)=>{let n=ls(e,this.state);return!n||!this.isHittingTextAutoResizeHandle(e,t)?!1:(this.actionManager.executeAction(XN,`ui`,n),this.cursor.reset(),!0)}),V(this,`startTextEditing`,({sceneX:e,sceneY:t,insertAtParentCenter:n=!0,container:r,autoEdit:i=!0,initialCaretSceneCoords:a,arrowEndpoint:o})=>{let s=!1,c=o&&this.arrowText.getTextBinding(o,this.getCurrentItemStrokeWidth(`text`));c&&(r=null,n=!1,e=c.anchor[0],t=c.anchor[1]);let l=n&&this.getTextWysiwygSnappedToCenterPosition(e,t,this.state,r);r&&l&&(Ga(r,this.scene.getNonDeletedElementsMap())||(s=!0));let u=c?null:this.getSelectedTextElement(r)||(r&&ye(r)?Ga(r,this.scene.getNonDeletedElementsMap()):null)||this.getTextElementAtPosition(e,t),d=u?.fontFamily||this.state.currentItemFontFamily,f=u?.lineHeight||qt(d),p=this.state.currentItemFontSize;if(!u&&s&&r&&!ye(r)&&!oe(r)){let n=la(Ro({fontSize:p,fontFamily:d}),f),i=Zn(p,f),a=Math.max(r.height,i),o=Math.max(r.width,n);this.scene.mutateElement(r,{height:a,width:o}),e=r.x+o/2,t=r.y+a/2,l&&=this.getTextWysiwygSnappedToCenterPosition(e,t,this.state,r)}let m=this.getTextCreationGridPoint(e,t),h=c?{x:e,y:t}:l?{x:l.elementCenterX,y:l.elementCenterY}:u?{x:e,y:t}:{x:m?.x??e,y:m===null?t-qo(p,f)/2:m.y},g=this.getTopLayerFrameAtSceneCoords({x:h.x,y:h.y}),_=g&&(!s||!r||r.frameId===g.id)?g.id:null,v=u||Ir({x:h.x,y:h.y,strokeColor:s&&oe(r)?r.strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(`text`),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:``,fontSize:p,baseFontSize:s&&oe(r)?p:null,fontFamily:d,textAlign:c?.textAlign??(l?`center`:this.state.currentItemTextAlign),verticalAlign:c?.verticalAlign??(l?$t.MIDDLE:`top`),containerId:s?r?.id:void 0,labelPosition:s&&r&&ye(r)?.5:null,groupIds:r?.groupIds??[],lineHeight:f,angle:r?ye(r)?0:r.angle:0,frameId:_});if(!u&&s&&r&&this.scene.mutateElement(r,{boundElements:(r.boundElements||[]).concat({type:`text`,id:v.id})}),this.setState({editingTextElement:v}),!u){if(r&&s){let e=this.scene.getElementIndex(r.id);this.scene.insertElementsAtIndex([v],e+1)}else this.insertNewElement(v)}o&&c&&this.arrowText.bindText(o,v,c.fixedPoint),i||u||r?this.handleTextWysiwyg(v,{isExistingElement:!!u,initialCaretSceneCoords:u?a:null}):this.setState({newElement:v,multiElement:null})}),V(this,`startImageCropping`,e=>{this.store.scheduleCapture(),this.setState({croppingElementId:e.id})}),V(this,`finishImageCropping`,()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))}),V(this,`shouldHandleBrowserCanvasDoubleClick`,e=>{if(e===`touch`||this.lastCompletedCanvasClicks.length===0)return!0;if(this.lastCompletedCanvasClicks.length<2)return!1;let[t,n]=this.lastCompletedCanvasClicks;return zt(F(t.x,t.y),F(n.x,n.y))<=35}),V(this,`handleCanvasDoubleClick`,e=>{if(!this.isInteractionEnabled()||this.state.editingTextElement||!this.shouldHandleBrowserCanvasDoubleClick(e.type)||this.state.multiElement||this.state.activeTool.type!==this.state.preferredSelectionTool.type&&this.state.activeTool.type!==`autoshape`)return;let t=this.scene.getSelectedElements(this.state),{x:n,y:r}=Qn(e,this.state);if(t.length===1&&ro(t[0])){let i=t[0];if((e[L.CTRL_OR_CMD]&&Wt(i)||oa(i))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==i.id)){this.actionManager.executeAction(IN);return}if(this.state.selectedLinearElement&&Br(t[0])){let e=I.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:n,y:r},this.state,this.scene.getNonDeletedElementsMap()),i=e?I.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,e,this.scene.getNonDeletedElementsMap()):-1;if(i&&i>-1){this.store.scheduleCapture(),I.deleteFixedSegment(t[0],this.scene,i);let a=I.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:n,y:r},this.state,this.scene.getNonDeletedElementsMap()),o=a?I.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,a,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,segmentMidpoint:{index:o,value:e,added:!1}},segmentMidPointHoveredCoords:a}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===i.id&&oa(i))return}if(t.length===1&&La(t[0])){this.startImageCropping(t[0]);return}if(this.cursor.reset(),Is(this.state).length>0){let e=this.getElementAtPosition(n,r),t=e&&b(e,this.state.selectedGroupIds);if(t){this.store.scheduleCapture(),this.setState(n=>({...n,...To({editingGroupId:t,selectedElementIds:{[e.id]:!0}},this.scene.getNonDeletedElements(),n,this)}));return}}if(this.cursor.reset(),!this.state.viewModeEnabled){let t=this.getElementAtPosition(n,r);if(Qt(t)){this.isIframeLikeInteractive(t)&&this.setState({activeEmbeddable:{element:t,state:`active`}});return}if(!this.state.selectedLinearElement?.isEditing){let t=!e[L.CTRL_OR_CMD]&&this.getTextBindableContainerAtPosition(n,r);if(t&&(this.state.activeTool.type===`autoshape`||xr(t)||!Ke(t.backgroundColor)||rs({point:F(n,r),element:t,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(t)}))){let e=Ui(t,this.scene.getNonDeletedElementsMap());n=e.x,r=e.y}this.startTextEditing({sceneX:n,sceneY:r,insertAtParentCenter:!e.altKey,container:t||null})}}}),V(this,`handleCanvasClick`,e=>{if(this.isInteractionEnabled()){if(e.button!==Kn.MAIN){this.lastCompletedCanvasClicks=[];return}this.lastCompletedCanvasClicks=[...this.lastCompletedCanvasClicks.slice(-1),{x:e.clientX,y:e.clientY}]}}),V(this,`getElementLinkAtPosition`,(e,t)=>{if(t&&t.locked)return;let n=this.scene.getNonDeletedElements(),r=-1;for(let i=n.length-1;i>=0;i--){let a=n[i];if(t&&a.id===t.id&&(r=i),a.link&&i>=r&&qi(a,this.scene.getNonDeletedElementsMap(),this.state,F(e.x,e.y),this.editorInterface.formFactor===`phone`))return a}}),V(this,`handleElementLinkClick`,e=>{let t=zt(F(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),F(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||t>10)return;let n=Qn(this.lastPointerDownEvent,this.state),r=this.scene.getNonDeletedElementsMap(),i=qi(this.hitLinkElement,r,this.state,F(n.x,n.y),this.editorInterface.formFactor===`phone`),a=Qn(this.lastPointerUpEvent,this.state),o=qi(this.hitLinkElement,r,this.state,F(a.x,a.y),this.editorInterface.formFactor===`phone`);if(i&&o){ok();let t=this.hitLinkElement.link;if(t){t=cn(t);let n;if(this.props.onLinkOpen&&(n=cr(B.EXCALIDRAW_LINK,e.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:t},n)),!n?.defaultPrevented){let e=gs(t)?`_self`:`_blank`,n=this.ownerWindow.open(void 0,e);n&&(n.opener=null,n.location=t)}}}}),V(this,`applyElementLinkHoverAffordance`,()=>this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(this.cursor.set(jt.POINTER),ik(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap()),!0):(ok(),!1)),V(this,`maybeHandleElementLinkClick`,(e,t)=>{if(this.editorInterface.isTouchScreen){let e=this.getElementAtPosition(t.x,t.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(t,e)}return this.hitLinkElement&&this.lastPointerDownEvent&&!this.state.selectedElementIds[this.hitLinkElement.id]?(this.handleElementLinkClick(e),!0):!1}),V(this,`handleInteractiveContentPointerMove`,e=>{let t=Qn(e,this.state),n=this.getElementAtPosition(t.x,t.y,{includeLockedElements:!0});if(this.isEmbedsEnabled()){let r=n?.locked?null:n;if(this.handleIframeLikeElementHover({hitElement:r,scenePointer:t,moveEvent:e}))return}this.hitLinkElement=this.isLinksEnabled()?this.getElementLinkAtPosition(t,n):void 0,this.applyElementLinkHoverAffordance()||this.cursor.reset()}),V(this,`handleInteractiveContentPointerUp`,e=>{if(this.lastPointerUpEvent=e,this.isEmbedsEnabled()&&this.handleIframeLikeCenterClick())return;let t=Qn(e,this.state);this.isLinksEnabled()&&this.maybeHandleElementLinkClick(e,t)||this.state.activeEmbeddable?.state===`active`&&this.setState({activeEmbeddable:null})}),V(this,`getTopLayerFrameAtSceneCoords`,(e,t)=>{let n=this.scene.getNonDeletedElementsMap(),r=this.scene.getNonDeletedFramesLikes().filter(t=>!t.locked&&Ka(e,t,n));if(!r.length)return null;let i=r.at(-1),a=this.getElementsAtPosition(e.x,e.y,{includeLockedElements:!0}).findLast(e=>!t?.excludeElementIds?.[e.id]);if(a){if(R(a)&&!a.locked)return i;let e=this.scene.getElementIndex(a.id),n=this.scene.getElementIndex(i.id);return e!==-1&&n!==-1&&e<=n?i:(t?.currentFrameId?r.find(e=>e.id===t.currentFrameId)??null:null)||(a.frameId?r.find(e=>e.id===a.frameId)??null:null)}return i}),V(this,`updateFrameToHighlight`,e=>{this.state.frameToHighlight!==e&&this.setState({frameToHighlight:e})}),V(this,`maybeUpdateFrameToHighlightOnPointerMove`,(e,t)=>{this.state.newElement||this.state.multiElement||this.state.selectionElement||this.state.selectedElementsAreBeingDragged||this.updateFrameToHighlight(!t&&ys(this.state.activeTool.type)?this.getTopLayerFrameAtSceneCoords(e):null)}),V(this,`insertNewElements`,e=>{if(!e.length)return;let t=[];for(let n of e){let e=t[t.length-1];e?.[0].frameId===n.frameId?e.push(n):t.push([n])}for(let e of t){let t=e[0].frameId,n=t?wc(this.scene.getElementsIncludingDeleted(),t):null;this.scene.insertElementsAtIndex(e,n)}}),V(this,`insertNewElement`,e=>{this.insertNewElements([e]);let t=e.frameId?this.scene.getNonDeletedElement(e.frameId):null;this.updateFrameToHighlight(t&&R(t)?t:null)}),V(this,`handleCanvasPointerMove`,e=>{if(!this.isInteractionEnabled()){this.isToolSupported(this.state.activeTool.type)&&this.savePointer(e.clientX,e.clientY,this.state.cursorButton),this.isNavigationEnabled()&&this.updateMultiTouchGesture(e),(this.isLinksEnabled()||this.isEmbedsEnabled())&&!this.pan.isActive()&&this.handleInteractiveContentPointerMove(e);return}this.savePointer(e.clientX,e.clientY,this.state.cursorButton),this.lastPointerMoveEvent=e.nativeEvent;let t=Qn(e,this.state),{x:n,y:r}=t;if(this.lastPointerMoveCoords={x:n,y:r},this.updateMultiTouchGesture(e),this.pan.isSpaceHeld()||this.pan.isActive()||CU||wr(this.state))return;let i=rF(wU,e.clientX-this.state.offsetLeft,e.clientY-this.state.offsetTop).isOverEither;if(!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(i?this.cursor.set(jt.AUTO):this.cursor.applyForTool()),this.maybeUpdateFrameToHighlightOnPointerMove({x:n,y:r},i),!this.state.newElement&&DP(this.state.activeTool.type)){let{originOffset:t,snapLines:i}=EP(this.scene.getNonDeletedElements(),this,{x:n,y:r},e,this.scene.getNonDeletedElementsMap());this.setState(e=>{let n=$s(e.snapLines,i),r=e.originSnapOffset?$s(e.originSnapOffset,t):t;return e.snapLines===n&&e.originSnapOffset===r?null:{snapLines:n,originSnapOffset:r}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(e=>e.snapLines.length?{snapLines:[]}:null);if(this.state.selectedLinearElement?.isEditing&&!this.state.selectedLinearElement.isDragging){let t=this.state.newElement?null:I.handlePointerMoveInEditMode(e,n,r,this);t&&t!==this.state.selectedLinearElement&&(0,hl.flushSync)(()=>{this.setState({selectedLinearElement:t})})}if(ko(this.state.activeTool.type)){let{newElement:e}=this.state;if(!e&&ze(this.state)){let e=F(n,r),t=this.scene.getNonDeletedElementsMap(),i=Et(e,this.scene.getNonDeletedElements(),t,kn(this.state.zoom));i?this.setState({suggestedBinding:{element:i,midPoint:go(e,i,t,this.state.zoom)}}):this.state.suggestedBinding&&this.setState({suggestedBinding:null})}}if(this.state.multiElement&&this.state.selectedLinearElement){let{multiElement:t,selectedLinearElement:i}=this.state,{x:a,y:o,points:s}=t,c=s[s.length-1],{lastCommittedPoint:l}=i;if(this.cursor.applyForTool(),c===l)zt(F(n-a,r-o),c)>=8?(this.store.scheduleCapture(),(0,hl.flushSync)(()=>{eo(this.state.selectedLinearElement?.initialState,`initialState must be set`),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:s[s.length-1],selectedPointsIndices:[t.points.length],initialState:{...this.state.selectedLinearElement.initialState,lastClickedPoint:t.points.length}}})}),this.scene.mutateElement(t,{points:[...s,F(n-a,r-o)]},{informMutation:!1,isDragging:!1})):this.cursor.set(jt.POINTER);else if(s.length>2&&l&&zt(F(n-a,r-o),l)<8){this.cursor.set(jt.POINTER),this.scene.mutateElement(t,{points:s.slice(0,-1)},{informMutation:!1,isDragging:!1});let e=t.points.length-1;this.setState({selectedLinearElement:{...i,selectedPointsIndices:i.selectedPointsIndices?[...new Set(i.selectedPointsIndices.map(t=>Math.min(t,e)))]:i.selectedPointsIndices,lastCommittedPoint:t.points[e],initialState:{...i.initialState,lastClickedPoint:e}}})}else{bt(s,this.state.zoom.value)&&this.cursor.set(jt.POINTER);let i=this.scene.getNonDeletedElementsMap();if(Wt(t)){let e=Et(F(n,r),this.scene.getNonDeletedElements(),i);me(`COMPLEX_BINDINGS`)&&this.handleDelayedBindModeChange(t,e)}eo(this.state.selectedLinearElement,`Expected selectedLinearElement to be set to operate on a linear element`);let a=I.handlePointerMove(e.nativeEvent,this,n,r,this.state.selectedLinearElement);a&&this.setState(a)}return}if(this.state.activeTool.type===`arrow`&&!this.state.newElement){let e=F(n,r),t=Et(e,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),kn(this.state.zoom)),i=this.scene.getNonDeletedElementsMap();t&&!Vn(e,t,i)&&this.setState({suggestedBinding:{element:t,midPoint:go(e,t,i,this.state.zoom)}})}let a=!!e.buttons,o=this.state.activeTool.type===`laser`;if(a||!o&&this.state.activeTool.type!==`selection`&&this.state.activeTool.type!==`lasso`&&this.state.activeTool.type!==`text`&&this.state.activeTool.type!==`eraser`)return;let s=this.scene.getNonDeletedElements(),c=this.scene.getSelectedElements(this.state);if(this.isHittingTextAutoResizeHandle(c,t)){this.cursor.set(jt.POINTER);return}if(c.length===1&&!i&&!this.state.selectedLinearElement?.isEditing){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,n,r),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&this.state.openDialog?.name!==`elementLinkSelector`&&!(c.length===1&&Br(c[0]))&&(!ro(c[0])||!this.editorInterface.userAgent.isMobileDevice&&c[0].points.length!==2)){let t=Co(s,this.state,n,r,this.state.zoom,e.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);if(t&&t.transformHandleType){this.cursor.set(Mt(t));return}}}else if(c.length>1&&!i&&this.state.openDialog?.name!==`elementLinkSelector`){let t=Qs(Wr(c),n,r,this.state.zoom,e.pointerType,this.editorInterface);if(t){this.cursor.set(Mt({transformHandleType:t}));return}}if(Ba(this.state))return;let l=this.getElementAtPosition(n,r,{preferSelected:!0,includeLockedElements:!0}),u=null;u=l&&l.locked?null:l;let d=this.arrowText.updateHoveredAnchor(t);if(this.handleIframeLikeElementHover({hitElement:u,scenePointer:t,moveEvent:e})||(this.hitLinkElement=this.getElementLinkAtPosition(t,l)),!this.applyElementLinkHoverAffordance()){if(o)return;u&&(u.link||Sn(u))&&this.state.selectedElementIds[u.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:`info`}):this.state.activeTool.type===`text`?this.cursor.set(d?jt.POINTER:z(u)?jt.TEXT:jt.CROSSHAIR):!e[L.CTRL_OR_CMD]&&this.isHittingCommonBoundingBoxOfSelectedElements(t,c)?this.cursor.set(jt.MOVE):this.state.viewModeEnabled?this.cursor.set(jt.GRAB):this.state.openDialog?.name===`elementLinkSelector`||i?this.cursor.set(jt.AUTO):!e[L.CTRL_OR_CMD]&&u?.id!==this.state.editingTextElement?.id?(u||this.isHittingCommonBoundingBoxOfSelectedElements(t,c))&&!u?.locked&&(!u||!Br(u)||!(u.startBinding||u.endBinding))&&(this.state.activeTool.type!==`lasso`||c.length>0)&&this.cursor.set(jt.MOVE):this.cursor.set(jt.AUTO),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,n,r)}this.state.openDialog?.name===`elementLinkSelector`&&u?this.setState(e=>({hoveredElementIds:$s(e.hoveredElementIds,To({editingGroupId:e.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),e,this).selectedElementIds)})):this.state.openDialog?.name===`elementLinkSelector`&&!u&&this.setState(e=>({hoveredElementIds:$s(e.hoveredElementIds,{})}))}),V(this,`handleEraser`,(e,t)=>{let n=this.eraserTrail.addPointToPath(t.x,t.y,e.altKey);this.elementsPendingErasure=new Set(n),this.triggerRender()}),V(this,`handleTouchMove`,e=>{this.isInteractionEnabled()&&(EU=!0)}),V(this,`handleCanvasPointerDown`,e=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)){(this.isLinksEnabled()||this.isEmbedsEnabled())&&(this.lastPointerDownEvent=e),this.isNavigationEnabled()&&(this.updateGestureOnPointerDown(e),this.pan.isActive()||this.pan.start(e));return}let t=this.scene.getSelectedElements(this.state);if(!e.ctrlKey){let e=this.state.bindingPreference===`enabled`;this.state.isBindingEnabled!==e&&this.setState({isBindingEnabled:e})}let n=Qn(e,this.state),{x:r,y:i}=n;this.lastPointerMoveCoords={x:r,y:i};let a=e.target;if(a.setPointerCapture&&a.setPointerCapture(e.pointerId),this.maybeCleanupAfterMissingPointerUp(e.nativeEvent),this.state.activeTool.type!==`laser`&&this.requestUnfollow(),this.state.searchMatches&&(this.setState(e=>({searchMatches:e.searchMatches&&{focusedId:null,matches:e.searchMatches.matches.map(e=>({...e,focus:!1}))}})),this.updateEditorAtom(FR,null)),Kb.get(bk)&&this.updateEditorAtom(bk,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.state.openPopup&&this.setState({openPopup:null}),this.updateGestureOnPointerDown(e),e.pointerType===`touch`&&this.state.newElement&&this.state.newElement.type===`freedraw`){let e=this.state.newElement;this.updateScene({...e.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(t=>t.id!==e.id)}:{},appState:{newElement:null,editingTextElement:null,suggestedBinding:null,selectedElementIds:yi(Object.keys(this.state.selectedElementIds).filter(t=>t!==e.id).reduce((e,t)=>(e[t]=this.state.selectedElementIds[t],e),{}),this.state)},captureUpdate:this.state.openDialog?.name===`elementLinkSelector`?N.EVENTUALLY:N.NEVER});return}let o=this.ownerDocument.getSelection();if(o?.anchorNode&&o.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(e),!this.state.penDetected&&e.pointerType===`pen`&&this.setState(e=>({penMode:!0,penDetected:!0,currentItemStrokeVariability:`variable`})),!this.editorInterface.isTouchScreen&&[`pen`,`touch`].includes(e.pointerType)&&(this.editorInterface=oi(this.editorInterface,{isTouchScreen:!0})),this.pan.isActive()||(this.lastPointerDownEvent=e,this.pan.start(e)))return;if(this.setState({lastPointerDownWith:e.pointerType,cursorButton:`down`}),this.savePointer(e.clientX,e.clientY,`down`),e.button===Kn.ERASER&&this.isInteractionEnabled()&&!this.props.activeTool&&this.state.activeTool.type!==A.eraser){this.setState({activeTool:ae(this.state,{type:A.eraser,lastActiveTool:this.state.activeTool})},()=>{this.handleCanvasPointerDown(e);let t=()=>{n(),r?.(),Ba(this.state)&&this.setState({activeTool:ae(this.state,{...this.state.activeTool.lastActiveTool||{type:A.selection},lastActiveTool:null})})},n=vo(this.ownerWindow,B.POINTER_UP,t,{once:!0}),r;this.ownerWindow.requestAnimationFrame(()=>{r=this.missingPointerEventCleanupEmitter.once(t)})});return}if(e.button!==Kn.MAIN&&e.button!==Kn.TOUCH&&e.button!==Kn.ERASER||NU.pointers.size>1)return;let s=this.initialPointerDownState(e);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleTextAutoResizeHandlePointerDown(t,s.origin)||this.handleDraggingScrollBar(e,s)||(this.clearSelectionIfNotUsingSelection(),this.handleSelectionOnPointerDown(e,s))||this.state.penMode&&e.pointerType===`touch`&&this.state.activeTool.type!==`selection`&&this.state.activeTool.type!==`lasso`&&this.state.activeTool.type!==`text`&&this.state.activeTool.type!==`image`)return;if(this.state.activeTool.type===`lasso`){let t=s.hit.element&&this.isASelectedElement(s.hit.element);(e.altKey&&e[L.CTRL_OR_CMD]&&!s.resize.handleType||!s.hit.hasHitCommonBoundingBoxOfSelectedElements&&!s.resize.handleType&&!t)&&(this.lassoTrail.hasCurrentTrail||this.lassoTrail.startPath(s.origin.x,s.origin.y,e.shiftKey),s.drag.blockDragging=this.editorInterface.formFactor===`desktop`),this.editorInterface.formFactor!==`desktop`&&s.hit.element&&!t&&(this.setState(e=>{let t={...e.selectedElementIds,[s.hit.element.id]:!0},n=[];Object.keys(e.selectedElementIds).forEach(e=>{let t=this.scene.getElement(e);t&&n.push(t)});let r=s.hit.element;if(R(r))Ti(n,r.id).forEach(e=>{delete t[e.id]});else if(r.frameId)t[r.frameId]&&delete t[r.id];else{let e=r.groupIds,i=new Set(e.flatMap(e=>Er(this.scene.getNonDeletedElements(),e)).filter(e=>R(e)).map(e=>e.id));i.size>0&&n.forEach(e=>{e.frameId&&i.has(e.frameId)&&(delete t[e.id],e.groupIds.flatMap(e=>Er(this.scene.getNonDeletedElements(),e)).forEach(e=>{delete t[e.id]}))})}return{...To({editingGroupId:e.editingGroupId,selectedElementIds:t},this.scene.getNonDeletedElements(),e,this),showHyperlinkPopup:r.link||Sn(r)?`info`:!1}}),s.hit.wasAddedToSelection=!0)}else this.state.activeTool.type===`text`?this.handleTextOnPointerDown(e,s):this.state.activeTool.type===`arrow`||this.state.activeTool.type===`line`?this.handleLinearElementOnPointerDown(e,this.state.activeTool.type,s):this.state.activeTool.type===`freedraw`?this.handleFreeDrawElementOnPointerDown(e,this.state.activeTool.type,s):this.state.activeTool.type===`custom`?this.cursor.applyForTool():this.state.activeTool.type===A.frame||this.state.activeTool.type===A.magicframe?this.createFrameElementOnPointerDown(s,this.state.activeTool.type):this.state.activeTool.type===`laser`?this.laserTrails.startPath(s.lastCoords.x,s.lastCoords.y):this.state.activeTool.type===`autoshape`?this.drawShape.handlePointerDown(s):this.state.activeTool.type===A.bucketfill?this.bucketFill.handlePointerDown(n):this.state.activeTool.type!==`eraser`&&this.state.activeTool.type!==`hand`&&this.state.activeTool.type!==`image`&&this.createGenericElementOnPointerDown(this.state.activeTool.type,s);this.props?.onPointerDown?.(this.state.activeTool,s),this.onPointerDownEmitter.trigger(this.state.activeTool,s,e),this.state.activeTool.type===`eraser`&&this.eraserTrail.startPath(s.lastCoords.x,s.lastCoords.y);let c=this.onPointerMoveFromPointerDownHandler(s),l=this.onPointerUpFromPointerDownHandler(s),u=this.onKeyDownFromPointerDownHandler(s),d=this.onKeyUpFromPointerDownHandler(s);this.missingPointerEventCleanupEmitter.once(t=>l(t||e.nativeEvent)),(!this.state.viewModeEnabled||this.isActiveToolPointerCapturing())&&(this.ownerWindow.addEventListener(B.POINTER_MOVE,c),this.ownerWindow.addEventListener(B.POINTER_UP,l),this.ownerWindow.addEventListener(B.KEYDOWN,u),this.ownerWindow.addEventListener(B.KEYUP,d),s.eventListeners.onMove=c,s.eventListeners.onUp=l,s.eventListeners.onKeyUp=d,s.eventListeners.onKeyDown=u)}),V(this,`handleCanvasPointerUp`,e=>{if(!this.isInteractionEnabled()){(this.isLinksEnabled()||this.isEmbedsEnabled())&&this.handleInteractiveContentPointerUp(e);return}if(me(`COMPLEX_BINDINGS`)&&this.resetDelayedBindMode(),this.removePointer(e),this.lastPointerUpIsDoubleClick=this.isDoubleClick(this.lastPointerUpEvent,e),this.lastPointerUpEvent=e,!e.ctrlKey){let e=this.state.bindingPreference===`enabled`;this.state.isBindingEnabled!==e&&this.setState({isBindingEnabled:e})}let t=Qn({clientX:e.clientX,clientY:e.clientY},this.state),{x:n,y:r}=t;this.lastPointerMoveCoords={x:n,y:r},!this.handleIframeLikeCenterClick()&&!this.maybeHandleElementLinkClick(e,t)&&this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})}),V(this,`maybeOpenContextMenuAfterPointerDownOnTouchDevices`,e=>{e.pointerType===`touch`&&(EU=!1,TU?EU=!0:TU=this.ownerWindow.setTimeout(()=>{TU=0,EU||this.handleCanvasContextMenu(e)},500))}),V(this,`resetContextMenuTimer`,()=>{clearTimeout(TU),TU=0,EU=!1}),V(this,`maybeCleanupAfterMissingPointerUp`,e=>{this.pan.end(),MU?.(),this.missingPointerEventCleanupEmitter.trigger(e).clear()}),V(this,`updateMultiTouchGesture`,e=>{NU.pointers.has(e.pointerId)&&NU.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY});let t=NU.initialScale;if(NU.pointers.size===2&&NU.lastCenter&&t&&NU.initialDistance){let e=$N(NU.pointers),n=e.x-NU.lastCenter.x,r=e.y-NU.lastCenter.y;NU.lastCenter=e;let i=eP(Array.from(NU.pointers.values())),a=this.state.activeTool.type===`freedraw`&&this.state.penMode?1:i/NU.initialDistance,o=a?Io(t*a):this.state.zoom.value;this.setState(t=>{let i=ba({viewportX:e.x,viewportY:e.y,nextZoom:o},t),a=i.zoom.value;return this.viewport.translate({zoom:i.zoom,scrollX:i.scrollX+2*n/a,scrollY:i.scrollY+2*r/a,shouldCacheIgnoreZoom:!0},{zoomPreConstrained:!0}),null}),this.viewport.isLockedTransitionPending||this.resetShouldCacheIgnoreZoomDebounced()}else NU.lastCenter=NU.initialDistance=NU.initialScale=null}),V(this,`clearSelectionIfNotUsingSelection`,()=>{Oo(this.state.activeTool.type)||this.setState({selectedElementIds:yi({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}),V(this,`handleSelectionOnPointerDown`,(e,t)=>{if(Oo(this.state.activeTool.type)){let n=this.scene.getNonDeletedElements(),r=this.scene.getNonDeletedElementsMap(),i=this.scene.getSelectedElements(this.state);if(i.length===1&&!this.state.selectedLinearElement?.isEditing&&!Br(i[0])&&(!ro(i[0])||!this.editorInterface.userAgent.isMobileDevice&&i[0].points.length!==2)&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let r=Co(n,this.state,t.origin.x,t.origin.y,this.state.zoom,e.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);r!=null&&(r.transformHandleType===`rotation`?(this.setState({resizingElement:r.element}),t.resize.handleType=r.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:r.element}),t.resize.handleType=r.transformHandleType))}else i.length>1&&(t.resize.handleType=Qs(Wr(i),t.origin.x,t.origin.y,this.state.zoom,e.pointerType,this.editorInterface));if(t.resize.handleType)t.resize.isResizing=!0,t.resize.offset=yn(Le(t.resize.handleType,i,r,t.origin.x,t.origin.y)),i.length===1&&ro(i[0])&&i[0].points.length===2&&(t.resize.arrowDirection=ue(t.resize.handleType,i[0]));else{if(this.state.selectedLinearElement){let n=this.state.selectedLinearElement,r=I.handlePointerDown(e,this,this.store,t.origin,n,this.scene);if(r.hitElement&&(t.hit.element=r.hitElement),t.hit.arrowLabel=r.hitBoundText,r.linearElementEditor&&this.setState({selectedLinearElement:r.linearElementEditor}),r.didAddPoint)return!0;let i=this.scene.getNonDeletedElementsMap(),a=I.getElement(n.elementId,i);if(a&&mo(a)){let{hitFocusPoint:e,pointerOffset:r,arrowOtherEndpointInitialBinding:o}=cc(a,t,i,this.state);if(e)return this.setState({selectedLinearElement:{...n,hoveredFocusPointBinding:e,draggedFocusPointBinding:e,pointerOffset:r,initialState:{...n.initialState,arrowOtherEndpointInitialBinding:o}}}),!1}}let n=this.getElementsAtPosition(t.origin.x,t.origin.y,{includeLockedElements:!0}),r=n.filter(e=>!e.locked),i=this.getElementAtPosition(t.origin.x,t.origin.y,{allHitElements:n});if((!i||i.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),i&&i.locked&&!r.some(e=>this.state.selectedElementIds[e.id])?t.hit.element=null:t.hit.element=t.hit.element??this.getElementAtPosition(t.origin.x,t.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(t.origin,i),this.hitLinkElement)return!0;if(this.state.croppingElementId&&t.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),t.hit.element&&this.getElementLinkAtPosition({x:t.origin.x,y:t.origin.y},t.hit.element))return!1;t.hit.allHitElements=r;let a=t.hit.element,o=t.hit.allHitElements.some(e=>this.isASelectedElement(e))||a!==null&&this.isASelectedElement(a);if((a===null||!o)&&!e.shiftKey&&!t.hit.hasHitCommonBoundingBoxOfSelectedElements&&(!this.state.selectedLinearElement?.isEditing||a&&a?.id!==this.state.selectedLinearElement?.elementId)&&this.clearSelection(a),this.state.selectedLinearElement?.isEditing)this.setState(e=>({selectedLinearElement:e.selectedLinearElement?{...e.selectedLinearElement,isEditing:!!a&&a.id===this.state.selectedLinearElement?.elementId}:null,selectedElementIds:e.selectedLinearElement?yi({[e.selectedLinearElement.elementId]:!0},this.state):yi({},e)}));else if(a!=null){if(e[L.CTRL_OR_CMD])return e.altKey?(this.state.openDialog?.name===`elementLinkSelector`&&this.setOpenDialog(null),this.lassoTrail.startPath(t.origin.x,t.origin.y,e.shiftKey),this.setActiveTool({type:`lasso`,fromSelection:!0}),!1):(this.state.selectedElementIds[a.id]||(t.hit.wasAddedToSelection=!0),this.setState(e=>({...Or(e,a),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[a.id]||(this.state.editingGroupId&&!w(a,this.state.editingGroupId)&&this.setState({selectedElementIds:yi({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!o&&!t.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(e=>{let t={...e.selectedElementIds,[a.id]:!0},n=[];if(Object.keys(e.selectedElementIds).forEach(e=>{let t=this.scene.getElement(e);t&&n.push(t)}),R(a))Ti(n,a.id).forEach(e=>{delete t[e.id]});else if(a.frameId)t[a.frameId]&&delete t[a.id];else{let e=a.groupIds,r=new Set(e.flatMap(e=>Er(this.scene.getNonDeletedElements(),e)).filter(e=>R(e)).map(e=>e.id));r.size>0&&n.forEach(e=>{e.frameId&&r.has(e.frameId)&&(delete t[e.id],e.groupIds.flatMap(e=>Er(this.scene.getNonDeletedElements(),e)).forEach(e=>{delete t[e.id]}))})}return e.openDialog?.name===`elementLinkSelector`&&(a.groupIds.some(t=>e.selectedGroupIds[t])||(t={[a.id]:!0})),{...To({editingGroupId:e.editingGroupId,selectedElementIds:t},this.scene.getNonDeletedElements(),e,this),showHyperlinkPopup:a.link||Sn(a)?`info`:!1}}),t.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1}),V(this,`handleTextOnPointerDown`,(e,t)=>{if(this.state.editingTextElement)return;let n=t.origin.x,r=t.origin.y;this.setState({hoveredArrowTextAnchor:null});let i=this.arrowText.getBindableEndpointAtPosition(n,r);if(i)this.startTextEditing({sceneX:n,sceneY:r,autoEdit:!1,arrowEndpoint:i});else{let t=this.getElementAtPosition(n,r,{includeBoundTextElement:!0}),i=this.getTextBindableContainerAtPosition(n,r);if(xr(t)){i=t;let e=this.arrowText.getLabelCenter(t);e?(n=e.x,r=e.y):(n=t.x+t.width/2,r=t.y+t.height/2)}this.startTextEditing({sceneX:n,sceneY:r,insertAtParentCenter:!e.altKey,container:i,autoEdit:!1,initialCaretSceneCoords:{x:n,y:r}})}this.isToolLocked()?this.cursor.reset():this.setState({activeTool:ae(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset())}),V(this,`handleFreeDrawElementOnPointerDown`,(e,t,n)=>{let[r,i]=Po(n.origin.x,n.origin.y,null),a=this.getTopLayerFrameAtSceneCoords({x:r,y:i}),o=e.pressure===.5,s=this.state.currentItemStrokeVariability,c=je({type:t,x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(`freedraw`),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:o,strokeOptions:{variability:s,streamline:e.pointerType===`mouse`?Ms:Ae},locked:!1,frameId:a?a.id:null,points:[F(0,0)],pressures:o?[]:[e.pressure]});this.insertNewElement(c),this.setState(e=>{let t={...e.selectedElementIds};return delete t[c.id],{selectedElementIds:yi(t,e)}}),this.setState({newElement:c,suggestedBinding:null})}),V(this,`insertIframeElement`,({sceneX:e,sceneY:t,width:n,height:r})=>{let[i,a]=Po(e,t,this.lastPointerDownEvent?.[L.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),o=tr({type:`iframe`,x:i,y:a,strokeColor:`transparent`,backgroundColor:`transparent`,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(`iframe`),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness(`iframe`),opacity:this.state.currentItemOpacity,locked:!1,width:n,height:r});return this.insertNewElement(o),o}),V(this,`insertEmbeddableElement`,({sceneX:e,sceneY:t,link:n})=>{let[r,i]=Po(e,t,this.lastPointerDownEvent?.[L.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=ja(n);if(!a)return;a.error instanceof URIError&&this.setToast({message:K(`toast.unrecognizedLinkFormat`),closable:!0});let o=Ls({type:`embeddable`,x:r,y:i,strokeColor:`transparent`,backgroundColor:`transparent`,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(`embeddable`),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:n});return this.insertNewElement(o),o}),V(this,`newImagePlaceholder`,({sceneX:e,sceneY:t,addToFrameUnderCursor:n=!0})=>{let[r,i]=Po(e,t,this.lastPointerDownEvent?.[L.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=n?this.getTopLayerFrameAtSceneCoords({x:r,y:i}):null,o=100/this.state.zoom.value;return no({type:`image`,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(`image`),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:a?a.id:null,x:r-o/2,y:i-o/2,width:o,height:o})}),V(this,`handleLinearElementOnPointerDown`,(e,t,n)=>{if(e.ctrlKey&&(0,hl.flushSync)(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!==`enabled`})}),this.state.multiElement){let{multiElement:t,selectedLinearElement:r}=this.state;if(eo(r,`selectedLinearElement is expected to be set`),t.type===`line`&&bt(t.points,this.state.zoom.value)){(0,hl.flushSync)(()=>{this.setState({selectedLinearElement:{...r,lastCommittedPoint:t.points[t.points.length-1],initialState:{...r.initialState,lastClickedPoint:-1}}})}),this.actionManager.executeAction(_D);return}if(Br(t)&&t.points.length>1){this.actionManager.executeAction(_D,`ui`,{event:e.nativeEvent,sceneCoords:{x:n.origin.x,y:n.origin.y}});return}let{x:i,y:a}=t,{lastCommittedPoint:o}=r,s=Qn(e,this.state),{start:c,end:l}=mo(t)&&ze(this.state)?Xe(t,new Map([[t.points.length-1,{point:t.points[t.points.length-1],isDragging:!1}]]),s.x,s.y,this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.state,{newArrow:!!this.state.newElement,zoom:this.state.zoom}):{end:{mode:void 0}},u=this.scene.getNonDeletedElementsMap(),d=c?.mode!=null&&l.mode!=null&&c.element.id===l.element.id&&!Vn(l.focusPoint,l.element,u),f=l.mode===`orbit`&&t.startBinding?.elementId!==l.element?.id,p=o&&zt(F(n.origin.x-i,n.origin.y-a),o)<8;if(f||d||t.points.length>1&&p){this.actionManager.executeAction(_D,`ui`,{event:e.nativeEvent,sceneCoords:{x:n.origin.x,y:n.origin.y}});return}this.setState(e=>({selectedElementIds:yi({...e.selectedElementIds,[t.id]:!0},e)})),this.cursor.set(jt.POINTER)}else{let[r,i]=Po(n.origin.x,n.origin.y,e[L.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:r,y:i}),{currentItemStartArrowhead:o,currentItemEndArrowhead:s}=this.state,[c,l]=t===`arrow`?[o,s]:[null,null],u=t===`arrow`?sn({type:t,x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(t),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemArrowType===Nt.round?{type:Pa.PROPORTIONAL_RADIUS}:null,startArrowhead:c,endArrowhead:l,locked:!1,frameId:a?a.id:null,elbowed:this.state.currentItemArrowType===Nt.elbow,fixedSegments:this.state.currentItemArrowType===Nt.elbow?[]:null}):wt({type:t,x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(t),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness===`round`?{type:Pa.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:a?a.id:null}),d=F(n.origin.x,n.origin.y),f=this.scene.getNonDeletedElementsMap(),p=ze(this.state)?Et(d,this.scene.getNonDeletedElements(),f):null;this.scene.mutateElement(u,{points:[F(0,0),F(0,0)]}),this.insertNewElement(u),mo(u)&&nn(u,new Map([[0,{point:F(0,0),isDragging:!1}]]),d[0],d[1],this.scene,this.state,{newArrow:!0,altKey:e.altKey,initialBinding:!0,angleLocked:br(e.nativeEvent)}),(0,hl.flushSync)(()=>{this.setState(t=>{let r=null,i=t.selectedElementIds;if(ro(u)){r=new I(u,this.scene.getNonDeletedElementsMap());let t=u.points.length-1;r={...r,selectedPointsIndices:[t],initialState:{...r.initialState,arrowStartIsInside:e.altKey,lastClickedPoint:t,origin:F(n.origin.x,n.origin.y)}}}return i=this.isToolLocked()?t.selectedElementIds:yi({[u.id]:!0},t),{...t,bindMode:`orbit`,newElement:u,suggestedBinding:p&&mo(u)?{element:p,midPoint:go(d,p,f,this.state.zoom)}:null,selectedElementIds:i,selectedLinearElement:r}})}),mo(u)&&me(`COMPLEX_BINDINGS`)&&this.handleDelayedBindModeChange(u,p)}}),V(this,`createGenericElementOnPointerDown`,(e,t)=>{let[n,r]=Po(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[L.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),i=this.getTopLayerFrameAtSceneCoords({x:n,y:r}),a={x:n,y:r,strokeColor:e===`stickynote`?this.state.currentItemStickynoteStrokeColor:this.state.currentItemStrokeColor,backgroundColor:e===`stickynote`?this.state.currentItemStickynoteBackgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(e),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(e),locked:!1,frameId:i?i.id:null},o;o=e===`embeddable`?Ls({type:`embeddable`,...a}):e===`stickynote`?dn({type:`stickynote`,...a}):At({type:e,...a}),o.type===`selection`?this.setState({selectionElement:o}):(this.insertNewElement(o),this.setState({multiElement:null,newElement:o}))}),V(this,`createFrameElementOnPointerDown`,(e,t)=>{let[n,r]=Po(e.origin.x,e.origin.y,this.lastPointerDownEvent?.[L.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),i={x:n,y:r,opacity:this.state.currentItemOpacity,locked:!1,...sa},a=t===A.magicframe?il(i):Vo(i);this.insertNewElement(a),this.setState({multiElement:null,newElement:a})}),V(this,`restoreReadyToEraseElements`,()=>{this.elementsPendingErasure=new Set,this.triggerRender()}),V(this,`eraseElements`,()=>{let e=!1;this.elementsPendingErasure.forEach(e=>{let t=this.scene.getElement(e);if(mo(t)){if(t.startBinding){let e=this.scene.getElement(t.startBinding.elementId);Xr(e,this.scene.getElementsMapIncludingDeleted(),{boundElements:e.boundElements.filter(e=>e.id!==t.id)})}if(t.endBinding){let e=this.scene.getElement(t.endBinding.elementId);Xr(e,this.scene.getElementsMapIncludingDeleted(),{boundElements:e.boundElements.filter(e=>e.id!==t.id)})}}else $i(t)&&t.boundElements?.forEach(e=>{if(e.type===`arrow`){let n=this.scene.getElement(e.id);n?.startBinding?.elementId===t.id&&Xr(n,this.scene.getElementsMapIncludingDeleted(),{startBinding:null}),n?.endBinding?.elementId===t.id&&Xr(n,this.scene.getElementsMapIncludingDeleted(),{endBinding:null})}})});let t=this.scene.getElementsIncludingDeleted().map(t=>this.elementsPendingErasure.has(t.id)||t.frameId&&this.elementsPendingErasure.has(t.frameId)||_s(t)&&this.elementsPendingErasure.has(t.containerId)?(e=!0,j(t,{isDeleted:!0})):t);this.elementsPendingErasure=new Set,e&&(this.store.scheduleCapture(),this.scene.replaceAllElements(t))}),V(this,`initializeImage`,async(e,t)=>{if(!Tt(t))throw Error(K(`errors.unsupportedFileType`));let n=t.type;if(this.cursor.set(`wait`),n===M.svg)try{t=h(zn(await t.text()),t.name)}catch(e){throw console.warn(e),Error(K(`errors.svgImageInsertError`))}let r=await(this.props.generateIdForFile?.(t)||ns(t));if(!r)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),Error(K(`errors.imageInsertError`));if(!this.files[r]?.dataURL){let{maxWidthOrHeight:e,maxFileSizeBytes:n}=this.props.imageOptions;try{t=await ra(t,{maxWidthOrHeight:e})}catch(e){console.error(`Error trying to resizing image file on insertion`,e)}if(t.size>n)throw Error(K(`errors.fileTooBig`,{maxSize:`${Math.trunc(n/1024/1024)}MB`}))}let i=this.files[r]?.dataURL||await tn(t);return new Promise(async(t,a)=>{try{let a=this.getLatestInitializedImageElement(e,r);if(this.addMissingFiles([{mimeType:n,id:r,dataURL:i,created:Date.now(),lastRetrieved:Date.now()}]),!this.imageCache.get(r)){this.addNewImagesToImageCache();let{erroredFiles:e}=await this.updateImageCache([a]);if(e.size)throw Error(`Image cache update resulted with an error.`)}let o=await this.imageCache.get(r)?.image;if(o&&this.state.newElement?.id!==a.id){a=this.getLatestInitializedImageElement(e,r);let t=this.getImageNaturalDimensions(a,o);Object.assign(a,t)}t(a)}catch(e){console.error(e),a(Error(K(`errors.imageInsertError`)))}})}),V(this,`getLatestInitializedImageElement`,(e,t)=>{let n=this.scene.getElement(e.id)??e;return j(n,{fileId:t})}),V(this,`onImageToolbarButtonClick`,async()=>{try{let e=this.state.width/2+this.state.offsetLeft,t=this.state.height/2+this.state.offsetTop,{x:n,y:r}=Qn({clientX:e,clientY:t},this.state),i=await Uc({description:`Image`,extensions:Object.keys(Lc),multiple:!0});this.insertImages(i,n,r)}catch(e){e.name===`AbortError`?console.warn(e):console.error(e),this.setState({newElement:null,activeTool:ae(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction(_D)})}}),V(this,`getImageNaturalDimensions`,(e,t)=>{let n=Math.max(this.state.height-120,160),r=Math.min(n,Math.floor(this.state.height*.5)/this.state.zoom.value),i=Math.min(t.naturalHeight,r),a=i*(t.naturalWidth/t.naturalHeight);return{x:e.x+e.width/2-a/2,y:e.y+e.height/2-i/2,width:a,height:i,crop:null}}),V(this,`updateImageCache`,async(e,t=this.files)=>{let{updatedFiles:n,erroredFiles:r}=await c({imageCache:this.imageCache,fileIds:e.map(e=>e.fileId),files:t});return r.size&&(this.store.scheduleAction(N.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(e=>D(e)&&r.has(e.fileId)?j(e,{status:`error`}):e))),{updatedFiles:n,erroredFiles:r}}),V(this,`addNewImagesToImageCache`,async(e=Pc(this.scene.getNonDeletedElements()),t=this.files)=>{let n=e.filter(e=>!e.isDeleted&&!this.imageCache.has(e.fileId));if(n.length){let{updatedFiles:e}=await this.updateImageCache(n,t);if(e.size)for(let t of n)e.has(t.fileId)&&Nn.delete(t);e.size&&this.scene.triggerUpdate()}}),V(this,`scheduleImageRefresh`,(0,_l.default)(()=>{this.addNewImagesToImageCache()},500)),V(this,`handleInteractiveCanvasRef`,e=>{e===null?(this.interactiveCanvas?.removeEventListener(B.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(B.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas=e,this.cursor.reset(),this.interactiveCanvas.addEventListener(B.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(B.TOUCH_END,this.onTouchEnd))}),V(this,`insertImages`,async(e,t,n)=>{let r=50/this.state.zoom.value,i=he(e.map(()=>this.newImagePlaceholder({sceneX:t,sceneY:n})),t,n,r);this.insertNewElements(i);let a=await Promise.all(i.map(async(t,n)=>{try{return await this.initializeImage(t,await fn(e[n]))}catch(e){return this.setState({errorMessage:e.message||K(`errors.imageInsertError`)}),j(t,{isDeleted:!0})}})),o=d(a),s=he(a.filter(e=>!e.isDeleted),t,n,r),c=d(s),l=this.scene.getElementsIncludingDeleted().map(e=>c.get(e.id)??o.get(e.id)??e);this.updateScene({appState:{selectedElementIds:yi(Object.fromEntries(s.map(e=>[e.id,!0])),this.state)},elements:l,captureUpdate:N.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(_D)})}),V(this,`handleAppOnDrop`,async e=>{if(!this.isInteractionEnabled())return;let{x:t,y:n}=Qn(e,this.state),r=await BD(e),i=r.getFiles();if(i.length===1){let{file:e,fileHandle:t}=i[0];if(e&&(e.type===M.png||e.type===M.svg))try{let n=await ac(e,this.state,this.scene.getElementsIncludingDeleted(),t);this.syncActionResult({...n,appState:{...n.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:N.IMMEDIATELY});return}catch(e){if(e.name!==`EncodingError`)throw Error(K(`alerts.couldNotLoadInvalidFile`))}}let a=i.map(e=>e.file).filter(e=>Tt(e));if(a.length>0&&this.isToolSupported(`image`))return this.insertImages(a,t,n);let o=r.getData(M.excalidrawlibIds),s=r.getData(M.excalidrawlib);if(o||s){try{let t=null;if(o){let{itemIds:e}=JSON.parse(o);t=(await this.library.getLatestLibrary()).filter(t=>e.includes(t.id))}else s&&(t=fe(s));t?.length&&(t=t.map(e=>({...e,elements:g({type:`everything`,elements:e.elements,randomizeSeed:!0,preserveFrameChildrenOrder:!0}).duplicatedElements})),this.addElementsFromPasteOrLibrary({elements:mA(t),position:e,files:null}))}catch(e){this.setState({errorMessage:e.message})}return}if(i.length>0){let{file:e,fileHandle:t}=i[0];e&&await this.loadFileToCanvas(e,t)}let c=r.findByType(M.text);if(c){let e=c.value;if(e&&va(e,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(e)||ja(e)?.type===`video`)){let r=this.insertEmbeddableElement({sceneX:t,sceneY:n,link:cn(e)});r&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[r.id]:!0}}))}}}),V(this,`loadFileToCanvas`,async(e,t)=>{e=await fn(e);try{let n=this.scene.getElementsIncludingDeleted(),r;try{r=await ao(e,this.state,n,t)}catch(e){let t=e instanceof zs;if(t&&e.code===`IMAGE_NOT_CONTAINS_SCENE_DATA`&&!this.isToolSupported(`image`)){this.setState({isLoading:!1,errorMessage:K(`errors.imageToolNotSupported`)});return}let n=K(t?`alerts.cannotRestoreFromImage`:`alerts.couldNotLoadInvalidFile`);this.setState({isLoading:!1,errorMessage:n})}if(!r)return;r.type===M.excalidraw?(Ot(n.concat(r.data.elements)),this.store.scheduleMicroAction({action:N.NEVER,elements:n,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({...r.data,appState:{...r.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:N.IMMEDIATELY})):r.type===M.excalidrawlib&&await this.library.updateLibrary({libraryItems:e,merge:!0,openLibraryMenu:!0}).catch(e=>{console.error(e),this.setState({errorMessage:K(`errors.importLibraryError`)})})}catch(e){this.setState({isLoading:!1,errorMessage:e.message})}}),V(this,`handleCanvasContextMenu`,e=>{e.preventDefault(),!this.pan.consumesContextMenuEvent()&&this.openContextMenu({clientX:e.clientX,clientY:e.clientY,button:e.button,pointerType:`pointerType`in e.nativeEvent?e.nativeEvent.pointerType:void 0})}),V(this,`openContextMenu`,e=>{if(!this.isInteractionEnabled()||(this.bucketFill.cancel(),(e.pointerType===`touch`||e.pointerType===`pen`&&e.button!==Kn.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type))return;let{x:t,y:n}=Qn(e,this.state),r=this.getElementAtPosition(t,n,{preferSelected:!0,includeLockedElements:!0}),i=this.scene.getSelectedElements(this.state),a=this.isHittingCommonBoundingBoxOfSelectedElements({x:t,y:n},i),o=r||a?`element`:`canvas`,{top:s,left:c}=this.excalidrawContainerRef.current.getBoundingClientRect(),l=e.clientX-c,u=e.clientY-s;Vw(`contextMenu`,`openContextMenu`,o),this.setState({...r&&!this.state.selectedElementIds[r.id]?{...this.state,...To({editingGroupId:this.state.editingGroupId,selectedElementIds:{[r.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:ro(r)?new I(r,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:l,items:this.getContextMenuItems(o)}})})}),V(this,`maybeDragNewGenericElement`,(e,t,n=!0)=>{let r=this.state.selectionElement,i=e.lastCoords;if(r&&e.boxSelection.hasOccurred&&this.state.activeTool.type!==`eraser`){Za({newElement:r,elementType:this.state.activeTool.type,originX:e.origin.x,originY:e.origin.y,x:i.x,y:i.y,width:pt(e.origin.x,i.x),height:pt(e.origin.y,i.y),shouldMaintainAspectRatio:de(t),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let a=this.state.newElement;if(!a||this.arrowText.maybeDragNewText(a,i))return;let[o,s]=Po(i.x,i.y,t[L.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),c=D(a)&&this.imageCache.get(a.fileId)?.image,l=c&&!(c instanceof Promise)?c.width/c.height:null;this.maybeCacheReferenceSnapPoints(t,[a]);let{snapOffset:u,snapLines:d}=TP(a,this,t,{x:e.originInGrid.x+(this.state.originSnapOffset?.x??0),y:e.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:o-e.originInGrid.x,y:s-e.originInGrid.y},this.scene.getNonDeletedElementsMap());o+=u.x,s+=u.y,this.setState({snapLines:d}),mo(a)||Za({newElement:a,elementType:this.state.activeTool.type,originX:e.originInGrid.x,originY:e.originInGrid.y,x:o,y:s,width:pt(e.originInGrid.x,o),height:pt(e.originInGrid.y,s),shouldMaintainAspectRatio:La(a)||oe(a)?!de(t):de(t),shouldResizeFromCenter:O(t),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:l,originOffset:this.state.originSnapOffset,informMutation:n}),this.setState({newElement:a}),(this.state.activeTool.type===A.frame||this.state.activeTool.type===A.magicframe)&&this.setState({elementsToHighlight:ut(this.scene.getNonDeletedElements(),a,this.state,this.scene.getNonDeletedElementsMap())})}),V(this,`maybeHandleCrop`,(e,t)=>{if(!this.state.croppingElementId)return!1;let n=e.resize.handleType,r=e.lastCoords,[i,a]=Po(r.x-e.resize.offset.x,r.y-e.resize.offset.y,t[L.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),o=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(n&&o&&La(o)){let s=e.originalElements.get(o.id),c=D(o)&&this.imageCache.get(o.fileId)?.image;if(s&&La(s)&&c&&!(c instanceof Promise)){let[l,d]=Po(r.x,r.y,t[L.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),f={x:l-e.originInGrid.x,y:d-e.originInGrid.y};this.maybeCacheReferenceSnapPoints(t,[o]);let{snapOffset:p,snapLines:m}=wP([o],[s],this,t,f,n);this.scene.mutateElement(o,Hc(o,this.scene.getNonDeletedElementsMap(),n,c.naturalWidth,c.naturalHeight,i+p.x,a+p.y,t.shiftKey?s.width/s.height:void 0)),u(o,this.scene),this.setState({isCropping:n&&n!==`rotation`,snapLines:m})}return!0}return!1}),V(this,`maybeHandleResize`,(e,t)=>{let n=this.scene.getSelectedElements(this.state),r=n.filter(R),i=e.resize.handleType;if(r.length>0&&i===`rotation`||n.length===1&&Br(n[0])||this.state.croppingElementId)return!1;this.activeResizeHandle=i&&i!==`rotation`?i:null,this.setState({isResizing:i&&i!==`rotation`,isRotating:i===`rotation`,activeEmbeddable:null});let a=e.lastCoords,[o,s]=Po(a.x-e.resize.offset.x,a.y-e.resize.offset.y,t[L.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),c=new Map;if(r.forEach(e=>{Ti(this.scene.getNonDeletedElements(),e.id).forEach(t=>{c.set(e.id+t.id,{x:t.x-e.x,y:t.y-e.y})})}),!this.state.selectedElementsAreBeingDragged){let[r,c]=Po(a.x,a.y,t[L.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l={x:r-e.originInGrid.x,y:c-e.originInGrid.y},u=[...e.originalElements.values()];this.maybeCacheReferenceSnapPoints(t,n);let{snapOffset:d,snapLines:f}=wP(n,ot(u,this.state),this,t,l,i);o+=d.x,s+=d.y,this.setState({snapLines:f})}let l=n.some(e=>La(e))||n.length===1&&oe(n[0])&&typeof i==`string`&&i.length===2;if(ca(e.originalElements,i,n,this.scene,br(t),O(t),l?!de(t):de(t),o,s,e.resize.center.x,e.resize.center.y)){let e=new Set;return r.forEach(t=>{ut(this.scene.getNonDeletedElements(),t,this.state,this.scene.getNonDeletedElementsMap()).forEach(t=>{ea(t)?e.add(t):console.error(`[NONDELETED][INVARIANT] Skipped highlighting deleted element in resizing frame`)})}),this.setState({elementsToHighlight:[...e]}),!0}return!1}),V(this,`getContextMenuItems`,e=>{let t=[];if(t.push(PO,NO),e===`canvas`)return this.state.viewModeEnabled?[...t,IO,LO,Fj,VO]:[jO,mL,PO,NO,FO,mL,Rw,dk,mL,IO,RO,zO,BO,LO,Fj,VO];if(t.push(FO),this.state.viewModeEnabled)return[AO,...t];let n=this.editorInterface.formFactor===`desktop`?[mL,Pw,Fw,Iw,Lw]:[];return[mL,MO,AO,jO,mL,BN,VN,HN,mL,RN,mL,...t,mL,cO,lO,mL,pO,XN,HO,UO,KO,mO,mL,xO,...n,mL,EO,DO,mL,IN,mL,ck,Uk,mL,zw,uk,mL,Nw]}),V(this,`savePointer`,(e,t,n)=>{if(this.pan.isActive()||!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)||!e||!t)return;let{x:r,y:i}=Qn({clientX:e,clientY:t},this.state),a={x:r,y:i,tool:this.state.activeTool.type===`laser`?`laser`:`pointer`};this.props.onPointerUpdate?.({pointer:a,button:n,pointersMap:NU.pointers})}),V(this,`resetShouldCacheIgnoreZoomDebounced`,ws(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300)),V(this,`updateDOMRect`,e=>{if(this.excalidrawContainerRef?.current){let{width:t,height:n,left:r,top:i}=this.excalidrawContainerRef.current.getBoundingClientRect(),{width:a,height:o,offsetTop:s,offsetLeft:c}=this.state;if(t===a&&n===o&&r===c&&i===s){e&&e();return}this.setState({width:t,height:n,offsetLeft:r,offsetTop:i},()=>{e&&e()}),this.viewport.constrain()}}),V(this,`refresh`,()=>{this.setState({...this.getCanvasOffsets()})}),V(this,`watchState`,()=>{});let n=Gt(),{viewModeEnabled:r=!1,zenModeEnabled:i=!1,gridModeEnabled:a=!1,objectsSnapModeEnabled:o=!1,theme:s=n.theme,name:l=`${K(`labels.untitled`)}-${He()}`}=t,f=null;t.activeTool&&(t.activeTool.type===`image`?console.warn(`"image" tool cannot be forced via "props.activeTool"`):this.isToolSupported(t.activeTool.type,t)?f=ae(n,t.activeTool):console.warn(`"${t.activeTool.type}" tool ("props.activeTool") cannot be activated \u2014 disabled via "UIOptions.tools", or not enabled while non-interactive (see "interaction.enabled.tools")`)),this.state={...n,theme:s,exportWithDarkMode:s===P.DARK,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:!this.isInteractionEnabled(t)||r,activeTool:f??n.activeTool,zenModeEnabled:i,objectsSnapModeEnabled:o,gridModeEnabled:a??n.gridModeEnabled,name:l,width:this.ownerWindow.innerWidth,height:this.ownerWindow.innerHeight},this.refreshEditorInterface(),this.stylesPanelMode=Ea(this.editorInterface),this.id=So(),this.library=new pA(this),this.actionManager=new QN(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new ur,this.canvas=this.ownerDocument.createElement(`canvas`),this.rc=fa.canvas(this.canvas),this.renderer=new OP(this.scene),this.visibleElements=[],this.store=new $a(this),this.history=new GN(this.store),this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new xn(this.scene,this.ownerDocument),this.history=new GN(this.store),this.actionManager.registerAll(Aw),this.actionManager.registerAction(JN(this.history)),this.actionManager.registerAction(YN(this.history)),this.api=this.createExcalidrawAPI()}get ownerDocument(){return this.props.ownerDocument??this.excalidrawContainerRef.current?.ownerDocument??document}get ownerWindow(){return this.ownerDocument.defaultView??window}createExcalidrawAPI(){return{isDestroyed:!1,updateScene:this.updateScene,applyDeltas:this.applyDeltas,mutateElement:this.mutateElement,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},setViewport:this.viewport.setViewport,getViewportOffsets:this.viewport.getOffsets,setElementRenderOverrides:this.setElementRenderOverrides,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:e=>{this.actionManager.registerAction(e)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.cursor.set,resetCursor:this.cursor.reset,getEditorInterface:()=>this.editorInterface,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:e=>this.onChangeEmitter.on(e),onIncrement:e=>this.store.onStoreIncrementEmitter.on(e),onPointerDown:e=>this.onPointerDownEmitter.on(e),onPointerUp:e=>this.onPointerUpEmitter.on(e),onScrollChange:e=>this.onScrollChangeEmitter.on(e),onUserFollow:e=>this.onUserFollowEmitter.on(e),onStateChange:this.onStateChange,onEvent:this.onEvent}}isInteractionEnabled(e=this.props){return e.interaction!==!1&&typeof e.interaction!=`object`}isLinksEnabled(e=this.props){return typeof e.interaction==`object`&&e.interaction!==null?e.interaction.enabled?.links===!0||e.interaction.enabled?.interactiveContent===!0:e.interaction!==!1}isNavigationEnabled(e=this.props){return typeof e.interaction==`object`&&e.interaction!==null?e.interaction.enabled?.navigation===!0:e.interaction!==!1}isEmbedsEnabled(e=this.props){return typeof e.interaction==`object`&&e.interaction!==null?e.interaction.enabled?.embeds===!0||e.interaction.enabled?.interactiveContent===!0:e.interaction!==!1}isBrowserZoomEnabled(e=this.props){return typeof e.interaction==`object`&&e.interaction!==null&&e.interaction.enabled?.browserZoom===!0}isToolLocked(){return this.state.activeTool.locked||this.props.activeTool!=null}isActiveToolPointerCapturing(){return this.isInteractionEnabled()?this.state.activeTool.type===`laser`||this.state.activeTool.type===`custom`:this.isToolSupported(this.state.activeTool.type)}isDefaultUIEnabled(e=this.props){return e.ui!==!1&&(typeof e.ui!=`object`||e.ui===null)}isUIControlEnabled(e,t=this.props){return typeof t.ui==`object`&&t.ui!==null?t.ui.enabled?.[e]===!0:t.ui!==!1}handleSkipBindMode(){if(this.state.selectedLinearElement?.initialState&&!this.state.selectedLinearElement.initialState.arrowStartIsInside){eo(this.lastPointerMoveCoords,`Missing last pointer move coords when changing bind skip mode for arrow start`);let e=this.scene.getNonDeletedElementsMap(),t=Et(F(this.lastPointerMoveCoords.x,this.lastPointerMoveCoords.y),this.scene.getNonDeletedElements(),e),n=I.getElement(this.state.selectedLinearElement.elementId,e);n?.startBinding&&t?.id===n.startBinding.elementId&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:!0}}})}if(this.state.bindMode===`orbit`&&(this.bindModeHandler&&=(clearTimeout(this.bindModeHandler),null),(0,hl.flushSync)(()=>{this.setState({bindMode:`skip`})}),this.lastPointerMoveCoords&&this.state.selectedLinearElement?.selectedPointsIndices&&this.state.selectedLinearElement?.selectedPointsIndices.length)){let{x:e,y:t}=this.lastPointerMoveCoords,n=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;eo(n,`Last event must exist`);let r=e-this.state.selectedLinearElement.pointerOffset.x,i=t-this.state.selectedLinearElement.pointerOffset.y,a=this.state.multiElement?I.handlePointerMove(n,this,r,i,this.state.selectedLinearElement):I.handlePointDragging(n,this,r,i,this.state.selectedLinearElement);a&&this.setState(a)}}resetDelayedBindMode(){this.bindModeHandler&&=(clearTimeout(this.bindModeHandler),null),this.state.bindMode!==`orbit`&&setTimeout(()=>this.setState({bindMode:`orbit`}))}handleDelayedBindModeChange(e,t){if(e.isDeleted||Br(e))return;let n=()=>{if(this.bindModeHandler=null,eo(this.lastPointerMoveCoords,`Expected lastPointerMoveCoords to be set`),!this.state.multiElement){if(!this.state.selectedLinearElement||!this.state.selectedLinearElement.selectedPointsIndices||!this.state.selectedLinearElement.selectedPointsIndices.length)return;let t=this.state.selectedLinearElement.selectedPointsIndices.includes(0),n=this.state.selectedLinearElement.selectedPointsIndices.includes(e.points.length-1);if(!t&&!n||t&&n)return}let{x:t,y:n}=this.lastPointerMoveCoords,r=Et(F(t,n),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(r&&this.state.bindMode!==`skip`){eo(this.state.selectedLinearElement?.elementId===e.id,`The selectedLinearElement is expected to not change while a bind mode timeout is ticking`);let i=this.state.selectedLinearElement.initialState.arrowStartIsInside||e.startBinding?.elementId===r.id;(0,hl.flushSync)(()=>{eo(this.state.selectedLinearElement,`this.state.selectedLinearElement must exist`),this.setState({bindMode:`inside`,selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:i}}})});let a=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;eo(a,`Last event must exist`);let o=t-this.state.selectedLinearElement.pointerOffset.x,s=n-this.state.selectedLinearElement.pointerOffset.y,c=this.state.multiElement?I.handlePointerMove(a,this,o,s,this.state.selectedLinearElement):I.handlePointDragging(a,this,o,s,this.state.selectedLinearElement);c&&this.setState(c)}},r=!1;if(this.state.selectedLinearElement?.selectedPointsIndices){let n=this.scene.getNonDeletedElementsMap(),i=this.state.selectedLinearElement.selectedPointsIndices.includes(0),a=this.state.selectedLinearElement.selectedPointsIndices.includes(e.points.length-1),s=i?t:e.startBinding&&n.get(e.startBinding.elementId),c=a?t:e.endBinding&&n.get(e.endBinding.elementId),l=s&&o(s,n),u=c&&o(c,n);r=!!(l&&u&&s.id!==c.id&&vs(l,u))}let i=this.state.selectedLinearElement?.selectedPointsIndices?.includes(0),a=this.state.selectedLinearElement?.selectedPointsIndices?.includes(e.points.length-1),s=i?`startBinding`:a?`endBinding`:null,c=i?`endBinding`:a?`startBinding`:null,l=c&&e[c]?.mode===`inside`&&e[c]?.elementId===t?.id||s&&e[s]?.mode===`inside`&&t?.id===e[s]?.elementId;s&&c&&e[s]?.mode===`inside`&&t?.id!==e[s]?.elementId&&e[c]?.elementId!==e[s]?.elementId&&this.scene.mutateElement(e,{[s]:{...e[s],mode:`orbit`}},{informMutation:!1,isDragging:!0}),!t||this.previousHoveredBindableElement&&t.id!==this.previousHoveredBindableElement.id?(this.bindModeHandler&&=(clearTimeout(this.bindModeHandler),null),this.state.bindMode===`inside`&&(0,hl.flushSync)(()=>{this.setState({bindMode:`orbit`})}),this.previousHoveredBindableElement=null):!this.bindModeHandler&&(!this.state.newElement||!e.startBinding||r)&&!l&&(this.bindModeHandler=setTimeout(n,700)),this.previousHoveredBindableElement=t}cacheEmbeddableRef(e,t){t&&this.iFrameRefs.set(e.id,t)}getHTMLIFrameElement(e){return this.iFrameRefs.get(e.id)}isIframeLikeInteractive(e){return!Ar(e)||(e.customData?.generationData??this.magicGenerations.get(e.id))?.status!==`pending`}handleIframeLikeCenterClick(){if(!this.lastPointerDownEvent||!this.lastPointerUpEvent||this.lastPointerDownEvent.button!==Kn.MAIN||this.pan.isSpaceHeld()||!zr(this.state.activeTool.type,[`laser`,`selection`,`lasso`]))return!1;let e=F(Qn({clientX:this.lastPointerDownEvent.clientX,clientY:this.lastPointerDownEvent.clientY},this.state)),t=F(Qn({clientX:this.lastPointerUpEvent.clientX,clientY:this.lastPointerUpEvent.clientY},this.state));if(zt(e,t)>10)return!1;let n=this.getElementAtPosition(e[0],e[1]);if(!(n&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<=300&&NU.pointers.size<2&&Qt(n)&&this.isIframeLikeInteractive(n)&&(this.state.viewModeEnabled||this.state.activeTool.type===`laser`||this.isIframeLikeElementCenter(n,this.lastPointerUpEvent,t[0],t[1]))))return!1;let r=n;if(this.state.activeEmbeddable?.element===r&&this.state.activeEmbeddable?.state===`active`||(setTimeout(()=>{this.setState({activeEmbeddable:{element:r,state:`active`},selectedElementIds:{[r.id]:!0},newElement:null,selectionElement:null})},100),Ar(r)))return!0;let i=this.getHTMLIFrameElement(r);if(!i?.contentWindow)return!0;if(i.src.includes(`youtube`)){let e=DU.get(r.id);switch(e||(DU.set(r.id,or.UNSTARTED),i.contentWindow.postMessage(JSON.stringify({event:`listening`,id:r.id}),`*`)),e){case or.PLAYING:case or.BUFFERING:i.contentWindow?.postMessage(JSON.stringify({event:`command`,func:`pauseVideo`,args:``}),`*`);break;default:i.contentWindow?.postMessage(JSON.stringify({event:`command`,func:`playVideo`,args:``}),`*`)}}return i.src.includes(`player.vimeo.com`)&&i.contentWindow.postMessage(JSON.stringify({method:`paused`}),`*`),!0}isIframeLikeElementCenter(e,t,n,r){return e&&!t.altKey&&!t.shiftKey&&!t.metaKey&&!t.ctrlKey&&(this.state.activeEmbeddable?.element!==e||this.state.activeEmbeddable?.state===`hover`||!this.state.activeEmbeddable)&&n>=e.x+e.width/3&&n<=e.x+2*e.width/3&&r>=e.y+e.height/3&&r<=e.y+2*e.height/3}renderEmbeddables(){let e=this.state.zoom.value,t=this.state.width,n=this.state.height,r=this.scene.getNonDeletedElements().filter(e=>Sn(e)&&this.embedsValidationStatus.get(e.id)===!0||Ar(e));return(0,W.jsx)(W.Fragment,{children:r.map(r=>{let i=this.getElementRenderState(r),{x:a,y:o}=lc({sceneX:r.x,sceneY:r.y},this.state),s=Uo(Hi(r,i.offset),t,n,this.state,this.scene.getNonDeletedElementsMap()),c=this.initializedEmbeds.has(r.id);if(s&&!c&&this.initializedEmbeds.add(r.id),!(s||c))return null;let l,u=!1;if(Ar(r)){l=null;let e=(r.customData?.generationData??this.magicGenerations.get(r.id))||{status:`error`,message:`No generation data`,code:`ERR_NO_GENERATION_DATA`};if(e.status===`done`){let t=e.html;l={intrinsicSize:{w:r.width,h:r.height},type:`document`,srcdoc:()=>t}}else if(e.status===`pending`)l={intrinsicSize:{w:r.width,h:r.height},type:`document`,srcdoc:()=>Xi(`
|
|
82
|
+
<style>
|
|
83
|
+
html, body {
|
|
84
|
+
width: 100%;
|
|
85
|
+
height: 100%;
|
|
86
|
+
margin: 0;
|
|
87
|
+
}
|
|
88
|
+
</style>
|
|
89
|
+
<script>
|
|
90
|
+
// progressively renders the partial HTML snapshots the
|
|
91
|
+
// editor streams in during generation by document.write-
|
|
92
|
+
// ing them into this very document — feeding the
|
|
93
|
+
// browser's incremental HTML parser, so incomplete
|
|
94
|
+
// markup renders progressively
|
|
95
|
+
// (see App.onMagicFrameGenerate)
|
|
96
|
+
let writtenLength = 0;
|
|
97
|
+
let opened = false;
|
|
98
|
+
|
|
99
|
+
const onPartialMessage = (event) => {
|
|
100
|
+
const data = event.data;
|
|
101
|
+
if (
|
|
102
|
+
!data ||
|
|
103
|
+
data.type !== "excalidraw:diagramToCode:partial" ||
|
|
104
|
+
typeof data.html !== "string" ||
|
|
105
|
+
data.html.length <= writtenLength
|
|
106
|
+
) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (!opened) {
|
|
110
|
+
opened = true;
|
|
111
|
+
document.open();
|
|
112
|
+
// document.open() wipes all listeners from both the
|
|
113
|
+
// document and the window, so re-register
|
|
114
|
+
window.addEventListener("message", onPartialMessage);
|
|
115
|
+
}
|
|
116
|
+
document.write(data.html.slice(writtenLength));
|
|
117
|
+
writtenLength = data.html.length;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
window.addEventListener("message", onPartialMessage);
|
|
121
|
+
<\/script>
|
|
122
|
+
`)},u=!0;else{let t;t=e.code===`ERR_GENERATION_INTERRUPTED`?`Generation was interrupted...`:e.message||`Generation failed`,l={intrinsicSize:{w:r.width,h:r.height},type:`document`,srcdoc:()=>Xi(`
|
|
123
|
+
<style>
|
|
124
|
+
html, body {
|
|
125
|
+
height: 100%;
|
|
126
|
+
}
|
|
127
|
+
body {
|
|
128
|
+
display: flex;
|
|
129
|
+
flex-direction: column;
|
|
130
|
+
align-items: center;
|
|
131
|
+
justify-content: center;
|
|
132
|
+
color: ${Ma.red[3]};
|
|
133
|
+
}
|
|
134
|
+
h1, h3 {
|
|
135
|
+
margin-top: 0;
|
|
136
|
+
margin-bottom: 0.5rem;
|
|
137
|
+
}
|
|
138
|
+
</style>
|
|
139
|
+
<h1>Error!</h1>
|
|
140
|
+
<h3>${t}</h3>
|
|
141
|
+
`)}}}else l=ja(Os(r.link||``));let d=this.state.activeEmbeddable?.element===r&&this.state.activeEmbeddable?.state===`active`,f=this.state.activeEmbeddable?.element===r&&this.state.activeEmbeddable?.state===`hover`,m=l?.type===`video`,h=fi(m?e:1,.75,OU);return(0,W.jsx)(`div`,{className:U(`excalidraw__embeddable-container`,{"is-hovered":f}),style:{transform:s?`translate(${a+i.offset.x*this.state.zoom.value-this.state.offsetLeft}px, ${o+i.offset.y*this.state.zoom.value-this.state.offsetTop}px) scale(${e})`:`none`,display:s?`block`:`none`,opacity:i.opacity*(this.state.openDialog?.name===`elementLinkSelector`?p:1),"--embeddable-radius":`${v(Math.min(r.width,r.height),r)}px`},children:(0,W.jsxs)(`div`,{className:`excalidraw__embeddable-container__inner`,style:{width:s?`${r.width}px`:0,height:s?`${r.height}px`:0,transform:s?`rotate(${r.angle}rad)`:`none`,pointerEvents:d?aa.enabled:aa.disabled},children:[f&&(0,W.jsx)(`div`,{className:`excalidraw__embeddable-hint`,children:K(`buttons.embeddableInteractionButton`)}),(0,W.jsx)(`div`,{className:`excalidraw__embeddable__outer`,style:{padding:`${r.strokeWidth}px`},children:(0,W.jsx)(`div`,{className:`excalidraw__embeddable__content`,style:{width:`${h*100}%`,height:`${h*100}%`,transform:`scale(${1/h})`},children:(Sn(r)?this.props.renderEmbeddable?.(r,this.state):null)??(0,W.jsx)(`iframe`,{ref:e=>this.cacheEmbeddableRef(r,e),className:`excalidraw__embeddable`,srcDoc:l?.type===`document`?l.srcdoc(this.state.theme):void 0,src:l?.type===`document`?void 0:l?.link??``,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:`${l?.sandbox?.allowSameOrigin?`allow-same-origin`:``} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})}),u&&(0,W.jsxs)(`div`,{className:`excalidraw__embeddable__generating`,children:[(0,W.jsx)(Ow,{size:`1em`}),`Generating…`]})]})},r.id)})})}render(){let e=this.scene.getSelectedElements(this.state),{renderTopRightUI:t,renderTopLeftUI:n,renderCustomStats:r}=this.props,{elementsMap:i,visibleElements:a,canvasNonce:o,newElementCanvasElement:s}=this.renderer.getRenderableElements({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,editingTextElement:this.state.editingTextElement,newElement:this.state.newElement,selectedElements:e,selectedElementsAreBeingDragged:this.state.selectedElementsAreBeingDragged,frameToHighlight:this.state.frameToHighlight});this.visibleElements=a,this.hasRenderableElements=i.size>0;let c=this.scene.getNonDeletedElementsMap(),l=s??this.toolDrag.preview,u=`setPointerCapture`in this.ownerWindow.HTMLElement.prototype?!1:this.state.selectionElement||this.state.newElement||this.state.selectedElementsAreBeingDragged||this.state.resizingElement||this.state.activeTool.type===`laser`&&this.state.cursorButton===`down`,d=e[0],f=Kb.get(bk)?.type===`panel`;return(0,W.jsx)(`div`,{translate:`no`,className:U(`excalidraw excalidraw-container notranslate`,this.props.className,{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name===`elementLinkSelector`,"excalidraw--mobile":this.editorInterface.formFactor===`phone`,"excalidraw--non-interactive":!this.isInteractionEnabled(),"excalidraw--navigation":!this.isInteractionEnabled()&&this.isNavigationEnabled(),"excalidraw--tools":!this.isInteractionEnabled()&&this.isToolSupported(this.state.activeTool.type),"excalidraw--embeds":!this.isInteractionEnabled()&&this.isEmbedsEnabled(),"excalidraw--allow-browser-zoom":!this.isInteractionEnabled()&&this.isBrowserZoomEnabled(),"excalidraw--ui-hidden":!this.isDefaultUIEnabled(),"excalidraw--mobile-toolbar":this.editorInterface.formFactor===`phone`&&this.isDefaultUIEnabled()&&!this.state.viewModeEnabled,"excalidraw--viewport-status-border":!!this.props.viewportStatusFrame?.border,"excalidraw--viewport-status-label":!!this.props.viewportStatusFrame?.label,"excalidraw--zen-mode":this.state.zenModeEnabled}),style:{"--ui-pointerEvents":u?aa.disabled:aa.enabled,"--right-sidebar-width":`${XI}px`},ref:this.excalidrawContainerRef,onDrop:this.isInteractionEnabled()?this.handleAppOnDrop:void 0,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally||!this.isInteractionEnabled()?void 0:this.onKeyDown,onPointerEnter:this.isInteractionEnabled()?this.toggleOverscrollBehavior:void 0,onPointerLeave:this.isInteractionEnabled()?this.toggleOverscrollBehavior:void 0,children:(0,W.jsx)(cU.Provider,{value:this.api,children:(0,W.jsx)(QH.Provider,{value:this,children:(0,W.jsx)($H.Provider,{value:this.props,children:(0,W.jsx)(rU.Provider,{value:this.excalidrawContainerValue,children:(0,W.jsx)(tU.Provider,{value:this.editorInterface,children:(0,W.jsx)(oU.Provider,{value:this.setAppState,children:(0,W.jsx)(aU.Provider,{value:this.state,children:(0,W.jsxs)(iU.Provider,{value:this.scene.getNonDeletedElements(),children:[(0,W.jsxs)(sU.Provider,{value:this.actionManager,children:[(0,W.jsx)(KV,{canvas:this.canvas,appState:this.state,defaultUIEnabled:this.isDefaultUIEnabled(),zoomUIEnabled:this.isUIControlEnabled(`zoom`),scrollBackToContentUIEnabled:this.isUIControlEnabled(`scrollBackToContent`),files:this.files,setAppState:this.setAppState,actionManager:this.actionManager,elements:this.scene.getNonDeletedElements(),onLockToggle:this.toggleLock,onPenModeToggle:this.togglePenMode,langCode:tx().code,renderTopLeftUI:n,renderTopRightUI:t,renderCustomStats:r,showExitZenModeBtn:typeof this.props?.zenModeEnabled>`u`&&this.state.zenModeEnabled,UIOptions:this.props.UIOptions,onExportImage:this.onExportImage,renderWelcomeScreen:!this.state.isLoading&&this.state.showWelcomeScreen&&this.state.activeTool.type===this.state.preferredSelectionTool.type&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,currentUserControls:this.props.currentUserControls,children:this.props.children}),(0,W.jsx)(`div`,{className:`excalidraw-textEditorContainer`}),(0,W.jsx)(`div`,{className:`excalidraw-contextMenuContainer`}),(0,W.jsx)(`div`,{className:`excalidraw-eye-dropper-container`}),(0,W.jsx)(JV,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail,this.drawShape.trail]}),this.isDefaultUIEnabled()&&(0,W.jsx)(YH,{}),this.isDefaultUIEnabled()&&e.length===1&&this.state.openDialog?.name!==`elementLinkSelector`&&this.state.showHyperlinkPopup&&(0,W.jsx)(ek,{element:d,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},d.id),this.isDefaultUIEnabled()&&this.props.aiEnabled!==!1&&e.length===1&&fc(d)&&(0,W.jsx)(jP,{element:d,elementsMap:i,children:(0,W.jsx)(qV,{title:K(`labels.convertToCode`),icon:BC,checked:!1,onChange:()=>this.onMagicFrameGenerate(d,`button`)})}),this.isDefaultUIEnabled()&&e.length===1&&Ar(d)&&d.customData?.generationData?.status===`done`&&(0,W.jsxs)(jP,{element:d,elementsMap:i,children:[(0,W.jsx)(qV,{title:K(`labels.copySource`),icon:TC,checked:!1,onChange:()=>this.onIframeSrcCopy(d)}),(0,W.jsx)(qV,{title:`Enter fullscreen`,icon:VC,checked:!1,onChange:()=>{let e=this.getHTMLIFrameElement(d);if(e)try{e.requestFullscreen(),this.setState({activeEmbeddable:{element:d,state:`active`},selectedElementIds:{[d.id]:!0},newElement:null,selectionElement:null})}catch(e){console.warn(e),this.setState({errorMessage:`Couldn't enter fullscreen`})}}})]}),this.isDefaultUIEnabled()&&this.state.contextMenu&&(0,W.jsx)(hL,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:e=>{this.setState({contextMenu:null},()=>{this.focusContainer(),e?.()})}}),(0,W.jsx)(LH,{canvas:this.canvas,rc:this.rc,elementsMap:i,allElementsMap:c,visibleElements:this.elementRenderOffsets.size?this.renderer.getVisibleElementsWithRenderOffsets(a,i,this.state,this.elementRenderOffsets):a,canvasNonce:o,selectionNonce:this.state.selectionElement?.versionNonce,scale:this.ownerWindow.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:lP(this),renderLinks:this.isLinksEnabled(),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowchart.pendingNodes,theme:this.state.theme,...this.getRenderOverrideConfig()}}),l&&(0,W.jsx)(VH,{appState:this.state,newElement:l,scale:this.ownerWindow.devicePixelRatio,rc:this.rc,elementsMap:i,allElementsMap:c,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null,theme:this.state.theme,...this.getRenderOverrideConfig()},opacity:this.toolDrag.preview?jI:void 0}),(0,W.jsx)(PH,{app:this,containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:i,visibleElements:a,allElementsMap:c,selectedElements:e,canvasNonce:o,selectionNonce:this.state.selectionElement?.versionNonce,scale:this.ownerWindow.devicePixelRatio,appState:this.state,renderScrollbars:this.props.renderScrollbars===!0,editorInterface:this.editorInterface,interactionEnabled:this.isInteractionEnabled(),navigationEnabled:this.isNavigationEnabled(),renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onClick:this.handleCanvasClick,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.props.viewportStatusFrame?.border&&this.editorInterface.formFactor===`phone`&&(0,W.jsx)(gL,{border:this.props.viewportStatusFrame.border}),this.renderFrameNames(),this.isDefaultUIEnabled()&&this.state.activeLockedId&&(0,W.jsx)(ZH,{app:this,activeLockedId:this.state.activeLockedId}),this.isDefaultUIEnabled()&&f&&(0,W.jsx)(Vk,{app:this})]}),this.renderEmbeddables()]})})})})})})})})})}setPlugins(e){Object.assign(this.plugins,e)}async onMagicFrameGenerate(e,t){let n=this.plugins.diagramToCode?.generate;if(!n){this.setState({errorMessage:`No diagram to code plugin found`});return}let r=Ji(this.scene.getNonDeletedElements(),e,this.scene.getNonDeletedElementsMap()).filter(e=>!fc(e));if(!r.length){t===`button`?(this.setState({errorMessage:`Cannot generate from an empty frame`}),Vw(`ai`,`generate (no-children)`,`d2c`)):this.setActiveTool({type:`magicframe`});return}let i=this.insertIframeElement({sceneX:e.x+e.width+30,sceneY:e.y,width:e.width,height:e.height});if(i){this.updateMagicGeneration({frameElement:i,data:{status:`pending`}}),this.setState({selectedElementIds:{[i.id]:!0}}),Vw(`ai`,`generate (start)`,`d2c`);try{let{html:t}=await n({frame:e,children:r,onPartial:e=>{if(this.magicGenerations.get(i.id)?.status!==`pending`)return;let t=e.search(/<!doctype html|<html[\s>]/i);t!==-1&&this.getHTMLIFrameElement(i)?.contentWindow?.postMessage({type:`excalidraw:diagramToCode:partial`,html:e.slice(t)},`*`)}});if(Vw(`ai`,`generate (success)`,`d2c`),!t.trim()){this.updateMagicGeneration({frameElement:i,data:{status:`error`,code:`ERR_OAI`,message:`Nothing genereated :(`}});return}let a=t.includes(`<!DOCTYPE html>`)&&t.includes(`</html>`)?t.slice(t.indexOf(`<!DOCTYPE html>`),t.indexOf(`</html>`)+7):t;this.updateMagicGeneration({frameElement:i,data:{status:`done`,html:a}})}catch(e){Vw(`ai`,`generate (failed)`,`d2c`),this.updateMagicGeneration({frameElement:i,data:{status:`error`,code:`ERR_OAI`,message:e.message||`Unknown error during generation`}})}}}onIframeSrcCopy(e){e.customData?.generationData?.status===`done`&&(UD(e.customData.generationData.html),this.setToast({message:`copied to clipboard`,closable:!1,duration:1500}))}clearImageShapeCache(e){let t=e??this.files;this.scene.getNonDeletedElements().forEach(e=>{D(e)&&t[e.fileId]&&(this.imageCache.delete(e.fileId),Nn.delete(e))})}async componentDidMount(){this.unmounted=!1,this.api=this.createExcalidrawAPI(),this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,(ei()||rt())&&(this.setState.bind(this),Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...e)=>this.setState(...e)},app:{configurable:!0,value:this},history:{configurable:!0,value:this.history},store:{configurable:!0,value:this.store},fonts:{configurable:!0,value:this.fonts}})),this.store.onDurableIncrementEmitter.on(e=>{this.history.record(e.delta)}),this.props.onIncrement&&this.store.onStoreIncrementEmitter.on(e=>{this.props.onIncrement?.(e)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),typeof this.ownerWindow.ResizeObserver==`function`&&this.excalidrawContainerRef.current&&(this.resizeObserver=new this.ownerWindow.ResizeObserver(()=>{this.refreshEditorInterface(),this.updateDOMRect()}),this.resizeObserver?.observe(this.excalidrawContainerRef.current)),new URLSearchParams(this.ownerWindow.location.search.slice(1)).has(`web-share-target`)?this.restoreFileFromShare():this.updateDOMRect(this.initializeScene),Re()&&!Bi()&&this.setState({errorMessage:(0,W.jsx)(dL,{})});let e={excalidrawAPI:this.api,container:this.excalidrawContainerRef.current};this.editorLifecycleEvents.emit(`editor:mount`,e),this.props.onMount?.(e),this.props.onExcalidrawAPI?.(this.api)}componentWillUnmount(){this.api={...this.api,isDestroyed:!0};for(let e of Object.keys(this.api))(e.startsWith(`get`)||e===`onStateChange`||e===`onEvent`)&&typeof this.api[e]==`function`&&(this.api[e]=()=>{throw Error("ExcalidrawAPI is no longer usable after the editor has been unmounted and will return invalid/empty data. You should check for `ExcalidrawAPI.isDestroyed` before calling get* methods on subscribing to state/event changes.")});this.editorLifecycleEvents.emit(`editor:unmount`),this.props.onUnmount?.(),this.props.onExcalidrawAPI?.(null),this.elementRenderOverrides=new Map,this.elementRenderOffsets=new Map,this.ownerWindow.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new ur,this.fonts=new xn(this.scene,this.ownerDocument),this.renderer=new OP(this.scene),this.files={},this.imageCache.clear(),this.resizeObserver?.disconnect(),this.unmounted=!0,this.viewport.destroy(),this.removeEventListeners(),this.library.destroy(),this.laserTrails.stop(),this.drawShape.stop(),this.toolDrag.cancel(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),this.store.onStoreIncrementEmitter.clear(),this.store.onDurableIncrementEmitter.clear(),this.appStateObserver.clear(),this.editorLifecycleEvents.clear(),Nn.destroy(),cP.destroy(),clearTimeout(TU),Jc.clearCache(),To.clearCache(),TU=0,this.ownerDocument.documentElement.style.overscrollBehaviorX=``}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){if(this.removeEventListeners(),this.onRemoveEventListenersEmitter.once(vo(this.ownerWindow,B.MESSAGE,this.onWindowMessage,!1),vo(this.ownerDocument,B.POINTER_UP,this.removePointer,{passive:!1}),vo(this.ownerDocument.fonts,`loadingdone`,e=>{let t=e.fontfaces;this.fonts.onLoaded(t)},{passive:!1}),vo(this.ownerWindow,B.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.isInteractionEnabled()){this.isNavigationEnabled()&&this.onRemoveEventListenersEmitter.once(vo(this.excalidrawContainerRef.current,B.WHEEL,this.wheel.handle,{passive:!1}),vo(this.props.handleKeyboardGlobally?this.ownerDocument:this.excalidrawContainerRef.current,B.KEYDOWN,this.handleNavigationModeKeyDown,!1),vo(this.ownerDocument,B.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),vo(this.ownerDocument,B.GESTURE_START,this.onGestureStart,!1),vo(this.ownerDocument,B.GESTURE_CHANGE,this.onGestureChange,!1),vo(this.ownerDocument,B.GESTURE_END,this.onGestureEnd,!1)),this.isBrowserZoomEnabled()||(this.isNavigationEnabled()||this.onRemoveEventListenersEmitter.once(vo(this.excalidrawContainerRef.current,B.WHEEL,this.wheel.preventBrowserZoom,{passive:!1}),vo(this.excalidrawContainerRef.current,B.GESTURE_START,this.disableEvent,!1),vo(this.excalidrawContainerRef.current,B.GESTURE_CHANGE,this.disableEvent,!1),vo(this.excalidrawContainerRef.current,B.GESTURE_END,this.disableEvent,!1)),this.onRemoveEventListenersEmitter.once(vo(this.props.handleKeyboardGlobally?this.ownerDocument:this.excalidrawContainerRef.current,B.KEYDOWN,this.preventBrowserZoomKeyDown,!1)));return}this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(vo(this.ownerDocument,B.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(vo(this.excalidrawContainerRef.current,B.WHEEL,this.wheel.handle,{passive:!1}),vo(this.ownerDocument,B.COPY,this.onCopy,{passive:!1}),vo(this.ownerDocument,B.KEYUP,this.onKeyUp,{passive:!0}),vo(this.ownerDocument,B.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),vo(this.ownerDocument,B.GESTURE_START,this.onGestureStart,!1),vo(this.ownerDocument,B.GESTURE_CHANGE,this.onGestureChange,!1),vo(this.ownerDocument,B.GESTURE_END,this.onGestureEnd,!1)),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(vo(this.ownerDocument,B.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),vo(this.ownerDocument,B.PASTE,this.pasteFromClipboard,{passive:!1}),vo(this.ownerDocument,B.CUT,this.onCut,{passive:!1}),vo(this.ownerWindow,B.RESIZE,this.onResize,!1),vo(this.ownerWindow,B.UNLOAD,this.onUnload,!1),vo(this.ownerWindow,B.BLUR,this.onBlur,!1),vo(this.excalidrawContainerRef.current,B.WHEEL,this.wheel.handle,{passive:!1}),vo(this.excalidrawContainerRef.current,B.DRAG_OVER,this.disableEvent,!1),vo(this.excalidrawContainerRef.current,B.DROP,this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(vo(kr(this.excalidrawContainerRef.current),B.SCROLL,this.onScroll,{passive:!1})))}componentDidUpdate(e,t){let n=this.renderOverridesUpdatePending;if(this.renderOverridesUpdatePending=!1,n&&e===this.props&&t===this.state)return;!this._initialized&&!this.state.isLoading&&(this._initialized=!0,this.editorLifecycleEvents.emit(`editor:initialize`,this.api),this.props.onInitialize?.(this.api)),this.handleInteractionStateChange(e,t),this.handleForcedToolChange(e,t),this.appStateObserver.flush(t),this.updateEmbeddables();let r=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted(),a=(this.sessionExportThemeOverride??this.state.theme)===P.DARK;this.state.exportWithDarkMode!==a&&this.setState({exportWithDarkMode:a}),!this.state.showWelcomeScreen&&!r.length&&this.setState({showWelcomeScreen:!0}),(t.zoom.value!==this.state.zoom.value||t.scrollX!==this.state.scrollX||t.scrollY!==this.state.scrollY)&&(this.props?.onScrollChange?.(this.state.scrollX,this.state.scrollY,this.state.zoom),this.onScrollChangeEmitter.trigger(this.state.scrollX,this.state.scrollY,this.state.zoom)),Object.keys(this.state.selectedElementIds).length&&Ba(this.state)&&this.setState({activeTool:ae(this.state,{type:`selection`})}),this.state.activeTool.type===`eraser`&&t.theme!==this.state.theme&&this.cursor.applyForTool(),this.state.activeTool.type===`bucketfill`&&t.currentItemBackgroundColor!==this.state.currentItemBackgroundColor&&this.cursor.applyForTool(),t.activeTool.type===`selection`&&this.state.activeTool.type!==`selection`&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),e.langCode!==this.props.langCode&&this.updateLanguage(),Ba(t)&&!Ba(this.state)&&this.eraserTrail.endPath(),(t.openDialog?.name===`elementLinkSelector`||this.state.openDialog?.name===`elementLinkSelector`)&&t.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),e.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),e.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.excalidrawContainerRef.current?.classList.toggle(`theme--dark`,this.state.theme===P.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(_D)});let o=Object.keys(this.state.selectedElementIds);if(o.length){let e=o.filter(e=>{let t=this.scene.getElement(e);return!t||t.isDeleted});e.length&&this.setState(t=>{let n={...t.selectedElementIds};for(let t of e)delete n[t];return{selectedElementIds:yi(n,t)}})}if(this.state.editingTextElement){let e=this.scene.getElement(this.state.editingTextElement.id);(!e||e.isDeleted)&&this.setState({editingTextElement:null})}let s=this.state.editingTextElement||this.viewport.isAnimating?!1:!this.visibleElements.length&&this.hasRenderableElements;this.state.scrolledOutside!==s&&this.setState({scrolledOutside:s}),this.store.commit(i,this.state),this.state.isLoading||(this.props.onChange?.(r,this.state,this.files),this.onChangeEmitter.trigger(r,this.state,this.files))}static resetTapTwice(){bU=!1,SU=null}async insertClipboardContent(e,t,r){let{x:i,y:a}=Qn({clientX:this.viewport.lastPosition.x,clientY:this.viewport.lastPosition.y},this.state);if(e.errorMessage){this.setState({errorMessage:e.errorMessage});return}if(t.length===0&&!r&&e.mixedContent){await this.addElementsFromMixedContentPaste(e.mixedContent,{isPlainPaste:r,sceneX:i,sceneY:a});return}if(!r&&e.text){let t=CI(e.text);if(t.ok){this.setState({openDialog:{name:`charts`,data:t.data,rawText:e.text}});return}}let o=t.map(e=>e.file);if(o.length===0&&e.text&&!r){let t=e.text.trim();t.startsWith(`<svg`)&&t.endsWith(`</svg>`)&&o.push(h(t))}if(o.length>0){this.isToolSupported(`image`)?await this.insertImages(o,i,a):this.setState({errorMessage:K(`errors.imageToolNotSupported`)});return}if(e.elements){let t=e.programmaticAPI?yo(e.elements):e.elements;this.addElementsFromPasteOrLibrary({elements:t,files:e.files||null,position:this.editorInterface.formFactor===`desktop`?`cursor`:`center`,retainSeed:r,preserveFrameChildrenOrder:!0});return}if(!e.text)return;if(!r&&iF(e.text)){let t=await n(()=>import(`./dist-CYfPeupF.js`),[],import.meta.url);try{let{elements:n,files:r={}}=await t.parseMermaidToExcalidraw(e.text),i=yo(n,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:i,files:r,position:this.editorInterface.formFactor===`desktop`?`cursor`:`center`});return}catch(e){console.warn(`parsing pasted text as mermaid definition failed: ${e.message}`)}}let s=Bn(e.text).split(/\n+/).map(e=>e.trim()).filter(Boolean),c=s.map(e=>an(e)).filter(e=>va(e,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(e)||ja(e)?.type===`video`));if(!r&&c.length>0&&c.length===s.length){let e=[];for(let t of c){let n=e[e.length-1],r=this.insertEmbeddableElement({sceneX:n?n.x+n.width+20:i,sceneY:a,link:cn(t)});r&&e.push(r)}e.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(e.map(e=>[e.id,!0]))}));return}this.addTextFromPaste(e.text,r)}async addElementsFromMixedContentPaste(e,{isPlainPaste:t,sceneX:n,sceneY:r}){if(!t&&e.some(e=>e.type===`imageUrl`)&&this.isToolSupported(`image`)){let t=e.filter(e=>e.type===`imageUrl`).map(e=>e.value),i=await Promise.all(t.map(async e=>{try{return{file:await Jn(e)}}catch(e){let t=e.message;return e.cause===`FETCH_ERROR`?t=K(`errors.failedToFetchImage`):e.cause===`UNSUPPORTED`&&(t=K(`errors.unsupportedFileType`)),{errorMessage:t}}})),a=i.filter(e=>!!e.file).map(e=>e.file);await this.insertImages(a,n,r);let o=i.find(e=>!!e.errorMessage);o&&o.errorMessage&&this.setState({errorMessage:o.errorMessage})}else{let n=e.filter(e=>e.type===`text`);n.length&&this.addTextFromPaste(n.map(e=>e.value).join(`
|
|
142
|
+
|
|
143
|
+
`),t)}}addTextFromPaste(e,t=!1){let{x:n,y:r}=Qn({clientX:this.viewport.lastPosition.x,clientY:this.viewport.lastPosition.y},this.state),i={x:n,y:r,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(`text`),strokeStyle:this.state.currentItemStrokeStyle,roundness:null,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:e,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:Rs,verticalAlign:`top`,locked:!1},a=Ro({fontSize:i.fontSize,fontFamily:i.fontFamily}),o=qt(i.fontFamily),[s,,c]=yr(this.state),l=Math.max(Math.min((c-s)*.5,800),200),u=r,d=t?[e]:e.split(`
|
|
144
|
+
`),f=d.reduce((e,t,r)=>{let s=T(t).trim();if(s.length){let t=this.getTopLayerFrameAtSceneCoords({x:n,y:u}),r=Di(s,a,o),c=r.width>l,d=c?En(s,a,l):s;r=c?Di(d,a,o):r;let f=n-r.width/2,p=u-r.height/2,m=Ir({...i,x:f,y:p,text:d,originalText:s,lineHeight:o,autoResize:!c,frameId:t?t.id:null});e.push(m),u+=m.height+10}else d[r-1]?.trim()&&(u+=qo(i.fontSize,o)+10);return e},[]);f.length!==0&&(this.insertNewElements(f),this.store.scheduleCapture(),this.setState({selectedElementIds:yi(Object.fromEntries(f.map(e=>[e.id,!0])),this.state)}),!t&&f.length>1&&jU===!1&&this.editorInterface.formFactor!==`phone`&&(this.setToast({message:K(`toast.pasteAsSingleElement`,{shortcut:Z(`CtrlOrCmd+Shift+V`)}),duration:5e3}),jU=!0))}handleTextWysiwyg(e,{isExistingElement:t=!1,initialCaretSceneCoords:n=null}){let r=this.scene.getElementsMapIncludingDeleted(),i=(t,n)=>{let i=this.scene.getElement(e.id);if(!i||!z(i))return;let a=Ws(i,r),o=a&&oe(a)?a:null,s=o?Do(o,i,{originalText:t}):null;if(this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(e=>s&&e.id===o?.id&&oe(e)?j(e,s.container):e.id===i.id&&z(e)?j(e,{originalText:t,isDeleted:n??e.isDeleted,...s?.text??ps(e,Ws(e,r),r,t)}):e)]),o){let e=this.scene.getNonDeletedElement(o.id);e&&u(e,this.scene)}};this.textWysiwygSubmitHandler=QP({canvas:this.canvas,getViewportCoords:(e,t)=>{let{x:n,y:r}=lc({sceneX:e,sceneY:t},this.state);return[n-this.state.offsetLeft,r-this.state.offsetTop]},onChange:MP(t=>{i(t,!1),ea(e)&&u(e,this.scene)}),onSubmit:MP(({viaKeyboard:n,nextOriginalText:r})=>{this.textWysiwygSubmitHandler=null;let a=!r.trim();i(r,a);let o=n&&!this.isToolLocked()&&this.state.activeTool.type!==`autoshape`?e.containerId||(a?null:e.id):null;o&&(0,hl.flushSync)(()=>{this.setState(e=>({selectedElementIds:yi({...e.selectedElementIds,[o]:!0},e)}))}),a&&jn(this.scene.getNonDeletedElements(),[e]),(!a||t)&&this.store.scheduleCapture(),(0,hl.flushSync)(()=>{this.setState({newElement:null,editingTextElement:null})}),(this.isToolLocked()||this.state.activeTool.type===`autoshape`)&&this.cursor.applyForTool(),this.focusContainer()}),element:e,excalidrawContainer:this.excalidrawContainerRef.current,app:this,initialCaretSceneCoords:n,autoSelect:!this.editorInterface.isTouchScreen}),this.deselectElements(),i(e.originalText,!1)}deselectElements(){this.setState({selectedElementIds:yi({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getSelectedTextElement(e){let t=this.scene.getSelectedElements(this.state);if(t.length!==1)return null;let n=t[0];return z(n)?n:e?Ga(n,this.scene.getNonDeletedElementsMap()):null}getSelectedTextEditingContainerAtPosition(e,t){let n=this.scene.getSelectedElements(this.state);if(n.length!==1||!e||e.id!==n[0].id)return null;let r=n[0];if(z(r))return null;if(!qe(r))return;let i=this.getSelectedTextElement(r),a=this.getTextElementAtPosition(t.x,t.y);if(i&&a?.id===i.id)return r}getTextElementAtPosition(e,t){let n=this.getElementAtPosition(e,t,{includeBoundTextElement:!0});return n&&z(n)&&!n.isDeleted?n:null}getElementAtPosition(e,t,n){let r=[];if(r=n&&`allHitElements`in n?n?.allHitElements||[]:this.getElementsAtPosition(e,t,{includeBoundTextElement:n?.includeBoundTextElement,includeLockedElements:n?.includeLockedElements}),r.length>1){if(n?.preferSelected){for(let e=r.length-1;e>-1;e--)if(this.state.selectedElementIds[r[e].id])return r[e]}let i=r[r.length-1];return rs({point:F(e,t),element:i,threshold:this.getElementHitThreshold(i)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:R(i)?this.frameNameBoundsCache.get(i):null})?i:r[r.length-2]}return r.length===1?r[0]:null}getElementsAtPosition(e,t,n){let r=[],i=this.scene.getNonDeletedElementsMap();return(n?.includeBoundTextElement&&n?.includeLockedElements?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(e=>(n?.includeLockedElements||!e.locked)&&(n?.includeBoundTextElement||!(z(e)&&e.containerId)))).filter(n=>this.hitElement(e,t,n)).filter(n=>{let r=Oe(n,i);return r&&!ea(r)&&console.error(`[NONDELETED][INVARIANT] Containing frame is deleted`),r&&this.state.frameRendering.enabled&&this.state.frameRendering.clip&&!Qt(n)?Ka({x:e,y:t},r,i):!0}).filter(e=>!Qt(e)||(r.push(e),!1)).concat(r)}getElementHitThreshold(e){return Math.max(e.strokeWidth/2+.1,.85*(ta/this.state.zoom.value))}hitElement(e,t,n,r=!0){return r&&this.state.selectedElementIds[n.id]&&Zo([n],this.state,this.editorInterface)&&Ta(F(e,t),n,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(n))||Ac(F(e,t),n,this.scene.getNonDeletedElementsMap())?!0:rs({point:F(e,t),element:n,threshold:this.getElementHitThreshold(n),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:R(n)?this.frameNameBoundsCache.get(n):null})}getTextBindableContainerAtPosition(e,t){let n=this.scene.getNonDeletedElements(),r=this.scene.getSelectedElements(this.state);if(r.length===1)return Ne(r[0],!1)?r[0]:null;let i=null;for(let r=n.length-1;r>=0;--r){if(n[r].isDeleted)continue;let[a,o,s,c]=ji(n[r],this.scene.getNonDeletedElementsMap());if(ye(n[r])&&rs({point:F(e,t),element:n[r],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(n[r])})){i=n[r];break}if(a<e&&e<s&&o<t&&t<c){if(R(n[r]))continue;i=n[r];break}}return Ne(i,!1)?i:null}isEditingTextContent(){return!!this.state.editingTextElement||z(this.state.newElement)}handleHoverSelectedLinearElement(e,t,n){let r=this.scene.getNonDeletedElementsMap(),i=I.getElement(e.elementId,r);if(i){if(this.state.selectedLinearElement){let a=I.getPointIndexUnderCursor(i,r,this.state.zoom,t,n),o=I.isPointHandle(i,a),s=o?null:I.getSegmentMidpointHitCoords(e,{x:t,y:n},this.state,r);o||s?this.cursor.set(jt.POINTER):this.arrowText.isBoundTextGrabbable(i,t,n)?this.cursor.set(jt.GRAB):this.hitElement(t,n,i)&&(!Br(i)||!(i.startBinding||i.endBinding))&&(this.state.activeTool.type!==`lasso`||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(jt.MOVE),this.state.selectedLinearElement.hoverPointIndex!==a&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:a}}),I.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,s)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:s}});let c=null,l=i;(l.startBinding||l.endBinding)&&(c=ua(i,t,n,this.scene,this.state)),this.state.selectedLinearElement.hoveredFocusPointBinding!==c&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!1,hoveredFocusPointBinding:c}}),c&&this.cursor.set(jt.POINTER)}else this.cursor.set(jt.AUTO)}}updateGestureOnPointerDown(e){NU.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),NU.pointers.size===2&&(NU.lastCenter=$N(NU.pointers),NU.initialScale=this.state.zoom.value,NU.initialDistance=eP(Array.from(NU.pointers.values())))}initialPointerDownState(e){let t=Qn(e,this.state),n=this.scene.getSelectedElements(this.state),[r,i,a,o]=Wr(n),s=n.findIndex(Br)===0;return{origin:t,withCmdOrCtrl:e[L.CTRL_OR_CMD],originInGrid:yn(Po(t.x,t.y,e[L.CTRL_OR_CMD]||s?null:this.getEffectiveGridSize())),scrollbars:rF(wU,e.clientX-this.state.offsetLeft,e.clientY-this.state.offsetTop),lastCoords:{...t},originalElements:this.scene.getNonDeletedElements().reduce((e,t)=>(e.set(t.id,Gn(t)),e),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:`origin`,center:{x:(a+r)/2,y:(o+i)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,arrowLabel:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(t,n)},drag:{hasOccurred:!1,offset:null,origin:{...t},blockDragging:!1},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(e,t){if(!t.scrollbars.isOverEither||this.state.multiElement)return!1;CU=!0,t.lastCoords.x=e.clientX,t.lastCoords.y=e.clientY;let n=NP(e=>{e.target instanceof this.ownerWindow.HTMLElement&&this.handlePointerMoveOverScrollbars(e,t)}),r=MP(()=>{MU=null,CU=!1,this.cursor.applyForTool(),this.setState({cursorButton:`up`}),this.savePointer(e.clientX,e.clientY,`up`),this.ownerWindow.removeEventListener(B.POINTER_MOVE,n),this.ownerWindow.removeEventListener(B.POINTER_UP,r),n.flush()});return MU=r,this.ownerWindow.addEventListener(B.POINTER_MOVE,n),this.ownerWindow.addEventListener(B.POINTER_UP,r),!0}isASelectedElement(e){return e!=null&&this.state.selectedElementIds[e.id]}isHittingCommonBoundingBoxOfSelectedElements(e,t){if(t.length<2)return!1;let n=Math.max(ta/this.state.zoom.value,1),r=4/this.state.zoom.value,[i,a,o,s]=Wr(t);return e.x>i-r-n&&e.x<o+r+n&&e.y>a-r-n&&e.y<s+r+n}getCurrentItemRoundness(e){return this.state.currentItemRoundness===`round`?{type:In(e)?Pa.ADAPTIVE_RADIUS:Pa.PROPORTIONAL_RADIUS}:null}getCurrentItemStrokeWidth(e){return al(e,this.state.currentItemStrokeWidthKey)}maybeCacheReferenceSnapPoints(e,t,n=!1){uP({event:e,app:this,selectedElements:t})&&(n||!cP.getReferenceSnapPoints())&&cP.setReferenceSnapPoints(gP(this.scene.getNonDeletedElements(),t,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(e,t,n=!1){uP({event:e,app:this,selectedElements:t})&&(n||!cP.getVisibleGaps())&&cP.setVisibleGaps(mP(this.scene.getNonDeletedElements(),t,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(e){return MP(t=>{this.maybeHandleResize(e,t)||this.maybeDragNewGenericElement(e,t)})}onKeyUpFromPointerDownHandler(e){return MP(t=>{t.key===L.ALT&&t.preventDefault(),!this.maybeHandleResize(e,t)&&this.maybeDragNewGenericElement(e,t)})}onPointerMoveFromPointerDownHandler(e){return NP(t=>{if(this.state.openDialog?.name===`elementLinkSelector`)return;let n=Qn(t,this.state);if(this.state.activeLockedId&&this.setState({activeLockedId:null}),this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.initialState.segmentMidpoint.index){let[e,r]=Po(n.x,n.y,t[L.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),i=this.state.selectedLinearElement.initialState.segmentMidpoint.index;if(i<0){let t=I.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:e,y:r},this.state,this.scene.getNonDeletedElementsMap());i=t?I.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,t,this.scene.getNonDeletedElementsMap()):-1}let a=I.moveFixedSegment(this.state.selectedLinearElement,i,e,r,this.scene);this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!0,segmentMidPointHoveredCoords:a.segmentMidPointHoveredCoords,initialState:a.initialState}});return}let r=this.previousPointerMoveCoords??e.origin;if(this.previousPointerMoveCoords=n,e.drag.offset===null&&(e.drag.offset=yn(Go(this.scene.getSelectedElements(this.state),e.origin.x,e.origin.y))),!(t.target instanceof this.ownerWindow.HTMLElement)||this.handlePointerMoveOverScrollbars(t,e))return;if(Ba(this.state)){this.handleEraser(t,n);return}if(this.state.activeTool.type===`laser`&&this.laserTrails.addPointToPath(n.x,n.y),this.drawShape.handlePointerMove(n))return;let[i,a]=Po(n.x,n.y,t[L.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(e.resize.isResizing&&(e.lastCoords.x=n.x,e.lastCoords.y=n.y,this.maybeHandleCrop(e,t)||this.maybeHandleResize(e,t)))return!0;let o=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let r=this.state.selectedLinearElement;if(r.draggedFocusPointBinding){ia(r,o,n,this.scene,this.state,this.getEffectiveGridSize(),t.altKey),this.setState({selectedLinearElement:{...r,isDragging:!1,selectedPointsIndices:[],initialState:{...r.initialState,lastClickedPoint:-1}}});return}if(this.arrowText.maybeDragLabel(r,e,n))return;if(I.shouldAddMidpoint(this.state.selectedLinearElement,n,this.state,o)){let e=I.addMidpoint(this.state.selectedLinearElement,n,this,!t[L.CTRL_OR_CMD],this.scene);if(!e)return;(0,hl.flushSync)(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:e.pointerDownState,selectedPointsIndices:e.selectedPointsIndices,segmentMidPointHoveredCoords:null,isDragging:!0}})});return}if(r.initialState.segmentMidpoint.value!==null&&!r.initialState.segmentMidpoint.added)return;if(r.initialState.lastClickedPoint>-1){let i=I.getElement(r.elementId,o);if(i?.isDeleted)return;if(mo(i)){let e=Et(F(n.x,n.y),this.scene.getNonDeletedElements(),o);me(`COMPLEX_BINDINGS`)&&this.handleDelayedBindModeChange(i,e)}if(t.altKey&&!this.state.selectedLinearElement?.initialState?.arrowStartIsInside&&me(`COMPLEX_BINDINGS`)&&this.handleSkipBindMode(),r.initialState.lastClickedPoint===-1)return;let a=I.handlePointDragging(t,this,n.x,n.y,r);if(a){e.lastCoords.x=n.x,e.lastCoords.y=n.y,e.drag.hasOccurred=!0,(a.suggestedBinding!==this.state.suggestedBinding||!Us(a.selectedLinearElement?.selectedPointsIndices??[],this.state.selectedLinearElement?.selectedPointsIndices??[])||a.selectedLinearElement?.hoverPointIndex!==this.state.selectedLinearElement?.hoverPointIndex||a.selectedLinearElement?.customLineAngle!==this.state.selectedLinearElement?.customLineAngle||this.state.selectedLinearElement.isDragging!==a.selectedLinearElement?.isDragging||this.state.selectedLinearElement?.initialState?.altFocusPoint!==a.selectedLinearElement?.initialState?.altFocusPoint)&&this.setState(a);return}}}let s=e.hit.allHitElements.some(e=>this.isASelectedElement(e)),c=this.state.selectedLinearElement?.isEditing&&t.shiftKey&&this.state.selectedLinearElement.elementId===e.hit.element?.id;if((s||e.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!c&&!e.drag.blockDragging){let i=this.scene.getSelectedElements(this.state);if(i.length>0&&i.every(e=>e.locked))return;let a=i.some(e=>R(e))?null:this.getTopLayerFrameAtSceneCoords(n,{currentFrameId:hi(i),excludeElementIds:this.state.selectedElementIds});if(this.updateFrameToHighlight(a),e.drag.hasOccurred=!0,this.state.activeTool.type===`lasso`&&this.lassoTrail.hasCurrentTrail&&!(this.editorInterface.formFactor!==`desktop`&&e.hit.element)&&!this.state.activeTool.fromSelection)return;if(this.state.activeTool.type===`lasso`&&i.length>0&&e.drag.hasOccurred&&!this.state.activeTool.fromSelection&&this.lassoTrail.endPath(),i.length>0&&!e.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!==`active`){let a={x:n.x-e.drag.origin.x,y:n.y-e.drag.origin.y},s=[...e.originalElements.values()],c=t.shiftKey;if(c){let e=Math.abs(a.x),t=Math.abs(a.y),n=c&&e<t,r=c&&e>t;n&&(a.x=0),r&&(a.y=0)}if(this.state.croppingElementId){let t=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(t&&La(t)&&t.crop!==null&&e.hit.element===t){let e=t.crop,i=D(t)&&this.imageCache.get(t.fileId)?.image;if(i&&!(i instanceof Promise)){let a=Wc(t),s=Lr(n.x-r.x,n.y-r.y);s[0]*=i.naturalWidth/a.width,s[1]*=i.naturalHeight/a.height;let[c,l,u,d,f,p]=ji(t,o),m=Tn(rl(F(c,l),F(f,p),t.angle)),h=Tn(rl(F(u,l),F(f,p),t.angle)),g=Tn(rl(F(c,d),F(f,p),t.angle)),_=y($e(h,m)),v=y($e(g,m)),b=Lr(lt(s,_),lt(s,v)),x={...e,x:fi(e.x-b[0]*Math.sign(t.scale[0]),0,i.naturalWidth-e.width),y:fi(e.y-b[1]*Math.sign(t.scale[1]),0,i.naturalHeight-e.height)};this.scene.mutateElement(t,{crop:x});return}}}this.maybeCacheVisibleGaps(t,i),this.maybeCacheReferenceSnapPoints(t,i);let{snapOffset:l,snapLines:f}=vP(s,a,this,t,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:f}),this.state.editingFrame||ks(e,i,a,this.scene,l,t[L.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),t.altKey&&!e.hit.hasBeenDuplicated){e.hit.hasBeenDuplicated=!0;let n=this.scene.getElementsIncludingDeleted(),r=e.hit.element,i=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});r&&e.hit.wasAddedToSelection&&!i.find(e=>e.id===r.id)&&i.push(r);let a=new Map(i.map(e=>[e.id,e])),{duplicatedElements:o,duplicateElementsMap:s,elementsWithDuplicates:c,origIdToDuplicateId:l}=g({type:`in-place`,elements:n,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:a,overrides:({duplicateElement:e,origElement:t})=>({frameId:e.frameId??t.frameId,seed:Zt()})});o.forEach(t=>{e.originalElements.set(t.id,Gn(t))});let f=c.map(t=>{if(a.has(t.id)){let n=e.originalElements.get(t.id);if(n)return j(t,{x:n.x,y:n.y})}return t}),p=this.props.onDuplicate?.(f,n),m=ct(p||f,d(o));(0,hl.flushSync)(()=>{if(e.hit.element){let t=l.get(e.hit.element.id),n=t&&s.get(t);e.hit.element=n||null}e.hit.allHitElements=e.hit.allHitElements.reduce((e,t)=>{let n=l.get(t.id),r=n&&s.get(n);return r&&e.push(r),e},[]),e.drag.origin=Qn(t,this.state),this.setState(e=>({...so(o,this.scene.getNonDeletedElements(),e)})),this.scene.replaceAllElements(m),i.forEach(e=>{$i(e)&&e.boundElements?.some(e=>e.type===`arrow`)&&u(e,this.scene)}),this.maybeCacheVisibleGaps(t,i,!0),this.maybeCacheReferenceSnapPoints(t,i,!0)})}return}}if(this.state.selectionElement){if(e.lastCoords.x=n.x,e.lastCoords.y=n.y,t.altKey){this.setActiveTool({type:`lasso`,fromSelection:!0},{keepSelection:t.shiftKey}),this.lassoTrail.startPath(e.origin.x,e.origin.y,t.shiftKey),this.setAppState({selectionElement:null});return}this.maybeDragNewGenericElement(e,t)}else if(this.state.activeTool.type===`lasso`)!t.altKey&&this.state.activeTool.fromSelection?(this.setActiveTool({type:`selection`}),this.createGenericElementOnPointerDown(`selection`,e),e.lastCoords.x=n.x,e.lastCoords.y=n.y,this.maybeDragNewGenericElement(e,t),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(n.x,n.y,t.shiftKey);else{let r=this.state.newElement;if(!r)return;if(r.type===`freedraw`){let e=r.points,i=n.x-r.x,a=n.y-r.y,o=e.length>0&&e[e.length-1];if(!(o&&o[0]===i&&o[1]===a)){let n=r.simulatePressure?r.pressures:[...r.pressures,t.pressure];this.scene.mutateElement(r,{points:[...e,F(i,a)],pressures:n},{informMutation:!1,isDragging:!1}),this.setState({newElement:r})}}else if(ro(r)&&!r.isDeleted){e.drag.hasOccurred=!0;let n=r.points;eo(n.length>1,`Do not create linear elements with less than 2 points`);let o=this.state.selectedLinearElement;(!o||o.elementId!==r.id)&&(o=new I(r,this.scene.getNonDeletedElementsMap())),o&&(o.initialState.lastClickedPoint<0||o.initialState.lastClickedPoint>=n.length)&&(console.warn(`Last clicked point is out of bounds. Attempting to fix it.`),o={...o,selectedPointsIndices:[n.length-1],initialState:{...o.initialState,prevSelectedPointsIndices:null,lastClickedPoint:n.length-1},hoverPointIndex:n.length-1}),this.setState({newElement:r,...I.handlePointDragging(t,this,i,a,o)})}else e.lastCoords.x=n.x,e.lastCoords.y=n.y,this.maybeDragNewGenericElement(e,t,!1)}if(this.state.activeTool.type===`selection`){e.boxSelection.hasOccurred=!0;let n=this.scene.getNonDeletedElements();if(this.state.selectedLinearElement?.isEditing)I.handleBoxSelection(t,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let r=!0;!t.shiftKey&&Jc(n,this.state)&&(e.withCmdOrCtrl&&e.hit.element?this.setState(t=>To({...t,selectedElementIds:{[e.hit.element.id]:!0}},this.scene.getNonDeletedElements(),t,this)):r=!1);let i=this.state.selectionElement?Pn(n,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1,this.state.boxSelectionMode):[];this.setState(t=>{let n={...r&&t.selectedElementIds,...i.reduce((e,t)=>(e[t.id]=!0,e),{})};return e.hit.element&&(i.length?delete n[e.hit.element.id]:n[e.hit.element.id]=!0),t=r?t:{...t,selectedGroupIds:{},editingGroupId:null},{...To({editingGroupId:t.editingGroupId,selectedElementIds:n},this.scene.getNonDeletedElements(),t,this),selectedLinearElement:i.length===1&&ro(i[0])?new I(i[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:i.length===1&&(i[0].link||Sn(i[0]))?`info`:!1}})}}})}handlePointerMoveOverScrollbars(e,t){if(t.scrollbars.isOverHorizontal){let n=e.clientX,r=n-t.lastCoords.x;return this.viewport.translate({scrollX:this.state.scrollX-r*(wU.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),t.lastCoords.x=n,!0}if(t.scrollbars.isOverVertical){let n=e.clientY,r=n-t.lastCoords.y;return this.viewport.translate({scrollY:this.state.scrollY-r*(wU.vertical?.deltaMultiplier||1)/this.state.zoom.value}),t.lastCoords.y=n,!0}return!1}onPointerUpFromPointerDownHandler(e){return MP(t=>{let n=this.scene.getNonDeletedElementsMap();this.removePointer(t),e.drag.blockDragging=!1,e.eventListeners.onMove&&e.eventListeners.onMove.flush(),t.type===`pointerup`&&this.state.activeTool.type===A.bucketfill?this.bucketFill.handlePointerUp():this.bucketFill.cancel();let{newElement:r,resizingElement:i,croppingElementId:a,multiElement:o,activeTool:s,isResizing:c,isRotating:l,isCropping:u}=this.state;this.activeResizeHandle=null,this.setState(e=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:`up`,snapLines:$s(e.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.previousPointerMoveCoords=null,cP.setReferenceSnapPoints(null),cP.setVisibleGaps(null),this.savePointer(t.clientX,t.clientY,`up`);let d=e.hit.allHitElements,f=Qn({clientX:t.clientX,clientY:t.clientY},this.state);if(this.state.activeTool.type===`selection`&&!e.boxSelection.hasOccurred&&!e.resize.isResizing&&!d.some(e=>this.state.selectedElementIds[e.id])){let e=this.getElementAtPosition(f.x,f.y,{includeLockedElements:!0});this.isEditingTextContent()||this.store.scheduleCapture(),e?.locked?this.setState({activeLockedId:e.groupIds.length>0?e.groupIds.at(-1)||``:e.id}):this.setState({activeLockedId:null})}else this.setState({activeLockedId:null});if(me(`COMPLEX_BINDINGS`)&&this.resetDelayedBindMode(),this.setState({selectedElementsAreBeingDragged:!1,bindMode:`orbit`}),e.drag.hasOccurred&&e.hit?.element?.id){let t=n.get(e.hit.element.id);$i(t)&&t.boundElements?.filter(e=>e.type===`arrow`).map(e=>n.get(e.id)).filter(e=>Br(e)).forEach(e=>{e&&this.scene.mutateElement(e,{})})}if(this.state.selectedLinearElement?.isEditing&&!this.state.newElement&&this.state.selectedLinearElement.draggedFocusPointBinding===null){if(!e.boxSelection.hasOccurred&&e.hit?.element?.id!==this.state.selectedLinearElement.elementId&&this.state.selectedLinearElement.draggedFocusPointBinding===null)this.actionManager.executeAction(_D);else{let n=I.handlePointerUp(t,this.state.selectedLinearElement,this.state,this.scene);this.actionManager.executeAction(_D,`ui`,{event:t,sceneCoords:f,hitBoundText:e.hit.arrowLabel}),n!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:n,suggestedBinding:null})}}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let e=I.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());e&&this.scene.mutateElement(e,{})}if(this.state.selectedLinearElement.draggedFocusPointBinding?(It(this.state.selectedLinearElement,this.scene),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,draggedFocusPointBinding:null,initialState:{...this.state.selectedLinearElement.initialState,arrowOtherEndpointInitialBinding:null}}})):e.hit?.element?.id===this.state.selectedLinearElement.elementId?this.state.selectedLinearElement.isDragging&&(this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!1}}),this.actionManager.executeAction(_D,`ui`,{event:t,sceneCoords:f,hitBoundText:e.hit.arrowLabel})):this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null}),this.state.newElement&&this.state.multiElement&&ro(this.state.newElement)&&this.state.selectedLinearElement){let{multiElement:e}=this.state;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:e.points[e.points.length-1]}})}}if(this.missingPointerEventCleanupEmitter.clear(),this.ownerWindow.removeEventListener(B.POINTER_MOVE,e.eventListeners.onMove),this.ownerWindow.removeEventListener(B.POINTER_UP,e.eventListeners.onUp),this.ownerWindow.removeEventListener(B.KEYDOWN,e.eventListeners.onKeyDown),this.ownerWindow.removeEventListener(B.KEYUP,e.eventListeners.onKeyUp),this.props?.onPointerUp?.(s,e),this.onPointerUpEmitter.trigger(this.state.activeTool,e,t),r?.type===`freedraw`){let e=Qn(t,this.state),n=r.points,i=e.x-r.x,a=e.y-r.y;i===n[0][0]&&a===n[0][1]&&(a+=1e-4,i+=1e-4);let o=r.simulatePressure?[]:[...r.pressures,t.pressure];this.scene.mutateElement(r,{points:[...n,F(i,a)],pressures:o}),this.actionManager.executeAction(_D);return}if(ro(r)&&this.state.activeTool.type!==`autoshape`){let n=Qn(t,this.state),i=zt(F(n.x,n.y),F(e.origin.x,e.origin.y))*this.state.zoom.value;if((!e.drag.hasOccurred||i<20)&&r&&!o){if(this.editorInterface.isTouchScreen){let e=Math.min(this.state.width*.7/this.state.zoom.value,100);this.scene.mutateElement(r,{x:r.x-e/2,points:[F(0,0),F(e,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(_D)}else this.setState({multiElement:r,newElement:r})}else e.drag.hasOccurred&&!o&&(this.store.scheduleCapture(),ro(r)&&this.actionManager.executeAction(_D,`ui`,{event:t,sceneCoords:f}),this.setState({suggestedBinding:null}),this.isToolLocked()?this.setState({newElement:null}):this.setState(e=>({newElement:null,activeTool:ae(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:yi({...e.selectedElementIds,[r.id]:!0},e),selectedLinearElement:new I(r,this.scene.getNonDeletedElementsMap())}),()=>this.cursor.reset()),this.scene.triggerUpdate());return}if(z(r)){let e=Ri(Ro({fontSize:r.fontSize,fontFamily:r.fontFamily}),r.lineHeight);r.width<e&&this.scene.mutateElement(r,{autoResize:!0}),this.cursor.reset(),this.handleTextWysiwyg(r,{isExistingElement:!0})}if(r&&oe(r)){let n=this.state.zoom.value,i=r.width*n<10&&r.height*n<10,a;if(i){let[n,r]=Po(e.origin.x-125,e.origin.y-125,t[L.CTRL_OR_CMD]?null:this.getEffectiveGridSize());a={x:n,y:r,width:250,height:250}}else{let n=xo({fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily}),i=Math.max(r.width,n.width),o=Math.max(r.height,n.height);de(t)||(i=o=Math.max(i,o));let{originInGrid:s}=e;a={x:r.x<s.x?s.x-i:r.x,y:r.y<s.y?s.y-o:r.y,width:i,height:o}}if(this.scene.mutateElement(r,{...a,baseHeight:a.height},{informMutation:!1,isDragging:!1}),this.store.scheduleCapture(),this.scene.triggerUpdate(),s.locked){this.setState(e=>({newElement:null,selectedElementIds:yi({},e)})),this.cursor.applyForTool();return}this.cursor.reset(),this.setState({newElement:null,activeTool:ae(this.state,{type:this.state.preferredSelectionTool.type})}),this.startTextEditing({sceneX:r.x+r.width/2,sceneY:r.y+r.height/2,container:r});return}if(s.type!==`selection`&&r&&Dc(r)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(e=>e.id!==r.id),appState:{newElement:null},captureUpdate:N.NEVER});return}if(R(r)){let e=jc(this.scene.getElementsIncludingDeleted(),r,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(ki(this.scene.getElementsMapIncludingDeleted(),e,r))}if(r&&(this.scene.mutateElement(r,S(r),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),e.drag.hasOccurred){let e=Qn(t,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let e=this.scene.getElement(this.state.selectedLinearElement.elementId);if(e?.frameId){let t=Oe(e,n);t&&e&&(zo(e,t,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(e,{groupIds:[]}),ai([e],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let t=this.scene.getSelectedElements(this.state),n=this.getTopLayerFrameAtSceneCoords(e,{currentFrameId:hi(t),excludeElementIds:this.state.selectedElementIds}),r=this.scene.getElementsMapIncludingDeleted(),i=e=>{if(e.length>0){for(let t of e){let e=t.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(t,{groupIds:t.groupIds.slice(0,e)},{informMutation:!1,isDragging:!1})}r.forEach(e=>{e.groupIds.length&&Er(r,e.groupIds[e.groupIds.length-1]).length<2&&this.scene.mutateElement(e,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(n&&!this.state.selectedElementIds[n.id]){let e=t.filter(e=>za(e,r,this.state));this.state.editingGroupId&&i(e),r=ki(r,e,n)}else!n&&this.state.editingGroupId&&i(t.filter(e=>e.frameId&&!za(e,r,this.state)));r=tc(r,this.state,this),this.scene.replaceAllElements(r)}}if(i&&this.store.scheduleCapture(),i&&Dc(i)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(e=>e.id!==i.id),captureUpdate:N.NEVER}),e.resize.isResizing){let e=tc(this.scene.getElementsIncludingDeleted(),this.state,this),t=this.scene.getSelectedElements(this.state).filter(R);for(let r of t)e=Cr(e,ut(this.scene.getElementsIncludingDeleted(),r,this.state,n),r);this.scene.replaceAllElements(e)}let p=e.hit.element;this.state.selectedLinearElement?.elementId!==p?.id&&ro(p)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new I(p,this.scene.getNonDeletedElementsMap())}),(!a||a&&(!p&&!u||p&&p.id!==a))&&this.finishImageCropping();let m=this.lastPointerDownEvent,h=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(Ba(this.state)&&m&&h){if(this.eraserTrail.endPath(),zt(F(m.clientX,m.clientY),F(h.clientX,h.clientY))===0){let e=Qn({clientX:h.clientX,clientY:h.clientY},this.state);this.getElementsAtPosition(e.x,e.y).forEach(e=>this.elementsPendingErasure.add(e.id))}this.eraseElements();return}if(this.elementsPendingErasure.size&&this.restoreReadyToEraseElements(),p&&!e.drag.hasOccurred&&!e.hit.wasAddedToSelection&&(!this.state.selectedLinearElement?.isEditing||!e.boxSelection.hasOccurred)&&this.state.activeTool.type!==`lasso`&&(t.shiftKey&&!this.state.selectedLinearElement?.isEditing?this.state.selectedElementIds[p.id]?As(this.state,p)?this.setState(e=>{let t={...e.selectedElementIds};for(let e of p.groupIds.flatMap(e=>Er(this.scene.getNonDeletedElements(),e)))delete t[e.id];return{selectedGroupIds:{...e.selectedElementIds,...p.groupIds.map(e=>({[e]:!1})).reduce((e,t)=>({...e,...t}),{})},selectedElementIds:yi(t,e)}}):this.state.selectedLinearElement?.isDragging||this.setState(e=>{let t={...e.selectedElementIds};delete t[p.id];let n=ot(this.scene.getNonDeletedElements(),{selectedElementIds:t});return{...To({editingGroupId:e.editingGroupId,selectedElementIds:t},this.scene.getNonDeletedElements(),e,this),selectedLinearElement:n.length===1&&ro(n[0])?new I(n[0],this.scene.getNonDeletedElementsMap()):e.selectedLinearElement}}):p.frameId&&this.state.selectedElementIds[p.frameId]?this.setState(e=>{let t={...e.selectedElementIds,[p.id]:!0};return delete t[p.frameId],(this.scene.getElement(p.frameId)?.groupIds??[]).flatMap(e=>Er(this.scene.getNonDeletedElements(),e)).forEach(e=>{delete t[e.id]}),{...To({editingGroupId:e.editingGroupId,selectedElementIds:t},this.scene.getNonDeletedElements(),e,this),showHyperlinkPopup:p.link||Sn(p)?`info`:!1}}):this.setState(e=>({selectedElementIds:yi({...e.selectedElementIds,[p.id]:!0},e)})):this.setState(e=>({...To({editingGroupId:e.editingGroupId,selectedElementIds:{[p.id]:!0}},this.scene.getNonDeletedElements(),e,this),selectedLinearElement:ro(p)&&e.selectedLinearElement?.elementId!==p.id?new I(p,this.scene.getNonDeletedElementsMap()):e.selectedLinearElement}))),this.state.activeTool.type!==`lasso`&&!(p&&Br(p))&&!e.drag.hasOccurred&&!this.state.isResizing&&(p&&Ya({point:F(e.origin.x,e.origin.y),element:p,elementsMap:n,threshold:this.getElementHitThreshold(p),frameNameBound:R(p)?this.frameNameBoundsCache.get(p):null},n)||!p&&e.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(IN):this.setState({selectedElementIds:yi({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),this.cursor.set(jt.AUTO);return}let g=this.getSelectedTextEditingContainerAtPosition(p,f);if(s.type===this.state.preferredSelectionTool.type&&!this.state.editingTextElement&&!e.drag.hasOccurred&&!e.hit.wasAddedToSelection&&!t.shiftKey&&!t[L.CTRL_OR_CMD]&&!t.altKey&&t.pointerType!==`touch`&&p&&(z(p)&&this.state.selectedElementIds[p.id]&&this.scene.getSelectedElements(this.state).length===1||g)){this.startTextEditing({sceneX:f.x,sceneY:f.y,container:g,initialCaretSceneCoords:this.lastPointerUpIsDoubleClick?void 0:f});return}if(!this.isToolLocked()&&s.type!==`freedraw`&&r&&this.setState(e=>({selectedElementIds:yi({...e.selectedElementIds,[r.id]:!0},e),showHyperlinkPopup:Sn(r)&&!r.link?`editor`:e.showHyperlinkPopup})),!this.isEditingTextContent()&&(s.type!==`selection`||Jc(this.scene.getNonDeletedElements(),this.state)||!Us(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),e.drag.hasOccurred&&!this.state.selectedLinearElement||c||l||u){let e=this.scene.getSelectedElements(this.state).filter(ye);wn(e,this.scene,this.state)}if(s.type===`laser`){this.laserTrails.endPath();return}if(s.type===`autoshape`){this.actionManager.executeAction(_D);return}!this.isToolLocked()&&s.type!==`freedraw`&&s.type!==A.bucketfill&&(s.type!==`lasso`||s.type===`lasso`&&s.fromSelection)?this.setState({newElement:null,suggestedBinding:null,activeTool:ae(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.cursor.reset(),this.cursor.refreshHover()}):this.setState({newElement:null,suggestedBinding:null},()=>this.cursor.refreshHover())})}clearSelection(e){this.setState(t=>({selectedElementIds:yi({},t),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:t.editingGroupId&&e!=null&&w(e,t.editingGroupId)?t.editingGroupId:null})),this.setState({selectedElementIds:yi({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds,selectedLinearElement:null})}getTextWysiwygSnappedToCenterPosition(e,t,n,r){if(r){let i=r.x+r.width/2,a=r.y+r.height/2,o=Ui(r,this.scene.getNonDeletedElementsMap());if(o&&(i=o.x,a=o.y),Math.hypot(e-i,t-a)<30){let{x:e,y:t}=lc({sceneX:i,sceneY:a},n);return{viewportX:e,viewportY:t,elementCenterX:i,elementCenterY:a}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let{left:e,top:t}=this.excalidrawContainerRef.current.getBoundingClientRect();return{offsetLeft:e,offsetTop:t}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){await ex(Xb.find(e=>e.code===this.props.langCode)||Yb),this.setAppState({})}};(ei()||rt())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(Ot(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}));var FU=PU,IU=e=>{let[t,n]=(0,H.useState)(!0);return(0,H.useEffect)(()=>{let t=async()=>{await ex(r),n(!1)},r=Xb.find(t=>t.code===e.langCode)||Yb;t()},[e.langCode]),t?(0,W.jsx)(SL,{theme:e.theme}):e.children},LU=({children:e})=>{let{FooterCenterTunnel:t}=yL(),n=Kw();return(0,W.jsx)(t.In,{children:(0,W.jsx)(`div`,{className:U(`footer-center zen-mode-transition`,{"layer-ui__wrapper__footer-left--transition-bottom":n.zenModeEnabled}),children:e})})},RU=LU;LU.displayName=`FooterCenter`;var zU=({isCollaborating:e,onSelect:t,editorInterface:n,...r})=>{let i=Kw(),a=n?.formFactor!==`desktop`||i.width<1440;return(0,W.jsxs)(xj,{...r,className:U(`collab-button`,{active:e}),type:`button`,onSelect:t,style:{position:`relative`,width:a?void 0:`auto`},title:K(`labels.liveCollaboration`),children:[a?lS:K(`labels.share`),i.collaborators.size>0&&(0,W.jsx)(`div`,{className:`CollabButton-collaborators`,children:i.collaborators.size})]})},BU=zU;zU.displayName=`LiveCollaborationTrigger`;var VU=()=>(0,W.jsx)(`svg`,{viewBox:`0 0 40 40`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,className:`ExcalidrawLogo-icon`,children:(0,W.jsx)(`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`})}),HU=()=>(0,W.jsxs)(`svg`,{viewBox:`0 0 450 55`,xmlns:`http://www.w3.org/2000/svg`,fill:`none`,className:`ExcalidrawLogo-text`,children:[(0,W.jsx)(`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)`}),(0,W.jsx)(`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)`}),(0,W.jsx)(`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)`}),(0,W.jsx)(`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)`})]}),UU=({style:e,size:t=`small`,withText:n})=>(0,W.jsxs)(`div`,{className:`ExcalidrawLogo is-${t}`,style:e,children:[(0,W.jsx)(VU,{}),n&&(0,W.jsx)(HU,{})]}),WU=({icon:e,shortcut:t,children:n})=>{let r=fU();return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`welcome-screen-menu-item__icon`,children:e}),(0,W.jsx)(`div`,{className:`welcome-screen-menu-item__text`,children:n}),t&&r.formFactor!==`phone`&&(0,W.jsx)(`div`,{className:`welcome-screen-menu-item__shortcut`,children:t})]})};WU.displayName=`WelcomeScreenMenuItemContent`;var GU=({onSelect:e,children:t,icon:n,shortcut:r,className:i=``,...a})=>(0,W.jsx)(`button`,{...a,type:`button`,className:`welcome-screen-menu-item ${i}`,onClick:e,children:(0,W.jsx)(WU,{icon:n,shortcut:r,children:t})});GU.displayName=`WelcomeScreenMenuItem`;var KU=({children:e,href:t,icon:n,shortcut:r,className:i=``,...a})=>(0,W.jsx)(`a`,{...a,className:`welcome-screen-menu-item ${i}`,href:t,target:`_blank`,rel:`noopener`,children:(0,W.jsx)(WU,{icon:n,shortcut:r,children:e})});KU.displayName=`WelcomeScreenMenuItemLink`;var qU=({children:e})=>{let{WelcomeScreenCenterTunnel:t}=yL();return(0,W.jsx)(t.In,{children:(0,W.jsx)(`div`,{className:`welcome-screen-center`,children:e||(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(JU,{}),(0,W.jsx)(YU,{children:K(`welcomeScreen.defaults.center_heading`)}),(0,W.jsxs)(XU,{children:[(0,W.jsx)(QU,{}),(0,W.jsx)(ZU,{})]})]})})})};qU.displayName=`Center`;var JU=({children:e})=>(0,W.jsx)(`div`,{className:`welcome-screen-center__logo excalifont welcome-screen-decor`,children:e||(0,W.jsx)(UU,{withText:!0})});JU.displayName=`Logo`;var YU=({children:e})=>(0,W.jsx)(`div`,{className:`welcome-screen-center__heading welcome-screen-decor excalifont`,children:e});YU.displayName=`Heading`;var XU=({children:e})=>(0,W.jsx)(`div`,{className:`welcome-screen-menu`,children:e});XU.displayName=`Menu`;var ZU=()=>{let e=vU();return(0,W.jsx)(GU,{onSelect:()=>e.executeAction(uO),shortcut:`?`,icon:Ux,children:K(`helpDialog.title`)})};ZU.displayName=`MenuItemHelp`;var QU=()=>{let e=Kw(),t=vU();return e.viewModeEnabled?null:(0,W.jsx)(GU,{onSelect:()=>t.executeAction(aO),shortcut:Kk(`loadScene`),icon:$x,children:K(`buttons.load`)})};QU.displayName=`MenuItemLoadScene`;var $U=({onSelect:e})=>{let{t}=ix();return(0,W.jsx)(GU,{shortcut:null,onSelect:e,icon:wS,children:t(`labels.liveCollaboration`)})};$U.displayName=`MenuItemLiveCollaborationTrigger`,qU.Logo=JU,qU.Heading=YU,qU.Menu=XU,qU.MenuItem=GU,qU.MenuItemLink=KU,qU.MenuItemHelp=ZU,qU.MenuItemLoadScene=QU,qU.MenuItemLiveCollaborationTrigger=$U;var eW=({children:e})=>{let{WelcomeScreenMenuHintTunnel:t}=yL();return(0,W.jsx)(t.In,{children:(0,W.jsxs)(`div`,{className:`excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu`,children:[_x,(0,W.jsx)(`div`,{className:`welcome-screen-decor-hint__label`,children:e||K(`welcomeScreen.defaults.menuHint`)})]})})};eW.displayName=`MenuHint`;var tW=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:t}=yL();return(0,W.jsx)(t.In,{children:(0,W.jsxs)(`div`,{className:`excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar`,children:[(0,W.jsx)(`div`,{className:`welcome-screen-decor-hint__label`,children:e||K(`welcomeScreen.defaults.toolbarHint`)}),yx]})})};tW.displayName=`ToolbarHint`;var nW=({children:e})=>{let{WelcomeScreenHelpHintTunnel:t}=yL();return(0,W.jsx)(t.In,{children:(0,W.jsxs)(`div`,{className:`excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help`,children:[(0,W.jsx)(`div`,{children:e||K(`welcomeScreen.defaults.helpHint`)}),vx]})})};nW.displayName=`HelpHint`;var rW=e=>(0,W.jsx)(W.Fragment,{children:e.children||(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(qU,{}),(0,W.jsx)(eW,{}),(0,W.jsx)(tW,{}),(0,W.jsx)(nW,{})]})});rW.displayName=`WelcomeScreen`,rW.Center=qU,rW.Hints={MenuHint:eW,ToolbarHint:tW,HelpHint:nW};var iW=rW,aW=()=>{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}),Array.prototype.findLast||Object.defineProperty(Array.prototype,"findLast",{value:function(e,t){return this.slice().reverse().find((n,r)=>e.call(t,n,this.length-r-1,this))},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.findIndex||Object.defineProperty(Array.prototype,"findIndex",{value:function(e,t){for(let n=0;n<this.length;n++)if(e.call(t,this[n],n,this))return n;return-1},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.findLastIndex||Object.defineProperty(Array.prototype,"findLastIndex",{value:function(e,t){let n=this.slice().reverse().findIndex((n,r)=>e.call(t,n,this.length-r-1,this));return n===-1?-1:this.length-n-1},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.toReversed||Object.defineProperty(Array.prototype,"toReversed",{value:function(){return this.slice().reverse()},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.toSorted||Object.defineProperty(Array.prototype,"toSorted",{value:function(e){return this.slice().sort(e)},writable:!0,enumerable:!1,configurable:!0}),Element.prototype.replaceChildren||(Element.prototype.replaceChildren=function(...e){this.innerHTML=``,this.append(...e)})},oW=(e,t,n)=>!!(t&&(t.id===e.editingTextElement?.id||t.id===e.resizingElement?.id||t.id===e.newElement?.id||t.version>n.version||t.version===n.version&&t.versionNonce<=n.versionNonce)),sW=(0,_l.default)((e,t,n)=>{if(rt()||ei()||window?.DEBUG_FRACTIONAL_INDICES){let r=Ot(e.map(e=>({...e})));le(r,{shouldThrow:ei()||rt(),includeBoundTextValidation:!0,reconciliationContext:{localElements:t,remoteElements:n}})}},6e4,{leading:!0,trailing:!1}),cW=(e,t,n)=>{let r=d(e),i=[],a=new Set;for(let e of t)if(!a.has(e.id)){let t=r.get(e.id),o=oW(n,t,e);t&&o?(i.push(t),a.add(t.id)):(i.push(e),a.add(e.id))}for(let t of e)a.has(t.id)||(i.push(t),a.add(t.id));let o=zc(i);return sW(o,e,t),Ot(o),o},lW=({children:e,icon:t})=>{let{t:n}=ix(),{TTDDialogTriggerTunnel:r}=yL(),i=_U();return(0,W.jsx)(r.In,{children:(0,W.jsx)(Q.Item,{onSelect:()=>{Vw(`ai`,`dialog open`,`ttd`),i({openDialog:{name:`ttd`,tab:`text-to-diagram`}})},icon:t??WC,badge:(0,W.jsx)(Q.Item.Badge,{children:`AI`}),children:e??n(`labels.textToDiagram`)})})};lW.displayName=`TTDDialogTrigger`;function uW(e){let t=e.get(`X-Ratelimit-Limit`),n=e.get(`X-Ratelimit-Remaining`);return{rateLimit:t?parseInt(t,10):void 0,rateLimitRemaining:n?parseInt(n,10):void 0}}async function*dW(e){let t=new TextDecoder,n=``;try{for(;;){let{done:r,value:i}=await e.read();if(r)break;n+=t.decode(i,{stream:!0});let a=n.split(`
|
|
145
|
+
`);n=a.pop()||``;for(let e of a){let t=e.trim();t&&t.startsWith(`data: `)&&(yield t.slice(6))}}}finally{e.releaseLock()}}async function fW(e){let{url:t,messages:n,onChunk:r,onStreamCreated:i,extractRateLimits:a=!0,signal:o}=e;try{let e=``,s={},c=null,l=await fetch(t,{method:`POST`,headers:{Accept:`text/event-stream`,"Content-Type":`application/json`},body:JSON.stringify({messages:n}),signal:o});if(a&&(s=uW(l.headers)),!l.ok){if(l.status===429)return{...s,error:new Rn({message:`Rate limit exceeded`,status:429})};let e=await l.text();throw new Rn({message:e||`Generation failed...`,status:l.status})}let u=l.body?.getReader();if(!u)throw new Rn({message:`Couldn't get reader from response body`,status:500});i?.();try{for await(let t of dW(u)){if(t===`[DONE]`)break;try{let n=JSON.parse(t);if(n===null)break;switch(n.type){case`content`:{let t=n.delta;t&&(e+=t,r?.(t));break}case`error`:c=new Rn({message:n.error.message,status:500})}}catch(e){console.warn(`Failed to parse SSE data:`,t,e)}}}catch(e){c=e.name===`AbortError`?new Rn({message:`Request aborted`,status:499}):new Rn({message:e.message||`Streaming error`,status:500})}return c?{...s,error:c}:e?{generatedResponse:e,error:null,...s}:{...s,error:new Rn({message:`Generation failed...`,status:l.status})}}catch(e){return e.name===`AbortError`?{error:new Rn({message:`Request aborted`,status:499})}:{error:new Rn({message:e.message||`Request failed`,status:500})}}}var pW=e=>{let t=uU();return(0,H.useLayoutEffect)(()=>{t.setPlugins({diagramToCode:{generate:e.generate}})},[t,e.generate]),null};aW();var mW=({children:e})=>{let[t,n]=(0,H.useState)(null);return(0,W.jsx)(cU.Provider,{value:t,children:(0,W.jsx)(lU.Provider,{value:n,children:e})})},hW=H.memo(e=>{let{onExport:t,className:r,ownerDocument:i=document,onChange:a,onThemeChange:o,onIncrement:s,initialData:c,initialState:l,onExcalidrawAPI:u,onMount:d,onUnmount:f,onInitialize:p,isCollaborating:m=!1,onPointerUpdate:h,renderTopLeftUI:g,renderTopRightUI:_,langCode:v=Yb.code,viewModeEnabled:y,interaction:b,ui:x,activeTool:S,zenModeEnabled:C,gridModeEnabled:w,libraryReturnUrl:T,theme:E,name:D,renderCustomStats:ee,onPaste:te,detectScroll:O=!0,handleKeyboardGlobally:k=!1,onLibraryChange:A,autoFocus:ne=!1,generateIdForFile:re,onLinkOpen:ie,generateLinkForSelection:ae,onPointerDown:oe,onPointerUp:se,onScrollChange:ce,onUserFollow:le,userToFollow:ue,onDuplicate:de,children:j,validateEmbeddable:fe,renderEmbeddable:pe,aiEnabled:me,showDeprecatedFonts:he,renderScrollbars:ge,viewportStatusFrame:_e,currentUserControls:ve,imageOptions:ye}=e,be=e.UIOptions?.canvasActions,xe={...e.UIOptions,canvasActions:{...Xn.canvasActions,...be},tools:{image:e.UIOptions?.tools?.image??!0}};be?.export&&(xe.canvasActions.export.saveFileToDisk=be.export?.saveFileToDisk??Xn.canvasActions.export.saveFileToDisk),xe.canvasActions.toggleTheme===null&&(E==null||o)&&(xe.canvasActions.toggleTheme=!0);let Se={maxFileSizeBytes:ye?.maxFileSizeBytes??Ut.maxFileSizeBytes,maxWidthOrHeight:ye?.maxWidthOrHeight??Ut.maxWidthOrHeight},Ce=(0,H.useContext)(lU),we=(0,H.useRef)(u);we.current=u;let Te=(0,H.useCallback)(e=>{Ce?.(e),we.current?.(e)},[Ce]),Ee=typeof b==`object`&&!!b&&b.enabled?.browserZoom===!0&&b.enabled?.navigation!==!0;return(0,H.useEffect)(()=>{if((async()=>{await n(()=>import(`./roundRect-D01gJrlt.js`),[],import.meta.url)})(),Ee)return;let e=e=>{typeof e.scale==`number`&&e.scale!==1&&e.preventDefault()};return i.addEventListener(`touchmove`,e,{passive:!1}),()=>{i.removeEventListener(`touchmove`,e)}},[Ee,i]),(0,W.jsx)(Gb,{store:Kb,children:(0,W.jsx)(IU,{langCode:v,theme:E,children:(0,W.jsx)(FU,{onExport:t,className:r,ownerDocument:i,onChange:a,onThemeChange:o,onIncrement:s,initialData:c,initialState:l,onExcalidrawAPI:Te,onMount:d,onUnmount:f,onInitialize:p,isCollaborating:m,onPointerUpdate:h,renderTopLeftUI:g,renderTopRightUI:_,langCode:v,viewModeEnabled:y,interaction:b,ui:x,activeTool:S,zenModeEnabled:C,gridModeEnabled:w,libraryReturnUrl:T,theme:E,name:D,renderCustomStats:ee,UIOptions:xe,onPaste:te,detectScroll:O,handleKeyboardGlobally:k,onLibraryChange:A,autoFocus:ne,generateIdForFile:re,onLinkOpen:ie,generateLinkForSelection:ae,onPointerDown:oe,onPointerUp:se,onScrollChange:ce,onUserFollow:le,userToFollow:ue,onDuplicate:de,validateEmbeddable:fe,renderEmbeddable:pe,aiEnabled:me!==!1,showDeprecatedFonts:he,renderScrollbars:ge,viewportStatusFrame:_e,currentUserControls:ve,imageOptions:Se,children:j})})})},(e,t)=>{if(e.children!==t.children)return!1;let{initialData:n,UIOptions:r={},imageOptions:i,interaction:a,ui:o,activeTool:s,...c}=e,{initialData:l,UIOptions:u={},imageOptions:d,interaction:f,ui:p,activeTool:m,...h}=t;if(!(s===m||s?.type===m?.type&&(s?.type===`custom`?s.customType:null)===(m?.type===`custom`?m.customType:null))||!(a===f||typeof a==`object`&&a&&typeof f==`object`&&f&&!!a.enabled?.links==!!f.enabled?.links&&!!a.enabled?.embeds==!!f.enabled?.embeds&&!!a.enabled?.interactiveContent==!!f.enabled?.interactiveContent&&!!a.enabled?.navigation==!!f.enabled?.navigation&&!!a.enabled?.browserZoom==!!f.enabled?.browserZoom&&!!a.enabled?.tools?.laser==!!f.enabled?.tools?.laser&&!!a.enabled?.tools?.custom==!!f.enabled?.tools?.custom)||!(o===p||typeof o==`object`&&o&&typeof p==`object`&&p&&!!o.enabled?.zoom==!!p.enabled?.zoom&&!!o.enabled?.scrollBackToContent==!!p.enabled?.scrollBackToContent))return!1;let g=Object.keys(r),_=Object.keys(u);if(g.length!==_.length)return!1;let v=g.every(e=>e===`getFormFactor`?!0:e===`canvasActions`?Object.keys(r.canvasActions).every(e=>e===`export`&&r?.canvasActions?.export&&u?.canvasActions?.export?r.canvasActions.export.saveFileToDisk===u.canvasActions.export.saveFileToDisk:r?.canvasActions?.[e]===u?.canvasActions?.[e]):r[e]===u[e]),y=(i?.maxWidthOrHeight??Ut.maxWidthOrHeight)===(d?.maxWidthOrHeight??Ut.maxWidthOrHeight)&&(i?.maxFileSizeBytes??Ut.maxFileSizeBytes)===(d?.maxFileSizeBytes??Ut.maxFileSizeBytes);return v&&y&&Us(c,h)});hW.displayName=`Excalidraw`;function gW(e){return zE(e,!1)}export{dA as A,$k as C,cU as D,wA as E,hW as F,gW as I,mW as L,yB as M,Yb as N,BE as O,pW as P,JF as R,dV as S,Xb as T,CI as _,iW as a,BU as b,Qk as c,yU as d,ix as f,lW as g,JR as h,GT as i,SA as j,pU as k,dW as l,TI as m,eA as n,gA as o,xj as p,RU as r,QL as s,tA as t,kR as u,cW as v,fU as w,lM as x,fW as y,ml as z};
|