@myoc/excalidraw 0.18.19 → 0.18.21

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.
Files changed (96) hide show
  1. package/dist/dev/{chunk-WD4YVUU4.js → chunk-DUURZLYX.js} +2 -2
  2. package/dist/dev/chunk-XJGMBAJT.js +5684 -0
  3. package/dist/dev/chunk-XJGMBAJT.js.map +7 -0
  4. package/dist/dev/data/{image-CW7TABKC.js → image-NCRXXRJW.js} +3 -3
  5. package/dist/dev/index.css +4 -0
  6. package/dist/dev/index.css.map +2 -2
  7. package/dist/dev/index.js +6055 -4020
  8. package/dist/dev/index.js.map +4 -4
  9. package/dist/dev/subset-shared.chunk.js +1 -1
  10. package/dist/dev/subset-worker.chunk.js +1 -1
  11. package/dist/prod/{chunk-W655L563.js → chunk-4UANJTGP.js} +1 -1
  12. package/dist/prod/chunk-ESVIN3T7.js +4 -0
  13. package/dist/prod/data/image-7MUHAX25.js +1 -0
  14. package/dist/prod/index.css +1 -1
  15. package/dist/prod/index.js +24 -17
  16. package/dist/prod/subset-shared.chunk.js +1 -1
  17. package/dist/prod/subset-worker.chunk.js +1 -1
  18. package/dist/types/common/src/constants.d.ts +2 -1
  19. package/dist/types/common/src/points.d.ts +1 -1
  20. package/dist/types/common/src/utils.d.ts +2 -2
  21. package/dist/types/element/src/Scene.d.ts +1 -1
  22. package/dist/types/element/src/align.d.ts +2 -1
  23. package/dist/types/element/src/binding.d.ts +4 -0
  24. package/dist/types/element/src/bounds.d.ts +3 -1
  25. package/dist/types/element/src/distribute.d.ts +2 -1
  26. package/dist/types/element/src/elbowArrow.d.ts +1 -1
  27. package/dist/types/element/src/frame.d.ts +2 -2
  28. package/dist/types/element/src/groups.d.ts +1 -0
  29. package/dist/types/element/src/heading.d.ts +2 -2
  30. package/dist/types/element/src/linearElementEditor.d.ts +3 -5
  31. package/dist/types/element/src/resizeTest.d.ts +2 -2
  32. package/dist/types/element/src/selection.d.ts +1 -1
  33. package/dist/types/element/src/shape.d.ts +2 -2
  34. package/dist/types/element/src/shapes.d.ts +8 -8
  35. package/dist/types/element/src/store.d.ts +3 -2
  36. package/dist/types/element/src/utils.d.ts +11 -5
  37. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +12 -15
  38. package/dist/types/excalidraw/actions/actionAlign.d.ts +8 -8
  39. package/dist/types/excalidraw/actions/actionArrange.d.ts +2 -2
  40. package/dist/types/excalidraw/actions/actionBoundText.d.ts +8 -10
  41. package/dist/types/excalidraw/actions/actionCanvas.d.ts +63 -75
  42. package/dist/types/excalidraw/actions/actionClipboard.d.ts +31 -36
  43. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +4 -5
  44. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +17 -20
  45. package/dist/types/excalidraw/actions/actionDistribute.d.ts +4 -4
  46. package/dist/types/excalidraw/actions/actionDuplicateSelection.d.ts +2 -2
  47. package/dist/types/excalidraw/actions/actionElementLink.d.ts +3 -4
  48. package/dist/types/excalidraw/actions/actionElementLock.d.ts +10 -12
  49. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +4 -5
  50. package/dist/types/excalidraw/actions/actionExport.d.ts +121 -130
  51. package/dist/types/excalidraw/actions/actionFinalize.d.ts +11 -12
  52. package/dist/types/excalidraw/actions/actionFlip.d.ts +4 -4
  53. package/dist/types/excalidraw/actions/actionFrame.d.ts +66 -70
  54. package/dist/types/excalidraw/actions/actionGroup.d.ts +14 -16
  55. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +85 -55
  56. package/dist/types/excalidraw/actions/actionLink.d.ts +5 -6
  57. package/dist/types/excalidraw/actions/actionMenu.d.ts +13 -16
  58. package/dist/types/excalidraw/actions/actionNavigate.d.ts +8 -10
  59. package/dist/types/excalidraw/actions/actionProperties.d.ts +63 -78
  60. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +7 -8
  61. package/dist/types/excalidraw/actions/actionSmartZoom.d.ts +2 -2
  62. package/dist/types/excalidraw/actions/actionStyles.d.ts +8 -9
  63. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +6 -7
  64. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +6 -7
  65. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +5 -6
  66. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +6 -7
  67. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +6 -7
  68. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +6 -7
  69. package/dist/types/excalidraw/actions/actionZindex.d.ts +8 -8
  70. package/dist/types/excalidraw/appState.d.ts +21 -21
  71. package/dist/types/excalidraw/components/Actions.d.ts +0 -4
  72. package/dist/types/excalidraw/components/App.d.ts +12 -6
  73. package/dist/types/excalidraw/components/Ellipsify.d.ts +4 -0
  74. package/dist/types/excalidraw/components/Stats/DragInput.d.ts +11 -1
  75. package/dist/types/excalidraw/components/shapes.d.ts +1 -1
  76. package/dist/types/excalidraw/data/blob.d.ts +1 -1
  77. package/dist/types/excalidraw/index.d.ts +1 -0
  78. package/dist/types/excalidraw/renderer/staticScene.d.ts +4 -1
  79. package/dist/types/excalidraw/types.d.ts +2 -4
  80. package/dist/types/math/src/angle.d.ts +1 -1
  81. package/dist/types/math/src/curve.d.ts +1 -1
  82. package/dist/types/math/src/ellipse.d.ts +3 -3
  83. package/dist/types/math/src/point.d.ts +2 -2
  84. package/dist/types/math/src/polygon.d.ts +2 -2
  85. package/dist/types/math/src/rectangle.d.ts +2 -0
  86. package/dist/types/math/src/segment.d.ts +5 -5
  87. package/dist/types/math/src/utils.d.ts +0 -2
  88. package/dist/types/utils/src/shape.d.ts +12 -12
  89. package/package.json +7 -4
  90. package/dist/dev/chunk-HDRNCSTL.js +0 -23870
  91. package/dist/dev/chunk-HDRNCSTL.js.map +0 -7
  92. package/dist/prod/chunk-23G2JOF5.js +0 -33
  93. package/dist/prod/data/image-TLNQ4QKS.js +0 -1
  94. package/dist/types/excalidraw/visualdebug.d.ts +0 -41
  95. /package/dist/dev/{chunk-WD4YVUU4.js.map → chunk-DUURZLYX.js.map} +0 -0
  96. /package/dist/dev/data/{image-CW7TABKC.js.map → image-NCRXXRJW.js.map} +0 -0
@@ -1,26 +1,33 @@
1
- import{$ as Yf,$a as Ci,$b as Wr,$c as N1,$d as $r,$e as I5,$f as Ec,$g as ib,A as Bf,Aa as tl,Ab as Un,Ac as I1,Ad as $1,Ae as q,Af as S0,Ag as q0,Ah as jp,B as $m,Ba as yr,Bb as ki,Bc as wr,Bd as j1,Be as lc,Bf as I0,Bg as J0,Bh as Lc,C as we,Ca as Dt,Cb as Ho,Cc as Ne,Cd as _i,Ce as Te,Cf as M0,Cg as Q0,Ch as bb,D as tr,Da as zs,Db as p1,Dc as zt,Dd as ml,De as sc,Df as L0,Dg as M5,Dh as qp,E as zn,Ea as Qe,Eb as u1,Ec as Vn,Ed as Qs,Ee as d0,Ef as gc,Eg as Up,Eh as Sr,F as qa,Fa as Gr,Fb as Gn,Fc as Li,Fd as xp,Fe as Cp,Ff as nr,Fg as Gp,Fh as xb,G as Bt,Ga as e1,Gb as Le,Gc as V,Gd as Ep,Ge as m0,Gf as en,Gg as fe,Gh as Jp,H as pt,Ha as ol,Hb as D,Hc as js,Hd as Pi,He as Wo,Hf as fl,Hg as Yp,Hh as Eb,I as re,Ia as $t,Ib as ze,Ic as ce,Id as ec,Ie as p0,If as A0,Ig as tb,Ih as yb,J as Pt,Ja as ht,Jb as gt,Jc as fp,Jd as q1,Je as u0,Jf as _0,Jg as ei,Jh as Ac,K as Er,Ka as t1,Kb as al,Kc as ge,Kd as J1,Ke as Oi,Kf as P0,Kg as ir,Kh as Qp,L as Fr,La as o1,Lb as Us,Lc as qe,Ld as Di,Le as h0,Lf as Dp,Lg as ob,Lh as vb,M as As,Ma as zo,Mb as Gs,Mc as Pe,Md as Q1,Me as jn,Mf as fc,Mg as Wi,Mh as wb,N as jm,Na as r1,Nb as h1,Nc as se,Nd as tc,Ne as g0,Nf as bc,Ng as rb,Nh as Tb,O as _s,Oa as le,Ob as vr,Oc as M1,Od as Go,Oe as Bi,Of as xc,Og as Vp,Oh as Cb,P as qm,Pa as w,Pb as g1,Pc as L1,Pd as te,Pe as cc,Pf as Jn,Pg as on,Q as Ja,Qa as vi,Qb as f1,Qc as Tr,Qd as kr,Qe as f0,Qf as D0,Qg as Vi,R as zf,Ra as Fn,Rb as b1,Rc as A1,Rd as e0,Re as dc,Rf as qt,Rg as Jt,S as Ff,Sa as ip,Sb as x1,Sc as _1,Sd as Xr,Se as wo,Sf as Rp,Sg as Ko,T as Jm,Ta as wi,Tb as j,Tc as Cr,Td as oc,Te as kp,Tf as R0,Tg as Ki,U as Qa,Ua as Fs,Ub as E1,Uc as P1,Ud as yp,Ue as Sp,Uf as Hi,Ug as wc,V as ue,Va as Et,Vb as rr,Vc as qs,Vd as pl,Ve as b0,Vf as bl,Vg as Kp,W as Hf,Wa as Eo,Wb as ft,Wc as bt,Wd as rc,We as mc,Wf as Ft,Wg as xl,X as Ps,Xa as n1,Xb as y1,Xc as rt,Xd as t0,Xe as pc,Xf as N0,Xg as Tc,Y as Hr,Ya as ap,Yb as Ys,Yc as D1,Yd as Ri,Ye as x0,Yf as O0,Yg as Zp,Z as Uf,Za as i1,Zb as Si,Zc as Kr,Zd as o0,Ze as E0,Zf as Co,Zg as Xp,_ as Gf,_a as Ti,_b as v1,_c as R1,_d as ul,_e as y0,_f as tn,_g as nb,a as ks,aa as Wf,ab as lp,ac as ll,ad as Kn,ae as jr,af as Jr,ag as Np,ah as ab,b as kf,ba as Vf,bb as Hs,bc as nt,bd as bp,be as vp,bf as hl,bg as Qn,bh as Cc,c as On,ca as yi,cb as sp,cc as Vr,cd as O1,ce as nc,cf as Ip,cg as B0,ch as El,d as Sf,da as Qm,db as cp,dc as Ii,dd as B1,de as wp,df as Mp,dg as Ui,dh as kc,e as If,ea as ep,eb as a1,ec as Ws,ed as cl,ee as $,ef as Lp,eg as Op,eh as Sc,f as Mf,fa as Kf,fb as dp,fc as w1,fd as z1,fe as C5,ff as Ap,fg as z0,fh as lb,g as bo,ga as Zf,gb as L,gc as Vs,gd as F1,ge as k5,gf as zi,gg as F0,gh as sb,h as Ss,ha as Ds,hb as mp,hc as jt,hd as vt,he as S5,hf as To,hg as H0,hh as yl,i as Is,ia as Rs,ib as Re,ic as Mi,id as H1,ie as r0,if as uc,ig as U0,ih as cb,j as Ms,ja as tp,jb as Yr,jc as Fe,jd as U1,je as it,jf as at,jg as G0,jh as db,k as Lf,ka as Xf,kb as rl,kc as T1,kd as G1,ke as ic,kf as v0,kg as Bp,kh as mb,l as Af,la as $f,lb as l1,lc as C1,ld as Zn,le as Yo,lf as w0,lg as Y0,lh as Ic,m as _f,ma as jf,mb as s1,mc as Ks,md as Y1,me as Xn,mf as ye,mg as W0,mh as Zi,n as Pf,na as qf,nb as co,nc as hp,nd as W1,ne as n0,nf as hc,ng as V0,nh as pb,o as Bo,oa as Ns,ob as nl,oc as Zs,od as T5,oe as Ni,of as po,og as K0,oh as $p,p as Ls,pa as Ur,pb as il,pc as Yn,pd as V1,pe as He,pf as _p,pg as Gi,ph as L5,q as xo,qa as Jf,qb as c1,qc as mo,qd as Ai,qe as i0,qf as Qr,qg as Z0,qh as Xi,r as Df,ra as op,rb as yt,rc as Uo,rd as Ke,re as a0,rf as gl,rg as yc,rh as vl,s as Rf,sa as rp,sb as pp,sc as Xs,sd as K1,se as l0,sf as Fi,sg as X0,t as Nf,ta as Qf,tb as Fo,tc as $s,td as Zr,te as $n,tf as Pp,tg as $0,th as ub,u as Xa,ua as Os,ub as d1,uc as yo,ud as dl,ue as ac,uf as T0,ug as vc,v as $a,va as np,vb as up,vc as gp,vd as pe,ve as qr,vf as C0,vg as zp,vh as hb,w as Bn,wa as Xt,wb as m1,wc as k1,wd as vo,we as s0,wf as qn,wg as Fp,wh as gb,x as ja,xa as el,xb as or,xc as Wn,xd as Js,xe as c0,xf as Vo,xg as Hp,xh as Mc,y as Of,ya as ut,yb as Hn,yc as S1,yd as Z1,ye as Tp,yf as A,yg as Yi,yh as fb,z as Xm,za as Bs,zb as et,zc as sl,zd as X1,ze as De,zf as k0,zg as j0,zh as wl}from"./chunk-23G2JOF5.js";import{a as C}from"./chunk-W655L563.js";import{J as Wp}from"./chunk-KZXLT4YB.js";import{c as eb}from"./chunk-Z3N5DIM6.js";import{b as Tf,c as Cf,d as k}from"./chunk-SRAX5OIU.js";import XL,{useEffect as $L}from"react";import t5 from"clsx";import wL from"lodash.throttle";import xr,{useContext as Dn}from"react";import{flushSync as Br}from"react-dom";import TL from"roughjs/bin/rough";import{nanoid as CL}from"nanoid";var _c=class{constructor(o=0){k(this,"root");k(this,"gap");this.root=null,this.gap=o}fit(o){let t=o.length,r=t>0?o[0].w:0,n=t>0?o[0].h:0;this.root={x:0,y:0,w:r,h:n};for(let i=0;i<t;i++){let a=o[i],l=this.findNode(this.root,a.w,a.h);l?a.fit=this.splitNode(l,a.w,a.h):a.fit=this.growNode(a.w,a.h)}}findNode(o,t,r){return o?o.used?this.findNode(o.right||null,t,r)||this.findNode(o.down||null,t,r):t<=o.w&&r<=o.h?o:null:null}splitNode(o,t,r){return o.used=!0,o.down={x:o.x,y:o.y+r+this.gap,w:o.w,h:o.h-r-this.gap},o.right={x:o.x+t+this.gap,y:o.y,w:o.w-t-this.gap,h:r},o}growNode(o,t){if(!this.root)return null;let r=o<=this.root.w,n=t<=this.root.h,i=n&&this.root.h>=this.root.w+o+this.gap,a=r&&this.root.w>=this.root.h+t+this.gap;return i?this.growRight(o,t):a?this.growDown(o,t):n?this.growRight(o,t):r?this.growDown(o,t):null}growRight(o,t){if(!this.root)return null;this.root={used:!0,x:0,y:0,w:this.root.w+o+this.gap,h:this.root.h,down:this.root,right:{x:this.root.w+this.gap,y:0,w:o,h:this.root.h}};let r=this.findNode(this.root,o,t);return r?this.splitNode(r,o,t):null}growDown(o,t){if(!this.root)return null;this.root={used:!0,x:0,y:0,w:this.root.w,h:this.root.h+t+this.gap,down:{x:0,y:this.root.h+this.gap,w:this.root.w,h:t},right:this.root};let r=this.findNode(this.root,o,t);return r?this.splitNode(r,o,t):null}};var A5=(e,o,t)=>{let r=po(o),n=t.x-r.minX,i=t.y-r.minY;o.forEach(a=>{e.mutateElement(a,{x:a.x+n,y:a.y+i})})},kb=(e,o,t)=>{let r=o.flatMap(c=>c.group),n=po(r),i={x:n.minX,y:n.minY},a=o.sort((c,m)=>Math.max(m.boundingBox.width,m.boundingBox.height)-Math.max(c.boundingBox.width,c.boundingBox.height)).map(c=>({w:c.boundingBox.width,h:c.boundingBox.height,group:c.group}));new _c(t).fit(a);let s=[];for(let c=0;c<a.length;c++){let m=a[c];m.fit&&s.push(m)}return s.forEach(c=>{A5(e,c.group,{x:i.x+(c.fit?.x??0),y:i.y+(c.fit?.y??0)})}),s.flatMap(c=>c.group)},Tl=(e,o,t,r,n)=>{let a=$n(o,t).map(l=>({group:l,boundingBox:po(l)}));switch(r){case"bin-packing":return kb(e,a,n);default:return console.warn(`Unimplemented algorithm [${r}] - using bin-packing`),kb(e,a,n)}};import{atom as Ie,createStore as _5}from"jotai";import{createIsolation as P5}from"jotai-scope";var Sb=P5();var{useAtom:Ee,useSetAtom:$i,useAtomValue:Pc,useStore:c8}=Sb,Ib=Sb.Provider,wt=_5();var D5=Tf({"./locales/ar-SA.json":()=>import("./locales/ar-SA-G6X2FPQ2.js"),"./locales/az-AZ.json":()=>import("./locales/az-AZ-76LH7QW2.js"),"./locales/bg-BG.json":()=>import("./locales/bg-BG-XCXSNQG7.js"),"./locales/bn-BD.json":()=>import("./locales/bn-BD-2XOGV67Q.js"),"./locales/ca-ES.json":()=>import("./locales/ca-ES-6MX7JW3Y.js"),"./locales/cs-CZ.json":()=>import("./locales/cs-CZ-2BRQDIVT.js"),"./locales/da-DK.json":()=>import("./locales/da-DK-5WZEPLOC.js"),"./locales/de-DE.json":()=>import("./locales/de-DE-XR44H4JA.js"),"./locales/el-GR.json":()=>import("./locales/el-GR-BZB4AONW.js"),"./locales/en.json":()=>import("./locales/en-XFR6MADM.js"),"./locales/es-ES.json":()=>import("./locales/es-ES-U4NZUMDT.js"),"./locales/eu-ES.json":()=>import("./locales/eu-ES-A7QVB2H4.js"),"./locales/fa-IR.json":()=>import("./locales/fa-IR-HGAKTJCU.js"),"./locales/fi-FI.json":()=>import("./locales/fi-FI-Z5N7JZ37.js"),"./locales/fr-FR.json":()=>import("./locales/fr-FR-RHASNOE6.js"),"./locales/gl-ES.json":()=>import("./locales/gl-ES-HMX3MZ6V.js"),"./locales/he-IL.json":()=>import("./locales/he-IL-6SHJWFNN.js"),"./locales/hi-IN.json":()=>import("./locales/hi-IN-IWLTKZ5I.js"),"./locales/hu-HU.json":()=>import("./locales/hu-HU-A5ZG7DT2.js"),"./locales/id-ID.json":()=>import("./locales/id-ID-SAP4L64H.js"),"./locales/it-IT.json":()=>import("./locales/it-IT-JPQ66NNP.js"),"./locales/ja-JP.json":()=>import("./locales/ja-JP-DBVTYXUO.js"),"./locales/kaa.json":()=>import("./locales/kaa-6HZHGXH3.js"),"./locales/kab-KAB.json":()=>import("./locales/kab-KAB-ZGHBKWFO.js"),"./locales/kk-KZ.json":()=>import("./locales/kk-KZ-P5N5QNE5.js"),"./locales/km-KH.json":()=>import("./locales/km-KH-HSX4SM5Z.js"),"./locales/ko-KR.json":()=>import("./locales/ko-KR-MTYHY66A.js"),"./locales/ku-TR.json":()=>import("./locales/ku-TR-6OUDTVRD.js"),"./locales/lt-LT.json":()=>import("./locales/lt-LT-XHIRWOB4.js"),"./locales/lv-LV.json":()=>import("./locales/lv-LV-5QDEKY6T.js"),"./locales/mr-IN.json":()=>import("./locales/mr-IN-CRQNXWMA.js"),"./locales/my-MM.json":()=>import("./locales/my-MM-5M5IBNSE.js"),"./locales/nb-NO.json":()=>import("./locales/nb-NO-T6EIAALU.js"),"./locales/nl-NL.json":()=>import("./locales/nl-NL-IS3SIHDZ.js"),"./locales/nn-NO.json":()=>import("./locales/nn-NO-6E72VCQL.js"),"./locales/oc-FR.json":()=>import("./locales/oc-FR-POXYY2M6.js"),"./locales/pa-IN.json":()=>import("./locales/pa-IN-N4M65BXN.js"),"./locales/percentages.json":()=>import("./locales/percentages-BXMCSKIN.js"),"./locales/pl-PL.json":()=>import("./locales/pl-PL-T2D74RX3.js"),"./locales/pt-BR.json":()=>import("./locales/pt-BR-5N22H2LF.js"),"./locales/pt-PT.json":()=>import("./locales/pt-PT-UZXXM6DQ.js"),"./locales/ro-RO.json":()=>import("./locales/ro-RO-JPDTUUEW.js"),"./locales/ru-RU.json":()=>import("./locales/ru-RU-B4JR7IUQ.js"),"./locales/si-LK.json":()=>import("./locales/si-LK-N5RQ5JYF.js"),"./locales/sk-SK.json":()=>import("./locales/sk-SK-C5VTKIMK.js"),"./locales/sl-SI.json":()=>import("./locales/sl-SI-NN7IZMDC.js"),"./locales/sv-SE.json":()=>import("./locales/sv-SE-XGPEYMSR.js"),"./locales/ta-IN.json":()=>import("./locales/ta-IN-2NMHFXQM.js"),"./locales/th-TH.json":()=>import("./locales/th-TH-HPSO5L25.js"),"./locales/tr-TR.json":()=>import("./locales/tr-TR-DEFEU3FU.js"),"./locales/uk-UA.json":()=>import("./locales/uk-UA-QMV73CPH.js"),"./locales/vi-VN.json":()=>import("./locales/vi-VN-M7AON7JQ.js"),"./locales/zh-CN.json":()=>import("./locales/zh-CN-LNUGB5OW.js"),"./locales/zh-HK.json":()=>import("./locales/zh-HK-E62DVLB3.js"),"./locales/zh-TW.json":()=>import("./locales/zh-TW-RAJ6MFWO.js")});var R5=85,ar={code:"en",label:"English"},qi=[ar,...[{code:"ar-SA",label:"\u0627\u0644\u0639\u0631\u0628\u064A\u0629",rtl:!0},{code:"bg-BG",label:"\u0411\u044A\u043B\u0433\u0430\u0440\u0441\u043A\u0438"},{code:"ca-ES",label:"Catal\xE0"},{code:"cs-CZ",label:"\u010Cesky"},{code:"de-DE",label:"Deutsch"},{code:"el-GR",label:"\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC"},{code:"es-ES",label:"Espa\xF1ol"},{code:"eu-ES",label:"Euskara"},{code:"fa-IR",label:"\u0641\u0627\u0631\u0633\u06CC",rtl:!0},{code:"fi-FI",label:"Suomi"},{code:"fr-FR",label:"Fran\xE7ais"},{code:"gl-ES",label:"Galego"},{code:"he-IL",label:"\u05E2\u05D1\u05E8\u05D9\u05EA",rtl:!0},{code:"hi-IN",label:"\u0939\u093F\u0928\u094D\u0926\u0940"},{code:"hu-HU",label:"Magyar"},{code:"id-ID",label:"Bahasa Indonesia"},{code:"it-IT",label:"Italiano"},{code:"ja-JP",label:"\u65E5\u672C\u8A9E"},{code:"kab-KAB",label:"Taqbaylit"},{code:"kk-KZ",label:"\u049A\u0430\u0437\u0430\u049B \u0442\u0456\u043B\u0456"},{code:"ko-KR",label:"\uD55C\uAD6D\uC5B4"},{code:"ku-TR",label:"Kurd\xEE"},{code:"lt-LT",label:"Lietuvi\u0173"},{code:"lv-LV",label:"Latvie\u0161u"},{code:"my-MM",label:"Burmese"},{code:"nb-NO",label:"Norsk bokm\xE5l"},{code:"nl-NL",label:"Nederlands"},{code:"nn-NO",label:"Norsk nynorsk"},{code:"oc-FR",label:"Occitan"},{code:"pa-IN",label:"\u0A2A\u0A70\u0A1C\u0A3E\u0A2C\u0A40"},{code:"pl-PL",label:"Polski"},{code:"pt-BR",label:"Portugu\xEAs Brasileiro"},{code:"pt-PT",label:"Portugu\xEAs"},{code:"ro-RO",label:"Rom\xE2n\u0103"},{code:"ru-RU",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439"},{code:"sk-SK",label:"Sloven\u010Dina"},{code:"sv-SE",label:"Svenska"},{code:"sl-SI",label:"Sloven\u0161\u010Dina"},{code:"tr-TR",label:"T\xFCrk\xE7e"},{code:"uk-UA",label:"\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430"},{code:"zh-CN",label:"\u7B80\u4F53\u4E2D\u6587"},{code:"zh-TW",label:"\u7E41\u9AD4\u4E2D\u6587"},{code:"vi-VN",label:"Ti\u1EBFng Vi\u1EC7t"},{code:"mr-IN",label:"\u092E\u0930\u093E\u0920\u0940"}].filter(e=>eb[e.code]>=R5).sort((e,o)=>e.label>o.label?1:-1)],Rc="__test__";ft()&&qi.unshift({code:Rc,label:"test language"},{code:`${Rc}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var ji=ar,Dc={},Nc=async e=>{if(ji=e,document.documentElement.dir=ji.rtl?"rtl":"ltr",document.documentElement.lang=ji.code,e.code.startsWith(Rc))Dc={};else try{Dc=await D5(`./locales/${ji.code}.json`)}catch(o){console.error(`Failed to load language ${e.code}:`,o.message),Dc=Wp}wt.set(Lb,e.code)},Ir=()=>ji,Mb=(e,o)=>{for(let t=0;t<o.length;++t){let r=o[t];if(e[r]===void 0)return;e=e[r]}if(typeof e=="string")return e},g=(e,o,t)=>{if(ji.code.startsWith(Rc))return`\u202A[[${o?`${e}(${JSON.stringify(o).slice(1,-1)})`:e}]]\u202C`;let r=e.split("."),n=Mb(Dc,r)||Mb(Wp,r)||t;if(n===void 0){let i=`Can't find translation for ${e}`;if(C.PROD)return console.warn(i),"";throw new Error(i)}if(o)for(let i in o)n=n.replace(`{{${i}}}`,String(o[i]));return n},Lb=Ie(ar.code),lt=()=>{let e=Pc(Lb);return{t:g,langCode:e}};import N5 from"clsx";import O5 from"open-color";import Lt from"react";import{Fragment as Ae,jsx as h,jsxs as N}from"react/jsx-runtime";var Zo=e=>"var(--icon-fill-color)",Ab=e=>e===re.LIGHT?O5.white:"#1e1e1e",_=(e,o=512)=>{let{width:t=512,height:r=t,mirror:n,style:i,...a}=typeof o=="number"?{width:o}:o;return h("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${t} ${r}`,className:N5({"rtl-mirror":n}),style:i,...a,children:typeof e=="string"?h("path",{fill:"currentColor",d:e}):e})},U={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},ae={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},k8=_(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:3,y:8,width:18,height:4,rx:1}),h("line",{x1:12,y1:8,x2:12,y2:21}),h("path",{d:"M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"}),h("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"})]}),U),Ji=_(N("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),h("path",{d:"M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),h("line",{x1:"3",y1:"6",x2:"3",y2:"19"}),h("line",{x1:"12",y1:"6",x2:"12",y2:"19"}),h("line",{x1:"21",y1:"6",x2:"21",y2:"19"})]}),U),_b=_(N("svg",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),h("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),U),Pb=_(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"1"}),h("circle",{cx:"12",cy:"19",r:"1"}),h("circle",{cx:"12",cy:"5",r:"1"})]}),U),Db=_(N("svg",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),h("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),h("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),U),eu=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M6.5 9.5l3.5 -3"}),h("path",{d:"M14 5.5l3 1.5"}),h("path",{d:"M18.5 10l-2.5 7"}),h("path",{d:"M13.5 17.5l-7 -5"})]}),U),Mr=_(N("g",{children:[h("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"}),h("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"}),h("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:h("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"})}),h("g",{mask:"url(#UnlockedIcon)",children:h("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"})})]}),ae),rn=_(N("g",{strokeWidth:"1.25",children:[h("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"}),h("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),h("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"})]}),ae),Rb=_(h("g",{fill:"currentColor",children:h("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}),Nb=_(N(Ae,{children:[h("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"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),h("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"}),Ob=_(N(Ae,{children:[h("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"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),h("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"}),Bb=_(N(Ae,{children:[h("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"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),h("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"}),S8=_(h("g",{fill:"currentColor",children:h("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"}),Oc=_(N("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),Cl=_(N("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,children:[h("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"}),h("path",{d:"M5 15m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 17c0 1.42 .316 2.805 1 4"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),nn=_(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),U),an=_(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"})]}),U),ln=_(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"})]}),U),Qi=_(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),h("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),h("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),U),sn=_(h("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),ae),zb=_(N("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),h("path",{d:"M16 7h4"}),h("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),U),lr=_(N("g",{strokeWidth:"1.25",children:[h("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"}),h("path",{d:"m11.25 5.417 3.333 3.333"})]}),ae),cn=_(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),h("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),h("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),h("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),h("polyline",{points:"5 20 11 4 13 4 20 20"})]}),U),Bc=_(N("g",{strokeWidth:"1.25",children:[h("path",{d:"M12.5 6.667h.01"}),h("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"}),h("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),h("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),ae),zc=_(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M18 13.3l-6.3 -6.3"})]}),U),tu=_(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),ae),ou=_(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),ae),Fb=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M21 21l-6 -6"}),h("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"}),h("path",{d:"M3 4v4h4"})]}),U),Lr=_(h("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"}),ae),Hb=_(N("g",{strokeWidth:"1.5",children:[h("polyline",{points:"12 16 18 10 12 4"}),h("polyline",{points:"8 4 2 10 8 16"})]}),ae),kl=_(N("g",{strokeWidth:"1.25",children:[h("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"}),h("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"})]}),ae),Sl=_(h("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"}),ae),Il=_(h("g",{stroke:"currentColor",strokeLinejoin:"round",children:h("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"})}),{...ae,strokeWidth:1.5}),Fc=_(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),h("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),h("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),U),ti=_(h("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"}),ae),ea=_(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"}),h("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),U),Ub=_(N("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"}),h("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),U),I8=_(h("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"}),ae),Gb=_(h("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"}),ae),Yb=_(N("g",{strokeWidth:"1.25",children:[h("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"}),h("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"})]}),ae),Wb=_(N("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),h("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),U),Vb=_(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),Ml=_(N("g",{strokeWidth:"1.25",children:[h("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"}),h("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"})]}),ae),Kb=_("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}),Zb=_("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}),ta=_(h("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"}),ae),M8=_("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}),Xb=_("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"),Hc=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z"}),h("path",{d:"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"}),h("path",{d:"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"})]}),U),$b=_(h("g",{strokeWidth:1.5,children:h("path",{d:"M6 18l12 -12"})}),U),Uc=_(N("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 8h.01"}),h("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),h("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),h("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),h("path",{d:"M19 16v6"}),h("path",{d:"M22 19l-3 3l-3 -3"})]}),U),jb=_("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}),L8=_("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}),A8=_("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}),qb=_("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"),_8=_("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"),ru=_(h("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"}),ae),nu=_(h("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"}),ae),Jb=_("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}),Qb=_(h("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"}),ae),P8=_("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"),D8=_("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}),R8=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M12 14v-11"}),h("path",{d:"M9 6l3 -3l3 3"})]}),U),N8=_(N(Ae,{children:[h("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"}),h("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}),O8=_(h("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}),ex=N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 10l0 10"}),h("path",{d:"M12 10l4 4"}),h("path",{d:"M12 10l-4 4"}),h("path",{d:"M4 4l16 0"})]}),tx=N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 5l0 14"}),h("path",{d:"M16 9l-4 -4"}),h("path",{d:"M8 9l4 -4"})]}),iu=_(tx,U),au=_(tx,{...U,style:{transform:"rotate(180deg)"}}),lu=_(ex,U),su=_(ex,{...U,style:{transform:"rotate(180deg)"}}),cu=_(N(Ae,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),du=_(N(Ae,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),mu=_(N(Ae,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),pu=_(N(Ae,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),ox=_(N(Ae,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),rx=_(N(Ae,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),uu=_(N("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),h("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),ae),hu=_(N("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),h("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),ae),Gc=_(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"9",cy:"7",r:"4"}),h("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),h("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),h("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),U),B8=_("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"),z8=_("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"),ko=_(N(Ae,{children:[h("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M15 5 5 15M5 5l10 10"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),F8=_("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}),H8=_("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}),U8=_("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}),gu=Lt.memo(({theme:e})=>_(N(Ae,{children:[h("path",{d:"M25 26H111V111H25",fill:Zo(e)}),h("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:Zo(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:Zo(e)}),h("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:Zo(e),strokeWidth:"2"}),N("g",{fill:Ab(e),stroke:Zo(e),strokeWidth:"6",children:[h("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),fu=Lt.memo(({theme:e})=>_(N(Ae,{children:[h("path",{d:"M25 26H111V111H25",fill:Zo(e)}),h("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:Zo(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:Zo(e)}),h("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:Zo(e),strokeWidth:"2"}),N("g",{fill:Ab(e),stroke:Zo(e),strokeWidth:"6",children:[h("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),h("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),nx=_(h("g",{strokeWidth:1.25,children:h("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"})}),ae),ix=_(N(Ae,{children:[h("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"}),h("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:h("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"})}),h("g",{mask:"url(#FillHachureIcon)",children:h("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"})})]}),ae),ax=_(N(Ae,{children:[N("g",{clipPath:"url(#a)",children:[h("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"}),h("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:h("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"})}),h("g",{mask:"url(#FillCrossHatchIcon)",children:h("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"})})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),lx=_(N(Ae,{children:[h("g",{clipPath:"url(#a)",children:h("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"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...ae,fill:"currentColor"}),bu=_(h(Ae,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),ae),sx=_(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),ae),cx=_(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),ae),G8=Lt.memo(({theme:e})=>_(h("path",{d:"M6 10H34",stroke:Zo(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),dx=_(N("g",{strokeWidth:"2",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12h2"}),h("path",{d:"M17 12h2"}),h("path",{d:"M11 12h2"})]}),U),mx=_(N("g",{strokeWidth:"2",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 12v.01"}),h("path",{d:"M8 12v.01"}),h("path",{d:"M12 12v.01"}),h("path",{d:"M16 12v.01"}),h("path",{d:"M20 12v.01"})]}),U),px=_(h("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"}),ae),ux=_(h("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"}),ae),hx=_(h("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"}),ae),gx=_(N("svg",{strokeWidth:"1.5",children:[h("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"}),h("path",{d:"M13.3333 3.33331V3.34331"}),h("path",{d:"M16.6667 3.33331V3.34331"}),h("path",{d:"M16.6667 6.66669V6.67669"}),h("path",{d:"M16.6667 10V10.01"}),h("path",{d:"M3.33334 13.3333V13.3433"}),h("path",{d:"M16.6667 13.3333V13.3433"}),h("path",{d:"M3.33334 16.6667V16.6767"}),h("path",{d:"M6.66666 16.6667V16.6767"}),h("path",{d:"M10 16.6667V16.6767"}),h("path",{d:"M13.3333 16.6667V16.6767"}),h("path",{d:"M16.6667 16.6667V16.6767"})]}),ae),fx=_(N("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),h("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),h("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),h("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),h("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),h("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),h("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),h("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),h("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),h("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),h("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),h("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),U),bx=_(N("g",{stroke:"currentColor",opacity:.3,strokeWidth:2,children:[h("path",{d:"M12 12l9 0"}),h("path",{d:"M3 9l6 6"}),h("path",{d:"M3 15l6 -6"})]}),U),xx=Lt.memo(({flip:e=!1})=>_(N("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",children:[h("path",{d:"M34 10H6M34 10L27 5M34 10L27 15"}),h("path",{d:"M27.5 5L34.5 10L27.5 15"})]}),{width:40,height:20})),Ex=Lt.memo(({flip:e=!1})=>_(N("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[h("path",{d:"M32 10L6 10",strokeWidth:2}),h("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),yx=Lt.memo(({flip:e=!1})=>_(N("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[h("path",{d:"M26 10L6 10"}),h("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),vx=Lt.memo(({flip:e=!1})=>_(h("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",children:h("path",{d:"M34 10H5.99996M34 10L34 5M34 10L34 15",stroke:"currentColor",strokeWidth:2,fill:"none"})}),{width:40,height:20})),wx=Lt.memo(({flip:e=!1})=>_(N("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[h("path",{d:"M32 10L6 10",strokeWidth:2}),h("path",{d:"M27.5 5.5L34.5 10L27.5 14.5L27.5 5.5"})]}),{width:40,height:20})),Tx=Lt.memo(({flip:e=!1})=>_(N("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",children:[h("path",{d:"M6,9.5H27"}),h("path",{d:"M27,5L34,10L27,14Z",fill:"none"})]}),{width:40,height:20})),Cx=Lt.memo(({flip:e=!1})=>_(N("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M6,9.5H20"}),h("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),kx=Lt.memo(({flip:e=!1})=>_(N("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M6,9.5H20"}),h("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),Sx=Lt.memo(({flip:e=!1})=>_(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M34,10 H6 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),Ix=Lt.memo(({flip:e=!1})=>_(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M34,10 H6 M15,10 L15,15 L15,5"})}),{width:40,height:20})),Mx=Lt.memo(({flip:e=!1})=>_(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M34,10 H6 M15,10 L15,16 L15,4 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),Lx=_(N(Ae,{children:[h("g",{clipPath:"url(#a)",children:h("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"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),Ax=_(N(Ae,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),_x=_(N(Ae,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),Px=_(h(Ae,{children:h("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"})}),ae),oi=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 7v-2h13v2"}),h("path",{d:"M10 5v14"}),h("path",{d:"M12 19h-4"}),h("path",{d:"M15 13v-1h6v1"}),h("path",{d:"M18 12v7"}),h("path",{d:"M17 19h2"})]}),U),Dx=_(h(Ae,{children:N("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 12h10"}),h("path",{d:"M7 5v14"}),h("path",{d:"M17 5v14"}),h("path",{d:"M15 19h4"}),h("path",{d:"M15 5h4"}),h("path",{d:"M5 19h4"}),h("path",{d:"M5 5h4"})]})}),U),Ll=_(h(Ae,{children:h("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("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"})})}),ae),Yc=_(N(Ae,{children:[h("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M5.833 6.667 2.5 10l3.333 3.333M14.167 6.667 17.5 10l-3.333 3.333M11.667 3.333 8.333 16.667"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),Rx=_(N("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),h("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),U),Nx=_(N("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),h("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),U),Ox=_(N("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),h("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),U),Bx=Lt.memo(({theme:e})=>_(N("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),h("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),U)),zx=Lt.memo(({theme:e})=>_(N("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),h("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),U)),Fx=Lt.memo(({theme:e})=>_(N("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),h("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),h("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),U)),Wc=_(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M21 19h-18l9 -15"}),h("path",{d:"M20.615 15.171h.015"}),h("path",{d:"M19.515 11.771h.015"}),h("path",{d:"M17.715 8.671h.015"}),h("path",{d:"M15.415 5.971h.015"})]}),U),Hx=_(h("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}),Y8=_(h("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"})),Vc=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),h("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),h("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),h("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"})]}),U),xu=_(N(Ae,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),h("path",{d:"M7 11l5 5l5 -5"}),h("path",{d:"M12 4l0 12"})]}),U),oa=_(N(Ae,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),U),Ux=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M9.15 14.85l8.85 -10.85"}),h("path",{d:"M6 4l8.85 10.85"})]}),U),Gx=_(N(Ae,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),h("path",{d:"M12 17l0 .01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),U),W8=_(N(Ae,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),U),V8=_(N(Ae,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"})]}),U),Yx=_(N(Ae,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),U),Wx=_(N(Ae,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M12 9v4"}),h("path",{d:"M12 17h.01"})]}),U),Vx=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M11 7l6 6"}),h("path",{d:"M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z"})]}),U),Eu=_(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 3l-4 7h8z"}),h("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M4 14m0 1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z"})]}),U),ra=_(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 7l16 0"}),h("path",{d:"M4 17l16 0"}),h("path",{d:"M7 4l0 16"}),h("path",{d:"M17 4l0 16"})]}),U),Kx=_(h("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"})),na=_(N("g",{strokeWidth:"1.25",children:[h("path",{d:"M4.16602 10H15.8327"}),h("path",{d:"M12.5 13.3333L15.8333 10"}),h("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),ae),Al=_(N("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[h("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"}),h("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),Zx=_(N("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z"}),h("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),h("path",{d:"M15 6l3 3"}),h("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"}),h("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"})]}),U),K8=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z"}),h("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),h("path",{d:"M15 6l3 3"}),h("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"}),h("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"})]}),U),Z8=_(N("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),h("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),h("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"}),h("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),h("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),h("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"})]}),U),Xx=_(N("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),h("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),h("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),h("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),U),ri=_(N("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),h("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"})]}),U),$x=_(N("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),h("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"}),h("path",{d:"M3 3l18 18"})]}),U),jx=_(N("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("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"}),h("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),h("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),h("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),h("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),U),qx=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("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"}),h("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),h("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),h("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),h("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),U),uo=_(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),h("path",{d:"M21 21l-6 -6"})]}),U),Jx=_(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),h("path",{d:"M12 7v5l3 3"}),h("path",{d:"M19 16l-2 3h4l-2 3"})]}),U),Qx=_(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M5 10a7 7 0 0 0 14 0"}),h("path",{d:"M8 21l8 0"}),h("path",{d:"M12 17l0 4"})]}),U),eE=_(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 3l18 18"}),h("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"}),h("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),h("path",{d:"M8 21l8 0"}),h("path",{d:"M12 17l0 4"})]}),U),_l=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),U),tE=_(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M12 20v.01"}),h("path",{d:"M16 20v.01"}),h("path",{d:"M8 20v.01"}),h("path",{d:"M4 20v.01"}),h("path",{d:"M4 16v.01"}),h("path",{d:"M4 12v.01"}),h("path",{d:"M4 8v.01"}),h("path",{d:"M4 4v.01"}),h("path",{d:"M8 4v.01"}),h("path",{d:"M12 4v.01"}),h("path",{d:"M16 4v.01"}),h("path",{d:"M20 4v.01"}),h("path",{d:"M20 8v.01"}),h("path",{d:"M20 12v.01"}),h("path",{d:"M20 16v.01"}),h("path",{d:"M20 20v.01"})]}),U),oE=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 3v18"}),h("path",{d:"M19 21v-18"}),h("path",{d:"M5 7h14"}),h("path",{d:"M5 15h14"}),h("path",{d:"M8 13v4"}),h("path",{d:"M11 13v4"}),h("path",{d:"M16 13v4"}),h("path",{d:"M14 5v4"}),h("path",{d:"M11 5v4"}),h("path",{d:"M8 5v4"}),h("path",{d:"M3 21h18"})]}),U),rE=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 12l18 0"}),h("path",{d:"M7 16l10 0l-10 5l0 -5"}),h("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),U),nE=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 3l0 18"}),h("path",{d:"M16 7l0 10l5 0l-5 -10"}),h("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),U),yu=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),h("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"})]}),U),Kc=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),h("path",{d:"M22 22l-3 -3"}),h("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),h("path",{d:"M3 11v-1"}),h("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),h("path",{d:"M10 3h1"}),h("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),U),iE=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),h("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),h("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"}),h("path",{d:"M10 15l2 6l2 -6"}),h("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),U),aE=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),h("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),h("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),h("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),h("path",{d:"M11 21v-6l3 6v-6"})]}),U),lE=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M4 8l5 0"}),h("path",{d:"M15 8l4 0"})]}),U),sE=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),h("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),h("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),h("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),U),cE=_(N("g",{stroke:"currentColor",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"})]}),{...U,strokeWidth:1.5}),X8=_(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M21 12h-13l3 -3"}),h("path",{d:"M11 15l-3 -3"})]}),U),$8=_(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M10 9l5 3l-5 3z"})]}),U),dE=_(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 6h18"}),h("path",{d:"M3 12h18"}),h("path",{d:"M3 18h18"}),h("path",{d:"M6 3v18"}),h("path",{d:"M12 3v18"}),h("path",{d:"M18 3v18"})]}),U),mE=_(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("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"}),h("path",{d:"M17 5c-6.627 0 -12 5.373 -12 12"})]}),U),Zc=_(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 18l12 -12"}),h("path",{d:"M18 10v-4h-4"})]}),U),Xc=_(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7"}),h("path",{d:"M18 4l3 3l-3 3"})]}),U),$c=_(N("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),U),jc=_(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),U),pE=_(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),U),uE=_(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),U),vu=_(N("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 5v10a1 1 0 0 0 1 1h10"}),h("path",{d:"M5 8h10a1 1 0 0 1 1 1v10"})]}),U),qc=_(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 7l0 10"}),h("path",{d:"M7 5l10 0"}),h("path",{d:"M7 19l10 0"}),h("path",{d:"M19 7l0 10"})]}),U),wu=_(N("g",{strokeWidth:"1.25",children:[h("rect",{x:"4",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"4",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"4",y:"16",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"16",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"16",width:"4",height:"4",rx:"1"})]}),U),Tu=_(h("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:.5,viewBox:"0 0 640 512",children:h("path",{d:"M15 15C24.4 5.7 39.6 5.7 49 15l63 63L112 40c0-13.3 10.7-24 24-24s24 10.7 24 24l0 96c0 13.3-10.7 24-24 24l-96 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l38.1 0L15 49C5.7 39.6 5.7 24.4 15 15zM133.5 243.9C158.6 193.6 222.7 112 320 112s161.4 81.6 186.5 131.9c3.8 7.6 3.8 16.5 0 24.2C481.4 318.4 417.3 400 320 400s-161.4-81.6-186.5-131.9c-3.8-7.6-3.8-16.5 0-24.2zM320 320a64 64 0 1 0 0-128 64 64 0 1 0 0 128zM591 15c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-63 63 38.1 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-96 0c-13.3 0-24-10.7-24-24l0-96c0-13.3 10.7-24 24-24s24 10.7 24 24l0 38.1 63-63zM15 497c-9.4-9.4-9.4-24.6 0-33.9l63-63L40 400c-13.3 0-24-10.7-24-24s10.7-24 24-24l96 0c13.3 0 24 10.7 24 24l0 96c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-38.1L49 497c-9.4 9.4-24.6 9.4-33.9 0zm576 0l-63-63 0 38.1c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-96c0-13.3 10.7-24 24-24l96 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-38.1 0 63 63c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0z"})}),U);import hE from"clsx";import ku,{useEffect as F5,useRef as gE,useState as H5}from"react";import B5 from"react";import{jsx as Cu}from"react/jsx-runtime";var z5=({size:e="1em",circleWidth:o=8,synchronized:t=!1,className:r=""})=>{let i=-(B5.useRef(Date.now()).current%1600);return Cu("div",{className:`Spinner ${r}`,children:Cu("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:Cu("circle",{cx:"50",cy:"50",r:50-o/2,strokeWidth:o,fill:"none",strokeMiterlimit:"10"})})})},At=z5;import{jsx as Pl,jsxs as Dl}from"react/jsx-runtime";var K=ku.forwardRef(({size:e="medium",visible:o=!0,className:t="",...r},n)=>{let{id:i}=st(),a=ku.useRef(null);ku.useImperativeHandle(n,()=>a.current);let l=`ToolIcon_size_${e}`,[s,c]=H5(!1),m=gE(!0),d=async u=>{let f="onClick"in r&&r.onClick?.(u);if(Wr(f))try{c(!0),await f}catch(b){if(b instanceof Wi)console.warn(b);else throw b}finally{m.current&&c(!1)}};F5(()=>(m.current=!0,()=>{m.current=!1}),[]);let p=gE(null);if(r.type==="button"||r.type==="icon"||r.type==="submit"){let u=r.type==="icon"?"button":r.type;return Dl("button",{className:hE("ToolIcon_type_button",l,t,o&&!r.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!r.hidden,"ToolIcon--selected":r.selected,"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:u,onClick:d,ref:a,disabled:s||r.isLoading||!!r.disabled,children:[(r.icon||r.label)&&Dl("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!r.disabled,children:[r.icon||r.label,r.keyBindingLabel&&Pl("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel}),r.isLoading&&Pl(At,{})]}),r.showAriaLabel&&Dl("div",{className:"ToolIcon__label",children:[r["aria-label"]," ",s&&Pl(At,{})]}),r.children]})}return Dl("label",{className:hE("ToolIcon",t),title:r.title,onPointerDown:u=>{p.current=u.pointerType||null,r.onPointerDown?.({pointerType:u.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{p.current=null})},children:[Pl("input",{className:`ToolIcon_type_radio ${l}`,type:"radio",name:r.name,"aria-label":r["aria-label"],"aria-keyshortcuts":r["aria-keyshortcuts"],"data-testid":r["data-testid"],id:`${i}-${r.id}`,onChange:()=>{r.onChange?.({pointerType:p.current})},checked:r.checked,ref:a}),Dl("div",{className:"ToolIcon__icon",children:[r.icon,r.keyBindingLabel&&Pl("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel})]})]})});K.displayName="ToolButton";var Jc=[],B=e=>(Jc=Jc.concat(e),e);import{jsx as G5}from"react/jsx-runtime";var U5=(e,o,t)=>{let r=new Set(q(e.filter(m=>ce(m)),o).map(m=>m.id)),n={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let m of r){let d=Wo(e,m);for(let p of d)if(!a.has(p.id)){if(rt(p)){let u=vo(p,i);u&&(n[u.id]=!0)}else n[p.id]=!0;a.add(p.id)}}let l=!0,s=e.map(m=>{if(o.selectedElementIds[m.id]){let d=rt(m)?vo(m,i):null;return m.frameId&&r.has(m.frameId)?(l=!1,n[m.id]=!0,m):d?.frameId&&r.has(d?.frameId)?m:(m.boundElements&&m.boundElements.forEach(p=>{let u=t.scene.getNonDeletedElementsMap().get(p.id);u&&se(u)&&t.scene.mutateElement(u,{startBinding:m.id===u.startBinding?.elementId?null:u.startBinding,endBinding:m.id===u.endBinding?.elementId?null:u.endBinding})}),te(m,{isDeleted:!0}))}return m.frameId&&r.has(m.frameId)?(l=!1,rt(m)||(n[m.id]=!0),te(m,{frameId:null})):rt(m)&&o.selectedElementIds[m.containerId]?te(m,{isDeleted:!0}):m}),c=o.editingGroupId;if(l&&o.editingGroupId){let m=He(s,o.editingGroupId).filter(d=>!d.isDeleted);if(m.length>1)m[0]&&(n[m[0].id]=!0);else{c=null,m[0]&&(n[m[0].id]=!0);let d=m[0];if(d){let p=d.groupIds.findIndex(f=>f===o.editingGroupId),u=d.groupIds[p+1];if(u){let f=He(s,u).filter(b=>!b.isDeleted);f.length>1&&(c=u,f.forEach(b=>{n[b.id]=!0}))}}}}return{elements:s,appState:{...o,...it({selectedElementIds:n,editingGroupId:c},s,o,null)}}},fE=(e,o)=>{if(e.editingGroupId){let t=He(fe(o),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},Rl=B({name:"deleteSelectedElements",label:"labels.delete",icon:Lr,trackEvent:{category:"element",action:"delete"},perform:(e,o,t,r)=>{if(o.editingLinearElement){let{elementId:a,selectedPointsIndices:l,startBindingElement:s,endBindingElement:c}=o.editingLinearElement,m=r.scene.getNonDeletedElementsMap(),d=$.getElement(a,m);if(!d||l==null)return!1;if(d.points.length<2){let u=e.map(b=>b.id===d.id?te(b,{isDeleted:!0}):b),f=fE(o,u);return{elements:u,appState:{...f,editingLinearElement:null},captureUpdate:A.IMMEDIATELY}}let p={startBindingElement:l?.includes(0)?null:s,endBindingElement:l?.includes(d.points.length-1)?null:c};return $.deletePoints(d,r,l),{elements:e,appState:{...o,editingLinearElement:{...o.editingLinearElement,...p,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},captureUpdate:A.IMMEDIATELY}}let{elements:n,appState:i}=U5(e,o,r);return nc(n,n.filter(a=>a.isDeleted)),i=fE(i,n),{elements:n,appState:{...i,activeTool:Le(o,{type:"selection"}),multiElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:De(fe(e),o)?A.IMMEDIATELY:A.EVENTUALLY}},keyTest:(e,o,t)=>(e.key===w.BACKSPACE||e.key===w.DELETE)&&!e[w.CTRL_OR_CMD],PanelComponent:({elements:e,appState:o,updateData:t})=>G5(K,{type:"button",icon:Lr,title:g("labels.delete"),"aria-label":g("labels.delete"),onClick:()=>t(null),visible:De(fe(e),o)})});import{jsx as Qc}from"react/jsx-runtime";var Su=B({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:au,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:j0(e,o,r.scene),appState:o,captureUpdate:A.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[w.CTRL_OR_CMD]&&!e.shiftKey&&e.code===le.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>Qc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendBackward")} \u2014 ${D("CtrlOrCmd+[")}`,children:au})}),Iu=B({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:iu,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:q0(e,o,r.scene),appState:o,captureUpdate:A.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[w.CTRL_OR_CMD]&&!e.shiftKey&&e.code===le.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>Qc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.bringForward")} \u2014 ${D("CtrlOrCmd+]")}`,children:iu})}),Mu=B({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:su,trackEvent:{category:"element"},perform:(e,o)=>({elements:J0(e,o),appState:o,captureUpdate:A.IMMEDIATELY}),keyTest:e=>Bo?e[w.CTRL_OR_CMD]&&e.altKey&&e.code===le.BRACKET_LEFT:e[w.CTRL_OR_CMD]&&e.shiftKey&&e.code===le.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>Qc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendToBack")} \u2014 ${Bo?D("CtrlOrCmd+Alt+["):D("CtrlOrCmd+Shift+[")}`,children:su})}),Lu=B({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:lu,trackEvent:{category:"element"},perform:(e,o)=>({elements:Q0(e,o),appState:o,captureUpdate:A.IMMEDIATELY}),keyTest:e=>Bo?e[w.CTRL_OR_CMD]&&e.altKey&&e.code===le.BRACKET_RIGHT:e[w.CTRL_OR_CMD]&&e.shiftKey&&e.code===le.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>Qc("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${g("labels.bringToFront")} \u2014 ${Bo?D("CtrlOrCmd+Alt+]"):D("CtrlOrCmd+Shift+]")}`,children:lu})});var Au=B({name:"selectAll",label:"labels.selectAll",icon:tE,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,o,t,r)=>{if(o.editingLinearElement)return!1;let n=e.filter(i=>!i.isDeleted&&!(V(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...o,...it({editingGroupId:null,selectedElementIds:n},fe(e),o,r),selectedLinearElement:Object.keys(n).length===1&&ge(e[0])?new $(e[0],j(e)):null},captureUpdate:A.IMMEDIATELY}},keyTest:e=>e[w.CTRL_OR_CMD]&&e.key===w.A});import{jsx as Y5}from"react/jsx-runtime";var _u=B({name:"duplicateSelection",label:"labels.duplicateSelection",icon:kl,trackEvent:{category:"element"},perform:(e,o,t,r)=>{if(o.selectedElementsAreBeingDragged)return!1;if(o.editingLinearElement)try{let a=$.duplicateSelectedPoints(o,r.scene);return{elements:e,appState:a,captureUpdate:A.IMMEDIATELY}}catch{return!1}let{duplicatedElements:n,elementsWithDuplicates:i}=qn({type:"in-place",elements:e,idsOfElementsToDuplicate:j(q(e,o,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:o,randomizeSeed:!0,overrides:({origElement:a,origIdToDuplicateId:l})=>{let s=a.frameId&&l.get(a.frameId);return{x:a.x+Jm/2,y:a.y+Jm/2,frameId:s??a.frameId}}});if(r.props.onDuplicate&&i){let a=r.props.onDuplicate(i,e);a&&(i=a)}return{elements:nr(i,j(n)),appState:{...o,...sc(n,fe(i),o)},captureUpdate:A.IMMEDIATELY}},keyTest:e=>e[w.CTRL_OR_CMD]&&e.key===w.D,PanelComponent:({elements:e,appState:o,updateData:t})=>Y5(K,{type:"button",icon:kl,title:`${g("labels.duplicateSelection")} \u2014 ${D("CtrlOrCmd+D")}`,"aria-label":g("labels.duplicateSelection"),onClick:()=>t(null),visible:De(fe(e),o)})});import{useEffect as Ju,useMemo as E4,useRef as Qu,useState as y4}from"react";var W5=new Set(["command_palette","export"]),me=(e,o,t,r)=>{try{if(typeof window>"u"||C.VITE_WORKER_ID||C.VITE_APP_ENABLE_TRACKING!=="true"||!W5.has(e)||ft())return;C.PROD||console.info("trackEvent",{category:e,action:o,label:t,value:r}),window.sa_event&&window.sa_event(o,{category:e,label:t,value:r})}catch(n){console.error("error during analytics",n)}};import X5 from"clsx";import V5 from"clsx";import{forwardRef as K5}from"react";import{jsx as Z5}from"react/jsx-runtime";var ia=K5((e,o)=>{let{title:t,className:r,testId:n,active:i,standalone:a,icon:l,onClick:s}=e;return Z5("button",{type:"button",ref:o,title:t,"data-testid":n,className:V5(r,{standalone:a,active:i}),onClick:s,style:e.style,children:l},t)});import{Fragment as j5,jsx as Pu,jsxs as $5}from"react/jsx-runtime";var So=e=>Pu(j5,{children:e.options.map(o=>e.type==="button"?Pu(ia,{icon:o.icon,title:o.text,testId:o.testId,active:o.active??e.value===o.value,onClick:t=>e.onClick(o.value,t)},o.text):$5("label",{className:X5({active:e.value===o.value}),title:o.text,children:[Pu("input",{type:"radio",name:e.group,onChange:()=>e.onChange(o.value),checked:e.value===o.value,"data-testid":o.testId}),o.icon]},o.text))});import*as id from"@radix-ui/react-popover";import N6 from"clsx";import{useRef as O6}from"react";import{jsx as q5}from"react/jsx-runtime";var ed=()=>q5("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as t6,useRef as o6}from"react";import{createPortal as r6}from"react-dom";import bE from"react";var Du=bE.createContext(null),Me=()=>bE.useContext(Du);import{useState as J5,useLayoutEffect as xE}from"react";var td=e=>{let[o,t]=J5(null),r=xe(),{theme:n}=Me(),{container:i}=st();return xE(()=>{o&&(o.className="",o.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),o.classList.toggle("excalidraw--mobile",r.editor.isMobile),o.classList.toggle("theme--dark",n===re.DARK))},[o,n,r.editor.isMobile,e?.className]),xE(()=>{let a=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!a)return;let l=document.createElement("div");return a.appendChild(l),t(l),()=>{a.removeChild(l)}},[i,e?.parentSelector]),o};import{useEffect as Q5}from"react";function aa(e,o,t){Q5(()=>{function r(n){let i=n;if(!e.current)return;let a=t?.(i,e.current);if(a===!0)return;if(a===!1)return o(i);e.current.contains(i.target)||!document.documentElement.contains(i.target)||i.target.closest("[data-radix-portal]")||i.target===document.documentElement&&document.body.style.pointerEvents==="none"||i.target.closest("[data-prevent-outside-click]")||o(i)}return document.addEventListener("pointerdown",r),document.addEventListener("touchstart",r),()=>{document.removeEventListener("pointerdown",r),document.removeEventListener("touchstart",r)}},[e,o,t])}import{useRef as e6}from"react";var dn=e=>{let o=e6(e);return Object.assign(o.current,e),o.current};import{jsx as n6}from"react/jsx-runtime";var mn=Ie(null),EE=({onCancel:e,onChange:o,onSelect:t,colorPickerType:r})=>{let n=td({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=Me(),a=pn(),l=tt(),s=q(a,i),c=dn({app:l,onCancel:e,onChange:o,onSelect:t,selectedElements:s}),{container:m}=st();t6(()=>{let p=d.current;if(!p||!l.canvas||!n)return;let u=!1,f=l.canvas.getContext("2d"),b=({clientX:S,clientY:P})=>{let M=f.getImageData((S-i.offsetLeft)*window.devicePixelRatio,(P-i.offsetTop)*window.devicePixelRatio,1,1).data;return Pf(M[0],M[1],M[2])},x=({clientX:S,clientY:P,altKey:M})=>{p.style.top=`${P+20}px`,p.style.left=`${S+20}px`;let O=b({clientX:S,clientY:P});u&&c.onChange(r,O,c.selectedElements,{altKey:M}),p.style.background=O},E=()=>{c.onCancel()},y=(S,P)=>{c.onSelect(S,P)},v=S=>{u=!0,S.stopImmediatePropagation()},T=S=>{u=!1,m?.focus(),S.stopImmediatePropagation(),S.preventDefault(),y(b(S),S)},I=S=>{S.key===w.ESCAPE&&(S.preventDefault(),S.stopImmediatePropagation(),E())};return n.tabIndex=-1,n.focus(),x({clientX:c.app.lastViewportPosition.x,clientY:c.app.lastViewportPosition.y,altKey:!1}),n.addEventListener("keydown",I),n.addEventListener("pointerdown",v),n.addEventListener("pointerup",T),window.addEventListener("pointermove",x,{passive:!0}),window.addEventListener("blur",E),()=>{u=!1,n.removeEventListener("keydown",I),n.removeEventListener("pointerdown",v),n.removeEventListener("pointerup",T),window.removeEventListener("pointermove",x),window.removeEventListener("blur",E)}},[c,l.canvas,n,r,m,i.offsetLeft,i.offsetTop]);let d=o6(null);return aa(d,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),n?r6(n6("div",{ref:d,className:"excalidraw-eye-dropper-preview"}),n):null};import*as la from"@radix-ui/react-popover";import s6 from"clsx";import c6 from"react";import i6 from"react";import a6 from"clsx";import{jsx as l6}from"react/jsx-runtime";var xt=i6.forwardRef(({children:e,padding:o,className:t,style:r},n)=>l6("div",{className:a6("Island",t),style:{"--padding":o,...r},ref:n,children:e}));import{jsx as Ru,jsxs as d6}from"react/jsx-runtime";var od=c6.forwardRef(({className:e,container:o,children:t,style:r,onClose:n,onKeyDown:i,onFocusOutside:a,onPointerLeave:l,onPointerDownOutside:s},c)=>{let m=xe();return Ru(la.Portal,{container:o,children:d6(la.Content,{ref:c,className:s6("focus-visible-none",e),"data-prevent-outside-click":!0,side:m.editor.isMobile&&!m.viewport.isLandscape?"bottom":"right",align:m.editor.isMobile&&!m.viewport.isLandscape?"center":"start",alignOffset:-16,sideOffset:20,style:{zIndex:"var(--zIndex-popup)"},onPointerLeave:l,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:s,onCloseAutoFocus:d=>{d.stopPropagation(),d.preventDefault(),o&&!m1(document.activeElement)&&o.focus(),n()},children:[Ru(xt,{padding:3,style:r,children:t}),Ru(la.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})});import m6 from"clsx";import{useCallback as p6,useEffect as Ou,useRef as wE,useState as u6}from"react";var un=({palette:e,color:o})=>{if(!o)return null;for(let[t,r]of Object.entries(e))if(Array.isArray(r)){let n=r.indexOf(o);if(n>-1)return{colorName:t,shade:n}}else if(r===o)return{colorName:t,shade:null};return null},Nl=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),Nu=({color:e,palette:o})=>!Object.values(o).flat().includes(e),vE=(e,o,t)=>{let r={elementBackground:"backgroundColor",elementStroke:"strokeColor"},n=e.filter(a=>{if(a.isDeleted)return!1;let l=a[r[o]];return Nu({color:l,palette:t})}),i=new Map;return n.forEach(a=>{let l=a[r[o]];i.has(l)?i.set(l,i.get(l)+1):i.set(l,1)}),[...i.entries()].sort((a,l)=>l[1]-a[1]).map(a=>a[0]).slice(0,kf)},Mo=Ie(null),yE=(e,o,t)=>(e*299+o*587+t*114)/1e3,sa=(e,o=160)=>{if(!e)return!0;if(e==="transparent")return!1;if(!e.startsWith("#")){let i=document.createElement("div");if(i.style.color=e,i.style.color){i.style.position="absolute",i.style.visibility="hidden",i.style.width="0",i.style.height="0",document.body.appendChild(i);let a=getComputedStyle(i).color;document.body.removeChild(i);let l=a.replace(/^(rgb|rgba)\(/,"").replace(/\)$/,"").replace(/\s/g,"").split(","),s=parseInt(l[0]),c=parseInt(l[1]),m=parseInt(l[2]);return yE(s,c,m)<o}return!0}let t=parseInt(e.slice(1,3),16),r=parseInt(e.slice(3,5),16),n=parseInt(e.slice(5,7),16);return yE(t,r,n)<o};import{Fragment as h6,jsx as rd,jsxs as TE}from"react/jsx-runtime";var CE=({color:e,onChange:o,label:t,colorPickerType:r,placeholder:n})=>{let i=xe(),[a,l]=u6(e),[s,c]=Ee(Mo);Ou(()=>{l(e)},[e]);let m=p6(b=>{let x=b.toLowerCase(),E=kE(x);E&&o(E),l(x)},[o]),d=wE(null),p=wE(null);Ou(()=>{d.current&&d.current.focus()},[s]);let[u,f]=Ee(mn);return Ou(()=>()=>{f(null)},[f]),TE("div",{className:"color-picker__input-label",children:[rd("div",{className:"color-picker__input-hash",children:"#"}),rd("input",{ref:s==="hex"?d:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,onChange:b=>{m(b.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{l(e)},tabIndex:-1,onFocus:()=>c("hex"),onKeyDown:b=>{b.key!==w.TAB&&(b.key===w.ESCAPE&&p.current?.focus(),b.stopPropagation())},placeholder:n}),!i.editor.isMobile&&TE(h6,{children:[rd("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),rd("div",{ref:p,className:m6("excalidraw-eye-dropper-trigger",{selected:u}),onClick:()=>f(b=>b?null:{keepOpenOnAlt:!1,onSelect:x=>o(x),colorPickerType:r}),title:`${g("labels.eyeDropper")} \u2014 ${w.I.toLocaleUpperCase()} or ${D("Alt")} `,children:Vx})]})]})};import Hu,{useEffect as Uu,useImperativeHandle as P6,useState as D6}from"react";import b6 from"clsx";import{useEffect as x6,useRef as E6}from"react";import{jsxs as f6}from"react/jsx-runtime";var g6=({color:e,keyLabel:o,isShade:t=!1})=>f6("div",{className:"color-picker__button__hotkey-label",style:{color:sa(e)?"#fff":"#000"},children:[t&&"\u21E7",o]}),ca=g6;import{jsx as Bu,jsxs as y6}from"react/jsx-runtime";var SE=({colors:e,color:o,onChange:t,label:r})=>{let[n,i]=Ee(Mo),a=E6(null);return x6(()=>{a.current&&a.current.focus()},[o,n]),Bu("div",{className:"color-picker-content--default",children:e.map((l,s)=>y6("button",{ref:o===l?a:void 0,tabIndex:-1,type:"button",className:b6("color-picker__button color-picker__button--large has-outline",{active:o===l,"is-transparent":l==="transparent"||!l}),onClick:()=>{t(l),i("custom")},title:l,"aria-label":r,style:{"--swatch-color":l},children:[Bu("div",{className:"color-picker__button-outline"}),Bu(ca,{color:l,keyLabel:s+1})]},s))})};import v6 from"clsx";import{useEffect as w6,useRef as T6}from"react";import{jsx as zu,jsxs as k6}from"react/jsx-runtime";var C6=({palette:e,color:o,onChange:t,activeShade:r})=>{let n=un({color:o,palette:e}),[i,a]=Ee(Mo),l=T6(null);return w6(()=>{l.current&&i==="baseColors"&&l.current.focus()},[n?.colorName,i]),zu("div",{className:"color-picker-content--default",children:Object.entries(e).map(([s,c],m)=>{let d=(Array.isArray(c)?c[r]:c)||"transparent",p=Nl[m],u=g(`colors.${s.replace(/\d+/,"")}`,null,"");return k6("button",{ref:n?.colorName===s?l:void 0,tabIndex:-1,type:"button",className:v6("color-picker__button color-picker__button--large has-outline",{active:n?.colorName===s,"is-transparent":d==="transparent"||!d}),onClick:()=>{t(d),a("baseColors")},title:`${u}${d.startsWith("#")?` ${d}`:""} \u2014 ${p}`,"aria-label":`${u} \u2014 ${p}`,style:d?{"--swatch-color":d}:void 0,"data-testid":`color-${s}`,children:[zu("div",{className:"color-picker__button-outline"}),zu(ca,{color:d,keyLabel:p})]},s)})})},IE=C6;import{jsx as I6}from"react/jsx-runtime";var S6=({children:e})=>I6("div",{className:"color-picker__heading",children:e}),da=S6;import M6 from"clsx";import{useEffect as L6,useRef as A6}from"react";import{jsx as Ol,jsxs as ME}from"react/jsx-runtime";var LE=({color:e,onChange:o,palette:t})=>{let r=un({color:e||"transparent",palette:t}),[n,i]=Ee(Mo),a=A6(null);if(L6(()=>{a.current&&n==="shades"&&a.current.focus()},[r,n]),r){let{colorName:l,shade:s}=r,c=t[l];if(Array.isArray(c))return Ol("div",{className:"color-picker-content--default shades",children:c.map((m,d)=>ME("button",{ref:d===s&&n==="shades"?a:void 0,tabIndex:-1,type:"button",className:M6("color-picker__button color-picker__button--large has-outline",{active:d===s}),"aria-label":"Shade",title:`${l} - ${d+1}`,style:m?{"--swatch-color":m}:void 0,onClick:()=>{o(m),i("shades")},children:[Ol("div",{className:"color-picker__button-outline"}),Ol(ca,{color:m,keyLabel:d+1,isShade:!0})]},d))})}return ME("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Ol("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Ol("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:g("colorPicker.noShades")})]})};var Fu=(e,o,t)=>{let r=Math.ceil(t/On);switch(o=o??-1,e){case"ArrowLeft":{let n=o-1;return n<0?t-1:n}case"ArrowRight":return(o+1)%t;case"ArrowDown":{let n=o+On;return n>=t?o%On:n}case"ArrowUp":{let n=o-On,i=n<0?On*r+n:n;return i>=t?void 0:i}}},_6=({e,colorObj:o,onChange:t,palette:r,customColors:n,setActiveColorPickerSection:i,activeShade:a})=>{if(o?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let l=Number(e.code.slice(-1))-1;return t(r[o.colorName][l]),i("shades"),!0}if(["1","2","3","4","5"].includes(e.key)&&n[Number(e.key)-1])return t(n[Number(e.key)-1]),i("custom"),!0;if(Nl.includes(e.key)){let l=Nl.indexOf(e.key),s=Object.keys(r)[l],c=r[s],m=Array.isArray(c)?c[a]:c;return t(m),i("baseColors"),!0}return!1},AE=({event:e,activeColorPickerSection:o,palette:t,color:r,onChange:n,customColors:i,setActiveColorPickerSection:a,updateData:l,activeShade:s,onEyeDropperToggle:c,onEscape:m})=>{if(e[w.CTRL_OR_CMD])return!1;if(e.key===w.ESCAPE)return m(e),!0;if(e.key===w.ALT)return c(!0),!0;if(e.key===w.I)return c(),!0;let d=un({color:r,palette:t});if(e.key===w.TAB){let p={custom:!!i.length,baseColors:!0,shades:d?.shade!=null,hex:!0},u=Object.entries(p).reduce((y,[v,T])=>(T&&y.push(v),y),[]),f=u.indexOf(o),b=e.shiftKey?-1:1,x=f+b>u.length-1?0:f+b<0?u.length-1:f+b,E=u[x];return E&&a(E),E==="custom"?n(i[0]):E==="baseColors"&&(Object.entries(t).find(([v,T])=>Array.isArray(T)?T.includes(r):T===r?v:null)||n(bo.black)),e.preventDefault(),e.stopPropagation(),!0}if(_6({e,colorObj:d,onChange:n,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:s}))return!0;if(o==="shades"&&d){let{shade:p}=d,u=Fu(e.key,p,On);if(u!==void 0)return n(t[d.colorName][u]),!0}if(o==="baseColors"&&d){let{colorName:p}=d,u=Object.keys(t),f=u.indexOf(p),b=Fu(e.key,f,u.length);if(b!==void 0){let x=u[b],E=t[x];return n(Array.isArray(E)?E[s]:E),!0}}if(o==="custom"){let p=r!=null?i.indexOf(r):0,u=Fu(e.key,p,i.length);if(u!==void 0){let f=i[u];return n(f),!0}}return!1};import{jsx as ni,jsxs as nd}from"react/jsx-runtime";var _E=Hu.forwardRef(({color:e,onChange:o,type:t,elements:r,palette:n,updateData:i,children:a,onEyeDropperToggle:l,onEscape:s},c)=>{let[m]=Hu.useState(()=>t==="canvasBackground"?[]:vE(r,t,n)),[d,p]=Ee(Mo),u=un({color:e,palette:n});Uu(()=>{if(!d){let E=!!e&&Nu({color:e,palette:n}),y=E&&!m.includes(e);p(y?null:E?"custom":u?.shade!=null?"shades":"baseColors")}},[d,e,n,p,u,m]);let[f,b]=D6(u?.shade??(t==="elementBackground"?Mf:If));Uu(()=>{u?.shade!=null&&b(u.shade);let E=y=>{y.key===w.ALT&&l(!1)};return document.addEventListener("keyup",E,{capture:!0}),()=>{document.removeEventListener("keyup",E,{capture:!0})}},[u,l]);let x=Hu.useRef(null);return P6(c,()=>x.current),Uu(()=>{x?.current?.focus()},[]),ni("div",{role:"dialog","aria-modal":"true","aria-label":g("labels.colorPicker"),children:nd("div",{ref:x,onKeyDown:E=>{AE({event:E,activeColorPickerSection:d,palette:n,color:e,onChange:o,onEyeDropperToggle:l,customColors:m,setActiveColorPickerSection:p,updateData:i,activeShade:f,onEscape:s})&&(E.preventDefault(),E.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[!!m.length&&nd("div",{children:[ni(da,{children:g("colorPicker.mostUsedCustomColors")}),ni(SE,{colors:m,color:e,label:g("colorPicker.mostUsedCustomColors"),onChange:o})]}),nd("div",{children:[ni(da,{children:g("colorPicker.colors")}),ni(IE,{color:e,palette:n,onChange:o,activeShade:f})]}),nd("div",{children:[ni(da,{children:g("colorPicker.shades")}),ni(LE,{color:e,onChange:o,palette:n})]}),a]})})});import R6 from"clsx";import{jsx as Gu}from"react/jsx-runtime";var PE=({onChange:e,type:o,activeColor:t,topPicks:r})=>{let n;return o==="elementStroke"&&(n=Ss),o==="elementBackground"&&(n=Is),o==="canvasBackground"&&(n=Ms),r&&(n=r),n?Gu("div",{className:"color-picker__top-picks",children:n.map(i=>Gu("button",{className:R6("color-picker__button",{active:i===t,"is-transparent":i==="transparent"||!i,"has-outline":!sa(i,ks)}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:Gu("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};import{jsx as Xo,jsxs as Yu}from"react/jsx-runtime";var DE=e=>{let o=new Option().style;return o.color=e,!!o.color},kE=e=>vr(e)?e:DE(`#${e}`)?`#${e}`:DE(e)?e:null,B6=({type:e,color:o,onChange:t,label:r,elements:n,palette:i=bo,updateData:a})=>{let{container:l}=st(),[,s]=Ee(Mo),[c,m]=Ee(mn),d=Yu("div",{children:[Xo(da,{children:g("colorPicker.hexCode")}),Xo(CE,{color:o||"",label:r,onChange:f=>{t(f)},colorPickerType:e,placeholder:g("colorPicker.color")})]}),p=O6(null),u=()=>{p.current?.focus()};return Xo(od,{container:l,style:{maxWidth:"13rem"},onFocusOutside:f=>{u(),f.preventDefault()},onPointerDownOutside:f=>{c&&f.preventDefault()},onClose:()=>{a({openPopup:null}),s(null)},children:i?Xo(_E,{ref:p,palette:i,color:o,onChange:f=>{t(f)},onEyeDropperToggle:f=>{m(b=>f?(b=b||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},b.keepOpenOnAlt=!0,b):f===!1||b?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:f=>{c?m(null):a({openPopup:null})},type:e,elements:n,updateData:a,children:d}):d})},z6=({label:e,color:o,type:t})=>Xo(id.Trigger,{type:"button",className:N6("color-picker__button active-color properties-trigger",{"is-transparent":!o||o==="transparent","has-outline":!o||!sa(o,ks)}),"aria-label":e,style:o?{"--swatch-color":o}:void 0,title:t==="elementStroke"?g("labels.showStroke"):g("labels.showBackground"),children:Xo("div",{className:"color-picker__button-outline",children:!o&&$b})}),Bl=({type:e,color:o,onChange:t,label:r,elements:n,palette:i=bo,topPicks:a,updateData:l,appState:s})=>Xo("div",{children:Yu("div",{role:"dialog","aria-modal":"true",className:"color-picker-container",children:[Xo(PE,{activeColor:o,onChange:t,type:e,topPicks:a}),Xo(ed,{}),Yu(id.Root,{open:s.openPopup===e,onOpenChange:c=>{l({openPopup:c?e:null})},children:[Xo(z6,{color:o,label:r,type:e}),s.openPopup===e&&Xo(B6,{type:e,color:o,onChange:t,label:r,elements:n,palette:i,updateData:l})]})]})});import*as YE from"@radix-ui/react-popover";import l4,{useCallback as s4,useMemo as c4}from"react";import e4,{useMemo as hn,useState as t4,useRef as o4,useEffect as r4,useCallback as n4}from"react";import F6 from"clsx";import H6 from"react";import{jsx as U6,jsxs as G6}from"react/jsx-runtime";var ad=H6.forwardRef(({className:e,placeholder:o,onChange:t},r)=>G6("div",{className:F6("QuickSearch__wrapper",e),children:[uo,U6("input",{ref:r,className:"QuickSearch__input",type:"text",placeholder:o,onChange:n=>t(n.target.value.trim().toLowerCase())})]}));import Y6 from"clsx";import{Children as W6}from"react";import{jsx as RE}from"react/jsx-runtime";var ld=({className:e,placeholder:o,children:t})=>{let r=!W6.count(t);return RE("div",{className:Y6("ScrollableList__wrapper",e),role:"menu",children:r?RE("div",{className:"empty",children:o}):t})};import{jsx as V6,jsxs as K6}from"react/jsx-runtime";var NE=({children:e,className:o="",style:t,title:r})=>K6("div",{className:`dropdown-menu-group ${o}`,style:t,children:[r&&V6("p",{className:"dropdown-menu-group-title",children:r}),e]}),zl=NE;NE.displayName="DropdownMenuGroup";import{useEffect as J6,useRef as Q6}from"react";import{Fragment as X6,jsx as Wu,jsxs as $6}from"react/jsx-runtime";var Z6=({textStyle:e,icon:o,shortcut:t,children:r})=>{let n=xe();return $6(X6,{children:[o&&Wu("div",{className:"dropdown-menu-item__icon",children:o}),Wu("div",{style:e,className:"dropdown-menu-item__text",children:r}),t&&!n.editor.isMobile&&Wu("div",{className:"dropdown-menu-item__shortcut",children:t})]})},sd=Z6;import j6,{useContext as q6}from"react";var Vu=j6.createContext({}),cd=(e="",o=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e}
2
- ${o?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),dd=(e,o)=>{let t=q6(Vu);return Vr(e,r=>{let n=new CustomEvent("menu.itemSelect",{bubbles:!0,cancelable:!0});o?.(n),n.defaultPrevented||t.onSelect?.(n)})};import{jsx as Ku}from"react/jsx-runtime";var Zu=({icon:e,value:o,order:t,children:r,shortcut:n,className:i,hovered:a,selected:l,textStyle:s,onSelect:c,onClick:m,...d})=>{let p=dd(m,c),u=Q6(null);return J6(()=>{a&&(t===0?u.current?.scrollIntoView({block:"end"}):u.current?.scrollIntoView({block:"nearest"}))},[a,t]),Ku("button",{...d,ref:u,value:o,onClick:p,className:cd(i,l,a),title:d.title??d["aria-label"],children:Ku(sd,{textStyle:s,icon:e,shortcut:n,children:r})})};Zu.displayName="DropdownMenuItem";var ma={GREEN:"green",RED:"red",BLUE:"blue"},md=({type:e=ma.BLUE,children:o})=>{let{theme:t}=sr(),r={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===re.LIGHT?"1.5px solid white":"none"};switch(e){case ma.GREEN:Object.assign(r,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case ma.RED:Object.assign(r,{backgroundColor:"pink",color:"darkred"});break;case ma.BLUE:default:Object.assign(r,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return Ku("div",{className:"DropDownMenuItemBadge",style:r,children:o})};md.displayName="DropdownMenuItemBadge";Zu.Badge=md;var Qt=Zu;var OE=({event:e,inputRef:o,hoveredFont:t,filteredFonts:r,onClose:n,onSelect:i,onHover:a})=>{if(!e[w.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===w.F)return o.current?.focus(),!0;if(e.key===w.ESCAPE)return n(),!0;if(e.key===w.ENTER)return t?.value&&i(t.value),!0;if(e.key===w.ARROW_DOWN)return t?.next?a(t.next.value):r[0]?.value&&a(r[0].value),!0;if(e.key===w.ARROW_UP)return t?.prev?a(t.prev.value):r[r.length-1]?.value&&a(r[r.length-1].value),!0};import{jsx as Fl,jsxs as BE}from"react/jsx-runtime";var i4=e=>{switch(e){case pt.Excalifont:case pt.Virgil:return lr;case pt.Nunito:case pt.Helvetica:return Ll;case pt["Lilita One"]:return Dx;case pt["Comic Shanns"]:case pt.Cascadia:return Yc;default:return Ll}},zE=e4.memo(({selectedFontFamily:e,hoveredFontFamily:o,onSelect:t,onHover:r,onLeave:n,onOpen:i,onClose:a})=>{let{container:l}=st(),{fonts:s}=tt(),{showDeprecatedFonts:c}=cr(),[m,d]=t4(""),p=o4(null),u=hn(()=>Array.from(on.registered.entries()).filter(([M,{metadata:O}])=>!O.private&&!O.fallback).map(([M,{metadata:O,fontFaces:R}])=>{let z={value:M,icon:i4(M),text:R[0]?.fontFace?.family??"Unknown"};return O.deprecated&&Object.assign(z,{deprecated:O.deprecated,badge:{type:ma.RED,placeholder:g("fontList.badge.old")}}),z}).sort((M,O)=>M.text.toLowerCase()>O.text.toLowerCase()?1:-1),[]),f=hn(()=>new Set(s.getSceneFamilies()),[e]),b=hn(()=>u.filter(M=>f.has(M.value)),[u,f]),x=hn(()=>u.filter(M=>!f.has(M.value)&&(c||!M.deprecated)),[u,f,c]),E=hn(()=>E1([...b,...x].filter(M=>M.text?.toLowerCase().includes(m))),[b,x,m]),y=hn(()=>{let M;return o?M=E.find(O=>O.value===o):e&&(M=E.find(O=>O.value===e)),!M&&m&&(E[0]?.value?r(E[0].value):n()),M},[o,e,m,E,r,n]),v=n4(M=>{OE({event:M,inputRef:p,hoveredFont:y,filteredFonts:E,onSelect:t,onHover:r,onClose:a})&&(M.preventDefault(),M.stopPropagation())},[y,E,t,r,a]);r4(()=>(i(),()=>{a()}),[]);let T=hn(()=>E.filter(M=>f.has(M.value)),[E,f]),I=hn(()=>E.filter(M=>!f.has(M.value)),[E,f]),S=(M,O)=>BE(Qt,{icon:M.icon,value:M.value,order:O,textStyle:{fontFamily:Hn({fontFamily:M.value})},hovered:M.value===y?.value,selected:M.value===e,tabIndex:M.value===e?0:-1,onClick:R=>{t(Number(R.currentTarget.value))},onMouseMove:()=>{y?.value!==M.value&&r(M.value)},children:[M.text,M.badge&&Fl(md,{type:M.badge.type,children:M.badge.placeholder})]},M.value),P=[];return T.length&&P.push(Fl(zl,{title:g("fontList.sceneFonts"),children:T.map(S)},"group_1")),I.length&&P.push(Fl(zl,{title:g("fontList.availableFonts"),children:I.map((M,O)=>S(M,O+T.length))},"group_2")),BE(od,{className:"properties-content",container:l,style:{width:"15rem"},onClose:a,onPointerLeave:n,onKeyDown:v,children:[Fl(ad,{ref:p,placeholder:g("quickSearch.placeholder"),onChange:Un(d,20)}),Fl(ld,{className:"dropdown-menu fonts manual-hover",placeholder:g("fontList.empty"),children:P.length?P:null})]})},(e,o)=>e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as FE from"@radix-ui/react-popover";import{useMemo as a4}from"react";import{jsx as Xu}from"react/jsx-runtime";var HE=({selectedFontFamily:e})=>{let o=a4(()=>!!(e&&!UE(e)),[e]);return Xu(FE.Trigger,{asChild:!0,children:Xu("div",{children:Xu(ia,{standalone:!0,icon:cn,title:g("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:o,onClick:()=>{}})})})};import{jsx as Hl,jsxs as GE}from"react/jsx-runtime";var WE=[{value:pt.Excalifont,icon:lr,text:g("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:pt.Nunito,icon:Ll,text:g("labels.normal"),testId:"font-family-normal"},{value:pt["Comic Shanns"],icon:Yc,text:g("labels.code"),testId:"font-family-code"}],d4=new Set(WE.map(e=>e.value)),UE=e=>e?d4.has(e):!1,VE=l4.memo(({isOpened:e,selectedFontFamily:o,hoveredFontFamily:t,onSelect:r,onHover:n,onLeave:i,onPopupChange:a})=>{let l=c4(()=>WE,[]),s=s4(c=>{c&&r(c)},[r]);return GE("div",{role:"dialog","aria-modal":"true",className:"FontPicker__container",children:[Hl("div",{className:"buttonList",children:Hl(So,{type:"button",options:l,value:o,onClick:s})}),Hl(ed,{}),GE(YE.Root,{open:e,onOpenChange:a,children:[Hl(HE,{selectedFontFamily:o}),e&&Hl(zE,{selectedFontFamily:o,hoveredFontFamily:t,onSelect:s,onHover:n,onLeave:i,onOpen:()=>a(!0),onClose:()=>a(!1)})]})]})},(e,o)=>e.isOpened===o.isOpened&&e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as pa from"@radix-ui/react-popover";import h4 from"clsx";import pd,{useEffect as g4}from"react";import{jsx as m4}from"react/jsx-runtime";var gn=({icon:e})=>m4("span",{style:{width:"1em",margin:"0 0.5ex 0 0.5ex",display:"inline-block",lineHeight:0,verticalAlign:"middle"},children:e});import{Fragment as u4,jsx as KE,jsxs as ZE}from"react/jsx-runtime";var p4=({label:e,open:o,openTrigger:t,children:r,className:n,showCollapsedIcon:i=!0})=>ZE(u4,{children:[ZE("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:n,onClick:t,children:[e,i&&KE(gn,{icon:o?pE:jc})]}),o&&KE("div",{style:{display:"flex",flexDirection:"column"},children:r})]}),Ul=p4;import{jsx as ii,jsxs as $u}from"react/jsx-runtime";var f4=Ie(!1);function b4({options:e,value:o,label:t,onChange:r,onClose:n,numberOfOptionsToAlwaysShow:i=e.length}){let a=xe(),l=u=>{let f=e.find(b=>b.keyBinding===u.key.toLowerCase());if(!(u.metaKey||u.altKey||u.ctrlKey)&&f)r(f.value),u.preventDefault();else if(u.key===w.TAB){let b=e.findIndex(E=>E.value===o),x=u.shiftKey?(e.length+b-1)%e.length:(b+1)%e.length;r(e[x].value)}else if(Fn(u.key)){let b=Ir().rtl,x=e.findIndex(E=>E.value===o);if(x!==-1){let E=e.length,y=x;switch(u.key){case(b?w.ARROW_LEFT:w.ARROW_RIGHT):y=(x+1)%E;break;case(b?w.ARROW_RIGHT:w.ARROW_LEFT):y=(E+x-1)%E;break;case w.ARROW_DOWN:{y=(x+(i??1))%E;break}case w.ARROW_UP:{y=(E+x-(i??1))%E;break}}r(e[y].value)}u.preventDefault()}else(u.key===w.ESCAPE||u.key===w.ENTER)&&(u.preventDefault(),n());u.nativeEvent.stopImmediatePropagation(),u.stopPropagation()},[s,c]=Ee(f4),m=pd.useMemo(()=>e.slice(0,i),[e,i]),d=pd.useMemo(()=>e.slice(i),[e,i]);g4(()=>{m.some(u=>u.value===o)||c(!0)},[o,m,c]);let p=u=>ii("div",{className:"picker-content",children:u.map((f,b)=>$u("button",{type:"button",className:h4("picker-option",{active:o===f.value}),onClick:x=>{r(f.value)},title:`${f.text} ${f.keyBinding&&`\u2014 ${f.keyBinding.toUpperCase()}`}`,"aria-label":f.text||"none","aria-keyshortcuts":f.keyBinding||void 0,ref:x=>{o===f.value&&setTimeout(()=>{x?.focus()},0)},children:[f.icon,f.keyBinding&&ii("span",{className:"picker-keybinding",children:f.keyBinding})]},f.text))});return ii(pa.Content,{side:a.editor.isMobile&&!a.viewport.isLandscape?"top":"bottom",align:"start",sideOffset:12,style:{zIndex:"var(--zIndex-popup)"},onKeyDown:l,children:$u("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":t,children:[p(m),d.length>0&&ii(Ul,{label:g("labels.more_options"),open:s,openTrigger:()=>{c(u=>!u)},className:"picker-collapsible",children:p(d)})]})})}function ju({value:e,label:o,options:t,onChange:r,group:n="",numberOfOptionsToAlwaysShow:i}){let[a,l]=pd.useState(!1),s=pd.useRef(null);return ii("div",{children:$u(pa.Root,{open:a,onOpenChange:c=>l(c),children:[ii(pa.Trigger,{name:n,type:"button","aria-label":o,onClick:()=>l(!a),ref:s,className:a?"active":"",children:t.find(c=>c.value===e)?.icon}),a&&ii(b4,{options:t,value:e,label:o,onChange:r,onClose:()=>{l(!1)},numberOfOptionsToAlwaysShow:i})]})})}import XE,{useEffect as x4}from"react";import{jsx as qu,jsxs as $E}from"react/jsx-runtime";var jE=({updateData:e,app:o,testId:t})=>{let r=XE.useRef(null),n=XE.useRef(null),i=o.scene.getSelectedElements(o.state),a=!0,l=i.at(0),c=i.reduce((m,d)=>(m!=null&&m!==d.opacity&&(a=!1),m==null||m>d.opacity?d.opacity:m),l?.opacity??null)??o.state.currentItemOpacity;return x4(()=>{if(r.current&&n.current){let m=r.current,d=n.current,p=m.offsetWidth,u=15,f=c/100*(p-u)+u/2;d.style.left=`${f}px`,m.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${c}%, var(--button-bg) ${c}%, var(--button-bg) 100%)`}},[c]),$E("label",{className:"control-label",children:[g("labels.opacity"),$E("div",{className:"range-wrapper",children:[qu("input",{style:{"--color-slider-track":a?void 0:"var(--button-bg)"},ref:r,type:"range",min:"0",max:"100",step:"10",onChange:m=>{e(+m.target.value)},value:c,className:"range-input","data-testid":t}),qu("div",{className:"value-bubble",ref:n,children:c!==0?c:null}),qu("div",{className:"zero-label",children:"0"})]})]})};import{Fragment as QE,jsx as ne,jsxs as to}from"react/jsx-runtime";var JE=.1,Ht=(e,o,t,r=!1)=>{let n=j(q(e,o,{includeBoundTextElement:r}));return e.map(i=>n.get(i.id)||i.id===o.editingTextElement?.id?t(i):i)},eo=function(e,o,t,r,n){let i=o.state.editingTextElement,a=fe(e),l=null;if(i&&(l=t(i)),!l)if(De(a,o.state)){let c=o.scene.getSelectedElements(o.state),m=r===!0?c:c.filter(d=>r(d));l=Zs(m,t)??(typeof n=="function"?n(!0):n)}else l=typeof n=="function"?n(!1):n;return l},v4=(e,o,t)=>rt(o)||!o.autoResize?o:t.mutateElement(o,{x:e.textAlign==="left"?e.x:e.x+(e.width-o.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-o.height)/2}),eh=(e,o,t,r,n)=>{let i=new Set,a=Ht(e,o,l=>{if(V(l)){let s=r(l);i.add(s);let c=te(l,{fontSize:s});return Ke(c,t.scene.getContainerElement(l),t.scene),c=v4(l,c,t.scene),c}return l},!0);return q(e,o,{includeBoundTextElement:!0}).forEach(l=>{V(l)&&$r(l,t.scene)}),{elements:a,appState:{...o,currentItemFontSize:i.size===1?[...i][0]:n??o.currentItemFontSize},captureUpdate:A.IMMEDIATELY}},w4=B({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,o,t)=>({...t.currentItemStrokeColor&&{elements:Ht(e,o,r=>hl(r.type)?te(r,{strokeColor:t.currentItemStrokeColor}):r,!0)},appState:{...o,...t},captureUpdate:t.currentItemStrokeColor?A.IMMEDIATELY:A.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>to(QE,{children:[ne("h3",{"aria-hidden":"true",children:g("labels.stroke")}),ne(Bl,{topPicks:r.props.strokeColorTopPicks??Ss,palette:Lf,type:"elementStroke",label:g("labels.stroke"),color:eo(e,r,n=>n.strokeColor,!0,n=>n?null:o.currentItemStrokeColor),onChange:n=>t({currentItemStrokeColor:n}),elements:e,appState:o,updateData:t})]})}),T4=B({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,o,t,r)=>{if(!t.currentItemBackgroundColor)return{appState:{...o,...t},captureUpdate:A.EVENTUALLY};let n,i=r.scene.getSelectedElements(o);if(!vr(t.currentItemBackgroundColor)&&i.every(l=>qe(l)&&O1(l.points))){let l=j(i);n=e.map(s=>l.has(s.id)&&qe(s)?te(s,{backgroundColor:t.currentItemBackgroundColor,...uc(s,!0)}):s)}else n=Ht(e,o,l=>te(l,{backgroundColor:t.currentItemBackgroundColor}));return{elements:n,appState:{...o,...t},captureUpdate:A.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>to(QE,{children:[ne("h3",{"aria-hidden":"true",children:g("labels.background")}),ne(Bl,{topPicks:r.props.backgroundColorTopPicks??Is,palette:Af,type:"elementBackground",label:g("labels.background"),color:eo(e,r,n=>n.backgroundColor,!0,n=>n?null:o.currentItemBackgroundColor),onChange:n=>t({currentItemBackgroundColor:n}),elements:e,appState:o,updateData:t})]})}),C4=B({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,o,t,r)=>(me("element","changeFillStyle",`${t} (${r.device.editor.isMobile?"mobile":"desktop"})`),{elements:Ht(e,o,n=>te(n,{fillStyle:t})),appState:{...o,currentItemFillStyle:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=q(e,o),i=n.length>0&&n.every(a=>a.fillStyle==="zigzag");return to("fieldset",{children:[ne("legend",{children:g("labels.fill")}),ne("div",{className:"buttonList",children:ne(So,{type:"button",options:[{value:"hachure",text:`${i?g("labels.zigzag"):g("labels.hachure")} (${D("Alt-Click")})`,icon:i?nx:ix,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:g("labels.crossHatch"),icon:ax,testId:"fill-cross-hatch"},{value:"solid",text:g("labels.solid"),icon:lx,testId:"fill-solid"}],value:eo(e,r,a=>a.fillStyle,a=>a.hasOwnProperty("fillStyle"),a=>a?null:o.currentItemFillStyle),onClick:(a,l)=>{let s=l.altKey&&a==="hachure"&&n.every(c=>c.fillStyle==="hachure")?"zigzag":a;t(s)}})})]})}}),k4=B({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,o,t)=>({elements:Ht(e,o,r=>te(r,{strokeWidth:t})),appState:{...o,currentItemStrokeWidth:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>to("fieldset",{children:[ne("legend",{children:g("labels.strokeWidth")}),ne("div",{className:"buttonList",children:ne(So,{group:"stroke-width",options:[{value:Bs.thin,text:g("labels.thin"),icon:bu,testId:"strokeWidth-thin"},{value:Bs.bold,text:g("labels.bold"),icon:sx,testId:"strokeWidth-bold"},{value:Bs.extraBold,text:g("labels.extraBold"),icon:cx,testId:"strokeWidth-extraBold"}],value:eo(e,r,n=>n.strokeWidth,n=>n.hasOwnProperty("strokeWidth"),n=>n?null:o.currentItemStrokeWidth),onChange:n=>t(n)})})]})}),S4=B({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,o,t)=>({elements:Ht(e,o,r=>te(r,{seed:Yn(),roughness:t})),appState:{...o,currentItemRoughness:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>to("fieldset",{children:[ne("legend",{children:g("labels.sloppiness")}),ne("div",{className:"buttonList",children:ne(So,{group:"sloppiness",options:[{value:0,text:g("labels.architect"),icon:px},{value:1,text:g("labels.artist"),icon:ux},{value:2,text:g("labels.cartoonist"),icon:hx}],value:eo(e,r,n=>n.roughness,n=>n.hasOwnProperty("roughness"),n=>n?null:o.currentItemRoughness),onChange:n=>t(n)})})]})}),zN=B({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,o,t)=>({elements:Ht(e,o,r=>te(r,{strokeStyle:t})),appState:{...o,currentItemStrokeStyle:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>to("fieldset",{children:[ne("legend",{children:g("labels.strokeStyle")}),ne("div",{className:"buttonList",children:ne(So,{group:"strokeStyle",options:[{value:"solid",text:g("labels.strokeStyle_solid"),icon:bu},{value:"dashed",text:g("labels.strokeStyle_dashed"),icon:dx},{value:"dotted",text:g("labels.strokeStyle_dotted"),icon:mx}],value:eo(e,r,n=>n.strokeStyle,n=>n.hasOwnProperty("strokeStyle"),n=>n?null:o.currentItemStrokeStyle),onChange:n=>t(n)})})]})}),I4=B({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,o,t)=>({elements:Ht(e,o,r=>te(r,{opacity:t}),!0),appState:{...o,currentItemOpacity:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({app:e,updateData:o})=>ne(jE,{updateData:o,app:e,testId:"opacity"})}),M4=B({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,o,t,r)=>eh(e,o,r,()=>t,t),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>to("fieldset",{children:[ne("legend",{children:g("labels.fontSize")}),ne("div",{className:"buttonList",children:ne(So,{group:"font-size",options:[{value:16,text:g("labels.small"),icon:Lx,testId:"fontSize-small"},{value:20,text:g("labels.medium"),icon:Ax,testId:"fontSize-medium"},{value:28,text:g("labels.large"),icon:_x,testId:"fontSize-large"},{value:36,text:g("labels.veryLarge"),icon:Px,testId:"fontSize-veryLarge"}],value:eo(e,r,n=>{if(V(n))return n.fontSize;let i=pe(n,r.scene.getNonDeletedElementsMap());return i?i.fontSize:null},n=>V(n)||pe(n,r.scene.getNonDeletedElementsMap())!==null,n=>n?null:o.currentItemFontSize||Er),onChange:n=>t(n)})})]})}),th=B({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:oi,trackEvent:!1,perform:(e,o,t,r)=>eh(e,o,r,n=>Math.round(1/(1+JE)*n.fontSize)),keyTest:e=>e[w.CTRL_OR_CMD]&&e.shiftKey&&(e.key===w.CHEVRON_LEFT||e.key===w.COMMA)}),oh=B({name:"increaseFontSize",label:"labels.increaseFontSize",icon:oi,trackEvent:!1,perform:(e,o,t,r)=>eh(e,o,r,n=>Math.round(n.fontSize*(1+JE))),keyTest:e=>e[w.CTRL_OR_CMD]&&e.shiftKey&&(e.key===w.CHEVRON_RIGHT||e.key===w.PERIOD)}),L4=B({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,o,t,r)=>{let{cachedElements:n,resetAll:i,resetContainers:a,...l}=t;if(i)return{elements:Ht(e,o,b=>{let x=n?.get(b.id);return x?te(b,{...x}):b},!0),appState:{...o,...l},captureUpdate:A.NEVER};let{currentItemFontFamily:s,currentHoveredFontFamily:c}=t,m=A.EVENTUALLY,d,p=!1;if(s)d=s,m=A.IMMEDIATELY;else if(c){d=c,m=A.EVENTUALLY;let f=q(e,o,{includeBoundTextElement:!0}).filter(b=>V(b));if(f.length>200)p=!0;else{let b=0,x=0;for(;b<f.length&&x<5e3;){let E=f[b];x+=E?.originalText.length||0,b++}x>5e3&&(p=!0)}}let u={appState:{...o,...l},captureUpdate:m};if(d&&!p){let f=new Map,b=new Set,x=!1,E=Array.from(on.loadedFontsCache.values()),y=Object.entries(pt).find(([I,S])=>S===d)?.[0];c&&y&&E.some(I=>I.startsWith(y))&&(x=!0),Object.assign(u,{elements:Ht(e,o,I=>{if(V(I)&&(I.fontFamily!==d||s)){let S=te(I,{fontFamily:d,lineHeight:zo(d)}),P=n?.get(I.containerId||"")||{},M=r.scene.getContainerElement(I);return a&&M&&P&&r.scene.mutateElement(M,{...P}),x||(b=new Set([...b,...Array.from(S.originalText)])),f.set(S,M),S}return I},!0)});let v=`10px ${Hn({fontFamily:d})}`,T=Array.from(b.values()).join();if(x||window.document.fonts.check(v,T))for(let[I,S]of f)Ke(I,S,r.scene);else window.document.fonts.load(v,T).then(I=>{for(let[S,P]of f){let M=r.scene.getElement(S.id),O=P?r.scene.getElement(P.id):null;M&&Ke(M,O,r.scene)}r.fonts.onLoaded(I)})}return u},PanelComponent:({elements:e,appState:o,app:t,updateData:r})=>{let n=Qu(new Map),i=Qu(null),[a,l]=y4({}),s=Qu(!0),c=E4(()=>{let m=(d,p)=>eo(d,t,u=>{if(V(u))return u.fontFamily;let f=pe(u,p);return f?f.fontFamily:null},u=>V(u)||pe(u,p)!==null,u=>u?null:o.currentItemFontFamily||Fr);return a.openPopup==="fontFamily"&&o.openPopup==="fontFamily"?m(Array.from(n.current?.values()??[]),n.current):!a.openPopup&&o.openPopup!=="fontFamily"?m(e,t.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,o,e,t]);return Ju(()=>{i.current=c},[c]),Ju(()=>{Object.keys(a).length&&(r(a),l({}))},[a]),Ju(()=>(s.current=!1,()=>{s.current=!0}),[]),to("fieldset",{children:[ne("legend",{children:g("labels.fontFamily")}),ne(VE,{isOpened:o.openPopup==="fontFamily",selectedFontFamily:c,hoveredFontFamily:o.currentHoveredFontFamily,onSelect:m=>{l({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:m}),n.current.clear()},onHover:m=>{l({currentHoveredFontFamily:m,cachedElements:new Map(n.current),resetContainers:!0})},onLeave:()=>{l({currentHoveredFontFamily:null,cachedElements:new Map(n.current),resetAll:!0})},onPopupChange:m=>{if(m){n.current.clear();let{editingTextElement:d}=o;if(d?.type==="text"){let p=t.scene.getElement(d.id);n.current.set(d.id,te(p||d,{},!0))}else{let p=q(e,o,{includeBoundTextElement:!0});for(let u of p)n.current.set(u.id,te(u,{},!0))}l({openPopup:"fontFamily"})}else{let d={openPopup:null,currentHoveredFontFamily:null,cachedElements:new Map(n.current),resetAll:!0};s.current?r({...a,...d}):l(d),n.current.clear()}}})]})}}),A4=B({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,o,t,r)=>({elements:Ht(e,o,n=>{if(V(n)){let i=te(n,{textAlign:t});return Ke(i,r.scene.getContainerElement(n),r.scene),i}return n},!0),appState:{...o,currentItemTextAlign:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=r.scene.getNonDeletedElementsMap();return to("fieldset",{children:[ne("legend",{children:g("labels.textAlign")}),ne("div",{className:"buttonList",children:ne(So,{group:"text-align",options:[{value:"left",text:g("labels.left"),icon:Rx,testId:"align-left"},{value:"center",text:g("labels.center"),icon:Nx,testId:"align-horizontal-center"},{value:"right",text:g("labels.right"),icon:Ox,testId:"align-right"}],value:eo(e,r,i=>{if(V(i))return i.textAlign;let a=pe(i,n);return a?a.textAlign:null},i=>V(i)||pe(i,n)!==null,i=>i?null:o.currentItemTextAlign),onChange:i=>t(i)})})]})}}),_4=B({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:Ht(e,o,n=>{if(V(n)){let i=te(n,{verticalAlign:t});return Ke(i,r.scene.getContainerElement(n),r.scene),i}return n},!0),appState:{...o},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>ne("fieldset",{children:ne("div",{className:"buttonList",children:ne(So,{group:"text-align",options:[{value:Xt.TOP,text:g("labels.alignTop"),icon:ne(Bx,{theme:o.theme}),testId:"align-top"},{value:Xt.MIDDLE,text:g("labels.centerVertically"),icon:ne(Fx,{theme:o.theme}),testId:"align-middle"},{value:Xt.BOTTOM,text:g("labels.alignBottom"),icon:ne(zx,{theme:o.theme}),testId:"align-bottom"}],value:eo(e,r,n=>{if(V(n)&&n.containerId)return n.verticalAlign;let i=pe(n,r.scene.getNonDeletedElementsMap());return i?i.verticalAlign:null},n=>V(n)||pe(n,r.scene.getNonDeletedElementsMap())!==null,n=>n?null:Xt.MIDDLE),onChange:n=>t(n)})})})}),FN=B({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,o,t)=>({elements:Ht(e,o,r=>se(r)?r:te(r,{roundness:t==="round"?{type:Kr(r.type)?ut.ADAPTIVE_RADIUS:ut.PROPORTIONAL_RADIUS}:null})),appState:{...o,currentItemRoundness:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r,renderAction:n})=>{let a=lc(fe(e),o).some(l=>l.roundness?.type===ut.LEGACY);return to("fieldset",{children:[ne("legend",{children:g("labels.edges")}),to("div",{className:"buttonList",children:[ne(So,{group:"edges",options:[{value:"sharp",text:g("labels.sharp"),icon:gx},{value:"round",text:g("labels.round"),icon:fx}],value:eo(e,r,l=>a?null:l.roundness?"round":"sharp",l=>!Pe(l)&&l.hasOwnProperty("roundness"),l=>l?null:o.currentItemRoundness),onChange:l=>t(l)}),n("togglePolygon")]})]})}}),qE=e=>[{value:null,text:g("labels.arrowhead_none"),keyBinding:"q",icon:bx},{value:"arrow",text:g("labels.arrowhead_arrow"),keyBinding:"w",icon:ne(xx,{flip:e})},{value:"triangle",text:g("labels.arrowhead_triangle"),icon:ne(wx,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:g("labels.arrowhead_triangle_outline"),icon:ne(Tx,{flip:e}),keyBinding:"r"},{value:"circle",text:g("labels.arrowhead_circle"),keyBinding:"a",icon:ne(Ex,{flip:e})},{value:"circle_outline",text:g("labels.arrowhead_circle_outline"),keyBinding:"s",icon:ne(yx,{flip:e})},{value:"diamond",text:g("labels.arrowhead_diamond"),icon:ne(Cx,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:g("labels.arrowhead_diamond_outline"),icon:ne(kx,{flip:e}),keyBinding:"f"},{value:"bar",text:g("labels.arrowhead_bar"),keyBinding:"z",icon:ne(vx,{flip:e})},{value:"crowfoot_one",text:g("labels.arrowhead_crowfoot_one"),icon:ne(Ix,{flip:e}),keyBinding:"x"},{value:"crowfoot_many",text:g("labels.arrowhead_crowfoot_many"),icon:ne(Sx,{flip:e}),keyBinding:"c"},{value:"crowfoot_one_or_many",text:g("labels.arrowhead_crowfoot_one_or_many"),icon:ne(Mx,{flip:e}),keyBinding:"v"}],HN=B({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,o,t)=>({elements:Ht(e,o,r=>{if(ge(r)){let{position:n,type:i}=t;if(n==="start")return te(r,{startArrowhead:i});if(n==="end")return te(r,{endArrowhead:i})}return r}),appState:{...o,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=Ir().rtl;return to("fieldset",{children:[ne("legend",{children:g("labels.arrowheads")}),to("div",{className:"iconSelectList buttonList",children:[ne(ju,{label:"arrowhead_start",options:qE(!n),value:eo(e,r,i=>ge(i)&&zi(i.type)?i.startArrowhead:o.currentItemStartArrowhead,!0,o.currentItemStartArrowhead),onChange:i=>t({position:"start",type:i}),numberOfOptionsToAlwaysShow:4}),ne(ju,{label:"arrowhead_end",group:"arrowheads",options:qE(!!n),value:eo(e,r,i=>ge(i)&&zi(i.type)?i.endArrowhead:o.currentItemEndArrowhead,!0,o.currentItemEndArrowhead),onChange:i=>t({position:"end",type:i}),numberOfOptionsToAlwaysShow:4})]})]})}}),UN=B({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,o,t,r)=>{let n=Ht(e,o,l=>{if(!Pe(l))return l;let s=te(l,{roundness:t===ht.round?{type:ut.PROPORTIONAL_RADIUS}:null,elbowed:t===ht.elbow,points:t===ht.elbow||l.elbowed?[l.points[0],l.points[l.points.length-1]]:l.points});if(se(s)){s.fixedSegments=null;let c=r.scene.getNonDeletedElementsMap();r.dismissLinearEditor();let m=$.getPointAtIndexGlobalCoordinates(s,0,c),d=$.getPointAtIndexGlobalCoordinates(s,-1,c),p=s.startBinding&&c.get(s.startBinding.elementId),u=s.endBinding&&c.get(s.endBinding.elementId),f=p&&s.startBinding?{...s.startBinding,...vp(s,p,"start",c)}:null,b=u&&s.endBinding?{...s.endBinding,...vp(s,u,"end",c)}:null;s={...s,startBinding:f,endBinding:b,...tc(s,c,{points:[m,d].map(x=>L(x[0]-s.x,x[1]-s.y)),startBinding:f,endBinding:b,fixedSegments:null})}}else{let c=r.scene.getNonDeletedElementsMap();if(s.startBinding){let m=c.get(s.startBinding.elementId);m&&Ri(s,m,"start",r.scene)}if(s.endBinding){let m=c.get(s.endBinding.elementId);m&&Ri(s,m,"end",r.scene)}}return s}),i={...o,currentItemArrowType:t},a=o.selectedLinearElement?.elementId;if(a){let l=n.find(s=>s.id===a);l&&(i.selectedLinearElement=new $(l,j(e)))}return{elements:n,appState:i,captureUpdate:A.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>to("fieldset",{children:[ne("legend",{children:g("labels.arrowtypes")}),ne("div",{className:"buttonList",children:ne(So,{group:"arrowtypes",options:[{value:ht.sharp,text:g("labels.arrowtype_sharp"),icon:Zc,testId:"sharp-arrow"},{value:ht.round,text:g("labels.arrowtype_round"),icon:$c,testId:"round-arrow"},{value:ht.elbow,text:g("labels.arrowtype_elbowed"),icon:Xc,testId:"elbow-arrow"}],value:eo(e,r,n=>Pe(n)?n.elbowed?ht.elbow:n.roundness?ht.round:ht.sharp:null,n=>Pe(n),n=>n?null:o.currentItemArrowType),onChange:n=>t(n)})})]})});import{useEffect as P4}from"react";import{jsx as R4}from"react/jsx-runtime";var ua=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let o=document.createElement("div");return document.body.appendChild(o),o.classList.add("excalidraw-tooltip"),o},rh=(e,o,t="bottom")=>{let r=e.getBoundingClientRect(),n=window.innerWidth,i=window.innerHeight,a=5,l=o.left+o.width/2-r.width/2;l<0?l=a:l+r.width>=n&&(l=n-r.width-a);let s;t==="bottom"?(s=o.top+o.height+a,s+r.height>=i&&(s=o.top-r.height-a)):(s=o.top-r.height-a,s<0&&(s=o.top+o.height+a)),Object.assign(e.style,{top:`${s}px`,left:`${l}px`})},D4=(e,o,t,r)=>{o.classList.add("excalidraw-tooltip--visible"),o.style.minWidth=r?"50ch":"10ch",o.style.maxWidth=r?"50ch":"15ch",o.textContent=t;let n=e.getBoundingClientRect();rh(o,n)},Rt=({children:e,label:o,long:t=!1,style:r,disabled:n})=>(P4(()=>()=>ua().classList.remove("excalidraw-tooltip--visible"),[]),n?null:R4("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>D4(i.currentTarget,ua(),o,t),onPointerLeave:()=>ua().classList.remove("excalidraw-tooltip--visible"),style:r,children:e}));import ud from"open-color";var t2='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',N4='<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"/>',o2='<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"/>',O4=`data:${ue.svg},${encodeURIComponent(`${t2}${o2}</svg>`)}`,B4=`data:${ue.svg},${encodeURIComponent(`${t2}${N4}${o2}</svg>`)}`,Lo=e=>{e&&(e.style.cursor="")},_e=(e,o)=>{e&&(e.style.cursor=o)},dr,e2,nh=(e,o)=>{let r=()=>{let n=o===re.DARK;dr=document.createElement("canvas"),dr.theme=o,dr.height=20,dr.width=20;let i=dr.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(dr.width/2,dr.height/2,5,0,2*Math.PI),i.fillStyle=n?ud.black:ud.white,i.fill(),i.strokeStyle=n?ud.white:ud.black,i.stroke(),e2=dr.toDataURL(ue.svg)};(!dr||dr.theme!==o)&&r(),_e(e,`url(${e2}) ${20/2} ${20/2}, auto`)},ho=(e,o)=>{if(e)if(o.activeTool.type==="selection")Lo(e);else if(Ko(o))e.style.cursor=we.GRAB;else if(Jt(o))nh(e,o.theme);else if(o.activeTool.type==="laser"){let t=o.theme===re.LIGHT?O4:B4;e.style.cursor=`url(${t}), auto`}else["image","custom"].includes(o.activeTool.type)?o.activeTool.type!=="image"&&(e.style.cursor=we.AUTO):e.style.cursor=we.CROSSHAIR};var Ar=({viewportX:e,viewportY:o,nextZoom:t},r)=>{let n=e-r.offsetLeft,i=o-r.offsetTop,a=r.zoom.value,l=r.scrollX+(n-n/a),s=r.scrollY+(i-i/a),c=-(n-n/t),m=-(i-i/t);return{scrollX:l+c,scrollY:s+m,zoom:{value:t}}};import{jsx as bd,jsxs as U4}from"react/jsx-runtime";var z4=B({name:"changeViewBackgroundColor",label:"labels.canvasBackground",trackEvent:!1,predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.changeViewBackgroundColor&&!o.viewModeEnabled,perform:(e,o,t)=>({appState:{...o,...t},captureUpdate:t.viewBackgroundColor?A.IMMEDIATELY:A.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:r})=>bd(Bl,{palette:null,topPicks:Ms,label:g("labels.canvasBackground"),type:"canvasBackground",color:o.viewBackgroundColor,onChange:n=>t({viewBackgroundColor:n}),"data-testid":"canvas-background-picker",elements:e,appState:o,updateData:t})}),hd=B({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:tu,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...Ar({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:ir(o.zoom.value+yi)},o),userToFollow:null},captureUpdate:A.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>bd(K,{type:"button",className:"zoom-in-button zoom-button",icon:tu,title:`${g("buttons.zoomIn")} \u2014 ${D("CtrlOrCmd++")}`,"aria-label":g("buttons.zoomIn"),disabled:o.zoom.value>=ep,onClick:()=>{e(null)}}),keyTest:e=>(e.code===le.EQUAL||e.code===le.NUM_ADD)&&(e[w.CTRL_OR_CMD]||e.shiftKey)}),gd=B({name:"zoomOut",label:"buttons.zoomOut",icon:ou,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...Ar({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:ir(o.zoom.value-yi)},o),userToFollow:null},captureUpdate:A.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>bd(K,{type:"button",className:"zoom-out-button zoom-button",icon:ou,title:`${g("buttons.zoomOut")} \u2014 ${D("CtrlOrCmd+-")}`,"aria-label":g("buttons.zoomOut"),disabled:o.zoom.value<=Qm,onClick:()=>{e(null)}}),keyTest:e=>(e.code===le.MINUS||e.code===le.NUM_SUBTRACT)&&(e[w.CTRL_OR_CMD]||e.shiftKey)}),fd=B({name:"resetZoom",label:"buttons.resetZoom",icon:Fb,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...Ar({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:ir(1)},o),userToFollow:null},captureUpdate:A.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>bd(Rt,{label:g("buttons.resetZoom"),style:{height:"100%"},children:U4(K,{type:"button",className:"reset-zoom-button zoom-button",title:g("buttons.resetZoom"),"aria-label":g("buttons.resetZoom"),onClick:()=>{e(null)},children:[(o.zoom.value*100).toFixed(0),"%"]})}),keyTest:e=>(e.code===le.ZERO||e.code===le.NUM_ZERO)&&(e[w.CTRL_OR_CMD]||e.shiftKey)}),F4=(e,o,t=1)=>{let[r,n,i,a]=e,l=i-r,s=o.width/l,c=a-n,m=o.height/c,p=Math.min(s,m)*Et(t,.1,1);return Math.min(p,1)},r2=({bounds:e,appState:o,canvasOffsets:t,fitToViewport:r=!1,viewportZoomFactor:n=1,minZoom:i=-1/0,maxZoom:a=1/0})=>{n=Et(n,Qm,ep);let[l,s,c,m]=e,d=(l+c)/2,p=(s+m)/2,u=t?.left??0,f=t?.top??0,b=t?.right??0,x=t?.bottom??0,E=o.width-u-b,y=o.height-f-x,v;if(r){let S=c-l,P=m-s;v=Math.min(E/S,y/P)*n}else v=F4(e,{width:E,height:y},n);let T=ir(Et(n1(v,yi,"floor"),i,a)),I=tb({scenePoint:{x:d,y:p},viewportDimensions:{width:o.width,height:o.height},offsets:t,zoom:{value:T}});return{appState:{...o,scrollX:I.scrollX,scrollY:I.scrollY,zoom:{value:T}},captureUpdate:A.EVENTUALLY}},Gl=({canvasOffsets:e,targetElements:o,appState:t,fitToViewport:r,viewportZoomFactor:n,minZoom:i,maxZoom:a})=>{let l=ye(fe(o));return r2({canvasOffsets:e,bounds:l,appState:t,fitToViewport:r,viewportZoomFactor:n,minZoom:i,maxZoom:a})},wO=B({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:Kc,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return Gl({targetElements:n.length?n:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()})},keyTest:e=>e.code===le.TWO&&e.shiftKey&&!e.altKey&&!e[w.CTRL_OR_CMD]}),TO=B({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:Kc,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return Gl({targetElements:n.length?n:e,appState:{...o,userToFollow:null},fitToViewport:!0,canvasOffsets:r.getEditorUIOffsets()})},keyTest:e=>e.code===le.THREE&&e.shiftKey&&!e.altKey&&!e[w.CTRL_OR_CMD]}),H4=B({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:Kc,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>Gl({targetElements:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()}),keyTest:e=>e.code===le.ONE&&e.shiftKey&&!e.altKey&&!e[w.CTRL_OR_CMD]}),ai=B({name:"toggleTheme",label:(e,o)=>o.theme===re.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:e=>e.theme===re.LIGHT?Sl:Il,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t)=>({appState:{...o,theme:t||(o.theme===re.LIGHT?re.DARK:re.LIGHT)},captureUpdate:A.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===le.D,predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.toggleTheme}),CO=B({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,o)=>{let t;return Jt(o)?t=Le(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):t=Le(o,{type:"eraser",lastActiveToolBeforeEraser:o.activeTool}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:t},captureUpdate:A.IMMEDIATELY}},keyTest:e=>e.key===w.E}),kO=B({name:"toggleLassoTool",label:"toolBar.lasso",icon:Cl,trackEvent:{category:"toolbar"},perform:(e,o,t,r)=>{let n;return o.activeTool.type!=="lasso"?(n=Le(o,{type:"lasso",fromSelection:!1}),_e(r.interactiveCanvas,we.CROSSHAIR)):n=Le(o,{type:"selection"}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:A.NEVER}}}),n2=B({name:"toggleHandTool",label:"toolBar.hand",trackEvent:{category:"toolbar"},icon:Vc,viewMode:!1,perform:(e,o,t,r)=>{let n;return Ko(o)?n=Le(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(n=Le(o,{type:"hand",lastActiveToolBeforeEraser:o.activeTool}),_e(r.interactiveCanvas,we.GRAB)),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:A.IMMEDIATELY}},keyTest:e=>!e.altKey&&!e[w.CTRL_OR_CMD]&&e.key===w.H});var G4=B({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,o,t,r)=>{let n=Le(o,{type:"embeddable"});return ho(r.canvas,{...o,activeTool:n}),{elements:e,appState:{...o,activeTool:Le(o,{type:"embeddable"})},captureUpdate:A.EVENTUALLY}}});import{jsx as Y4}from"react/jsx-runtime";var Ut=B({name:"finalize",label:"",trackEvent:!1,perform:(e,o,t,r)=>{let{interactiveCanvas:n,focusContainer:i,scene:a}=r,l=a.getNonDeletedElementsMap();if(t?.event&&o.selectedLinearElement){let d=$.handlePointerUp(t.event,o.selectedLinearElement,o,r.scene),{startBindingElement:p,endBindingElement:u}=d,f=r.scene.getElement(d.elementId);if(Tr(f)&&yp(f,p,u,r.scene),d!==o.selectedLinearElement){let b=e;return f&&Qr(f)&&(b=b.filter(x=>x.id!==f.id)),{elements:b,appState:{selectedLinearElement:{...d,selectedPointsIndices:null},suggestedBindings:[]},captureUpdate:A.IMMEDIATELY}}}if(o.editingLinearElement){let{elementId:d,startBindingElement:p,endBindingElement:u}=o.editingLinearElement,f=$.getElement(d,l);if(f)return Tr(f)&&yp(f,p,u,a),qe(f)&&!bp(f.points)&&a.mutateElement(f,{polygon:!1}),{elements:f.points.length<2||Qr(f)?e.filter(b=>b.id!==f.id):void 0,appState:{...o,cursorButton:"up",editingLinearElement:null},captureUpdate:A.IMMEDIATELY}}let s=e;window.document.activeElement instanceof HTMLElement&&i();let c=null;if(o.multiElement)c=o.multiElement;else if(o.newElement?.type==="freedraw"||Tr(o.newElement))c=o.newElement;else if(Object.keys(o.selectedElementIds).length===1){let d=l.get(Object.keys(o.selectedElementIds)[0]);d&&(c=d)}if(c){if(o.multiElement&&c.type!=="freedraw"&&o.lastPointerDownWith!=="touch"){let{points:d,lastCommittedPoint:p}=c;(!p||d[d.length-1]!==p)&&a.mutateElement(c,{points:c.points.slice(0,-1)})}if(c&&Qr(c)&&(s=s.filter(d=>d.id!==c.id)),ge(c)||fp(c)){let d=sl(c.points,o.zoom.value);if(d&&(qe(c)||fp(c))){let p=c.points,u=p[0],f=p.map((b,x)=>x===p.length-1?L(u[0],u[1]):b);qe(c)?a.mutateElement(c,{points:f,polygon:!0}):a.mutateElement(c,{points:f})}if(qe(c)&&!bp(c.points)&&a.mutateElement(c,{polygon:!1}),Tr(c)&&!d&&c.points.length>1&&Xr(o)){let[p,u]=$.getPointAtIndexGlobalCoordinates(c,-1,j(e));t0(c,o,{x:p,y:u},a)}}}(!o.activeTool.locked&&o.activeTool.type!=="freedraw"||!c)&&Lo(n);let m;return o.activeTool.type==="eraser"?m=Le(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):m=Le(o,{type:"selection"}),{elements:s,appState:{...o,cursorButton:"up",activeTool:(o.activeTool.locked||o.activeTool.type==="freedraw")&&c?o.activeTool:m,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:c&&!o.activeTool.locked&&o.activeTool.type!=="freedraw"?{...o.selectedElementIds,[c.id]:!0}:o.selectedElementIds,selectedLinearElement:c&&ge(c)?new $(c,j(s)):o.selectedLinearElement},captureUpdate:A.IMMEDIATELY}},keyTest:(e,o)=>e.key===w.ESCAPE&&(o.editingLinearElement!==null||!o.newElement&&o.multiElement===null)||(e.key===w.ESCAPE||e.key===w.ENTER)&&o.multiElement!==null,PanelComponent:({appState:e,updateData:o,data:t})=>Y4(K,{type:"button",icon:qb,title:g("buttons.done"),"aria-label":g("buttons.done"),onClick:o,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import W4 from"clsx";import{jsx as i2,jsxs as V4}from"react/jsx-runtime";var Yl=({children:e,checked:o,onChange:t,className:r})=>V4("div",{className:W4("Checkbox",r,{"is-checked":o}),onClick:n=>{t(!o,n),n.currentTarget.querySelector(".Checkbox-box").focus()},children:[i2("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":o,children:Vb}),i2("div",{className:"Checkbox-label",children:e})]});import{jsx as Wl}from"react/jsx-runtime";var l2=e=>{let o=e.title||(e.value===re.DARK?g("buttons.lightMode"):g("buttons.darkMode"));return Wl(K,{type:"icon",icon:e.value===re.LIGHT?a2.MOON:a2.SUN,title:o,"aria-label":o,onClick:()=>e.onChange(e.value===re.DARK?re.LIGHT:re.DARK),"data-testid":"toggle-dark-mode"})},a2={SUN:Wl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Wl("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:Wl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Wl("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"})})};import{useState as K4}from"react";import{jsx as s2,jsxs as Z4}from"react/jsx-runtime";var c2=e=>{let{id:o}=st(),[t,r]=K4(e.value),n=a=>{e.ignoreFocus||b1(a.target);let l=a.target.value;l!==e.value&&e.onChange(l)},i=a=>{if(a.key===w.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return Z4("div",{className:"ProjectName",children:[s2("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),s2("input",{type:"text",className:"TextInput",onBlur:n,onKeyDown:i,id:`${o}-filename`,value:t,onChange:a=>r(a.target.value)})]})};var $o=32,Be=12,fn=256,m2=50,li="NOT_SPREADSHEET",ha="VALID_SPREADSHEET",Vl=e=>{let o=/^([-+]?)[$€£¥₩]?([-+]?)([\d.,]+)[%]?$/.exec(e);return o?parseFloat(`${(o[1]||o[2])+o[3]}`.replace(/,/g,"")):null},ih=(e,o)=>e.slice(1).every(t=>Vl(t[o])!==null),d2=e=>{let o=e[0].length;if(o>2)return{type:li,reason:"More than 2 columns"};if(o===1){if(!ih(e,0))return{type:li,reason:"Value is not numeric"};let s=Vl(e[0][0])===null,c=(s?e.slice(1):e).map(m=>Vl(m[0]));return c.length<2?{type:li,reason:"Less than two rows"}:{type:ha,spreadsheet:{title:s?e[0][0]:null,labels:null,values:c}}}let t=ih(e,0),r=ih(e,1);if(!t&&!r)return{type:li,reason:"Value is not numeric"};let[n,i]=r?[0,1]:[1,0],a=Vl(e[0][i])===null,l=a?e.slice(1):e;return l.length<2?{type:li,reason:"Less than 2 rows"}:{type:ha,spreadsheet:{title:a?e[0][i]:null,labels:l.map(s=>s[n]),values:l.map(s=>Vl(s[i]))}}},X4=e=>{let o=[];for(let t=0;t<e[0].length;t++){let r=[];for(let n=0;n<e.length;n++)r.push(e[n][t]);o.push(r)}return o},p2=e=>{let o=e.trim().split(`
1
+ import{$ as Hl,A as um,B as Qf,C as e1,D as t1,E as Bl,F as qi,G as Fl,H as Ol,I as o1,J as r1,K as Ji,L as n1,M as i1,N as a1,O as l1,P as zl,Q as En,R as s1,S as hm,T as oC,U as yn,V as Qi,X as c1,Z as d1,_ as m1,a as $f,aa as p1,b as Or,ba as ea,c as uo,ca as gm,d as jf,da as Gl,e as Ee,ea as u1,f as qf,fa as fm,g as $,ga as Lo,h as _l,ha as h1,i as Ko,ia as bm,j as lm,ja as g1,k as sm,ka as f1,l as gn,la as Ul,m as cm,ma as xm,n as fn,na as b1,o as Jf,oa as x1,p as dm,pa as E1,q as Zo,qa as y1,r as bn,s as Et,t as qt,u as xn,v as Rl,w as mm,x as ji,y as Nl,z as pm}from"./chunk-ESVIN3T7.js";import{a as T}from"./chunk-4UANJTGP.js";import{J as am}from"./chunk-KZXLT4YB.js";import{c as Zf}from"./chunk-Z3N5DIM6.js";import{b as Xf,c as Kf,d as I}from"./chunk-SRAX5OIU.js";import rU,{useEffect as nU}from"react";import{DEFAULT_UI_OPTIONS as QI,isShallowEqual as iU}from"@excalidraw/common";import DT from"clsx";import zz from"lodash.throttle";import Mo,{useContext as Nr}from"react";import{flushSync as Yi}from"react-dom";import Hz from"roughjs/bin/rough";import{nanoid as Gz}from"nanoid";import{clamp as _T,pointFrom as ne,pointDistance as sn,vector as RT,pointRotateRads as qg,vectorScale as Uz,vectorFromPoint as Jg,vectorSubtract as NT,vectorDot as BT,vectorNormalize as FT}from"@excalidraw/math";import{COLOR_PALETTE as Yz,CODES as OT,shouldResizeFromCenter as zT,shouldMaintainAspectRatio as bl,shouldRotateWithDiscreteAngle as Qg,isArrowKey as Vd,KEYS as U,APP_NAME as Wz,CURSOR_TYPE as De,DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT as Vz,DEFAULT_VERTICAL_ALIGN as HT,DRAGGING_THRESHOLD as Xz,ELEMENT_SHIFT_TRANSLATE_AMOUNT as Kz,ELEMENT_TRANSLATE_AMOUNT as GT,EVENT as ee,FRAME_STYLE as Pr,IMAGE_MIME_TYPES as Zz,IMAGE_RENDER_TIMEOUT as $z,isBrave as jz,LINE_CONFIRM_THRESHOLD as ef,MAX_ALLOWED_FILE_BYTES as UT,MIME_TYPES as Ar,MQ_MAX_HEIGHT_LANDSCAPE as qz,MQ_MAX_WIDTH_LANDSCAPE as Jz,MQ_MAX_WIDTH_PORTRAIT as Qz,MQ_RIGHT_SIDEBAR_MIN_WIDTH as eH,POINTER_BUTTON as cn,ROUNDNESS as Xd,SCROLL_TIMEOUT as tH,TAP_TWICE_TIMEOUT as oH,TEXT_TO_CENTER_SNAP_THRESHOLD as rH,THEME as Kd,THEME_FILTER as nH,TOUCH_CTX_MENU_TIMEOUT as iH,VERTICAL_ALIGN as aH,YOUTUBE_STATES as Zd,ZOOM_STEP as lH,POINTER_EVENTS as Wi,TOOL_TYPE as ko,isIOS as sH,supportsResizeObserver as YT,DEFAULT_COLLISION_THRESHOLD as WT,DEFAULT_TEXT_ALIGN as cH,ARROW_TYPE as Dr,DEFAULT_REDUCED_GLOBAL_ALPHA as dH,isSafari as mH,isLocalLink as pH,normalizeLink as tf,toValidURL as uH,getGridPoint as nt,getLineHeight as VT,debounce as XT,distance as Vi,getFontString as of,getNearestScrollableContainer as hH,isInputLike as KT,isToolIcon as gH,isWritableElement as xl,sceneCoordsToViewportCoords as $d,tupleToCoors as rf,viewportCoordsToSceneCoords as Fe,wrapEvent as fH,updateObject as nf,updateActiveTool as Vo,getShortcutKey as bH,isTransparent as xH,easeToValuesRAF as EH,muteFSAbortError as yH,isTestEnv as Sf,isDevEnv as AI,easeOut as wH,updateStable as El,addEventListener as _e,normalizeEOL as vH,getDateTime as ZT,isShallowEqual as TH,arrayToMap as jd,randomInteger as IH,CLASSES as CH,Emitter as dn,MINIMUM_ARROW_SIZE as $T}from"@excalidraw/common";import{getObservedAppState as SH,getCommonBounds as Xi,maybeSuggestBindingsForLinearElementAtCoords as jT,getElementAbsoluteCoords as qT,bindOrUnbindLinearElements as JT,fixBindingsAfterDeletion as kH,getHoveredElementForBinding as af,isBindingEnabled as lf,shouldEnableBindingForPointerEvent as MH,updateBoundElements as sf,getSuggestedBindingsForArrows as cf,LinearElementEditor as Ce,newElementWith as mn,newFrameElement as LH,newFreeDrawElement as PH,newEmbeddableElement as QT,newMagicFrameElement as eI,newIframeElement as AH,newArrowElement as DH,newElement as _H,newImageElement as RH,newLinearElement as NH,newTextElement as tI,refreshTextDimensions as BH,deepCopyElement as oI,duplicateElements as rI,hasBoundTextElement as nI,isArrowElement as df,isBindingElement as mf,isBindingElementType as iI,isBoundToContainer as pf,isFrameLikeElement as Zt,isImageElement as pn,isEmbeddableElement as _r,isInitializedImageElement as yl,isLinearElement as $t,isLinearElementType as FH,isUsingAdaptiveRadius as OH,isIframeElement as Ki,isIframeLikeElement as wl,isMagicFrameElement as uf,isTextBindableContainer as aI,isElbowArrow as Ge,isFlowchartNodeElement as zH,isBindableElement as HH,isTextElement as mo,getLockedLinearCursorAlignSize as lI,getNormalizedDimensions as GH,isElementCompletelyInViewport as hf,isElementInViewport as sI,isInvisiblySmallElement as cI,getCornerRadius as UH,isPathALoop as dI,createSrcDoc as mI,embeddableURLValidator as gf,maybeParseEmbedSrc as YH,getEmbedLink as qd,getInitializedImageElements as WH,normalizeSVG as pI,updateImageCache as VH,getBoundTextElement as ff,getContainerCenter as bf,getContainerElement as uI,isValidTextContainer as XH,redrawTextBoundingBox as KH,shouldShowBoundingBox as ZH,getFrameChildren as hI,isCursorInFrame as gI,addElementsToFrame as xf,replaceAllElementsInFrame as $H,removeElementsFromFrame as jH,getElementsInResizingFrame as Ef,getElementsInNewFrame as qH,getContainingFrame as yf,elementOverlapsWithFrame as JH,updateFrameMembershipOfSelectedElements as fI,isElementInFrame as bI,getFrameLikeTitle as QH,getElementsOverlappingFrame as eG,filterElementsEligibleAsFrameChildren as tG,hitElementBoundText as oG,hitElementBoundingBoxOnly as rG,hitElementItself as vl,getVisibleSceneBounds as nG,FlowChartCreator as iG,FlowChartNavigator as aG,getLinkDirectionFromKey as xI,cropElement as lG,wrapText as sG,isElementLink as wf,parseElementLinkFromURL as cG,isMeasureTextSupported as dG,normalizeText as mG,measureText as EI,getLineHeightInPx as pG,getApproxMinLineWidth as uG,getApproxMinLineHeight as hG,getMinTextElementWidth as gG,ShapeCache as Tl,getRenderOpacity as fG,editGroupForSelectedElement as bG,getElementsInGroup as Il,getSelectedGroupIdForElement as xG,getSelectedGroupIds as EG,isElementInGroup as yI,isSelectedViaGroup as yG,selectGroupsForSelectedElements as po,syncInvalidIndices as DI,syncMovedIndices as wI,excludeElementsInFramesFromSelection as wG,getSelectionStateForElements as vG,makeNextSelectedElementIds as fe,getResizeOffsetXY as TG,getResizeArrowDirection as IG,transformElements as CG,getCursorForResizingElement as vI,getElementWithTransformHandleType as TI,getTransformHandleTypeFromCoords as II,dragNewElement as CI,dragSelectedElements as SG,getDragOffsetXY as kG,isNonDeletedElement as SI,Scene as kI,Store as MG,CaptureUpdateAction as mt,hitElementBoundingBox as LG,isLineElement as vf,isSimpleArrow as PG}from"@excalidraw/element";import{arrangeElements as MI}from"@excalidraw/element/arrange";import{KEYS as Vm,updateActiveTool as fC}from"@excalidraw/common";import{getNonDeletedElements as Xm}from"@excalidraw/element";import{fixBindingsAfterDeletion as bC}from"@excalidraw/element";import{LinearElementEditor as hb}from"@excalidraw/element";import{newElementWith as ds}from"@excalidraw/element";import{getContainerElement as gb}from"@excalidraw/element";import{isBoundToContainer as ss,isElbowArrow as xC,isFrameLikeElement as EC}from"@excalidraw/element";import{getFrameChildren as yC}from"@excalidraw/element";import{getElementsInGroup as Km,selectGroupsForSelectedElements as wC}from"@excalidraw/element";import{CaptureUpdateAction as cs}from"@excalidraw/element";import{isDevEnv as aC}from"@excalidraw/common";import{atom as he,createStore as rC}from"jotai";import{createIsolation as nC}from"jotai-scope";var w1=nC();var{useAtom:se,useSetAtom:wn,useAtomValue:Yl,useStore:mU}=w1,v1=w1.Provider,Ke=rC();var iC=Xf({"./locales/ar-SA.json":()=>import("./locales/ar-SA-G6X2FPQ2.js"),"./locales/az-AZ.json":()=>import("./locales/az-AZ-76LH7QW2.js"),"./locales/bg-BG.json":()=>import("./locales/bg-BG-XCXSNQG7.js"),"./locales/bn-BD.json":()=>import("./locales/bn-BD-2XOGV67Q.js"),"./locales/ca-ES.json":()=>import("./locales/ca-ES-6MX7JW3Y.js"),"./locales/cs-CZ.json":()=>import("./locales/cs-CZ-2BRQDIVT.js"),"./locales/da-DK.json":()=>import("./locales/da-DK-5WZEPLOC.js"),"./locales/de-DE.json":()=>import("./locales/de-DE-XR44H4JA.js"),"./locales/el-GR.json":()=>import("./locales/el-GR-BZB4AONW.js"),"./locales/en.json":()=>import("./locales/en-XFR6MADM.js"),"./locales/es-ES.json":()=>import("./locales/es-ES-U4NZUMDT.js"),"./locales/eu-ES.json":()=>import("./locales/eu-ES-A7QVB2H4.js"),"./locales/fa-IR.json":()=>import("./locales/fa-IR-HGAKTJCU.js"),"./locales/fi-FI.json":()=>import("./locales/fi-FI-Z5N7JZ37.js"),"./locales/fr-FR.json":()=>import("./locales/fr-FR-RHASNOE6.js"),"./locales/gl-ES.json":()=>import("./locales/gl-ES-HMX3MZ6V.js"),"./locales/he-IL.json":()=>import("./locales/he-IL-6SHJWFNN.js"),"./locales/hi-IN.json":()=>import("./locales/hi-IN-IWLTKZ5I.js"),"./locales/hu-HU.json":()=>import("./locales/hu-HU-A5ZG7DT2.js"),"./locales/id-ID.json":()=>import("./locales/id-ID-SAP4L64H.js"),"./locales/it-IT.json":()=>import("./locales/it-IT-JPQ66NNP.js"),"./locales/ja-JP.json":()=>import("./locales/ja-JP-DBVTYXUO.js"),"./locales/kaa.json":()=>import("./locales/kaa-6HZHGXH3.js"),"./locales/kab-KAB.json":()=>import("./locales/kab-KAB-ZGHBKWFO.js"),"./locales/kk-KZ.json":()=>import("./locales/kk-KZ-P5N5QNE5.js"),"./locales/km-KH.json":()=>import("./locales/km-KH-HSX4SM5Z.js"),"./locales/ko-KR.json":()=>import("./locales/ko-KR-MTYHY66A.js"),"./locales/ku-TR.json":()=>import("./locales/ku-TR-6OUDTVRD.js"),"./locales/lt-LT.json":()=>import("./locales/lt-LT-XHIRWOB4.js"),"./locales/lv-LV.json":()=>import("./locales/lv-LV-5QDEKY6T.js"),"./locales/mr-IN.json":()=>import("./locales/mr-IN-CRQNXWMA.js"),"./locales/my-MM.json":()=>import("./locales/my-MM-5M5IBNSE.js"),"./locales/nb-NO.json":()=>import("./locales/nb-NO-T6EIAALU.js"),"./locales/nl-NL.json":()=>import("./locales/nl-NL-IS3SIHDZ.js"),"./locales/nn-NO.json":()=>import("./locales/nn-NO-6E72VCQL.js"),"./locales/oc-FR.json":()=>import("./locales/oc-FR-POXYY2M6.js"),"./locales/pa-IN.json":()=>import("./locales/pa-IN-N4M65BXN.js"),"./locales/percentages.json":()=>import("./locales/percentages-BXMCSKIN.js"),"./locales/pl-PL.json":()=>import("./locales/pl-PL-T2D74RX3.js"),"./locales/pt-BR.json":()=>import("./locales/pt-BR-5N22H2LF.js"),"./locales/pt-PT.json":()=>import("./locales/pt-PT-UZXXM6DQ.js"),"./locales/ro-RO.json":()=>import("./locales/ro-RO-JPDTUUEW.js"),"./locales/ru-RU.json":()=>import("./locales/ru-RU-B4JR7IUQ.js"),"./locales/si-LK.json":()=>import("./locales/si-LK-N5RQ5JYF.js"),"./locales/sk-SK.json":()=>import("./locales/sk-SK-C5VTKIMK.js"),"./locales/sl-SI.json":()=>import("./locales/sl-SI-NN7IZMDC.js"),"./locales/sv-SE.json":()=>import("./locales/sv-SE-XGPEYMSR.js"),"./locales/ta-IN.json":()=>import("./locales/ta-IN-2NMHFXQM.js"),"./locales/th-TH.json":()=>import("./locales/th-TH-HPSO5L25.js"),"./locales/tr-TR.json":()=>import("./locales/tr-TR-DEFEU3FU.js"),"./locales/uk-UA.json":()=>import("./locales/uk-UA-QMV73CPH.js"),"./locales/vi-VN.json":()=>import("./locales/vi-VN-M7AON7JQ.js"),"./locales/zh-CN.json":()=>import("./locales/zh-CN-LNUGB5OW.js"),"./locales/zh-HK.json":()=>import("./locales/zh-HK-E62DVLB3.js"),"./locales/zh-TW.json":()=>import("./locales/zh-TW-RAJ6MFWO.js")});var lC=85,ho={code:"en",label:"English"},Tn=[ho,...[{code:"ar-SA",label:"\u0627\u0644\u0639\u0631\u0628\u064A\u0629",rtl:!0},{code:"bg-BG",label:"\u0411\u044A\u043B\u0433\u0430\u0440\u0441\u043A\u0438"},{code:"ca-ES",label:"Catal\xE0"},{code:"cs-CZ",label:"\u010Cesky"},{code:"de-DE",label:"Deutsch"},{code:"el-GR",label:"\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC"},{code:"es-ES",label:"Espa\xF1ol"},{code:"eu-ES",label:"Euskara"},{code:"fa-IR",label:"\u0641\u0627\u0631\u0633\u06CC",rtl:!0},{code:"fi-FI",label:"Suomi"},{code:"fr-FR",label:"Fran\xE7ais"},{code:"gl-ES",label:"Galego"},{code:"he-IL",label:"\u05E2\u05D1\u05E8\u05D9\u05EA",rtl:!0},{code:"hi-IN",label:"\u0939\u093F\u0928\u094D\u0926\u0940"},{code:"hu-HU",label:"Magyar"},{code:"id-ID",label:"Bahasa Indonesia"},{code:"it-IT",label:"Italiano"},{code:"ja-JP",label:"\u65E5\u672C\u8A9E"},{code:"kab-KAB",label:"Taqbaylit"},{code:"kk-KZ",label:"\u049A\u0430\u0437\u0430\u049B \u0442\u0456\u043B\u0456"},{code:"ko-KR",label:"\uD55C\uAD6D\uC5B4"},{code:"ku-TR",label:"Kurd\xEE"},{code:"lt-LT",label:"Lietuvi\u0173"},{code:"lv-LV",label:"Latvie\u0161u"},{code:"my-MM",label:"Burmese"},{code:"nb-NO",label:"Norsk bokm\xE5l"},{code:"nl-NL",label:"Nederlands"},{code:"nn-NO",label:"Norsk nynorsk"},{code:"oc-FR",label:"Occitan"},{code:"pa-IN",label:"\u0A2A\u0A70\u0A1C\u0A3E\u0A2C\u0A40"},{code:"pl-PL",label:"Polski"},{code:"pt-BR",label:"Portugu\xEAs Brasileiro"},{code:"pt-PT",label:"Portugu\xEAs"},{code:"ro-RO",label:"Rom\xE2n\u0103"},{code:"ru-RU",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439"},{code:"sk-SK",label:"Sloven\u010Dina"},{code:"sv-SE",label:"Svenska"},{code:"sl-SI",label:"Sloven\u0161\u010Dina"},{code:"tr-TR",label:"T\xFCrk\xE7e"},{code:"uk-UA",label:"\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430"},{code:"zh-CN",label:"\u7B80\u4F53\u4E2D\u6587"},{code:"zh-TW",label:"\u7E41\u9AD4\u4E2D\u6587"},{code:"vi-VN",label:"Ti\u1EBFng Vi\u1EC7t"},{code:"mr-IN",label:"\u092E\u0930\u093E\u0920\u0940"}].filter(e=>Zf[e.code]>=lC).sort((e,o)=>e.label>o.label?1:-1)],Vl="__test__";aC()&&Tn.unshift({code:Vl,label:"test language"},{code:`${Vl}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var vn=ho,Wl={},Xl=async e=>{if(vn=e,document.documentElement.dir=vn.rtl?"rtl":"ltr",document.documentElement.lang=vn.code,e.code.startsWith(Vl))Wl={};else try{Wl=await iC(`./locales/${vn.code}.json`)}catch(o){console.error(`Failed to load language ${e.code}:`,o.message),Wl=am}Ke.set(I1,e.code)},Po=()=>vn,T1=(e,o)=>{for(let t=0;t<o.length;++t){let r=o[t];if(e[r]===void 0)return;e=e[r]}if(typeof e=="string")return e},g=(e,o,t)=>{if(vn.code.startsWith(Vl))return`\u202A[[${o?`${e}(${JSON.stringify(o).slice(1,-1)})`:e}]]\u202C`;let r=e.split("."),n=T1(Wl,r)||T1(am,r)||t;if(n===void 0){let i=`Can't find translation for ${e}`;if(T.PROD)return console.warn(i),"";throw new Error(i)}if(o)for(let i in o)n=n.replace(`{{${i}}}`,String(o[i]));return n},I1=he(ho.code),Oe=()=>{let e=Yl(I1);return{t:g,langCode:e}};import sC from"clsx";import cC from"open-color";import et from"react";import{THEME as dC}from"@excalidraw/common";import{Fragment as be,jsx as h,jsxs as D}from"react/jsx-runtime";var Jt=e=>"var(--icon-fill-color)",C1=e=>e===dC.LIGHT?cC.white:"#1e1e1e",M=(e,o=512)=>{let{width:t=512,height:r=t,mirror:n,style:i,...a}=typeof o=="number"?{width:o}:o;return h("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${t} ${r}`,className:sC({"rtl-mirror":n}),style:i,...a,children:typeof e=="string"?h("path",{fill:"currentColor",d:e}):e})},F={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},te={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},kU=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:3,y:8,width:18,height:4,rx:1}),h("line",{x1:12,y1:8,x2:12,y2:21}),h("path",{d:"M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"}),h("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"})]}),F),In=M(D("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),h("path",{d:"M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),h("line",{x1:"3",y1:"6",x2:"3",y2:"19"}),h("line",{x1:"12",y1:"6",x2:"12",y2:"19"}),h("line",{x1:"21",y1:"6",x2:"21",y2:"19"})]}),F),S1=M(D("svg",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),h("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),F),k1=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"1"}),h("circle",{cx:"12",cy:"19",r:"1"}),h("circle",{cx:"12",cy:"5",r:"1"})]}),F),M1=M(D("svg",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),h("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),h("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),F),Em=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M6.5 9.5l3.5 -3"}),h("path",{d:"M14 5.5l3 1.5"}),h("path",{d:"M18.5 10l-2.5 7"}),h("path",{d:"M13.5 17.5l-7 -5"})]}),F),Ao=M(D("g",{children:[h("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"}),h("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"}),h("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:h("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"})}),h("g",{mask:"url(#UnlockedIcon)",children:h("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"})})]}),te),$o=M(D("g",{strokeWidth:"1.25",children:[h("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"}),h("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),h("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"})]}),te),L1=M(h("g",{fill:"currentColor",children:h("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}),P1=M(D(be,{children:[h("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"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),h("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"}),A1=M(D(be,{children:[h("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"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),h("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"}),D1=M(D(be,{children:[h("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"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),h("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"}),MU=M(h("g",{fill:"currentColor",children:h("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"}),_1=M(D("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),ta=M(D("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,children:[h("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"}),h("path",{d:"M5 15m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 17c0 1.42 .316 2.805 1 4"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),Cn=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),F),Sn=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"})]}),F),kn=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"})]}),F),Kl=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),h("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),h("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),F),Mn=M(h("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),te),R1=M(D("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),h("path",{d:"M16 7h4"}),h("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),F),jo=M(D("g",{strokeWidth:"1.25",children:[h("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"}),h("path",{d:"m11.25 5.417 3.333 3.333"})]}),te),Ln=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),h("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),h("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),h("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),h("polyline",{points:"5 20 11 4 13 4 20 20"})]}),F),N1=M(D("g",{strokeWidth:"1.25",children:[h("path",{d:"M12.5 6.667h.01"}),h("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"}),h("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),h("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),te),B1=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M18 13.3l-6.3 -6.3"})]}),F),ym=M(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),te),wm=M(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),te),F1=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M21 21l-6 -6"}),h("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"}),h("path",{d:"M3 4v4h4"})]}),F),Do=M(h("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"}),te),O1=M(D("g",{strokeWidth:"1.5",children:[h("polyline",{points:"12 16 18 10 12 4"}),h("polyline",{points:"8 4 2 10 8 16"})]}),te),oa=M(D("g",{strokeWidth:"1.25",children:[h("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"}),h("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"})]}),te),ra=M(h("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"}),te),na=M(h("g",{stroke:"currentColor",strokeLinejoin:"round",children:h("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"})}),{...te,strokeWidth:1.5}),Zl=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),h("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),h("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),F),zr=M(h("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"}),te),Pn=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"}),h("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),F),z1=M(D("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"}),h("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),F),LU=M(h("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"}),te),H1=M(h("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"}),te),G1=M(D("g",{strokeWidth:"1.25",children:[h("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"}),h("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"})]}),te),U1=M(D("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),h("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),F),Y1=M(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),ia=M(D("g",{strokeWidth:"1.25",children:[h("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"}),h("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"})]}),te),W1=M("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}),V1=M("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}),An=M(h("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"}),te),PU=M("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}),X1=M("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"),$l=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z"}),h("path",{d:"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"}),h("path",{d:"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"})]}),F),K1=M(h("g",{strokeWidth:1.5,children:h("path",{d:"M6 18l12 -12"})}),F),jl=M(D("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 8h.01"}),h("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),h("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),h("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),h("path",{d:"M19 16v6"}),h("path",{d:"M22 19l-3 3l-3 -3"})]}),F),Z1=M("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}),AU=M("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}),DU=M("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}),$1=M("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"),_U=M("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"),vm=M(h("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"}),te),Tm=M(h("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"}),te),j1=M("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}),q1=M(h("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"}),te),RU=M("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"),NU=M("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}),BU=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M12 14v-11"}),h("path",{d:"M9 6l3 -3l3 3"})]}),F),FU=M(D(be,{children:[h("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"}),h("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}),OU=M(h("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}),J1=D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 10l0 10"}),h("path",{d:"M12 10l4 4"}),h("path",{d:"M12 10l-4 4"}),h("path",{d:"M4 4l16 0"})]}),Q1=D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 5l0 14"}),h("path",{d:"M16 9l-4 -4"}),h("path",{d:"M8 9l4 -4"})]}),Im=M(Q1,F),Cm=M(Q1,{...F,style:{transform:"rotate(180deg)"}}),Sm=M(J1,F),km=M(J1,{...F,style:{transform:"rotate(180deg)"}}),Mm=M(D(be,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),Lm=M(D(be,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),Pm=M(D(be,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),Am=M(D(be,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),e0=M(D(be,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),t0=M(D(be,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),Dm=M(D("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),h("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),te),_m=M(D("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),h("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),te),ql=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"9",cy:"7",r:"4"}),h("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),h("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),h("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),F),zU=M("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"),HU=M("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"),Ft=M(D(be,{children:[h("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M15 5 5 15M5 5l10 10"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),GU=M("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}),UU=M("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}),YU=M("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}),Rm=et.memo(({theme:e})=>M(D(be,{children:[h("path",{d:"M25 26H111V111H25",fill:Jt(e)}),h("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:Jt(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:Jt(e)}),h("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:Jt(e),strokeWidth:"2"}),D("g",{fill:C1(e),stroke:Jt(e),strokeWidth:"6",children:[h("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),Nm=et.memo(({theme:e})=>M(D(be,{children:[h("path",{d:"M25 26H111V111H25",fill:Jt(e)}),h("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:Jt(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:Jt(e)}),h("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:Jt(e),strokeWidth:"2"}),D("g",{fill:C1(e),stroke:Jt(e),strokeWidth:"6",children:[h("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),h("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),o0=M(h("g",{strokeWidth:1.25,children:h("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"})}),te),r0=M(D(be,{children:[h("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"}),h("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:h("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"})}),h("g",{mask:"url(#FillHachureIcon)",children:h("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"})})]}),te),n0=M(D(be,{children:[D("g",{clipPath:"url(#a)",children:[h("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"}),h("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:h("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"})}),h("g",{mask:"url(#FillCrossHatchIcon)",children:h("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"})})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),i0=M(D(be,{children:[h("g",{clipPath:"url(#a)",children:h("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"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...te,fill:"currentColor"}),Bm=M(h(be,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),te),a0=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),te),l0=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),te),WU=et.memo(({theme:e})=>M(h("path",{d:"M6 10H34",stroke:Jt(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),s0=M(D("g",{strokeWidth:"2",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12h2"}),h("path",{d:"M17 12h2"}),h("path",{d:"M11 12h2"})]}),F),c0=M(D("g",{strokeWidth:"2",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 12v.01"}),h("path",{d:"M8 12v.01"}),h("path",{d:"M12 12v.01"}),h("path",{d:"M16 12v.01"}),h("path",{d:"M20 12v.01"})]}),F),d0=M(h("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"}),te),m0=M(h("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"}),te),p0=M(h("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"}),te),u0=M(D("svg",{strokeWidth:"1.5",children:[h("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"}),h("path",{d:"M13.3333 3.33331V3.34331"}),h("path",{d:"M16.6667 3.33331V3.34331"}),h("path",{d:"M16.6667 6.66669V6.67669"}),h("path",{d:"M16.6667 10V10.01"}),h("path",{d:"M3.33334 13.3333V13.3433"}),h("path",{d:"M16.6667 13.3333V13.3433"}),h("path",{d:"M3.33334 16.6667V16.6767"}),h("path",{d:"M6.66666 16.6667V16.6767"}),h("path",{d:"M10 16.6667V16.6767"}),h("path",{d:"M13.3333 16.6667V16.6767"}),h("path",{d:"M16.6667 16.6667V16.6767"})]}),te),h0=M(D("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),h("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),h("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),h("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),h("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),h("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),h("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),h("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),h("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),h("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),h("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),h("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),F),g0=M(D("g",{stroke:"currentColor",opacity:.3,strokeWidth:2,children:[h("path",{d:"M12 12l9 0"}),h("path",{d:"M3 9l6 6"}),h("path",{d:"M3 15l6 -6"})]}),F),f0=et.memo(({flip:e=!1})=>M(D("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",children:[h("path",{d:"M34 10H6M34 10L27 5M34 10L27 15"}),h("path",{d:"M27.5 5L34.5 10L27.5 15"})]}),{width:40,height:20})),b0=et.memo(({flip:e=!1})=>M(D("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[h("path",{d:"M32 10L6 10",strokeWidth:2}),h("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),x0=et.memo(({flip:e=!1})=>M(D("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[h("path",{d:"M26 10L6 10"}),h("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),E0=et.memo(({flip:e=!1})=>M(h("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",children:h("path",{d:"M34 10H5.99996M34 10L34 5M34 10L34 15",stroke:"currentColor",strokeWidth:2,fill:"none"})}),{width:40,height:20})),y0=et.memo(({flip:e=!1})=>M(D("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[h("path",{d:"M32 10L6 10",strokeWidth:2}),h("path",{d:"M27.5 5.5L34.5 10L27.5 14.5L27.5 5.5"})]}),{width:40,height:20})),w0=et.memo(({flip:e=!1})=>M(D("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",children:[h("path",{d:"M6,9.5H27"}),h("path",{d:"M27,5L34,10L27,14Z",fill:"none"})]}),{width:40,height:20})),v0=et.memo(({flip:e=!1})=>M(D("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M6,9.5H20"}),h("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),T0=et.memo(({flip:e=!1})=>M(D("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M6,9.5H20"}),h("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),I0=et.memo(({flip:e=!1})=>M(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M34,10 H6 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),C0=et.memo(({flip:e=!1})=>M(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M34,10 H6 M15,10 L15,15 L15,5"})}),{width:40,height:20})),S0=et.memo(({flip:e=!1})=>M(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M34,10 H6 M15,10 L15,16 L15,4 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),k0=M(D(be,{children:[h("g",{clipPath:"url(#a)",children:h("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"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),M0=M(D(be,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),L0=M(D(be,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),P0=M(h(be,{children:h("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"})}),te),Hr=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 7v-2h13v2"}),h("path",{d:"M10 5v14"}),h("path",{d:"M12 19h-4"}),h("path",{d:"M15 13v-1h6v1"}),h("path",{d:"M18 12v7"}),h("path",{d:"M17 19h2"})]}),F),A0=M(h(be,{children:D("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 12h10"}),h("path",{d:"M7 5v14"}),h("path",{d:"M17 5v14"}),h("path",{d:"M15 19h4"}),h("path",{d:"M15 5h4"}),h("path",{d:"M5 19h4"}),h("path",{d:"M5 5h4"})]})}),F),aa=M(h(be,{children:h("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("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"})})}),te),Jl=M(D(be,{children:[h("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M5.833 6.667 2.5 10l3.333 3.333M14.167 6.667 17.5 10l-3.333 3.333M11.667 3.333 8.333 16.667"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),te),D0=M(D("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),h("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),F),_0=M(D("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),h("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),F),R0=M(D("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),h("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),F),N0=et.memo(({theme:e})=>M(D("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),h("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),F)),B0=et.memo(({theme:e})=>M(D("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),h("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),F)),F0=et.memo(({theme:e})=>M(D("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),h("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),h("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),F)),Ql=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M21 19h-18l9 -15"}),h("path",{d:"M20.615 15.171h.015"}),h("path",{d:"M19.515 11.771h.015"}),h("path",{d:"M17.715 8.671h.015"}),h("path",{d:"M15.415 5.971h.015"})]}),F),O0=M(h("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}),VU=M(h("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"})),es=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),h("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),h("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),h("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"})]}),F),Fm=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),h("path",{d:"M7 11l5 5l5 -5"}),h("path",{d:"M12 4l0 12"})]}),F),Dn=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),F),z0=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M9.15 14.85l8.85 -10.85"}),h("path",{d:"M6 4l8.85 10.85"})]}),F),H0=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),h("path",{d:"M12 17l0 .01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),F),XU=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),F),KU=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"})]}),F),G0=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),F),U0=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M12 9v4"}),h("path",{d:"M12 17h.01"})]}),F),Y0=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M11 7l6 6"}),h("path",{d:"M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z"})]}),F),Om=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 3l-4 7h8z"}),h("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M4 14m0 1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z"})]}),F),_n=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 7l16 0"}),h("path",{d:"M4 17l16 0"}),h("path",{d:"M7 4l0 16"}),h("path",{d:"M17 4l0 16"})]}),F),W0=M(h("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"})),Rn=M(D("g",{strokeWidth:"1.25",children:[h("path",{d:"M4.16602 10H15.8327"}),h("path",{d:"M12.5 13.3333L15.8333 10"}),h("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),te),la=M(D("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[h("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"}),h("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),V0=M(D("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z"}),h("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),h("path",{d:"M15 6l3 3"}),h("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"}),h("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"})]}),F),ZU=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z"}),h("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),h("path",{d:"M15 6l3 3"}),h("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"}),h("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"})]}),F),$U=M(D("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),h("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),h("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"}),h("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),h("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),h("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"})]}),F),X0=M(D("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),h("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),h("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),h("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),F),Gr=M(D("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),h("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"})]}),F),K0=M(D("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),h("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"}),h("path",{d:"M3 3l18 18"})]}),F),Z0=M(D("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("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"}),h("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),h("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),h("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),h("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),F),$0=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("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"}),h("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),h("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),h("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),h("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),F),At=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),h("path",{d:"M21 21l-6 -6"})]}),F),j0=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),h("path",{d:"M12 7v5l3 3"}),h("path",{d:"M19 16l-2 3h4l-2 3"})]}),F),q0=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M5 10a7 7 0 0 0 14 0"}),h("path",{d:"M8 21l8 0"}),h("path",{d:"M12 17l0 4"})]}),F),J0=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 3l18 18"}),h("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"}),h("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),h("path",{d:"M8 21l8 0"}),h("path",{d:"M12 17l0 4"})]}),F),sa=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),F),Q0=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M12 20v.01"}),h("path",{d:"M16 20v.01"}),h("path",{d:"M8 20v.01"}),h("path",{d:"M4 20v.01"}),h("path",{d:"M4 16v.01"}),h("path",{d:"M4 12v.01"}),h("path",{d:"M4 8v.01"}),h("path",{d:"M4 4v.01"}),h("path",{d:"M8 4v.01"}),h("path",{d:"M12 4v.01"}),h("path",{d:"M16 4v.01"}),h("path",{d:"M20 4v.01"}),h("path",{d:"M20 8v.01"}),h("path",{d:"M20 12v.01"}),h("path",{d:"M20 16v.01"}),h("path",{d:"M20 20v.01"})]}),F),eb=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 3v18"}),h("path",{d:"M19 21v-18"}),h("path",{d:"M5 7h14"}),h("path",{d:"M5 15h14"}),h("path",{d:"M8 13v4"}),h("path",{d:"M11 13v4"}),h("path",{d:"M16 13v4"}),h("path",{d:"M14 5v4"}),h("path",{d:"M11 5v4"}),h("path",{d:"M8 5v4"}),h("path",{d:"M3 21h18"})]}),F),tb=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 12l18 0"}),h("path",{d:"M7 16l10 0l-10 5l0 -5"}),h("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),F),ob=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 3l0 18"}),h("path",{d:"M16 7l0 10l5 0l-5 -10"}),h("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),F),zm=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),h("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"})]}),F),ts=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),h("path",{d:"M22 22l-3 -3"}),h("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),h("path",{d:"M3 11v-1"}),h("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),h("path",{d:"M10 3h1"}),h("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),F),rb=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),h("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),h("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"}),h("path",{d:"M10 15l2 6l2 -6"}),h("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),F),nb=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),h("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),h("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),h("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),h("path",{d:"M11 21v-6l3 6v-6"})]}),F),ib=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M4 8l5 0"}),h("path",{d:"M15 8l4 0"})]}),F),ab=M(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),h("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),h("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),h("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),F),lb=M(D("g",{stroke:"currentColor",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"})]}),{...F,strokeWidth:1.5}),jU=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M21 12h-13l3 -3"}),h("path",{d:"M11 15l-3 -3"})]}),F),qU=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M10 9l5 3l-5 3z"})]}),F),sb=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 6h18"}),h("path",{d:"M3 12h18"}),h("path",{d:"M3 18h18"}),h("path",{d:"M6 3v18"}),h("path",{d:"M12 3v18"}),h("path",{d:"M18 3v18"})]}),F),cb=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("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"}),h("path",{d:"M17 5c-6.627 0 -12 5.373 -12 12"})]}),F),os=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 18l12 -12"}),h("path",{d:"M18 10v-4h-4"})]}),F),rs=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7"}),h("path",{d:"M18 4l3 3l-3 3"})]}),F),ns=M(D("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),F),is=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),F),db=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),F),mb=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),F),Hm=M(D("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 5v10a1 1 0 0 0 1 1h10"}),h("path",{d:"M5 8h10a1 1 0 0 1 1 1v10"})]}),F),as=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 7l0 10"}),h("path",{d:"M7 5l10 0"}),h("path",{d:"M7 19l10 0"}),h("path",{d:"M19 7l0 10"})]}),F),Gm=M(D("g",{strokeWidth:"1.25",children:[h("rect",{x:"4",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"4",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"4",y:"16",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"16",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"16",width:"4",height:"4",rx:"1"})]}),F),Um=M(h("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:.5,viewBox:"0 0 640 512",children:h("path",{d:"M15 15C24.4 5.7 39.6 5.7 49 15l63 63L112 40c0-13.3 10.7-24 24-24s24 10.7 24 24l0 96c0 13.3-10.7 24-24 24l-96 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l38.1 0L15 49C5.7 39.6 5.7 24.4 15 15zM133.5 243.9C158.6 193.6 222.7 112 320 112s161.4 81.6 186.5 131.9c3.8 7.6 3.8 16.5 0 24.2C481.4 318.4 417.3 400 320 400s-161.4-81.6-186.5-131.9c-3.8-7.6-3.8-16.5 0-24.2zM320 320a64 64 0 1 0 0-128 64 64 0 1 0 0 128zM591 15c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-63 63 38.1 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-96 0c-13.3 0-24-10.7-24-24l0-96c0-13.3 10.7-24 24-24s24 10.7 24 24l0 38.1 63-63zM15 497c-9.4-9.4-9.4-24.6 0-33.9l63-63L40 400c-13.3 0-24-10.7-24-24s10.7-24 24-24l96 0c13.3 0 24 10.7 24 24l0 96c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-38.1L49 497c-9.4 9.4-24.6 9.4-33.9 0zm576 0l-63-63 0 38.1c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-96c0-13.3 10.7-24 24-24l96 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-38.1 0 63 63c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0z"})}),F);import pb from"clsx";import Wm,{useEffect as uC,useRef as ub,useState as hC}from"react";import{isPromiseLike as gC}from"@excalidraw/common";import mC from"react";import{jsx as Ym}from"react/jsx-runtime";var pC=({size:e="1em",circleWidth:o=8,synchronized:t=!1,className:r=""})=>{let i=-(mC.useRef(Date.now()).current%1600);return Ym("div",{className:`Spinner ${r}`,children:Ym("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:Ym("circle",{cx:"50",cy:"50",r:50-o/2,strokeWidth:o,fill:"none",strokeMiterlimit:"10"})})})},tt=pC;import{jsx as ca,jsxs as da}from"react/jsx-runtime";var W=Wm.forwardRef(({size:e="medium",visible:o=!0,className:t="",...r},n)=>{let{id:i}=ze(),a=Wm.useRef(null);Wm.useImperativeHandle(n,()=>a.current);let l=`ToolIcon_size_${e}`,[s,c]=hC(!1),d=ub(!0),m=async u=>{let f="onClick"in r&&r.onClick?.(u);if(gC(f))try{c(!0),await f}catch(b){if(b instanceof fn)console.warn(b);else throw b}finally{d.current&&c(!1)}};uC(()=>(d.current=!0,()=>{d.current=!1}),[]);let p=ub(null);if(r.type==="button"||r.type==="icon"||r.type==="submit"){let u=r.type==="icon"?"button":r.type;return da("button",{className:pb("ToolIcon_type_button",l,t,o&&!r.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!r.hidden,"ToolIcon--selected":r.selected,"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:u,onClick:m,ref:a,disabled:s||r.isLoading||!!r.disabled,children:[(r.icon||r.label)&&da("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!r.disabled,children:[r.icon||r.label,r.keyBindingLabel&&ca("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel}),r.isLoading&&ca(tt,{})]}),r.showAriaLabel&&da("div",{className:"ToolIcon__label",children:[r["aria-label"]," ",s&&ca(tt,{})]}),r.children]})}return da("label",{className:pb("ToolIcon",t),title:r.title,onPointerDown:u=>{p.current=u.pointerType||null,r.onPointerDown?.({pointerType:u.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{p.current=null})},children:[ca("input",{className:`ToolIcon_type_radio ${l}`,type:"radio",name:r.name,"aria-label":r["aria-label"],"aria-keyshortcuts":r["aria-keyshortcuts"],"data-testid":r["data-testid"],id:`${i}-${r.id}`,onChange:()=>{r.onChange?.({pointerType:p.current})},checked:r.checked,ref:a}),da("div",{className:"ToolIcon__icon",children:[r.icon,r.keyBindingLabel&&ca("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel})]})]})});W.displayName="ToolButton";var ls=[],N=e=>(ls=ls.concat(e),e);import{jsx as TC}from"react/jsx-runtime";var vC=(e,o,t)=>{let r=new Set($(e.filter(d=>EC(d)),o).map(d=>d.id)),n={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let d of r){let m=yC(e,d);for(let p of m)if(!a.has(p.id)){if(ss(p)){let u=gb(p,i);u&&(n[u.id]=!0)}else n[p.id]=!0;a.add(p.id)}}let l=!0,s=e.map(d=>{if(o.selectedElementIds[d.id]){let m=ss(d)?gb(d,i):null;return d.frameId&&r.has(d.frameId)?(l=!1,n[d.id]=!0,d):m?.frameId&&r.has(m?.frameId)?d:(d.boundElements&&d.boundElements.forEach(p=>{let u=t.scene.getNonDeletedElementsMap().get(p.id);u&&xC(u)&&t.scene.mutateElement(u,{startBinding:d.id===u.startBinding?.elementId?null:u.startBinding,endBinding:d.id===u.endBinding?.elementId?null:u.endBinding})}),ds(d,{isDeleted:!0}))}return d.frameId&&r.has(d.frameId)?(l=!1,ss(d)||(n[d.id]=!0),ds(d,{frameId:null})):ss(d)&&o.selectedElementIds[d.containerId]?ds(d,{isDeleted:!0}):d}),c=o.editingGroupId;if(l&&o.editingGroupId){let d=Km(s,o.editingGroupId).filter(m=>!m.isDeleted);if(d.length>1)d[0]&&(n[d[0].id]=!0);else{c=null,d[0]&&(n[d[0].id]=!0);let m=d[0];if(m){let p=m.groupIds.findIndex(f=>f===o.editingGroupId),u=m.groupIds[p+1];if(u){let f=Km(s,u).filter(b=>!b.isDeleted);f.length>1&&(c=u,f.forEach(b=>{n[b.id]=!0}))}}}}return{elements:s,appState:{...o,...wC({selectedElementIds:n,editingGroupId:c},s,o,null)}}},fb=(e,o)=>{if(e.editingGroupId){let t=Km(Xm(o),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},ma=N({name:"deleteSelectedElements",label:"labels.delete",icon:Do,trackEvent:{category:"element",action:"delete"},perform:(e,o,t,r)=>{if(o.selectedLinearElement?.isEditing){let{elementId:a,selectedPointsIndices:l,startBindingElement:s,endBindingElement:c}=o.selectedLinearElement,d=r.scene.getNonDeletedElementsMap(),m=hb.getElement(a,d);if(!m||l==null)return!1;if(l.length>=m.points.length){let u=e.map(b=>b.id===m.id?ds(b,{isDeleted:!0}):b),f=fb(o,u);return{elements:u,appState:{...f,selectedLinearElement:null},captureUpdate:cs.IMMEDIATELY}}let p={startBindingElement:l?.includes(0)?null:s,endBindingElement:l?.includes(m.points.length-1)?null:c};return hb.deletePoints(m,r,l),{elements:e,appState:{...o,selectedLinearElement:{...o.selectedLinearElement,...p,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},captureUpdate:cs.IMMEDIATELY}}let{elements:n,appState:i}=vC(e,o,r);return bC(n,n.filter(a=>a.isDeleted)),i=fb(i,n),{elements:n,appState:{...i,activeTool:fC(o,{type:"selection"}),multiElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Ee(Xm(e),o)?cs.IMMEDIATELY:cs.EVENTUALLY}},keyTest:(e,o,t)=>(e.key===Vm.BACKSPACE||e.key===Vm.DELETE)&&!e[Vm.CTRL_OR_CMD],PanelComponent:({elements:e,appState:o,updateData:t})=>TC(W,{type:"button",icon:Do,title:g("labels.delete"),"aria-label":g("labels.delete"),onClick:()=>t(null),visible:Ee(Xm(e),o)})});import{KEYS as Nn,CODES as Bn,getShortcutKey as Fn,isDarwin as ms}from"@excalidraw/common";import{moveOneLeft as IC,moveOneRight as CC,moveAllLeft as SC,moveAllRight as kC}from"@excalidraw/element";import{CaptureUpdateAction as ps}from"@excalidraw/element";import{jsx as us}from"react/jsx-runtime";var Zm=N({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:Cm,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:IC(e,o,r.scene),appState:o,captureUpdate:ps.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Nn.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Bn.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>us("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendBackward")} \u2014 ${Fn("CtrlOrCmd+[")}`,children:Cm})}),$m=N({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:Im,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:CC(e,o,r.scene),appState:o,captureUpdate:ps.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Nn.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Bn.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>us("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.bringForward")} \u2014 ${Fn("CtrlOrCmd+]")}`,children:Im})}),jm=N({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:km,trackEvent:{category:"element"},perform:(e,o)=>({elements:SC(e,o),appState:o,captureUpdate:ps.IMMEDIATELY}),keyTest:e=>ms?e[Nn.CTRL_OR_CMD]&&e.altKey&&e.code===Bn.BRACKET_LEFT:e[Nn.CTRL_OR_CMD]&&e.shiftKey&&e.code===Bn.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>us("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendToBack")} \u2014 ${ms?Fn("CtrlOrCmd+Alt+["):Fn("CtrlOrCmd+Shift+[")}`,children:km})}),qm=N({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:Sm,trackEvent:{category:"element"},perform:(e,o)=>({elements:kC(e,o),appState:o,captureUpdate:ps.IMMEDIATELY}),keyTest:e=>ms?e[Nn.CTRL_OR_CMD]&&e.altKey&&e.code===Bn.BRACKET_RIGHT:e[Nn.CTRL_OR_CMD]&&e.shiftKey&&e.code===Bn.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>us("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${g("labels.bringToFront")} \u2014 ${ms?Fn("CtrlOrCmd+Alt+]"):Fn("CtrlOrCmd+Shift+]")}`,children:Sm})});import{getNonDeletedElements as MC}from"@excalidraw/element";import{LinearElementEditor as LC}from"@excalidraw/element";import{isLinearElement as PC,isTextElement as AC}from"@excalidraw/element";import{arrayToMap as DC,KEYS as bb}from"@excalidraw/common";import{selectGroupsForSelectedElements as _C}from"@excalidraw/element";import{CaptureUpdateAction as RC}from"@excalidraw/element";var Jm=N({name:"selectAll",label:"labels.selectAll",icon:Q0,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,o,t,r)=>{if(o.selectedLinearElement?.isEditing)return!1;let n=e.filter(i=>!i.isDeleted&&!(AC(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...o,..._C({editingGroupId:null,selectedElementIds:n},MC(e),o,r),selectedLinearElement:Object.keys(n).length===1&&PC(e[0])?new LC(e[0],DC(e)):null},captureUpdate:RC.IMMEDIATELY}},keyTest:e=>e[bb.CTRL_OR_CMD]&&e.key===bb.A});import{DEFAULT_GRID_SIZE as xb,KEYS as Eb,arrayToMap as yb,getShortcutKey as NC}from"@excalidraw/common";import{getNonDeletedElements as wb}from"@excalidraw/element";import{LinearElementEditor as BC}from"@excalidraw/element";import{getSelectedElements as FC,getSelectionStateForElements as OC}from"@excalidraw/element";import{syncMovedIndices as zC}from"@excalidraw/element";import{duplicateElements as HC}from"@excalidraw/element";import{CaptureUpdateAction as vb}from"@excalidraw/element";import{jsx as GC}from"react/jsx-runtime";var Qm=N({name:"duplicateSelection",label:"labels.duplicateSelection",icon:oa,trackEvent:{category:"element"},perform:(e,o,t,r)=>{if(o.selectedElementsAreBeingDragged)return!1;if(o.selectedLinearElement?.isEditing)try{let a=BC.duplicateSelectedPoints(o,r.scene);return{elements:e,appState:a,captureUpdate:vb.IMMEDIATELY}}catch{return!1}let{duplicatedElements:n,elementsWithDuplicates:i}=HC({type:"in-place",elements:e,idsOfElementsToDuplicate:yb(FC(e,o,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:o,randomizeSeed:!0,overrides:({origElement:a,origIdToDuplicateId:l})=>{let s=a.frameId&&l.get(a.frameId);return{x:a.x+xb/2,y:a.y+xb/2,frameId:s??a.frameId}}});if(r.props.onDuplicate&&i){let a=r.props.onDuplicate(i,e);a&&(i=a)}return{elements:zC(i,yb(n)),appState:{...o,...OC(n,wb(i),o)},captureUpdate:vb.IMMEDIATELY}},keyTest:e=>e[Eb.CTRL_OR_CMD]&&e.key===Eb.D,PanelComponent:({elements:e,appState:o,updateData:t})=>GC(W,{type:"button",icon:oa,title:`${g("labels.duplicateSelection")} \u2014 ${NC("CtrlOrCmd+D")}`,"aria-label":g("labels.duplicateSelection"),onClick:()=>t(null),visible:Ee(wb(e),o)})});import{pointFrom as U4}from"@excalidraw/math";import{useEffect as wp,useMemo as Y4,useRef as vp,useState as W4}from"react";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as V4,DEFAULT_ELEMENT_BACKGROUND_PICKS as X4,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as K4,DEFAULT_ELEMENT_STROKE_PICKS as Z4,ARROW_TYPE as Ro,DEFAULT_FONT_FAMILY as $4,DEFAULT_FONT_SIZE as j4,FONT_FAMILY as q4,ROUNDNESS as Ps,STROKE_WIDTH as Tp,VERTICAL_ALIGN as Ls,KEYS as Zn,randomInteger as J4,arrayToMap as Sp,getFontFamilyString as Q4,getShortcutKey as e6,getLineHeight as t6,isTransparent as o6,reduceToCommonValue as r6}from"@excalidraw/common";import{canBecomePolygon as n6,getNonDeletedElements as cx}from"@excalidraw/element";import{bindLinearElement as ix,calculateFixedPointForElbowArrowBinding as ax,updateBoundElements as i6}from"@excalidraw/element";import{LinearElementEditor as Ip}from"@excalidraw/element";import{newElementWith as Ve}from"@excalidraw/element";import{getBoundTextElement as nr,redrawTextBoundingBox as wa}from"@excalidraw/element";import{isArrowElement as As,isBoundToContainer as a6,isElbowArrow as dx,isLinearElement as Cp,isLineElement as lx,isTextElement as wt,isUsingAdaptiveRadius as l6}from"@excalidraw/element";import{hasStrokeColor as s6}from"@excalidraw/element";import{updateElbowArrowPoints as c6,CaptureUpdateAction as Xe,toggleLinePolygonState as d6}from"@excalidraw/element";import{isDevEnv as UC}from"@excalidraw/common";var YC=new Set(["command_palette","export"]),re=(e,o,t,r)=>{try{if(typeof window>"u"||T.VITE_WORKER_ID||T.VITE_APP_ENABLE_TRACKING!=="true"||!YC.has(e)||UC())return;T.PROD||console.info("trackEvent",{category:e,action:o,label:t,value:r}),window.sa_event&&window.sa_event(o,{category:e,label:t,value:r})}catch(n){console.error("error during analytics",n)}};import KC from"clsx";import WC from"clsx";import{forwardRef as VC}from"react";import{jsx as XC}from"react/jsx-runtime";var On=VC((e,o)=>{let{title:t,className:r,testId:n,active:i,standalone:a,icon:l,onClick:s}=e;return XC("button",{type:"button",ref:o,title:t,"data-testid":n,className:WC(r,{standalone:a,active:i}),onClick:s,style:e.style,children:l},t)});import{Fragment as $C,jsx as ep,jsxs as ZC}from"react/jsx-runtime";var Ot=e=>ep($C,{children:e.options.map(o=>e.type==="button"?ep(On,{icon:o.icon,title:o.text,testId:o.testId,active:o.active??e.value===o.value,onClick:t=>e.onClick(o.value,t)},o.text):ZC("label",{className:KC({active:e.value===o.value}),title:o.text,children:[ep("input",{type:"radio",name:e.group,onChange:()=>e.onChange(o.value),checked:e.value===o.value,"data-testid":o.testId}),o.icon]},o.text))});import*as ys from"@radix-ui/react-popover";import ZS from"clsx";import{useRef as $S}from"react";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as jS,COLOR_PALETTE as Gb,isTransparent as qS}from"@excalidraw/common";import{jsx as jC}from"react/jsx-runtime";var hs=()=>jC("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as tS,useRef as oS}from"react";import{createPortal as rS}from"react-dom";import{EVENT as Jo,KEYS as nS,rgbToHex as iS}from"@excalidraw/common";import Tb from"react";var tp=Tb.createContext(null),ge=()=>Tb.useContext(tp);import{useState as qC,useLayoutEffect as Ib}from"react";import{THEME as JC}from"@excalidraw/common";var gs=e=>{let[o,t]=qC(null),r=ce(),{theme:n}=ge(),{container:i}=ze();return Ib(()=>{o&&(o.className="",o.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),o.classList.toggle("excalidraw--mobile",r.editor.isMobile),o.classList.toggle("theme--dark",n===JC.DARK))},[o,n,r.editor.isMobile,e?.className]),Ib(()=>{let a=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!a)return;let l=document.createElement("div");return a.appendChild(l),t(l),()=>{a.removeChild(l)}},[i,e?.parentSelector]),o};import{useEffect as QC}from"react";import{EVENT as fs}from"@excalidraw/common";function zn(e,o,t){QC(()=>{function r(n){let i=n;if(!e.current)return;let a=t?.(i,e.current);if(a===!0)return;if(a===!1)return o(i);e.current.contains(i.target)||!document.documentElement.contains(i.target)||i.target.closest("[data-radix-portal]")||i.target===document.documentElement&&document.body.style.pointerEvents==="none"||i.target.closest("[data-prevent-outside-click]")||o(i)}return document.addEventListener(fs.POINTER_DOWN,r),document.addEventListener(fs.TOUCH_START,r),()=>{document.removeEventListener(fs.POINTER_DOWN,r),document.removeEventListener(fs.TOUCH_START,r)}},[e,o,t])}import{useRef as eS}from"react";var qo=e=>{let o=eS(e);return Object.assign(o.current,e),o.current};import{jsx as aS}from"react/jsx-runtime";var Qo=he(null),Cb=({onCancel:e,onChange:o,onSelect:t,colorPickerType:r})=>{let n=gs({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=ge(),a=er(),l=Re(),s=$(a,i),c=qo({app:l,onCancel:e,onChange:o,onSelect:t,selectedElements:s}),{container:d}=ze();tS(()=>{let p=m.current;if(!p||!l.canvas||!n)return;let u=!1,f=l.canvas.getContext("2d"),b=({clientX:S,clientY:L})=>{let k=f.getImageData((S-i.offsetLeft)*window.devicePixelRatio,(L-i.offsetTop)*window.devicePixelRatio,1,1).data;return iS(k[0],k[1],k[2])},x=({clientX:S,clientY:L,altKey:k})=>{p.style.top=`${L+20}px`,p.style.left=`${S+20}px`;let A=b({clientX:S,clientY:L});u&&c.onChange(r,A,c.selectedElements,{altKey:k}),p.style.background=A},w=()=>{c.onCancel()},E=(S,L)=>{c.onSelect(S,L)},y=S=>{u=!0,S.stopImmediatePropagation()},v=S=>{u=!1,d?.focus(),S.stopImmediatePropagation(),S.preventDefault(),E(b(S),S)},C=S=>{S.key===nS.ESCAPE&&(S.preventDefault(),S.stopImmediatePropagation(),w())};return n.tabIndex=-1,n.focus(),x({clientX:c.app.lastViewportPosition.x,clientY:c.app.lastViewportPosition.y,altKey:!1}),n.addEventListener(Jo.KEYDOWN,C),n.addEventListener(Jo.POINTER_DOWN,y),n.addEventListener(Jo.POINTER_UP,v),window.addEventListener("pointermove",x,{passive:!0}),window.addEventListener(Jo.BLUR,w),()=>{u=!1,n.removeEventListener(Jo.KEYDOWN,C),n.removeEventListener(Jo.POINTER_DOWN,y),n.removeEventListener(Jo.POINTER_UP,v),window.removeEventListener("pointermove",x),window.removeEventListener(Jo.BLUR,w)}},[c,l.canvas,n,r,d,i.offsetLeft,i.offsetTop]);let m=oS(null);return zn(m,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),n?rS(aS("div",{ref:m,className:"excalidraw-eye-dropper-preview"}),n):null};import*as Hn from"@radix-ui/react-popover";import dS from"clsx";import mS from"react";import{isInteractive as pS}from"@excalidraw/common";import lS from"react";import sS from"clsx";import{jsx as cS}from"react/jsx-runtime";var We=lS.forwardRef(({children:e,padding:o,className:t,style:r},n)=>cS("div",{className:sS("Island",t),style:{"--padding":o,...r},ref:n,children:e}));import{jsx as op,jsxs as uS}from"react/jsx-runtime";var bs=mS.forwardRef(({className:e,container:o,children:t,style:r,onClose:n,onKeyDown:i,onFocusOutside:a,onPointerLeave:l,onPointerDownOutside:s},c)=>{let d=ce();return op(Hn.Portal,{container:o,children:uS(Hn.Content,{ref:c,className:dS("focus-visible-none",e),"data-prevent-outside-click":!0,side:d.editor.isMobile&&!d.viewport.isLandscape?"bottom":"right",align:d.editor.isMobile&&!d.viewport.isLandscape?"center":"start",alignOffset:-16,sideOffset:20,style:{zIndex:"var(--zIndex-popup)"},onPointerLeave:l,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:s,onCloseAutoFocus:m=>{m.stopPropagation(),m.preventDefault(),o&&!pS(document.activeElement)&&o.focus(),n()},children:[op(We,{padding:3,style:r,children:t}),op(Hn.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})});import gS from"clsx";import{useCallback as fS,useEffect as np,useRef as Mb,useState as bS}from"react";import{KEYS as ip,getShortcutKey as xS}from"@excalidraw/common";import{MAX_CUSTOM_COLORS_USED_IN_CANVAS as hS}from"@excalidraw/common";var tr=({palette:e,color:o})=>{if(!o)return null;for(let[t,r]of Object.entries(e))if(Array.isArray(r)){let n=r.indexOf(o);if(n>-1)return{colorName:t,shade:n}}else if(r===o)return{colorName:t,shade:null};return null},pa=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),rp=({color:e,palette:o})=>!Object.values(o).flat().includes(e),kb=(e,o,t)=>{let r={elementBackground:"backgroundColor",elementStroke:"strokeColor"},n=e.filter(a=>{if(a.isDeleted)return!1;let l=a[r[o]];return rp({color:l,palette:t})}),i=new Map;return n.forEach(a=>{let l=a[r[o]];i.has(l)?i.set(l,i.get(l)+1):i.set(l,1)}),[...i.entries()].sort((a,l)=>l[1]-a[1]).map(a=>a[0]).slice(0,hS)},zt=he(null),Sb=(e,o,t)=>(e*299+o*587+t*114)/1e3,Gn=(e,o=160)=>{if(!e)return!0;if(e==="transparent")return!1;if(!e.startsWith("#")){let i=document.createElement("div");if(i.style.color=e,i.style.color){i.style.position="absolute",i.style.visibility="hidden",i.style.width="0",i.style.height="0",document.body.appendChild(i);let a=getComputedStyle(i).color;document.body.removeChild(i);let l=a.replace(/^(rgb|rgba)\(/,"").replace(/\)$/,"").replace(/\s/g,"").split(","),s=parseInt(l[0]),c=parseInt(l[1]),d=parseInt(l[2]);return Sb(s,c,d)<o}return!0}let t=parseInt(e.slice(1,3),16),r=parseInt(e.slice(3,5),16),n=parseInt(e.slice(5,7),16);return Sb(t,r,n)<o};import{Fragment as ES,jsx as xs,jsxs as Lb}from"react/jsx-runtime";var Pb=({color:e,onChange:o,label:t,colorPickerType:r,placeholder:n})=>{let i=ce(),[a,l]=bS(e),[s,c]=se(zt);np(()=>{l(e)},[e]);let d=fS(b=>{let x=b.toLowerCase(),w=Ab(x);w&&o(w),l(x)},[o]),m=Mb(null),p=Mb(null);np(()=>{m.current&&m.current.focus()},[s]);let[u,f]=se(Qo);return np(()=>()=>{f(null)},[f]),Lb("div",{className:"color-picker__input-label",children:[xs("div",{className:"color-picker__input-hash",children:"#"}),xs("input",{ref:s==="hex"?m:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,onChange:b=>{d(b.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{l(e)},tabIndex:-1,onFocus:()=>c("hex"),onKeyDown:b=>{b.key!==ip.TAB&&(b.key===ip.ESCAPE&&p.current?.focus(),b.stopPropagation())},placeholder:n}),!i.editor.isMobile&&Lb(ES,{children:[xs("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),xs("div",{ref:p,className:gS("excalidraw-eye-dropper-trigger",{selected:u}),onClick:()=>f(b=>b?null:{keepOpenOnAlt:!1,onSelect:x=>o(x),colorPickerType:r}),title:`${g("labels.eyeDropper")} \u2014 ${ip.I.toLocaleUpperCase()} or ${xS("Alt")} `,children:Y0})]})]})};import cp,{useEffect as dp,useImperativeHandle as OS,useState as zS}from"react";import{EVENT as Fb}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as HS,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as GS,KEYS as US}from"@excalidraw/common";import vS from"clsx";import{useEffect as TS,useRef as IS}from"react";import{jsxs as wS}from"react/jsx-runtime";var yS=({color:e,keyLabel:o,isShade:t=!1})=>wS("div",{className:"color-picker__button__hotkey-label",style:{color:Gn(e)?"#fff":"#000"},children:[t&&"\u21E7",o]}),Un=yS;import{jsx as ap,jsxs as CS}from"react/jsx-runtime";var Db=({colors:e,color:o,onChange:t,label:r})=>{let[n,i]=se(zt),a=IS(null);return TS(()=>{a.current&&a.current.focus()},[o,n]),ap("div",{className:"color-picker-content--default",children:e.map((l,s)=>CS("button",{ref:o===l?a:void 0,tabIndex:-1,type:"button",className:vS("color-picker__button color-picker__button--large has-outline",{active:o===l,"is-transparent":l==="transparent"||!l}),onClick:()=>{t(l),i("custom")},title:l,"aria-label":r,style:{"--swatch-color":l},children:[ap("div",{className:"color-picker__button-outline"}),ap(Un,{color:l,keyLabel:s+1})]},s))})};import SS from"clsx";import{useEffect as kS,useRef as MS}from"react";import{jsx as lp,jsxs as PS}from"react/jsx-runtime";var LS=({palette:e,color:o,onChange:t,activeShade:r})=>{let n=tr({color:o,palette:e}),[i,a]=se(zt),l=MS(null);return kS(()=>{l.current&&i==="baseColors"&&l.current.focus()},[n?.colorName,i]),lp("div",{className:"color-picker-content--default",children:Object.entries(e).map(([s,c],d)=>{let m=(Array.isArray(c)?c[r]:c)||"transparent",p=pa[d],u=g(`colors.${s.replace(/\d+/,"")}`,null,"");return PS("button",{ref:n?.colorName===s?l:void 0,tabIndex:-1,type:"button",className:SS("color-picker__button color-picker__button--large has-outline",{active:n?.colorName===s,"is-transparent":m==="transparent"||!m}),onClick:()=>{t(m),a("baseColors")},title:`${u}${m.startsWith("#")?` ${m}`:""} \u2014 ${p}`,"aria-label":`${u} \u2014 ${p}`,style:m?{"--swatch-color":m}:void 0,"data-testid":`color-${s}`,children:[lp("div",{className:"color-picker__button-outline"}),lp(Un,{color:m,keyLabel:p})]},s)})})},_b=LS;import{jsx as DS}from"react/jsx-runtime";var AS=({children:e})=>DS("div",{className:"color-picker__heading",children:e}),Yn=AS;import _S from"clsx";import{useEffect as RS,useRef as NS}from"react";import{jsx as ua,jsxs as Rb}from"react/jsx-runtime";var Nb=({color:e,onChange:o,palette:t})=>{let r=tr({color:e||"transparent",palette:t}),[n,i]=se(zt),a=NS(null);if(RS(()=>{a.current&&n==="shades"&&a.current.focus()},[r,n]),r){let{colorName:l,shade:s}=r,c=t[l];if(Array.isArray(c))return ua("div",{className:"color-picker-content--default shades",children:c.map((d,m)=>Rb("button",{ref:m===s&&n==="shades"?a:void 0,tabIndex:-1,type:"button",className:_S("color-picker__button color-picker__button--large has-outline",{active:m===s}),"aria-label":"Shade",title:`${l} - ${m+1}`,style:d?{"--swatch-color":d}:void 0,onClick:()=>{o(d),i("shades")},children:[ua("div",{className:"color-picker__button-outline"}),ua(Un,{color:d,keyLabel:m+1,isShade:!0})]},m))})}return Rb("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[ua("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),ua("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:g("colorPicker.noShades")})]})};import{COLORS_PER_ROW as Wn,COLOR_PALETTE as BS,KEYS as ha}from"@excalidraw/common";var sp=(e,o,t)=>{let r=Math.ceil(t/Wn);switch(o=o??-1,e){case"ArrowLeft":{let n=o-1;return n<0?t-1:n}case"ArrowRight":return(o+1)%t;case"ArrowDown":{let n=o+Wn;return n>=t?o%Wn:n}case"ArrowUp":{let n=o-Wn,i=n<0?Wn*r+n:n;return i>=t?void 0:i}}},FS=({e,colorObj:o,onChange:t,palette:r,customColors:n,setActiveColorPickerSection:i,activeShade:a})=>{if(o?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let l=Number(e.code.slice(-1))-1;return t(r[o.colorName][l]),i("shades"),!0}if(["1","2","3","4","5"].includes(e.key)&&n[Number(e.key)-1])return t(n[Number(e.key)-1]),i("custom"),!0;if(pa.includes(e.key)){let l=pa.indexOf(e.key),s=Object.keys(r)[l],c=r[s],d=Array.isArray(c)?c[a]:c;return t(d),i("baseColors"),!0}return!1},Bb=({event:e,activeColorPickerSection:o,palette:t,color:r,onChange:n,customColors:i,setActiveColorPickerSection:a,updateData:l,activeShade:s,onEyeDropperToggle:c,onEscape:d})=>{if(e[ha.CTRL_OR_CMD])return!1;if(e.key===ha.ESCAPE)return d(e),!0;if(e.key===ha.ALT)return c(!0),!0;if(e.key===ha.I)return c(),!0;let m=tr({color:r,palette:t});if(e.key===ha.TAB){let p={custom:!!i.length,baseColors:!0,shades:m?.shade!=null,hex:!0},u=Object.entries(p).reduce((E,[y,v])=>(v&&E.push(y),E),[]),f=u.indexOf(o),b=e.shiftKey?-1:1,x=f+b>u.length-1?0:f+b<0?u.length-1:f+b,w=u[x];return w&&a(w),w==="custom"?n(i[0]):w==="baseColors"&&(Object.entries(t).find(([y,v])=>Array.isArray(v)?v.includes(r):v===r?y:null)||n(BS.black)),e.preventDefault(),e.stopPropagation(),!0}if(FS({e,colorObj:m,onChange:n,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:s}))return!0;if(o==="shades"&&m){let{shade:p}=m,u=sp(e.key,p,Wn);if(u!==void 0)return n(t[m.colorName][u]),!0}if(o==="baseColors"&&m){let{colorName:p}=m,u=Object.keys(t),f=u.indexOf(p),b=sp(e.key,f,u.length);if(b!==void 0){let x=u[b],w=t[x];return n(Array.isArray(w)?w[s]:w),!0}}if(o==="custom"){let p=r!=null?i.indexOf(r):0,u=sp(e.key,p,i.length);if(u!==void 0){let f=i[u];return n(f),!0}}return!1};import{jsx as Ur,jsxs as Es}from"react/jsx-runtime";var Ob=cp.forwardRef(({color:e,onChange:o,type:t,elements:r,palette:n,updateData:i,children:a,onEyeDropperToggle:l,onEscape:s},c)=>{let[d]=cp.useState(()=>t==="canvasBackground"?[]:kb(r,t,n)),[m,p]=se(zt),u=tr({color:e,palette:n});dp(()=>{if(!m){let w=!!e&&rp({color:e,palette:n}),E=w&&!d.includes(e);p(E?null:w?"custom":u?.shade!=null?"shades":"baseColors")}},[m,e,n,p,u,d]);let[f,b]=zS(u?.shade??(t==="elementBackground"?HS:GS));dp(()=>{u?.shade!=null&&b(u.shade);let w=E=>{E.key===US.ALT&&l(!1)};return document.addEventListener(Fb.KEYUP,w,{capture:!0}),()=>{document.removeEventListener(Fb.KEYUP,w,{capture:!0})}},[u,l]);let x=cp.useRef(null);return OS(c,()=>x.current),dp(()=>{x?.current?.focus()},[]),Ur("div",{role:"dialog","aria-modal":"true","aria-label":g("labels.colorPicker"),children:Es("div",{ref:x,onKeyDown:w=>{Bb({event:w,activeColorPickerSection:m,palette:n,color:e,onChange:o,onEyeDropperToggle:l,customColors:d,setActiveColorPickerSection:p,updateData:i,activeShade:f,onEscape:s})&&(w.preventDefault(),w.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[!!d.length&&Es("div",{children:[Ur(Yn,{children:g("colorPicker.mostUsedCustomColors")}),Ur(Db,{colors:d,color:e,label:g("colorPicker.mostUsedCustomColors"),onChange:o})]}),Es("div",{children:[Ur(Yn,{children:g("colorPicker.colors")}),Ur(_b,{color:e,palette:n,onChange:o,activeShade:f})]}),Es("div",{children:[Ur(Yn,{children:g("colorPicker.shades")}),Ur(Nb,{color:e,onChange:o,palette:n})]}),a]})})});import YS from"clsx";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as WS,DEFAULT_CANVAS_BACKGROUND_PICKS as VS,DEFAULT_ELEMENT_BACKGROUND_PICKS as XS,DEFAULT_ELEMENT_STROKE_PICKS as KS}from"@excalidraw/common";import{jsx as mp}from"react/jsx-runtime";var zb=({onChange:e,type:o,activeColor:t,topPicks:r})=>{let n;return o==="elementStroke"&&(n=KS),o==="elementBackground"&&(n=XS),o==="canvasBackground"&&(n=VS),r&&(n=r),n?mp("div",{className:"color-picker__top-picks",children:n.map(i=>mp("button",{className:YS("color-picker__button",{active:i===t,"is-transparent":i==="transparent"||!i,"has-outline":!Gn(i,WS)}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:mp("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};import{jsx as Qt,jsxs as pp}from"react/jsx-runtime";var Hb=e=>{let o=new Option().style;return o.color=e,!!o.color},Ab=e=>qS(e)?e:Hb(`#${e}`)?`#${e}`:Hb(e)?e:null,JS=({type:e,color:o,onChange:t,label:r,elements:n,palette:i=Gb,updateData:a})=>{let{container:l}=ze(),[,s]=se(zt),[c,d]=se(Qo),m=pp("div",{children:[Qt(Yn,{children:g("colorPicker.hexCode")}),Qt(Pb,{color:o||"",label:r,onChange:f=>{t(f)},colorPickerType:e,placeholder:g("colorPicker.color")})]}),p=$S(null),u=()=>{p.current?.focus()};return Qt(bs,{container:l,style:{maxWidth:"13rem"},onFocusOutside:f=>{u(),f.preventDefault()},onPointerDownOutside:f=>{c&&f.preventDefault()},onClose:()=>{a({openPopup:null}),s(null)},children:i?Qt(Ob,{ref:p,palette:i,color:o,onChange:f=>{t(f)},onEyeDropperToggle:f=>{d(b=>f?(b=b||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},b.keepOpenOnAlt=!0,b):f===!1||b?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:f=>{c?d(null):a({openPopup:null})},type:e,elements:n,updateData:a,children:m}):m})},QS=({label:e,color:o,type:t})=>Qt(ys.Trigger,{type:"button",className:ZS("color-picker__button active-color properties-trigger",{"is-transparent":!o||o==="transparent","has-outline":!o||!Gn(o,jS)}),"aria-label":e,style:o?{"--swatch-color":o}:void 0,title:t==="elementStroke"?g("labels.showStroke"):g("labels.showBackground"),children:Qt("div",{className:"color-picker__button-outline",children:!o&&K1})}),ga=({type:e,color:o,onChange:t,label:r,elements:n,palette:i=Gb,topPicks:a,updateData:l,appState:s})=>Qt("div",{children:pp("div",{role:"dialog","aria-modal":"true",className:"color-picker-container",children:[Qt(zb,{activeColor:o,onChange:t,type:e,topPicks:a}),Qt(hs,{}),pp(ys.Root,{open:s.openPopup===e,onOpenChange:c=>{l({openPopup:c?e:null})},children:[Qt(QS,{color:o,label:r,type:e}),s.openPopup===e&&Qt(JS,{type:e,color:o,onChange:t,label:r,elements:n,palette:i,updateData:l})]})]})});import*as qb from"@radix-ui/react-popover";import L4,{useCallback as P4,useMemo as A4}from"react";import{FONT_FAMILY as bp}from"@excalidraw/common";import E4,{useMemo as or,useState as y4,useRef as w4,useEffect as v4,useCallback as T4}from"react";import{arrayToList as I4,debounce as C4,FONT_FAMILY as Yr,getFontFamilyString as S4}from"@excalidraw/common";import e4 from"clsx";import t4 from"react";import{jsx as o4,jsxs as r4}from"react/jsx-runtime";var ws=t4.forwardRef(({className:e,placeholder:o,onChange:t},r)=>r4("div",{className:e4("QuickSearch__wrapper",e),children:[At,o4("input",{ref:r,className:"QuickSearch__input",type:"text",placeholder:o,onChange:n=>t(n.target.value.trim().toLowerCase())})]}));import n4 from"clsx";import{Children as i4}from"react";import{jsx as Ub}from"react/jsx-runtime";var vs=({className:e,placeholder:o,children:t})=>{let r=!i4.count(t);return Ub("div",{className:n4("ScrollableList__wrapper",e),role:"menu",children:r?Ub("div",{className:"empty",children:o}):t})};import{jsx as a4,jsxs as l4}from"react/jsx-runtime";var Yb=({children:e,className:o="",style:t,title:r})=>l4("div",{className:`dropdown-menu-group ${o}`,style:t,children:[r&&a4("p",{className:"dropdown-menu-group-title",children:r}),e]}),fa=Yb;Yb.displayName="DropdownMenuGroup";import{useEffect as f4,useRef as b4}from"react";import{THEME as x4}from"@excalidraw/common";import{jsx as s4}from"react/jsx-runtime";var ba=({children:e,...o})=>s4("span",{...o,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...o.style},children:e});import{Fragment as d4,jsx as Ts,jsxs as m4}from"react/jsx-runtime";var c4=({textStyle:e,icon:o,shortcut:t,children:r})=>{let n=ce();return m4(d4,{children:[o&&Ts("div",{className:"dropdown-menu-item__icon",children:o}),Ts("div",{style:e,className:"dropdown-menu-item__text",children:Ts(ba,{children:r})}),t&&!n.editor.isMobile&&Ts("div",{className:"dropdown-menu-item__shortcut",children:t})]})},Is=c4;import p4,{useContext as u4}from"react";import{EVENT as h4,composeEventHandlers as g4}from"@excalidraw/common";var up=p4.createContext({}),Cs=(e="",o=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e}
2
+ ${o?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),Ss=(e,o)=>{let t=u4(up);return g4(e,r=>{let n=new CustomEvent(h4.MENU_ITEM_SELECT,{bubbles:!0,cancelable:!0});o?.(n),n.defaultPrevented||t.onSelect?.(n)})};import{jsx as hp}from"react/jsx-runtime";var gp=({icon:e,value:o,order:t,children:r,shortcut:n,className:i,hovered:a,selected:l,textStyle:s,onSelect:c,onClick:d,...m})=>{let p=Ss(d,c),u=b4(null);return f4(()=>{a&&(t===0?u.current?.scrollIntoView({block:"end"}):u.current?.scrollIntoView({block:"nearest"}))},[a,t]),hp("button",{...m,ref:u,value:o,onClick:p,className:Cs(i,l,a),title:m.title??m["aria-label"],children:hp(Is,{textStyle:s,icon:e,shortcut:n,children:r})})};gp.displayName="DropdownMenuItem";var Vn={GREEN:"green",RED:"red",BLUE:"blue"},ks=({type:e=Vn.BLUE,children:o})=>{let{theme:t}=go(),r={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===x4.LIGHT?"1.5px solid white":"none"};switch(e){case Vn.GREEN:Object.assign(r,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case Vn.RED:Object.assign(r,{backgroundColor:"pink",color:"darkred"});break;case Vn.BLUE:default:Object.assign(r,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return hp("div",{className:"DropDownMenuItemBadge",style:r,children:o})};ks.displayName="DropdownMenuItemBadge";gp.Badge=ks;var yt=gp;import{KEYS as Xn}from"@excalidraw/common";var Wb=({event:e,inputRef:o,hoveredFont:t,filteredFonts:r,onClose:n,onSelect:i,onHover:a})=>{if(!e[Xn.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===Xn.F)return o.current?.focus(),!0;if(e.key===Xn.ESCAPE)return n(),!0;if(e.key===Xn.ENTER)return t?.value&&i(t.value),!0;if(e.key===Xn.ARROW_DOWN)return t?.next?a(t.next.value):r[0]?.value&&a(r[0].value),!0;if(e.key===Xn.ARROW_UP)return t?.prev?a(t.prev.value):r[r.length-1]?.value&&a(r[r.length-1].value),!0};import{jsx as xa,jsxs as Vb}from"react/jsx-runtime";var k4=e=>{switch(e){case Yr.Excalifont:case Yr.Virgil:return jo;case Yr.Nunito:case Yr.Helvetica:return aa;case Yr["Lilita One"]:return A0;case Yr["Comic Shanns"]:case Yr.Cascadia:return Jl;default:return aa}},Xb=E4.memo(({selectedFontFamily:e,hoveredFontFamily:o,onSelect:t,onHover:r,onLeave:n,onOpen:i,onClose:a})=>{let{container:l}=ze(),{fonts:s}=Re(),{showDeprecatedFonts:c}=fo(),[d,m]=y4(""),p=w4(null),u=or(()=>Array.from(Zo.registered.entries()).filter(([k,{metadata:A}])=>!A.private&&!A.fallback).map(([k,{metadata:A,fontFaces:P}])=>{let B={value:k,icon:k4(k),text:P[0]?.fontFace?.family??"Unknown"};return A.deprecated&&Object.assign(B,{deprecated:A.deprecated,badge:{type:Vn.RED,placeholder:g("fontList.badge.old")}}),B}).sort((k,A)=>k.text.toLowerCase()>A.text.toLowerCase()?1:-1),[]),f=or(()=>new Set(s.getSceneFamilies()),[e]),b=or(()=>u.filter(k=>f.has(k.value)),[u,f]),x=or(()=>u.filter(k=>!f.has(k.value)&&(c||!k.deprecated)),[u,f,c]),w=or(()=>I4([...b,...x].filter(k=>k.text?.toLowerCase().includes(d))),[b,x,d]),E=or(()=>{let k;return o?k=w.find(A=>A.value===o):e&&(k=w.find(A=>A.value===e)),!k&&d&&(w[0]?.value?r(w[0].value):n()),k},[o,e,d,w,r,n]),y=T4(k=>{Wb({event:k,inputRef:p,hoveredFont:E,filteredFonts:w,onSelect:t,onHover:r,onClose:a})&&(k.preventDefault(),k.stopPropagation())},[E,w,t,r,a]);v4(()=>(i(),()=>{a()}),[]);let v=or(()=>w.filter(k=>f.has(k.value)),[w,f]),C=or(()=>w.filter(k=>!f.has(k.value)),[w,f]),S=(k,A)=>Vb(yt,{icon:k.icon,value:k.value,order:A,textStyle:{fontFamily:S4({fontFamily:k.value})},hovered:k.value===E?.value,selected:k.value===e,tabIndex:k.value===e?0:-1,onClick:P=>{t(Number(P.currentTarget.value))},onMouseMove:()=>{E?.value!==k.value&&r(k.value)},children:[k.text,k.badge&&xa(ks,{type:k.badge.type,children:k.badge.placeholder})]},k.value),L=[];return v.length&&L.push(xa(fa,{title:g("fontList.sceneFonts"),children:v.map(S)},"group_1")),C.length&&L.push(xa(fa,{title:g("fontList.availableFonts"),children:C.map((k,A)=>S(k,A+v.length))},"group_2")),Vb(bs,{className:"properties-content",container:l,style:{width:"15rem"},onClose:a,onPointerLeave:n,onKeyDown:y,children:[xa(ws,{ref:p,placeholder:g("quickSearch.placeholder"),onChange:C4(m,20)}),xa(vs,{className:"dropdown-menu fonts manual-hover",placeholder:g("fontList.empty"),children:L.length?L:null})]})},(e,o)=>e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as Kb from"@radix-ui/react-popover";import{useMemo as M4}from"react";import{jsx as fp}from"react/jsx-runtime";var Zb=({selectedFontFamily:e})=>{let o=M4(()=>!!(e&&!$b(e)),[e]);return fp(Kb.Trigger,{asChild:!0,children:fp("div",{children:fp(On,{standalone:!0,icon:Ln,title:g("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:o,onClick:()=>{}})})})};import{jsx as Ea,jsxs as jb}from"react/jsx-runtime";var Jb=[{value:bp.Excalifont,icon:jo,text:g("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:bp.Nunito,icon:aa,text:g("labels.normal"),testId:"font-family-normal"},{value:bp["Comic Shanns"],icon:Jl,text:g("labels.code"),testId:"font-family-code"}],D4=new Set(Jb.map(e=>e.value)),$b=e=>e?D4.has(e):!1,Qb=L4.memo(({isOpened:e,selectedFontFamily:o,hoveredFontFamily:t,onSelect:r,onHover:n,onLeave:i,onPopupChange:a})=>{let l=A4(()=>Jb,[]),s=P4(c=>{c&&r(c)},[r]);return jb("div",{role:"dialog","aria-modal":"true",className:"FontPicker__container",children:[Ea("div",{className:"buttonList",children:Ea(Ot,{type:"button",options:l,value:o,onClick:s})}),Ea(hs,{}),jb(qb.Root,{open:e,onOpenChange:a,children:[Ea(Zb,{selectedFontFamily:o}),e&&Ea(Xb,{selectedFontFamily:o,hoveredFontFamily:t,onSelect:s,onHover:n,onLeave:i,onOpen:()=>a(!0),onClose:()=>a(!1)})]})]})},(e,o)=>e.isOpened===o.isOpened&&e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as Kn from"@radix-ui/react-popover";import B4 from"clsx";import Ms,{useEffect as F4}from"react";import{isArrowKey as O4,KEYS as _o}from"@excalidraw/common";import{jsx as _4}from"react/jsx-runtime";var rr=({icon:e})=>_4("span",{style:{width:"1em",margin:"0 0.5ex 0 0.5ex",display:"inline-block",lineHeight:0,verticalAlign:"middle",flex:"0 0 auto"},children:e});import{Fragment as N4,jsx as ex,jsxs as tx}from"react/jsx-runtime";var R4=({label:e,open:o,openTrigger:t,children:r,className:n,showCollapsedIcon:i=!0})=>tx(N4,{children:[tx("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:n,onClick:t,children:[e,i&&ex(rr,{icon:o?db:is})]}),o&&ex("div",{style:{display:"flex",flexDirection:"column"},children:r})]}),ya=R4;import{jsx as Wr,jsxs as xp}from"react/jsx-runtime";var z4=he(!1);function H4({options:e,value:o,label:t,onChange:r,onClose:n,numberOfOptionsToAlwaysShow:i=e.length}){let a=ce(),l=u=>{let f=e.find(b=>b.keyBinding===u.key.toLowerCase());if(!(u.metaKey||u.altKey||u.ctrlKey)&&f)r(f.value),u.preventDefault();else if(u.key===_o.TAB){let b=e.findIndex(w=>w.value===o),x=u.shiftKey?(e.length+b-1)%e.length:(b+1)%e.length;r(e[x].value)}else if(O4(u.key)){let b=Po().rtl,x=e.findIndex(w=>w.value===o);if(x!==-1){let w=e.length,E=x;switch(u.key){case(b?_o.ARROW_LEFT:_o.ARROW_RIGHT):E=(x+1)%w;break;case(b?_o.ARROW_RIGHT:_o.ARROW_LEFT):E=(w+x-1)%w;break;case _o.ARROW_DOWN:{E=(x+(i??1))%w;break}case _o.ARROW_UP:{E=(w+x-(i??1))%w;break}}r(e[E].value)}u.preventDefault()}else(u.key===_o.ESCAPE||u.key===_o.ENTER)&&(u.preventDefault(),n());u.nativeEvent.stopImmediatePropagation(),u.stopPropagation()},[s,c]=se(z4),d=Ms.useMemo(()=>e.slice(0,i),[e,i]),m=Ms.useMemo(()=>e.slice(i),[e,i]);F4(()=>{d.some(u=>u.value===o)||c(!0)},[o,d,c]);let p=u=>Wr("div",{className:"picker-content",children:u.map((f,b)=>xp("button",{type:"button",className:B4("picker-option",{active:o===f.value}),onClick:x=>{r(f.value)},title:`${f.text} ${f.keyBinding&&`\u2014 ${f.keyBinding.toUpperCase()}`}`,"aria-label":f.text||"none","aria-keyshortcuts":f.keyBinding||void 0,ref:x=>{o===f.value&&setTimeout(()=>{x?.focus()},0)},children:[f.icon,f.keyBinding&&Wr("span",{className:"picker-keybinding",children:f.keyBinding})]},f.text))});return Wr(Kn.Content,{side:a.editor.isMobile&&!a.viewport.isLandscape?"top":"bottom",align:"start",sideOffset:12,style:{zIndex:"var(--zIndex-popup)"},onKeyDown:l,children:xp("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":t,children:[p(d),m.length>0&&Wr(ya,{label:g("labels.more_options"),open:s,openTrigger:()=>{c(u=>!u)},className:"picker-collapsible",children:p(m)})]})})}function Ep({value:e,label:o,options:t,onChange:r,group:n="",numberOfOptionsToAlwaysShow:i}){let[a,l]=Ms.useState(!1),s=Ms.useRef(null);return Wr("div",{children:xp(Kn.Root,{open:a,onOpenChange:c=>l(c),children:[Wr(Kn.Trigger,{name:n,type:"button","aria-label":o,onClick:()=>l(!a),ref:s,className:a?"active":"",children:t.find(c=>c.value===e)?.icon}),a&&Wr(H4,{options:t,value:e,label:o,onChange:r,onClose:()=>{l(!1)},numberOfOptionsToAlwaysShow:i})]})})}import ox,{useEffect as G4}from"react";import{jsx as yp,jsxs as rx}from"react/jsx-runtime";var nx=({updateData:e,app:o,testId:t})=>{let r=ox.useRef(null),n=ox.useRef(null),i=o.scene.getSelectedElements(o.state),a=!0,l=i.at(0),c=i.reduce((d,m)=>(d!=null&&d!==m.opacity&&(a=!1),d==null||d>m.opacity?m.opacity:d),l?.opacity??null)??o.state.currentItemOpacity;return G4(()=>{if(r.current&&n.current){let d=r.current,m=n.current,p=d.offsetWidth,u=15,f=c/100*(p-u)+u/2;m.style.left=`${f}px`,d.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${c}%, var(--button-bg) ${c}%, var(--button-bg) 100%)`}},[c]),rx("label",{className:"control-label",children:[g("labels.opacity"),rx("div",{className:"range-wrapper",children:[yp("input",{style:{"--color-slider-track":a?void 0:"var(--button-bg)"},ref:r,type:"range",min:"0",max:"100",step:"10",onChange:d=>{e(+d.target.value)},value:c,className:"range-input","data-testid":t}),yp("div",{className:"value-bubble",ref:n,children:c!==0?c:null}),yp("div",{className:"zero-label",children:"0"})]})]})};import{Fragment as px,jsx as Q,jsxs as Tt}from"react/jsx-runtime";var mx=.1,pt=(e,o,t,r=!1)=>{let n=Sp($(e,o,{includeBoundTextElement:r}));return e.map(i=>n.get(i.id)||i.id===o.editingTextElement?.id?t(i):i)},vt=function(e,o,t,r,n){let i=o.state.editingTextElement,a=cx(e),l=null;if(i&&(l=t(i)),!l)if(Ee(a,o.state)){let c=o.scene.getSelectedElements(o.state),d=r===!0?c:c.filter(m=>r(m));l=r6(d,t)??(typeof n=="function"?n(!0):n)}else l=typeof n=="function"?n(!1):n;return l},m6=(e,o,t)=>a6(o)||!o.autoResize?o:t.mutateElement(o,{x:e.textAlign==="left"?e.x:e.x+(e.width-o.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-o.height)/2}),kp=(e,o,t,r,n)=>{let i=new Set,a=pt(e,o,l=>{if(wt(l)){let s=r(l);i.add(s);let c=Ve(l,{fontSize:s});return wa(c,t.scene.getContainerElement(l),t.scene),c=m6(l,c,t.scene),c}return l},!0);return $(e,o,{includeBoundTextElement:!0}).forEach(l=>{wt(l)&&i6(l,t.scene)}),{elements:a,appState:{...o,currentItemFontSize:i.size===1?[...i][0]:n??o.currentItemFontSize},captureUpdate:Xe.IMMEDIATELY}},p6=N({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,o,t)=>({...t.currentItemStrokeColor&&{elements:pt(e,o,r=>s6(r.type)?Ve(r,{strokeColor:t.currentItemStrokeColor}):r,!0)},appState:{...o,...t},captureUpdate:t.currentItemStrokeColor?Xe.IMMEDIATELY:Xe.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Tt(px,{children:[Q("h3",{"aria-hidden":"true",children:g("labels.stroke")}),Q(ga,{topPicks:r.props.strokeColorTopPicks??Z4,palette:K4,type:"elementStroke",label:g("labels.stroke"),color:vt(e,r,n=>n.strokeColor,!0,n=>n?null:o.currentItemStrokeColor),onChange:n=>t({currentItemStrokeColor:n}),elements:e,appState:o,updateData:t})]})}),u6=N({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,o,t,r)=>{if(!t.currentItemBackgroundColor)return{appState:{...o,...t},captureUpdate:Xe.EVENTUALLY};let n,i=r.scene.getSelectedElements(o);if(!o6(t.currentItemBackgroundColor)&&i.every(l=>lx(l)&&n6(l.points))){let l=Sp(i);n=e.map(s=>l.has(s.id)&&lx(s)?Ve(s,{backgroundColor:t.currentItemBackgroundColor,...d6(s,!0)}):s)}else n=pt(e,o,l=>Ve(l,{backgroundColor:t.currentItemBackgroundColor}));return{elements:n,appState:{...o,...t},captureUpdate:Xe.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Tt(px,{children:[Q("h3",{"aria-hidden":"true",children:g("labels.background")}),Q(ga,{topPicks:r.props.backgroundColorTopPicks??X4,palette:V4,type:"elementBackground",label:g("labels.background"),color:vt(e,r,n=>n.backgroundColor,!0,n=>n?null:o.currentItemBackgroundColor),onChange:n=>t({currentItemBackgroundColor:n}),elements:e,appState:o,updateData:t})]})}),h6=N({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,o,t,r)=>(re("element","changeFillStyle",`${t} (${r.device.editor.isMobile?"mobile":"desktop"})`),{elements:pt(e,o,n=>Ve(n,{fillStyle:t})),appState:{...o,currentItemFillStyle:t},captureUpdate:Xe.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=$(e,o),i=n.length>0&&n.every(a=>a.fillStyle==="zigzag");return Tt("fieldset",{children:[Q("legend",{children:g("labels.fill")}),Q("div",{className:"buttonList",children:Q(Ot,{type:"button",options:[{value:"hachure",text:`${i?g("labels.zigzag"):g("labels.hachure")} (${e6("Alt-Click")})`,icon:i?o0:r0,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:g("labels.crossHatch"),icon:n0,testId:"fill-cross-hatch"},{value:"solid",text:g("labels.solid"),icon:i0,testId:"fill-solid"}],value:vt(e,r,a=>a.fillStyle,a=>a.hasOwnProperty("fillStyle"),a=>a?null:o.currentItemFillStyle),onClick:(a,l)=>{let s=l.altKey&&a==="hachure"&&n.every(c=>c.fillStyle==="hachure")?"zigzag":a;t(s)}})})]})}}),g6=N({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,o,t)=>({elements:pt(e,o,r=>Ve(r,{strokeWidth:t})),appState:{...o,currentItemStrokeWidth:t},captureUpdate:Xe.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Tt("fieldset",{children:[Q("legend",{children:g("labels.strokeWidth")}),Q("div",{className:"buttonList",children:Q(Ot,{group:"stroke-width",options:[{value:Tp.thin,text:g("labels.thin"),icon:Bm,testId:"strokeWidth-thin"},{value:Tp.bold,text:g("labels.bold"),icon:a0,testId:"strokeWidth-bold"},{value:Tp.extraBold,text:g("labels.extraBold"),icon:l0,testId:"strokeWidth-extraBold"}],value:vt(e,r,n=>n.strokeWidth,n=>n.hasOwnProperty("strokeWidth"),n=>n?null:o.currentItemStrokeWidth),onChange:n=>t(n)})})]})}),f6=N({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,o,t)=>({elements:pt(e,o,r=>Ve(r,{seed:J4(),roughness:t})),appState:{...o,currentItemRoughness:t},captureUpdate:Xe.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Tt("fieldset",{children:[Q("legend",{children:g("labels.sloppiness")}),Q("div",{className:"buttonList",children:Q(Ot,{group:"sloppiness",options:[{value:0,text:g("labels.architect"),icon:d0},{value:1,text:g("labels.artist"),icon:m0},{value:2,text:g("labels.cartoonist"),icon:p0}],value:vt(e,r,n=>n.roughness,n=>n.hasOwnProperty("roughness"),n=>n?null:o.currentItemRoughness),onChange:n=>t(n)})})]})}),W$=N({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,o,t)=>({elements:pt(e,o,r=>Ve(r,{strokeStyle:t})),appState:{...o,currentItemStrokeStyle:t},captureUpdate:Xe.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Tt("fieldset",{children:[Q("legend",{children:g("labels.strokeStyle")}),Q("div",{className:"buttonList",children:Q(Ot,{group:"strokeStyle",options:[{value:"solid",text:g("labels.strokeStyle_solid"),icon:Bm},{value:"dashed",text:g("labels.strokeStyle_dashed"),icon:s0},{value:"dotted",text:g("labels.strokeStyle_dotted"),icon:c0}],value:vt(e,r,n=>n.strokeStyle,n=>n.hasOwnProperty("strokeStyle"),n=>n?null:o.currentItemStrokeStyle),onChange:n=>t(n)})})]})}),b6=N({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,o,t)=>({elements:pt(e,o,r=>Ve(r,{opacity:t}),!0),appState:{...o,currentItemOpacity:t},captureUpdate:Xe.IMMEDIATELY}),PanelComponent:({app:e,updateData:o})=>Q(nx,{updateData:o,app:e,testId:"opacity"})}),x6=N({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,o,t,r)=>kp(e,o,r,()=>t,t),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Tt("fieldset",{children:[Q("legend",{children:g("labels.fontSize")}),Q("div",{className:"buttonList",children:Q(Ot,{group:"font-size",options:[{value:16,text:g("labels.small"),icon:k0,testId:"fontSize-small"},{value:20,text:g("labels.medium"),icon:M0,testId:"fontSize-medium"},{value:28,text:g("labels.large"),icon:L0,testId:"fontSize-large"},{value:36,text:g("labels.veryLarge"),icon:P0,testId:"fontSize-veryLarge"}],value:vt(e,r,n=>{if(wt(n))return n.fontSize;let i=nr(n,r.scene.getNonDeletedElementsMap());return i?i.fontSize:null},n=>wt(n)||nr(n,r.scene.getNonDeletedElementsMap())!==null,n=>n?null:o.currentItemFontSize||j4),onChange:n=>t(n)})})]})}),Mp=N({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:Hr,trackEvent:!1,perform:(e,o,t,r)=>kp(e,o,r,n=>Math.round(1/(1+mx)*n.fontSize)),keyTest:e=>e[Zn.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Zn.CHEVRON_LEFT||e.key===Zn.COMMA)}),Lp=N({name:"increaseFontSize",label:"labels.increaseFontSize",icon:Hr,trackEvent:!1,perform:(e,o,t,r)=>kp(e,o,r,n=>Math.round(n.fontSize*(1+mx))),keyTest:e=>e[Zn.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Zn.CHEVRON_RIGHT||e.key===Zn.PERIOD)}),E6=N({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,o,t,r)=>{let{cachedElements:n,resetAll:i,resetContainers:a,...l}=t;if(i)return{elements:pt(e,o,b=>{let x=n?.get(b.id);return x?Ve(b,{...x}):b},!0),appState:{...o,...l},captureUpdate:Xe.NEVER};let{currentItemFontFamily:s,currentHoveredFontFamily:c}=t,d=Xe.EVENTUALLY,m,p=!1;if(s)m=s,d=Xe.IMMEDIATELY;else if(c){m=c,d=Xe.EVENTUALLY;let f=$(e,o,{includeBoundTextElement:!0}).filter(b=>wt(b));if(f.length>200)p=!0;else{let b=0,x=0;for(;b<f.length&&x<5e3;){let w=f[b];x+=w?.originalText.length||0,b++}x>5e3&&(p=!0)}}let u={appState:{...o,...l},captureUpdate:d};if(m&&!p){let f=new Map,b=new Set,x=!1,w=Array.from(Zo.loadedFontsCache.values()),E=Object.entries(q4).find(([C,S])=>S===m)?.[0];c&&E&&w.some(C=>C.startsWith(E))&&(x=!0),Object.assign(u,{elements:pt(e,o,C=>{if(wt(C)&&(C.fontFamily!==m||s)){let S=Ve(C,{fontFamily:m,lineHeight:t6(m)}),L=n?.get(C.containerId||"")||{},k=r.scene.getContainerElement(C);return a&&k&&L&&r.scene.mutateElement(k,{...L}),x||(b=new Set([...b,...Array.from(S.originalText)])),f.set(S,k),S}return C},!0)});let y=`10px ${Q4({fontFamily:m})}`,v=Array.from(b.values()).join();if(x||window.document.fonts.check(y,v))for(let[C,S]of f)wa(C,S,r.scene);else window.document.fonts.load(y,v).then(C=>{for(let[S,L]of f){let k=r.scene.getElement(S.id),A=L?r.scene.getElement(L.id):null;k&&wa(k,A,r.scene)}r.fonts.onLoaded(C)})}return u},PanelComponent:({elements:e,appState:o,app:t,updateData:r})=>{let n=vp(new Map),i=vp(null),[a,l]=W4({}),s=vp(!0),c=Y4(()=>{let d=(m,p)=>vt(m,t,u=>{if(wt(u))return u.fontFamily;let f=nr(u,p);return f?f.fontFamily:null},u=>wt(u)||nr(u,p)!==null,u=>u?null:o.currentItemFontFamily||$4);return a.openPopup==="fontFamily"&&o.openPopup==="fontFamily"?d(Array.from(n.current?.values()??[]),n.current):!a.openPopup&&o.openPopup!=="fontFamily"?d(e,t.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,o,e,t]);return wp(()=>{i.current=c},[c]),wp(()=>{Object.keys(a).length&&(r(a),l({}))},[a]),wp(()=>(s.current=!1,()=>{s.current=!0}),[]),Tt("fieldset",{children:[Q("legend",{children:g("labels.fontFamily")}),Q(Qb,{isOpened:o.openPopup==="fontFamily",selectedFontFamily:c,hoveredFontFamily:o.currentHoveredFontFamily,onSelect:d=>{l({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:d}),n.current.clear()},onHover:d=>{l({currentHoveredFontFamily:d,cachedElements:new Map(n.current),resetContainers:!0})},onLeave:()=>{l({currentHoveredFontFamily:null,cachedElements:new Map(n.current),resetAll:!0})},onPopupChange:d=>{if(d){n.current.clear();let{editingTextElement:m}=o;if(m?.type==="text"){let p=t.scene.getElement(m.id);n.current.set(m.id,Ve(p||m,{},!0))}else{let p=$(e,o,{includeBoundTextElement:!0});for(let u of p)n.current.set(u.id,Ve(u,{},!0))}l({openPopup:"fontFamily"})}else{let m={openPopup:null,currentHoveredFontFamily:null,cachedElements:new Map(n.current),resetAll:!0};s.current?r({...a,...m}):l(m),n.current.clear()}}})]})}}),y6=N({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,o,t,r)=>({elements:pt(e,o,n=>{if(wt(n)){let i=Ve(n,{textAlign:t});return wa(i,r.scene.getContainerElement(n),r.scene),i}return n},!0),appState:{...o,currentItemTextAlign:t},captureUpdate:Xe.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=r.scene.getNonDeletedElementsMap();return Tt("fieldset",{children:[Q("legend",{children:g("labels.textAlign")}),Q("div",{className:"buttonList",children:Q(Ot,{group:"text-align",options:[{value:"left",text:g("labels.left"),icon:D0,testId:"align-left"},{value:"center",text:g("labels.center"),icon:_0,testId:"align-horizontal-center"},{value:"right",text:g("labels.right"),icon:R0,testId:"align-right"}],value:vt(e,r,i=>{if(wt(i))return i.textAlign;let a=nr(i,n);return a?a.textAlign:null},i=>wt(i)||nr(i,n)!==null,i=>i?null:o.currentItemTextAlign),onChange:i=>t(i)})})]})}}),w6=N({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:pt(e,o,n=>{if(wt(n)){let i=Ve(n,{verticalAlign:t});return wa(i,r.scene.getContainerElement(n),r.scene),i}return n},!0),appState:{...o},captureUpdate:Xe.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Q("fieldset",{children:Q("div",{className:"buttonList",children:Q(Ot,{group:"text-align",options:[{value:Ls.TOP,text:g("labels.alignTop"),icon:Q(N0,{theme:o.theme}),testId:"align-top"},{value:Ls.MIDDLE,text:g("labels.centerVertically"),icon:Q(F0,{theme:o.theme}),testId:"align-middle"},{value:Ls.BOTTOM,text:g("labels.alignBottom"),icon:Q(B0,{theme:o.theme}),testId:"align-bottom"}],value:vt(e,r,n=>{if(wt(n)&&n.containerId)return n.verticalAlign;let i=nr(n,r.scene.getNonDeletedElementsMap());return i?i.verticalAlign:null},n=>wt(n)||nr(n,r.scene.getNonDeletedElementsMap())!==null,n=>n?null:Ls.MIDDLE),onChange:n=>t(n)})})})}),V$=N({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,o,t)=>({elements:pt(e,o,r=>dx(r)?r:Ve(r,{roundness:t==="round"?{type:l6(r.type)?Ps.ADAPTIVE_RADIUS:Ps.PROPORTIONAL_RADIUS}:null})),appState:{...o,currentItemRoundness:t},captureUpdate:Xe.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r,renderAction:n})=>{let a=_l(cx(e),o).some(l=>l.roundness?.type===Ps.LEGACY);return Tt("fieldset",{children:[Q("legend",{children:g("labels.edges")}),Tt("div",{className:"buttonList",children:[Q(Ot,{group:"edges",options:[{value:"sharp",text:g("labels.sharp"),icon:u0},{value:"round",text:g("labels.round"),icon:h0}],value:vt(e,r,l=>a?null:l.roundness?"round":"sharp",l=>!As(l)&&l.hasOwnProperty("roundness"),l=>l?null:o.currentItemRoundness),onChange:l=>t(l)}),n("togglePolygon")]})]})}}),sx=e=>[{value:null,text:g("labels.arrowhead_none"),keyBinding:"q",icon:g0},{value:"arrow",text:g("labels.arrowhead_arrow"),keyBinding:"w",icon:Q(f0,{flip:e})},{value:"triangle",text:g("labels.arrowhead_triangle"),icon:Q(y0,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:g("labels.arrowhead_triangle_outline"),icon:Q(w0,{flip:e}),keyBinding:"r"},{value:"circle",text:g("labels.arrowhead_circle"),keyBinding:"a",icon:Q(b0,{flip:e})},{value:"circle_outline",text:g("labels.arrowhead_circle_outline"),keyBinding:"s",icon:Q(x0,{flip:e})},{value:"diamond",text:g("labels.arrowhead_diamond"),icon:Q(v0,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:g("labels.arrowhead_diamond_outline"),icon:Q(T0,{flip:e}),keyBinding:"f"},{value:"bar",text:g("labels.arrowhead_bar"),keyBinding:"z",icon:Q(E0,{flip:e})},{value:"crowfoot_one",text:g("labels.arrowhead_crowfoot_one"),icon:Q(C0,{flip:e}),keyBinding:"x"},{value:"crowfoot_many",text:g("labels.arrowhead_crowfoot_many"),icon:Q(I0,{flip:e}),keyBinding:"c"},{value:"crowfoot_one_or_many",text:g("labels.arrowhead_crowfoot_one_or_many"),icon:Q(S0,{flip:e}),keyBinding:"v"}],X$=N({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,o,t)=>({elements:pt(e,o,r=>{if(Cp(r)){let{position:n,type:i}=t;if(n==="start")return Ve(r,{startArrowhead:i});if(n==="end")return Ve(r,{endArrowhead:i})}return r}),appState:{...o,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:Xe.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=Po().rtl;return Tt("fieldset",{children:[Q("legend",{children:g("labels.arrowheads")}),Tt("div",{className:"iconSelectList buttonList",children:[Q(Ep,{label:"arrowhead_start",options:sx(!n),value:vt(e,r,i=>Cp(i)&&gn(i.type)?i.startArrowhead:o.currentItemStartArrowhead,!0,o.currentItemStartArrowhead),onChange:i=>t({position:"start",type:i}),numberOfOptionsToAlwaysShow:4}),Q(Ep,{label:"arrowhead_end",group:"arrowheads",options:sx(!!n),value:vt(e,r,i=>Cp(i)&&gn(i.type)?i.endArrowhead:o.currentItemEndArrowhead,!0,o.currentItemEndArrowhead),onChange:i=>t({position:"end",type:i}),numberOfOptionsToAlwaysShow:4})]})]})}}),K$=N({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,o,t,r)=>{let n=pt(e,o,l=>{if(!As(l))return l;let s=Ve(l,{roundness:t===Ro.round?{type:Ps.PROPORTIONAL_RADIUS}:null,elbowed:t===Ro.elbow,points:t===Ro.elbow||l.elbowed?[l.points[0],l.points[l.points.length-1]]:l.points});if(dx(s)){s.fixedSegments=null;let c=r.scene.getNonDeletedElementsMap();r.dismissLinearEditor();let d=Ip.getPointAtIndexGlobalCoordinates(s,0,c),m=Ip.getPointAtIndexGlobalCoordinates(s,-1,c),p=s.startBinding&&c.get(s.startBinding.elementId),u=s.endBinding&&c.get(s.endBinding.elementId),f=p&&s.startBinding?{...s.startBinding,...ax(s,p,"start",c)}:null,b=u&&s.endBinding?{...s.endBinding,...ax(s,u,"end",c)}:null;s={...s,startBinding:f,endBinding:b,...c6(s,c,{points:[d,m].map(x=>U4(x[0]-s.x,x[1]-s.y)),startBinding:f,endBinding:b,fixedSegments:null})}}else{let c=r.scene.getNonDeletedElementsMap();if(s.startBinding){let d=c.get(s.startBinding.elementId);d&&ix(s,d,"start",r.scene)}if(s.endBinding){let d=c.get(s.endBinding.elementId);d&&ix(s,d,"end",r.scene)}}return s}),i={...o,currentItemArrowType:t},a=o.selectedLinearElement?.elementId;if(a){let l=n.find(s=>s.id===a);l&&(i.selectedLinearElement=new Ip(l,Sp(e)))}return{elements:n,appState:i,captureUpdate:Xe.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Tt("fieldset",{children:[Q("legend",{children:g("labels.arrowtypes")}),Q("div",{className:"buttonList",children:Q(Ot,{group:"arrowtypes",options:[{value:Ro.sharp,text:g("labels.arrowtype_sharp"),icon:os,testId:"sharp-arrow"},{value:Ro.round,text:g("labels.arrowtype_round"),icon:ns,testId:"round-arrow"},{value:Ro.elbow,text:g("labels.arrowtype_elbowed"),icon:rs,testId:"elbow-arrow"}],value:vt(e,r,n=>As(n)?n.elbowed?Ro.elbow:n.roundness?Ro.round:Ro.sharp:null,n=>As(n),n=>n?null:o.currentItemArrowType),onChange:n=>t(n)})})]})});import{clamp as Rp,roundToStep as M6}from"@excalidraw/math";import{DEFAULT_CANVAS_BACKGROUND_PICKS as L6,CURSOR_TYPE as bx,MAX_ZOOM as xx,MIN_ZOOM as Ex,THEME as va,ZOOM_STEP as Np,getShortcutKey as yx,updateActiveTool as jn,CODES as xo,KEYS as Bo}from"@excalidraw/common";import{getNonDeletedElements as P6}from"@excalidraw/element";import{getCommonBounds as A6}from"@excalidraw/element";import{CaptureUpdateAction as Eo}from"@excalidraw/element";import{useEffect as v6}from"react";import{jsx as I6}from"react/jsx-runtime";var $n=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let o=document.createElement("div");return document.body.appendChild(o),o.classList.add("excalidraw-tooltip"),o},Pp=(e,o,t="bottom")=>{let r=e.getBoundingClientRect(),n=window.innerWidth,i=window.innerHeight,a=5,l=o.left+o.width/2-r.width/2;l<0?l=a:l+r.width>=n&&(l=n-r.width-a);let s;t==="bottom"?(s=o.top+o.height+a,s+r.height>=i&&(s=o.top-r.height-a)):(s=o.top-r.height-a,s<0&&(s=o.top+o.height+a)),Object.assign(e.style,{top:`${s}px`,left:`${l}px`})},T6=(e,o,t,r)=>{o.classList.add("excalidraw-tooltip--visible"),o.style.minWidth=r?"50ch":"10ch",o.style.maxWidth=r?"50ch":"15ch",o.textContent=t;let n=e.getBoundingClientRect();Pp(o,n)},it=({children:e,label:o,long:t=!1,style:r,disabled:n})=>(v6(()=>()=>$n().classList.remove("excalidraw-tooltip--visible"),[]),n?null:I6("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>T6(i.currentTarget,$n(),o,t),onPointerLeave:()=>$n().classList.remove("excalidraw-tooltip--visible"),style:r,children:e}));import Ds from"open-color";import{CURSOR_TYPE as Ap,MIME_TYPES as Dp,THEME as hx}from"@excalidraw/common";var gx='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',C6='<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"/>',fx='<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"/>',S6=`data:${Dp.svg},${encodeURIComponent(`${gx}${fx}</svg>`)}`,k6=`data:${Dp.svg},${encodeURIComponent(`${gx}${C6}${fx}</svg>`)}`,Ht=e=>{e&&(e.style.cursor="")},xe=(e,o)=>{e&&(e.style.cursor=o)},bo,ux,_p=(e,o)=>{let r=()=>{let n=o===hx.DARK;bo=document.createElement("canvas"),bo.theme=o,bo.height=20,bo.width=20;let i=bo.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(bo.width/2,bo.height/2,5,0,2*Math.PI),i.fillStyle=n?Ds.black:Ds.white,i.fill(),i.strokeStyle=n?Ds.white:Ds.black,i.stroke(),ux=bo.toDataURL(Dp.svg)};(!bo||bo.theme!==o)&&r(),xe(e,`url(${ux}) ${20/2} ${20/2}, auto`)},Dt=(e,o)=>{if(e)if(o.activeTool.type==="selection")Ht(e);else if(qt(o))e.style.cursor=Ap.GRAB;else if(Et(o))_p(e,o.theme);else if(o.activeTool.type==="laser"){let t=o.theme===hx.LIGHT?S6:k6;e.style.cursor=`url(${t}), auto`}else["image","custom"].includes(o.activeTool.type)?o.activeTool.type!=="image"&&(e.style.cursor=Ap.AUTO):e.style.cursor=Ap.CROSSHAIR};var No=({viewportX:e,viewportY:o,nextZoom:t},r)=>{let n=e-r.offsetLeft,i=o-r.offsetTop,a=r.zoom.value,l=r.scrollX+(n-n/a),s=r.scrollY+(i-i/a),c=-(n-n/t),d=-(i-i/t);return{scrollX:l+c,scrollY:s+d,zoom:{value:t}}};import{jsx as Bs,jsxs as N6}from"react/jsx-runtime";var D6=N({name:"changeViewBackgroundColor",label:"labels.canvasBackground",trackEvent:!1,predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.changeViewBackgroundColor&&!o.viewModeEnabled,perform:(e,o,t)=>({appState:{...o,...t},captureUpdate:t.viewBackgroundColor?Eo.IMMEDIATELY:Eo.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:r})=>Bs(ga,{palette:null,topPicks:L6,label:g("labels.canvasBackground"),type:"canvasBackground",color:o.viewBackgroundColor,onChange:n=>t({viewBackgroundColor:n}),"data-testid":"canvas-background-picker",elements:e,appState:o,updateData:t})}),_s=N({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:ym,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...No({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:uo(o.zoom.value+Np)},o),userToFollow:null},captureUpdate:Eo.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>Bs(W,{type:"button",className:"zoom-in-button zoom-button",icon:ym,title:`${g("buttons.zoomIn")} \u2014 ${yx("CtrlOrCmd++")}`,"aria-label":g("buttons.zoomIn"),disabled:o.zoom.value>=xx,onClick:()=>{e(null)}}),keyTest:e=>(e.code===xo.EQUAL||e.code===xo.NUM_ADD)&&(e[Bo.CTRL_OR_CMD]||e.shiftKey)}),Rs=N({name:"zoomOut",label:"buttons.zoomOut",icon:wm,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...No({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:uo(o.zoom.value-Np)},o),userToFollow:null},captureUpdate:Eo.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>Bs(W,{type:"button",className:"zoom-out-button zoom-button",icon:wm,title:`${g("buttons.zoomOut")} \u2014 ${yx("CtrlOrCmd+-")}`,"aria-label":g("buttons.zoomOut"),disabled:o.zoom.value<=Ex,onClick:()=>{e(null)}}),keyTest:e=>(e.code===xo.MINUS||e.code===xo.NUM_SUBTRACT)&&(e[Bo.CTRL_OR_CMD]||e.shiftKey)}),Ns=N({name:"resetZoom",label:"buttons.resetZoom",icon:F1,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...No({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:uo(1)},o),userToFollow:null},captureUpdate:Eo.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>Bs(it,{label:g("buttons.resetZoom"),style:{height:"100%"},children:N6(W,{type:"button",className:"reset-zoom-button zoom-button",title:g("buttons.resetZoom"),"aria-label":g("buttons.resetZoom"),onClick:()=>{e(null)},children:[(o.zoom.value*100).toFixed(0),"%"]})}),keyTest:e=>(e.code===xo.ZERO||e.code===xo.NUM_ZERO)&&(e[Bo.CTRL_OR_CMD]||e.shiftKey)}),_6=(e,o,t=1)=>{let[r,n,i,a]=e,l=i-r,s=o.width/l,c=a-n,d=o.height/c,p=Math.min(s,d)*Rp(t,.1,1);return Math.min(p,1)},wx=({bounds:e,appState:o,canvasOffsets:t,fitToViewport:r=!1,viewportZoomFactor:n=1,minZoom:i=-1/0,maxZoom:a=1/0})=>{n=Rp(n,Ex,xx);let[l,s,c,d]=e,m=(l+c)/2,p=(s+d)/2,u=t?.left??0,f=t?.top??0,b=t?.right??0,x=t?.bottom??0,w=o.width-u-b,E=o.height-f-x,y;if(r){let S=c-l,L=d-s;y=Math.min(w/S,E/L)*n}else y=_6(e,{width:w,height:E},n);let v=uo(Rp(M6(y,Np,"floor"),i,a)),C=$f({scenePoint:{x:m,y:p},viewportDimensions:{width:o.width,height:o.height},offsets:t,zoom:{value:v}});return{appState:{...o,scrollX:C.scrollX,scrollY:C.scrollY,zoom:{value:v}},captureUpdate:Eo.EVENTUALLY}},Ta=({canvasOffsets:e,targetElements:o,appState:t,fitToViewport:r,viewportZoomFactor:n,minZoom:i,maxZoom:a})=>{let l=A6(P6(o));return wx({canvasOffsets:e,bounds:l,appState:t,fitToViewport:r,viewportZoomFactor:n,minZoom:i,maxZoom:a})},Mj=N({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:ts,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return Ta({targetElements:n.length?n:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()})},keyTest:e=>e.code===xo.TWO&&e.shiftKey&&!e.altKey&&!e[Bo.CTRL_OR_CMD]}),Lj=N({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:ts,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return Ta({targetElements:n.length?n:e,appState:{...o,userToFollow:null},fitToViewport:!0,canvasOffsets:r.getEditorUIOffsets()})},keyTest:e=>e.code===xo.THREE&&e.shiftKey&&!e.altKey&&!e[Bo.CTRL_OR_CMD]}),R6=N({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:ts,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>Ta({targetElements:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()}),keyTest:e=>e.code===xo.ONE&&e.shiftKey&&!e.altKey&&!e[Bo.CTRL_OR_CMD]}),Vr=N({name:"toggleTheme",label:(e,o)=>o.theme===va.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:e=>e.theme===va.LIGHT?ra:na,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t)=>({appState:{...o,theme:t||(o.theme===va.LIGHT?va.DARK:va.LIGHT)},captureUpdate:Eo.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===xo.D,predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.toggleTheme}),Pj=N({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,o)=>{let t;return Et(o)?t=jn(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):t=jn(o,{type:"eraser",lastActiveToolBeforeEraser:o.activeTool}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:t},captureUpdate:Eo.IMMEDIATELY}},keyTest:e=>e.key===Bo.E}),Aj=N({name:"toggleLassoTool",label:"toolBar.lasso",icon:ta,trackEvent:{category:"toolbar"},perform:(e,o,t,r)=>{let n;return o.activeTool.type!=="lasso"?(n=jn(o,{type:"lasso",fromSelection:!1}),xe(r.interactiveCanvas,bx.CROSSHAIR)):n=jn(o,{type:"selection"}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:Eo.NEVER}}}),vx=N({name:"toggleHandTool",label:"toolBar.hand",trackEvent:{category:"toolbar"},icon:es,viewMode:!1,perform:(e,o,t,r)=>{let n;return qt(o)?n=jn(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(n=jn(o,{type:"hand",lastActiveToolBeforeEraser:o.activeTool}),xe(r.interactiveCanvas,bx.GRAB)),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:Eo.IMMEDIATELY}},keyTest:e=>!e.altKey&&!e[Bo.CTRL_OR_CMD]&&e.key===Bo.H});import{updateActiveTool as Tx}from"@excalidraw/common";import{CaptureUpdateAction as B6}from"@excalidraw/element";var F6=N({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,o,t,r)=>{let n=Tx(o,{type:"embeddable"});return Dt(r.canvas,{...o,activeTool:n}),{elements:e,appState:{...o,activeTool:Tx(o,{type:"embeddable"})},captureUpdate:B6.EVENTUALLY}}});import{pointFrom as O6}from"@excalidraw/math";import{maybeBindLinearElement as z6,bindOrUnbindLinearElement as Ix,isBindingEnabled as H6}from"@excalidraw/element/binding";import{isValidPolygon as Cx,LinearElementEditor as Ia}from"@excalidraw/element";import{isBindingElement as Fs,isFreeDrawElement as Sx,isLinearElement as kx,isLineElement as Os}from"@excalidraw/element";import{KEYS as Bp,arrayToMap as Fp,tupleToCoors as G6,updateActiveTool as Mx}from"@excalidraw/common";import{isPathALoop as U6}from"@excalidraw/element";import{isInvisiblySmallElement as Op}from"@excalidraw/element";import{CaptureUpdateAction as zp}from"@excalidraw/element";import{jsx as Y6}from"react/jsx-runtime";var It=N({name:"finalize",label:"",trackEvent:!1,perform:(e,o,t,r)=>{let{interactiveCanvas:n,focusContainer:i,scene:a}=r,{event:l,sceneCoords:s}=t??{},c=a.getNonDeletedElementsMap();if(l&&o.selectedLinearElement){let u=Ia.handlePointerUp(l,o.selectedLinearElement,o,r.scene),{startBindingElement:f,endBindingElement:b}=u,x=r.scene.getElement(u.elementId);if(Fs(x)&&Ix(x,f,b,r.scene),u!==o.selectedLinearElement){let w=e;return x&&Op(x)&&(w=w.filter(E=>E.id!==x.id)),{elements:w,appState:{selectedLinearElement:{...u,selectedPointsIndices:null},suggestedBindings:[]},captureUpdate:zp.IMMEDIATELY}}}if(o.selectedLinearElement?.isEditing){let{elementId:u,startBindingElement:f,endBindingElement:b}=o.selectedLinearElement,x=Ia.getElement(u,c);if(x)return Fs(x)&&Ix(x,f,b,a),Os(x)&&!Cx(x.points)&&a.mutateElement(x,{polygon:!1}),{elements:x.points.length<2||Op(x)?e.filter(w=>w.id!==x.id):void 0,appState:{...o,cursorButton:"up",selectedLinearElement:new Ia(x,Fp(c),!1)},captureUpdate:zp.IMMEDIATELY}}let d=e;window.document.activeElement instanceof HTMLElement&&i();let m=null;if(o.multiElement)m=o.multiElement;else if(o.newElement?.type==="freedraw"||Fs(o.newElement))m=o.newElement;else if(Object.keys(o.selectedElementIds).length===1){let u=c.get(Object.keys(o.selectedElementIds)[0]);u&&(m=u)}if(m){if(o.multiElement&&m.type!=="freedraw"){let{points:u,lastCommittedPoint:f}=m;(!f||u[u.length-1]!==f)&&a.mutateElement(m,{points:m.points.slice(0,-1)})}if(m&&Op(m)&&(d=d.filter(u=>u.id!==m.id)),kx(m)||Sx(m)){let u=U6(m.points,o.zoom.value);if(u&&(Os(m)||Sx(m))){let f=m.points,b=f[0],x=f.map((w,E)=>E===f.length-1?O6(b[0],b[1]):w);Os(m)?a.mutateElement(m,{points:x,polygon:!0}):a.mutateElement(m,{points:x})}if(Os(m)&&!Cx(m.points)&&a.mutateElement(m,{polygon:!1}),Fs(m)&&!u&&m.points.length>1&&H6(o)){let f=s??G6(Ia.getPointAtIndexGlobalCoordinates(m,-1,Fp(e)));z6(m,o,f,a)}}}(!o.activeTool.locked&&o.activeTool.type!=="freedraw"||!m)&&Ht(n);let p;return o.activeTool.type==="eraser"?p=Mx(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):p=Mx(o,{type:"selection"}),{elements:d,appState:{...o,cursorButton:"up",activeTool:(o.activeTool.locked||o.activeTool.type==="freedraw")&&m?o.activeTool:p,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:m&&!o.activeTool.locked&&o.activeTool.type!=="freedraw"?{...o.selectedElementIds,[m.id]:!0}:o.selectedElementIds,selectedLinearElement:m&&kx(m)?new Ia(m,Fp(d)):o.selectedLinearElement},captureUpdate:zp.IMMEDIATELY}},keyTest:(e,o)=>e.key===Bp.ESCAPE&&(o.selectedLinearElement?.isEditing||!o.newElement&&o.multiElement===null)||(e.key===Bp.ESCAPE||e.key===Bp.ENTER)&&o.multiElement!==null,PanelComponent:({appState:e,updateData:o,data:t})=>Y6(W,{type:"button",icon:$1,title:g("buttons.done"),"aria-label":g("buttons.done"),onClick:o,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import{KEYS as Vs,DEFAULT_EXPORT_PADDING as Lk,EXPORT_SCALES as Pk,THEME as Up}from"@excalidraw/common";import{getNonDeletedElements as Ak}from"@excalidraw/element";import{CaptureUpdateAction as ro}from"@excalidraw/element";import W6 from"clsx";import{jsx as Lx,jsxs as V6}from"react/jsx-runtime";var Ca=({children:e,checked:o,onChange:t,className:r})=>V6("div",{className:W6("Checkbox",r,{"is-checked":o}),onClick:n=>{t(!o,n),n.currentTarget.querySelector(".Checkbox-box").focus()},children:[Lx("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":o,children:Y1}),Lx("div",{className:"Checkbox-label",children:e})]});import{THEME as Sa}from"@excalidraw/common";import{jsx as ka}from"react/jsx-runtime";var Ax=e=>{let o=e.title||(e.value===Sa.DARK?g("buttons.lightMode"):g("buttons.darkMode"));return ka(W,{type:"icon",icon:e.value===Sa.LIGHT?Px.MOON:Px.SUN,title:o,"aria-label":o,onClick:()=>e.onChange(e.value===Sa.DARK?Sa.LIGHT:Sa.DARK),"data-testid":"toggle-dark-mode"})},Px={SUN:ka("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:ka("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:ka("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:ka("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"})})};import{useState as X6}from"react";import{focusNearestParent as K6,KEYS as Z6}from"@excalidraw/common";import{jsx as Dx,jsxs as $6}from"react/jsx-runtime";var _x=e=>{let{id:o}=ze(),[t,r]=X6(e.value),n=a=>{e.ignoreFocus||K6(a.target);let l=a.target.value;l!==e.value&&e.onChange(l)},i=a=>{if(a.key===Z6.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return $6("div",{className:"ProjectName",children:[Dx("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),Dx("input",{type:"text",className:"TextInput",onBlur:n,onKeyDown:i,id:`${o}-filename`,value:t,onChange:a=>r(a.target.value)})]})};import{DEFAULT_EXPORT_PADDING as yk,DEFAULT_FILENAME as wk,IMAGE_MIME_TYPES as Zx,isFirefox as vk,MIME_TYPES as Tk,cloneJSON as Ik,SVG_DOCUMENT_PREAMBLE as Ck}from"@excalidraw/common";import{getNonDeletedElements as Sk}from"@excalidraw/element";import{isFrameLikeElement as kk}from"@excalidraw/element";import{getElementsOverlappingFrame as Mk}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as ak,EXPORT_DATA_TYPES as Pa,MIME_TYPES as to,arrayToMap as lk,isMemberOf as sk,isPromiseLike as ck}from"@excalidraw/common";import{mutateElement as dk}from"@excalidraw/element";import{deepCopyElement as mk}from"@excalidraw/element";import{isFrameLikeElement as pk,isInitializedImageElement as uk}from"@excalidraw/element";import{getContainingFrame as Wx}from"@excalidraw/element";import{pointFrom as ir}from"@excalidraw/math";import{COLOR_PALETTE as Nx,DEFAULT_CHART_COLOR_INDEX as j6,getAllColorsSpecificShade as q6,DEFAULT_FONT_FAMILY as J6,DEFAULT_FONT_SIZE as Bx,VERTICAL_ALIGN as Q6,randomId as Fx,isDevEnv as Ox}from"@excalidraw/common";import{newTextElement as zs,newLinearElement as La,newElement as Gp}from"@excalidraw/element";var eo=32,we=12,ar=256,zx=50,Xr="NOT_SPREADSHEET",qn="VALID_SPREADSHEET",Ma=e=>{let o=/^([-+]?)[$€£¥₩]?([-+]?)([\d.,]+)[%]?$/.exec(e);return o?parseFloat(`${(o[1]||o[2])+o[3]}`.replace(/,/g,"")):null},Hp=(e,o)=>e.slice(1).every(t=>Ma(t[o])!==null),Rx=e=>{let o=e[0].length;if(o>2)return{type:Xr,reason:"More than 2 columns"};if(o===1){if(!Hp(e,0))return{type:Xr,reason:"Value is not numeric"};let s=Ma(e[0][0])===null,c=(s?e.slice(1):e).map(d=>Ma(d[0]));return c.length<2?{type:Xr,reason:"Less than two rows"}:{type:qn,spreadsheet:{title:s?e[0][0]:null,labels:null,values:c}}}let t=Hp(e,0),r=Hp(e,1);if(!t&&!r)return{type:Xr,reason:"Value is not numeric"};let[n,i]=r?[0,1]:[1,0],a=Ma(e[0][i])===null,l=a?e.slice(1):e;return l.length<2?{type:Xr,reason:"Less than 2 rows"}:{type:qn,spreadsheet:{title:a?e[0][i]:null,labels:l.map(s=>s[n]),values:l.map(s=>Ma(s[i]))}}},ek=e=>{let o=[];for(let t=0;t<e[0].length;t++){let r=[];for(let n=0;n<e.length;n++)r.push(e[n][t]);o.push(r)}return o},Hx=e=>{let o=e.trim().split(`
3
3
  `).map(i=>i.trim().split(" "));if(o.length&&o[0].length!==2&&(o=e.trim().split(`
4
- `).map(i=>i.trim().split(","))),o.length===0)return{type:li,reason:"No values"};let t=o[0].length;if(!o.every(i=>i.length===t))return{type:li,reason:"All rows don't have same number of columns"};let n=d2(o);if(n.type!==ha){let i=d2(X4(o));if(i.type===ha)return i}return n},xd=_f(Sf),Ao={fillStyle:"hachure",fontFamily:Fr,fontSize:Er,opacity:100,roughness:1,strokeColor:bo.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:Xt.MIDDLE,locked:!1},u2=e=>{let o=($o+Be)*e.values.length+Be,t=fn+Be*2;return{chartWidth:o,chartHeight:t}},$4=(e,o,t,r,n)=>e.labels?.map((i,a)=>Ft({groupIds:[r],backgroundColor:n,...Ao,text:i.length>8?`${i.slice(0,5)}...`:i,x:o+a*($o+Be)+Be*2,y:t+Be/2,width:$o,angle:5.87,fontSize:16,textAlign:"center",verticalAlign:"top"}))||[],j4=(e,o,t,r,n)=>{let i=Ft({groupIds:[r],backgroundColor:n,...Ao,x:o-Be,y:t-Be,text:"0",textAlign:"right"}),a=Ft({groupIds:[r],backgroundColor:n,...Ao,x:o-Be,y:t-fn-i.height/2,text:Math.max(...e.values).toLocaleString(),textAlign:"right"});return[i,a]},q4=(e,o,t,r,n)=>{let{chartWidth:i,chartHeight:a}=u2(e),l=Co({backgroundColor:n,groupIds:[r],...Ao,type:"line",x:o,y:t,width:i,points:[L(0,0),L(i,0)]}),s=Co({backgroundColor:n,groupIds:[r],...Ao,type:"line",x:o,y:t,height:a,points:[L(0,0),L(0,-a)]}),c=Co({backgroundColor:n,groupIds:[r],...Ao,type:"line",x:o,y:t-fn-Be,strokeStyle:"dotted",width:i,opacity:m2,points:[L(0,0),L(i,0)]});return[l,s,c]},h2=(e,o,t,r,n,i)=>{let{chartWidth:a,chartHeight:l}=u2(e),s=e.title?Ft({backgroundColor:n,groupIds:[r],...Ao,text:e.title,x:o+a/2,y:t-fn-Be*2-Er,roundness:null,textAlign:"center"}):null,c=i?qt({backgroundColor:n,groupIds:[r],...Ao,type:"rectangle",x:o,y:t-l,width:a,height:l,strokeColor:bo.black,fillStyle:"solid",opacity:6}):null;return[...c?[c]:[],...s?[s]:[],...$4(e,o,t,r,n),...j4(e,o,t,r,n),...q4(e,o,t,r,n)]},J4=(e,o,t)=>{let r=Math.max(...e.values),n=mo(),i=xd[Math.floor(Math.random()*xd.length)];return[...e.values.map((l,s)=>{let c=l/r*fn;return qt({backgroundColor:i,groupIds:[n],...Ao,type:"rectangle",x:o+s*($o+Be)+Be,y:t-c-Be,width:$o,height:c})}),...h2(e,o,t,n,i,ft())]},Q4=(e,o,t)=>{let r=Math.max(...e.values),n=mo(),i=xd[Math.floor(Math.random()*xd.length)],a=0,l=[];for(let b of e.values){let x=a*($o+Be),E=-(b/r)*fn;l.push([x,E]),a++}let s=Math.max(...l.map(b=>b[0])),c=Math.max(...l.map(b=>b[1])),m=Math.min(...l.map(b=>b[0])),d=Math.min(...l.map(b=>b[1])),p=Co({backgroundColor:i,groupIds:[n],...Ao,type:"line",x:o+Be+$o/2,y:t-Be,height:c-d,width:s-m,strokeWidth:2,points:l}),u=e.values.map((b,x)=>{let E=x*($o+Be)+Be/2,y=-(b/r)*fn+Be/2;return qt({backgroundColor:i,groupIds:[n],...Ao,fillStyle:"solid",strokeWidth:2,type:"ellipse",x:o+E+$o/2,y:t+y-Be*2,width:Be,height:Be})}),f=e.values.map((b,x)=>{let E=x*($o+Be)+Be/2,y=b/r*fn+Be/2+Be;return Co({backgroundColor:i,groupIds:[n],...Ao,type:"line",x:o+E+$o/2+Be/2,y:t-y,height:y,strokeStyle:"dotted",opacity:m2,points:[L(0,0),L(0,y)]})});return[...h2(e,o,t,n,i,ft()),p,...f,...u]},g2=(e,o,t,r)=>e==="line"?Q4(o,t,r):J4(o,t,r);var zB="clipboard"in navigator&&"readText"in navigator.clipboard,Ed="clipboard"in navigator&&"writeText"in navigator.clipboard,bn="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,eT=e=>!!([Hr.excalidraw,Hr.excalidrawClipboard,Hr.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),f2=({types:e,files:o})=>{!e&&!o&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});if(e)for(let[r,n]of Object.entries(e)){if(typeof n!="string"){o=o||[],o.push(n);continue}try{if(t.clipboardData?.setData(r,n),t.clipboardData?.getData(r)!==n)throw new Error(`Failed to set "${r}" as clipboardData item`)}catch(i){throw new Error(i.message)}}if(o){let r=-1;for(let n of o){r++;try{if(t.clipboardData?.items.add(n),t.clipboardData?.files[r]!==n)throw new Error(`Failed to set file "${n.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return t},tT=({elements:e,files:o})=>{let t=j(e),r=new Set(e.filter(l=>ce(l))),n=!1,i=e.reduce((l,s)=>(wr(s)&&(n=!0,o&&o[s.fileId]&&(l[s.fileId]=o[s.fileId])),l),{});n&&!o&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:Hr.excalidrawClipboard,elements:e.map(l=>{if(jn(l,t)&&!r.has(jn(l,t))){let s=Vo(l);return Go(s,t,{frameId:null}),s}return l}),files:o?i:void 0};return JSON.stringify(a)},yd=async(e,o,t)=>{await jo(tT({elements:e,files:o}),t)},oT=e=>{let o=p2(e);return o.type===ha?{spreadsheet:o.spreadsheet}:null};function b2(e){let o=[];for(let t of e.childNodes)if(t.nodeType===3){let r=t.textContent?.trim();r&&o.push({type:"text",value:r})}else if(t instanceof HTMLImageElement){let r=t.getAttribute("src");r&&r.startsWith("http")&&o.push({type:"imageUrl",value:r})}else o=o.concat(b2(t));return o}var rT=e=>{let o=e.clipboardData?.getData(ue.html);if(!o)return null;try{let t=new DOMParser().parseFromString(o,ue.html),r=b2(t.body);if(r.length)return{type:"mixedContent",value:r}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},x2=async()=>{let e={},o;try{o=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 r=await navigator.clipboard?.readText();if(r)return{[ue.text]:r}}}catch(r){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${r.message}). Failling back to navigator.clipboard.read()`);else{if(r.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${r.message}`),e;throw r}}throw t}for(let t of o)for(let r of t.types)if(Vs(Hf,r))try{if(r===ue.text||r===ue.html)e[r]=await(await t.getType(r)).text();else if(fb(r)){let n=await t.getType(r),i=Tb(n,r,void 0);e[r]=i}else throw new Vp(`Unsupported clipboard type: ${r}`)}catch(n){console.warn(n instanceof Vp?n.message:`Cannot retrieve ${r} from clipboardItem: ${n.message}`)}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},nT=async(e,o=!1)=>{try{let t=!o&&e&&rT(e);return t?t.value.every(n=>n.type==="text")?{type:"text",value:e.clipboardData?.getData(ue.text)||t.value.map(n=>n.value).join(`
5
- `).trim()}:t:{type:"text",value:(e.clipboardData?.getData(ue.text)||"").trim()}}catch{return{type:"text",value:""}}},vd=async(e,o=!1)=>{let t=await nT(e,o);if(t.type==="mixedContent")return{mixedContent:t.value};try{let r=!o&&oT(t.value);if(r)return r}catch(r){console.error(r)}try{let r=JSON.parse(t.value),n=r.type===Hr.excalidrawClipboardWithAPI;if(eT(r))return{elements:r.elements,files:r.files,text:o?JSON.stringify(r.elements,null,2):void 0,programmaticAPI:n}}catch{}return{text:t.value}},wd=async e=>{try{await navigator.clipboard.write([new window.ClipboardItem({[ue.png]:e})])}catch(o){if(Wr(e))await navigator.clipboard.write([new window.ClipboardItem({[ue.png]:await e})]);else throw o}},jo=async(e,o)=>{if(Ed)try{await navigator.clipboard.writeText(e||"");return}catch(t){console.error(t)}try{if(o){if(o.clipboardData?.setData(ue.text,e||""),o.clipboardData?.getData(ue.text)!==e)throw new Error("Failed to setData on clipboardEvent");return}}catch(t){console.error(t)}if(!iT(e))throw new Error("Error copying to clipboard.")},iT=e=>{e||(e=" ");let o=document.documentElement.getAttribute("dir")==="rtl",t=document.createElement("textarea");t.style.border="0",t.style.padding="0",t.style.margin="0",t.style.position="absolute",t.style[o?"right":"left"]="-9999px";let r=window.pageYOffset||document.documentElement.scrollTop;t.style.top=`${r}px`,t.style.fontSize="12pt",t.setAttribute("readonly",""),t.value=e,document.body.appendChild(t);let n=!1;try{t.select(),t.setSelectionRange(0,t.value.length),n=document.execCommand("copy")}catch(i){console.error(i)}return t.remove(),n};var si=(e,{selectedElementIds:o},t)=>{e=fe(e);let r=t&&De(e,{selectedElementIds:o}),n=null,i=r?q(e,{selectedElementIds:o},{includeBoundTextElement:!0}):e;return r&&(i.length===1&&ce(i[0])?(n=i[0],i=mc(e,n)):i.length>1&&(i=q(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:n,exportedElements:jt(i)}},ci=async(e,o,t,r,{exportBackground:n,exportPadding:i=Ur,viewBackgroundColor:a,name:l=t.name||e1,fileHandle:s=null,exportingFrame:c=null})=>{if(o.length===0)throw new Error(g("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let d=Zi(o,{exportBackground:n,exportWithDarkMode:t.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:t.exportScale,exportEmbedScene:t.exportEmbedScene&&e==="svg"},r,{exportingFrame:c});if(e==="svg")return Kp(d.then(p=>new Blob([Qf+p.outerHTML],{type:ue.svg})),{description:"Export to SVG",name:l,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[Qa.svg],fileHandle:s});if(e==="clipboard-svg"){let p=await d.then(u=>u.outerHTML);try{await jo(p)}catch{throw new Error(g("errors.copyToSystemClipboardFailed"))}return}}let m=Ic(o,t,r,{exportBackground:n,viewBackgroundColor:a,exportPadding:i,exportingFrame:c});if(e==="png"){let d=Sr(m);return t.exportEmbedScene&&(d=d.then(p=>import("./data/image-TLNQ4QKS.js").then(({encodePngMetadata:u})=>u({blob:p,metadata:xl(o,t,r,"local")})))),Kp(d,{description:"Export to PNG",name:l,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[Qa.png],fileHandle:s})}else if(e==="clipboard")try{let d=Sr(m);await wd(d)}catch(d){throw console.warn(d),d.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):xo&&d.name==="TypeError"?new Error(`${g("alerts.couldNotCopyToClipboard")}
4
+ `).map(i=>i.trim().split(","))),o.length===0)return{type:Xr,reason:"No values"};let t=o[0].length;if(!o.every(i=>i.length===t))return{type:Xr,reason:"All rows don't have same number of columns"};let n=Rx(o);if(n.type!==qn){let i=Rx(ek(o));if(i.type===qn)return i}return n},Hs=q6(j6),Gt={fillStyle:"hachure",fontFamily:J6,fontSize:Bx,opacity:100,roughness:1,strokeColor:Nx.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:Q6.MIDDLE,locked:!1},Gx=e=>{let o=(eo+we)*e.values.length+we,t=ar+we*2;return{chartWidth:o,chartHeight:t}},tk=(e,o,t,r,n)=>e.labels?.map((i,a)=>zs({groupIds:[r],backgroundColor:n,...Gt,text:i.length>8?`${i.slice(0,5)}...`:i,x:o+a*(eo+we)+we*2,y:t+we/2,width:eo,angle:5.87,fontSize:16,textAlign:"center",verticalAlign:"top"}))||[],ok=(e,o,t,r,n)=>{let i=zs({groupIds:[r],backgroundColor:n,...Gt,x:o-we,y:t-we,text:"0",textAlign:"right"}),a=zs({groupIds:[r],backgroundColor:n,...Gt,x:o-we,y:t-ar-i.height/2,text:Math.max(...e.values).toLocaleString(),textAlign:"right"});return[i,a]},rk=(e,o,t,r,n)=>{let{chartWidth:i,chartHeight:a}=Gx(e),l=La({backgroundColor:n,groupIds:[r],...Gt,type:"line",x:o,y:t,width:i,points:[ir(0,0),ir(i,0)]}),s=La({backgroundColor:n,groupIds:[r],...Gt,type:"line",x:o,y:t,height:a,points:[ir(0,0),ir(0,-a)]}),c=La({backgroundColor:n,groupIds:[r],...Gt,type:"line",x:o,y:t-ar-we,strokeStyle:"dotted",width:i,opacity:zx,points:[ir(0,0),ir(i,0)]});return[l,s,c]},Ux=(e,o,t,r,n,i)=>{let{chartWidth:a,chartHeight:l}=Gx(e),s=e.title?zs({backgroundColor:n,groupIds:[r],...Gt,text:e.title,x:o+a/2,y:t-ar-we*2-Bx,roundness:null,textAlign:"center"}):null,c=i?Gp({backgroundColor:n,groupIds:[r],...Gt,type:"rectangle",x:o,y:t-l,width:a,height:l,strokeColor:Nx.black,fillStyle:"solid",opacity:6}):null;return[...c?[c]:[],...s?[s]:[],...tk(e,o,t,r,n),...ok(e,o,t,r,n),...rk(e,o,t,r,n)]},nk=(e,o,t)=>{let r=Math.max(...e.values),n=Fx(),i=Hs[Math.floor(Math.random()*Hs.length)];return[...e.values.map((l,s)=>{let c=l/r*ar;return Gp({backgroundColor:i,groupIds:[n],...Gt,type:"rectangle",x:o+s*(eo+we)+we,y:t-c-we,width:eo,height:c})}),...Ux(e,o,t,n,i,Ox())]},ik=(e,o,t)=>{let r=Math.max(...e.values),n=Fx(),i=Hs[Math.floor(Math.random()*Hs.length)],a=0,l=[];for(let b of e.values){let x=a*(eo+we),w=-(b/r)*ar;l.push([x,w]),a++}let s=Math.max(...l.map(b=>b[0])),c=Math.max(...l.map(b=>b[1])),d=Math.min(...l.map(b=>b[0])),m=Math.min(...l.map(b=>b[1])),p=La({backgroundColor:i,groupIds:[n],...Gt,type:"line",x:o+we+eo/2,y:t-we,height:c-m,width:s-d,strokeWidth:2,points:l}),u=e.values.map((b,x)=>{let w=x*(eo+we)+we/2,E=-(b/r)*ar+we/2;return Gp({backgroundColor:i,groupIds:[n],...Gt,fillStyle:"solid",strokeWidth:2,type:"ellipse",x:o+w+eo/2,y:t+E-we*2,width:we,height:we})}),f=e.values.map((b,x)=>{let w=x*(eo+we)+we/2,E=b/r*ar+we/2+we;return La({backgroundColor:i,groupIds:[n],...Gt,type:"line",x:o+w+eo/2+we/2,y:t-E,height:E,strokeStyle:"dotted",opacity:zx,points:[ir(0,0),ir(0,E)]})});return[...Ux(e,o,t,n,i,Ox()),p,...f,...u]},Yx=(e,o,t,r)=>e==="line"?ik(o,t,r):nk(o,t,r);var Wq="clipboard"in navigator&&"readText"in navigator.clipboard,Gs="clipboard"in navigator&&"writeText"in navigator.clipboard,lr="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,hk=e=>!!([Pa.excalidraw,Pa.excalidrawClipboard,Pa.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),Vx=({types:e,files:o})=>{!e&&!o&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});if(e)for(let[r,n]of Object.entries(e)){if(typeof n!="string"){o=o||[],o.push(n);continue}try{if(t.clipboardData?.setData(r,n),t.clipboardData?.getData(r)!==n)throw new Error(`Failed to set "${r}" as clipboardData item`)}catch(i){throw new Error(i.message)}}if(o){let r=-1;for(let n of o){r++;try{if(t.clipboardData?.items.add(n),t.clipboardData?.files[r]!==n)throw new Error(`Failed to set file "${n.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return t},gk=({elements:e,files:o})=>{let t=lk(e),r=new Set(e.filter(l=>pk(l))),n=!1,i=e.reduce((l,s)=>(uk(s)&&(n=!0,o&&o[s.fileId]&&(l[s.fileId]=o[s.fileId])),l),{});n&&!o&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:Pa.excalidrawClipboard,elements:e.map(l=>{if(Wx(l,t)&&!r.has(Wx(l,t))){let s=mk(l);return dk(s,t,{frameId:null}),s}return l}),files:o?i:void 0};return JSON.stringify(a)},Us=async(e,o,t)=>{await oo(gk({elements:e,files:o}),t)},fk=e=>{let o=Hx(e);return o.type===qn?{spreadsheet:o.spreadsheet}:null};function Xx(e){let o=[];for(let t of e.childNodes)if(t.nodeType===3){let r=t.textContent?.trim();r&&o.push({type:"text",value:r})}else if(t instanceof HTMLImageElement){let r=t.getAttribute("src");r&&r.startsWith("http")&&o.push({type:"imageUrl",value:r})}else o=o.concat(Xx(t));return o}var bk=e=>{let o=e.clipboardData?.getData(to.html);if(!o)return null;try{let t=new DOMParser().parseFromString(o,to.html),r=Xx(t.body);if(r.length)return{type:"mixedContent",value:r}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},Kx=async()=>{let e={},o;try{o=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 r=await navigator.clipboard?.readText();if(r)return{[to.text]:r}}}catch(r){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${r.message}). Failling back to navigator.clipboard.read()`);else{if(r.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${r.message}`),e;throw r}}throw t}for(let t of o)for(let r of t.types)if(sk(ak,r))try{if(r===to.text||r===to.html)e[r]=await(await t.getType(r)).text();else if(p1(r)){let n=await t.getType(r),i=E1(n,r,void 0);e[r]=i}else throw new dm(`Unsupported clipboard type: ${r}`)}catch(n){console.warn(n instanceof dm?n.message:`Cannot retrieve ${r} from clipboardItem: ${n.message}`)}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},xk=async(e,o=!1)=>{try{let t=!o&&e&&bk(e);return t?t.value.every(n=>n.type==="text")?{type:"text",value:e.clipboardData?.getData(to.text)||t.value.map(n=>n.value).join(`
5
+ `).trim()}:t:{type:"text",value:(e.clipboardData?.getData(to.text)||"").trim()}}catch{return{type:"text",value:""}}},Ys=async(e,o=!1)=>{let t=await xk(e,o);if(t.type==="mixedContent")return{mixedContent:t.value};try{let r=!o&&fk(t.value);if(r)return r}catch(r){console.error(r)}try{let r=JSON.parse(t.value),n=r.type===Pa.excalidrawClipboardWithAPI;if(hk(r))return{elements:r.elements,files:r.files,text:o?JSON.stringify(r.elements,null,2):void 0,programmaticAPI:n}}catch{}return{text:t.value}},Ws=async e=>{try{await navigator.clipboard.write([new window.ClipboardItem({[to.png]:e})])}catch(o){if(ck(e))await navigator.clipboard.write([new window.ClipboardItem({[to.png]:await e})]);else throw o}},oo=async(e,o)=>{if(Gs)try{await navigator.clipboard.writeText(e||"");return}catch(t){console.error(t)}try{if(o){if(o.clipboardData?.setData(to.text,e||""),o.clipboardData?.getData(to.text)!==e)throw new Error("Failed to setData on clipboardEvent");return}}catch(t){console.error(t)}if(!Ek(e))throw new Error("Error copying to clipboard.")},Ek=e=>{e||(e=" ");let o=document.documentElement.getAttribute("dir")==="rtl",t=document.createElement("textarea");t.style.border="0",t.style.padding="0",t.style.margin="0",t.style.position="absolute",t.style[o?"right":"left"]="-9999px";let r=window.pageYOffset||document.documentElement.scrollTop;t.style.top=`${r}px`,t.style.fontSize="12pt",t.setAttribute("readonly",""),t.value=e,document.body.appendChild(t);let n=!1;try{t.select(),t.setSelectionRange(0,t.value.length),n=document.execCommand("copy")}catch(i){console.error(i)}return t.remove(),n};var Kr=(e,{selectedElementIds:o},t)=>{e=Sk(e);let r=t&&Ee(e,{selectedElementIds:o}),n=null,i=r?$(e,{selectedElementIds:o},{includeBoundTextElement:!0}):e;return r&&(i.length===1&&kk(i[0])?(n=i[0],i=Mk(e,n)):i.length>1&&(i=$(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:n,exportedElements:Ik(i)}},Zr=async(e,o,t,r,{exportBackground:n,exportPadding:i=yk,viewBackgroundColor:a,name:l=t.name||wk,fileHandle:s=null,exportingFrame:c=null})=>{if(o.length===0)throw new Error(g("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let m=En(o,{exportBackground:n,exportWithDarkMode:t.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:t.exportScale,exportEmbedScene:t.exportEmbedScene&&e==="svg"},r,{exportingFrame:c});if(e==="svg")return mm(m.then(p=>new Blob([Ck+p.outerHTML],{type:Tk.svg})),{description:"Export to SVG",name:l,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[Zx.svg],fileHandle:s});if(e==="clipboard-svg"){let p=await m.then(u=>u.outerHTML);try{await oo(p)}catch{throw new Error(g("errors.copyToSystemClipboardFailed"))}return}}let d=zl(o,t,r,{exportBackground:n,viewBackgroundColor:a,exportPadding:i,exportingFrame:c});if(e==="png"){let m=Lo(d);return t.exportEmbedScene&&(m=m.then(p=>import("./data/image-7MUHAX25.js").then(({encodePngMetadata:u})=>u({blob:p,metadata:ji(o,t,r,"local")})))),mm(m,{description:"Export to PNG",name:l,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[Zx.png],fileHandle:s})}else if(e==="clipboard")try{let m=Lo(d);await Ws(m)}catch(m){throw console.warn(m),m.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):vk&&m.name==="TypeError"?new Error(`${g("alerts.couldNotCopyToClipboard")}
6
6
 
7
- ${g("hints.firefox_clipboard_write")}`):new Error(g("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var E2=async(e,o,t,r)=>{let{exportBackground:n,viewBackgroundColor:i,fileHandle:a}=o,l=hb(a);if(!a||!gb(l))throw new Error("fileHandle should exist and should be of type svg or png when resaving");o={...o,exportEmbedScene:!0};let{exportedElements:s,exportingFrame:c}=si(e,o,!1);return await ci(l,s,o,t,{exportBackground:n,viewBackgroundColor:i,name:r,fileHandle:a,exportingFrame:c}),{fileHandle:a}};import{Fragment as aT,jsx as _r,jsxs as lT}from"react/jsx-runtime";var ah=B({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,o,t)=>({appState:{...o,name:t},captureUpdate:A.EVENTUALLY}),PanelComponent:({appState:e,updateData:o,appProps:t,data:r,app:n})=>_r(c2,{label:g("labels.fileTitle"),value:n.getName(),onChange:i=>o(i),ignoreFocus:r?.ignoreFocus??!1})}),y2=B({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,o,t)=>({appState:{...o,exportScale:t},captureUpdate:A.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=fe(e),i=De(r,o)?q(r,o):r;return _r(aT,{children:Ns.map(a=>{let[l,s]=pb(i,Ur,a),c=`${g("imageExportDialog.label.scale")} ${a}x (${l}x${s})`;return _r(K,{size:"small",type:"radio",icon:`${a}x`,name:"export-canvas-scale",title:c,"aria-label":c,id:"export-canvas-scale",checked:a===o.exportScale,onChange:()=>t(a)},a)})})}}),lh=B({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,o,t)=>({appState:{...o,exportBackground:t},captureUpdate:A.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>_r(Yl,{checked:e.exportBackground,onChange:t=>o(t),children:g("imageExportDialog.label.withBackground")})}),Td=B({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,o,t)=>({appState:{...o,exportEmbedScene:t},captureUpdate:A.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>lT(Yl,{checked:e.exportEmbedScene,onChange:t=>o(t),children:[g("imageExportDialog.label.embedScene"),_r(Rt,{label:g("imageExportDialog.tooltip.embedScene"),long:!0,children:_r("div",{className:"excalidraw-tooltip-icon",children:Jb})})]})}),di=B({name:"saveToActiveFile",label:"buttons.save",icon:ti,trackEvent:{category:"export"},predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.saveToActiveFile&&!!o.fileHandle&&!o.viewModeEnabled,perform:async(e,o,t,r)=>{let n=!!o.fileHandle;try{let{fileHandle:i}=Mc(o.fileHandle)?await E2(e,o,r.files,r.getName()):await Tc(e,o,r.files,r.getName());return{captureUpdate:A.EVENTUALLY,appState:{...o,fileHandle:i,toast:n?{message:i?.name?g("toast.fileSavedToFilename").replace("{filename}",`"${i.name}"`):g("toast.fileSaved")}:null}}}catch(i){return i?.name!=="AbortError"?console.error(i):console.warn(i),{captureUpdate:A.EVENTUALLY}}},keyTest:e=>!1}),Kl=B({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:ti,viewMode:!0,trackEvent:{category:"export"},perform:async(e,o,t,r)=>{try{let{fileHandle:n}=await Tc(e,{...o,fileHandle:null},r.files,r.getName());return{captureUpdate:A.EVENTUALLY,appState:{...o,openDialog:null,fileHandle:n,toast:{message:g("toast.fileSaved")}}}}catch(n){return n?.name!=="AbortError"?console.error(n):console.warn(n),{captureUpdate:A.EVENTUALLY}}},keyTest:e=>e.key===w.S&&e.shiftKey&&e[w.CTRL_OR_CMD],PanelComponent:({updateData:e})=>_r(K,{type:"button",icon:Zb,title:g("buttons.saveAs"),"aria-label":g("buttons.saveAs"),showAriaLabel:xe().editor.isMobile,hidden:!Ki,onClick:()=>e(null),"data-testid":"save-as-button"})}),ga=B({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.loadScene&&!o.viewModeEnabled,perform:async(e,o,t,r)=>{try{let{elements:n,appState:i,files:a}=await Zp(o,e);return{elements:n,appState:i,files:a,captureUpdate:A.IMMEDIATELY}}catch(n){return n?.name==="AbortError"?(console.warn(n),!1):{elements:e,appState:{...o,errorMessage:n.message},files:r.files,captureUpdate:A.EVENTUALLY}}},keyTest:e=>e[w.CTRL_OR_CMD]&&e.key===w.O}),v2=B({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,o,t)=>({appState:{...o,exportWithDarkMode:t},captureUpdate:A.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>_r("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:_r(l2,{value:e.exportWithDarkMode?re.DARK:re.LIGHT,onChange:t=>{o(t===re.DARK)},title:g("imageExportDialog.label.darkMode")})})});var w2="{}",sh=B({name:"copyStyles",label:"labels.copyStyles",icon:yu,trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=[],i=e.find(a=>o.selectedElementIds[a.id]);if(n.push(i),i&&bt(i)){let a=pe(i,r.scene.getNonDeletedElementsMap());n.push(a)}return i&&(w2=JSON.stringify(n)),{appState:{...o,toast:{message:g("toast.copyStyles")}},captureUpdate:A.EVENTUALLY}},keyTest:e=>e[w.CTRL_OR_CMD]&&e.altKey&&e.code===le.C}),ch=B({name:"pasteStyles",label:"labels.pasteStyles",icon:yu,trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=JSON.parse(w2),i=n[0],a=n[1];if(!P1(i))return{elements:e,captureUpdate:A.EVENTUALLY};let l=q(e,o,{includeBoundTextElement:!0}),s=l.map(c=>c.id);return{elements:e.map(c=>{if(s.includes(c.id)){let m=i;if(V(c)&&c.containerId&&(m=a),!m)return c;let d=te(c,{backgroundColor:m?.backgroundColor,strokeWidth:m?.strokeWidth,strokeColor:m?.strokeColor,strokeStyle:m?.strokeStyle,fillStyle:m?.fillStyle,opacity:m?.opacity,roughness:m?.roughness,roundness:m.roundness?R1(m.roundness.type,c)?m.roundness:N1(c):null});if(V(d)){let p=m.fontSize||Er,u=m.fontFamily||Fr;d=te(d,{fontSize:p,fontFamily:u,textAlign:m.textAlign||As,lineHeight:m.lineHeight||zo(u)});let f=null;d.containerId&&(f=l.find(b=>V(d)&&b.id===d.containerId)||null),Ke(d,f,r.scene)}return d.type==="arrow"&&Pe(m)&&(d=te(d,{startArrowhead:m.startArrowhead,endArrowhead:m.endArrowhead})),ce(c)&&(d=te(d,{roundness:null,backgroundColor:"transparent"})),d}return c}),captureUpdate:A.IMMEDIATELY}},keyTest:e=>e[w.CTRL_OR_CMD]&&e.altKey&&e.code===le.V});import{jsx as T2}from"react/jsx-runtime";var sT=B({name:"toggleCanvasMenu",label:"buttons.menu",trackEvent:{category:"menu"},perform:(e,o)=>({appState:{...o,openMenu:o.openMenu==="canvas"?null:"canvas"},captureUpdate:A.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>T2(K,{type:"button",icon:Fc,"aria-label":g("buttons.menu"),onClick:o,selected:e.openMenu==="canvas"})}),cT=B({name:"toggleEditMenu",label:"buttons.edit",trackEvent:{category:"menu"},perform:(e,o)=>({appState:{...o,openMenu:o.openMenu==="shape"?null:"shape"},captureUpdate:A.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>T2(K,{visible:Yi(o,fe(e)),type:"button",icon:Xb,"aria-label":g("buttons.edit"),onClick:t,selected:o.openMenu==="shape"})}),mi=B({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:Ub,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,o,t,{focusContainer:r})=>(o.openDialog?.name==="help"&&r(),{appState:{...o,openDialog:o.openDialog?.name==="help"?null:{name:"help"}},captureUpdate:A.EVENTUALLY}),keyTest:e=>e.key===w.QUESTION_MARK});import{jsx as fa}from"react/jsx-runtime";var dT=e=>{if(e.length>=2){let o=e[0].groupIds;for(let t of o)if(e.reduce((r,n)=>r&&Ni(n,t),!0))return!0}return!1},C2=(e,o,t)=>{let r=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});return r.length>=2&&!dT(r)&&!pc(r)},dh=B({name:"group",label:"labels.group",icon:e=>fa(gu,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=u0(r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}));if(n.length<2)return{appState:o,elements:e,captureUpdate:A.EVENTUALLY};let i=Yo(o);if(i.length===1){let x=i[0],E=new Set(He(e,x).map(T=>T.id)),y=new Set(n.map(T=>T.id));if(new Set([...Array.from(E),...Array.from(y)]).size===E.size)return{appState:o,elements:e,captureUpdate:A.EVENTUALLY}}let a=[...e];new Set(n.map(x=>x.frameId)).size>1&&m0(n).forEach((E,y)=>{cc(E,r.scene.getNonDeletedElementsMap())});let s=mo(),c=j(n);a=a.map(x=>c.get(x.id)?te(x,{groupIds:a0(x.groupIds,s,o.editingGroupId)}):x);let m=He(a,s),d=m[m.length-1],p=a.lastIndexOf(d),u=a.slice(p+1),f=a.slice(0,p).filter(x=>!Ni(x,s)),b=nr([...f,...m,...u],j(m));return{appState:{...o,...r0(s,{...o,selectedGroupIds:{}},fe(a))},elements:b,captureUpdate:A.IMMEDIATELY}},predicate:(e,o,t,r)=>C2(e,o,r),keyTest:e=>!e.shiftKey&&e[w.CTRL_OR_CMD]&&e.key===w.G,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>fa(K,{hidden:!C2(e,o,r),type:"button",icon:fa(gu,{theme:o.theme}),onClick:()=>t(null),title:`${g("labels.group")} \u2014 ${D("CtrlOrCmd+G")}`,"aria-label":g("labels.group"),visible:De(fe(e),o)})}),mh=B({name:"ungroup",label:"labels.ungroup",icon:e=>fa(fu,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=Yo(o),i=j(e);if(n.length===0)return{appState:o,elements:e,captureUpdate:A.EVENTUALLY};let a=[...e],l=[];a=a.map(p=>{rt(p)&&l.push(p.id);let u=l0(p.groupIds,o.selectedGroupIds);return u.length===p.groupIds.length?p:te(p,{groupIds:u})});let s=it(o,fe(a),o,null),c=r.scene.getSelectedElements(o),m=new Set(c.filter(p=>p.frameId).map(p=>p.frameId));return p0(e).filter(p=>m.has(p.id)).forEach(p=>{p&&(a=dc(a,Oi(a,p,o,i),p,r))}),s.selectedElementIds=Object.entries(s.selectedElementIds).reduce((p,[u,f])=>(f&&!l.includes(u)&&(p[u]=!0),p),{}),{appState:{...o,...s},elements:a,captureUpdate:A.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[w.CTRL_OR_CMD]&&e.key===w.G.toUpperCase(),predicate:(e,o)=>Yo(o).length>0,PanelComponent:({elements:e,appState:o,updateData:t})=>fa(K,{type:"button",hidden:Yo(o).length===0,icon:fa(fu,{theme:o.theme}),onClick:()=>t(null),title:`${g("labels.ungroup")} \u2014 ${D("CtrlOrCmd+Shift+G")}`,"aria-label":g("labels.ungroup"),visible:De(fe(e),o)})});import hT from"clsx";var Cd=(e,o,t,r,n,i,a)=>{e.beginPath(),e.moveTo(o+i,t),e.lineTo(o+r-i,t),e.quadraticCurveTo(o+r,t,o+r,t+i),e.lineTo(o+r,t+n-i),e.quadraticCurveTo(o+r,t+n,o+r-i,t+n),e.lineTo(o+i,t+n),e.quadraticCurveTo(o,t+n,o,t+n-i),e.lineTo(o,t+i),e.quadraticCurveTo(o,t,o+i,t),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};function mT(e){let o=0;if(e.length===0)return o;for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);o=(o<<5)-o+r}return o}var pi=(e,o)=>`hsl(${Math.abs(mT(o?.id||e))%37*10}, 100%, 83%)`,k2=e=>{let o=e?.trim()?.codePointAt(0);return(o?String.fromCodePoint(o):"?").toUpperCase()},S2=({context:e,renderConfig:o,appState:t,normalizedWidth:r,normalizedHeight:n})=>{for(let[i,a]of o.remotePointerViewportCoords){let{x:l,y:s}=a,c=t.collaborators.get(i);l-=t.offsetLeft,s-=t.offsetTop;let m=11,d=14,p=l<0||l>r-m||s<0||s>n-d;l=Math.max(l,0),l=Math.min(l,r-m),s=Math.max(s,0),s=Math.min(s,n-d);let u=pi(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let f=o.remotePointerUserStates.get(i),b=p||f==="idle"||f==="away";b&&(e.globalAlpha=.3),o.remotePointerButton.get(i)==="down"&&(e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=u,e.stroke(),e.closePath());let x=t.theme===re.DARK?"#2f6330":Ff,E=c?.isSpeaking;E&&(e.fillStyle=x,e.strokeStyle=x,e.lineWidth=10,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=Ja,e.strokeStyle=Ja,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=u,e.strokeStyle=u,e.lineWidth=2,e.lineJoin="round",e.beginPath(),b?(e.moveTo(l-1,s-1),e.lineTo(l-1,s+15),e.lineTo(l+5,s+10),e.lineTo(l+12,s+9),e.closePath(),e.fill()):(e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.fill(),e.stroke());let y=o.remotePointerUsernames.get(i)||"";if(!p&&y){e.font="600 12px sans-serif";let v=(E?l+0:l)+m/2,T=(E?s+0:s)+d+2,I=5,S=3,P=e.measureText(y),M=P.actualBoundingBoxDescent+P.actualBoundingBoxAscent,O=Math.max(M,12),R=v-1,z=T-1,W=P.width+2+I*2+2,Y=O+2+S*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(R,z,W,Y,8),e.fillStyle=u,e.fill(),e.strokeStyle=Ja,e.stroke(),E&&(e.beginPath(),e.roundRect(R-2,z-2,W+4,Y+4,8),e.strokeStyle=x,e.stroke())):Cd(e,R,z,W,Y,8,Ja),e.fillStyle=zf,e.fillText(y,v+I+1,T+S+P.actualBoundingBoxAscent+Math.floor((O-M)/2)+2),E){e.fillStyle=x;let oe=8,H=8,F=5;e.fillRect(R+W+H,z+(Y/2-oe/2),2,oe),e.fillRect(R+W+H+F,z+(Y/2-oe*2/2),2,oe*2),e.fillRect(R+W+H+F*2,z+(Y/2-oe/2),2,oe)}}e.restore(),e.closePath()}};import pT from"clsx";import{useState as uT}from"react";import{jsx as I2}from"react/jsx-runtime";var ph=({color:e,onClick:o,name:t,src:r,className:n})=>{let i=k2(t),[a,l]=uT(!1),s=!a&&r,c=s?void 0:{background:e};return I2("div",{className:pT("Avatar",n),style:c,onClick:o,children:s?I2("img",{className:"Avatar-img",src:r,alt:i,referrerPolicy:"no-referrer",onError:()=>l(!0)}):i})};import{jsx as mr,jsxs as kd}from"react/jsx-runtime";var gT=B({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,o,t)=>!t.socketId||o.userToFollow?.socketId===t.socketId||t.isCurrentUser?{appState:{...o,userToFollow:null},captureUpdate:A.EVENTUALLY}:{appState:{...o,userToFollow:{socketId:t.socketId,username:t.username||""},openMenu:o.openMenu==="canvas"?null:o.openMenu},captureUpdate:A.EVENTUALLY},PanelComponent:({updateData:e,data:o,appState:t})=>{let{socketId:r,collaborator:n,withName:i,isBeingFollowed:a}=o,l=pi(r,n),s=hT({"is-followed":a,"is-current-user":n.isCurrentUser===!0,"is-speaking":n.isSpeaking,"is-in-call":n.isInCall,"is-muted":n.isMuted}),c=n.isInCall?n.isSpeaking?kd("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:g("userList.hint.isSpeaking"),children:[mr("div",{}),mr("div",{}),mr("div",{})]}):n.isMuted?mr("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:g("userList.hint.micMuted"),children:eE}):mr("div",{title:g("userList.hint.inCall"),children:Qx}):null;return i?kd("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(n),children:[mr(ph,{color:l,onClick:()=>{},name:n.username||"",src:n.avatarUrl,className:s}),mr("div",{className:"UserList__collaborator-name",children:n.username}),kd("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&mr("div",{className:"UserList__collaborator-status-icon-is-followed",title:g("userList.hint.followStatus"),children:ri}),c]})]}):kd("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[mr(ph,{color:l,onClick:()=>{e(n)},name:n.username||"",src:n.avatarUrl,className:s}),c&&mr("div",{className:"UserList__collaborator-status-icon",children:c})]})}});var uh=B({name:"addToLibrary",trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let i of zs)if(n.some(a=>a.type===i))return{captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:g(`errors.libraryElementTypeError.${i}`)}};return r.library.getLatestLibrary().then(i=>r.library.setLibrary([{id:mo(),status:"unpublished",elements:n.map(Vo),created:Date.now()},...i])).then(()=>({captureUpdate:A.EVENTUALLY,appState:{...o,toast:{message:g("toast.addedToLibrary")}}})).catch(i=>({captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:i.message}}))},label:"labels.addToLibrary"});import{jsx as xa}from"react/jsx-runtime";var Nt=(e,o)=>{let t=o.scene.getSelectedElements(e);return $n(t,o.scene.getNonDeletedElementsMap()).length>1&&!t.some(n=>ce(n))},ba=(e,o,t,r)=>{let n=t.scene.getSelectedElements(o),i=C0(n,r,t.scene),a=j(i);return wo(e.map(l=>a.get(l.id)||l),o,t)},fT=B({name:"alignTop",label:"labels.alignTop",icon:cu,trackEvent:{category:"element"},predicate:(e,o,t,r)=>Nt(o,r),perform:(e,o,t,r)=>({appState:o,elements:ba(e,o,r,{position:"start",axis:"y"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>e[w.CTRL_OR_CMD]&&e.shiftKey&&e.key===w.ARROW_UP,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>xa(K,{hidden:!Nt(o,r),type:"button",icon:cu,onClick:()=>t(null),title:`${g("labels.alignTop")} \u2014 ${D("CtrlOrCmd+Shift+Up")}`,"aria-label":g("labels.alignTop"),visible:De(fe(e),o)})}),bT=B({name:"alignBottom",label:"labels.alignBottom",icon:du,trackEvent:{category:"element"},predicate:(e,o,t,r)=>Nt(o,r),perform:(e,o,t,r)=>({appState:o,elements:ba(e,o,r,{position:"end",axis:"y"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>e[w.CTRL_OR_CMD]&&e.shiftKey&&e.key===w.ARROW_DOWN,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>xa(K,{hidden:!Nt(o,r),type:"button",icon:du,onClick:()=>t(null),title:`${g("labels.alignBottom")} \u2014 ${D("CtrlOrCmd+Shift+Down")}`,"aria-label":g("labels.alignBottom"),visible:De(fe(e),o)})}),xT=B({name:"alignLeft",label:"labels.alignLeft",icon:mu,trackEvent:{category:"element"},predicate:(e,o,t,r)=>Nt(o,r),perform:(e,o,t,r)=>({appState:o,elements:ba(e,o,r,{position:"start",axis:"x"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>e[w.CTRL_OR_CMD]&&e.shiftKey&&e.key===w.ARROW_LEFT,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>xa(K,{hidden:!Nt(o,r),type:"button",icon:mu,onClick:()=>t(null),title:`${g("labels.alignLeft")} \u2014 ${D("CtrlOrCmd+Shift+Left")}`,"aria-label":g("labels.alignLeft"),visible:De(fe(e),o)})}),ET=B({name:"alignRight",label:"labels.alignRight",icon:pu,trackEvent:{category:"element"},predicate:(e,o,t,r)=>Nt(o,r),perform:(e,o,t,r)=>({appState:o,elements:ba(e,o,r,{position:"end",axis:"x"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>e[w.CTRL_OR_CMD]&&e.shiftKey&&e.key===w.ARROW_RIGHT,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>xa(K,{hidden:!Nt(o,r),type:"button",icon:pu,onClick:()=>t(null),title:`${g("labels.alignRight")} \u2014 ${D("CtrlOrCmd+Shift+Right")}`,"aria-label":g("labels.alignRight"),visible:De(fe(e),o)})}),yT=B({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:uu,trackEvent:{category:"element"},predicate:(e,o,t,r)=>Nt(o,r),perform:(e,o,t,r)=>({appState:o,elements:ba(e,o,r,{position:"center",axis:"y"}),captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>xa(K,{hidden:!Nt(o,r),type:"button",icon:uu,onClick:()=>t(null),title:g("labels.centerVertically"),"aria-label":g("labels.centerVertically"),visible:De(fe(e),o)})}),vT=B({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:hu,trackEvent:{category:"element"},predicate:(e,o,t,r)=>Nt(o,r),perform:(e,o,t,r)=>({appState:o,elements:ba(e,o,r,{position:"center",axis:"x"}),captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>xa(K,{hidden:!Nt(o,r),type:"button",icon:hu,onClick:()=>t(null),title:g("labels.centerHorizontally"),"aria-label":g("labels.centerHorizontally"),visible:De(fe(e),o)})});import{jsx as A2}from"react/jsx-runtime";var M2=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length>1&&!t.some(r=>ce(r))},L2=(e,o,t,r)=>{let n=t.scene.getSelectedElements(o),i=A0(n,t.scene.getNonDeletedElementsMap(),r),a=j(i);return wo(e.map(l=>a.get(l.id)||l),o,t)},wT=B({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,o,t,r)=>({appState:o,elements:L2(e,o,r,{space:"between",axis:"x"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>!e[w.CTRL_OR_CMD]&&e.altKey&&e.code===le.H,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>A2(K,{hidden:!M2(o,r),type:"button",icon:ox,onClick:()=>t(null),title:`${g("labels.distributeHorizontally")} \u2014 ${D("Alt+H")}`,"aria-label":g("labels.distributeHorizontally"),visible:De(fe(e),o)})}),TT=B({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,o,t,r)=>({appState:o,elements:L2(e,o,r,{space:"between",axis:"y"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>!e[w.CTRL_OR_CMD]&&e.altKey&&e.code===le.V,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>A2(K,{hidden:!M2(o,r),type:"button",icon:rx,onClick:()=>t(null),title:`${g("labels.distributeVertically")} \u2014 ${D("Alt+V")}`,"aria-label":g("labels.distributeVertically"),visible:De(fe(e),o)})});import{jsx as IT}from"react/jsx-runtime";var CT=(e,o,t)=>{let r=t.scene.getSelectedElements(o),n=j(e),i=Tl(t.scene,r,n,o.arrangeConfiguration.algorithm,o.arrangeConfiguration.gap),a=j(i);return wo(e.map(l=>a.get(l.id)||l),o,t)},kT=Nt,ST=B({name:"arrangeElements",label:"labels.arrangeElements",keywords:["arrange","rearrange","spread"],icon:wu,trackEvent:{category:"element"},viewMode:!1,predicate:(e,o,t,r)=>kT(o,r),perform:(e,o,t,r)=>({appState:o,elements:CT(e,o,r),captureUpdate:A.IMMEDIATELY}),keyTest:e=>e.shiftKey&&vi(e,w.R),PanelComponent:({updateData:e})=>IT("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:`${g("labels.arrangeElements")} \u2014 ${D("Shift+R")}`,children:wu})});var hh=B({name:"flipHorizontal",label:"labels.flipHorizontal",icon:nE,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:wo(_2(e,r.scene.getNonDeletedElementsMap(),o,"horizontal",r),o,r),appState:o,captureUpdate:A.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===le.H}),gh=B({name:"flipVertical",label:"labels.flipVertical",icon:rE,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:wo(_2(e,r.scene.getNonDeletedElementsMap(),o,"vertical",r),o,r),appState:o,captureUpdate:A.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===le.V&&!e[w.CTRL_OR_CMD]}),_2=(e,o,t,r,n)=>{let i=q(fe(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=MT(i,o,t,r,n),l=j(a);return e.map(s=>l.get(s.id)||s)},MT=(e,o,t,r,n)=>{if(e.every(u=>Pe(u)&&(u.startBinding||u.endBinding)))return e.map(u=>{let f=u;return te(f,{startArrowhead:f.endArrowhead,endArrowhead:f.startArrowhead})});let{midX:i,midY:a}=po(e);Z0(e,o,"nw",n.scene,new Map(Array.from(o.values()).map(u=>[u.id,Vo(u)])),{flipByX:r==="horizontal",flipByY:r==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),pl(e.filter(ge),Xr(t),[],n.scene,t.zoom);let{elbowArrows:l,otherElements:s}=e.reduce((u,f)=>se(f)?{...u,elbowArrows:u.elbowArrows.concat(f)}:{...u,otherElements:u.otherElements.concat(f)},{elbowArrows:[],otherElements:[]}),{midX:c,midY:m}=po(e),[d,p]=[i-c,a-m];return s.forEach(u=>n.scene.mutateElement(u,{x:u.x+d,y:u.y+p})),l.forEach(u=>n.scene.mutateElement(u,{x:u.x+d,y:u.y+p})),e};var Ea=B({name:"copy",label:"labels.copy",icon:kl,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await yd(n,r.files,t)}catch(i){return{captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:i.message}}}return{captureUpdate:A.EVENTUALLY}},keyTest:void 0}),fh=B({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n;try{n=await x2()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),xo?{captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:g("hints.firefox_clipboard_write")}}:{captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:g("errors.asyncPasteFailedOnRead")}})}try{r.pasteFromClipboard(f2({types:n}))}catch(i){return console.error(i),{captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:g("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:A.EVENTUALLY}},keyTest:void 0}),Sd=B({name:"cut",label:"labels.cut",icon:Ux,trackEvent:{category:"element"},perform:(e,o,t,r)=>(Ea.perform(e,o,t,r),Rl.perform(e,o,null,r)),keyTest:e=>e[w.CTRL_OR_CMD]&&e.key===w.X}),Id=B({name:"copyAsSvg",label:"labels.copyAsSvg",icon:iE,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{if(!r.canvas)return{captureUpdate:A.EVENTUALLY};let{exportedElements:n,exportingFrame:i}=si(e,o,!0);try{await ci("clipboard-svg",n,o,r.files,{...o,exportingFrame:i,name:r.getName()});let a=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:g("toast.copyToClipboardAsSvg",{exportSelection:a.length?g("toast.selection"):g("toast.canvas"),exportColorScheme:o.exportWithDarkMode?g("buttons.darkMode"):g("buttons.lightMode")})}},captureUpdate:A.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:A.EVENTUALLY}}},predicate:e=>Ed&&e.length>0,keywords:["svg","clipboard","copy"]}),Md=B({name:"copyAsPng",label:"labels.copyAsPng",icon:aE,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{if(!r.canvas)return{captureUpdate:A.EVENTUALLY};let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=si(e,o,!0);try{return await ci("clipboard",i,o,r.files,{...o,exportingFrame:a,name:r.getName()}),{appState:{...o,toast:{message:g("toast.copyToClipboardAsPng",{exportSelection:n.length?g("toast.selection"):g("toast.canvas"),exportColorScheme:o.exportWithDarkMode?g("buttons.darkMode"):g("buttons.lightMode")})}},captureUpdate:A.EVENTUALLY}}catch(l){return console.error(l),{appState:{...o,errorMessage:l.message},captureUpdate:A.EVENTUALLY}}},predicate:e=>bn&&e.length>0,keyTest:e=>e.code===le.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),Ld=B({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});try{jo(xp(n))}catch{throw new Error(g("errors.copyToSystemClipboardFailed"))}return{captureUpdate:A.EVENTUALLY}},predicate:(e,o,t,r)=>Ed&&r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}).some(V),keywords:["text","clipboard","copy"]});var Ad=B({name:"gridMode",icon:dE,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>e.gridModeEnabled},perform(e,o){return{appState:{...o,gridModeEnabled:!this.checked(o),objectsSnapModeEnabled:!1},captureUpdate:A.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[w.CTRL_OR_CMD]&&e.code===le.QUOTE});var ya=B({name:"zenMode",label:"buttons.zenMode",icon:sE,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,o){return{appState:{...o,zenModeEnabled:!this.checked(o)},captureUpdate:A.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,o,t)=>typeof t.zenModeEnabled>"u",keyTest:e=>!e[w.CTRL_OR_CMD]&&e.altKey&&e.code===le.Z});var bh=B({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:lE,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,o){return{appState:{...o,objectsSnapModeEnabled:!this.checked(o),gridModeEnabled:!1},captureUpdate:A.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,o,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[w.CTRL_OR_CMD]&&e.altKey&&e.code===le.S});var va=B({name:"stats",label:"stats.fullTitle",icon:oE,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,o){return{appState:{...o,stats:{...o.stats,open:!this.checked(o)}},captureUpdate:A.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[w.CTRL_OR_CMD]&&e.altKey&&e.code===le.SLASH});var xh=B({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>r.scene.getSelectedElements(o).some(i=>bt(i)),perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=r.scene.getNonDeletedElementsMap();return n.forEach(a=>{let l=pe(a,i);if(l){let{width:s,height:c}=vt(l.originalText,et(l),l.lineHeight),m=F1(a.id);z1(a.id);let{x:d,y:p}=Zr(a,l,i);r.scene.mutateElement(l,{containerId:null,width:s,height:c,text:l.originalText,x:d,y:p}),r.scene.mutateElement(a,{boundElements:a.boundElements?.filter(u=>u.id!==l.id),height:m||a.height})}}),{elements:e,appState:o,captureUpdate:A.IMMEDIATELY}}}),Eh=B({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);if(n.length===2){let i=V(n[0])||V(n[1]),a;if(Cr(n[0])?a=n[0]:Cr(n[1])&&(a=n[1]),i&&a&&pe(a,r.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i,a;V(n[0])&&Cr(n[1])?(i=n[0],a=n[1]):(i=n[1],a=n[0]),r.scene.mutateElement(i,{containerId:a.id,verticalAlign:Xt.MIDDLE,textAlign:el.CENTER,autoResize:!0,angle:Pe(a)?0:a?.angle??0}),r.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let l=a.height;return Ke(i,a,r.scene),cl(a.id,l),{elements:LT(e,a,i),appState:{...o,selectedElementIds:{[a.id]:!0}},captureUpdate:A.IMMEDIATELY}}}),LT=(e,o,t)=>{let r=e.slice(),n=r.findIndex(a=>a.id===t.id);r.splice(n,1);let i=r.findIndex(a=>a.id===o.id);return r.splice(i+1,0,t),nr(r,j([o,t])),r},AT=(e,o,t)=>{let r=e.slice(),n=r.findIndex(a=>a.id===o.id);r.splice(n,1);let i=r.findIndex(a=>a.id===t.id);return r.splice(i,0,o),nr(r,j([o,t])),r},P2=B({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=n.some(a=>V(a));return n.length>0&&i},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=e.slice(),a={};for(let l of n)if(V(l)){let s=qt({type:"rectangle",backgroundColor:o.currentItemBackgroundColor,boundElements:[...l.boundElements||[],{id:l.id,type:"text"}],angle:l.angle,fillStyle:o.currentItemFillStyle,strokeColor:o.currentItemStrokeColor,roughness:o.currentItemRoughness,strokeWidth:o.currentItemStrokeWidth,strokeStyle:o.currentItemStrokeStyle,roundness:o.currentItemRoundness==="round"?{type:Kr("rectangle")?ut.ADAPTIVE_RADIUS:ut.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:l.x-np,y:l.y-np,width:_i(l.width,"rectangle"),height:_i(l.height,"rectangle"),groupIds:l.groupIds,frameId:l.frameId});if(l.boundElements?.length){let c=l.boundElements.filter(d=>d.type==="arrow").map(d=>d.id);i.filter(d=>c.includes(d.id)).forEach(d=>{let p=d.startBinding,u=d.endBinding;p?.elementId===l.id&&(p={...p,elementId:s.id}),u?.elementId===l.id&&(u={...u,elementId:s.id}),(p||u)&&r.scene.mutateElement(d,{startBinding:p,endBinding:u})})}r.scene.mutateElement(l,{containerId:s.id,verticalAlign:Xt.MIDDLE,boundElements:null,textAlign:el.CENTER,autoResize:!0}),Ke(l,s,r.scene),i=AT([...i,s],s,l),a[s.id]=!0}return{elements:i,appState:{...o,selectedElementIds:a},captureUpdate:A.IMMEDIATELY}}});import _T from"clsx";import{useCallback as D2,useEffect as R2,useLayoutEffect as PT,useRef as DT,useState as RT}from"react";import{jsx as wa,jsxs as N2}from"react/jsx-runtime";var wh=380,NT=42,yh=5,O2=85,OT=500,vh=!1,_d=new Map,B2=({element:e,scene:o,setAppState:t,onLinkOpen:r,setToast:n,updateEmbedValidationStatus:i})=>{let a=o.getNonDeletedElementsMap(),l=sr(),s=cr(),c=xe(),m=e.link||"",[d,p]=RT(m),u=DT(null),f=l.showHyperlinkPopup==="editor",b=D2(()=>{if(!u.current)return;let T=Uo(u.current.value)||null;if(!e.link&&T&&me("hyperlink","create"),zt(e)){if(l.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!T){o.mutateElement(e,{link:null}),i(e,!1);return}if(!Ui(T,s.validateEmbeddable))T&&n({message:g("toast.unableToEmbed"),closable:!0}),e.link&&_d.set(e.id,e.link),o.mutateElement(e,{link:T}),i(e,!1);else{let{width:I,height:S}=e,P=Qn(T);P?.error instanceof URIError&&n({message:g("toast.unrecognizedLinkFormat"),closable:!0});let M=P?P.intrinsicSize.w/P.intrinsicSize.h:1,O=_d.get(e.id)!==e.link;o.mutateElement(e,{...O?{width:P?.type==="video"?I>S?I:S*M:I,height:P?.type==="video"&&I>S?I/M:S}:{},link:T}),i(e,!0),_d.has(e.id)&&_d.delete(e.id)}}else o.mutateElement(e,{link:T})},[e,o,n,s.validateEmbeddable,l.activeEmbeddable,t,i]);PT(()=>()=>{b()},[b]),R2(()=>{f&&u?.current&&!(c.viewport.isMobile||c.isTouchScreen)&&u.current.select()},[f,c.viewport.isMobile,c.isTouchScreen]),R2(()=>{let T=null,I=S=>{if(f)return;T&&clearTimeout(T),zT(e,a,l,L(S.clientX,S.clientY))&&(T=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},OT))};return window.addEventListener("pointermove",I,!1),()=>{window.removeEventListener("pointermove",I,!1),T&&clearTimeout(T)}},[l,e,f,t,a]);let x=D2(()=>{me("hyperlink","delete"),o.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,o]),E=()=>{me("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:y,y:v}=z2(e,l,a);return l.contextMenu||l.selectedElementsAreBeingDragged||l.resizingElement||l.isRotating||l.openMenu||l.viewModeEnabled?null:N2("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${v}px`,left:`${y}px`,width:wh,padding:yh},children:[f?wa("input",{className:_T("excalidraw-hyperlinkContainer-input"),placeholder:g("labels.link.hint"),ref:u,value:d,onChange:T=>p(T.target.value),autoFocus:!0,onKeyDown:T=>{T.stopPropagation(),T[w.CTRL_OR_CMD]&&T.key===w.K&&T.preventDefault(),(T.key===w.ENTER||T.key===w.ESCAPE)&&(b(),t({showHyperlinkPopup:"info"}))}}):e.link?wa("a",{href:Uo(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:Xs(e.link)?"_self":"_blank",onClick:T=>{if(e.link&&r){let I=Ys("excalidraw-link",T.nativeEvent);r({...e,link:Uo(e.link)},I),I.defaultPrevented&&T.preventDefault()}},rel:"noopener noreferrer",children:e.link}):wa("div",{className:"excalidraw-hyperlinkContainer-link",children:g("labels.link.empty")}),N2("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!f&&wa(K,{type:"button",title:g("buttons.edit"),"aria-label":g("buttons.edit"),label:g("buttons.edit"),onClick:E,className:"excalidraw-hyperlinkContainer--edit",icon:lr}),wa(K,{type:"button",title:g("labels.linkToElement"),"aria-label":g("labels.linkToElement"),label:g("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:qc}),m&&!zt(e)&&wa(K,{type:"button",title:g("buttons.remove"),"aria-label":g("buttons.remove"),label:g("buttons.remove"),onClick:x,className:"excalidraw-hyperlinkContainer--remove",icon:Lr})]})]})},z2=(e,o,t)=>{let[r,n]=at(e,t),{x:i,y:a}=gt({sceneX:r+e.width/2,sceneY:n},o),l=i-o.offsetLeft-wh/2,s=a-o.offsetTop-O2;return{x:l,y:s}},Th=(e,o)=>{let t=q(e,o);return zt(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},Zl=null,F2=(e,o,t)=>{Zl&&clearTimeout(Zl),Zl=window.setTimeout(()=>BT(e,o,t),Kf)},BT=(e,o,t)=>{if(!e.link)return;let r=ua();r.classList.add("excalidraw-tooltip--visible"),r.style.maxWidth="20rem",r.textContent=Jn(e.link)?g("labels.link.goToElement"):e.link;let[n,i,a,l]=at(e,t),[s,c,m,d]=ib([n,i,a,l],e.angle,o),p=gt({sceneX:s,sceneY:c},o);rh(r,{left:p.x,top:p.y,width:m,height:d},"top"),me("hyperlink","tooltip","link-icon"),vh=!0},Ch=()=>{Zl&&clearTimeout(Zl),vh&&(vh=!1,ua().classList.remove("excalidraw-tooltip--visible"))},zT=(e,o,t,[r,n])=>{let{x:i,y:a}=ze({clientX:r,clientY:n},t),l=15/t.zoom.value;if(ec(L(i,a),e,o))return!1;let[s,c,m]=at(e,o);if(i>=s&&i<=m&&a>=c-O2&&a<=c)return!1;let{x:d,y:p}=z2(e,t,o);return!(r>=d-l&&r<=d+wh+yh*2+l&&n>=p-l&&n<=p+l+yh*2+NT)};import{jsx as FT}from"react/jsx-runtime";var Xl=B({name:"hyperlink",label:(e,o)=>Th(e,o),icon:Ml,perform:(e,o)=>o.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...o,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:A.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[w.CTRL_OR_CMD]&&e.key===w.K,predicate:(e,o)=>q(e,o).length===1,PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=q(e,o);return FT(K,{type:"button",icon:Ml,"aria-label":g(Th(e,o)),title:`${zt(e[0])?g("labels.link.labelEmbed"):g("labels.link.label")} - ${D("CtrlOrCmd+K")}`,onClick:()=>t(null),selected:r.length===1&&!!r[0].link})}});var kh=e=>e.every(o=>!o.locked),$l=B({name:"toggleElementLock",label:(e,o,t)=>{let r=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1});return kh(r)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,o)=>{let t=q(o,e);return kh(t)?rn:Mr},trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return n.length>0&&!n.some(i=>i.locked&&i.frameId)},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!n.length)return!1;let i=kh(n),a=j(n),l=n.length>1&&ac(n),c=n.length===1||l?null:mo(),m={...o.lockedMultiSelections};if(i)m={...o.lockedMultiSelections,...c?{[c]:!0}:{}};else if(l){let E=n[0].groupIds.at(-1);delete m[E]}let d=e.map(E=>{if(!a.has(E.id))return E;let y=E.groupIds;return i?c&&(y=[...y,c]):y=y.filter(v=>!o.lockedMultiSelections[v]),te(E,{locked:i,groupIds:y.length!==E.groupIds.length?y:E.groupIds})}),p=j(d),u=i?{}:Object.fromEntries(n.map(E=>[E.id,!0])),f=n.map(E=>p.get(E.id)||E),b=i?{}:Xn(f,o),x=i?c||(l?n[0].groupIds.at(-1):n[0].id):null;return{elements:d,appState:{...o,selectedElementIds:u,selectedGroupIds:b,selectedLinearElement:i?null:o.selectedLinearElement,lockedMultiSelections:m,activeLockedId:x},captureUpdate:A.IMMEDIATELY}},keyTest:(e,o,t,r)=>e.key.toLocaleLowerCase()===w.L&&e[w.CTRL_OR_CMD]&&e.shiftKey&&r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}).length>0}),H2=B({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:Mr,predicate:(e,o)=>q(e,o).length===0&&e.some(r=>r.locked),perform:(e,o)=>{let t=e.filter(a=>a.locked),r=e.map(a=>{if(a.locked){let l=a.groupIds.filter(s=>!o.lockedMultiSelections[s]);return te(a,{locked:!1,groupIds:a.groupIds.length!==l.length?l:a.groupIds})}return a}),n=j(r),i=t.map(a=>n.get(a.id)||a);return{elements:r,appState:{...o,selectedElementIds:Object.fromEntries(t.map(a=>[a.id,!0])),selectedGroupIds:Xn(i,o),lockedMultiSelections:{},activeLockedId:null},captureUpdate:A.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import qy from"clsx";import Fk from"fuzzy";import{useEffect as Qd,useRef as Hk,useState as Jd}from"react";import{useEffect as Jl,useMemo as U2,useRef as Ih,useState as HT}from"react";import{jsx as Ah}from"react/jsx-runtime";var UT=8,GT=10,jl=["rectangle","diamond","ellipse"],ql=["line","sharpArrow","curvedArrow","elbowArrow"],YT=new Set(jl),WT=new Set(ql),Ca=e=>YT.has(e),Dd=e=>e==="arrow"||WT.has(e),qo=Ie(null),Ql=new Map,es=new Map,VT=({app:e})=>{let o=e.scene.getSelectedElements(e.state),t=Ih(null);return Jl(()=>{if(o.length===0){e.updateEditorAtom(qo,null);return}let r=ka(o);r&&!t.current?t.current=r:(t.current&&!r||t.current&&r!==t.current)&&(e.updateEditorAtom(qo,null),t.current=null)},[o,e]),Jl(()=>()=>{Ql.clear(),es.clear()},[]),Ah(KT,{app:e,elements:o})},KT=({app:e,elements:o})=>{let t=ka(o),r=U2(()=>t==="generic"?V2(o):[],[t,o]),n=U2(()=>t==="linear"?Lh(o):[],[t,o]),i=t==="generic"?r.every(d=>d.type===r[0].type):t==="linear"?n.every(d=>Kn(d)===Kn(n[0])):!1,[a,l]=HT({x:0,y:0}),s=Ih(""),c=Ih(null);Jl(()=>{let d=[...r,...n].sort((x,E)=>x.id.localeCompare(E.id)),p=`
8
- ${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${d.map(x=>x.id).join(",")}`;if(p===s.current)return;s.current=p;let u;if(d.length===1){let[x,,,E,y,v]=at(d[0],e.scene.getNonDeletedElementsMap());u=Re(L(x,E),L(y,v),d[0].angle)}else{let{minX:x,maxY:E}=po(d);u=L(x,E)}let{x:f,y:b}=gt({sceneX:u[0],sceneY:u[1]},e.state);l({x:f,y:b})},[r,n,e.scene,e.state]),Jl(()=>{for(let d of n){let p=Mh(d.id,qT(d));es.has(p)||es.set(p,d)}},[n]),Jl(()=>{for(let d of r)if(!Ql.has(d.id)){let p=pe(d,e.scene.getNonDeletedElementsMap());p&&Ql.set(d.id,{fontSize:p.fontSize})}},[r,e.scene]);let m=t==="linear"?[["line",sn],["sharpArrow",Zc],["curvedArrow",$c],["elbowArrow",Xc]]:t==="generic"?[["rectangle",nn],["diamond",an],["ellipse",ln]]:[];return Ah("div",{ref:c,tabIndex:-1,style:{position:"absolute",top:`${a.y+(GT+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-UT}px`,zIndex:2},className:Bt.CONVERT_ELEMENT_TYPE_POPUP,children:m.map(([d,p])=>{let u=i&&(t==="generic"&&r[0].type===d||t==="linear"&&Kn(n[0])===d);return Ah(K,{className:"Shape",type:"radio",icon:p,checked:u,name:"convertElementType-option",title:d,keyBindingLabel:"","aria-label":d,"data-testid":`toolbar-${d}`,onChange:()=>{e.state.activeTool.type!==d&&me("convertElementType",d,"ui"),_h(e,{conversionType:t,nextType:d}),c.current?.focus()}},`${o[0].id}${o[0].version}_${d}`)})})},ZT=(e,o,t)=>{let r=ml(e,o),n=Qs(e,o),i=Ai(o.text,et(o),r),a=vt(i,et(o),o.lineHeight),l=o.fontSize;for(;(a.width>r||a.height>n)&&l>0;){l-=1;let s={...o,fontSize:l};a=vt(o.text,et(s),o.lineHeight)}Go(o,t.getNonDeletedElementsMap(),{fontSize:l,width:a.width,height:a.height}),Ke(o,e,t)},_h=(e,{conversionType:o,nextType:t,direction:r="right"})=>{if(!o)return!1;let n=e.scene.getSelectedElements(e.state),i=n.reduce((l,s)=>({...l,[s.id]:!0}),{}),a=r==="right"?1:-1;if(o==="generic"){let l=V2(n),c=l.every(m=>m.type===l[0].type)?jl.indexOf(l[0].type):-1;if(t=t??jl[(c+jl.length+a)%jl.length],t&&Ca(t)){let m={};for(let p of l){let u=Y2(p,t,e);m[u.id]=u}let d=[];for(let p of e.scene.getElementsIncludingDeleted())m[p.id]?d.push(m[p.id]):d.push(p);e.scene.replaceAllElements(d);for(let p of Object.values(m)){let u=pe(p,e.scene.getNonDeletedElementsMap());u&&(Ql.get(p.id)&&Go(u,e.scene.getNonDeletedElementsMap(),{fontSize:Ql.get(p.id)?.fontSize??u.fontSize}),ZT(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:Le(p,{type:"selection"})}))}}if(o==="linear"){let l=Lh(n);if(!t){let c=Zs(l,Kn),m=c?ql.indexOf(c):-1;t=ql[(m+ql.length+a)%ql.length]}if(Dd(t)){let c=[],m=e.scene.getElementsMapIncludingDeleted();for(let d of l){let p=es.get(Mh(d.id,t));if(p&&Kn(p)===t)m.set(p.id,p),c.push(p);else{let u=Y2(d,t,e);m.set(u.id,u),c.push(u)}}e.scene.replaceAllElements(m);for(let d of c)if(ge(d))if(se(d)){let p=XT(d);if(p.length<2)continue;let u=[];for(let b=1;b<p.length-2;b++)u.push({start:p[b],end:p[b+1],index:b+1});let f=tc(d,e.scene.getNonDeletedElementsMap(),{points:p,fixedSegments:u});Go(d,e.scene.getNonDeletedElementsMap(),{...f,endArrowhead:"arrow"})}else{let p=h1(["line","sharpArrow","curvedArrow"],u=>es.get(Mh(d.id,u)));if(p){let u=p.points;e.scene.mutateElement(d,{points:u})}}}let s=Lh(e.scene.getSelectedElements(e.state));e.setState(c=>({selectedElementIds:i,selectedLinearElement:s.length===1?new $(s[0],e.scene.getNonDeletedElementsMap()):null,activeTool:Le(c,{type:"selection"})}))}return!0},ka=e=>{if(e.length===0)return null;let o=!1;for(let t of e){if(Ca(t.type))return"generic";W2(t)&&(o=!0)}return o?"linear":null},W2=e=>ge(e)&&(!Pe(e)||!D1(e)&&!bt(e)),Mh=(e,o)=>`${e}:${o}`,V2=e=>e.filter(o=>Ca(o.type)),Lh=e=>e.filter(o=>W2(o)),Pd=20,Ta=(e,o)=>e[0]===o[0],Sh=(e,o)=>e[1]===o[1],G2=(e,o)=>Ta(e,o)?Math.abs(e[1]-o[1]):Math.abs(e[0]-o[0]),XT=e=>{let o=[e.points[0]],t=$T(e.points);for(let i=1;i<t.length;++i){let a=o[o.length-1],l=[...t[i]];Math.abs(l[0]-a[0])<Pd?l[0]=a[0]:Math.abs(l[1]-a[1])<Pd&&(l[1]=a[1]),Ta(a,l)||Sh(a,l)||o.push(L(a[0],l[1])),o.push(l)}let r=[o[0]];for(let i=1;i<o.length-1;++i)Ta(o[i-1],o[i])&&Ta(o[i],o[i+1])||Sh(o[i-1],o[i])&&Sh(o[i],o[i+1])||r.push(o[i]);r.push(o[o.length-1]);let n=[r[0]];for(let i=1;i<r.length-1;++i){let a=n[n.length-1],l=r[i],s=r[i+1],c=Ta(a,l),m=Ta(l,s);if(c!==m){let d=G2(a,l),p=G2(l,s);if(d<Pd||p<Pd){if(p<d)c?s[0]=a[0]:s[1]=a[1];else if(m)for(let u=n.length-1;u>=0&&n[u][0]===a[0];--u)n[u][0]=l[0];else for(let u=n.length-1;u>=0&&n[u][1]===a[1];--u)n[u][1]=l[1];continue}}n.push(l)}return n.push(r[r.length-1]),n},$T=e=>{if(e.length===0)return[];let o=[e[0]];for(let t=1;t<e.length;t++){let[r,n]=o[o.length-1],[i,a]=e[t];(r!==i||n!==a)&&o.push(e[t])}return o},Y2=(e,o,t)=>{if(!jT(e.type,o)){if(!y1())throw Error(`Invalid conversion from ${e.type} to ${o}.`);return e}if(e.type===o)return e;if(To.delete(e),Ca(o)){let r=kr(qt({...e,type:o,roundness:o==="diamond"&&e.roundness?{type:Kr(o)?ut.ADAPTIVE_RADIUS:ut.PROPORTIONAL_RADIUS}:e.roundness}));return jr(r,t.scene),r}if(Dd(o))switch(o){case"line":return kr(Co({...e,type:"line"}));case"sharpArrow":return kr(tn({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return kr(tn({...e,type:"arrow",elbowed:!1,roundness:{type:ut.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return kr(tn({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return Ii(o,`unhandled conversion type: ${o}`),e},jT=(e,o)=>!!(Ca(e)&&Ca(o)||Dd(e)&&Dd(o)),qT=e=>ge(e)?Kn(e):e.type,K2=VT;var Z2=B({name:"toggleShapeSwitch",label:"labels.shapeSwitch",icon:()=>null,viewMode:!0,trackEvent:{category:"shape_switch",action:"toggle"},keywords:["change","switch","swap"],perform(e,o,t,r){return wt.set(qo,{type:"panel"}),{captureUpdate:A.NEVER}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>ka(e)!==null});var Rd=B({name:"copyElementLink",label:"labels.copyElementLink",icon:oa,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n=q(e,o);try{if(window.location){let i=bc(n,o);return i?(await jo(r.props.generateLinkForSelection?r.props.generateLinkForSelection(i.id,i.type):fc(i.id,i.type)),{appState:{toast:{message:g("toast.elementLinkCopied"),closable:!0}},captureUpdate:A.EVENTUALLY}):{appState:o,elements:e,app:r,captureUpdate:A.EVENTUALLY}}}catch(i){console.error(i)}return{appState:o,elements:e,app:r,captureUpdate:A.EVENTUALLY}},predicate:(e,o)=>xc(q(e,o))}),X2=B({name:"linkToElement",label:"labels.linkToElement",icon:qc,perform:(e,o,t,r)=>{let n=q(e,o);return n.length!==1||!xc(n)?{elements:e,appState:o,app:r,captureUpdate:A.EVENTUALLY}:{appState:{...o,openDialog:{name:"elementLinkSelector",sourceElementId:q(e,o)[0].id}},captureUpdate:A.IMMEDIATELY}},predicate:(e,o,t,r)=>{let n=q(e,o);return o.openDialog?.name!=="elementLinkSelector"&&n.length===1&&xc(n)},trackEvent:!1});var JT={toggleTheme:[D("Shift+Alt+D")],saveScene:[D("CtrlOrCmd+S")],loadScene:[D("CtrlOrCmd+O")],imageExport:[D("CtrlOrCmd+Shift+E")],commandPalette:[D("CtrlOrCmd+/"),D("CtrlOrCmd+Shift+P")],cut:[D("CtrlOrCmd+X")],copy:[D("CtrlOrCmd+C")],paste:[D("CtrlOrCmd+V")],copyStyles:[D("CtrlOrCmd+Alt+C")],pasteStyles:[D("CtrlOrCmd+Alt+V")],selectAll:[D("CtrlOrCmd+A")],deleteSelectedElements:[D("Delete")],duplicateSelection:[D("CtrlOrCmd+D"),D(`Alt+${g("helpDialog.drag")}`)],sendBackward:[D("CtrlOrCmd+[")],bringForward:[D("CtrlOrCmd+]")],sendToBack:[Bo?D("CtrlOrCmd+Alt+["):D("CtrlOrCmd+Shift+[")],bringToFront:[Bo?D("CtrlOrCmd+Alt+]"):D("CtrlOrCmd+Shift+]")],copyAsPng:[D("Shift+Alt+C")],group:[D("CtrlOrCmd+G")],ungroup:[D("CtrlOrCmd+Shift+G")],gridMode:[D("CtrlOrCmd+'")],zenMode:[D("Alt+Z")],objectsSnapMode:[D("Alt+S")],stats:[D("Alt+/")],addToLibrary:[],flipHorizontal:[D("Shift+H")],flipVertical:[D("Shift+V")],viewMode:[D("Alt+R")],hyperlink:[D("CtrlOrCmd+K")],toggleElementLock:[D("CtrlOrCmd+Shift+L")],resetZoom:[D("CtrlOrCmd+0")],zoomOut:[D("CtrlOrCmd+-")],zoomIn:[D("CtrlOrCmd++")],zoomToFitSelection:[D("Shift+3")],zoomToFit:[D("Shift+1")],zoomToFitSelectionInViewport:[D("Shift+2")],toggleEraserTool:[D("E")],toggleHandTool:[D("H")],setFrameAsActiveTool:[D("F")],saveFileToDisk:[D("CtrlOrCmd+S")],saveToActiveFile:[D("CtrlOrCmd+S")],toggleShortcuts:[D("?")],searchMenu:[D("CtrlOrCmd+F")],wrapSelectionInFrame:[],arrangeElements:[D("Shift+R")]},We=(e,o=0)=>{let t=JT[e];return t&&t.length>0?t[o]||t[0]:""};var QT="\\u0300-\\u036f",eC="\\ufe20-\\ufe2f",tC="\\u20d0-\\u20ff",oC=QT+eC+tC,rC=`[${oC}]`,nC=RegExp(rC,"g"),iC=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,aC={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"E",\u00E6:"e",\u00DE:"T",\u00FE:"t",\u00DF:"s",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"I",\u0133:"i",\u0152:"E",\u0153:"e",\u0149:"n",\u017F:"s"},Ph=e=>e.replace(iC,o=>aC[o]||o).replace(nC,"");import Ck from"clsx";import{useEffect as kk,useState as Sk}from"react";import{useCallback as lC,useState as sC}from"react";var $2=()=>{let[e,o]=sC(null),t=lC(r=>o(r),[]);return[e,t]};import{useState as By,useCallback as Yh,useMemo as zy,useEffect as Ry,memo as Fy,useRef as bk}from"react";import{useEffect as Q2,useRef as ey}from"react";var xn=({elements:e,appState:o,files:t,maxWidthOrHeight:r,getDimensions:n,exportPadding:i,exportingFrame:a})=>{let{elements:l,appState:s}=Xi({elements:e,appState:o},null,null),{exportBackground:c,viewBackgroundColor:m}=s;return Ic(l,{...s,offsetTop:0,offsetLeft:0,width:0,height:0},t||{},{exportBackground:c,exportPadding:i,viewBackgroundColor:m,exportingFrame:a},(d,p)=>{let u=document.createElement("canvas");if(r){typeof n=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let b=Math.max(d,p),x=r<b?r/b:o?.exportScale??1;return u.width=d*x,u.height=p*x,{canvas:u,scale:x}}let f=n?.(d,p)||{width:d,height:p};return u.width=f.width,u.height=f.height,{canvas:u,scale:f.scale??1}})},j2=async e=>{let{mimeType:o=ue.png,quality:t}=e;o===ue.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${ue.png}" mimeType`),o==="image/jpg"&&(o=ue.jpg),o===ue.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${ue.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let r=await xn(e);return t=t||(/image\/jpe?g/.test(o)?.92:.8),new Promise((n,i)=>{r.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&o===ue.png&&e.appState?.exportEmbedScene&&(a=await ub({blob:a,metadata:xl(e.elements,e.appState,e.files||{},"local")})),n(a)},o,t)})},Sa=async({elements:e,appState:o=Vi(),files:t={},exportPadding:r,renderEmbeddables:n,exportingFrame:i,skipInliningFonts:a,reuseImages:l})=>{let{elements:s,appState:c}=Xi({elements:e,appState:o},null,null),m={...c,exportPadding:r};return Zi(s,m,t,{exportingFrame:i,renderEmbeddables:n,skipInliningFonts:a,reuseImages:l})},cC=async e=>{if(e.type==="svg"){let o=await Sa(e);await jo(o.outerHTML)}else if(e.type==="png")await wd(j2(e));else if(e.type==="json")await yd(e.elements,e.files);else throw new Error("Invalid export type")};import{useEffect as dC,useState as mC}from"react";var Dh=Ie(new Map),q2=async e=>await Sa({elements:e,appState:{exportBackground:!1,viewBackgroundColor:bo.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),J2=(e,o,t)=>{let[r,n]=mC();return dC(()=>{if(o)if(e){let i=t.get(e);i?n(i):(async()=>{let a=await q2(o);a.querySelector(".style-fonts")?.remove(),a&&(t.set(e,a),n(a))})()}else(async()=>{let i=await q2(o);n(i)})()},[e,o,t,n]),r},Nd=()=>{let[e]=Ee(Dh);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:r=>{r.forEach(n=>e.delete(n))},svgCache:e}};var pC=["excalidraw.com","raw.githubusercontent.com/excalidraw/excalidraw-libraries"],oy=new yo,ui=Ie({status:"loaded",isInitialized:!1,libraryItems:[]}),ts=e=>jt(e),uC=(e,o)=>!e.find(t=>t.elements.length!==o.elements.length?!1:t.elements.every((r,n)=>r.id===o.elements[n].id&&r.versionNonce===o.elements[n].versionNonce)),ry=(e,o)=>{let t=[];for(let r of o)uC(e,r)&&t.push(r);return[...t,...e]},ny=(e,o)=>{let t=j(o),r={deletedItems:new Map,addedItems:new Map};for(let i of e)t.has(i.id)||r.deletedItems.set(i.id,i);let n=j(e);for(let i of o)n.has(i.id)||r.addedItems.set(i.id,i);return r},Rh=class{constructor(o){k(this,"currLibraryItems",[]);k(this,"prevLibraryItems",ts(this.currLibraryItems));k(this,"app");k(this,"updateQueue",[]);k(this,"getLastUpdateTask",()=>this.updateQueue[this.updateQueue.length-1]);k(this,"notifyListeners",()=>{if(this.updateQueue.length>0)wt.set(ui,o=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:o.isInitialized}));else{wt.set(ui,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let o=this.prevLibraryItems;this.prevLibraryItems=ts(this.currLibraryItems);let t=ts(this.currLibraryItems);this.app.props.onLibraryChange?.(t),oy.trigger(ny(o,t),t)}catch(o){console.error(o)}}});k(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],wt.set(Dh,new Map)});k(this,"resetLibrary",()=>this.setLibrary([]));k(this,"getLatestLibrary",()=>new Promise(async o=>{try{let t=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?o(this.getLatestLibrary()):o(ts(t))}catch{return o(this.currLibraryItems)}}));k(this,"updateLibrary",async({libraryItems:o,prompt:t=!1,merge:r=!1,openLibraryMenu:n=!1,defaultStatus:i="unpublished"})=>(n&&this.app.setState({openSidebar:{name:Dt.name,tab:tl}}),this.setLibrary(()=>new Promise(async(a,l)=>{try{let s=await(typeof o=="function"&&!(o instanceof Blob)?o(this.currLibraryItems):o),c;s instanceof Blob?c=await qp(s,i):c=vl(s,i),!t||window.confirm(g("alerts.confirmAddLibrary",{numShapes:c.length}))?(t&&this.app.focusContainer(),a(r?ry(this.currLibraryItems,c):c)):l(new Wi)}catch(s){l(s)}}))));k(this,"setLibrary",o=>{let t=new Promise(async(r,n)=>{try{await this.getLastUpdateTask(),typeof o=="function"&&(o=o(this.currLibraryItems)),this.currLibraryItems=ts(await o),r(this.currLibraryItems)}catch(i){n(i)}}).catch(r=>{if(r.name==="AbortError")return console.warn("Library update aborted by user"),this.currLibraryItems;throw r}).finally(()=>{this.updateQueue=this.updateQueue.filter(r=>r!==t),this.notifyListeners()});return this.updateQueue.push(t),this.notifyListeners(),t});this.app=o}},iy=Rh,zd=e=>{let t=Math.ceil(Math.sqrt(e.length)),r=[],n=u=>e.slice(u*t,u*t+t).reduce((b,x)=>{let{height:E}=po(x.elements);return Math.max(b,E)},0),i=u=>{let f=0,b=0,x=0;for(let E of e){if(f%t===0&&(b=0),b===u){let{width:y}=po(E.elements);x=Math.max(x,y)}f++,b++}return x},a=0,l=0,s=0,c=0,m=0,d=0,p=0;for(let u of e){m&&m%t===0&&(l+=s+50,a=0,d=0,p++),d===0&&(s=n(p)),c=i(d);let{minX:f,minY:b,width:x,height:E}=po(u.elements),y=(c-x)/2,v=(s-E)/2;r.push(...u.elements.map(T=>({...T,x:T.x+a+y-f,y:T.y+l+v-b}))),a+=c+50,m++,d++}return r},hC=(e,o=pC)=>{if(typeof o=="function"?o(e):o.some(t=>{let r=new URL(`https://${t.replace(/^https?:\/\//,"")}`),{hostname:n,pathname:i}=new URL(e);return new RegExp(`(^|\\.)${r.hostname}$`).test(n)&&new RegExp(`^${r.pathname.replace(/\/+$/,"")}(/+|$)`).test(i)}))return!0;throw new Error(`Invalid or disallowed library URL: "${e}"`)},Nh=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(Rs.addLibrary)||new URLSearchParams(window.location.search).get(Ds.addLibrary),o=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:o}:null},En=class En{constructor(o){k(this,"adapter");this.adapter=o}static async getLibraryItems(o,t,r=!0){let n=()=>new Promise(async(i,a)=>{try{let l=await o.load({source:t});i(vl(l?.libraryItems||[],"published"))}catch(l){a(l)}});return r?En.queue.push(n):n()}getLibraryItems(o){return En.getLibraryItems(this.adapter,o,!1)}};k(En,"queue",new r1),k(En,"run",async(o,t)=>{let r=new En(o);return En.queue.push(()=>t(r))});var Ia=En,os=0,Od=0,Bd=e=>Gp(e.map(o=>`${o.id}:${Up(o.elements)}`).sort().join()),ty=async(e,o)=>{try{return Od++,await Ia.run(e,async t=>{let r=j(await t.getLibraryItems("save"));for(let[l]of o.deletedItems)r.delete(l);let n=[];for(let[l,s]of o.addedItems)r.has(l)?r.set(l,s):n.push(s);let i=n.concat(Array.from(r.values())),a=Bd(i);return a!==os&&await e.save({libraryItems:i}),os=a,i})}finally{Od--}},gC=e=>{let{excalidrawAPI:o}=e,t=ey(e);t.current=e;let r=ey(!1);Q2(()=>{if(!o)return;r.current=!1;let n=async({libraryUrl:l,idToken:s})=>{let c=new Promise(async(d,p)=>{try{l=decodeURIComponent(l),l=$s(l),hC(l,t.current.validateLibraryUrl);let f=await(await fetch(l)).blob();d(f)}catch(u){p(u)}}),m=s!==o.id;await(m&&document.hidden?new Promise(d=>{window.addEventListener("focus",()=>d(),{once:!0})}):null);try{await o.updateLibrary({libraryItems:c,prompt:m,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(d){throw o.updateScene({appState:{errorMessage:d.message}}),d}finally{if(window.location.hash.includes(Rs.addLibrary)){let d=new URLSearchParams(window.location.hash.slice(1));d.delete(Rs.addLibrary),window.history.replaceState({},$a,`#${d.toString()}`)}else if(window.location.search.includes(Ds.addLibrary)){let d=new URLSearchParams(window.location.search);d.delete(Ds.addLibrary),window.history.replaceState({},$a,`?${d.toString()}`)}}},i=l=>{l.preventDefault();let s=Nh();s&&(l.stopImmediatePropagation(),window.history.replaceState({},"",l.oldURL),n(s))},a=Nh();if(a&&n(a),"getInitialLibraryItems"in t.current&&t.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(t.current.getInitialLibraryItems()).then(l=>{o.updateLibrary({libraryItems:l,merge:!0})}).catch(l=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${l?.message}`)})),"adapter"in t.current&&t.current.adapter){let l=t.current.adapter,s=t.current.migrationAdapter,c=g1();s?c.resolve(hp(s.load).then(async m=>{let d=null;try{if(!m)return Ia.getLibraryItems(l,"load");d=vl(m.libraryItems||[],"published");let p=await ty(l,ny([],d));try{await s.clear()}catch(u){console.error(`couldn't delete legacy library data: ${u.message}`)}return p}catch(p){return console.error(`couldn't migrate legacy library data: ${p.message}`),d}}).catch(m=>(console.error(`error during library migration: ${m.message}`),Ia.getLibraryItems(l,"load")))):c.resolve(hp(Ia.getLibraryItems,l,"load")),o.updateLibrary({libraryItems:c.then(m=>{let d=m||[];return os=Bd(d),d}),merge:!0}).finally(()=>{r.current=!0})}return window.addEventListener("hashchange",i),()=>{window.removeEventListener("hashchange",i)}},[o]),Q2(()=>{let n=oy.on(async(a,l)=>{let s=r.current,c="adapter"in t.current&&t.current.adapter||null;try{c&&os!==Bd(l)&&await ty(c,a)}catch(m){console.error(`couldn't persist library update: ${m.message}`,a),s&&t.current.excalidrawAPI&&t.current.excalidrawAPI.updateScene({appState:{errorMessage:g("errors.saveLibraryError")}})}}),i=a=>{Od&&x1(a)};return window.addEventListener("beforeunload",i),()=>{window.removeEventListener("beforeunload",i),n(),os=0,Od=0}},[])};import xC from"clsx";import{jsx as bC}from"react/jsx-runtime";var fC=({theme:e,id:o,libraryReturnUrl:t})=>{let r=t||window.location.origin+window.location.pathname;return bC("a",{className:"library-menu-browse-button",href:`${C.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${r}&useHash=true&token=${o}&theme=${e}&version=${Os.excalidrawLibrary}`,target:"_excalidraw_libraries",children:g("labels.libraries")})},ay=fC;import{jsx as EC,jsxs as yC}from"react/jsx-runtime";var Fd=({libraryReturnUrl:e,theme:o,id:t,style:r,children:n,className:i})=>yC("div",{className:xC("library-menu-control-buttons",i),style:r,children:[EC(ay,{id:t,libraryReturnUrl:e,theme:o}),n]});import{useCallback as Aa,useEffect as pk,useMemo as Py,useRef as uk,useState as hk}from"react";import vC from"lodash.throttle";import{useEffect as wC}from"react";var TC=Ie(0),ly=e=>{let[o,t]=Ee(TC);return wC(()=>{let{current:r}=e;if(!r)return;let n=vC(()=>{let{scrollTop:i}=r;t(i)},200);return r.addEventListener("scroll",n),()=>{n.cancel(),r.removeEventListener("scroll",n)}},[e,t]),o};import jC from"clsx";import{useCallback as qC,useState as zh}from"react";import{flushSync as sy}from"react-dom";import CC from"clsx";import{jsx as Hd,jsxs as SC}from"react/jsx-runtime";var kC=({label:e,onClick:o,className:t,children:r,actionType:n,type:i="button",isLoading:a,...l})=>{let s=n?`Dialog__action-button--${n}`:"";return SC("button",{className:CC("Dialog__action-button",s,t),type:i,"aria-label":e,onClick:o,...l,children:[r&&Hd("div",{style:a?{visibility:"hidden"}:{},children:r}),Hd("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&Hd("div",{style:{position:"absolute",inset:0},children:Hd(At,{})})]})},Pr=kC;import{jsx as cy,jsxs as dy}from"react/jsx-runtime";var IC=e=>{let{onConfirm:o,onCancel:t,children:r,confirmText:n=g("buttons.confirm"),cancelText:i=g("buttons.cancel"),className:a="",...l}=e,s=ve(),c=$i(Ma),{container:m}=st();return dy(ot,{onCloseRequest:t,size:"small",...l,className:`confirm-dialog ${a}`,children:[r,dy("div",{className:"confirm-dialog-buttons",children:[cy(Pr,{label:i,onClick:()=>{s({openMenu:null}),c(!1),sy(()=>{t()}),m?.focus()}}),cy(Pr,{label:n,onClick:()=>{s({openMenu:null}),c(!1),sy(()=>{o()}),m?.focus()},actionType:"danger"})]})]})},my=IC;import Gd from"open-color";import{useCallback as RC,useEffect as Bh,useRef as py,useState as Oh}from"react";var _o=class{static has(o){try{return!!window.localStorage.getItem(o)}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),!1}}static get(o){try{let t=window.localStorage.getItem(o);return t?JSON.parse(t):null}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),null}}};k(_o,"set",(o,t)=>{try{return window.localStorage.setItem(o,JSON.stringify(t)),!0}catch(r){return console.warn(`localStorage.setItem error: ${r.message}`),!1}}),k(_o,"delete",o=>{try{window.localStorage.removeItem(o)}catch(t){console.warn(`localStorage.removeItem error: ${t.message}`)}});import Ud from"react";var MC=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,LC=/{{([\w-]+)}}/,AC=/<([\w-]+)>/,_C=/<\/([\w-]+)>/,PC=(e,o)=>{let t=[{name:"",children:[]}];return e.split(MC).filter(Boolean).forEach(r=>{let n=r.match(AC),i=r.match(_C),a=r.match(LC);if(n!==null){let l=n[1];o.hasOwnProperty(l)?t.push({name:l,children:[]}):console.warn(`Trans: missed to pass in prop ${l} for interpolating ${e}`)}else if(i!==null)if(i[1]===t[t.length-1].name){let s=t.pop(),c=Ud.createElement(Ud.Fragment,{},...s.children),m=o[s.name];typeof m=="function"&&t[t.length-1].children.push(m(c))}else console.warn(`Trans: unexpected end tag ${r} for interpolating ${e}`);else if(a!==null){let l=a[1];o.hasOwnProperty(l)?t[t.length-1].children.push(o[l]):console.warn(`Trans: key ${l} not in props for interpolating ${e}`)}else t[t.length-1].children.push(r)}),t.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),t[0].children},DC=({i18nKey:e,children:o,...t})=>{let{t:r}=lt();return Ud.createElement(Ud.Fragment,{},...PC(r(e),t))},Gt=DC;import{jsx as be,jsxs as Ot}from"react/jsx-runtime";var NC=async e=>{let r=Math.round(8),n=Math.max(Math.round(128/64),2),i=u1(e,6),a=document.createElement("canvas");a.width=i[0].length*128+(i[0].length+1)*(r*2)-r*2,a.height=i.length*128+(i.length+1)*(r*2)-r*2;let l=a.getContext("2d");l.fillStyle=Gd.white,l.fillRect(0,0,a.width,a.height);for(let[s,c]of e.entries()){let m=await xn({elements:c.elements,files:null,maxWidthOrHeight:128}),{width:d,height:p}=m,u=Math.floor(s/6)*(128+r*2),f=s%6*(128+r*2);l.drawImage(m,f+(128-d)/2+r,u+(128-p)/2+r),l.lineWidth=n,l.strokeStyle=Gd.gray[4],l.strokeRect(f+r/2,u+r/2,128+r,128+r)}return await Ac(new File([await Sr(a)],"preview",{type:ue.png}),{outputType:ue.jpg,maxWidthOrHeight:5e3})},OC=({libItem:e,appState:o,index:t,onChange:r,onRemove:n})=>{let i=py(null),a=py(null);return Bh(()=>{let l=i.current;l&&(async()=>{let s=await Sa({elements:e.elements,appState:{...o,viewBackgroundColor:Gd.white,exportBackground:!0},files:null,skipInliningFonts:!0});l.innerHTML=s.outerHTML})()},[e.elements,o]),Ot("div",{className:"single-library-item",children:[e.status==="published"&&be("span",{className:"single-library-item-status",children:g("labels.statusPublished")}),be("div",{ref:i,className:"single-library-item__svg"}),be(K,{"aria-label":g("buttons.remove"),type:"button",icon:ko,className:"single-library-item--remove",onClick:n.bind(null,e.id),title:g("buttons.remove")}),Ot("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[Ot("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[Ot("div",{style:{padding:"0.5em 0"},children:[be("span",{style:{fontWeight:500,color:Gd.gray[6]},children:g("publishDialog.itemName")}),be("span",{"aria-hidden":"true",className:"required",children:"*"})]}),be("input",{type:"text",ref:a,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:l=>{r(l.target.value,t)}})]}),be("span",{className:"error",children:e.error})]})]})},BC=({onClose:e,libraryItems:o,appState:t,onSuccess:r,onError:n,updateItemsInStorage:i,onRemove:a})=>{let[l,s]=Oh({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[c,m]=Oh(!1);Bh(()=>{let v=_o.get(Gr.PUBLISH_LIBRARY);v&&s(v)},[]);let[d,p]=Oh(o.slice());Bh(()=>{p(o.slice())},[o]);let u=v=>{s({...l,[v.target.name]:v.target.value})},f=async v=>{v.preventDefault(),m(!0);let T=[],I=!1;if(d.forEach(z=>{let W="";z.name||(W=g("publishDialog.errors.required"),I=!0),T.push({...z,error:W})}),I){p(T),m(!1);return}let S=await NC(d),P={type:Hr.excalidrawLibrary,version:Os.excalidrawLibrary,source:Uf(),libraryItems:d},M=JSON.stringify(P,null,2),O=new Blob([M],{type:"application/json"}),R=new FormData;R.append("excalidrawLib",O),R.append("previewImage",S),R.append("previewImageType",S.type),R.append("title",l.name),R.append("authorName",l.authorName),R.append("githubHandle",l.githubHandle),R.append("name",l.name),R.append("description",l.description),R.append("twitterHandle",l.twitterHandle),R.append("website",l.website),fetch(`${C.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:R}).then(z=>z.ok?z.json().then(({url:W})=>{_o.delete(Gr.PUBLISH_LIBRARY),r({url:W,authorName:l.authorName,items:d})}):z.json().catch(()=>{throw new Error(z.statusText||"something went wrong")}).then(W=>{throw new Error(W.message||z.statusText||"something went wrong")}),z=>{console.error(z),n(z),m(!1)}).catch(z=>{console.error(z),n(z),m(!1)})},b=()=>{let v=[];return d.forEach((T,I)=>{v.push(be("div",{className:"single-library-item-wrapper",children:be(OC,{libItem:T,appState:t,index:I,onChange:(S,P)=>{let M=d.slice();M[P].name=S,p(M)},onRemove:a})},I))}),be("div",{className:"selected-library-items",children:v})},x=RC(()=>{i(d),_o.set(Gr.PUBLISH_LIBRARY,l),e()},[d,e,i,l]),E=!!o.length,y=o.some(v=>v.status==="published");return be(ot,{onCloseRequest:x,title:g("publishDialog.title"),className:"publish-library",children:E?Ot("form",{onSubmit:f,children:[be("div",{className:"publish-library-note",children:be(Gt,{i18nKey:"publishDialog.noteDescription",link:v=>be("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener",children:v})})}),be("span",{className:"publish-library-note",children:be(Gt,{i18nKey:"publishDialog.noteGuidelines",link:v=>be("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:v})})}),be("div",{className:"publish-library-note",children:g("publishDialog.noteItems")}),y&&be("span",{className:"publish-library-note publish-library-warning",children:g("publishDialog.republishWarning")}),b(),Ot("div",{className:"publish-library__fields",children:[Ot("label",{children:[Ot("div",{children:[be("span",{children:g("publishDialog.libraryName")}),be("span",{"aria-hidden":"true",className:"required",children:"*"})]}),be("input",{type:"text",name:"name",required:!0,value:l.name,onChange:u,placeholder:g("publishDialog.placeholder.libraryName")})]}),Ot("label",{style:{alignItems:"flex-start"},children:[Ot("div",{children:[be("span",{children:g("publishDialog.libraryDesc")}),be("span",{"aria-hidden":"true",className:"required",children:"*"})]}),be("textarea",{name:"description",rows:4,required:!0,value:l.description,onChange:u,placeholder:g("publishDialog.placeholder.libraryDesc")})]}),Ot("label",{children:[Ot("div",{children:[be("span",{children:g("publishDialog.authorName")}),be("span",{"aria-hidden":"true",className:"required",children:"*"})]}),be("input",{type:"text",name:"authorName",required:!0,value:l.authorName,onChange:u,placeholder:g("publishDialog.placeholder.authorName")})]}),Ot("label",{children:[be("span",{children:g("publishDialog.githubUsername")}),be("input",{type:"text",name:"githubHandle",value:l.githubHandle,onChange:u,placeholder:g("publishDialog.placeholder.githubHandle")})]}),Ot("label",{children:[be("span",{children:g("publishDialog.twitterUsername")}),be("input",{type:"text",name:"twitterHandle",value:l.twitterHandle,onChange:u,placeholder:g("publishDialog.placeholder.twitterHandle")})]}),Ot("label",{children:[be("span",{children:g("publishDialog.website")}),be("input",{type:"text",name:"website",pattern:"https?://.+",title:g("publishDialog.errors.website"),value:l.website,onChange:u,placeholder:g("publishDialog.placeholder.website")})]}),be("span",{className:"publish-library-note",children:be(Gt,{i18nKey:"publishDialog.noteLicense",link:v=>be("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:v})})})]}),Ot("div",{className:"publish-library__buttons",children:[be(Pr,{label:g("buttons.cancel"),onClick:x,"data-testid":"cancel-clear-canvas-button"}),be(Pr,{type:"submit",label:g("buttons.submit"),actionType:"primary",isLoading:c})]})]}):be("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:g("publishDialog.atleastOneLibItem")})})},uy=BC;import HC from"clsx";import{useEffect as UC,useRef as GC}from"react";import{forwardRef as hy}from"react";import gy from"clsx";import{jsx as fy}from"react/jsx-runtime";var zC=hy(({children:e,gap:o,align:t,justifyContent:r,className:n,style:i},a)=>fy("div",{className:gy("Stack Stack_horizontal",n),style:{"--gap":o,alignItems:t,justifyContent:r,...i},ref:a,children:e})),FC=hy(({children:e,gap:o,align:t,justifyContent:r,className:n,style:i},a)=>fy("div",{className:gy("Stack Stack_vertical",n),style:{"--gap":o,justifyItems:t,justifyContent:r,...i},ref:a,children:e})),Tt={Row:zC,Col:FC};import{jsx as Yd}from"react/jsx-runtime";var by=({children:e,onClickOutside:o,className:t="",onSelect:r,style:n})=>{let i=xe(),a=GC(null),l=dn({onClickOutside:o});aa(a,()=>{l.onClickOutside?.()}),UC(()=>{let c=d=>{d.key===w.ESCAPE&&(d.stopImmediatePropagation(),l.onClickOutside?.())},m={capture:!0};return document.addEventListener("keydown",c,m),()=>{document.removeEventListener("keydown",c,m)}},[l]);let s=HC(`dropdown-menu ${t}`,{"dropdown-menu--mobile":i.editor.isMobile}).trim();return Yd(Vu.Provider,{value:{onSelect:r},children:Yd("div",{ref:a,className:s,style:n,"data-testid":"dropdown-menu",children:i.editor.isMobile?Yd(Tt.Col,{className:"dropdown-menu-container",children:e}):Yd(xt,{className:"dropdown-menu-container",padding:2,style:{zIndex:2},children:e})})})};by.displayName="DropdownMenuContent";var xy=by;import{jsx as WC}from"react/jsx-runtime";var YC=({children:e,className:o="",selected:t,...r})=>WC("div",{...r,className:`dropdown-menu-item-base dropdown-menu-item-custom ${o} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),Ey=YC;import{jsx as yy}from"react/jsx-runtime";var vy=({icon:e,shortcut:o,href:t,children:r,onSelect:n,className:i="",selected:a,rel:l="noopener",...s})=>{let c=dd(s.onClick,n);return yy("a",{...s,href:t,target:"_blank",rel:l||"noopener",className:cd(i,a),title:s.title??s["aria-label"],onClick:c,children:yy(sd,{icon:e,shortcut:o,children:r})})},La=vy;vy.displayName="DropdownMenuItemLink";import{jsx as VC}from"react/jsx-runtime";var wy=()=>VC("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0"}}),Ty=wy;wy.displayName="DropdownMenuSeparator";import KC from"clsx";import{jsx as ZC}from"react/jsx-runtime";var Cy=({className:e="",children:o,onToggle:t,title:r,...n})=>{let i=xe(),a=KC(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.editor.isMobile}).trim();return ZC("button",{"data-prevent-outside-click":!0,className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:r,...n,children:o})},ky=Cy;Cy.displayName="DropdownMenuTrigger";import Wd from"react";var Sy=e=>{let o=Wd.Children.toArray(e).find(t=>Wd.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuTrigger");return o||null},Iy=e=>{let o=Wd.Children.toArray(e).find(t=>Wd.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuContent");return o||null};import{Fragment as XC,jsxs as $C}from"react/jsx-runtime";var Dr=({children:e,open:o})=>{let t=Sy(e),r=Iy(e);return $C(XC,{children:[t,o&&r]})};Dr.Trigger=ky;Dr.Content=xy;Dr.Item=Qt;Dr.ItemLink=La;Dr.ItemCustom=Ey;Dr.Group=zl;Dr.Separator=Ty;var Oe=Dr;Dr.displayName="DropdownMenu";import{jsx as oo,jsxs as Vd}from"react/jsx-runtime";var JC=(e,o)=>e.filter(t=>o.includes(t.id)),QC=({setAppState:e,selectedItems:o,library:t,onRemoveFromLibrary:r,resetLibrary:n,onSelectItems:i,appState:a,className:l})=>{let[s]=Ee(ui),[c,m]=Ee(Ma),d=()=>{let R=o.length?g("alerts.removeItemsFromsLibrary",{count:o.length}):g("alerts.resetLibrary"),z=o.length?g("confirmDialog.removeItemsFromLib"):g("confirmDialog.resetLibrary");return oo(my,{onConfirm:()=>{o.length?r():n(),u(!1)},onCancel:()=>{u(!1)},title:z,children:oo("p",{children:R})})},[p,u]=zh(!1),f=!!o.length,b=f?s.libraryItems.filter(R=>o.includes(R.id)):s.libraryItems,x=f?g("buttons.remove"):g("buttons.resetLibrary"),[E,y]=zh(!1),[v,T]=zh(null),I=qC(()=>Vd(ot,{onCloseRequest:()=>T(null),title:g("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[oo("p",{children:oo(Gt,{i18nKey:"publishSuccessDialog.content",authorName:v.authorName,link:R=>oo("a",{href:v?.url,target:"_blank",rel:"noopener noreferrer",children:R})})}),oo(K,{type:"button",title:g("buttons.close"),"aria-label":g("buttons.close"),label:g("buttons.close"),onClick:()=>T(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[T,v]),S=(R,z)=>{y(!1),T({url:R.url,authorName:R.authorName});let W=z.slice();W.forEach(Y=>{o.includes(Y.id)&&(Y.status="published")}),t.setLibrary(W)},P=async()=>{try{await t.updateLibrary({libraryItems:wc({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(R){if(R?.name==="AbortError"){console.warn(R);return}e({errorMessage:g("errors.importLibraryError")})}},M=async()=>{let R=f?b:await t.getLatestLibrary();nb(R).catch(Gs).catch(z=>{e({errorMessage:z.message})})},O=()=>Vd(Oe,{open:c,children:[oo(Oe.Trigger,{onToggle:()=>m(!c),children:Pb}),Vd(Oe.Content,{onClickOutside:()=>m(!1),onSelect:()=>m(!1),className:"library-menu",children:[!f&&oo(Oe.Item,{onSelect:P,icon:ta,"data-testid":"lib-dropdown--load",children:g("buttons.load")}),!!b.length&&oo(Oe.Item,{onSelect:M,icon:ti,"data-testid":"lib-dropdown--export",children:g("buttons.export")}),!!b.length&&oo(Oe.Item,{onSelect:()=>u(!0),icon:Lr,children:x}),f&&oo(Oe.Item,{icon:Hx,onSelect:()=>y(!0),"data-testid":"lib-dropdown--remove",children:g("buttons.publishLibrary")})]})]});return Vd("div",{className:jC("library-menu-dropdown-container",l),children:[O(),o.length>0&&oo("div",{className:"library-actions-counter",children:o.length}),p&&d(),E&&oo(uy,{onClose:()=>y(!1),libraryItems:JC(s.libraryItems,o),appState:a,onSuccess:R=>S(R,s.libraryItems),onError:R=>window.alert(R),updateItemsInStorage:()=>t.setLibrary(s.libraryItems),onRemove:R=>i(o.filter(z=>z!==R))}),v&&I()]})},Fh=({selectedItems:e,onSelectItems:o,className:t})=>{let{library:r}=tt(),{clearLibraryCache:n,deleteItemsFromLibraryCache:i}=Nd(),a=Me(),l=ve(),[s]=Ee(ui),c=async d=>{let p=d.filter(u=>!e.includes(u.id));r.setLibrary(p).catch(()=>{l({errorMessage:g("alerts.errorRemovingFromLibrary")})}),i(e),o([])};return oo(QC,{appState:a,setAppState:l,selectedItems:e,onSelectItems:o,library:r,onRemoveFromLibrary:()=>c(s.libraryItems),resetLibrary:()=>{r.resetLibrary(),n()},className:t})};import{memo as sk,useEffect as ck,useState as dk}from"react";import ek,{useCallback as tk}from"react";function ok(){return[!1,tk(o=>o(),[])]}var My=ek.useTransition||ok;import Ly from"clsx";import{memo as rk,useEffect as nk,useRef as ik,useState as ak}from"react";import{jsx as Kd,jsxs as lk}from"react/jsx-runtime";var Ay=rk(({id:e,elements:o,isPending:t,onClick:r,selected:n,onToggle:i,onDrag:a,svgCache:l})=>{let s=ik(null),c=J2(e,o,l);nk(()=>{let f=s.current;if(f)return c&&(f.innerHTML=c.outerHTML),()=>{f.innerHTML=""}},[c]);let[m,d]=ak(!1),p=xe().editor.isMobile,u=t&&Kd("div",{className:"library-unit__adder",children:_b});return lk("div",{className:Ly("library-unit",{"library-unit__active":o,"library-unit--hover":o&&m,"library-unit--selected":n,"library-unit--skeleton":!c}),onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[Kd("div",{className:Ly("library-unit__dragger",{"library-unit__pulse":!!t}),ref:s,draggable:!!o,onClick:o||t?f=>{e&&f.shiftKey?i(e,f):r(e)}:void 0,onDragStart:f=>{if(!e){f.preventDefault();return}d(!1),a(e,f)}}),u,e&&o&&(m||p||n)&&Kd(Yl,{checked:n,onChange:(f,b)=>i(e,b),className:"library-unit__checkbox"})]})}),_y=()=>Kd("div",{className:"library-unit library-unit--skeleton"});import{Fragment as mk,jsx as Zd}from"react/jsx-runtime";var Hh=({children:e})=>Zd("div",{className:"library-menu-items-container__grid",children:e}),Xd=sk(({items:e,onItemSelectToggle:o,onItemDrag:t,isItemSelected:r,onClick:n,svgCache:i,itemsRenderedPerBatch:a})=>{let[,l]=My(),[s,c]=dk(0);return ck(()=>{s<e.length&&l(()=>{c(s+a)})},[s,e.length,l,a]),Zd(mk,{children:e.map((m,d)=>d<s?Zd(Ay,{elements:m?.elements,isPending:!m?.id&&!!m?.elements,onClick:n,svgCache:i,id:m?.id,selected:r(m.id),onToggle:o,onDrag:t},m?.id??d):Zd(_y,{},d))})});import{Fragment as Dy,jsx as ro,jsxs as _a}from"react/jsx-runtime";var gk=17,fk=64;function Uh({isLoading:e,libraryItems:o,onAddToLibrary:t,onInsertLibraryItems:r,pendingElements:n,theme:i,id:a,libraryReturnUrl:l,onSelectItems:s,selectedItems:c}){let m=uk(null),d=ly(m);pk(()=>{d>0&&m.current?.scrollTo(0,d)},[]);let{svgCache:p}=Nd(),u=Py(()=>o.filter(R=>R.status!=="published"),[o]),f=Py(()=>o.filter(R=>R.status==="published"),[o]),b=!o.length&&!n.length,x=!n.length&&!u.length&&!f.length,[E,y]=hk(null),v=Aa((R,z)=>{let W=!c.includes(R),Y=[...u,...f];if(W){if(z.shiftKey&&E){let oe=Y.findIndex(ie=>ie.id===E),H=Y.findIndex(ie=>ie.id===R);if(oe===-1||H===-1){s([...c,R]);return}let F=j(c),ee=Y.reduce((ie,X,de)=>((de>=oe&&de<=H||F.has(X.id))&&ie.push(X.id),ie),[]);s(ee)}else s([...c,R]);y(R)}else y(null),s(c.filter(oe=>oe!==R))},[E,s,f,c,u]),T=Aa(R=>{let z;return c.includes(R)?z=o.filter(W=>c.includes(W.id)):z=o.filter(W=>W.id===R),z.map(W=>({...W,elements:qn({type:"everything",elements:W.elements,randomizeSeed:!0}).duplicatedElements}))},[o,c]),I=Aa((R,z)=>{z.dataTransfer.setData(ue.excalidrawlib,Xp(T(R)))},[T]),S=Aa(R=>R?c.includes(R):!1,[c]),P=Aa(()=>{t(n)},[n,t]),M=Aa(R=>{R&&r(T(R))},[T,r]),O=p.size>=o.length?fk:gk;return _a("div",{className:"library-menu-items-container",style:n.length||u.length||f.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[!x&&ro(Fh,{selectedItems:c,onSelectItems:s,className:"library-menu-dropdown-container--in-heading"}),_a(Tt.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:f.length>0?1:"0 1 auto",marginBottom:0},ref:m,children:[_a(Dy,{children:[!x&&ro("div",{className:"library-menu-items-container__header",children:g("labels.personalLib")}),e&&ro("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:ro(At,{})}),!n.length&&!u.length?_a("div",{className:"library-menu-items__no-items",children:[ro("div",{className:"library-menu-items__no-items__label",children:g("library.noItems")}),ro("div",{className:"library-menu-items__no-items__hint",children:f.length>0?g("library.hint_emptyPrivateLibrary"):g("library.hint_emptyLibrary")})]}):_a(Hh,{children:[n.length>0&&ro(Xd,{itemsRenderedPerBatch:O,items:[{id:null,elements:n}],onItemSelectToggle:v,onItemDrag:I,onClick:P,isItemSelected:S,svgCache:p}),ro(Xd,{itemsRenderedPerBatch:O,items:u,onItemSelectToggle:v,onItemDrag:I,onClick:M,isItemSelected:S,svgCache:p})]})]}),_a(Dy,{children:[(f.length>0||n.length>0||u.length>0)&&ro("div",{className:"library-menu-items-container__header library-menu-items-container__header--excal",children:g("labels.excalidrawLib")}),f.length>0?ro(Hh,{children:ro(Xd,{itemsRenderedPerBatch:O,items:f,onItemSelectToggle:v,onItemDrag:I,onClick:M,isItemSelected:S,svgCache:p})}):u.length>0?ro("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",fontSize:".9rem"},children:g("library.noItems")}):null]}),b&&ro(Fd,{style:{padding:"16px 0",width:"100%"},id:a,libraryReturnUrl:l,theme:i,children:ro(Fh,{selectedItems:c,onSelectItems:s})})]})]})}import{jsx as yn,jsxs as Oy}from"react/jsx-runtime";var Ma=Ie(!1),Ny=({children:e})=>yn("div",{className:"layer-ui__library",children:e}),xk=Fy(({onInsertLibraryItems:e,pendingElements:o,onAddToLibrary:t,setAppState:r,libraryReturnUrl:n,library:i,id:a,theme:l,selectedItems:s,onSelectItems:c})=>{let[m]=Ee(ui),d=Yh(f=>{(async(x,E)=>{me("element","addToLibrary","ui");for(let v of zs)if(x.some(T=>T.type===v))return r({errorMessage:g(`errors.libraryElementTypeError.${v}`)});let y=[{status:"unpublished",elements:x,id:mo(),created:Date.now()},...E];t(),i.setLibrary(y).catch(()=>{r({errorMessage:g("alerts.errorAddingToLibrary")})})})(f,m.libraryItems)},[t,i,r,m.libraryItems]),p=zy(()=>m.libraryItems,[m]);if(m.status==="loading"&&!m.isInitialized)return yn(Ny,{children:yn("div",{className:"layer-ui__library-message",children:Oy("div",{children:[yn(At,{size:"2em"}),yn("span",{children:g("labels.libraryLoadingMessage")})]})})});let u=m.libraryItems.length>0||o.length>0;return Oy(Ny,{children:[yn(Uh,{isLoading:m.status==="loading",libraryItems:p,onAddToLibrary:d,onInsertLibraryItems:e,pendingElements:o,id:a,libraryReturnUrl:n,theme:l,onSelectItems:c,selectedItems:s}),u&&yn(Fd,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:a,libraryReturnUrl:n,theme:l})]})}),Gh=(e,o)=>({elements:e,pending:q(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:o}),Ek=(e,o)=>{let t=pn(),[r,n]=By(()=>Gh(t,e.selectedElementIds)),i=bk(new Map);return Ry(()=>{for(let a of r.pending)i.current.set(a.id,a.version)},[r.pending]),Ry(()=>{o.state.cursorButton==="up"&&o.state.activeTool.type==="selection"&&n(a=>{if(!nt(a.selectedElementIds,e.selectedElementIds))return i.current.clear(),Gh(t,e.selectedElementIds);let l=o.scene.getNonDeletedElementsMap();for(let s of Object.keys(e.selectedElementIds)){let c=l.get(s)?.version;if(c&&c!==i.current.get(s))return Gh(t,e.selectedElementIds)}return a})},[o,o.state.cursorButton,o.state.activeTool.type,e.selectedElementIds,t]),r.pending},Hy=Fy(()=>{let e=tt(),{onInsertElements:o}=e,t=cr(),r=Me(),n=ve(),[i,a]=By([]),l=zy(()=>e.library,[e.library]),s=Ek(r,e),c=Yh(d=>{o(zd(d))},[o]),m=Yh(()=>{n({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[n]);return yn(xk,{pendingElements:s,onInsertLibraryItems:c,onAddToLibrary:m,setAppState:n,libraryReturnUrl:t.libraryReturnUrl,library:l,id:e.id,theme:r.theme,selectedItems:i,onSelectItems:a})});import yk from"clsx";import{useRef as vk}from"react";import{createPortal as wk}from"react-dom";import{jsx as Uy,jsxs as Tk}from"react/jsx-runtime";var Gy=e=>{let{closeOnClickOutside:o=!0}=e,t=td({className:"excalidraw-modal-container"}),r=vk(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let n=i=>{i.key===w.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return wk(Tk("div",{className:yk("Modal",e.className,{"animations-disabled":r.current}),role:"dialog","aria-modal":"true",onKeyDown:n,"aria-labelledby":e.labelledBy,"data-prevent-outside-click":!0,children:[Uy("div",{className:"Modal__background",onClick:o?e.onCloseRequest:void 0}),Uy("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as $d,jsxs as Yy}from"react/jsx-runtime";function Ik(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var ot=e=>{let[o,t]=$2(),[r]=Sk(document.activeElement),{id:n}=st(),i=xe().viewport.isMobile;kk(()=>{if(!o)return;let c=ll(o);setTimeout(()=>{c.length>0&&e.autofocus!==!1&&(c[1]||c[0]).focus()});let m=d=>{if(d.key===w.TAB){let p=ll(o),{activeElement:u}=document,f=p.findIndex(b=>b===u);f===0&&d.shiftKey?(p[p.length-1].focus(),d.preventDefault()):f===p.length-1&&!d.shiftKey&&(p[0].focus(),d.preventDefault())}};return o.addEventListener("keydown",m),()=>o.removeEventListener("keydown",m)},[o,e.autofocus]);let a=ve(),l=$i(Ma),s=()=>{a({openMenu:null}),l(!1),r.focus(),e.onCloseRequest()};return $d(Gy,{className:Ck("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:Ik(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,children:Yy(xt,{ref:t,children:[e.title&&Yy("h2",{id:`${n}-dialog-title`,className:"Dialog__title",children:[$d("span",{className:"Dialog__titleContent",children:e.title}),e.titleButton]}),i&&$d("button",{className:"Dialog__close",onClick:s,title:g("buttons.close"),"aria-label":g("buttons.close"),type:"button",children:ko}),$d("div",{className:"Dialog__content",children:e.children})]})})};import Wh from"clsx";import{forwardRef as Ak,useRef as _k,useImperativeHandle as Pk,useLayoutEffect as Dk,useState as Rk}from"react";import Mk from"clsx";import{jsx as Lk}from"react/jsx-runtime";var go=({type:e="button",onSelect:o,selected:t,children:r,className:n="",...i})=>Lk("button",{onClick:Vr(i.onClick,a=>{o()}),type:e,className:Mk("excalidraw-button",n,{selected:t}),...i,children:r});import{jsx as Vh,jsxs as Wy}from"react/jsx-runtime";var Pa=Ak(({onChange:e,label:o,fullWidth:t,placeholder:r,readonly:n,selectOnRender:i,onKeyDown:a,isRedacted:l=!1,icon:s,className:c,...m},d)=>{let p=_k(null);Pk(d,()=>p.current),Dk(()=>{i&&(p.current?.focus(),p.current?.select())},[i]);let[u,f]=Rk(!1);return Wy("div",{className:Wh("ExcTextField",c,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!s}),onClick:()=>{p.current?.focus()},children:[s,o&&Vh("div",{className:"ExcTextField__label",children:o}),Wy("div",{className:Wh("ExcTextField__input",{"ExcTextField__input--readonly":n}),children:[Vh("input",{className:Wh({"is-redacted":"value"in m&&m.value&&l&&!u}),readOnly:n,value:"value"in m?m.value:void 0,defaultValue:"defaultValue"in m?m.defaultValue:void 0,placeholder:r,ref:p,onChange:b=>e?.(b.target.value),onKeyDown:a}),l&&Vh(go,{onSelect:()=>f(!u),style:{border:0,userSelect:"none"},children:u?$x:ri})]})]})});var vn=[{icon:Oc,value:"selection",key:w.V,fillable:!0,myocSimplifiedMode:!0},{icon:nn,value:"rectangle",key:w.R,fillable:!0,myocSimplifiedMode:!1},{icon:an,value:"diamond",key:w.D,fillable:!0,myocSimplifiedMode:!1},{icon:ln,value:"ellipse",key:w.O,fillable:!0,myocSimplifiedMode:!1},{icon:Qi,value:"arrow",key:w.A,fillable:!0,myocSimplifiedMode:!1},{icon:sn,value:"line",key:w.L,fillable:!0,myocSimplifiedMode:!1},{icon:lr,value:"freedraw",key:[w.P,w.X],fillable:!1,myocSimplifiedMode:!0},{icon:cn,value:"text",key:w.T,fillable:!1,myocSimplifiedMode:!0},{icon:Bc,value:"image",key:[w.I],fillable:!1,myocSimplifiedMode:!0},{icon:zc,value:"eraser",key:w.E,fillable:!1,myocSimplifiedMode:!0}],Vy=e=>vn.find((t,r)=>t.key&&(typeof t.key=="string"?t.key===e:t.key.includes(e)))?.value||null;import Kh from"clsx";import{useMemo as Nk,useState as Ok}from"react";import{Fragment as wn,jsx as Je,jsxs as Ct}from"react/jsx-runtime";var Zh=(e,o)=>{let t=o[0]?.type||null;for(let r of o)if(r.type!==t){t=null;break}return hl(e.activeTool.type)&&e.activeTool.type!=="image"&&t!=="image"&&t!=="frame"&&t!=="magicframe"||o.some(r=>hl(r.type))},Xh=(e,o)=>Jr(e.activeTool.type)||o.some(t=>Jr(t.type)),jd=({appState:e,elementsMap:o,renderAction:t,app:r})=>{let n=lc(o,e),i=!1;n.length===2&&(bt(n[0])||bt(n[1]))&&(i=!0);let a=!!(e.editingTextElement||e.newElement),l=xe(),s=document.documentElement.getAttribute("dir")==="rtl",c=Jr(e.activeTool.type)&&!vr(e.currentItemBackgroundColor)||n.some(f=>Jr(f.type)&&!vr(f.backgroundColor)),m=n.length===1||i,d=!e.editingLinearElement&&n.length===1&&ge(n[0])&&!se(n[0]),p=!e.croppingElementId&&n.length===1&&Ne(n[0]),u=!i&&Nt(e,r);return Ct("div",{className:"selected-shape-actions",children:[Je("div",{children:Zh(e,n)&&t("changeStrokeColor")}),Xh(e,n)&&Je("div",{children:t("changeBackgroundColor")}),c&&t("changeFillStyle"),(Ip(e.activeTool.type)||n.some(f=>Ip(f.type)))&&t("changeStrokeWidth"),(e.activeTool.type==="freedraw"||n.some(f=>f.type==="freedraw"))&&t("changeStrokeShape"),(Mp(e.activeTool.type)||n.some(f=>Mp(f.type)))&&Ct(wn,{children:[t("changeStrokeStyle"),t("changeSloppiness")]}),(Lp(e.activeTool.type)||n.some(f=>Lp(f.type)))&&Je(wn,{children:t("changeRoundness")}),(Ap(e.activeTool.type)||n.some(f=>Ap(f.type)))&&Je(wn,{children:t("changeArrowType")}),(e.activeTool.type==="text"||n.some(V))&&Ct(wn,{children:[t("changeFontFamily"),t("changeFontSize"),(e.activeTool.type==="text"||$1(n,o))&&t("changeTextAlign")]}),X1(n,o)&&t("changeVerticalAlign"),(zi(e.activeTool.type)||n.some(f=>zi(f.type)))&&Je(wn,{children:t("changeArrowhead")}),t("changeOpacity"),Ct("fieldset",{children:[Je("legend",{children:g("labels.layers")}),Ct("div",{className:"buttonList",children:[t("sendToBack"),t("sendBackward"),t("bringForward"),t("bringToFront")]})]}),u&&!i&&Ct("fieldset",{children:[Je("legend",{children:g("labels.align")}),Ct("div",{className:"buttonList",children:[s?Ct(wn,{children:[t("alignRight"),t("alignHorizontallyCentered"),t("alignLeft")]}):Ct(wn,{children:[t("alignLeft"),t("alignHorizontallyCentered"),t("alignRight")]}),n.length>2&&t("distributeHorizontally"),Je("div",{style:{flexBasis:"100%",height:0}}),Ct("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[t("alignTop"),t("alignVerticallyCentered"),t("alignBottom"),n.length>2&&t("distributeVertically"),Je("div",{style:{flexBasis:"100%",height:0}}),t("arrangeElements")]})]})]}),!a&&n.length>0&&Ct("fieldset",{children:[Je("legend",{children:g("labels.actions")}),Ct("div",{className:"buttonList",children:[!l.editor.isMobile&&t("duplicateSelection"),!l.editor.isMobile&&t("deleteSelectedElements"),t("group"),t("ungroup"),m&&t("hyperlink"),p&&t("cropEditor"),d&&t("toggleLinearEditor"),t("smartZoom")]})]})]})},qd=({activeTool:e,appState:o,app:t,UIOptions:r})=>{let[n,i]=Ok(!1),a=e.type==="frame",l=e.type==="laser",s=e.type==="lasso",c=e.type==="embeddable",m=vn.filter(p=>p.myocSimplifiedMode===!1),d=Nk(()=>{switch(e.type){case"frame":return{icon:ra,highlight:!1};case"lasso":return{icon:Cl,highlight:!0};case"embeddable":return{icon:Hb,highlight:!0};case"laser":return t.props.isCollaborating?{icon:Eu,highlight:!0}:{icon:Al,highlight:!0};case"diamond":return{icon:an,highlight:!0};case"rectangle":return{icon:nn,highlight:!0};case"ellipse":return{icon:ln,highlight:!0};case"arrow":return{icon:Qi,highlight:!0};case"line":return{icon:sn,highlight:!0};default:return{icon:Eu,highlight:!1}}},[e.type,t.props.isCollaborating]);return Ct(wn,{children:[vn.filter(p=>!o.myocSimplifiedMode||p.myocSimplifiedMode).map(({value:p,icon:u,key:f,fillable:b},x)=>{if(r.tools?.[p]===!1)return null;let E=g(`toolBar.${p}`),y=f&&Fo(typeof f=="string"?f:f[0]),v=`${y}`;return Je(K,{className:Kh("Shape",{fillable:b}),type:"radio",icon:u,checked:e.type===p,name:"editor-current-shape",title:`${Fo(E)} \u2014 ${v}`,keyBindingLabel:y,"aria-label":Fo(E),"aria-keyshortcuts":v,"data-testid":`toolbar-${p}`,onPointerDown:({pointerType:T})=>{!o.penDetected&&T==="pen"&&t.togglePenMode(!0),p==="selection"&&(o.activeTool.type==="selection"?t.setActiveTool({type:"lasso"}):t.setActiveTool({type:"selection"}))},onChange:({pointerType:T})=>{o.activeTool.type!==p&&me("toolbar",p,"ui"),p==="image"?t.setActiveTool({type:p}):t.setActiveTool({type:p})}},p)}),Ct(Oe,{open:n,children:[Je(Oe.Trigger,{className:Kh("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":d.highlight}),onToggle:()=>i(!n),title:g("toolBar.extraTools"),children:d.icon}),Ct(Oe.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[Je(Oe.Item,{onSelect:()=>t.setActiveTool({type:"lasso"}),icon:Cl,"data-testid":"toolbar-lasso",selected:s,children:g("toolBar.lasso")}),m.map(({value:p,icon:u,key:f,fillable:b})=>{let x=g(`toolBar.${p}`),E=f&&Fo(typeof f=="string"?f:f[0]);return Je(Oe.Item,{onSelect:()=>t.setActiveTool({type:p}),icon:u,"data-testid":`toolbar-${p}`,selected:e.type===p,shortcut:E??void 0,children:Fo(x)},p)}),Je("div",{className:"App-toolbar__dropdown-divider"}),Je(Oe.Item,{onSelect:()=>t.toggleLock(),icon:o.activeTool.locked?rn:Mr,"data-testid":"toolbar-lock",selected:o.activeTool.locked,shortcut:w.Q,children:Fo(g("toolBar.lock-short"))}),!o.myocSimplifiedMode&&Je(Oe.Item,{onSelect:()=>t.setActiveTool({type:"laser"}),icon:Al,"data-testid":"toolbar-laser",selected:l,shortcut:w.K.toLocaleUpperCase(),children:g("toolBar.laser")})]})]})]})},Ky=({renderAction:e,zoom:o})=>Je(Tt.Col,{gap:1,className:Bt.ZOOM_ACTIONS,children:Ct(Tt.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),Zy=({renderAction:e,className:o})=>Ct("div",{className:`undo-redo-buttons ${o}`,children:[Je("div",{className:"undo-button-container",children:Je(Rt,{label:g("buttons.undo"),children:e("undo")})}),Je("div",{className:"redo-button-container",children:Ct(Rt,{label:g("buttons.redo"),children:[" ",e("redo")]})})]}),Xy=({actionManager:e,showExitZenModeBtn:o})=>Je("button",{type:"button",className:Kh("disable-zen-mode",{"disable-zen-mode--visible":o}),onClick:()=>e.executeAction(ya),children:g("buttons.exitZenMode")}),$y=({renderAction:e,className:o})=>Je("div",{className:`finalize-button ${o}`,children:e("finalize",{size:"small"})});import{useRef as Bk}from"react";var $h=e=>{let o=Bk({userFn:e});return o.current.userFn=e,o.current.stableFn||(o.current.stableFn=(...t)=>o.current.userFn(...t)),o.current.stableFn};var jh={};Cf(jh,{toggleTheme:()=>zk});var zk={...ai,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(ai,"commandPalette")}};import{jsx as Yt,jsxs as pr}from"react/jsx-runtime";var Uk=Ie(null),Ze={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links"},Gk=e=>{switch(e){case Ze.app:return 1;case Ze.export:return 2;case Ze.editor:return 3;case Ze.tools:return 4;case Ze.elements:return 5;case Ze.links:return 6;default:return 10}},em=({shortcut:e,className:o,children:t})=>{let r=e.replace("++","+$").split("+");return pr("div",{className:qy("shortcut",o),children:[r.map((n,i)=>Yt("div",{className:"shortcut-wrapper",children:Yt("div",{className:"shortcut-key",children:n==="$"?"+":n})},n)),Yt("div",{className:"shortcut-desc",children:t})]})},Jy=e=>!e.altKey&&e[w.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===w.P||e.key===w.SLASH),_$=Object.assign(e=>{let o=Me(),t=ve();return Qd(()=>{let r=n=>{Jy(n)&&(n.preventDefault(),n.stopPropagation(),t(i=>{let a=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return a&&me("command_palette","open","shortcut"),{openDialog:a}}))};return window.addEventListener("keydown",r,{capture:!0}),()=>window.removeEventListener("keydown",r,{capture:!0})},[t]),o.openDialog?.name!=="commandPalette"?null:Yt(Yk,{...e})},{defaultItems:jh});function Yk({customCommandPaletteItems:e}){let o=tt(),t=Me(),r=ve(),n=cr(),i=_t(),[a,l]=Ee(Uk),[s,c]=Jd(null),m=Hk(null),d=dn({uiAppState:t,customCommandPaletteItems:e,appProps:n});Qd(()=>{let{uiAppState:S,customCommandPaletteItems:P,appProps:M}=d,O=Y=>{let oe="";return Y.label&&(typeof Y.label=="function"?oe=g(Y.label(o.scene.getNonDeletedElements(),S,o)):oe=g(Y.label)),oe},R=Y=>typeof Y.icon=="function"?Y.icon(S,o.scene.getNonDeletedElements()):Y.icon,z=[],W=(Y,oe,H)=>{let F={label:O(Y),icon:R(Y),category:oe,shortcut:We(Y.name),keywords:Y.keywords,predicate:Y.predicate,viewMode:Y.viewMode,perform:()=>{i.executeAction(Y,"commandPalette")}};return H?H(F,Y):F};if(S&&o.scene&&i){let Y=[i.actions.group,i.actions.ungroup,i.actions.cut,i.actions.copy,i.actions.deleteSelectedElements,i.actions.wrapSelectionInFrame,i.actions.copyStyles,i.actions.pasteStyles,i.actions.bringToFront,i.actions.bringForward,i.actions.sendBackward,i.actions.sendToBack,i.actions.alignTop,i.actions.alignBottom,i.actions.alignLeft,i.actions.alignRight,i.actions.alignVerticallyCentered,i.actions.alignHorizontallyCentered,i.actions.arrangeElements,i.actions.duplicateSelection,i.actions.smartZoom,i.actions.flipHorizontal,i.actions.flipVertical,i.actions.zoomToFitSelection,i.actions.zoomToFitSelectionInViewport,i.actions.increaseFontSize,i.actions.decreaseFontSize,i.actions.toggleLinearEditor,i.actions.cropEditor,i.actions.togglePolygon,Xl,Rd,X2].map(X=>W(X,Ze.elements,(de,he)=>({...de,predicate:he.predicate?he.predicate:(Ce,mt,so,Nn)=>q(Ce,mt).length>0}))),oe=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool,i.actions.toggleLassoTool].map(X=>W(X,Ze.tools)),H=[i.actions.undo,i.actions.redo,i.actions.zoomIn,i.actions.zoomOut,i.actions.resetZoom,i.actions.zoomToFit,i.actions.smartZoom,i.actions.zenMode,i.actions.viewMode,i.actions.gridMode,i.actions.objectsSnapMode,i.actions.toggleShortcuts,i.actions.selectAll,i.actions.toggleElementLock,i.actions.unlockAllElements,i.actions.stats].map(X=>W(X,Ze.editor)),F=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map(X=>W(X,Ze.export));z=[...Y,...H,{label:g("buttons.exportImage"),category:Ze.export,icon:Uc,shortcut:We("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{r({openDialog:{name:"imageExport"}})}},...F];let ee=[{label:g("toolBar.library"),category:Ze.app,icon:Ji,viewMode:!1,perform:()=>{S.openSidebar?r({openSidebar:null}):r({openSidebar:{name:Dt.name,tab:Dt.defaultTab}})}},{label:g("search.title"),category:Ze.app,icon:uo,viewMode:!0,perform:()=>{i.executeAction(rs)}},{label:g("labels.shapeSwitch"),category:Ze.elements,icon:_l,perform:()=>{i.executeAction(Z2)}},{label:g("labels.changeStroke"),keywords:["color","outline"],category:Ze.elements,icon:Hc,viewMode:!1,predicate:(X,de)=>{let he=q(X,de);return he.length>0&&Zh(de,he)},perform:()=>{r(X=>({openMenu:X.openMenu==="shape"?null:"shape",openPopup:"elementStroke"}))}},{label:g("labels.changeBackground"),keywords:["color","fill"],icon:Hc,category:Ze.elements,viewMode:!1,predicate:(X,de)=>{let he=q(X,de);return he.length>0&&Xh(de,he)},perform:()=>{r(X=>({openMenu:X.openMenu==="shape"?null:"shape",openPopup:"elementBackground"}))}},{label:g("labels.canvasBackground"),keywords:["color"],icon:Hc,category:Ze.editor,viewMode:!1,perform:()=>{r(X=>({openMenu:X.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...vn.reduce((X,de)=>{let{value:he,icon:Ce,key:mt}=de;if(M.UIOptions.tools?.[he]===!1)return X;let Nn=mt&&Fo(typeof mt=="string"?mt:mt[0]),Ei={label:g(`toolBar.${he}`),category:Ze.tools,shortcut:Nn,icon:Ce,keywords:["toolbar"],viewMode:!1,perform:({event:Km})=>{he==="image"?o.setActiveTool({type:he}):o.setActiveTool({type:he})}};return X.push(Ei),X},[]),...oe,{label:g("toolBar.lock"),category:Ze.tools,icon:S.activeTool.locked?rn:Mr,shortcut:w.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{o.toggleLock()}},{label:`${g("labels.textToDiagram")}...`,category:Ze.tools,icon:qx,viewMode:!1,predicate:M.aiEnabled,perform:()=>{r(X=>({...X,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${g("toolBar.mermaidToExcalidraw")}...`,category:Ze.tools,icon:Kx,viewMode:!1,predicate:M.aiEnabled,perform:()=>{r(X=>({...X,openDialog:{name:"ttd",tab:"mermaid"}}))}}],ie=[...z,...ee,...P||[]].map(X=>({...X,icon:X.icon||_l,order:X.order??Gk(X.category),haystack:`${Ph(X.label.toLocaleLowerCase())} ${X.keywords?.join(" ")||""}`}));c(ie),l(ie.find(X=>X.label===a?.label)??null)}},[d,o,i,c,a?.label,l,r]);let[p,u]=Jd(""),[f,b]=Jd(null),[x,E]=Jd({}),y=S=>{r({openDialog:null},S),u("")},v=(S,P)=>{t.openDialog?.name==="commandPalette"&&(P.stopPropagation(),P.preventDefault(),document.body.classList.add("excalidraw-animations-disabled"),y(()=>{S.perform({actionManager:i,event:P}),l(S),requestAnimationFrame(()=>{document.body.classList.remove("excalidraw-animations-disabled")})}))},T=$h(S=>S.viewMode===!1&&t.viewModeEnabled?!1:typeof S.predicate=="function"?S.predicate(o.scene.getNonDeletedElements(),t,n,o):S.predicate===void 0||S.predicate),I=$h(S=>{let P=or(S.target)||Jy(S)||S.key===w.ESCAPE;if(P&&S.key!==w.ARROW_UP&&S.key!==w.ARROW_DOWN&&S.key!==w.ENTER)return;let M=Object.values(x).flat(),O=a&&!p&&T(a);if(S.key===w.ARROW_UP){S.preventDefault();let R=M.findIndex(Y=>Y.label===f?.label);if(O){if(R===0){b(a);return}if(f===a){let Y=M[M.length-1];Y&&b(Y);return}}let z;R===-1?z=M.length-1:z=R===0?M.length-1:(R-1)%M.length;let W=M[z];W&&b(W);return}if(S.key===w.ARROW_DOWN){S.preventDefault();let R=M.findIndex(Y=>Y.label===f?.label);if(O){if(!f||R===M.length-1){b(a);return}if(f===a){let Y=M[0];Y&&b(Y);return}}let z=(R+1)%M.length,W=M[z];W&&b(W);return}if(S.key===w.ENTER&&f&&setTimeout(()=>{v(f,S)}),!P){if(S.stopPropagation(),/^[a-zA-Z0-9]$/.test(S.key)){m?.current?.focus();return}S.preventDefault()}});return Qd(()=>(window.addEventListener("keydown",I,{capture:!0}),()=>window.removeEventListener("keydown",I,{capture:!0})),[I]),Qd(()=>{if(!s)return;let S=R=>{let z={};for(let W of R)z[W.category]?z[W.category].push(W):z[W.category]=[W];return z},P=s.filter(T).sort((R,z)=>R.order-z.order),M=!p&&a&&T(a);if(!p){E(S(M?P.filter(R=>R.label!==a?.label):P)),b(M?a:P[0]||null);return}let O=Ph(p.toLocaleLowerCase().replace(/[<>_| -]/g,""));P=Fk.filter(O,P,{extract:R=>R.haystack}).sort((R,z)=>z.score-R.score).map(R=>R.original),E(S(P)),b(P[0]??null)},[p,s,T,a]),pr(ot,{onCloseRequest:()=>y(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[Yt(Pa,{value:p,placeholder:g("commandPalette.search.placeholder"),onChange:S=>{u(S)},selectOnRender:!0,ref:m}),!o.device.viewport.isMobile&&pr("div",{className:"shortcuts-wrapper",children:[Yt(em,{shortcut:"\u2191\u2193",children:g("commandPalette.shortcuts.select")}),Yt(em,{shortcut:"\u21B5",children:g("commandPalette.shortcuts.confirm")}),Yt(em,{shortcut:D("Esc"),children:g("commandPalette.shortcuts.close")})]}),pr("div",{className:"commands",children:[a&&!p&&pr("div",{className:"command-category",children:[pr("div",{className:"command-category-title",children:[g("commandPalette.recents"),Yt("div",{className:"icon",style:{marginLeft:"6px"},children:Jx})]}),Yt(jy,{command:a,isSelected:a.label===f?.label,onClick:S=>v(a,S),disabled:!T(a),onMouseMove:()=>b(a),showShortcut:!o.device.viewport.isMobile,appState:t})]}),Object.keys(x).length>0?Object.keys(x).map((S,P)=>pr("div",{className:"command-category",children:[Yt("div",{className:"command-category-title",children:S}),x[S].map(M=>Yt(jy,{command:M,isSelected:M.label===f?.label,onClick:O=>v(M,O),onMouseMove:()=>b(M),showShortcut:!o.device.viewport.isMobile,appState:t},M.label))]},S)):s?pr("div",{className:"no-match",children:[Yt("div",{className:"icon",children:uo})," ",g("commandPalette.search.noMatch")]}):null]})]})}var jy=({command:e,isSelected:o,disabled:t,onMouseMove:r,onClick:n,showShortcut:i,appState:a})=>{let l=()=>{};return pr("div",{className:qy("command-item",{"item-selected":o,"item-disabled":t}),ref:s=>{o&&!t&&s?.scrollIntoView?.({block:"nearest"})},onClick:t?l:n,onMouseMove:t?l:r,title:t?g("commandPalette.itemNotAvailable"):"",children:[pr("div",{className:"name",children:[e.icon&&Yt(gn,{icon:typeof e.icon=="function"?e.icon(a):e.icon}),e.label]}),i&&e.shortcut&&Yt(em,{shortcut:e.shortcut})]})};import{jsx as Qy}from"react/jsx-runtime";var qh=B({name:"toggleLinearEditor",category:Ze.elements,label:(e,o,t)=>t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return!!(!o.editingLinearElement&&n.length===1&&ge(n[0])&&!se(n[0]))},perform(e,o,t,r){let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0],i=o.editingLinearElement?.elementId===n.id?null:new $(n,j(e));return{appState:{...o,editingLinearElement:i},captureUpdate:A.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0],n=g(r.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return Qy(K,{type:"button",icon:mE,title:n,"aria-label":n,onClick:()=>o(null)})}}),K$=B({name:"togglePolygon",category:Ze.elements,icon:eu,keywords:["loop"],label:(e,o,t)=>!t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds}).some(i=>!qe(i)||!i.polygon)?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds});return n.length>0&&n.every(i=>qe(i)&&i.points.length>=4)},perform(e,o,t,r){let n=r.scene.getSelectedElements(o);if(n.some(s=>!qe(s)))return!1;let i=n,a=i.some(s=>!s.polygon),l=j(i);return{elements:e.map(s=>!l.has(s.id)||!qe(s)?s:te(s,{backgroundColor:a?s.backgroundColor:"transparent",...uc(s,a)})),appState:o,captureUpdate:A.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(r.length===0||r.some(a=>!qe(a)||!a.polygon||a.points.length<3))return null;let n=r.every(a=>qe(a)&&a.polygon),i=g(n?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return Qy(ia,{icon:eu,title:i,"aria-label":i,active:n,onClick:()=>o(null),style:{marginLeft:"auto"}})}});var rs=B({name:"searchMenu",icon:uo,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,o,t,r){if(o.openDialog)return!1;if(o.openSidebar?.name===Dt.name&&o.openSidebar.tab===yr){let n=r.excalidrawContainerValue.container?.querySelector(`.${Bt.SEARCH_MENU_INPUT_WRAPPER} input`);return n?.focus(),n?.select(),!1}return{appState:{...o,openSidebar:{name:Dt.name,tab:yr},openDialog:null},captureUpdate:A.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[w.CTRL_OR_CMD]&&e.key===w.F});import{jsx as Wk}from"react/jsx-runtime";var Jh=B({name:"cropEditor",label:"helpDialog.cropStart",icon:vu,viewMode:!0,trackEvent:{category:"menu"},keywords:["image","crop"],perform(e,o,t,r){let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...o,isCropping:!1,croppingElementId:n.id},captureUpdate:A.IMMEDIATELY}},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return!!(!o.croppingElementId&&n.length===1&&Ne(n[0]))},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=g("helpDialog.cropStart");return Wk(K,{type:"button",icon:vu,title:r,"aria-label":r,onClick:()=>o(null)})}});var ev=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length===1&&ce(t[0])},tv=B({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o).at(0)||null;if(ce(n)){let i=Wo(fe(e),n.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...o,selectedElementIds:i.reduce((a,l)=>(a[l.id]=!0,a),{})},captureUpdate:A.IMMEDIATELY}}return{elements:e,appState:o,captureUpdate:A.EVENTUALLY}},predicate:(e,o,t,r)=>ev(o,r)}),ov=B({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o).at(0)||null;return ce(n)?{elements:f0(e,n),appState:{...o,selectedElementIds:{[n.id]:!0}},captureUpdate:A.IMMEDIATELY}:{elements:e,appState:o,captureUpdate:A.EVENTUALLY}},predicate:(e,o,t,r)=>ev(o,r)}),oq=B({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o)=>({elements:e,appState:{...o,frameRendering:{...o.frameRendering,enabled:!o.frameRendering.enabled}},captureUpdate:A.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),rq=B({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:ra,viewMode:!1,perform:(e,o,t,r)=>{let n=Le(o,{type:"frame"});return ho(r.interactiveCanvas,{...o,activeTool:n}),{elements:e,appState:{...o,activeTool:Le(o,{type:"frame"})},captureUpdate:A.EVENTUALLY}},keyTest:e=>!1}),rv=B({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=q(e,o);return n.length>0&&!n.some(i=>ce(i))},perform:(e,o,t,r)=>{let n=q(e,o),i=r.scene.getNonDeletedElementsMap(),[a,l,s,c]=ye(n,i),m=16,d=Hi({x:a-m,y:l-m,width:s-a+m*2,height:c-l+m*2});if(o.editingGroupId){let u=He(n,o.editingGroupId);for(let f of u){let b=f.groupIds.indexOf(o.editingGroupId);Go(f,i,{groupIds:f.groupIds.slice(0,b)})}}return{elements:Bi([...r.scene.getElementsIncludingDeleted(),d],n,d,o),appState:{selectedElementIds:{[d.id]:!0}},captureUpdate:A.IMMEDIATELY}}});var Da=class extends I0{applyTo(o,t,r){let[n,i]=this.elements.applyTo(o,r.elements,{excludedProperties:new Set(["version","versionNonce"])}),[a,l]=this.appState.applyTo(t,n);return[n,a,i||l]}static calculate(o,t){return super.calculate(o,t)}static inverse(o){return super.inverse(o)}static applyLatestChanges(o,t,r,n){return super.applyLatestChanges(o,t,r,n)}},hi=class{constructor(o=!0,t=!0){this.isUndoStackEmpty=o;this.isRedoStackEmpty=t}},ns=class e{constructor(o){this.store=o;k(this,"onHistoryChangedEmitter",new yo);k(this,"undoStack",[]);k(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(o){if(o.isEmpty()||o instanceof Da)return;let t=Da.inverse(o);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new hi(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(o,t){return this.perform(o,t,()=>e.pop(this.undoStack),r=>e.push(this.redoStack,r))}redo(o,t){return this.perform(o,t,()=>e.pop(this.redoStack),r=>e.push(this.undoStack,r))}perform(o,t,r,n){try{let i=r();if(i===null)return;let a=A.IMMEDIATELY,l=this.store.snapshot,s=o,c=t,m=!1;for(;i;){try{[s,c,m]=i.applyTo(s,c,l);let d=l.elements,p=l.maybeClone(a,s,c),u=S0.create(l,p),f=Da.applyLatestChanges(i,d,s);f.isEmpty()||(this.store.scheduleMicroAction({action:a,change:u,delta:f}),i=f),l=p}finally{n(i)}if(m)break;i=r()}return[s,c]}finally{this.onHistoryChangedEmitter.trigger(new hi(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(o){if(!o.length)return null;let t=o.pop();return t!==void 0?t:null}static push(o,t){let r=Da.inverse(t);return o.push(r)}};import{useEffect as Vk,useState as Kk}from"react";var Qh=(e,o)=>{let[t,r]=Kk(o);return Vk(()=>{let n=e.on(i=>{r(i)});return()=>{n()}},[e]),t};import{jsx as lv}from"react/jsx-runtime";var nv=(e,o,t)=>{if(!o.multiElement&&!o.resizingElement&&!o.editingTextElement&&!o.newElement&&!o.selectedElementsAreBeingDragged&&!o.selectionElement&&!e.flowChartCreator.isCreatingChart){let r=t();if(!r)return{captureUpdate:A.EVENTUALLY};let[n,i]=r,a=gc(Array.from(n.values()));return{appState:i,elements:a,captureUpdate:A.NEVER}}return{captureUpdate:A.EVENTUALLY}},iv=e=>({name:"undo",label:"buttons.undo",icon:ru,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,r,n)=>nv(n,t,()=>e.undo(j(o),t)),keyTest:o=>o[w.CTRL_OR_CMD]&&vi(o,w.Z)&&!o.shiftKey,PanelComponent:({updateData:o,data:t})=>{let{isUndoStackEmpty:r}=Qh(e.onHistoryChangedEmitter,new hi(e.isUndoStackEmpty,e.isRedoStackEmpty));return lv(K,{type:"button",icon:ru,"aria-label":g("buttons.undo"),onClick:o,size:t?.size||"medium",disabled:r,"data-testid":"button-undo"})}}),av=e=>({name:"redo",label:"buttons.redo",icon:nu,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,r,n)=>nv(n,t,()=>e.redo(j(o),t)),keyTest:o=>o[w.CTRL_OR_CMD]&&o.shiftKey&&vi(o,w.Z)||Ls&&o.ctrlKey&&!o.shiftKey&&vi(o,w.Y),PanelComponent:({updateData:o,data:t})=>{let{isRedoStackEmpty:r}=Qh(e.onHistoryChangedEmitter,new hi(e.isUndoStackEmpty,e.isRedoStackEmpty));return lv(K,{type:"button",icon:nu,"aria-label":g("buttons.redo"),onClick:o,size:t?.size||"medium",disabled:r,"data-testid":"button-redo"})}});var sv=B({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=q(e,o);return n.length===1&&V(n[0])&&!n[0].autoResize},perform:(e,o,t,r)=>{let n=q(e,o);return{appState:o,elements:e.map(i=>{if(i.id===n[0].id&&V(i)){let a=vt(i.originalText,et(i),i.lineHeight);return te(i,{autoResize:!0,width:a.width,height:a.height,text:i.originalText})}return i}),captureUpdate:A.IMMEDIATELY}}});import Zk from"clsx";import{jsx as Xk}from"react/jsx-runtime";var eg=B({name:"viewMode",label:"labels.viewMode",icon:ri,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,o){return{appState:{...o,viewModeEnabled:!this.checked(o)},captureUpdate:A.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,o,t)=>typeof t.viewModeEnabled>"u",keyTest:e=>!e[w.CTRL_OR_CMD]&&e.altKey&&e.code===le.R,PanelComponent:({data:e,updateData:o,appState:t})=>Xk(K,{type:"button",icon:ri,"aria-label":g("labels.viewMode"),onClick:()=>o(null),size:e?.size||"medium","data-testid":"button-view-mode",className:Zk({enabled:t.viewModeEnabled})})});import{jsx as $k}from"react/jsx-runtime";var tg=(e,o,t,r,n,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,r,i))&&me(e.trackEvent.category,e.trackEvent.action||e.name,`${o} (${n.device.editor.isMobile?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},tm=class{constructor(o,t,r,n){k(this,"actions",{});k(this,"updater");k(this,"getAppState");k(this,"getElementsIncludingDeleted");k(this,"app");k(this,"renderAction",(o,t)=>{let r=this.app.props.UIOptions.canvasActions;if(this.actions[o]&&"PanelComponent"in this.actions[o]&&(!(o in r)||r[o])){let n=this.actions[o],i=n.PanelComponent;i.displayName="PanelComponent";let a=this.getElementsIncludingDeleted(),l=this.getAppState(),s=c=>{tg(n,"ui",l,a,this.app,c),this.updater(n.perform(this.getElementsIncludingDeleted(),this.getAppState(),c,this.app))};return $k(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:s,appProps:this.app.props,app:this.app,data:t,renderAction:this.renderAction})}return null});k(this,"isActionEnabled",o=>{let t=this.getElementsIncludingDeleted(),r=this.getAppState();return!o.predicate||o.predicate(t,r,this.app.props,this.app)});this.updater=i=>{if(Wr(i))i.then(a=>o(a));else return o(i)},this.getAppState=t,this.getElementsIncludingDeleted=r,this.app=n}registerAction(o){this.actions[o.name]=o}registerAll(o){o.forEach(t=>this.registerAction(t))}handleKeyDown(o){let t=this.app.props.UIOptions.canvasActions,r=Object.values(this.actions).sort((s,c)=>(c.keyPriority||0)-(s.keyPriority||0)).filter(s=>(s.name in t?t[s.name]:!0)&&s.keyTest&&s.keyTest(o,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(r.length!==1)return r.length>1&&console.warn("Canceling as multiple actions match this shortcut",r),!1;let n=r[0];if(this.getAppState().viewModeEnabled&&n.viewMode!==!0)return!1;let i=this.getElementsIncludingDeleted(),a=this.getAppState(),l=null;return tg(n,"keyboard",a,i,this.app,null),o.preventDefault(),o.stopPropagation(),this.updater(r[0].perform(i,a,l,this.app)),!0}executeAction(o,t="api",r=null){let n=this.getElementsIncludingDeleted(),i=this.getAppState();tg(o,t,i,n,this.app,r),this.updater(o.perform(n,i,r,this.app))}};var om=class{constructor(){k(this,"targets",new WeakMap);k(this,"rafIds",new WeakMap)}register(o,t){this.targets.set(o,{callback:t,stopped:!0})}start(o){let t=this.targets.get(o);t&&(this.rafIds.has(o)||(this.targets.set(o,{...t,stopped:!1}),this.scheduleFrame(o)))}stop(o){let t=this.targets.get(o);t&&!t.stopped&&this.targets.set(o,{...t,stopped:!0}),this.cancelFrame(o)}constructFrame(o){return t=>{let r=this.targets.get(o);if(!r)return;let n=this.onFrame(r,t);!r.stopped&&!n?this.scheduleFrame(o):this.cancelFrame(o)}}scheduleFrame(o){let t=requestAnimationFrame(this.constructFrame(o));this.rafIds.set(o,t)}cancelFrame(o){if(this.rafIds.has(o)){let t=this.rafIds.get(o);cancelAnimationFrame(t)}this.rafIds.delete(o)}onFrame(o,t){return o.callback(t)??!1}};var og=e=>{let o=Array.from(e.values());return{x:cv(o,t=>t.x)/o.length,y:cv(o,t=>t.y)/o.length}},rg=([e,o])=>Math.hypot(e.x-o.x,e.y-o.y),cv=(e,o)=>e.reduce((t,r)=>t+o(r),0);var jk=8,dv=99999,rm=e=>jk/e,Wt=class Wt{};k(Wt,"referenceSnapPoints",null),k(Wt,"visibleGaps",null),k(Wt,"setReferenceSnapPoints",o=>{Wt.referenceSnapPoints=o}),k(Wt,"getReferenceSnapPoints",()=>Wt.referenceSnapPoints),k(Wt,"setVisibleGaps",o=>{Wt.visibleGaps=o}),k(Wt,"getVisibleGaps",()=>Wt.visibleGaps),k(Wt,"destroy",()=>{Wt.referenceSnapPoints=null,Wt.visibleGaps=null});var Po=Wt,Tn=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,Rr=({event:e,app:o,selectedElements:t})=>e?o.state.activeTool.type!=="lasso"&&(o.state.objectsSnapModeEnabled&&!e[w.CTRL_OR_CMD]||!o.state.objectsSnapModeEnabled&&e[w.CTRL_OR_CMD]&&!Tn(o)):t.length===1&&t[0].type==="arrow"?!1:o.state.objectsSnapModeEnabled,qk=(e,o,t=.01)=>Math.abs(e-o)<=t,is=(e,o,{omitCenter:t,boundingBoxCorners:r,dragOffset:n}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[l,s,c,m,d,p]=at(a,o);n&&(l+=n.x,c+=n.x,d+=n.x,s+=n.y,m+=n.y,p+=n.y);let u=(c-l)/2,f=(m-s)/2;if((a.type==="diamond"||a.type==="ellipse")&&!r){let b=Re(L(l,s+f),L(d,p),a.angle),x=Re(L(l+u,s),L(d,p),a.angle),E=Re(L(c,s+f),L(d,p),a.angle),y=Re(L(l+u,m),L(d,p),a.angle),v=L(d,p);i=t?[b,x,E,y]:[b,x,E,y,v]}else{let b=Re(L(l,s),L(d,p),a.angle),x=Re(L(c,s),L(d,p),a.angle),E=Re(L(l,m),L(d,p),a.angle),y=Re(L(c,m),L(d,p),a.angle),v=L(d,p);i=t?[b,x,E,y]:[b,x,E,y,v]}}else if(e.length>1){let[a,l,s,c]=hc(e,n??{x:0,y:0}),m=s-a,d=c-l,p=L(a,l),u=L(s,l),f=L(a,c),b=L(s,c),x=L(a+m/2,l+d/2);i=t?[p,u,f,b]:[p,u,f,b,x]}return i.map(a=>L(Xe(a[0]),Xe(a[1])))},uv=(e,o,t,r)=>{let n=o.filter(i=>ce(i)).map(i=>i.id);return Tp(e,o,t,r).filter(i=>!(i.frameId&&n.includes(i.frameId)))},hv=(e,o,t,r)=>{let n=uv(e,o,t,r),i=$n(n,r).filter(d=>!(d.length===1&&rt(d[0]))).map(d=>ye(d).map(p=>Xe(p))),a=i.sort((d,p)=>d[0]-p[0]),l=[],s=0;e:for(let d=0;d<a.length;d++){let p=a[d];for(let u=d+1;u<a.length;u++){if(++s>dv)break e;let f=a[u],[,b,x,E]=p,[y,v,,T]=f;x<y&&nl(co(b,E),co(v,T))&&l.push({startBounds:p,endBounds:f,startSide:[L(x,b),L(x,E)],endSide:[L(y,v),L(y,T)],length:y-x,overlap:il(co(b,E),co(v,T))})}}let c=i.sort((d,p)=>d[1]-p[1]),m=[];s=0;e:for(let d=0;d<c.length;d++){let p=c[d];for(let u=d+1;u<c.length;u++){if(++s>dv)break e;let f=c[u],[b,,x,E]=p,[y,v,T]=f;E<v&&nl(co(b,x),co(y,T))&&m.push({startBounds:p,endBounds:f,startSide:[L(b,E),L(x,E)],endSide:[L(y,v),L(T,v)],length:v-E,overlap:il(co(b,x),co(y,T))})}}return{horizontalGaps:l,verticalGaps:m}},mv=(e,o,t,r,n,i,a)=>{if(!Rr({app:t,event:r,selectedElements:e}))return[];if(e.length===0)return[];let l=Po.getVisibleGaps();if(l){let{horizontalGaps:s,verticalGaps:c}=l,[m,d,p,u]=hc(e,o).map(x=>Xe(x)),f=(m+p)/2,b=(d+u)/2;for(let x of s){if(!nl(co(d,u),x.overlap))continue;let E=x.startSide[0][0]+x.length/2,y=Xe(E-f);if(x.length>p-m&&Math.abs(y)<=a.x){Math.abs(y)<a.x&&(n.length=0),a.x=Math.abs(y);let R={type:"gap",direction:"center_horizontal",gap:x,offset:y};n.push(R);continue}let[,,T]=x.endBounds,I=m-T,S=Xe(x.length-I);if(Math.abs(S)<=a.x){Math.abs(S)<a.x&&(n.length=0),a.x=Math.abs(S);let R={type:"gap",direction:"side_right",gap:x,offset:S};n.push(R);continue}let[P,,,]=x.startBounds,M=P-p,O=Xe(M-x.length);if(Math.abs(O)<=a.x){Math.abs(O)<a.x&&(n.length=0),a.x=Math.abs(O);let R={type:"gap",direction:"side_left",gap:x,offset:O};n.push(R);continue}}for(let x of c){if(!nl(co(m,p),x.overlap))continue;let E=x.startSide[0][1]+x.length/2,y=Xe(E-b);if(x.length>u-d&&Math.abs(y)<=a.y){Math.abs(y)<a.y&&(i.length=0),a.y=Math.abs(y);let R={type:"gap",direction:"center_vertical",gap:x,offset:y};i.push(R);continue}let[,T,,]=x.startBounds,I=T-u,S=Xe(I-x.length);if(Math.abs(S)<=a.y){Math.abs(S)<a.y&&(i.length=0),a.y=Math.abs(S);let R={type:"gap",direction:"side_top",gap:x,offset:S};i.push(R);continue}let[,,,P]=x.endBounds,M=Xe(d-P),O=x.length-M;if(Math.abs(O)<=a.y){Math.abs(O)<a.y&&(i.length=0),a.y=Math.abs(O);let R={type:"gap",direction:"side_bottom",gap:x,offset:O};i.push(R);continue}}}},gv=(e,o,t,r)=>{let n=uv(e,o,t,r);return $n(n,r).filter(i=>!(i.length===1&&rt(i[0]))).flatMap(i=>is(i,r))},Ra=(e,o,t,r,n,i,a)=>{if(!Rr({app:t,event:r,selectedElements:e})||e.length===0&&o.length===0)return[];let l=Po.getReferenceSnapPoints();if(l)for(let s of o)for(let c of l){let m=c[0]-s[0],d=c[1]-s[1];Math.abs(m)<=a.x&&(Math.abs(m)<a.x&&(n.length=0),n.push({type:"point",points:[s,c],offset:m}),a.x=Math.abs(m)),Math.abs(d)<=a.y&&(Math.abs(d)<a.y&&(i.length=0),i.push({type:"point",points:[s,c],offset:d}),a.y=Math.abs(d))}},fv=(e,o,t,r,n)=>{let i=t.state,a=q(e,i);if(!Rr({app:t,event:r,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};o.x=Xe(o.x),o.y=Xe(o.y);let l=[],s=[],c=rm(i.zoom.value),m={x:c,y:c},d=is(a,n,{dragOffset:o});Ra(a,d,t,r,l,s,m),mv(a,o,t,r,l,s,m);let p={x:l[0]?.offset??0,y:s[0]?.offset??0};m.x=0,m.y=0,l.length=0,s.length=0;let u={x:Xe(o.x+p.x),y:Xe(o.y+p.y)};Ra(a,is(a,n,{dragOffset:u}),t,r,l,s,m),mv(a,u,t,r,l,s,m);let f=ng(l,s),b=Qk(a,u,[...l,...s].filter(x=>x.type==="gap"));return{snapOffset:p,snapLines:[...f,...b]}},Xe=e=>Math.round(e*10**6)/10**6,pv=e=>{let o=new Map;for(let t of e){let r=t.join(",");o.has(r)||o.set(r,t)}return Array.from(o.values())},ng=(e,o)=>{let t={},r={};if(e.length>0){for(let n of e)if(n.type==="point"){let i=Xe(n.points[0][0]);t[i]||(t[i]=[]),t[i].push(...n.points.map(a=>L(Xe(a[0]),Xe(a[1]))))}}if(o.length>0){for(let n of o)if(n.type==="point"){let i=Xe(n.points[0][1]);r[i]||(r[i]=[]),r[i].push(...n.points.map(a=>L(Xe(a[0]),Xe(a[1]))))}}return Object.entries(t).map(([n,i])=>({type:"points",points:pv(i.map(a=>L(Number(n),a[1])).sort((a,l)=>a[1]-l[1]))})).concat(Object.entries(r).map(([n,i])=>({type:"points",points:pv(i.map(a=>L(a[0],Number(n))).sort((a,l)=>a[0]-l[0]))})))},Jk=e=>{let o=new Map;for(let t of e){let r=t.points.flat().map(n=>[Xe(n)]).join(",");o.has(r)||o.set(r,t)}return Array.from(o.values())},Qk=(e,o,t)=>{let[r,n,i,a]=hc(e,o),l=[];for(let s of t){let[c,m,d,p]=s.gap.startBounds,[u,f,b,x]=s.gap.endBounds,E=il(co(n,a),s.gap.overlap),y=il(co(r,i),s.gap.overlap);switch(s.direction){case"center_horizontal":{if(E){let v=(E[0]+E[1])/2;l.push({type:"gap",direction:"horizontal",points:[L(s.gap.startSide[0][0],v),L(r,v)]},{type:"gap",direction:"horizontal",points:[L(i,v),L(s.gap.endSide[0][0],v)]})}break}case"center_vertical":{if(y){let v=(y[0]+y[1])/2;l.push({type:"gap",direction:"vertical",points:[L(v,s.gap.startSide[0][1]),L(v,n)]},{type:"gap",direction:"vertical",points:[L(v,a),L(v,s.gap.endSide[0][1])]})}break}case"side_right":{if(E){let v=(E[0]+E[1])/2;l.push({type:"gap",direction:"horizontal",points:[L(d,v),L(u,v)]},{type:"gap",direction:"horizontal",points:[L(b,v),L(r,v)]})}break}case"side_left":{if(E){let v=(E[0]+E[1])/2;l.push({type:"gap",direction:"horizontal",points:[L(i,v),L(c,v)]},{type:"gap",direction:"horizontal",points:[L(d,v),L(u,v)]})}break}case"side_top":{if(y){let v=(y[0]+y[1])/2;l.push({type:"gap",direction:"vertical",points:[L(v,a),L(v,m)]},{type:"gap",direction:"vertical",points:[L(v,p),L(v,f)]})}break}case"side_bottom":{if(y){let v=(y[0]+y[1])/2;l.push({type:"gap",direction:"vertical",points:[L(v,p),L(v,f)]},{type:"gap",direction:"vertical",points:[L(v,x),L(v,n)]})}break}}}return Jk(l.map(s=>({...s,points:s.points.map(c=>L(Xe(c[0]),Xe(c[1])))})))},ig=(e,o,t,r,n,i)=>{if(!Rr({event:r,selectedElements:e,app:t})||e.length===0||e.length===1&&!qk(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,l,s,c]=ye(o);i&&(i.includes("e")?s+=n.x:i.includes("w")&&(a+=n.x),i.includes("n")?l+=n.y:i.includes("s")&&(c+=n.y));let m=[];if(i)switch(i){case"e":{m.push(L(s,l),L(s,c));break}case"w":{m.push(L(a,l),L(a,c));break}case"n":{m.push(L(a,l),L(s,l));break}case"s":{m.push(L(a,c),L(s,c));break}case"ne":{m.push(L(s,l));break}case"nw":{m.push(L(a,l));break}case"se":{m.push(L(s,c));break}case"sw":{m.push(L(a,c));break}}let d=rm(t.state.zoom.value),p={x:d,y:d},u=[],f=[];Ra(o,m,t,r,u,f,p);let b={x:u[0]?.offset??0,y:f[0]?.offset??0};p.x=0,p.y=0,u.length=0,f.length=0;let[x,E,y,v]=ye(e).map(S=>Xe(S)),T=[L(x,E),L(x,v),L(y,E),L(y,v)];Ra(e,T,t,r,u,f,p);let I=ng(u,f);return{snapOffset:b,snapLines:I}},bv=(e,o,t,r,n,i)=>{if(!Rr({event:t,selectedElements:[e],app:o}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[L(r.x+n.x,r.y+n.y)],l=rm(o.state.zoom.value),s={x:l,y:l},c=[],m=[];Ra([e],a,o,t,c,m,s);let d={x:c[0]?.offset??0,y:m[0]?.offset??0};s.x=0,s.y=0,c.length=0,m.length=0;let p=is([e],i,{boundingBoxCorners:!0,omitCenter:!0});Ra([e],p,o,t,c,m,s);let u=ng(c,m);return{snapOffset:d,snapLines:u}},xv=(e,o,t,r,n)=>{if(!Rr({event:r,selectedElements:[],app:o}))return{originOffset:{x:0,y:0},snapLines:[]};let i=Tp(e,[],o.state,n),a=rm(o.state.zoom.value),l={x:a,y:a},s=[],c=[];for(let m of i){let d=is([m],n);for(let p of d){let u=p[0]-t.x;Math.abs(u)<=Math.abs(l.x)&&(Math.abs(u)<Math.abs(l.x)&&(c.length=0),c.push({type:"pointer",points:[p,L(p[0],t.y)],direction:"vertical"}),l.x=u);let f=p[1]-t.y;Math.abs(f)<=Math.abs(l.y)&&(Math.abs(f)<Math.abs(l.y)&&(s.length=0),s.push({type:"pointer",points:[p,L(t.x,p[1])],direction:"horizontal"}),l.y=f)}}return{originOffset:{x:c.length>0?c[0].points[0][0]-t.x:0,y:s.length>0?s[0].points[0][1]-t.y:0},snapLines:[...c,...s]}},Ev=e=>e===Qe.rectangle||e===Qe.ellipse||e===Qe.diamond||e===Qe.frame||e===Qe.magicframe||e===Qe.image||e===Qe.text;var nm={width:100,height:0},Cn=100,eS=(e,o,t)=>{let r=Ft({x:0,y:0,textAlign:el.CENTER,verticalAlign:Xt.MIDDLE,...o,containerId:e.id,strokeColor:o.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:r.id})}),Ke(r,e,t),[e,r]},yv=(e,o,t,r,n)=>{let i,a;if(Object.assign(e,{startBinding:e?.startBinding||null,endBinding:e.endBinding||null}),o){let m=o?.width??Cn,d=o?.height??Cn,p;o.id&&(p=r.getElement(o.id),p||console.error(`No element for start binding with id ${o.id} found`));let u=o.x||e.x-m,f=o.y||e.y-d/2,b=p?p.type:o.type;if(b){if(b==="text"){let x="";p&&p.type==="text"?x=p.text:o.type==="text"&&(x=o.text),x||console.error(`No text found for start binding text element for ${e.id}`),i=Ft({x:u,y:f,type:"text",...p,...o,text:x}),Object.assign(i,{x:o.x||e.x-i.width,y:o.y||e.y-i.height/2})}else switch(b){case"rectangle":case"ellipse":case"diamond":{i=qt({x:u,y:f,width:m,height:d,...p,...o,type:b});break}default:Ii(e,`Unhandled element start type "${o.type}"`,!0)}Ri(e,i,"start",n)}}if(t){let m=t?.height??Cn,d=t?.width??Cn,p;t.id&&(p=r.getElement(t.id),p||console.error(`No element for end binding with id ${t.id} found`));let u=t.x||e.x+e.width,f=t.y||e.y-m/2,b=p?p.type:t.type;if(b){if(b==="text"){let x="";p&&p.type==="text"?x=p.text:t.type==="text"&&(x=t.text),x||console.error(`No text found for end binding text element for ${e.id}`),a=Ft({x:u,y:f,type:"text",...p,...t,text:x}),Object.assign(a,{y:t.y||e.y-a.height/2})}else switch(b){case"rectangle":case"ellipse":case"diamond":{a=qt({x:u,y:f,width:d,height:m,...p,...t,type:b});break}default:Ii(e,`Unhandled element end type "${b}"`,!0)}Ri(e,a,"end",n)}}if(e.points.length<2)return{linearElement:e,startBoundElement:i,endBoundElement:a};let l=e.points.length-1,s=.5,c=jt(e.points);return e.points[l][0]>e.points[l-1][0]&&(c[0][0]=s,c[l][0]-=s),e.points[l][0]<e.points[l-1][0]&&(c[0][0]=-s,c[l][0]+=s),e.points[l][1]>e.points[l-1][1]&&(c[0][1]=s,c[l][1]-=s),e.points[l][1]<e.points[l-1][1]&&(c[0][1]=-s,c[l][1]+=s),Object.assign(e,$.getNormalizeElementPointsAndCoords({...e,points:c})),{linearElement:e,startBoundElement:i,endBoundElement:a}},ag=class{constructor(){k(this,"excalidrawElements",new Map);k(this,"add",o=>{o&&this.excalidrawElements.set(o.id,o)});k(this,"getElements",()=>en(Array.from(this.excalidrawElements.values())));k(this,"getElementsMap",()=>Ks(j(this.getElements())));k(this,"getElement",o=>this.excalidrawElements.get(o))}},Na=(e,o)=>{if(!e)return[];let t=jt(e),r=new ag,n=new Map,i=new Map;for(let s of t){let c,m=s.id;switch(o?.regenerateIds!==!1&&Object.assign(s,{id:mo()}),s.type){case"rectangle":case"ellipse":case"diamond":{let p=s?.label?.text&&s.width===void 0?0:s?.width||Cn,u=s?.label?.text&&s.height===void 0?0:s?.height||Cn;c=qt({...s,width:p,height:u});break}case"line":{let p=s.width||nm.width,u=s.height||nm.height;c=Co({width:p,height:u,points:[L(0,0),L(p,u)],...s});break}case"arrow":{let p=s.width||nm.width,u=s.height||nm.height;c=tn({width:p,height:u,endArrowhead:"arrow",points:[L(0,0),L(p,u)],...s,type:"arrow"}),Object.assign(c,c1(c.points));break}case"text":{let p=s?.fontFamily||Fr,u=s?.fontSize||Er,f=s?.lineHeight||zo(p),b=s.text??"",x=Zn(b),E=vt(x,et({fontFamily:p,fontSize:u}),f);c=Ft({width:E.width,height:E.height,fontFamily:p,fontSize:u,...s});break}case"image":{c=Ec({width:s?.width||Cn,height:s?.height||Cn,...s});break}case"frame":{c=Hi({x:0,y:0,...s});break}case"magicframe":{c=bl({x:0,y:0,...s});break}case"freedraw":case"iframe":case"embeddable":{c=s;break}default:c=s,Ii(s,`Unhandled element type "${s.type}"`,!0)}r.getElement(c.id)?console.error(`Duplicate id found for ${c.id}`):(r.add(c),n.set(c.id,s),m&&i.set(m,c.id))}let a=r.getElementsMap(),l=new fl(a);for(let[s,c]of n){let m=r.getElement(s);switch(c.type){case"rectangle":case"ellipse":case"diamond":case"arrow":{if(c.label?.text){let[d,p]=eS(m,c?.label,l);if(r.add(d),r.add(p),Pe(d)){let u=c.type==="arrow"?c?.start:void 0,f=c.type==="arrow"?c?.end:void 0;if(u&&u.id){let y=i.get(u.id);y&&Object.assign(u,{id:y})}if(f&&f.id){let y=i.get(f.id);y&&Object.assign(f,{id:y})}let{linearElement:b,startBoundElement:x,endBoundElement:E}=yv(d,u,f,r,l);d=b,r.add(b),r.add(x),r.add(E)}}else switch(c.type){case"arrow":{let{start:d,end:p}=c;if(d&&d.id){let x=i.get(d.id);Object.assign(d,{id:x})}if(p&&p.id){let x=i.get(p.id);Object.assign(p,{id:x})}let{linearElement:u,startBoundElement:f,endBoundElement:b}=yv(m,d,p,r,l);r.add(u),r.add(f),r.add(b);break}}break}}}for(let[s,c]of n){if(c.type!=="frame"&&c.type!=="magicframe")continue;let m=r.getElement(s);if(!m)throw new Error(`Excalidraw element with id ${s} doesn't exist`);let d=[];c.children.forEach(I=>{let S=i.get(I);if(!S)throw new Error(`Element with ${I} wasn't mapped correctly`);let P=r.getElement(S);if(!P)throw new Error(`Frame element with id ${S} doesn't exist`);Object.assign(P,{frameId:m.id}),P?.boundElements?.forEach(M=>{let O=r.getElement(M.id);if(!O)throw new Error(`Bound element with id ${M.id} doesn't exist`);Object.assign(O,{frameId:m.id}),d.push(O)}),d.push(P)});let[p,u,f,b]=ye(d),x=10;p=p-x,u=u-x,f=f+x,b=b+x;let E=m?.x||p,y=m?.y||u,v=m?.width||f-p,T=m?.height||b-u;Object.assign(m,{x:E,y,width:v,height:T}),ft()&&c.children.length&&(m?.x||m?.y||m?.width||m?.height)&&console.info("User provided frame attributes are being considered, if you find this inaccurate, please remove any of the attributes - x, y, width and height so frame coordinates and dimensions are calculated automatically")}return r.getElements()};import im from"open-color";var tS="#ff6b6b",oS="#ff0000",vv=1,wv=2,Tv=(e,o)=>{if(!o.snapLines.length)return;let t=o.theme===re.LIGHT||o.zenModeEnabled?tS:oS,r=(o.zenModeEnabled?vv*1.5:vv)/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY);for(let n of o.snapLines)n.type==="pointer"?(e.lineWidth=r,e.strokeStyle=t,nS(n,e,o)):n.type==="gap"?(e.lineWidth=r,e.strokeStyle=t,iS(n.points[0],n.points[1],n.direction,o,e)):n.type==="points"&&(e.lineWidth=r,e.strokeStyle=t,rS(n,e,o));e.restore()},rS=(e,o,t)=>{if(!t.zenModeEnabled){let r=e.points[0],n=e.points[e.points.length-1];Do(r,n,o)}for(let r of e.points)Cv(r,t,o)},nS=(e,o,t)=>{Cv(e.points[0],t,o),t.zenModeEnabled||Do(e.points[0],e.points[1],o)},Cv=([e,o],t,r)=>{r.save();let n=(t.zenModeEnabled?wv*1.5:wv)/t.zoom.value;r.beginPath(),r.moveTo(e-n,o-n),r.lineTo(e+n,o+n),r.moveTo(e+n,o-n),r.lineTo(e-n,o+n),r.stroke(),r.restore()},Do=(e,o,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(o[0],o[1]),t.stroke()},iS=(e,o,t,r,n)=>{let i=8/r.zoom.value,a=i/2,l=i/4;if(t==="horizontal"){let s=[(e[0]+o[0])/2,e[1]];r.zenModeEnabled||Do(L(e[0],e[1]-i),L(e[0],e[1]+i),n),Do(L(s[0]-l,s[1]-a),L(s[0]-l,s[1]+a),n),Do(L(s[0]+l,s[1]-a),L(s[0]+l,s[1]+a),n),r.zenModeEnabled||(Do(L(o[0],o[1]-i),L(o[0],o[1]+i),n),Do(e,o,n))}else{let s=[e[0],(e[1]+o[1])/2];r.zenModeEnabled||Do(L(e[0]-i,e[1]),L(e[0]+i,e[1]),n),Do(L(s[0]-a,s[1]-l),L(s[0]+a,s[1]-l),n),Do(L(s[0]-a,s[1]+l),L(s[0]+a,s[1]+l),n),r.zenModeEnabled||(Do(L(o[0]-i,o[1]),L(o[0]+i,o[1]),n),Do(e,o,n))}};var Jo=4,no=6,kv="rgba(0,0,0,0.3)",Sv=(e,o,t,r)=>{if(!e.size)return{horizontal:null,vertical:null};let[n,i,a,l]=ye(e),s=o/r.zoom.value,c=t/r.zoom.value,m={top:parseInt(al("sat"))||0,bottom:parseInt(al("sab"))||0,left:parseInt(al("sal"))||0,right:parseInt(al("sar"))||0},d=Ir().rtl,p=-r.scrollX+m.left,u=-r.scrollY+m.top,f=p+s-m.right,b=u+c-m.bottom,x=Math.min(n,p),E=Math.min(i,u),y=Math.max(a,f),v=Math.max(l,b),T=a-n,I=l-i,S=y-x,P=v-E,M=Math.max(Jo*2,m.left+m.right)+no*2,O=o*(s/S)-M,R=Math.max(Jo*2,m.top+m.bottom)+no*2,z=t*(c/P)-R,W=S>T?S*r.zoom.value/(O+M):o/(O+M),Y=P>I?P*r.zoom.value/(z+R):t/(z+R);return{horizontal:p===x&&f===y?null:{x:Math.max(m.left,Jo)+no+(p-x)/S*o,y:t-no-Math.max(Jo,m.bottom),width:O,height:no,deltaMultiplier:W},vertical:u===E&&b===v?null:{x:d?Math.max(m.left,Jo):o-no-Math.max(m.right,Jo),y:Math.max(m.top,Jo)+no+(u-E)/P*t,width:no,height:z,deltaMultiplier:Y}}},lg=(e,o,t)=>{let[r,n]=[e.horizontal,e.vertical].map(a=>a!=null&&a.x<=o&&o<=a.x+a.width&&a.y<=t&&t<=a.y+a.height);return{isOverEither:r||n,isOverHorizontal:r,isOverVertical:n}};var aS=(e,o)=>{Ws(o.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=o.selectedLinearElement;Ws(t,"midPointCoords is null"),e.save(),e.translate(o.scrollX,o.scrollY),Lv(t,e,o),e.restore()},lS=(e,o,t)=>{let{elementId:r,hoverPointIndex:n}=o.selectedLinearElement;if(o.editingLinearElement?.selectedPointsIndices?.includes(n))return;let i=$.getElement(r,t);if(!i)return;let a=$.getPointAtIndexGlobalCoordinates(i,n,t);e.save(),e.translate(o.scrollX,o.scrollY),Lv(a,e,o),e.restore()},Lv=(e,o,t)=>{o.fillStyle="rgba(105, 101, 219, 0.4)",El(o,e[0],e[1],$.POINT_HANDLE_SIZE/t.zoom.value,!1)},sg=(e,o,t,r,n,i,a)=>{e.strokeStyle="#5e5ad8",e.setLineDash([]),e.fillStyle="rgba(255, 255, 255, 0.9)",n?e.fillStyle="rgba(134, 131, 226, 0.9)":i&&(e.fillStyle="rgba(177, 151, 252, 0.7)"),El(e,t[0],t[1],(a?r*(o.editingLinearElement?1.5:2):r)/o.zoom.value,!i,!a||n)},sS=(e,o,t,r)=>{let n=wp(o,o.width,o.height,r);switch(e.fillStyle="rgba(0,0,0,.05)",o.type){case"rectangle":case"text":case"image":case"iframe":case"embeddable":case"frame":case"magicframe":lb(e,o,t,n);break;case"diamond":cb(e,n,o,t);break;case"ellipse":{let[i,a,l,s]=at(o,t),c=l-i,m=s-a;e.strokeStyle="rgba(0,0,0,.05)",e.lineWidth=n-oc,sb(e,c+n+oc,m+n+oc,i+c/2,a+m/2,o.angle);break}}},cS=(e,o,t,r)=>{let[n,i,a]=o,l=wp(a,a.width,a.height,r);e.strokeStyle="rgba(0,0,0,0)",e.fillStyle="rgba(0,0,0,.05)",(i==="both"?[0,-1]:i==="start"?[0]:[-1]).forEach(c=>{let[m,d]=$.getPointAtIndexGlobalCoordinates(n,c,t);El(e,m,d,l,!0)})},Av=(e,o,t)=>{let{angle:r,x1:n,y1:i,x2:a,y2:l,selectionColors:s,cx:c,cy:m,dashed:d,activeEmbeddable:p}=t,u=a-n,f=l-i,x=(t.padding??_s*2)/o.zoom.value,E=8/o.zoom.value,y=4/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=(p?4:1)/o.zoom.value;let v=s.length;for(let T=0;T<v;++T)e.strokeStyle=s[T],d&&e.setLineDash([E,y+(E+y)*(v-1)]),e.lineDashOffset=(E+y)*T,yl(e,n-x,i-x,u+x*2,f+x*2,c,m,r);e.restore()},dS=(e,o,t,r)=>{let n=Array.isArray(t)?cS:sS;e.save(),e.translate(o.scrollX,o.scrollY),n(e,t,r,o.zoom),e.restore()},mS=(e,o,t,r)=>{let[n,i,a,l]=at(t,r),s=a-n,c=l-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=Pt.strokeWidth/o.zoom.value,e.save(),e.translate(o.scrollX,o.scrollY),yl(e,n,i,s,c,n+s/2,i+c/2,t.angle,!1,Pt.radius/o.zoom.value),e.restore()},Iv=(e,o,t,r)=>{let{colors:n=["rgb(0,118,255)"],dashed:i=!1}=r||{},a=t.filter(m=>m.groupIds.length===0),l=t.filter(m=>m.groupIds.length>0),s=m=>{let[d,p,u,f]=ye(m);return{angle:0,x1:d,x2:u,y1:p,y2:f,selectionColors:n,dashed:i,cx:d+(u-d)/2,cy:p+(f-p)/2,activeEmbeddable:!1}},c=m=>{let d=He(t,m);return s(d)};Object.entries(Xn(l,o)).filter(([m,d])=>d).map(([m,d])=>m).map(m=>c(m)).concat(a.map(m=>s([m]))).forEach(m=>Av(e,o,m))},cg=(e,o,t,r)=>{if(!o.selectedLinearElement)return;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=1/o.zoom.value;let n=$.getPointsGlobalCoordinates(t,r),{POINT_HANDLE_SIZE:i}=$,a=o.editingLinearElement?i:i/2,l=se(t),s=qe(t);if(n.forEach((c,m)=>{if(l&&m!==0&&m!==n.length-1)return;let d=m>0&&(m!==n.length-1||!s||!t.polygon)&&mp(c,m===n.length-1?n[0]:n[m-1],2/o.zoom.value),p=!!o.editingLinearElement?.selectedPointsIndices?.includes(m);s&&t.polygon&&!p&&m===t.points.length-1&&o.editingLinearElement?.selectedPointsIndices?.includes(0)&&(p=!0),sg(e,o,c,a,p,!1,d)}),se(t)){let c=t.fixedSegments?.map(m=>m.index)||[];n.slice(0,-1).forEach((m,d)=>{$.isSegmentTooShort(t,n[d+1],n[d],d,o.zoom)||sg(e,o,L((m[0]+n[d+1][0])/2,(m[1]+n[d+1][1])/2),i/2,!1,!c.includes(d+1),!1)})}else $.getEditorMidPoints(t,r,o).filter((m,d,p)=>m!==null&&!(se(t)&&(d===0||d===p.length-1))).forEach(m=>{(o.editingLinearElement||n.length===2)&&sg(e,o,m,i/2,!1,!0,!1)});e.restore()},Mv=(e,o,t,r,n)=>{Object.keys(r).forEach(i=>{let a=r[i];if(a!==void 0){let[l,s,c,m]=a;e.save(),e.lineWidth=1/t.zoom.value,o.selectionColor&&(e.strokeStyle=o.selectionColor),i==="rotation"?El(e,l+c/2,s+m/2,c/2,!0):e.roundRect?(e.beginPath(),e.roundRect(l,s,c,m,2/t.zoom.value),e.fill(),e.stroke()):yl(e,l,s,c,m,l+c/2,s+m/2,n,!0),e.restore()}})},pS=(e,o,t,r,n)=>{let[i,a,,,l,s]=at(r,n),c=3,m=20,d=c/t.zoom.value,p=d/2,u=l-i+d,f=s-a+d,b=Math.min(m/t.zoom.value,u),x=Math.min(m/t.zoom.value,f);e.save(),e.fillStyle=o.selectionColor,e.strokeStyle=o.selectionColor,e.lineWidth=d,[[[-u,-f],[0,p],[b,p],[p,0],[p,x]],[[u-p,-f],[p,p],[-b+p,p],[0,0],[0,x]],[[-u,f],[0,-p],[b,-p],[p,0],[p,-x]],[[u-p,f],[p,-p],[-b+p,-p],[0,0],[0,-x]]].forEach(y=>{let[[v,T],[I,S],[P,M],[O,R],[z,W]]=y;e.save(),e.translate(l,s),e.rotate(r.angle),e.beginPath(),e.moveTo(v+I,T+S),e.lineTo(v+P,T+M),e.stroke(),e.beginPath(),e.moveTo(v+O,T+R),e.lineTo(v+z,T+W),e.stroke(),e.restore()}),e.restore()},uS=(e,o,t,r)=>{o.save();let n=_s*2/t.zoom.value,i=e.width+n*2,a=e.height+n*2,l=e.x+i/2,s=e.y+a/2,c=-(i/2+n),m=-(a/2+n);o.translate(l+t.scrollX,s+t.scrollY),o.rotate(e.angle),o.lineWidth=1/t.zoom.value,o.strokeStyle=r,o.strokeRect(c,m,i,a),o.restore()},_v=({canvas:e,elementsMap:o,visibleElements:t,selectedElements:r,allElementsMap:n,scale:i,appState:a,renderConfig:l,device:s})=>{if(e===null)return{atLeastOneVisibleElement:!1,elementsMap:o};let[c,m]=kc(e,i),d=Sc({canvas:e,scale:i,normalizedWidth:c,normalizedHeight:m});d.save(),d.scale(a.zoom.value,a.zoom.value);let p;if(t.forEach(b=>{a.editingLinearElement?.elementId===b.id&&b&&(p=b)}),p&&cg(d,a,p,o),a.selectionElement&&!a.isCropping)try{E0(a.selectionElement,d,a,l.selectionColor)}catch(b){console.error(b)}if(a.editingTextElement&&V(a.editingTextElement)){let b=n.get(a.editingTextElement.id);b&&!b.autoResize&&uS(b,d,a,l.selectionColor)}if(a.isBindingEnabled&&a.suggestedBindings.filter(b=>b!=null).forEach(b=>{dS(d,a,b,o)}),a.frameToHighlight&&mS(d,a,a.frameToHighlight,o),a.elementsToHighlight&&Iv(d,a,a.elementsToHighlight),a.activeLockedId){let b=n.get(a.activeLockedId),x=b?[b]:He(n,a.activeLockedId);Iv(d,a,x,{colors:["#ced4da"],dashed:!0})}let u=r.some(b=>ce(b));if(r.length===1&&a.editingLinearElement?.elementId===r[0].id&&cg(d,a,r[0],o),a.selectedLinearElement){let b=a.selectedLinearElement,x=r.find(E=>E.id===b.elementId);b.segmentMidPointHoveredCoords?aS(d,a):(se(x)?b.hoverPointIndex===0||b.hoverPointIndex===x.points.length-1:b.hoverPointIndex>=0)&&lS(d,a,o)}if(!a.multiElement&&!a.editingLinearElement){let b=vc(r,a),x=r.length===1&&ge(r[0]);x&&a.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&cg(d,a,r[0],o);let E=l.selectionColor||im.black;if(b){let y=j(r),v=[];for(let I of o.values()){let S=[],P=l.remoteSelectedElementIds.get(I.id);if(x&&se(I)&&(I.startBinding||I.endBinding)||(y.has(I.id)&&!ic(a,I)&&S.push(E),P&&S.push(...P.map(M=>pi(M,a.collaborators.get(M))))),S.length){let[M,O,R,z,W,Y]=at(I,o,!0);v.push({angle:I.angle,x1:M,y1:O,x2:R,y2:z,selectionColors:I.locked?["#ced4da"]:S,dashed:!!P||I.locked,cx:W,cy:Y,activeEmbeddable:a.activeEmbeddable?.element===I&&a.activeEmbeddable.state==="active",padding:I.id===a.croppingElementId||Ne(I)?0:void 0})}}let T=I=>{let S=He(o,I),[P,M,O,R]=ye(S);v.push({angle:0,x1:P,x2:O,y1:M,y2:R,selectionColors:S.some(z=>z.locked)?["#ced4da"]:[im.black],dashed:!0,cx:P+(O-P)/2,cy:M+(R-M)/2,activeEmbeddable:!1})};for(let I of Yo(a))T(I);a.editingGroupId&&T(a.editingGroupId),v.forEach(I=>Av(d,a,I))}if(d.save(),d.translate(a.scrollX,a.scrollY),r.length===1){d.fillStyle=im.white;let y=$0(r[0],a.zoom,o,"mouse",yc(s));if(!a.viewModeEnabled&&b&&!V(a.editingTextElement)&&!a.croppingElementId&&Mv(d,l,a,y,r[0].angle),a.croppingElementId&&!a.isCropping){let v=o.get(a.croppingElementId);v&&Ne(v)&&pS(d,l,a,v,o)}}else if(r.length>1&&!a.isRotating&&!r.some(y=>y.locked)){let y=_s*2/a.zoom.value;d.fillStyle=im.white;let[v,T,I,S]=ye(r,o),P=d.getLineDash();d.setLineDash([2/a.zoom.value]);let M=d.lineWidth;d.lineWidth=1/a.zoom.value,d.strokeStyle=E,yl(d,v-y,T-y,I-v+y*2,S-T+y*2,(v+I)/2,(T+S)/2,0),d.lineWidth=M,d.setLineDash(P);let O=X0([v,T,I,S,(v+I)/2,(T+S)/2],0,a.zoom,"mouse",u?{...yc(s),rotation:!0}:yc(s));r.some(R=>!R.locked)&&Mv(d,l,a,O,0)}d.restore()}a.searchMatches?.matches.forEach(({id:b,focus:x,matchedLines:E})=>{let y=o.get(b);if(y){let[v,T,,,I,S]=at(y,o,!0);d.save(),a.theme===re.LIGHT?x?d.fillStyle="rgba(255, 124, 0, 0.4)":d.fillStyle="rgba(255, 226, 0, 0.4)":x?d.fillStyle="rgba(229, 82, 0, 0.4)":d.fillStyle="rgba(99, 52, 0, 0.4)";let P=ce(y)?a.zoom.value:1;d.translate(a.scrollX,a.scrollY),d.translate(I,S),d.rotate(y.angle),E.forEach(M=>{(M.showOnCanvas||x)&&d.fillRect(v+M.offsetX/P-I,T+M.offsetY/P-S,M.width/P,M.height/P)}),d.restore()}}),Tv(d,a),d.restore(),S2({context:d,renderConfig:l,appState:a,normalizedWidth:c,normalizedHeight:m});let f;return l.renderScrollbars&&(f=Sv(o,c,m,a),d.save(),d.fillStyle=kv,d.strokeStyle="rgba(255,255,255,0.8)",[f.horizontal,f.vertical].forEach(b=>{b&&Cd(d,b.x,b.y,b.width,b.height,no/2)}),d.restore()),{scrollBars:f,atLeastOneVisibleElement:t.length>0,elementsMap:o}},dg=ki(e=>{let o=_v(e);e.callback?.(o)},{trailing:!0}),Pv=(e,o)=>{if(o){dg(e);return}let t=_v(e);return e.callback(t),t};var as=class{constructor(o){k(this,"scene");k(this,"getRenderableElements",(()=>{let o=({elementsMap:r,zoom:n,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s,height:c,width:m})=>{let d=[];for(let p of r.values())gl(p,m,c,{zoom:n,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s},r)&&d.push(p);return d},t=({elements:r,editingTextElement:n,newElementId:i})=>{let a=Ks(new Map);for(let l of r)i!==l.id&&(!n||n.type!=="text"||l.id!==n.id)&&a.set(l.id,l);return a};return w1(({zoom:r,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:l,height:s,width:c,editingTextElement:m,newElementId:d,sceneNonce:p})=>{let u=this.scene.getNonDeletedElements(),f=t({elements:u,editingTextElement:m,newElementId:d}),b=o({elementsMap:f,zoom:r,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:l,height:s,width:c});return{elementsMap:f,visibleElements:b}})})());this.scene=o}destroy(){dg.cancel(),db.cancel(),this.getRenderableElements.clear()}};import{jsx as fS}from"react/jsx-runtime";var hS=5,gS=(e,o,t)=>{let[r,n]=at(e,t),{x:i,y:a}=gt({sceneX:r+e.width,sceneY:n},o),l=i-o.offsetLeft+10,s=a-o.offsetTop;return{x:l,y:s}},mg=({children:e,element:o,elementsMap:t})=>{let r=sr();if(r.contextMenu||r.newElement||r.resizingElement||r.isRotating||r.openMenu||r.viewModeEnabled)return null;let{x:n,y:i}=gS(o,r,t);return fS("div",{className:"excalidraw-canvas-buttons",style:{top:`${i}px`,left:`${n}px`,padding:hS},children:e})};import{LaserPointer as bS}from"@excalidraw/laser-pointer";var Nr=class{constructor(o,t,r){this.animationFrameHandler=o;this.app=t;this.options=r;k(this,"currentTrail");k(this,"pastTrails",[]);k(this,"container");k(this,"trailElement");k(this,"trailAnimation");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.trailElement=document.createElementNS(rp,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(rp,"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(o,t){if(this.currentTrail){let r=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[r-1][0]===o&&this.currentTrail.originalPoints[r-1][1]===t}return!1}start(o){o&&(this.container=o),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),this.animationFrameHandler.start(this)}stop(){this.animationFrameHandler.stop(this),this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}startPath(o,t){this.currentTrail=new bS(this.options),this.currentTrail.addPoint([o,t,performance.now()]),this.update()}addPointToPath(o,t){this.currentTrail&&(this.currentTrail.addPoint([o,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 o=[];for(let r of this.pastTrails)o.push(this.drawTrail(r,this.app.state));if(this.currentTrail){let r=this.drawTrail(this.currentTrail,this.app.state);o.push(r)}this.pastTrails=this.pastTrails.filter(r=>r.getStrokeOutline().length!==0),o.length===0&&this.stop();let t=o.join(" ").trim();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))}drawTrail(o,t){let r=o.getStrokeOutline(o.options.size/t.zoom.value).map(([i,a])=>{let l=gt({sceneX:i,sceneY:a},t);return[l.x,l.y]}),n=this.trailAnimation?r.slice(0,r.length/2):r;return T1(n,!0)}};var am=class{constructor(o,t){this.animationFrameHandler=o;this.app=t;k(this,"localTrail");k(this,"collabTrails",new Map);k(this,"container");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.localTrail=new Nr(o,t,{...this.getTrailOptions(),fill:()=>$m})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:o=>{let n=Math.max(0,1-(performance.now()-o.pressure)/1e3),i=(50-Math.min(50,o.totalLength-o.currentIndex))/50;return Math.min(Ho(i),Ho(n))}}}startPath(o,t){this.localTrail.startPath(o,t)}addPointToPath(o,t){this.localTrail.addPointToPath(o,t)}endPath(){this.localTrail.endPath()}start(o){this.container=o,this.animationFrameHandler.start(this),this.localTrail.start(o)}stop(){this.animationFrameHandler.stop(this),this.localTrail.stop()}onFrame(){this.updateCollabTrails()}updateCollabTrails(){if(!(!this.container||this.app.state.collaborators.size===0)){for(let[o,t]of this.app.state.collaborators.entries()){let r;this.collabTrails.has(o)?r=this.collabTrails.get(o):(r=new Nr(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>t.pointer?.laserColor||pi(o,t)}),r.start(this.container),this.collabTrails.set(o,r)),t.pointer&&t.pointer.tool==="laser"&&(t.button==="down"&&!r.hasCurrentTrail&&r.startPath(t.pointer.x,t.pointer.y),t.button==="down"&&r.hasCurrentTrail&&!r.hasLastPoint(t.pointer.x,t.pointer.y)&&r.addPointToPath(t.pointer.x,t.pointer.y),t.button==="up"&&r.hasCurrentTrail&&(r.addPointToPath(t.pointer.x,t.pointer.y),r.endPath()))}for(let o of this.collabTrails.keys())this.app.state.collaborators.has(o)||(this.collabTrails.get(o).stop(),this.collabTrails.delete(o))}}};import{version as xS}from"react";import{unstable_batchedUpdates as Dv}from"react-dom";var $e=e=>o=>{Dv(e,o)},lm=e=>ki(o=>{Dv(e,o)}),Oa=(()=>{let e;try{let t=xS.split(".");e=Number(t[0])>17}catch{e=!1}let o=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(o||(o=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})();var ES=(e,o,t,r,n,i)=>{let{zoom:a}=r,l=180*t/Math.PI,s=e*(a.value-1)/2,c=o*(a.value-1)/2;return e>n&&a.value!==1&&(s=n*(a.value-1)/2),o>i&&a.value!==1&&(c=i*(a.value-1)/2),`translate(${s}px, ${c}px) scale(${a.value}) rotate(${l}deg)`},Rv=({id:e,onChange:o,onSubmit:t,getViewportCoords:r,element:n,canvas:i,excalidrawContainer:a,app:l,autoSelect:s=!0})=>{let c=(H,F)=>{if(!F.style.fontFamily||!F.style.fontSize)return!1;let ee=F.style.fontFamily.replace(/"/g,"");return Hn({fontFamily:H.fontFamily})!==ee||`${H.fontSize}px`!==F.style.fontSize},m=()=>{let H=l.state,F=l.scene.getElement(e);if(!F)return;let{textAlign:ee,verticalAlign:ie}=F,X=l.scene.getNonDeletedElementsMap();if(F&&V(F)){let de=F.x,he=F.y,Ce=vo(F,l.scene.getNonDeletedElementsMap()),mt=F.width,so=F.height,Nn=F.width,Ei=F.height;if(Ce&&F.containerId){if(Pe(Ce)){let zr=$.getBoundTextElementPosition(Ce,F,X);de=zr.x,he=zr.y}let Cs=c(F,d),Za;if(Cs?Za=cl(Ce.id,Ce.height):(Za=B1[Ce.id],Za||(Za=cl(Ce.id,Ce.height))),Nn=ml(Ce,F),Ei=Qs(Ce,F),!Pe(Ce)&&so>Ei){let zr=_i(so,Ce.type);l.scene.mutateElement(Ce,{height:zr});return}else if(!Pe(Ce)&&Ce.height>Za.height&&so<Ei){let zr=_i(so,Ce.type);l.scene.mutateElement(Ce,{height:zr})}else{let{y:zr}=Zr(Ce,F,X);he=zr}}let[Km,yf]=r(de,he),v5=d.selectionStart,Zm=d.selectionEnd,vf=d.value.length;if(v5===Zm&&Zm!==vf){let Cs=vf-Zm;d.selectionStart=d.value.length-Cs,d.selectionEnd=d.value.length-Cs}Ce?mt+=.5:(Nn=(H.width-8-Km)/H.zoom.value,mt=Math.min(mt,Nn)),so*=1.05;let w5=et(F),wf=(H.height-yf)/H.zoom.value;Object.assign(d.style,{font:w5,lineHeight:F.lineHeight,width:`${mt}px`,height:`${so}px`,left:`${Km}px`,top:`${yf}px`,transform:ES(mt,so,Z1(F,Ce),H,Nn,wf),textAlign:ee,verticalAlign:ie,color:F.strokeColor,opacity:F.opacity/100,filter:"var(--theme-filter)",maxHeight:`${wf}px`}),d.scrollTop=0,rr()&&(d.style.fontFamily=Hn(F)),l.scene.mutateElement(F,{x:de,y:he})}},d=document.createElement("textarea");d.dir="auto",d.tabIndex=0,d.dataset.type="wysiwyg",d.wrap="off",d.classList.add("excalidraw-wysiwyg");let p="pre",u="normal";(rt(n)||!n.autoResize)&&(p="pre-wrap",u="break-word"),Object.assign(d.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:u,whiteSpace:p,overflowWrap:"break-word",boxSizing:"content-box"}),d.value=n.originalText,m(),o&&(d.onpaste=async H=>{let F=await vd(H,!0);if(!F.text)return;let ee=Zn(F.text);if(!ee)return;let ie=vo(n,l.scene.getNonDeletedElementsMap()),X=et({fontSize:l.state.currentItemFontSize,fontFamily:l.state.currentItemFontFamily});if(ie){let de=pe(ie,l.scene.getNonDeletedElementsMap()),he=Ai(`${d.value}${ee}`,X,ml(ie,de)),Ce=V1(he,X);d.style.width=`${Ce}px`}},d.oninput=()=>{let H=Zn(d.value);if(d.value!==H){let F=d.selectionStart;d.value=H,d.selectionStart=F,d.selectionEnd=F}o(d.value)}),d.onkeydown=H=>{if(!H.shiftKey&&hd.keyTest(H))H.preventDefault(),l.actionManager.executeAction(hd),m();else if(!H.shiftKey&&gd.keyTest(H))H.preventDefault(),l.actionManager.executeAction(gd),m();else if(!H.shiftKey&&fd.keyTest(H))H.preventDefault(),l.actionManager.executeAction(fd),m();else if(th.keyTest(H))l.actionManager.executeAction(th);else if(oh.keyTest(H))l.actionManager.executeAction(oh);else if(H.key===w.ESCAPE)H.preventDefault(),I=!0,S();else if(di.keyTest(H))H.preventDefault(),S(),l.actionManager.executeAction(di);else if(H.key===w.ENTER&&H[w.CTRL_OR_CMD]){if(H.preventDefault(),H.isComposing||H.keyCode===229)return;I=!0,S()}else if(H.key===w.TAB||H[w.CTRL_OR_CMD]&&(H.code===le.BRACKET_LEFT||H.code===le.BRACKET_RIGHT)){if(H.preventDefault(),H.isComposing)return;H.shiftKey||H.code===le.BRACKET_LEFT?y():E(),d.dispatchEvent(new Event("input"))}};let f=4,b=" ".repeat(f),x=new RegExp(`^ {1,${f}}`),E=()=>{let{selectionStart:H,selectionEnd:F}=d,ee=v(),ie=d.value;ee.forEach(X=>{let de=ie.slice(0,X),he=ie.slice(X);ie=`${de}${b}${he}`}),d.value=ie,d.selectionStart=H+f,d.selectionEnd=F+f*ee.length},y=()=>{let{selectionStart:H,selectionEnd:F}=d,ee=v(),ie=[],X=d.value;ee.forEach(de=>{let he=X.slice(de,de+f).match(x);if(he){let Ce=X.slice(0,de),mt=X.slice(de+he[0].length);X=`${Ce}${mt}`,ie.push(de)}}),d.value=X,ie.length&&(H>ie[ie.length-1]?d.selectionStart=Math.max(H-f,ie[ie.length-1]):d.selectionStart=H,d.selectionEnd=Math.max(d.selectionStart,F-f*ie.length))},v=()=>{let{selectionStart:H,selectionEnd:F,value:ee}=d,ie=ee.slice(0,H).match(/[^\n]*$/)[0].length;return H=H-ie,ee.slice(H,F).split(`
9
- `).reduce((de,he,Ce,mt)=>de.concat(Ce?de[Ce-1]+mt[Ce-1].length+1:H),[]).reverse()},T=H=>{H.target instanceof HTMLCanvasElement&&(H.preventDefault(),H.stopPropagation())},I=!1,S=()=>{if(Y)return;Y=!0,P();let H=l.scene.getElement(n.id);if(!H)return;let F=vo(H,l.scene.getNonDeletedElementsMap());if(F){if(d.value.trim()){let ee=dl(F);!ee||ee!==n.id?l.scene.mutateElement(F,{boundElements:(F.boundElements||[]).concat({type:"text",id:n.id})}):Pe(F)&&kr(F)}else l.scene.mutateElement(F,{boundElements:F.boundElements?.filter(ee=>!V(ee))});Ke(H,F,l.scene)}t({viaKeyboard:I,nextOriginalText:d.value})},P=()=>{d.onblur=null,d.oninput=null,d.onkeydown=null,oe&&oe.disconnect(),window.removeEventListener("resize",m),window.removeEventListener("wheel",T,!0),window.removeEventListener("pointerdown",R),window.removeEventListener("pointerup",M),window.removeEventListener("blur",S),window.removeEventListener("beforeunload",S),z(),W(),d.remove()},M=H=>{window.removeEventListener("pointerup",M);let F=H?.target,ee=F instanceof HTMLElement&&F.classList.contains("properties-trigger");setTimeout(()=>{d.onblur=S,ee||d.focus()})},O=()=>{d.onblur=null,window.addEventListener("pointerup",M),window.addEventListener("blur",S)},R=H=>{let F=H?.target;if(H.button===tr.WHEEL){F instanceof HTMLTextAreaElement&&(H.preventDefault(),l.handleCanvasPanUsingWheelOrSpaceDrag(H)),O();return}let ee=F instanceof HTMLElement&&F.classList.contains("properties-trigger");(H.target instanceof HTMLElement||H.target instanceof SVGElement)&&H.target.closest(`.${Bt.SHAPE_ACTIONS_MENU}, .${Bt.ZOOM_ACTIONS}`)&&!or(H.target)||ee?O():H.target instanceof HTMLCanvasElement&&!rr()&&requestAnimationFrame(()=>{S()})},z=l.scene.onUpdate(()=>{m(),!!document.activeElement?.closest(".properties-content")||d.focus()}),W=l.onScrollChangeEmitter.on(()=>{m()}),Y=!1;s&&d.select(),M();let oe=null;return i&&"ResizeObserver"in window?(oe=new window.ResizeObserver(()=>{m()}),oe.observe(i)):window.addEventListener("resize",m),d.onpointerdown=H=>H.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",R,{capture:!0})}),window.addEventListener("beforeunload",S),a?.querySelector(".excalidraw-textEditorContainer").appendChild(d),S};var Nv=e=>{let o=["flowchart","graph","sequenceDiagram","classDiagram","stateDiagram","stateDiagram-v2","erDiagram","journey","gantt","pie","quadrantChart","requirementDiagram","gitGraph","C4Context","mindmap","timeline","zenuml","sankey","xychart","block"];return new RegExp(`^(?:%%{.*?}%%[\\s\\n]*)?\\b(?:${o.map(r=>`\\s*${r}(-beta)?`).join("|")})\\b`).test(e.trim())};import{simplify as yS}from"points-on-curve";var Ov=e=>{let{lassoPath:o,elements:t,elementsMap:r,elementsSegments:n,intersectedElements:i,enclosedElements:a,simplifyDistance:l}=e,s=o;l&&(s=yS(o,l));let c=t.filter(p=>!p.locked);a.clear(),i.clear();let m=o.reduce((p,u)=>[Math.min(p[0],u[0]),Math.min(p[1],u[1]),Math.max(p[2],u[0]),Math.max(p[3],u[1])],[1/0,1/0,-1/0,-1/0]);for(let p of c){let u=w0(p,r);i1(m,u)&&!i.has(p.id)&&!a.has(p.id)&&(vS(s,p,n)?a.add(p.id):wS(s,p,r)&&i.add(p.id))}return{selectedElementIds:[...i,...a]}},vS=(e,o,t)=>{let r=l1(e),n=t.get(o.id);return n?n.some(i=>i.some(a=>s1(a,r))):!1},wS=(e,o,t)=>{let r=e.slice(1).map((i,a)=>rl(e[a],i)).concat([rl(e[e.length-1],e[0])]),n=pe(o,t);return r.some(i=>Di(o,t,i,0,!0).length>0||!!n&&Di({...n,...Zr(o,n,t)},t,i,0,!0).length>0)};var sm=class extends Nr{constructor(t,r){super(t,r,{animateTrail:!0,streamline:.4,sizeMapping:n=>{let l=Math.max(0,1-(performance.now()-n.pressure)/(1/0)),s=(5e3-Math.min(5e3,n.totalLength-n.currentIndex))/5e3;return Math.min(Ho(s),Ho(l))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});k(this,"intersectedElements",new Set);k(this,"enclosedElements",new Set);k(this,"elementsSegments",null);k(this,"canvasTranslate",null);k(this,"keepPreviousSelection",!1);k(this,"selectElementsFromIds",t=>{this.app.setState(r=>{let n=t.reduce((s,c)=>(s[c]=!0,s),{});if(this.keepPreviousSelection)for(let s of Object.keys(r.selectedElementIds))n[s]=!0;for(let[s]of Object.entries(n)){let c=this.app.scene.getNonDeletedElement(s);if(c&&V(c)){let m=vo(c,this.app.scene.getNonDeletedElementsMap());m&&(n[m.id]=!0,delete n[c.id])}}for(let[s]of Object.entries(n)){let c=this.app.scene.getNonDeletedElement(s);if(c&&ce(c)){let m=Wo(this.app.scene.getNonDeletedElementsMap(),c.id);for(let d of m)delete n[d.id]}}let i=it({editingGroupId:r.editingGroupId,selectedElementIds:n},this.app.scene.getNonDeletedElements(),r,this.app),a=[...Object.keys(i.selectedElementIds)],l=[...Object.keys(i.selectedGroupIds)];return{selectedElementIds:i.selectedElementIds,selectedGroupIds:i.selectedGroupIds,selectedLinearElement:a.length===1&&!l.length&&ge(this.app.scene.getNonDeletedElement(a[0]))?new $(this.app.scene.getNonDeletedElement(a[0]),this.app.scene.getNonDeletedElementsMap()):null}})});k(this,"addPointToPath",(t,r,n=!1)=>{super.addPointToPath(t,r),this.keepPreviousSelection=n,this.updateSelection()});k(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(n=>L(n[0],n[1])),r={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!nt(r,this.canvasTranslate??{})){this.canvasTranslate=r,this.elementsSegments=new Map;let n=j(this.app.visibleElements);for(let i of this.app.visibleElements){let a=v0(i,n);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:n}=Ov({lassoPath:t,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});this.selectElementsFromIds(n)}})}startPath(t,r,n=!1){this.endPath(),super.startPath(t,r),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}};import{jsx as TS}from"react/jsx-runtime";var Bv=B({name:"smartZoom",label:"toolBar.smartZoom",trackEvent:{category:"toolbar"},icon:Tu,viewMode:!0,perform:(e,o,t,r)=>{let n={fitToViewport:!0,animate:!0,duration:200,viewportZoomFactor:.8},i=q(e,o);return i.length<1?r.scrollToContent(e,n):r.scrollToContent(i,n),{captureUpdate:A.NEVER}},keyTest:e=>!e[w.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===w.F,PanelComponent:({data:e,updateData:o})=>TS(K,{type:"button",icon:Tu,"aria-label":g("labels.smartZoom"),onClick:()=>o(null),size:e?.size||"medium","data-testid":"button-smart-zoom",keyBindingLabel:w.F.toLocaleUpperCase()})});var cm=class extends Nr{constructor(t,r){super(t,r,{streamline:.2,size:5,keepHead:!0,sizeMapping:n=>{let l=Math.max(0,1-(performance.now()-n.pressure)/200),s=(10-Math.min(10,n.totalLength-n.currentIndex))/10;return Math.min(Ho(s),Ho(l))},fill:()=>r.state.theme===re.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"});k(this,"elementsToErase",new Set);k(this,"groupsToErase",new Set)}startPath(t,r){this.endPath(),super.startPath(t,r),this.elementsToErase.clear()}addPointToPath(t,r,n=!1){return super.addPointToPath(t,r),this.updateElementsToBeErased(n)}updateElementsToBeErased(t){let r=super.getCurrentTrail()?.originalPoints?.map(l=>L(l[0],l[1]))||[];if(r.length<2)return[];let n=rl(r[r.length-1],r[r.length-2]),i=this.app.visibleElements.filter(l=>!l.locked),a=j(i);for(let l of i)if(t&&this.elementsToErase.has(l.id)){if(zv(n,l,a)){let c=l.groupIds.at(-1);if(this.groupsToErase.has(c)){let m=He(this.app.scene.getNonDeletedElementsMap(),c);for(let d of m)this.elementsToErase.delete(d.id);this.groupsToErase.delete(c)}if(rt(l)&&this.elementsToErase.delete(l.containerId),bt(l)){let m=dl(l);m&&this.elementsToErase.delete(m)}this.elementsToErase.delete(l.id)}}else if(!t&&!this.elementsToErase.has(l.id)&&zv(n,l,a)){let c=l.groupIds.at(-1);if(!this.groupsToErase.has(c)){let m=He(this.app.scene.getNonDeletedElementsMap(),c);for(let d of m)this.elementsToErase.add(d.id);this.groupsToErase.add(c)}if(bt(l)){let m=dl(l);m&&this.elementsToErase.add(m)}rt(l)&&this.elementsToErase.add(l.containerId),this.elementsToErase.add(l.id)}return Array.from(this.elementsToErase)}endPath(){super.endPath(),super.clearTrails(),this.elementsToErase.clear(),this.groupsToErase.clear()}},zv=(e,o,t)=>{let r=e[1];if(Ep(o)&&Q1(r,o,t))return!0;let n=pe(o,t);return Di(o,t,e,0,!0).length>0||!!n&&Di({...n,...Zr(o,n,t)},t,e,0,!0).length>0};import{jsx as Ro,jsxs as Fv}from"react/jsx-runtime";var CS=()=>Fv("div",{"data-testid":"brave-measure-text-error",children:[Ro("p",{children:Ro(Gt,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>Ro("span",{style:{fontWeight:600},children:e})})}),Ro("p",{children:Ro(Gt,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>Ro("span",{style:{fontWeight:600},children:e})})}),Ro("p",{children:Ro(Gt,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>Ro("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),Ro("p",{children:Ro(Gt,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>Ro("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>Fv("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),Hv=CS;import MS from"clsx";import LS from"react";import{useLayoutEffect as kS,useRef as Uv,useEffect as Gv}from"react";import{unstable_batchedUpdates as SS}from"react-dom";import{jsx as IS}from"react/jsx-runtime";var Yv=({children:e,left:o,top:t,onCloseRequest:r,fitInViewport:n=!1,offsetLeft:i=0,offsetTop:a=0,viewportWidth:l=window.innerWidth,viewportHeight:s=window.innerHeight})=>{let c=Uv(null);Gv(()=>{let d=c.current;if(!d)return;d.contains(document.activeElement)||d.focus();let p=u=>{if(u.key===w.TAB){let f=ll(d),{activeElement:b}=document,x=f.findIndex(E=>E===b);b===d?(u.shiftKey?f[f.length-1]?.focus():f[0].focus(),u.preventDefault(),u.stopImmediatePropagation()):x===0&&u.shiftKey?(f[f.length-1]?.focus(),u.preventDefault(),u.stopImmediatePropagation()):x===f.length-1&&!u.shiftKey&&(f[0]?.focus(),u.preventDefault(),u.stopImmediatePropagation())}};return d.addEventListener("keydown",p),()=>d.removeEventListener("keydown",p)},[]);let m=Uv(null);return kS(()=>{if(n&&c.current&&t!=null&&o!=null){let d=c.current,{width:p,height:u}=d.getBoundingClientRect();if(m.current?.top===t&&m.current?.left===o)return;m.current={top:t,left:o},p>=l?(d.style.width=`${l}px`,d.style.left="0px",d.style.overflowX="scroll"):o+p-i>l?d.style.left=`${l-p-10}px`:d.style.left=`${o}px`,u>=s?(d.style.height=`${s-20}px`,d.style.top="10px",d.style.overflowY="scroll"):t+u-a>s?d.style.top=`${s-u}px`:d.style.top=`${t}px`}},[t,o,n,l,s,i,a]),Gv(()=>{if(r){let d=p=>{c.current?.contains(p.target)||SS(()=>r(p))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[r]),IS("div",{className:"popover",ref:c,tabIndex:-1,children:e})};import{jsx as Ba,jsxs as AS}from"react/jsx-runtime";var ct="separator",Wv=LS.memo(({actionManager:e,items:o,top:t,left:r,onClose:n})=>{let i=sr(),a=pn(),l=o.reduce((s,c)=>(c&&(c===ct||!c.predicate||c.predicate(a,i,e.app.props,e.app))&&s.push(c),s),[]);return Ba(Yv,{onCloseRequest:()=>{n()},top:t,left:r,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,children:Ba("ul",{className:"context-menu",onContextMenu:s=>s.preventDefault(),children:l.map((s,c)=>{if(s===ct)return!l[c-1]||l[c-1]===ct?null:Ba("hr",{className:"context-menu-item-separator"},c);let m=s.name,d="";return s.label&&(typeof s.label=="function"?d=g(s.label(a,i,e.app)):d=g(s.label)),Ba("li",{"data-testid":m,onClick:()=>{n(()=>{e.executeAction(s,"contextMenu")})},children:AS("button",{type:"button",className:MS("context-menu-item",{dangerous:m==="deleteSelectedElements",checkmark:s.checked?.(i)}),children:[Ba("div",{className:"context-menu-item__label",children:d}),Ba("kbd",{className:"context-menu-item__shortcut",children:m?We(m):""})]})},c)})})})});import{jsx as pg,jsxs as Vv}from"react/jsx-runtime";var _S=({height:e,width:o,userToFollow:t,onDisconnect:r})=>pg("div",{className:"follow-mode",style:{width:o,height:e},children:Vv("div",{className:"follow-mode__badge",children:[Vv("div",{className:"follow-mode__badge__label",children:["Following"," ",pg("span",{className:"follow-mode__badge__username",title:t.username,children:t.username})]}),pg("button",{type:"button",onClick:r,className:"follow-mode__disconnect-btn",children:ko})]})}),Kv=_S;import fs from"clsx";import G7 from"react";import{createIsolation as PS}from"jotai-scope";import ug from"react";import ur from"tunnel-rat";var hg=ug.createContext(null),je=()=>ug.useContext(hg),DS=PS(),Zv=()=>ug.useMemo(()=>({MainMenuTunnel:ur(),WelcomeScreenMenuHintTunnel:ur(),WelcomeScreenToolbarHintTunnel:ur(),WelcomeScreenHelpHintTunnel:ur(),WelcomeScreenCenterTunnel:ur(),FooterCenterTunnel:ur(),DefaultSidebarTriggerTunnel:ur(),DefaultSidebarTabTriggersTunnel:ur(),OverwriteConfirmDialogTunnel:ur(),TTDDialogTriggerTunnel:ur(),tunnelsJotai:DS}),[]);import RS from"clsx";import{useState as NS,useEffect as OS}from"react";import{jsx as gg,jsxs as BS}from"react/jsx-runtime";var dm=({delay:e,theme:o})=>{let[t,r]=NS(!!e);return OS(()=>{if(!e)return;let n=setTimeout(()=>{r(!1)},e);return()=>clearTimeout(n)},[e]),t?null:BS("div",{className:RS("LoadingMessage",{"LoadingMessage--dark":o===re.DARK}),children:[gg("div",{children:gg(At,{})}),gg("div",{className:"LoadingMessage-text",children:g("labels.loadingScene")})]})};import zS from"clsx";import{jsx as FS}from"react/jsx-runtime";var mm=({children:e,side:o,className:t})=>FS("div",{className:zS("FixedSideContainer",`FixedSideContainer_side_${o}`,t),children:e});import HS from"clsx";import{jsx as US}from"react/jsx-runtime";var pm=e=>US(K,{className:HS("Shape",{fillable:!1}),type:"radio",icon:Vc,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:w.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":w.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});import{jsx as Xv}from"react/jsx-runtime";var GS=({appState:e,isMobile:o,device:t,app:r})=>{let{activeTool:n,isResizing:i,isRotating:a,lastPointerDownWith:l}=e,s=e.multiElement!==null;if(e.openSidebar?.name===Dt.name&&e.openSidebar.tab===yr&&e.searchMatches?.matches.length)return g("hints.dismissSearch");if(e.openSidebar&&!t.editor.canFitSidebar)return null;if(Jt(e))return g("hints.eraserRevert");if(n.type==="arrow"||n.type==="line")return s?g("hints.linearElementMulti"):n.type==="arrow"?g("hints.arrowTool",{arrowShortcut:D("A")}):g("hints.linearElement");if(n.type==="freedraw")return g("hints.freeDraw");if(n.type==="text")return g("hints.text");if(n.type==="embeddable")return g("hints.embeddable");let c=r.scene.getSelectedElements(e);if(i&&l==="mouse"&&c.length===1){let m=c[0];return ge(m)&&m.points.length===2?g("hints.lockAngle"):Ne(m)?g("hints.resizeImage"):g("hints.resize")}if(a&&l==="mouse")return g("hints.rotate");if(c.length===1&&V(c[0]))return g("hints.text_selected");if(e.editingTextElement)return g("hints.text_editing");if(e.croppingElementId)return g("hints.leaveCropEditor");if(c.length===1&&Ne(c[0]))return g("hints.enterCropEditor");if(n.type==="selection"){if(e.selectionElement&&!c.length&&!e.editingTextElement&&!e.editingLinearElement)return[g("hints.deepBoxSelect")];if(Tn(r)&&e.selectedElementsAreBeingDragged)return g("hints.disableSnapping");if(!c.length&&!o)return[g("hints.canvasPanning")];if(c.length===1){if(ge(c[0]))return e.editingLinearElement?e.editingLinearElement.selectedPointsIndices?g("hints.lineEditor_pointSelected"):g("hints.lineEditor_nothingSelected"):qe(c[0])?g("hints.lineEditor_line_info"):g("hints.lineEditor_info");if(!e.newElement&&!e.selectedElementsAreBeingDragged&&Cr(c[0]))return qs(c[0])?H0(c[0],r.scene.getNonDeletedElementsMap())?[g("hints.bindTextToElement"),g("hints.createFlowchart")]:[g("hints.bindTextToElement"),g("hints.createFlowchart")]:g("hints.bindTextToElement")}}return null},um=({appState:e,isMobile:o,device:t,app:r})=>{let n=GS({appState:e,isMobile:o,device:t,app:r});if(!n)return null;let i=Array.isArray(n)?n.map(a=>D(a).replace(/\. ?$/,"")).join(". "):D(n);return Xv("div",{className:"HintViewer",children:Xv("span",{children:i})})};import YS from"clsx";import{jsx as jv,jsxs as VS}from"react/jsx-runtime";var WS="medium",$v={CHECKED:rn,UNCHECKED:Mr},qv=e=>VS("label",{className:YS("ToolIcon ToolIcon__lock",`ToolIcon_size_${WS}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[jv("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),jv("div",{className:"ToolIcon__icon",children:e.checked?$v.CHECKED:$v.UNCHECKED})]});import KS from"clsx";import{jsx as Jv,jsxs as XS}from"react/jsx-runtime";var ZS="medium",hm=e=>e.penDetected?XS("label",{className:KS("ToolIcon ToolIcon__penMode",`ToolIcon_size_${ZS}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[Jv("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),Jv("div",{className:"ToolIcon__icon",children:zb})]}):null;import{Fragment as $S,jsx as Qv,jsxs as jS}from"react/jsx-runtime";var kn=({heading:e,children:o,...t})=>{let{id:r}=st(),n=Qv("h2",{className:"visually-hidden",id:`${r}-${e}-title`,children:g(`headings.${e}`)});return Qv("section",{...t,"aria-labelledby":`${r}-${e}-title`,children:typeof o=="function"?o(n):jS($S,{children:[n,o]})})};import{Fragment as qS,jsx as Vt,jsxs as hr}from"react/jsx-runtime";var ew=({appState:e,elements:o,actionManager:t,setAppState:r,onLockToggle:n,onHandToolToggle:i,onPenModeToggle:a,renderTopRightUI:l,renderCustomStats:s,renderSidebars:c,device:m,renderWelcomeScreen:d,UIOptions:p,app:u})=>{let{WelcomeScreenCenterTunnel:f,MainMenuTunnel:b,DefaultSidebarTriggerTunnel:x}=je(),E=()=>hr(mm,{side:"top",className:"App-top-bar",children:[d&&Vt(f.Out,{}),Vt(kn,{heading:"shapes",children:v=>Vt(Tt.Col,{gap:4,align:"center",children:hr(Tt.Row,{gap:1,className:"App-toolbar-container",children:[hr(xt,{padding:1,className:"App-toolbar App-toolbar--mobile",children:[v,Vt(Tt.Row,{gap:1,children:Vt(qd,{appState:e,activeTool:e.activeTool,UIOptions:p,app:u})})]}),l&&l(!0,e),hr("div",{className:"mobile-misc-tools-container",children:[!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&Vt(x.Out,{}),Vt(hm,{checked:e.penMode,onChange:()=>a(null),title:g("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),Vt(qv,{checked:e.activeTool.locked,onChange:n,title:g("toolBar.lock"),isMobile:!0}),Vt(pm,{checked:Ko(e),onChange:()=>i(),title:g("toolBar.hand"),isMobile:!0})]})]})})}),Vt(um,{appState:e,isMobile:!0,device:m,app:u})]}),y=()=>e.viewModeEnabled||e.openDialog?.name==="elementLinkSelector"?Vt("div",{className:"App-toolbar-content",children:hr("div",{children:[t.renderAction("viewMode"),t.renderAction("smartZoom")]})}):hr("div",{className:"App-toolbar-content",children:[hr("div",{children:[t.renderAction("viewMode"),t.renderAction("smartZoom"),t.renderAction("undo"),t.renderAction("redo")]}),t.renderAction("toggleEditMenu"),t.renderAction(e.multiElement?"finalize":"duplicateSelection"),t.renderAction("deleteSelectedElements")]});return hr(qS,{children:[c(),!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&E(),Vt("div",{className:"App-bottom-bar",style:{marginBottom:no+Jo*2,marginLeft:no+Jo*2,marginRight:no+Jo*2},children:hr(xt,{padding:0,children:[e.openMenu==="shape"&&!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&Yi(e,o)?Vt(kn,{className:"App-mobile-menu",heading:"selectedShapeActions",children:Vt(jd,{appState:e,elementsMap:u.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:u})}):null,hr("footer",{className:"App-toolbar",children:[y(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&Vt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(v=>({...ei(o,v)}))},children:g("buttons.scrollBackToContent")})]})]})})]})};import JS from"open-color";import QS,{useLayoutEffect as eI,useRef as tI,useState as oI}from"react";import{jsx as ls,jsxs as rI}from"react/jsx-runtime";var tw=e=>{let o=tI(null),[t,r]=oI(null);return eI(()=>{if(!e.spreadsheet)return;let n=g2(e.chartType,e.spreadsheet,0,0);r(n);let i,a=o.current;return(async()=>(i=await Zi(n,{exportBackground:!1,viewBackgroundColor:JS.white},null,{skipInliningFonts:!0}),i.querySelector(".style-fonts")?.remove(),a.replaceChildren(),a.appendChild(i),e.selected&&a.parentNode.focus()))(),()=>{a.replaceChildren()}},[e.spreadsheet,e.chartType,e.selected]),ls("button",{type:"button",className:"ChartPreview",onClick:()=>{t&&e.onClick(e.chartType,t)},children:ls("div",{ref:o})})},ow=({setAppState:e,appState:o,onClose:t})=>{let{onInsertElements:r}=tt(),n=QS.useCallback(()=>{t&&t()},[t]),i=(a,l)=>{r(l),me("paste","chart",a),e({currentChartType:a,pasteDialog:{shown:!1,data:null}})};return ls(ot,{size:"small",onCloseRequest:n,title:g("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:rI("div",{className:"container",children:[ls(tw,{chartType:"bar",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="bar",onClick:i}),ls(tw,{chartType:"line",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="line",onClick:i})]})})};import*as Sn from"@radix-ui/react-popover";import rw from"clsx";import gm,{useLayoutEffect as nI}from"react";import{Fragment as cI,jsx as gr,jsxs as fm}from"react/jsx-runtime";var iI=4,aI=8,lI=({shouldWrap:e,children:o,username:t})=>e?gr(Rt,{label:t||"Unknown user",children:o}):gr(cI,{children:o}),fg=({actionManager:e,collaborator:o,socketId:t,withName:r=!1,shouldWrapWithTooltip:n=!1,isBeingFollowed:i})=>{let a={socketId:t,collaborator:o,withName:r,isBeingFollowed:i},l=e.renderAction("goToCollaborator",a);return gr(lI,{username:o.username,shouldWrap:n,children:l},t)},sI=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],bm=gm.memo(({className:e,mobile:o,collaborators:t,userToFollow:r})=>{let n=_t(),i=new Map;t.forEach((b,x)=>{let E=b.id||x;i.set(E,{...b,socketId:x})});let a=Array.from(i.values()).filter(b=>b.username?.trim()),[l,s]=gm.useState(""),c=a.filter(b=>b.username?.toLowerCase().includes(l)),m=gm.useRef(null);nI(()=>{if(m.current){let b=E=>{let y=Math.max(1,Math.min(8,Math.floor(E/38)));p(y)};if(b(m.current.clientWidth),!Xa)return;let x=new ResizeObserver(E=>{for(let y of E){let{width:v}=y.contentRect;b(v)}});return x.observe(m.current),()=>{x.disconnect()}}},[]);let[d,p]=gm.useState(iI),f=a.slice(0,d-1).map(b=>fg({actionManager:n,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===r}));return o?gr("div",{className:rw("UserList UserList_mobile",e),children:a.map(b=>fg({actionManager:n,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===r}))}):gr("div",{className:"UserList__wrapper",ref:m,children:fm("div",{className:rw("UserList",e),style:{"--max-avatars":d},children:[f,a.length>d-1&&fm(Sn.Root,{children:[fm(Sn.Trigger,{className:"UserList__more",children:["+",a.length-d+1]}),gr(Sn.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:fm(xt,{padding:2,children:[a.length>=aI&&gr(ad,{placeholder:g("quickSearch.placeholder"),onChange:s}),gr(ld,{className:"dropdown-menu UserList__collaborators",placeholder:g("userList.empty"),children:c.length>0?[gr("div",{className:"hint",children:g("userList.hint.text")}),c.map(b=>fg({actionManager:n,collaborator:b,socketId:b.socketId,withName:!0,isBeingFollowed:b.socketId===r}))]:[]}),gr(Sn.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})]})]})})},(e,o)=>{if(e.collaborators.size!==o.collaborators.size||e.mobile!==o.mobile||e.className!==o.className||e.userToFollow!==o.userToFollow)return!1;let t=o.collaborators.keys();for(let[r,n]of e.collaborators){let i=o.collaborators.get(r);if(!i||r!==t.next().value||!nt(n,i,sI))return!1}return!0});import za from"clsx";import{jsx as dI}from"react/jsx-runtime";var nw=e=>dI("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${g("helpDialog.title")} \u2014 ?`,"aria-label":g("helpDialog.title"),children:ea});import{jsx as io,jsxs as bg}from"react/jsx-runtime";var iw=({appState:e,actionManager:o,showExitZenModeBtn:t,renderWelcomeScreen:r})=>{let{FooterCenterTunnel:n,WelcomeScreenHelpHintTunnel:i}=je(),a=xe(),l=!e.viewModeEnabled&&e.multiElement&&a.isTouchScreen;return bg("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[io("div",{className:za("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:io(Tt.Col,{gap:2,children:bg(kn,{heading:"canvasActions",children:[io(Rt,{label:g("labels.viewMode"),children:io("div",{className:za("view-mode-button"),children:o.renderAction("viewMode")})}),io(Rt,{label:g("buttons.smartZoom"),children:io("div",{className:za("smart-zoom-button"),children:o.renderAction("smartZoom")})}),io(Ky,{renderAction:o.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&io(Zy,{renderAction:o.renderAction,className:za("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})}),l&&io($y,{renderAction:o.renderAction,className:za("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled})})]})})}),io(n.Out,{}),io("div",{className:za("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:bg("div",{style:{position:"relative"},children:[r&&io(i.Out,{}),io(nw,{onClick:()=>o.executeAction(mi)})]})}),io(Xy,{actionManager:o,showExitZenModeBtn:t})]})},aw=iw;iw.displayName="Footer";import xI from"clsx";import{useEffect as fw,useLayoutEffect as bw,useRef as Sg,useState as EI,forwardRef as xw,useImperativeHandle as yI,useCallback as hw}from"react";import pI from"clsx";import{useContext as uI}from"react";import mI from"react";var xm=mI.createContext({});import{jsx as xg,jsxs as lw}from"react/jsx-runtime";var Eg=({children:e,className:o})=>{let t=xe(),r=uI(xm),n=!!(t.editor.canFitSidebar&&r.shouldRenderDockButton);return lw("div",{className:pI("sidebar__header",o),"data-testid":"sidebar-header",children:[e,lw("div",{className:"sidebar__header__buttons",children:[n&&xg(Rt,{label:g("labels.sidebarLock"),children:xg(go,{onSelect:()=>r.onDock?.(!r.docked),selected:!!r.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":g("labels.sidebarLock"),children:Db})}),xg(go,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:r.onCloseRequest,"aria-label":g("buttons.close"),children:ko})]})]})};Eg.displayName="SidebarHeader";import*as cw from"@radix-ui/react-tabs";import{jsx as sw}from"react/jsx-runtime";var yg=({children:e,tab:o,onSelect:t,...r})=>sw(cw.Trigger,{value:o,asChild:!0,onSelect:t,children:sw("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...r,children:e})});yg.displayName="SidebarTabTrigger";import*as dw from"@radix-ui/react-tabs";import{jsx as hI}from"react/jsx-runtime";var vg=({children:e,...o})=>hI(dw.List,{className:"sidebar-triggers",...o,children:e});vg.displayName="SidebarTabTriggers";import gI from"clsx";import{jsx as wg,jsxs as mw}from"react/jsx-runtime";var Tg=({name:e,tab:o,icon:t,title:r,children:n,onToggle:i,className:a,style:l})=>{let s=ve(),c=Me();return mw("label",{title:r,className:"sidebar-trigger__label-element",children:[wg("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:m=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let d=m.target.checked;s({openSidebar:d?{name:e,tab:o}:null}),i?.(d)},checked:c.openSidebar?.name===e,"aria-label":r,"aria-keyshortcuts":"0"}),mw("div",{className:gI("sidebar-trigger",a),style:l,children:[t&&wg("div",{children:t}),n&&wg("div",{className:"sidebar-trigger__label",children:n})]})]})};Tg.displayName="SidebarTrigger";import*as pw from"@radix-ui/react-tabs";import{jsx as fI}from"react/jsx-runtime";var Cg=({children:e,...o})=>{let t=Me(),r=ve();if(!t.openSidebar)return null;let{name:n}=t.openSidebar;return fI(pw.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>r(a=>({...a,openSidebar:{...a.openSidebar,name:n,tab:i}})),...o,children:e})};Cg.displayName="SidebarTabs";import*as uw from"@radix-ui/react-tabs";import{jsx as bI}from"react/jsx-runtime";var kg=({tab:e,children:o,...t})=>bI(uw.Content,{...t,value:e,"data-testid":e,children:o});kg.displayName="SidebarTab";import{jsx as gw}from"react/jsx-runtime";import{createElement as vI}from"react";var ss=Ie(!1),Ew=xw(({name:e,children:o,onDock:t,docked:r,className:n,...i},a)=>{ft()&&t&&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 l=ve(),s=$i(ss);bw(()=>(s(!!r),()=>{s(!1)}),[s,r]);let c=Sg({});c.current.onCloseRequest=()=>{l({openSidebar:null})},c.current.onDock=u=>t?.(u),c.current=Si(c.current,{docked:r,shouldRenderDockButton:!!t&&r!=null});let m=Sg(null);yI(a,()=>m.current);let d=xe(),p=hw(()=>{document.querySelector(".Dialog")||l({openSidebar:null})},[l]);return aa(m,hw(u=>{u.target.closest(".sidebar-trigger")||(!r||!d.editor.canFitSidebar)&&p()},[p,r,d.editor.canFitSidebar])),fw(()=>{let u=f=>{f.key===w.ESCAPE&&(!r||!d.editor.canFitSidebar)&&p()};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}},[p,r,d.editor.canFitSidebar]),gw(xt,{...i,className:xI("sidebar",{"sidebar--docked":r},n),ref:m,children:gw(xm.Provider,{value:c.current,children:o})})});Ew.displayName="SidebarInner";var No=Object.assign(xw((e,o)=>{let t=Me(),{onStateChange:r}=e,n=Sg(t.openSidebar);fw(()=>{(!t.openSidebar&&n?.current?.name===e.name||t.openSidebar?.name===e.name&&n?.current?.name!==e.name||n.current?.name===e.name)&&t.openSidebar!==n.current&&r?.(t.openSidebar?.name!==e.name?null:t.openSidebar),n.current=t.openSidebar},[t.openSidebar,r,e.name]);let[i,a]=EI(!1);return bw(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?vI(Ew,{...e,ref:o,key:e.name}):null}),{Header:Eg,TabTriggers:vg,TabTrigger:yg,Tabs:Cg,Tab:kg,Trigger:Tg});No.displayName="Sidebar";import{useLayoutEffect as wI,useRef as TI}from"react";import{jsx as CI}from"react/jsx-runtime";var Or=(e,o)=>{let t=Ie(0),r=n=>{let{tunnelsJotai:{useAtom:i}}=je(),[,a]=i(t),l=TI({preferHost:!1,counter:0});return wI(()=>{let s=l.current;return a(c=>{let m=c+1;return s.counter=m,m}),()=>{a(c=>{let m=c-1;return s.counter=m,m||(s.preferHost=!1),m})}},[a]),n.__fallback||(l.current.preferHost=!0),!l.current.counter&&n.__fallback&&l.current.preferHost||l.current.counter>1&&n.__fallback?null:CI(o,{...n})};return r.displayName=e,r};var Lg={};Cf(Lg,{ChangeCanvasBackground:()=>Pw,CommandPalette:()=>Mw,Export:()=>Dw,Help:()=>Aw,LiveCollaborationTrigger:()=>Nw,LoadScene:()=>kw,SaveAsImage:()=>Iw,SaveToActiveFile:()=>Sw,SearchMenu:()=>Lw,Socials:()=>Rw,ToggleTheme:()=>_w});import MI from"clsx";var Ig=Ie({active:!1});async function yw({title:e,description:o,actionLabel:t,color:r}){return new Promise(n=>{wt.set(Ig,{active:!0,onConfirm:()=>n(!0),onClose:()=>n(!1),onReject:()=>n(!1),title:e,description:o,actionLabel:t,color:r})})}import kI from"clsx";import{jsx as vw,jsxs as SI}from"react/jsx-runtime";var Em=function({onChange:e,value:o,choices:t,name:r}){return vw("div",{className:"RadioGroup",children:t.map(n=>SI("div",{className:kI("RadioGroup__choice",{active:n.value===o}),title:n.ariaLabel,children:[vw("input",{name:r,type:"radio",checked:n.value===o,onChange:()=>e(n.value),"aria-label":n.ariaLabel}),n.label]},String(n.value)))})};import{Fragment as II,jsx as Mg,jsxs as ww}from"react/jsx-runtime";var Tw=({value:e,shortcut:o,onChange:t,choices:r,children:n,name:i})=>{let a=xe();return ww(II,{children:[ww("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[Mg("label",{className:"dropdown-menu-item__text",htmlFor:i,children:n}),Mg(Em,{name:i,value:e,onChange:t,choices:r})]}),o&&!a.editor.isMobile&&Mg("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:o})]})};Tw.displayName="DropdownMenuItemContentRadio";var Cw=Tw;import{Fragment as LI,jsx as kt,jsxs as Ow}from"react/jsx-runtime";var kw=()=>{let{t:e}=lt(),o=_t(),t=pn();return o.isActionEnabled(ga)?kt(Qt,{icon:ta,onSelect:async()=>{(!t.length||await yw({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:kt(Gt,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:n=>kt("strong",{children:n}),br:()=>kt("br",{})})}))&&o.executeAction(ga)},"data-testid":"load-button",shortcut:We("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};kw.displayName="LoadScene";var Sw=()=>{let{t:e}=lt(),o=_t();return o.isActionEnabled(di)?kt(Qt,{shortcut:We("saveScene"),"data-testid":"save-button",onSelect:()=>o.executeAction(di),icon:Kb,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};Sw.displayName="SaveToActiveFile";var Iw=()=>{let e=ve(),{t:o}=lt();return kt(Qt,{icon:Uc,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:We("imageExport"),"aria-label":o("buttons.exportImage"),children:o("buttons.exportImage")})};Iw.displayName="SaveAsImage";var Mw=e=>{let o=ve(),{t}=lt();return kt(Qt,{icon:_l,"data-testid":"command-palette-button",onSelect:()=>{me("command_palette","open","menu"),o({openDialog:{name:"commandPalette"}})},shortcut:We("commandPalette"),"aria-label":t("commandPalette.title"),className:e?.className,children:t("commandPalette.title")})};Mw.displayName="CommandPalette";var Lw=e=>{let{t:o}=lt(),t=_t();return kt(Qt,{icon:uo,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(rs)},shortcut:We("searchMenu"),"aria-label":o("search.title"),className:e?.className,children:o("search.title")})};Lw.displayName="SearchMenu";var Aw=()=>{let{t:e}=lt(),o=_t();return kt(Qt,{"data-testid":"help-menu-item",icon:ea,onSelect:()=>o.executeAction(mi),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};Aw.displayName="Help";var _w=e=>{let{t:o}=lt(),t=Me(),r=_t(),n=We("toggleTheme");return r.isActionEnabled(ai)?e?.allowSystemTheme?kt(Cw,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:re.LIGHT,label:Il,ariaLabel:`${o("buttons.lightMode")} - ${n}`},{value:re.DARK,label:Sl,ariaLabel:`${o("buttons.darkMode")} - ${n}`},{value:"system",label:cE,ariaLabel:o("buttons.systemMode")}],children:o("labels.theme")}):kt(Qt,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(t.theme===re.DARK?re.LIGHT:re.DARK);else return r.executeAction(ai)},icon:t.theme===re.DARK?Il:Sl,"data-testid":"toggle-dark-mode",shortcut:n,"aria-label":t.theme===re.DARK?o("buttons.lightMode"):o("buttons.darkMode"),children:t.theme===re.DARK?o("buttons.lightMode"):o("buttons.darkMode")}):null};_w.displayName="ToggleTheme";var Pw=()=>{let{t:e}=lt(),o=Me(),t=_t(),r=cr();return o.viewModeEnabled||!r.UIOptions.canvasActions.changeViewBackgroundColor?null:Ow("div",{style:{marginTop:"0.5rem"},children:[kt("div",{"data-testid":"canvas-background-label",style:{fontSize:".75rem",marginBottom:".5rem"},children:e("labels.canvasBackground")}),kt("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};Pw.displayName="ChangeCanvasBackground";var Dw=()=>{let{t:e}=lt(),o=ve();return kt(Qt,{icon:ti,onSelect:()=>{o({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};Dw.displayName="Export";var Rw=()=>{let{t:e}=lt();return Ow(LI,{children:[kt(La,{icon:Gb,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),kt(La,{icon:Wb,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),kt(La,{icon:Yb,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};Rw.displayName="Socials";var Nw=({onSelect:e,isCollaborating:o})=>{let{t}=lt();return kt(Qt,{"data-testid":"collab-button",icon:Gc,className:MI({"active-collab":o}),onSelect:e,children:t("labels.liveCollaboration")})};Nw.displayName="LiveCollaborationTrigger";import{jsx as ym,jsxs as Ag}from"react/jsx-runtime";var AI=Object.assign(Or("MainMenu",({children:e,onSelect:o})=>{let{MainMenuTunnel:t}=je(),r=xe(),n=Me(),i=ve(),a=r.editor.isMobile?void 0:()=>i({openMenu:null});return ym(t.In,{children:Ag(Oe,{open:n.openMenu==="canvas",children:[ym(Oe.Trigger,{onToggle:()=>{i({openMenu:n.openMenu==="canvas"?null:"canvas"})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:Fc}),Ag(Oe.Content,{onClickOutside:a,onSelect:Vr(o,()=>{i({openMenu:null})}),children:[e,r.editor.isMobile&&n.collaborators.size>0&&Ag("fieldset",{className:"UserList-Wrapper",children:[ym("legend",{children:g("labels.collaborators")}),ym(bm,{mobile:!0,collaborators:n.collaborators,userToFollow:n.userToFollow?.socketId||null})]})]})]})})}),{Trigger:Oe.Trigger,Item:Oe.Item,ItemLink:Oe.ItemLink,ItemCustom:Oe.ItemCustom,Group:Oe.Group,Separator:Oe.Separator,DefaultItems:Lg}),Kt=AI;import _I from"clsx";import{forwardRef as PI,useState as DI}from"react";import{jsx as vm,jsxs as RI}from"react/jsx-runtime";var In=PI(({children:e,icon:o,onClick:t,label:r,variant:n="filled",color:i="primary",size:a="medium",fullWidth:l,className:s,status:c},m)=>{let[d,p]=DI(!1),u=async b=>{let x=t?.(b);if(Wr(x)){let E=window.setTimeout(()=>{p(!0)},50);try{await x}catch(y){if(y instanceof Wi)console.warn(y);else throw y}finally{clearTimeout(E),p(!1)}}},f=d?"loading":c;return i=f==="success"?"success":i,vm("button",{className:_I("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${n}`,`ExcButton--size-${a}`,`ExcButton--status-${f}`,{"ExcButton--fullWidth":l},s),onClick:u,type:"button","aria-label":r,ref:m,disabled:f==="loading"||f==="success",children:RI("div",{className:"ExcButton__contents",children:[f==="loading"?vm(At,{className:"ExcButton__statusIcon"}):f==="success"&&vm("div",{className:"ExcButton__statusIcon",children:Yx}),o&&vm("div",{className:"ExcButton__icon","aria-hidden":!0,children:o}),n!=="icon"&&(e??r)]})})});import{jsx as Fa,jsxs as BI}from"react/jsx-runtime";var wm=({title:e,children:o,actionLabel:t,onClick:r})=>BI("div",{className:"OverwriteConfirm__Actions__Action",children:[Fa("h4",{children:e}),Fa("div",{className:"OverwriteConfirm__Actions__Action__content",children:o}),Fa(In,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:r})]}),NI=()=>{let{t:e}=lt(),o=_t(),t=ve();return Fa(wm,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{o.executeAction(Td,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},OI=()=>{let{t:e}=lt(),o=_t();return Fa(wm,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{o.executeAction(Kl,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},_g=Object.assign(({children:e})=>Fa("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:NI,SaveToDisk:OI});import{jsx as Mn,jsxs as Bw}from"react/jsx-runtime";var Tm=Object.assign(Or("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:o}=je(),[t,r]=Ee(Ig);if(!t.active)return null;let n=()=>{t.onClose(),r(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),r(a=>({...a,active:!1}))};return Mn(o.In,{children:Mn(ot,{onCloseRequest:n,title:!1,size:916,children:Bw("div",{className:"OverwriteConfirm",children:[Mn("h3",{children:t.title}),Bw("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[Mn("div",{className:"OverwriteConfirm__Description__icon",children:Wx}),Mn("div",{children:t.description}),Mn("div",{className:"OverwriteConfirm__Description__spacer"}),Mn(In,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),Mn(_g,{children:e})]})})})}),{Actions:_g,Action:wm});import JI from"clsx";import zI from"clsx";import FI from"lodash.debounce";import{Fragment as HI,memo as UI,useEffect as cs,useMemo as zw,useRef as Pg,useState as Fw}from"react";import{Fragment as qI,jsx as St,jsxs as fr}from"react/jsx-runtime";var GI=Ie(""),Dg=Ie(null),YI=350,Yw=()=>{let e=tt(),o=ve(),t=Pg(null),[r,n]=Ee(GI),i=r.trim(),[a,l]=Fw(!1),[s,c]=Fw({nonce:null,items:[]}),m=Pg(null),d=Pg(void 0),[p,u]=Ee(Dg),f=e.scene.getNonDeletedElementsMap();cs(()=>{a||(i!==m.current||e.scene.getSceneNonce()!==d.current)&&(m.current=null,Gw(i,e,(v,T)=>{c({nonce:Yn(),items:v}),m.current=i,d.current=e.scene.getSceneNonce(),o({searchMatches:v.length?{focusedId:null,matches:v.map(I=>({id:I.element.id,focus:!1,matchedLines:I.matchedLines}))}:null})}))},[a,i,f,e,o,u,d]);let b=()=>{s.items.length>0&&u(v=>v===null?0:(v+1)%s.items.length)},x=()=>{s.items.length>0&&u(v=>v===null?0:v-1<0?s.items.length-1:v-1)};cs(()=>{o(v=>v.searchMatches?{searchMatches:{focusedId:p!==null&&v.searchMatches?.matches[p]?.id||null,matches:v.searchMatches.matches.map((I,S)=>S===p?{...I,focus:!0}:{...I,focus:!1})}}:null)},[p,o]),cs(()=>{if(s.items.length>0&&p!==null){let v=s.items[p];if(v){let T=e.state.zoom.value,I=Ft({text:v.searchQuery,x:v.element.x+(v.matchedLines[0]?.offsetX??0),y:v.element.y+(v.matchedLines[0]?.offsetY??0),width:v.matchedLines[0]?.width,height:v.matchedLines[0]?.height,fontSize:ce(v.element)?Pt.nameFontSize:v.element.fontSize,fontFamily:ce(v.element)?pt.Assistant:v.element.fontFamily}),S=14,P=I.fontSize,M=P*T<S;if(!Fi([I],e.canvas.width/window.devicePixelRatio,e.canvas.height/window.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.getEditorUIOffsets())||M){let O;M?P>=S?O={fitToContent:!0}:O={fitToViewport:!0,maxZoom:Eo(S/P,1)}:O={fitToContent:!0},e.scrollToContent(I,{animate:!0,duration:300,...O,canvasOffsets:e.getEditorUIOffsets()})}}}},[p,s,e]),cs(()=>()=>{u(null),m.current=null,d.current=void 0,o({searchMatches:null}),l(!1)},[o,u]);let E=dn({goToNextItem:b,goToPreviousItem:x,searchMatches:s});cs(()=>{let v=T=>{if(T.key===w.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){T.preventDefault(),T.stopPropagation(),o({openSidebar:null});return}if(T[w.CTRL_OR_CMD]&&T.key===w.F){if(T.preventDefault(),T.stopPropagation(),e.state.openDialog)return;t.current?.matches(":focus")||(e.state.openDialog&&o({openDialog:null}),t.current?.focus(),t.current?.select())}T.target instanceof HTMLElement&&T.target.closest(".layer-ui__search")&&E.searchMatches.items.length&&(T.key===w.ENTER&&(T.stopPropagation(),E.goToNextItem()),T.key===w.ARROW_UP?(T.stopPropagation(),E.goToPreviousItem()):T.key===w.ARROW_DOWN&&(T.stopPropagation(),E.goToNextItem()))};return Fe(window,"keydown",v,{capture:!0,passive:!1})},[o,E,e]);let y=`${s.items.length} ${s.items.length===1?g("search.singleResult"):g("search.multipleResults")}`;return fr("div",{className:"layer-ui__search",children:[St("div",{className:"layer-ui__search-header",children:St(Pa,{className:Bt.SEARCH_MENU_INPUT_WRAPPER,value:r,ref:t,placeholder:g("search.placeholder"),icon:uo,onChange:v=>{n(v),l(!0);let T=v.trim();Gw(T,e,(I,S)=>{c({nonce:Yn(),items:I}),u(S),m.current=T,d.current=e.scene.getSceneNonce(),o({searchMatches:I.length?{focusedId:null,matches:I.map(P=>({id:P.element.id,focus:!1,matchedLines:P.matchedLines}))}:null}),l(!1)})},selectOnRender:!0})}),fr("div",{className:"layer-ui__search-count",children:[s.items.length>0&&fr(qI,{children:[p!==null&&p>-1?fr("div",{children:[p+1," / ",y]}):St("div",{children:y}),fr("div",{className:"result-nav",children:[St(go,{onSelect:()=>{b()},className:"result-nav-btn",children:jc}),St(go,{onSelect:()=>{x()},className:"result-nav-btn",children:uE})]})]}),s.items.length===0&&i&&m.current&&St("div",{style:{margin:"1rem auto"},children:g("search.noMatch")})]}),St(KI,{matches:s,onItemClick:u,focusIndex:p,searchQuery:i})]})},Hw=e=>{let o=[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 St("div",{tabIndex:-1,className:zI("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:St("div",{className:"preview-text",children:o.flatMap((t,r)=>St(HI,{children:r===2?St("b",{children:t}):t},r))})})},WI=e=>{let o=zw(()=>e.matches.items.filter(r=>ce(r.element)),[e.matches]),t=zw(()=>e.matches.items.filter(r=>V(r.element)),[e.matches]);return fr("div",{children:[o.length>0&&fr("div",{className:"layer-ui__search-result-container",children:[fr("div",{className:"layer-ui__search-result-title",children:[St("div",{className:"title-icon",children:ra}),St("div",{children:g("search.frames")})]}),o.map((r,n)=>St(Hw,{searchQuery:e.searchQuery,preview:r.preview,highlighted:n===e.focusIndex,onClick:()=>e.onItemClick(n)},r.element.id+r.index)),t.length>0&&St("div",{className:"layer-ui__divider"})]}),t.length>0&&fr("div",{className:"layer-ui__search-result-container",children:[fr("div",{className:"layer-ui__search-result-title",children:[St("div",{className:"title-icon",children:cn}),St("div",{children:g("search.texts")})]}),t.map((r,n)=>St(Hw,{searchQuery:e.searchQuery,preview:r.preview,highlighted:n+o.length===e.focusIndex,onClick:()=>e.onItemClick(n+o.length)},r.element.id+r.index))]})]})},VI=(e,o)=>e.matches.nonce===o.matches.nonce&&e.focusIndex===o.focusIndex,KI=UI(WI,VI),Uw=(e,o,t)=>{let i=e.slice(0,o),a=i.split(/\s+/),l=i.endsWith(" "),s=a.length-2-1-(l?0:1),c=a.slice(s<=0?0:s).join(" ")+(l?" ":""),m=20;c=c.length>m?c.slice(-m):c;let d=e.slice(o+t.length),p=d.split(/\s+/),u=!d.startsWith(" "),f=u?6:5,b=(u?"":" ")+p.slice(0,f).join(" ");return{indexInSearchQuery:c.length,previewText:c+t+b,moreBefore:s>0,moreAfter:p.length>f}},ZI=(e,o)=>{let t=e.split(`
7
+ ${g("hints.firefox_clipboard_write")}`):new Error(g("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var $x=async(e,o,t,r)=>{let{exportBackground:n,viewBackgroundColor:i,fileHandle:a}=o,l=d1(a);if(!a||!m1(l))throw new Error("fileHandle should exist and should be of type svg or png when resaving");o={...o,exportEmbedScene:!0};let{exportedElements:s,exportingFrame:c}=Kr(e,o,!1);return await Zr(l,s,o,t,{exportBackground:n,viewBackgroundColor:i,name:r,fileHandle:a,exportingFrame:c}),{fileHandle:a}};import{Fragment as Dk,jsx as Fo,jsxs as _k}from"react/jsx-runtime";var Yp=N({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,o,t)=>({appState:{...o,name:t},captureUpdate:ro.EVENTUALLY}),PanelComponent:({appState:e,updateData:o,appProps:t,data:r,app:n})=>Fo(_x,{label:g("labels.fileTitle"),value:n.getName(),onChange:i=>o(i),ignoreFocus:r?.ignoreFocus??!1})}),jx=N({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,o,t)=>({appState:{...o,exportScale:t},captureUpdate:ro.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=Ak(e),i=Ee(r,o)?$(r,o):r;return Fo(Dk,{children:Pk.map(a=>{let[l,s]=s1(i,Lk,a),c=`${g("imageExportDialog.label.scale")} ${a}x (${l}x${s})`;return Fo(W,{size:"small",type:"radio",icon:`${a}x`,name:"export-canvas-scale",title:c,"aria-label":c,id:"export-canvas-scale",checked:a===o.exportScale,onChange:()=>t(a)},a)})})}}),Wp=N({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,o,t)=>({appState:{...o,exportBackground:t},captureUpdate:ro.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Fo(Ca,{checked:e.exportBackground,onChange:t=>o(t),children:g("imageExportDialog.label.withBackground")})}),Xs=N({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,o,t)=>({appState:{...o,exportEmbedScene:t},captureUpdate:ro.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>_k(Ca,{checked:e.exportEmbedScene,onChange:t=>o(t),children:[g("imageExportDialog.label.embedScene"),Fo(it,{label:g("imageExportDialog.tooltip.embedScene"),long:!0,children:Fo("div",{className:"excalidraw-tooltip-icon",children:j1})})]})}),$r=N({name:"saveToActiveFile",label:"buttons.save",icon:zr,trackEvent:{category:"export"},predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.saveToActiveFile&&!!o.fileHandle&&!o.viewModeEnabled,perform:async(e,o,t,r)=>{let n=!!o.fileHandle;try{let{fileHandle:i}=Hl(o.fileHandle)?await $x(e,o,r.files,r.getName()):await Nl(e,o,r.files,r.getName());return{captureUpdate:ro.EVENTUALLY,appState:{...o,fileHandle:i,toast:n?{message:i?.name?g("toast.fileSavedToFilename").replace("{filename}",`"${i.name}"`):g("toast.fileSaved")}:null}}}catch(i){return i?.name!=="AbortError"?console.error(i):console.warn(i),{captureUpdate:ro.EVENTUALLY}}},keyTest:e=>!1}),Aa=N({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:zr,viewMode:!0,trackEvent:{category:"export"},perform:async(e,o,t,r)=>{try{let{fileHandle:n}=await Nl(e,{...o,fileHandle:null},r.files,r.getName());return{captureUpdate:ro.EVENTUALLY,appState:{...o,openDialog:null,fileHandle:n,toast:{message:g("toast.fileSaved")}}}}catch(n){return n?.name!=="AbortError"?console.error(n):console.warn(n),{captureUpdate:ro.EVENTUALLY}}},keyTest:e=>e.key===Vs.S&&e.shiftKey&&e[Vs.CTRL_OR_CMD],PanelComponent:({updateData:e})=>Fo(W,{type:"button",icon:V1,title:g("buttons.saveAs"),"aria-label":g("buttons.saveAs"),showAriaLabel:ce().editor.isMobile,hidden:!xn,onClick:()=>e(null),"data-testid":"save-as-button"})}),Jn=N({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.loadScene&&!o.viewModeEnabled,perform:async(e,o,t,r)=>{try{let{elements:n,appState:i,files:a}=await pm(o,e);return{elements:n,appState:i,files:a,captureUpdate:ro.IMMEDIATELY}}catch(n){return n?.name==="AbortError"?(console.warn(n),!1):{elements:e,appState:{...o,errorMessage:n.message},files:r.files,captureUpdate:ro.EVENTUALLY}}},keyTest:e=>e[Vs.CTRL_OR_CMD]&&e.key===Vs.O}),qx=N({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,o,t)=>({appState:{...o,exportWithDarkMode:t},captureUpdate:ro.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Fo("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:Fo(Ax,{value:e.exportWithDarkMode?Up.DARK:Up.LIGHT,onChange:t=>{o(t===Up.DARK)},title:g("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as Rk,DEFAULT_FONT_FAMILY as Nk,DEFAULT_TEXT_ALIGN as Bk,CODES as Jx,KEYS as Qx,getLineHeight as Fk}from"@excalidraw/common";import{newElementWith as Ks}from"@excalidraw/element";import{hasBoundTextElement as Ok,canApplyRoundnessTypeToElement as zk,getDefaultRoundnessTypeForElement as Hk,isFrameLikeElement as Gk,isArrowElement as Uk,isExcalidrawElement as Yk,isTextElement as Vp}from"@excalidraw/element";import{getBoundTextElement as Wk,redrawTextBoundingBox as Vk}from"@excalidraw/element";import{CaptureUpdateAction as Xp}from"@excalidraw/element";var eE="{}",Kp=N({name:"copyStyles",label:"labels.copyStyles",icon:zm,trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=[],i=e.find(a=>o.selectedElementIds[a.id]);if(n.push(i),i&&Ok(i)){let a=Wk(i,r.scene.getNonDeletedElementsMap());n.push(a)}return i&&(eE=JSON.stringify(n)),{appState:{...o,toast:{message:g("toast.copyStyles")}},captureUpdate:Xp.EVENTUALLY}},keyTest:e=>e[Qx.CTRL_OR_CMD]&&e.altKey&&e.code===Jx.C}),Zp=N({name:"pasteStyles",label:"labels.pasteStyles",icon:zm,trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=JSON.parse(eE),i=n[0],a=n[1];if(!Yk(i))return{elements:e,captureUpdate:Xp.EVENTUALLY};let l=$(e,o,{includeBoundTextElement:!0}),s=l.map(c=>c.id);return{elements:e.map(c=>{if(s.includes(c.id)){let d=i;if(Vp(c)&&c.containerId&&(d=a),!d)return c;let m=Ks(c,{backgroundColor:d?.backgroundColor,strokeWidth:d?.strokeWidth,strokeColor:d?.strokeColor,strokeStyle:d?.strokeStyle,fillStyle:d?.fillStyle,opacity:d?.opacity,roughness:d?.roughness,roundness:d.roundness?zk(d.roundness.type,c)?d.roundness:Hk(c):null});if(Vp(m)){let p=d.fontSize||Rk,u=d.fontFamily||Nk;m=Ks(m,{fontSize:p,fontFamily:u,textAlign:d.textAlign||Bk,lineHeight:d.lineHeight||Fk(u)});let f=null;m.containerId&&(f=l.find(b=>Vp(m)&&b.id===m.containerId)||null),Vk(m,f,r.scene)}return m.type==="arrow"&&Uk(d)&&(m=Ks(m,{startArrowhead:d.startArrowhead,endArrowhead:d.endArrowhead})),Gk(c)&&(m=Ks(m,{roundness:null,backgroundColor:"transparent"})),m}return c}),captureUpdate:Xp.IMMEDIATELY}},keyTest:e=>e[Qx.CTRL_OR_CMD]&&e.altKey&&e.code===Jx.V});import{KEYS as Xk}from"@excalidraw/common";import{getNonDeletedElements as Kk}from"@excalidraw/element";import{showSelectedShapeActions as Zk}from"@excalidraw/element";import{CaptureUpdateAction as $p}from"@excalidraw/element";import{jsx as tE}from"react/jsx-runtime";var $k=N({name:"toggleCanvasMenu",label:"buttons.menu",trackEvent:{category:"menu"},perform:(e,o)=>({appState:{...o,openMenu:o.openMenu==="canvas"?null:"canvas"},captureUpdate:$p.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>tE(W,{type:"button",icon:Zl,"aria-label":g("buttons.menu"),onClick:o,selected:e.openMenu==="canvas"})}),jk=N({name:"toggleEditMenu",label:"buttons.edit",trackEvent:{category:"menu"},perform:(e,o)=>({appState:{...o,openMenu:o.openMenu==="shape"?null:"shape"},captureUpdate:$p.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>tE(W,{visible:Zk(o,Kk(e)),type:"button",icon:X1,"aria-label":g("buttons.edit"),onClick:t,selected:o.openMenu==="shape"})}),jr=N({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:z1,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,o,t,{focusContainer:r})=>(o.openDialog?.name==="help"&&r(),{appState:{...o,openDialog:o.openDialog?.name==="help"?null:{name:"help"}},captureUpdate:$p.EVENTUALLY}),keyTest:e=>e.key===Xk.QUESTION_MARK});import{getNonDeletedElements as $s}from"@excalidraw/element";import{newElementWith as nE}from"@excalidraw/element";import{isBoundToContainer as qk}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as Jk,getElementsInResizingFrame as Qk,getFrameLikeElements as eM,getRootElements as tM,groupByFrameLikes as oM,removeElementsFromFrame as rM,replaceAllElementsInFrame as nM}from"@excalidraw/element";import{KEYS as js,randomId as iM,arrayToMap as jp,getShortcutKey as iE}from"@excalidraw/common";import{getSelectedGroupIds as Zs,selectGroup as aM,selectGroupsForSelectedElements as lM,getElementsInGroup as oE,addToGroup as sM,removeFromSelectedGroups as cM,isElementInGroup as aE}from"@excalidraw/element";import{syncMovedIndices as dM}from"@excalidraw/element";import{CaptureUpdateAction as Da}from"@excalidraw/element";import{jsx as Qn}from"react/jsx-runtime";var mM=e=>{if(e.length>=2){let o=e[0].groupIds;for(let t of o)if(e.reduce((r,n)=>r&&aE(n,t),!0))return!0}return!1},rE=(e,o,t)=>{let r=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});return r.length>=2&&!mM(r)&&!Jk(r)},qp=N({name:"group",label:"labels.group",icon:e=>Qn(Rm,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=tM(r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}));if(n.length<2)return{appState:o,elements:e,captureUpdate:Da.EVENTUALLY};let i=Zs(o);if(i.length===1){let x=i[0],w=new Set(oE(e,x).map(v=>v.id)),E=new Set(n.map(v=>v.id));if(new Set([...Array.from(w),...Array.from(E)]).size===w.size)return{appState:o,elements:e,captureUpdate:Da.EVENTUALLY}}let a=[...e];new Set(n.map(x=>x.frameId)).size>1&&oM(n).forEach((w,E)=>{rM(w,r.scene.getNonDeletedElementsMap())});let s=iM(),c=jp(n);a=a.map(x=>c.get(x.id)?nE(x,{groupIds:sM(x.groupIds,s,o.editingGroupId)}):x);let d=oE(a,s),m=d[d.length-1],p=a.lastIndexOf(m),u=a.slice(p+1),f=a.slice(0,p).filter(x=>!aE(x,s)),b=dM([...f,...d,...u],jp(d));return{appState:{...o,...aM(s,{...o,selectedGroupIds:{}},$s(a))},elements:b,captureUpdate:Da.IMMEDIATELY}},predicate:(e,o,t,r)=>rE(e,o,r),keyTest:e=>!e.shiftKey&&e[js.CTRL_OR_CMD]&&e.key===js.G,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Qn(W,{hidden:!rE(e,o,r),type:"button",icon:Qn(Rm,{theme:o.theme}),onClick:()=>t(null),title:`${g("labels.group")} \u2014 ${iE("CtrlOrCmd+G")}`,"aria-label":g("labels.group"),visible:Ee($s(e),o)})}),Jp=N({name:"ungroup",label:"labels.ungroup",icon:e=>Qn(Nm,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=Zs(o),i=jp(e);if(n.length===0)return{appState:o,elements:e,captureUpdate:Da.EVENTUALLY};let a=[...e],l=[];a=a.map(p=>{qk(p)&&l.push(p.id);let u=cM(p.groupIds,o.selectedGroupIds);return u.length===p.groupIds.length?p:nE(p,{groupIds:u})});let s=lM(o,$s(a),o,null),c=r.scene.getSelectedElements(o),d=new Set(c.filter(p=>p.frameId).map(p=>p.frameId));return eM(e).filter(p=>d.has(p.id)).forEach(p=>{p&&(a=nM(a,Qk(a,p,o,i),p,r))}),s.selectedElementIds=Object.entries(s.selectedElementIds).reduce((p,[u,f])=>(f&&!l.includes(u)&&(p[u]=!0),p),{}),{appState:{...o,...s},elements:a,captureUpdate:Da.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[js.CTRL_OR_CMD]&&e.key===js.G.toUpperCase(),predicate:(e,o)=>Zs(o).length>0,PanelComponent:({elements:e,appState:o,updateData:t})=>Qn(W,{type:"button",hidden:Zs(o).length===0,icon:Qn(Nm,{theme:o.theme}),onClick:()=>t(null),title:`${g("labels.ungroup")} \u2014 ${iE("CtrlOrCmd+Shift+G")}`,"aria-label":g("labels.ungroup"),visible:Ee($s(e),o)})});import xM from"clsx";import{CaptureUpdateAction as mE}from"@excalidraw/element";import{COLOR_CHARCOAL_BLACK as pM,COLOR_VOICE_CALL as uM,COLOR_WHITE as Js,THEME as hM,UserIdleState as lE}from"@excalidraw/common";var qs=(e,o,t,r,n,i,a)=>{e.beginPath(),e.moveTo(o+i,t),e.lineTo(o+r-i,t),e.quadraticCurveTo(o+r,t,o+r,t+i),e.lineTo(o+r,t+n-i),e.quadraticCurveTo(o+r,t+n,o+r-i,t+n),e.lineTo(o+i,t+n),e.quadraticCurveTo(o,t+n,o,t+n-i),e.lineTo(o,t+i),e.quadraticCurveTo(o,t,o+i,t),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};function gM(e){let o=0;if(e.length===0)return o;for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);o=(o<<5)-o+r}return o}var qr=(e,o)=>`hsl(${Math.abs(gM(o?.id||e))%37*10}, 100%, 83%)`,sE=e=>{let o=e?.trim()?.codePointAt(0);return(o?String.fromCodePoint(o):"?").toUpperCase()},cE=({context:e,renderConfig:o,appState:t,normalizedWidth:r,normalizedHeight:n})=>{for(let[i,a]of o.remotePointerViewportCoords){let{x:l,y:s}=a,c=t.collaborators.get(i);l-=t.offsetLeft,s-=t.offsetTop;let d=11,m=14,p=l<0||l>r-d||s<0||s>n-m;l=Math.max(l,0),l=Math.min(l,r-d),s=Math.max(s,0),s=Math.min(s,n-m);let u=qr(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let f=o.remotePointerUserStates.get(i),b=p||f===lE.IDLE||f===lE.AWAY;b&&(e.globalAlpha=.3),o.remotePointerButton.get(i)==="down"&&(e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=u,e.stroke(),e.closePath());let x=t.theme===hM.DARK?"#2f6330":uM,w=c?.isSpeaking;w&&(e.fillStyle=x,e.strokeStyle=x,e.lineWidth=10,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=Js,e.strokeStyle=Js,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=u,e.strokeStyle=u,e.lineWidth=2,e.lineJoin="round",e.beginPath(),b?(e.moveTo(l-1,s-1),e.lineTo(l-1,s+15),e.lineTo(l+5,s+10),e.lineTo(l+12,s+9),e.closePath(),e.fill()):(e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.fill(),e.stroke());let E=o.remotePointerUsernames.get(i)||"";if(!p&&E){e.font="600 12px sans-serif";let y=(w?l+0:l)+d/2,v=(w?s+0:s)+m+2,C=5,S=3,L=e.measureText(E),k=L.actualBoundingBoxDescent+L.actualBoundingBoxAscent,A=Math.max(k,12),P=y-1,B=v-1,O=L.width+2+C*2+2,G=A+2+S*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(P,B,O,G,8),e.fillStyle=u,e.fill(),e.strokeStyle=Js,e.stroke(),w&&(e.beginPath(),e.roundRect(P-2,B-2,O+4,G+4,8),e.strokeStyle=x,e.stroke())):qs(e,P,B,O,G,8,Js),e.fillStyle=pM,e.fillText(E,y+C+1,v+S+L.actualBoundingBoxAscent+Math.floor((A-k)/2)+2),w){e.fillStyle=x;let J=8,_=8,R=5;e.fillRect(P+O+_,B+(G/2-J/2),2,J),e.fillRect(P+O+_+R,B+(G/2-J*2/2),2,J*2),e.fillRect(P+O+_+R*2,B+(G/2-J/2),2,J)}}e.restore(),e.closePath()}};import fM from"clsx";import{useState as bM}from"react";import{jsx as dE}from"react/jsx-runtime";var Qp=({color:e,onClick:o,name:t,src:r,className:n})=>{let i=sE(t),[a,l]=bM(!1),s=!a&&r,c=s?void 0:{background:e};return dE("div",{className:fM("Avatar",n),style:c,onClick:o,children:s?dE("img",{className:"Avatar-img",src:r,alt:i,referrerPolicy:"no-referrer",onError:()=>l(!0)}):i})};import{jsx as yo,jsxs as Qs}from"react/jsx-runtime";var EM=N({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,o,t)=>!t.socketId||o.userToFollow?.socketId===t.socketId||t.isCurrentUser?{appState:{...o,userToFollow:null},captureUpdate:mE.EVENTUALLY}:{appState:{...o,userToFollow:{socketId:t.socketId,username:t.username||""},openMenu:o.openMenu==="canvas"?null:o.openMenu},captureUpdate:mE.EVENTUALLY},PanelComponent:({updateData:e,data:o,appState:t})=>{let{socketId:r,collaborator:n,withName:i,isBeingFollowed:a}=o,l=qr(r,n),s=xM({"is-followed":a,"is-current-user":n.isCurrentUser===!0,"is-speaking":n.isSpeaking,"is-in-call":n.isInCall,"is-muted":n.isMuted}),c=n.isInCall?n.isSpeaking?Qs("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:g("userList.hint.isSpeaking"),children:[yo("div",{}),yo("div",{}),yo("div",{})]}):n.isMuted?yo("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:g("userList.hint.micMuted"),children:J0}):yo("div",{title:g("userList.hint.inCall"),children:q0}):null;return i?Qs("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(n),children:[yo(Qp,{color:l,onClick:()=>{},name:n.username||"",src:n.avatarUrl,className:s}),yo("div",{className:"UserList__collaborator-name",children:n.username}),Qs("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&yo("div",{className:"UserList__collaborator-status-icon-is-followed",title:g("userList.hint.followStatus"),children:Gr}),c]})]}):Qs("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[yo(Qp,{color:l,onClick:()=>{e(n)},name:n.username||"",src:n.avatarUrl,className:s}),c&&yo("div",{className:"UserList__collaborator-status-icon",children:c})]})}});import{LIBRARY_DISABLED_TYPES as yM,randomId as wM}from"@excalidraw/common";import{deepCopyElement as vM}from"@excalidraw/element";import{CaptureUpdateAction as eu}from"@excalidraw/element";var tu=N({name:"addToLibrary",trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let i of yM)if(n.some(a=>a.type===i))return{captureUpdate:eu.EVENTUALLY,appState:{...o,errorMessage:g(`errors.libraryElementTypeError.${i}`)}};return r.library.getLatestLibrary().then(i=>r.library.setLibrary([{id:wM(),status:"unpublished",elements:n.map(vM),created:Date.now()},...i])).then(()=>({captureUpdate:eu.EVENTUALLY,appState:{...o,toast:{message:g("toast.addedToLibrary")}}})).catch(i=>({captureUpdate:eu.EVENTUALLY,appState:{...o,errorMessage:i.message}}))},label:"labels.addToLibrary"});import{getNonDeletedElements as ei}from"@excalidraw/element";import{isFrameLikeElement as TM}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as IM}from"@excalidraw/element";import{KEYS as sr,arrayToMap as CM,getShortcutKey as ec}from"@excalidraw/common";import{alignElements as SM}from"@excalidraw/element";import{CaptureUpdateAction as ti}from"@excalidraw/element";import{getMaximumGroups as kM}from"@excalidraw/element/groups";import{getSelectedElementsByGroup as MM}from"@excalidraw/element";import{jsx as ri}from"react/jsx-runtime";var at=(e,o)=>{let t=o.scene.getSelectedElements(e);return kM(t,o.scene.getNonDeletedElementsMap()).length>1&&MM(t,o.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(n=>TM(n))},oi=(e,o,t,r)=>{let n=t.scene.getSelectedElements(o),i=SM(n,r,t.scene,o),a=CM(i);return IM(e.map(l=>a.get(l.id)||l),o,t)},LM=N({name:"alignTop",label:"labels.alignTop",icon:Mm,trackEvent:{category:"element"},predicate:(e,o,t,r)=>at(o,r),perform:(e,o,t,r)=>({appState:o,elements:oi(e,o,r,{position:"start",axis:"y"}),captureUpdate:ti.IMMEDIATELY}),keyTest:e=>e[sr.CTRL_OR_CMD]&&e.shiftKey&&e.key===sr.ARROW_UP,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>ri(W,{hidden:!at(o,r),type:"button",icon:Mm,onClick:()=>t(null),title:`${g("labels.alignTop")} \u2014 ${ec("CtrlOrCmd+Shift+Up")}`,"aria-label":g("labels.alignTop"),visible:Ee(ei(e),o)})}),PM=N({name:"alignBottom",label:"labels.alignBottom",icon:Lm,trackEvent:{category:"element"},predicate:(e,o,t,r)=>at(o,r),perform:(e,o,t,r)=>({appState:o,elements:oi(e,o,r,{position:"end",axis:"y"}),captureUpdate:ti.IMMEDIATELY}),keyTest:e=>e[sr.CTRL_OR_CMD]&&e.shiftKey&&e.key===sr.ARROW_DOWN,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>ri(W,{hidden:!at(o,r),type:"button",icon:Lm,onClick:()=>t(null),title:`${g("labels.alignBottom")} \u2014 ${ec("CtrlOrCmd+Shift+Down")}`,"aria-label":g("labels.alignBottom"),visible:Ee(ei(e),o)})}),AM=N({name:"alignLeft",label:"labels.alignLeft",icon:Pm,trackEvent:{category:"element"},predicate:(e,o,t,r)=>at(o,r),perform:(e,o,t,r)=>({appState:o,elements:oi(e,o,r,{position:"start",axis:"x"}),captureUpdate:ti.IMMEDIATELY}),keyTest:e=>e[sr.CTRL_OR_CMD]&&e.shiftKey&&e.key===sr.ARROW_LEFT,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>ri(W,{hidden:!at(o,r),type:"button",icon:Pm,onClick:()=>t(null),title:`${g("labels.alignLeft")} \u2014 ${ec("CtrlOrCmd+Shift+Left")}`,"aria-label":g("labels.alignLeft"),visible:Ee(ei(e),o)})}),DM=N({name:"alignRight",label:"labels.alignRight",icon:Am,trackEvent:{category:"element"},predicate:(e,o,t,r)=>at(o,r),perform:(e,o,t,r)=>({appState:o,elements:oi(e,o,r,{position:"end",axis:"x"}),captureUpdate:ti.IMMEDIATELY}),keyTest:e=>e[sr.CTRL_OR_CMD]&&e.shiftKey&&e.key===sr.ARROW_RIGHT,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>ri(W,{hidden:!at(o,r),type:"button",icon:Am,onClick:()=>t(null),title:`${g("labels.alignRight")} \u2014 ${ec("CtrlOrCmd+Shift+Right")}`,"aria-label":g("labels.alignRight"),visible:Ee(ei(e),o)})}),_M=N({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Dm,trackEvent:{category:"element"},predicate:(e,o,t,r)=>at(o,r),perform:(e,o,t,r)=>({appState:o,elements:oi(e,o,r,{position:"center",axis:"y"}),captureUpdate:ti.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>ri(W,{hidden:!at(o,r),type:"button",icon:Dm,onClick:()=>t(null),title:g("labels.centerVertically"),"aria-label":g("labels.centerVertically"),visible:Ee(ei(e),o)})}),RM=N({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:_m,trackEvent:{category:"element"},predicate:(e,o,t,r)=>at(o,r),perform:(e,o,t,r)=>({appState:o,elements:oi(e,o,r,{position:"center",axis:"x"}),captureUpdate:ti.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>ri(W,{hidden:!at(o,r),type:"button",icon:_m,onClick:()=>t(null),title:g("labels.centerHorizontally"),"aria-label":g("labels.centerHorizontally"),visible:Ee(ei(e),o)})});import{getNonDeletedElements as pE}from"@excalidraw/element";import{isFrameLikeElement as NM}from"@excalidraw/element";import{CODES as uE,KEYS as hE,arrayToMap as BM,getShortcutKey as gE}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as FM}from"@excalidraw/element";import{distributeElements as OM}from"@excalidraw/element";import{CaptureUpdateAction as fE}from"@excalidraw/element";import{getSelectedElementsByGroup as zM}from"@excalidraw/element";import{jsx as EE}from"react/jsx-runtime";var bE=(e,o)=>{let t=o.scene.getSelectedElements(e);return zM(t,o.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(r=>NM(r))},xE=(e,o,t,r)=>{let n=t.scene.getSelectedElements(o),i=OM(n,t.scene.getNonDeletedElementsMap(),r,o),a=BM(i);return FM(e.map(l=>a.get(l.id)||l),o,t)},HM=N({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,o,t,r)=>({appState:o,elements:xE(e,o,r,{space:"between",axis:"x"}),captureUpdate:fE.IMMEDIATELY}),keyTest:e=>!e[hE.CTRL_OR_CMD]&&e.altKey&&e.code===uE.H,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>EE(W,{hidden:!bE(o,r),type:"button",icon:e0,onClick:()=>t(null),title:`${g("labels.distributeHorizontally")} \u2014 ${gE("Alt+H")}`,"aria-label":g("labels.distributeHorizontally"),visible:Ee(pE(e),o)})}),GM=N({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,o,t,r)=>({appState:o,elements:xE(e,o,r,{space:"between",axis:"y"}),captureUpdate:fE.IMMEDIATELY}),keyTest:e=>!e[hE.CTRL_OR_CMD]&&e.altKey&&e.code===uE.V,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>EE(W,{hidden:!bE(o,r),type:"button",icon:t0,onClick:()=>t(null),title:`${g("labels.distributeVertically")} \u2014 ${gE("Alt+V")}`,"aria-label":g("labels.distributeVertically"),visible:Ee(pE(e),o)})});import{arrayToMap as yE,getShortcutKey as UM,KEYS as YM,matchKey as WM}from"@excalidraw/common";import{CaptureUpdateAction as VM}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as XM}from"@excalidraw/element/frame";import{arrangeElements as KM}from"@excalidraw/element/arrange";import{jsx as qM}from"react/jsx-runtime";var ZM=(e,o,t)=>{let r=t.scene.getSelectedElements(o),n=yE(e),i=KM(t.scene,r,n,o.arrangeConfiguration.algorithm,o.arrangeConfiguration.gap),a=yE(i);return XM(e.map(l=>a.get(l.id)||l),o,t)},$M=at,jM=N({name:"arrangeElements",label:"labels.arrangeElements",keywords:["arrange","rearrange","spread"],icon:Gm,trackEvent:{category:"element"},viewMode:!1,predicate:(e,o,t,r)=>$M(o,r),perform:(e,o,t,r)=>({appState:o,elements:ZM(e,o,r),captureUpdate:VM.IMMEDIATELY}),keyTest:e=>e.shiftKey&&WM(e,YM.R),PanelComponent:({updateData:e})=>qM("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:`${g("labels.arrangeElements")} \u2014 ${UM("Shift+R")}`,children:Gm})});import{getNonDeletedElements as JM}from"@excalidraw/element";import{bindOrUnbindLinearElements as QM,isBindingEnabled as eL}from"@excalidraw/element";import{getCommonBoundingBox as wE}from"@excalidraw/element";import{newElementWith as tL}from"@excalidraw/element";import{deepCopyElement as oL}from"@excalidraw/element";import{resizeMultipleElements as rL}from"@excalidraw/element";import{isArrowElement as nL,isElbowArrow as iL,isLinearElement as aL}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as vE}from"@excalidraw/element";import{CODES as TE,KEYS as lL,arrayToMap as sL}from"@excalidraw/common";import{CaptureUpdateAction as IE}from"@excalidraw/element";var ou=N({name:"flipHorizontal",label:"labels.flipHorizontal",icon:ob,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:vE(CE(e,r.scene.getNonDeletedElementsMap(),o,"horizontal",r),o,r),appState:o,captureUpdate:IE.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===TE.H}),ru=N({name:"flipVertical",label:"labels.flipVertical",icon:tb,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:vE(CE(e,r.scene.getNonDeletedElementsMap(),o,"vertical",r),o,r),appState:o,captureUpdate:IE.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===TE.V&&!e[lL.CTRL_OR_CMD]}),CE=(e,o,t,r,n)=>{let i=$(JM(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=cL(i,o,t,r,n),l=sL(a);return e.map(s=>l.get(s.id)||s)},cL=(e,o,t,r,n)=>{if(e.every(u=>nL(u)&&(u.startBinding||u.endBinding)))return e.map(u=>{let f=u;return tL(f,{startArrowhead:f.endArrowhead,endArrowhead:f.startArrowhead})});let{midX:i,midY:a}=wE(e);rL(e,o,"nw",n.scene,new Map(Array.from(o.values()).map(u=>[u.id,oL(u)])),{flipByX:r==="horizontal",flipByY:r==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),QM(e.filter(aL),eL(t),[],n.scene,t.zoom);let{elbowArrows:l,otherElements:s}=e.reduce((u,f)=>iL(f)?{...u,elbowArrows:u.elbowArrows.concat(f)}:{...u,otherElements:u.otherElements.concat(f)},{elbowArrows:[],otherElements:[]}),{midX:c,midY:d}=wE(e),[m,p]=[i-c,a-d];return s.forEach(u=>n.scene.mutateElement(u,{x:u.x+m,y:u.y+p})),l.forEach(u=>n.scene.mutateElement(u,{x:u.x+m,y:u.y+p})),e};import{isTextElement as dL}from"@excalidraw/element";import{getTextFromElements as mL}from"@excalidraw/element";import{CODES as pL,KEYS as SE,isFirefox as uL}from"@excalidraw/common";import{CaptureUpdateAction as _t}from"@excalidraw/element";var ni=N({name:"copy",label:"labels.copy",icon:oa,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await Us(n,r.files,t)}catch(i){return{captureUpdate:_t.EVENTUALLY,appState:{...o,errorMessage:i.message}}}return{captureUpdate:_t.EVENTUALLY}},keyTest:void 0}),nu=N({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n;try{n=await Kx()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),uL?{captureUpdate:_t.EVENTUALLY,appState:{...o,errorMessage:g("hints.firefox_clipboard_write")}}:{captureUpdate:_t.EVENTUALLY,appState:{...o,errorMessage:g("errors.asyncPasteFailedOnRead")}})}try{r.pasteFromClipboard(Vx({types:n}))}catch(i){return console.error(i),{captureUpdate:_t.EVENTUALLY,appState:{...o,errorMessage:g("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:_t.EVENTUALLY}},keyTest:void 0}),tc=N({name:"cut",label:"labels.cut",icon:z0,trackEvent:{category:"element"},perform:(e,o,t,r)=>(ni.perform(e,o,t,r),ma.perform(e,o,null,r)),keyTest:e=>e[SE.CTRL_OR_CMD]&&e.key===SE.X}),oc=N({name:"copyAsSvg",label:"labels.copyAsSvg",icon:rb,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{if(!r.canvas)return{captureUpdate:_t.EVENTUALLY};let{exportedElements:n,exportingFrame:i}=Kr(e,o,!0);try{await Zr("clipboard-svg",n,o,r.files,{...o,exportingFrame:i,name:r.getName()});let a=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:g("toast.copyToClipboardAsSvg",{exportSelection:a.length?g("toast.selection"):g("toast.canvas"),exportColorScheme:o.exportWithDarkMode?g("buttons.darkMode"):g("buttons.lightMode")})}},captureUpdate:_t.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:_t.EVENTUALLY}}},predicate:e=>Gs&&e.length>0,keywords:["svg","clipboard","copy"]}),rc=N({name:"copyAsPng",label:"labels.copyAsPng",icon:nb,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{if(!r.canvas)return{captureUpdate:_t.EVENTUALLY};let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=Kr(e,o,!0);try{return await Zr("clipboard",i,o,r.files,{...o,exportingFrame:a,name:r.getName()}),{appState:{...o,toast:{message:g("toast.copyToClipboardAsPng",{exportSelection:n.length?g("toast.selection"):g("toast.canvas"),exportColorScheme:o.exportWithDarkMode?g("buttons.darkMode"):g("buttons.lightMode")})}},captureUpdate:_t.EVENTUALLY}}catch(l){return console.error(l),{appState:{...o,errorMessage:l.message},captureUpdate:_t.EVENTUALLY}}},predicate:e=>lr&&e.length>0,keyTest:e=>e.code===pL.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),nc=N({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});try{oo(mL(n))}catch{throw new Error(g("errors.copyToSystemClipboardFailed"))}return{captureUpdate:_t.EVENTUALLY}},predicate:(e,o,t,r)=>Gs&&r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}).some(dL),keywords:["text","clipboard","copy"]});import{CODES as hL,KEYS as gL}from"@excalidraw/common";import{CaptureUpdateAction as fL}from"@excalidraw/element";var ic=N({name:"gridMode",icon:sb,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>e.gridModeEnabled},perform(e,o){return{appState:{...o,gridModeEnabled:!this.checked(o),objectsSnapModeEnabled:!1},captureUpdate:fL.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[gL.CTRL_OR_CMD]&&e.code===hL.QUOTE});import{CODES as bL,KEYS as xL}from"@excalidraw/common";import{CaptureUpdateAction as EL}from"@excalidraw/element";var ii=N({name:"zenMode",label:"buttons.zenMode",icon:ab,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,o){return{appState:{...o,zenModeEnabled:!this.checked(o)},captureUpdate:EL.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,o,t)=>typeof t.zenModeEnabled>"u",keyTest:e=>!e[xL.CTRL_OR_CMD]&&e.altKey&&e.code===bL.Z});import{CODES as yL,KEYS as wL}from"@excalidraw/common";import{CaptureUpdateAction as vL}from"@excalidraw/element";var iu=N({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:ib,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,o){return{appState:{...o,objectsSnapModeEnabled:!this.checked(o),gridModeEnabled:!1},captureUpdate:vL.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,o,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[wL.CTRL_OR_CMD]&&e.altKey&&e.code===yL.S});import{CODES as TL,KEYS as IL}from"@excalidraw/common";import{CaptureUpdateAction as CL}from"@excalidraw/element";var ai=N({name:"stats",label:"stats.fullTitle",icon:eb,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,o){return{appState:{...o,stats:{...o.stats,open:!this.checked(o)}},captureUpdate:CL.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[IL.CTRL_OR_CMD]&&e.altKey&&e.code===TL.SLASH});import{BOUND_TEXT_PADDING as kE,ROUNDNESS as ME,TEXT_ALIGN as PE,VERTICAL_ALIGN as AE,arrayToMap as DE,getFontString as SL}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as kL,resetOriginalContainerCache as ML,updateOriginalContainerCache as LL}from"@excalidraw/element";import{computeBoundTextPosition as PL,computeContainerDimensionForBoundText as LE,getBoundTextElement as _E,redrawTextBoundingBox as RE}from"@excalidraw/element";import{hasBoundTextElement as AL,isArrowElement as DL,isTextBindableContainer as au,isTextElement as _a,isUsingAdaptiveRadius as _L}from"@excalidraw/element";import{measureText as RL}from"@excalidraw/element";import{syncMovedIndices as NE}from"@excalidraw/element";import{newElement as NL}from"@excalidraw/element";import{CaptureUpdateAction as lu}from"@excalidraw/element";var su=N({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>r.scene.getSelectedElements(o).some(i=>AL(i)),perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=r.scene.getNonDeletedElementsMap();return n.forEach(a=>{let l=_E(a,i);if(l){let{width:s,height:c}=RL(l.originalText,SL(l),l.lineHeight),d=kL(a.id);ML(a.id);let{x:m,y:p}=PL(a,l,i);r.scene.mutateElement(l,{containerId:null,width:s,height:c,text:l.originalText,x:m,y:p}),r.scene.mutateElement(a,{boundElements:a.boundElements?.filter(u=>u.id!==l.id),height:d||a.height})}}),{elements:e,appState:o,captureUpdate:lu.IMMEDIATELY}}}),cu=N({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);if(n.length===2){let i=_a(n[0])||_a(n[1]),a;if(au(n[0])?a=n[0]:au(n[1])&&(a=n[1]),i&&a&&_E(a,r.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i,a;_a(n[0])&&au(n[1])?(i=n[0],a=n[1]):(i=n[1],a=n[0]),r.scene.mutateElement(i,{containerId:a.id,verticalAlign:AE.MIDDLE,textAlign:PE.CENTER,autoResize:!0,angle:DL(a)?0:a?.angle??0}),r.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let l=a.height;return RE(i,a,r.scene),LL(a.id,l),{elements:BL(e,a,i),appState:{...o,selectedElementIds:{[a.id]:!0}},captureUpdate:lu.IMMEDIATELY}}}),BL=(e,o,t)=>{let r=e.slice(),n=r.findIndex(a=>a.id===t.id);r.splice(n,1);let i=r.findIndex(a=>a.id===o.id);return r.splice(i+1,0,t),NE(r,DE([o,t])),r},FL=(e,o,t)=>{let r=e.slice(),n=r.findIndex(a=>a.id===o.id);r.splice(n,1);let i=r.findIndex(a=>a.id===t.id);return r.splice(i,0,o),NE(r,DE([o,t])),r},BE=N({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=n.some(a=>_a(a));return n.length>0&&i},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=e.slice(),a={};for(let l of n)if(_a(l)){let s=NL({type:"rectangle",backgroundColor:o.currentItemBackgroundColor,boundElements:[...l.boundElements||[],{id:l.id,type:"text"}],angle:l.angle,fillStyle:o.currentItemFillStyle,strokeColor:o.currentItemStrokeColor,roughness:o.currentItemRoughness,strokeWidth:o.currentItemStrokeWidth,strokeStyle:o.currentItemStrokeStyle,roundness:o.currentItemRoundness==="round"?{type:_L("rectangle")?ME.ADAPTIVE_RADIUS:ME.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:l.x-kE,y:l.y-kE,width:LE(l.width,"rectangle"),height:LE(l.height,"rectangle"),groupIds:l.groupIds,frameId:l.frameId});if(l.boundElements?.length){let c=l.boundElements.filter(m=>m.type==="arrow").map(m=>m.id);i.filter(m=>c.includes(m.id)).forEach(m=>{let p=m.startBinding,u=m.endBinding;p?.elementId===l.id&&(p={...p,elementId:s.id}),u?.elementId===l.id&&(u={...u,elementId:s.id}),(p||u)&&r.scene.mutateElement(m,{startBinding:p,endBinding:u})})}r.scene.mutateElement(l,{containerId:s.id,verticalAlign:AE.MIDDLE,boundElements:null,textAlign:PE.CENTER,autoResize:!0}),RE(l,s,r.scene),i=FL([...i,s],s,l),a[s.id]=!0}return{elements:i,appState:{...o,selectedElementIds:a},captureUpdate:lu.IMMEDIATELY}}});import{isEmbeddableElement as eP}from"@excalidraw/element";import{KEYS as XE,getShortcutKey as tP}from"@excalidraw/common";import{CaptureUpdateAction as oP}from"@excalidraw/element";import{pointFrom as HE}from"@excalidraw/math";import OL from"clsx";import{useCallback as FE,useEffect as OE,useLayoutEffect as zL,useRef as HL,useState as GL}from"react";import{EVENT as du,HYPERLINK_TOOLTIP_DELAY as UL,KEYS as ac}from"@excalidraw/common";import{getElementAbsoluteCoords as gu}from"@excalidraw/element";import{hitElementBoundingBox as YL}from"@excalidraw/element";import{isElementLink as WL}from"@excalidraw/element";import{getEmbedLink as VL,embeddableURLValidator as XL}from"@excalidraw/element";import{sceneCoordsToViewportCoords as GE,viewportCoordsToSceneCoords as KL,wrapEvent as ZL,isLocalLink as $L,normalizeLink as mu}from"@excalidraw/common";import{isEmbeddableElement as pu}from"@excalidraw/element";import{jsx as li,jsxs as zE}from"react/jsx-runtime";var fu=380,jL=42,uu=5,UE=85,qL=500,hu=!1,lc=new Map,YE=({element:e,scene:o,setAppState:t,onLinkOpen:r,setToast:n,updateEmbedValidationStatus:i})=>{let a=o.getNonDeletedElementsMap(),l=go(),s=fo(),c=ce(),d=e.link||"",[m,p]=GL(d),u=HL(null),f=l.showHyperlinkPopup==="editor",b=FE(()=>{if(!u.current)return;let v=mu(u.current.value)||null;if(!e.link&&v&&re("hyperlink","create"),pu(e)){if(l.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!v){o.mutateElement(e,{link:null}),i(e,!1);return}if(!XL(v,s.validateEmbeddable))v&&n({message:g("toast.unableToEmbed"),closable:!0}),e.link&&lc.set(e.id,e.link),o.mutateElement(e,{link:v}),i(e,!1);else{let{width:C,height:S}=e,L=VL(v);L?.error instanceof URIError&&n({message:g("toast.unrecognizedLinkFormat"),closable:!0});let k=L?L.intrinsicSize.w/L.intrinsicSize.h:1,A=lc.get(e.id)!==e.link;o.mutateElement(e,{...A?{width:L?.type==="video"?C>S?C:S*k:C,height:L?.type==="video"&&C>S?C/k:S}:{},link:v}),i(e,!0),lc.has(e.id)&&lc.delete(e.id)}}else o.mutateElement(e,{link:v})},[e,o,n,s.validateEmbeddable,l.activeEmbeddable,t,i]);zL(()=>()=>{b()},[b]),OE(()=>{f&&u?.current&&!(c.viewport.isMobile||c.isTouchScreen)&&u.current.select()},[f,c.viewport.isMobile,c.isTouchScreen]),OE(()=>{let v=null,C=S=>{if(f)return;v&&clearTimeout(v),QL(e,a,l,HE(S.clientX,S.clientY))&&(v=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},qL))};return window.addEventListener(du.POINTER_MOVE,C,!1),()=>{window.removeEventListener(du.POINTER_MOVE,C,!1),v&&clearTimeout(v)}},[l,e,f,t,a]);let x=FE(()=>{re("hyperlink","delete"),o.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,o]),w=()=>{re("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:E,y}=WE(e,l,a);return l.contextMenu||l.selectedElementsAreBeingDragged||l.resizingElement||l.isRotating||l.openMenu||l.viewModeEnabled?null:zE("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${y}px`,left:`${E}px`,width:fu,padding:uu},children:[f?li("input",{className:OL("excalidraw-hyperlinkContainer-input"),placeholder:g("labels.link.hint"),ref:u,value:m,onChange:v=>p(v.target.value),autoFocus:!0,onKeyDown:v=>{v.stopPropagation(),v[ac.CTRL_OR_CMD]&&v.key===ac.K&&v.preventDefault(),(v.key===ac.ENTER||v.key===ac.ESCAPE)&&(b(),t({showHyperlinkPopup:"info"}))}}):e.link?li("a",{href:mu(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:$L(e.link)?"_self":"_blank",onClick:v=>{if(e.link&&r){let C=ZL(du.EXCALIDRAW_LINK,v.nativeEvent);r({...e,link:mu(e.link)},C),C.defaultPrevented&&v.preventDefault()}},rel:"noopener noreferrer",children:e.link}):li("div",{className:"excalidraw-hyperlinkContainer-link",children:g("labels.link.empty")}),zE("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!f&&li(W,{type:"button",title:g("buttons.edit"),"aria-label":g("buttons.edit"),label:g("buttons.edit"),onClick:w,className:"excalidraw-hyperlinkContainer--edit",icon:jo}),li(W,{type:"button",title:g("labels.linkToElement"),"aria-label":g("labels.linkToElement"),label:g("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:as}),d&&!pu(e)&&li(W,{type:"button",title:g("buttons.remove"),"aria-label":g("buttons.remove"),label:g("buttons.remove"),onClick:x,className:"excalidraw-hyperlinkContainer--remove",icon:Do})]})]})},WE=(e,o,t)=>{let[r,n]=gu(e,t),{x:i,y:a}=GE({sceneX:r+e.width/2,sceneY:n},o),l=i-o.offsetLeft-fu/2,s=a-o.offsetTop-UE;return{x:l,y:s}},bu=(e,o)=>{let t=$(e,o);return pu(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},Ra=null,VE=(e,o,t)=>{Ra&&clearTimeout(Ra),Ra=window.setTimeout(()=>JL(e,o,t),UL)},JL=(e,o,t)=>{if(!e.link)return;let r=$n();r.classList.add("excalidraw-tooltip--visible"),r.style.maxWidth="20rem",r.textContent=WL(e.link)?g("labels.link.goToElement"):e.link;let[n,i,a,l]=gu(e,t),[s,c,d,m]=e1([n,i,a,l],e.angle,o),p=GE({sceneX:s,sceneY:c},o);Pp(r,{left:p.x,top:p.y,width:d,height:m},"top"),re("hyperlink","tooltip","link-icon"),hu=!0},xu=()=>{Ra&&clearTimeout(Ra),hu&&(hu=!1,$n().classList.remove("excalidraw-tooltip--visible"))},QL=(e,o,t,[r,n])=>{let{x:i,y:a}=KL({clientX:r,clientY:n},t),l=15/t.zoom.value;if(YL(HE(i,a),e,o))return!1;let[s,c,d]=gu(e,o);if(i>=s&&i<=d&&a>=c-UE&&a<=c)return!1;let{x:m,y:p}=WE(e,t,o);return!(r>=m-l&&r<=m+fu+uu*2+l&&n>=p-l&&n<=p+l+uu*2+jL)};import{jsx as rP}from"react/jsx-runtime";var Na=N({name:"hyperlink",label:(e,o)=>bu(e,o),icon:ia,perform:(e,o)=>o.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...o,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:oP.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[XE.CTRL_OR_CMD]&&e.key===XE.K,predicate:(e,o)=>$(e,o).length===1,PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=$(e,o);return rP(W,{type:"button",icon:ia,"aria-label":g(bu(e,o)),title:`${eP(e[0])?g("labels.link.labelEmbed"):g("labels.link.label")} - ${tP("CtrlOrCmd+K")}`,onClick:()=>t(null),selected:r.length===1&&!!r[0].link})}});import{KEYS as KE,arrayToMap as yu,randomId as nP}from"@excalidraw/common";import{elementsAreInSameGroup as iP,newElementWith as ZE,selectGroupsFromGivenElements as $E}from"@excalidraw/element";import{CaptureUpdateAction as jE}from"@excalidraw/element";var Eu=e=>e.every(o=>!o.locked),Ba=N({name:"toggleElementLock",label:(e,o,t)=>{let r=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1});return Eu(r)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,o)=>{let t=$(o,e);return Eu(t)?$o:Ao},trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return n.length>0&&!n.some(i=>i.locked&&i.frameId)},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!n.length)return!1;let i=Eu(n),a=yu(n),l=n.length>1&&iP(n),c=n.length===1||l?null:nP(),d={...o.lockedMultiSelections};if(i)d={...o.lockedMultiSelections,...c?{[c]:!0}:{}};else if(l){let w=n[0].groupIds.at(-1);delete d[w]}let m=e.map(w=>{if(!a.has(w.id))return w;let E=w.groupIds;return i?c&&(E=[...E,c]):E=E.filter(y=>!o.lockedMultiSelections[y]),ZE(w,{locked:i,groupIds:E.length!==w.groupIds.length?E:w.groupIds})}),p=yu(m),u=i?{}:Object.fromEntries(n.map(w=>[w.id,!0])),f=n.map(w=>p.get(w.id)||w),b=i?{}:$E(f,o),x=i?c||(l?n[0].groupIds.at(-1):n[0].id):null;return{elements:m,appState:{...o,selectedElementIds:u,selectedGroupIds:b,selectedLinearElement:i?null:o.selectedLinearElement,lockedMultiSelections:d,activeLockedId:x},captureUpdate:jE.IMMEDIATELY}},keyTest:(e,o,t,r)=>e.key.toLocaleLowerCase()===KE.L&&e[KE.CTRL_OR_CMD]&&e.shiftKey&&r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}).length>0}),qE=N({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:Ao,predicate:(e,o)=>$(e,o).length===0&&e.some(r=>r.locked),perform:(e,o)=>{let t=e.filter(a=>a.locked),r=e.map(a=>{if(a.locked){let l=a.groupIds.filter(s=>!o.lockedMultiSelections[s]);return ZE(a,{locked:!1,groupIds:a.groupIds.length!==l.length?l:a.groupIds})}return a}),n=yu(r),i=t.map(a=>n.get(a.id)||a);return{elements:r,appState:{...o,selectedElementIds:Object.fromEntries(t.map(a=>[a.id,!0])),selectedGroupIds:$E(i,o),lockedMultiSelections:{},activeLockedId:null},captureUpdate:jE.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as fD,isLinearElement as bD,isLineElement as Si}from"@excalidraw/element";import{arrayToMap as xD,invariant as xh}from"@excalidraw/common";import{toggleLinePolygonState as ED,CaptureUpdateAction as q2}from"@excalidraw/element";import T2 from"clsx";import m7 from"fuzzy";import{useEffect as _c,useRef as p7,useState as Dc}from"react";import{DEFAULT_SIDEBAR as w2,EVENT as Nc,KEYS as ao,capitalizeString as u7,getShortcutKey as h7,isWritableElement as g7}from"@excalidraw/common";import{CaptureUpdateAction as GP}from"@excalidraw/element";import{useEffect as za,useMemo as JE,useRef as Iu,useState as aP}from"react";import{getLinearElementSubType as di,updateElbowArrowPoints as lP}from"@excalidraw/element";import{pointFrom as cc,pointRotateRads as sP}from"@excalidraw/math";import{hasBoundTextElement as cP,isArrowBoundToElement as dP,isArrowElement as mP,isElbowArrow as pP,isLinearElement as Mu,isUsingAdaptiveRadius as uP}from"@excalidraw/element";import{getCommonBoundingBox as hP,getElementAbsoluteCoords as gP}from"@excalidraw/element";import{getBoundTextElement as ry,getBoundTextMaxHeight as fP,getBoundTextMaxWidth as bP,redrawTextBoundingBox as xP}from"@excalidraw/element";import{wrapText as EP}from"@excalidraw/element";import{assertNever as yP,CLASSES as wP,getFontString as wu,isProdEnv as vP,mapFind as TP,reduceToCommonValue as IP,updateActiveTool as QE}from"@excalidraw/common";import{measureText as ey}from"@excalidraw/element";import{LinearElementEditor as CP}from"@excalidraw/element";import{newArrowElement as vu,newElement as SP,newLinearElement as kP}from"@excalidraw/element";import{ShapeCache as MP}from"@excalidraw/element";import{updateBindings as LP}from"@excalidraw/element";import{jsx as ku}from"react/jsx-runtime";var PP=8,AP=10,Fa=["rectangle","diamond","ellipse"],Oa=["line","sharpArrow","curvedArrow","elbowArrow"],DP=new Set(Fa),_P=new Set(Oa),mi=e=>DP.has(e),mc=e=>e==="arrow"||_P.has(e),no=he(null),Ha=new Map,Ga=new Map,RP=({app:e})=>{let o=e.scene.getSelectedElements(e.state),t=Iu(null);return za(()=>{if(o.length===0){e.updateEditorAtom(no,null);return}let r=pi(o);r&&!t.current?t.current=r:(t.current&&!r||t.current&&r!==t.current)&&(e.updateEditorAtom(no,null),t.current=null)},[o,e]),za(()=>()=>{Ha.clear(),Ga.clear()},[]),ku(NP,{app:e,elements:o})},NP=({app:e,elements:o})=>{let t=pi(o),r=JE(()=>t==="generic"?iy(o):[],[t,o]),n=JE(()=>t==="linear"?Su(o):[],[t,o]),i=t==="generic"?r.every(m=>m.type===r[0].type):t==="linear"?n.every(m=>di(m)===di(n[0])):!1,[a,l]=aP({x:0,y:0}),s=Iu(""),c=Iu(null);za(()=>{let m=[...r,...n].sort((x,w)=>x.id.localeCompare(w.id)),p=`
8
+ ${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${m.map(x=>x.id).join(",")}`;if(p===s.current)return;s.current=p;let u;if(m.length===1){let[x,,,w,E,y]=gP(m[0],e.scene.getNonDeletedElementsMap());u=sP(cc(x,w),cc(E,y),m[0].angle)}else{let{minX:x,maxY:w}=hP(m);u=cc(x,w)}let{x:f,y:b}=ly({sceneX:u[0],sceneY:u[1]},e.state);l({x:f,y:b})},[r,n,e.scene,e.state]),za(()=>{for(let m of n){let p=Cu(m.id,HP(m));Ga.has(p)||Ga.set(p,m)}},[n]),za(()=>{for(let m of r)if(!Ha.has(m.id)){let p=ry(m,e.scene.getNonDeletedElementsMap());p&&Ha.set(m.id,{fontSize:p.fontSize})}},[r,e.scene]);let d=t==="linear"?[["line",Mn],["sharpArrow",os],["curvedArrow",ns],["elbowArrow",rs]]:t==="generic"?[["rectangle",Cn],["diamond",Sn],["ellipse",kn]]:[];return ku("div",{ref:c,tabIndex:-1,style:{position:"absolute",top:`${a.y+(AP+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-PP}px`,zIndex:2},className:wP.CONVERT_ELEMENT_TYPE_POPUP,children:d.map(([m,p])=>{let u=i&&(t==="generic"&&r[0].type===m||t==="linear"&&di(n[0])===m);return ku(W,{className:"Shape",type:"radio",icon:p,checked:u,name:"convertElementType-option",title:m,keyBindingLabel:"","aria-label":m,"data-testid":`toolbar-${m}`,onChange:()=>{e.state.activeTool.type!==m&&re("convertElementType",m,"ui"),Lu(e,{conversionType:t,nextType:m}),c.current?.focus()}},`${o[0].id}${o[0].version}_${m}`)})})},BP=(e,o,t)=>{let r=bP(e,o),n=fP(e,o),i=EP(o.text,wu(o),r),a=ey(i,wu(o),o.lineHeight),l=o.fontSize;for(;(a.width>r||a.height>n)&&l>0;){l-=1;let s={...o,fontSize:l};a=ey(o.text,wu(s),o.lineHeight)}pc(o,t.getNonDeletedElementsMap(),{fontSize:l,width:a.width,height:a.height}),xP(o,e,t)},Lu=(e,{conversionType:o,nextType:t,direction:r="right"})=>{if(!o)return!1;let n=e.scene.getSelectedElements(e.state),i=n.reduce((l,s)=>({...l,[s.id]:!0}),{}),a=r==="right"?1:-1;if(o==="generic"){let l=iy(n),c=l.every(d=>d.type===l[0].type)?Fa.indexOf(l[0].type):-1;if(t=t??Fa[(c+Fa.length+a)%Fa.length],t&&mi(t)){let d={};for(let p of l){let u=oy(p,t,e);d[u.id]=u}let m=[];for(let p of e.scene.getElementsIncludingDeleted())d[p.id]?m.push(d[p.id]):m.push(p);e.scene.replaceAllElements(m);for(let p of Object.values(d)){let u=ry(p,e.scene.getNonDeletedElementsMap());u&&(Ha.get(p.id)&&pc(u,e.scene.getNonDeletedElementsMap(),{fontSize:Ha.get(p.id)?.fontSize??u.fontSize}),BP(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:QE(p,{type:"selection"})}))}}if(o==="linear"){let l=Su(n);if(!t){let c=IP(l,di),d=c?Oa.indexOf(c):-1;t=Oa[(d+Oa.length+a)%Oa.length]}if(mc(t)){let c=[],d=e.scene.getElementsMapIncludingDeleted();for(let m of l){let p=Ga.get(Cu(m.id,t));if(p&&di(p)===t)d.set(p.id,p),c.push(p);else{let u=oy(m,t,e);d.set(u.id,u),c.push(u)}}e.scene.replaceAllElements(d);for(let m of c)if(Mu(m))if(pP(m)){let p=FP(m);if(p.length<2)continue;let u=[];for(let b=1;b<p.length-2;b++)u.push({start:p[b],end:p[b+1],index:b+1});let f=lP(m,e.scene.getNonDeletedElementsMap(),{points:p,fixedSegments:u});pc(m,e.scene.getNonDeletedElementsMap(),{...f,endArrowhead:"arrow"})}else{let p=TP(["line","sharpArrow","curvedArrow"],u=>Ga.get(Cu(m.id,u)));if(p){let u=p.points;e.scene.mutateElement(m,{points:u})}}}let s=Su(e.scene.getSelectedElements(e.state));e.setState(c=>({selectedElementIds:i,selectedLinearElement:s.length===1?new CP(s[0],e.scene.getNonDeletedElementsMap()):null,activeTool:QE(c,{type:"selection"})}))}return!0},pi=e=>{if(e.length===0)return null;let o=!1;for(let t of e){if(mi(t.type))return"generic";ny(t)&&(o=!0)}return o?"linear":null},ny=e=>Mu(e)&&(!mP(e)||!dP(e)&&!cP(e)),Cu=(e,o)=>`${e}:${o}`,iy=e=>e.filter(o=>mi(o.type)),Su=e=>e.filter(o=>ny(o)),sc=20,si=(e,o)=>e[0]===o[0],Tu=(e,o)=>e[1]===o[1],ty=(e,o)=>si(e,o)?Math.abs(e[1]-o[1]):Math.abs(e[0]-o[0]),FP=e=>{let o=[e.points[0]],t=OP(e.points);for(let i=1;i<t.length;++i){let a=o[o.length-1],l=[...t[i]];Math.abs(l[0]-a[0])<sc?l[0]=a[0]:Math.abs(l[1]-a[1])<sc&&(l[1]=a[1]),si(a,l)||Tu(a,l)||o.push(cc(a[0],l[1])),o.push(l)}let r=[o[0]];for(let i=1;i<o.length-1;++i)si(o[i-1],o[i])&&si(o[i],o[i+1])||Tu(o[i-1],o[i])&&Tu(o[i],o[i+1])||r.push(o[i]);r.push(o[o.length-1]);let n=[r[0]];for(let i=1;i<r.length-1;++i){let a=n[n.length-1],l=r[i],s=r[i+1],c=si(a,l),d=si(l,s);if(c!==d){let m=ty(a,l),p=ty(l,s);if(m<sc||p<sc){if(p<m)c?s[0]=a[0]:s[1]=a[1];else if(d)for(let u=n.length-1;u>=0&&n[u][0]===a[0];--u)n[u][0]=l[0];else for(let u=n.length-1;u>=0&&n[u][1]===a[1];--u)n[u][1]=l[1];continue}}n.push(l)}return n.push(r[r.length-1]),n},OP=e=>{if(e.length===0)return[];let o=[e[0]];for(let t=1;t<e.length;t++){let[r,n]=o[o.length-1],[i,a]=e[t];(r!==i||n!==a)&&o.push(e[t])}return o},oy=(e,o,t)=>{if(!zP(e.type,o)){if(!vP())throw Error(`Invalid conversion from ${e.type} to ${o}.`);return e}if(e.type===o)return e;if(MP.delete(e),mi(o)){let r=ci(SP({...e,type:o,roundness:o==="diamond"&&e.roundness?{type:uP(o)?dc.ADAPTIVE_RADIUS:dc.PROPORTIONAL_RADIUS}:e.roundness}));return LP(r,t.scene),r}if(mc(o))switch(o){case"line":return ci(kP({...e,type:"line"}));case"sharpArrow":return ci(vu({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return ci(vu({...e,type:"arrow",elbowed:!1,roundness:{type:dc.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return ci(vu({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return yP(o,`unhandled conversion type: ${o}`),e},zP=(e,o)=>!!(mi(e)&&mi(o)||mc(e)&&mc(o)),HP=e=>Mu(e)?di(e):e.type,ay=RP;var sy=N({name:"toggleShapeSwitch",label:"labels.shapeSwitch",icon:()=>null,viewMode:!0,trackEvent:{category:"shape_switch",action:"toggle"},keywords:["change","switch","swap"],perform(e,o,t,r){return Ke.set(no,{type:"panel"}),{captureUpdate:GP.NEVER}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>pi(e)!==null});import{canCreateLinkFromElements as Pu,defaultGetElementLinkFromSelection as UP,getLinkIdAndTypeFromSelection as YP}from"@excalidraw/element";import{CaptureUpdateAction as Ua}from"@excalidraw/element";var uc=N({name:"copyElementLink",label:"labels.copyElementLink",icon:Dn,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n=$(e,o);try{if(window.location){let i=YP(n,o);return i?(await oo(r.props.generateLinkForSelection?r.props.generateLinkForSelection(i.id,i.type):UP(i.id,i.type)),{appState:{toast:{message:g("toast.elementLinkCopied"),closable:!0}},captureUpdate:Ua.EVENTUALLY}):{appState:o,elements:e,app:r,captureUpdate:Ua.EVENTUALLY}}}catch(i){console.error(i)}return{appState:o,elements:e,app:r,captureUpdate:Ua.EVENTUALLY}},predicate:(e,o)=>Pu($(e,o))}),cy=N({name:"linkToElement",label:"labels.linkToElement",icon:as,perform:(e,o,t,r)=>{let n=$(e,o);return n.length!==1||!Pu(n)?{elements:e,appState:o,app:r,captureUpdate:Ua.EVENTUALLY}:{appState:{...o,openDialog:{name:"elementLinkSelector",sourceElementId:$(e,o)[0].id}},captureUpdate:Ua.IMMEDIATELY}},predicate:(e,o,t,r)=>{let n=$(e,o);return o.openDialog?.name!=="elementLinkSelector"&&n.length===1&&Pu(n)},trackEvent:!1});import{isDarwin as dy,getShortcutKey as oe}from"@excalidraw/common";var WP={toggleTheme:[oe("Shift+Alt+D")],saveScene:[oe("CtrlOrCmd+S")],loadScene:[oe("CtrlOrCmd+O")],imageExport:[oe("CtrlOrCmd+Shift+E")],commandPalette:[oe("CtrlOrCmd+/"),oe("CtrlOrCmd+Shift+P")],cut:[oe("CtrlOrCmd+X")],copy:[oe("CtrlOrCmd+C")],paste:[oe("CtrlOrCmd+V")],copyStyles:[oe("CtrlOrCmd+Alt+C")],pasteStyles:[oe("CtrlOrCmd+Alt+V")],selectAll:[oe("CtrlOrCmd+A")],deleteSelectedElements:[oe("Delete")],duplicateSelection:[oe("CtrlOrCmd+D"),oe(`Alt+${g("helpDialog.drag")}`)],sendBackward:[oe("CtrlOrCmd+[")],bringForward:[oe("CtrlOrCmd+]")],sendToBack:[dy?oe("CtrlOrCmd+Alt+["):oe("CtrlOrCmd+Shift+[")],bringToFront:[dy?oe("CtrlOrCmd+Alt+]"):oe("CtrlOrCmd+Shift+]")],copyAsPng:[oe("Shift+Alt+C")],group:[oe("CtrlOrCmd+G")],ungroup:[oe("CtrlOrCmd+Shift+G")],gridMode:[oe("CtrlOrCmd+'")],zenMode:[oe("Alt+Z")],objectsSnapMode:[oe("Alt+S")],stats:[oe("Alt+/")],addToLibrary:[],flipHorizontal:[oe("Shift+H")],flipVertical:[oe("Shift+V")],viewMode:[oe("Alt+R")],hyperlink:[oe("CtrlOrCmd+K")],toggleElementLock:[oe("CtrlOrCmd+Shift+L")],resetZoom:[oe("CtrlOrCmd+0")],zoomOut:[oe("CtrlOrCmd+-")],zoomIn:[oe("CtrlOrCmd++")],zoomToFitSelection:[oe("Shift+3")],zoomToFit:[oe("Shift+1")],zoomToFitSelectionInViewport:[oe("Shift+2")],toggleEraserTool:[oe("E")],toggleHandTool:[oe("H")],setFrameAsActiveTool:[oe("F")],saveFileToDisk:[oe("CtrlOrCmd+S")],saveToActiveFile:[oe("CtrlOrCmd+S")],toggleShortcuts:[oe("?")],searchMenu:[oe("CtrlOrCmd+F")],wrapSelectionInFrame:[],arrangeElements:[oe("Shift+R")]},Se=(e,o=0)=>{let t=WP[e];return t&&t.length>0?t[o]||t[0]:""};var VP="\\u0300-\\u036f",XP="\\ufe20-\\ufe2f",KP="\\u20d0-\\u20ff",ZP=VP+XP+KP,$P=`[${ZP}]`,jP=RegExp($P,"g"),qP=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,JP={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"E",\u00E6:"e",\u00DE:"T",\u00FE:"t",\u00DF:"s",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"I",\u0133:"i",\u0152:"E",\u0153:"e",\u0149:"n",\u017F:"s"},Au=e=>e.replace(qP,o=>JP[o]||o).replace(jP,"");import G8 from"clsx";import{useEffect as U8,useState as Y8}from"react";import{KEYS as W8,queryFocusableElements as c2}from"@excalidraw/common";import{useCallback as QP,useState as eA}from"react";var my=()=>{let[e,o]=eA(null),t=QP(r=>o(r),[]);return[e,t]};import{useState as r2,useCallback as Ku,useMemo as n2,useEffect as e2,memo as i2,useRef as P8}from"react";import{LIBRARY_DISABLED_TYPES as A8,randomId as D8,isShallowEqual as _8}from"@excalidraw/common";import{useEffect as gy,useRef as fy}from"react";import{URL_HASH_KEYS as Ru,URL_QUERY_KEYS as Nu,APP_NAME as by,EVENT as gc,DEFAULT_SIDEBAR as iA,LIBRARY_SIDEBAR_TAB as aA,arrayToMap as Bu,cloneJSON as lA,preventUnload as sA,promiseTry as xy,resolvablePromise as cA,toValidURL as dA,Queue as mA,Emitter as pA}from"@excalidraw/common";import{hashElementsVersion as uA,hashString as hA}from"@excalidraw/element";import{getCommonBoundingBox as _u}from"@excalidraw/element";import{MIME_TYPES as Jr}from"@excalidraw/common";var cr=({elements:e,appState:o,files:t,maxWidthOrHeight:r,getDimensions:n,exportPadding:i,exportingFrame:a})=>{let{elements:l,appState:s}=yn({elements:e,appState:o},null,null),{exportBackground:c,viewBackgroundColor:d}=s;return zl(l,{...s,offsetTop:0,offsetLeft:0,width:0,height:0},t||{},{exportBackground:c,exportPadding:i,viewBackgroundColor:d,exportingFrame:a},(m,p)=>{let u=document.createElement("canvas");if(r){typeof n=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let b=Math.max(m,p),x=r<b?r/b:o?.exportScale??1;return u.width=m*x,u.height=p*x,{canvas:u,scale:x}}let f=n?.(m,p)||{width:m,height:p};return u.width=f.width,u.height=f.height,{canvas:u,scale:f.scale??1}})},py=async e=>{let{mimeType:o=Jr.png,quality:t}=e;o===Jr.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${Jr.png}" mimeType`),o==="image/jpg"&&(o=Jr.jpg),o===Jr.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${Jr.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let r=await cr(e);return t=t||(/image\/jpe?g/.test(o)?.92:.8),new Promise((n,i)=>{r.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&o===Jr.png&&e.appState?.exportEmbedScene&&(a=await c1({blob:a,metadata:ji(e.elements,e.appState,e.files||{},"local")})),n(a)},o,t)})},ui=async({elements:e,appState:o=bn(),files:t={},exportPadding:r,renderEmbeddables:n,exportingFrame:i,skipInliningFonts:a,reuseImages:l})=>{let{elements:s,appState:c}=yn({elements:e,appState:o},null,null),d={...c,exportPadding:r};return En(s,d,t,{exportingFrame:i,renderEmbeddables:n,skipInliningFonts:a,reuseImages:l})},tA=async e=>{if(e.type==="svg"){let o=await ui(e);await oo(o.outerHTML)}else if(e.type==="png")await Ws(py(e));else if(e.type==="json")await Us(e.elements,e.files);else throw new Error("Invalid export type")};import{useEffect as oA,useState as rA}from"react";import{COLOR_PALETTE as nA}from"@excalidraw/common";var Du=he(new Map),uy=async e=>await ui({elements:e,appState:{exportBackground:!1,viewBackgroundColor:nA.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),hy=(e,o,t)=>{let[r,n]=rA();return oA(()=>{if(o)if(e){let i=t.get(e);i?n(i):(async()=>{let a=await uy(o);a.querySelector(".style-fonts")?.remove(),a&&(t.set(e,a),n(a))})()}else(async()=>{let i=await uy(o);n(i)})()},[e,o,t,n]),r},hc=()=>{let[e]=se(Du);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:r=>{r.forEach(n=>e.delete(n))},svgCache:e}};var gA=["excalidraw.com","raw.githubusercontent.com/excalidraw/excalidraw-libraries"],yy=new pA,Qr=he({status:"loaded",isInitialized:!1,libraryItems:[]}),Ya=e=>lA(e),fA=(e,o)=>!e.find(t=>t.elements.length!==o.elements.length?!1:t.elements.every((r,n)=>r.id===o.elements[n].id&&r.versionNonce===o.elements[n].versionNonce)),wy=(e,o)=>{let t=[];for(let r of o)fA(e,r)&&t.push(r);return[...t,...e]},vy=(e,o)=>{let t=Bu(o),r={deletedItems:new Map,addedItems:new Map};for(let i of e)t.has(i.id)||r.deletedItems.set(i.id,i);let n=Bu(e);for(let i of o)n.has(i.id)||r.addedItems.set(i.id,i);return r},Fu=class{constructor(o){I(this,"currLibraryItems",[]);I(this,"prevLibraryItems",Ya(this.currLibraryItems));I(this,"app");I(this,"updateQueue",[]);I(this,"getLastUpdateTask",()=>this.updateQueue[this.updateQueue.length-1]);I(this,"notifyListeners",()=>{if(this.updateQueue.length>0)Ke.set(Qr,o=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:o.isInitialized}));else{Ke.set(Qr,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let o=this.prevLibraryItems;this.prevLibraryItems=Ya(this.currLibraryItems);let t=Ya(this.currLibraryItems);this.app.props.onLibraryChange?.(t),yy.trigger(vy(o,t),t)}catch(o){console.error(o)}}});I(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],Ke.set(Du,new Map)});I(this,"resetLibrary",()=>this.setLibrary([]));I(this,"getLatestLibrary",()=>new Promise(async o=>{try{let t=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?o(this.getLatestLibrary()):o(Ya(t))}catch{return o(this.currLibraryItems)}}));I(this,"updateLibrary",async({libraryItems:o,prompt:t=!1,merge:r=!1,openLibraryMenu:n=!1,defaultStatus:i="unpublished"})=>(n&&this.app.setState({openSidebar:{name:iA.name,tab:aA}}),this.setLibrary(()=>new Promise(async(a,l)=>{try{let s=await(typeof o=="function"&&!(o instanceof Blob)?o(this.currLibraryItems):o),c;s instanceof Blob?c=await fm(s,i):c=Qi(s,i),!t||window.confirm(g("alerts.confirmAddLibrary",{numShapes:c.length}))?(t&&this.app.focusContainer(),a(r?wy(this.currLibraryItems,c):c)):l(new fn)}catch(s){l(s)}}))));I(this,"setLibrary",o=>{let t=new Promise(async(r,n)=>{try{await this.getLastUpdateTask(),typeof o=="function"&&(o=o(this.currLibraryItems)),this.currLibraryItems=Ya(await o),r(this.currLibraryItems)}catch(i){n(i)}}).catch(r=>{if(r.name==="AbortError")return console.warn("Library update aborted by user"),this.currLibraryItems;throw r}).finally(()=>{this.updateQueue=this.updateQueue.filter(r=>r!==t),this.notifyListeners()});return this.updateQueue.push(t),this.notifyListeners(),t});this.app=o}},Ty=Fu,xc=e=>{let t=Math.ceil(Math.sqrt(e.length)),r=[],n=u=>e.slice(u*t,u*t+t).reduce((b,x)=>{let{height:w}=_u(x.elements);return Math.max(b,w)},0),i=u=>{let f=0,b=0,x=0;for(let w of e){if(f%t===0&&(b=0),b===u){let{width:E}=_u(w.elements);x=Math.max(x,E)}f++,b++}return x},a=0,l=0,s=0,c=0,d=0,m=0,p=0;for(let u of e){d&&d%t===0&&(l+=s+50,a=0,m=0,p++),m===0&&(s=n(p)),c=i(m);let{minX:f,minY:b,width:x,height:w}=_u(u.elements),E=(c-x)/2,y=(s-w)/2;r.push(...u.elements.map(v=>({...v,x:v.x+a+E-f,y:v.y+l+y-b}))),a+=c+50,d++,m++}return r},bA=(e,o=gA)=>{if(typeof o=="function"?o(e):o.some(t=>{let r=new URL(`https://${t.replace(/^https?:\/\//,"")}`),{hostname:n,pathname:i}=new URL(e);return new RegExp(`(^|\\.)${r.hostname}$`).test(n)&&new RegExp(`^${r.pathname.replace(/\/+$/,"")}(/+|$)`).test(i)}))return!0;throw new Error(`Invalid or disallowed library URL: "${e}"`)},Ou=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(Ru.addLibrary)||new URLSearchParams(window.location.search).get(Nu.addLibrary),o=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:o}:null},dr=class dr{constructor(o){I(this,"adapter");this.adapter=o}static async getLibraryItems(o,t,r=!0){let n=()=>new Promise(async(i,a)=>{try{let l=await o.load({source:t});i(Qi(l?.libraryItems||[],"published"))}catch(l){a(l)}});return r?dr.queue.push(n):n()}getLibraryItems(o){return dr.getLibraryItems(this.adapter,o,!1)}};I(dr,"queue",new mA),I(dr,"run",async(o,t)=>{let r=new dr(o);return dr.queue.push(()=>t(r))});var hi=dr,Wa=0,fc=0,bc=e=>hA(e.map(o=>`${o.id}:${uA(o.elements)}`).sort().join()),Ey=async(e,o)=>{try{return fc++,await hi.run(e,async t=>{let r=Bu(await t.getLibraryItems("save"));for(let[l]of o.deletedItems)r.delete(l);let n=[];for(let[l,s]of o.addedItems)r.has(l)?r.set(l,s):n.push(s);let i=n.concat(Array.from(r.values())),a=bc(i);return a!==Wa&&await e.save({libraryItems:i}),Wa=a,i})}finally{fc--}},xA=e=>{let{excalidrawAPI:o}=e,t=fy(e);t.current=e;let r=fy(!1);gy(()=>{if(!o)return;r.current=!1;let n=async({libraryUrl:l,idToken:s})=>{let c=new Promise(async(m,p)=>{try{l=decodeURIComponent(l),l=dA(l),bA(l,t.current.validateLibraryUrl);let f=await(await fetch(l)).blob();m(f)}catch(u){p(u)}}),d=s!==o.id;await(d&&document.hidden?new Promise(m=>{window.addEventListener("focus",()=>m(),{once:!0})}):null);try{await o.updateLibrary({libraryItems:c,prompt:d,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(m){throw o.updateScene({appState:{errorMessage:m.message}}),m}finally{if(window.location.hash.includes(Ru.addLibrary)){let m=new URLSearchParams(window.location.hash.slice(1));m.delete(Ru.addLibrary),window.history.replaceState({},by,`#${m.toString()}`)}else if(window.location.search.includes(Nu.addLibrary)){let m=new URLSearchParams(window.location.search);m.delete(Nu.addLibrary),window.history.replaceState({},by,`?${m.toString()}`)}}},i=l=>{l.preventDefault();let s=Ou();s&&(l.stopImmediatePropagation(),window.history.replaceState({},"",l.oldURL),n(s))},a=Ou();if(a&&n(a),"getInitialLibraryItems"in t.current&&t.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(t.current.getInitialLibraryItems()).then(l=>{o.updateLibrary({libraryItems:l,merge:!0})}).catch(l=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${l?.message}`)})),"adapter"in t.current&&t.current.adapter){let l=t.current.adapter,s=t.current.migrationAdapter,c=cA();s?c.resolve(xy(s.load).then(async d=>{let m=null;try{if(!d)return hi.getLibraryItems(l,"load");m=Qi(d.libraryItems||[],"published");let p=await Ey(l,vy([],m));try{await s.clear()}catch(u){console.error(`couldn't delete legacy library data: ${u.message}`)}return p}catch(p){return console.error(`couldn't migrate legacy library data: ${p.message}`),m}}).catch(d=>(console.error(`error during library migration: ${d.message}`),hi.getLibraryItems(l,"load")))):c.resolve(xy(hi.getLibraryItems,l,"load")),o.updateLibrary({libraryItems:c.then(d=>{let m=d||[];return Wa=bc(m),m}),merge:!0}).finally(()=>{r.current=!0})}return window.addEventListener(gc.HASHCHANGE,i),()=>{window.removeEventListener(gc.HASHCHANGE,i)}},[o]),gy(()=>{let n=yy.on(async(a,l)=>{let s=r.current,c="adapter"in t.current&&t.current.adapter||null;try{c&&Wa!==bc(l)&&await Ey(c,a)}catch(d){console.error(`couldn't persist library update: ${d.message}`,a),s&&t.current.excalidrawAPI&&t.current.excalidrawAPI.updateScene({appState:{errorMessage:g("errors.saveLibraryError")}})}}),i=a=>{fc&&sA(a)};return window.addEventListener(gc.BEFORE_UNLOAD,i),()=>{window.removeEventListener(gc.BEFORE_UNLOAD,i),n(),Wa=0,fc=0}},[])};import vA from"clsx";import{VERSIONS as EA}from"@excalidraw/common";import{jsx as wA}from"react/jsx-runtime";var yA=({theme:e,id:o,libraryReturnUrl:t})=>{let r=t||window.location.origin+window.location.pathname;return wA("a",{className:"library-menu-browse-button",href:`${T.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${r}&useHash=true&token=${o}&theme=${e}&version=${EA.excalidrawLibrary}`,target:"_excalidraw_libraries",children:g("labels.libraries")})},Iy=yA;import{jsx as TA,jsxs as IA}from"react/jsx-runtime";var Ec=({libraryReturnUrl:e,theme:o,id:t,style:r,children:n,className:i})=>IA("div",{className:vA("library-menu-control-buttons",i),style:r,children:[TA(Iy,{id:t,libraryReturnUrl:e,theme:o}),n]});import{useCallback as bi,useEffect as v8,useMemo as Jy,useRef as T8,useState as I8}from"react";import{MIME_TYPES as C8,arrayToMap as S8}from"@excalidraw/common";import{duplicateElements as k8}from"@excalidraw/element";import CA from"lodash.throttle";import{useEffect as SA}from"react";var kA=he(0),Cy=e=>{let[o,t]=se(kA);return SA(()=>{let{current:r}=e;if(!r)return;let n=CA(()=>{let{scrollTop:i}=r;t(i)},200);return r.addEventListener("scroll",n),()=>{n.cancel(),r.removeEventListener("scroll",n)}},[e,t]),o};import i8 from"clsx";import{useCallback as a8,useState as Uu}from"react";import{muteFSAbortError as l8}from"@excalidraw/common";import{flushSync as Sy}from"react-dom";import MA from"clsx";import{jsx as yc,jsxs as PA}from"react/jsx-runtime";var LA=({label:e,onClick:o,className:t,children:r,actionType:n,type:i="button",isLoading:a,...l})=>{let s=n?`Dialog__action-button--${n}`:"";return PA("button",{className:MA("Dialog__action-button",s,t),type:i,"aria-label":e,onClick:o,...l,children:[r&&yc("div",{style:a?{visibility:"hidden"}:{},children:r}),yc("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&yc("div",{style:{position:"absolute",inset:0},children:yc(tt,{})})]})},Oo=LA;import{jsx as ky,jsxs as My}from"react/jsx-runtime";var AA=e=>{let{onConfirm:o,onCancel:t,children:r,confirmText:n=g("buttons.confirm"),cancelText:i=g("buttons.cancel"),className:a="",...l}=e,s=le(),c=wn(gi),{container:d}=ze();return My(Ne,{onCloseRequest:t,size:"small",...l,className:`confirm-dialog ${a}`,children:[r,My("div",{className:"confirm-dialog-buttons",children:[ky(Oo,{label:i,onClick:()=>{s({openMenu:null}),c(!1),Sy(()=>{t()}),d?.focus()}}),ky(Oo,{label:n,onClick:()=>{s({openMenu:null}),c(!1),Sy(()=>{o()}),d?.focus()},actionType:"danger"})]})]})},Ly=AA;import vc from"open-color";import{useCallback as OA,useEffect as Gu,useRef as Py,useState as zu}from"react";import{EDITOR_LS_KEYS as Hu,EXPORT_DATA_TYPES as zA,MIME_TYPES as Ay,VERSIONS as HA,chunk as GA,getExportSource as UA}from"@excalidraw/common";var Ut=class{static has(o){try{return!!window.localStorage.getItem(o)}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),!1}}static get(o){try{let t=window.localStorage.getItem(o);return t?JSON.parse(t):null}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),null}}};I(Ut,"set",(o,t)=>{try{return window.localStorage.setItem(o,JSON.stringify(t)),!0}catch(r){return console.warn(`localStorage.setItem error: ${r.message}`),!1}}),I(Ut,"delete",o=>{try{window.localStorage.removeItem(o)}catch(t){console.warn(`localStorage.removeItem error: ${t.message}`)}});import wc from"react";var DA=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,_A=/{{([\w-]+)}}/,RA=/<([\w-]+)>/,NA=/<\/([\w-]+)>/,BA=(e,o)=>{let t=[{name:"",children:[]}];return e.split(DA).filter(Boolean).forEach(r=>{let n=r.match(RA),i=r.match(NA),a=r.match(_A);if(n!==null){let l=n[1];o.hasOwnProperty(l)?t.push({name:l,children:[]}):console.warn(`Trans: missed to pass in prop ${l} for interpolating ${e}`)}else if(i!==null)if(i[1]===t[t.length-1].name){let s=t.pop(),c=wc.createElement(wc.Fragment,{},...s.children),d=o[s.name];typeof d=="function"&&t[t.length-1].children.push(d(c))}else console.warn(`Trans: unexpected end tag ${r} for interpolating ${e}`);else if(a!==null){let l=a[1];o.hasOwnProperty(l)?t[t.length-1].children.push(o[l]):console.warn(`Trans: key ${l} not in props for interpolating ${e}`)}else t[t.length-1].children.push(r)}),t.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),t[0].children},FA=({i18nKey:e,children:o,...t})=>{let{t:r}=Oe();return wc.createElement(wc.Fragment,{},...BA(r(e),t))},ut=FA;import{jsx as ie,jsxs as lt}from"react/jsx-runtime";var YA=async e=>{let r=Math.round(8),n=Math.max(Math.round(128/64),2),i=GA(e,6),a=document.createElement("canvas");a.width=i[0].length*128+(i[0].length+1)*(r*2)-r*2,a.height=i.length*128+(i.length+1)*(r*2)-r*2;let l=a.getContext("2d");l.fillStyle=vc.white,l.fillRect(0,0,a.width,a.height);for(let[s,c]of e.entries()){let d=await cr({elements:c.elements,files:null,maxWidthOrHeight:128}),{width:m,height:p}=d,u=Math.floor(s/6)*(128+r*2),f=s%6*(128+r*2);l.drawImage(d,f+(128-m)/2+r,u+(128-p)/2+r),l.lineWidth=n,l.strokeStyle=vc.gray[4],l.strokeRect(f+r/2,u+r/2,128+r,128+r)}return await Ul(new File([await Lo(a)],"preview",{type:Ay.png}),{outputType:Ay.jpg,maxWidthOrHeight:5e3})},WA=({libItem:e,appState:o,index:t,onChange:r,onRemove:n})=>{let i=Py(null),a=Py(null);return Gu(()=>{let l=i.current;l&&(async()=>{let s=await ui({elements:e.elements,appState:{...o,viewBackgroundColor:vc.white,exportBackground:!0},files:null,skipInliningFonts:!0});l.innerHTML=s.outerHTML})()},[e.elements,o]),lt("div",{className:"single-library-item",children:[e.status==="published"&&ie("span",{className:"single-library-item-status",children:g("labels.statusPublished")}),ie("div",{ref:i,className:"single-library-item__svg"}),ie(W,{"aria-label":g("buttons.remove"),type:"button",icon:Ft,className:"single-library-item--remove",onClick:n.bind(null,e.id),title:g("buttons.remove")}),lt("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[lt("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[lt("div",{style:{padding:"0.5em 0"},children:[ie("span",{style:{fontWeight:500,color:vc.gray[6]},children:g("publishDialog.itemName")}),ie("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ie("input",{type:"text",ref:a,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:l=>{r(l.target.value,t)}})]}),ie("span",{className:"error",children:e.error})]})]})},VA=({onClose:e,libraryItems:o,appState:t,onSuccess:r,onError:n,updateItemsInStorage:i,onRemove:a})=>{let[l,s]=zu({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[c,d]=zu(!1);Gu(()=>{let y=Ut.get(Hu.PUBLISH_LIBRARY);y&&s(y)},[]);let[m,p]=zu(o.slice());Gu(()=>{p(o.slice())},[o]);let u=y=>{s({...l,[y.target.name]:y.target.value})},f=async y=>{y.preventDefault(),d(!0);let v=[],C=!1;if(m.forEach(B=>{let O="";B.name||(O=g("publishDialog.errors.required"),C=!0),v.push({...B,error:O})}),C){p(v),d(!1);return}let S=await YA(m),L={type:zA.excalidrawLibrary,version:HA.excalidrawLibrary,source:UA(),libraryItems:m},k=JSON.stringify(L,null,2),A=new Blob([k],{type:"application/json"}),P=new FormData;P.append("excalidrawLib",A),P.append("previewImage",S),P.append("previewImageType",S.type),P.append("title",l.name),P.append("authorName",l.authorName),P.append("githubHandle",l.githubHandle),P.append("name",l.name),P.append("description",l.description),P.append("twitterHandle",l.twitterHandle),P.append("website",l.website),fetch(`${T.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:P}).then(B=>B.ok?B.json().then(({url:O})=>{Ut.delete(Hu.PUBLISH_LIBRARY),r({url:O,authorName:l.authorName,items:m})}):B.json().catch(()=>{throw new Error(B.statusText||"something went wrong")}).then(O=>{throw new Error(O.message||B.statusText||"something went wrong")}),B=>{console.error(B),n(B),d(!1)}).catch(B=>{console.error(B),n(B),d(!1)})},b=()=>{let y=[];return m.forEach((v,C)=>{y.push(ie("div",{className:"single-library-item-wrapper",children:ie(WA,{libItem:v,appState:t,index:C,onChange:(S,L)=>{let k=m.slice();k[L].name=S,p(k)},onRemove:a})},C))}),ie("div",{className:"selected-library-items",children:y})},x=OA(()=>{i(m),Ut.set(Hu.PUBLISH_LIBRARY,l),e()},[m,e,i,l]),w=!!o.length,E=o.some(y=>y.status==="published");return ie(Ne,{onCloseRequest:x,title:g("publishDialog.title"),className:"publish-library",children:w?lt("form",{onSubmit:f,children:[ie("div",{className:"publish-library-note",children:ie(ut,{i18nKey:"publishDialog.noteDescription",link:y=>ie("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener",children:y})})}),ie("span",{className:"publish-library-note",children:ie(ut,{i18nKey:"publishDialog.noteGuidelines",link:y=>ie("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:y})})}),ie("div",{className:"publish-library-note",children:g("publishDialog.noteItems")}),E&&ie("span",{className:"publish-library-note publish-library-warning",children:g("publishDialog.republishWarning")}),b(),lt("div",{className:"publish-library__fields",children:[lt("label",{children:[lt("div",{children:[ie("span",{children:g("publishDialog.libraryName")}),ie("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ie("input",{type:"text",name:"name",required:!0,value:l.name,onChange:u,placeholder:g("publishDialog.placeholder.libraryName")})]}),lt("label",{style:{alignItems:"flex-start"},children:[lt("div",{children:[ie("span",{children:g("publishDialog.libraryDesc")}),ie("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ie("textarea",{name:"description",rows:4,required:!0,value:l.description,onChange:u,placeholder:g("publishDialog.placeholder.libraryDesc")})]}),lt("label",{children:[lt("div",{children:[ie("span",{children:g("publishDialog.authorName")}),ie("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ie("input",{type:"text",name:"authorName",required:!0,value:l.authorName,onChange:u,placeholder:g("publishDialog.placeholder.authorName")})]}),lt("label",{children:[ie("span",{children:g("publishDialog.githubUsername")}),ie("input",{type:"text",name:"githubHandle",value:l.githubHandle,onChange:u,placeholder:g("publishDialog.placeholder.githubHandle")})]}),lt("label",{children:[ie("span",{children:g("publishDialog.twitterUsername")}),ie("input",{type:"text",name:"twitterHandle",value:l.twitterHandle,onChange:u,placeholder:g("publishDialog.placeholder.twitterHandle")})]}),lt("label",{children:[ie("span",{children:g("publishDialog.website")}),ie("input",{type:"text",name:"website",pattern:"https?://.+",title:g("publishDialog.errors.website"),value:l.website,onChange:u,placeholder:g("publishDialog.placeholder.website")})]}),ie("span",{className:"publish-library-note",children:ie(ut,{i18nKey:"publishDialog.noteLicense",link:y=>ie("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:y})})})]}),lt("div",{className:"publish-library__buttons",children:[ie(Oo,{label:g("buttons.cancel"),onClick:x,"data-testid":"cancel-clear-canvas-button"}),ie(Oo,{type:"submit",label:g("buttons.submit"),actionType:"primary",isLoading:c})]})]}):ie("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:g("publishDialog.atleastOneLibItem")})})},Dy=VA;import ZA from"clsx";import{useEffect as $A,useRef as jA}from"react";import{EVENT as By,KEYS as qA}from"@excalidraw/common";import{forwardRef as _y}from"react";import Ry from"clsx";import{jsx as Ny}from"react/jsx-runtime";var XA=_y(({children:e,gap:o,align:t,justifyContent:r,className:n,style:i},a)=>Ny("div",{className:Ry("Stack Stack_horizontal",n),style:{"--gap":o,alignItems:t,justifyContent:r,...i},ref:a,children:e})),KA=_y(({children:e,gap:o,align:t,justifyContent:r,className:n,style:i},a)=>Ny("div",{className:Ry("Stack Stack_vertical",n),style:{"--gap":o,justifyItems:t,justifyContent:r,...i},ref:a,children:e})),Ze={Row:XA,Col:KA};import{jsx as Tc}from"react/jsx-runtime";var Fy=({children:e,onClickOutside:o,className:t="",onSelect:r,style:n})=>{let i=ce(),a=jA(null),l=qo({onClickOutside:o});zn(a,()=>{l.onClickOutside?.()}),$A(()=>{let c=m=>{m.key===qA.ESCAPE&&(m.stopImmediatePropagation(),l.onClickOutside?.())},d={capture:!0};return document.addEventListener(By.KEYDOWN,c,d),()=>{document.removeEventListener(By.KEYDOWN,c,d)}},[l]);let s=ZA(`dropdown-menu ${t}`,{"dropdown-menu--mobile":i.editor.isMobile}).trim();return Tc(up.Provider,{value:{onSelect:r},children:Tc("div",{ref:a,className:s,style:n,"data-testid":"dropdown-menu",children:i.editor.isMobile?Tc(Ze.Col,{className:"dropdown-menu-container",children:e}):Tc(We,{className:"dropdown-menu-container",padding:2,style:{zIndex:2},children:e})})})};Fy.displayName="DropdownMenuContent";var Oy=Fy;import{jsx as QA}from"react/jsx-runtime";var JA=({children:e,className:o="",selected:t,...r})=>QA("div",{...r,className:`dropdown-menu-item-base dropdown-menu-item-custom ${o} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),zy=JA;import{jsx as Hy}from"react/jsx-runtime";var Gy=({icon:e,shortcut:o,href:t,children:r,onSelect:n,className:i="",selected:a,rel:l="noopener",...s})=>{let c=Ss(s.onClick,n);return Hy("a",{...s,href:t,target:"_blank",rel:l||"noopener",className:Cs(i,a),title:s.title??s["aria-label"],onClick:c,children:Hy(Is,{icon:e,shortcut:o,children:r})})},fi=Gy;Gy.displayName="DropdownMenuItemLink";import{jsx as e8}from"react/jsx-runtime";var Uy=()=>e8("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0"}}),Yy=Uy;Uy.displayName="DropdownMenuSeparator";import t8 from"clsx";import{jsx as o8}from"react/jsx-runtime";var Wy=({className:e="",children:o,onToggle:t,title:r,...n})=>{let i=ce(),a=t8(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.editor.isMobile}).trim();return o8("button",{"data-prevent-outside-click":!0,className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:r,...n,children:o})},Vy=Wy;Wy.displayName="DropdownMenuTrigger";import Ic from"react";var Xy=e=>{let o=Ic.Children.toArray(e).find(t=>Ic.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuTrigger");return o||null},Ky=e=>{let o=Ic.Children.toArray(e).find(t=>Ic.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuContent");return o||null};import{Fragment as r8,jsxs as n8}from"react/jsx-runtime";var zo=({children:e,open:o})=>{let t=Xy(e),r=Ky(e);return n8(r8,{children:[t,o&&r]})};zo.Trigger=Vy;zo.Content=Oy;zo.Item=yt;zo.ItemLink=fi;zo.ItemCustom=zy;zo.Group=fa;zo.Separator=Yy;var ye=zo;zo.displayName="DropdownMenu";import{jsx as Ct,jsxs as Cc}from"react/jsx-runtime";var s8=(e,o)=>e.filter(t=>o.includes(t.id)),c8=({setAppState:e,selectedItems:o,library:t,onRemoveFromLibrary:r,resetLibrary:n,onSelectItems:i,appState:a,className:l})=>{let[s]=se(Qr),[c,d]=se(gi),m=()=>{let P=o.length?g("alerts.removeItemsFromsLibrary",{count:o.length}):g("alerts.resetLibrary"),B=o.length?g("confirmDialog.removeItemsFromLib"):g("confirmDialog.resetLibrary");return Ct(Ly,{onConfirm:()=>{o.length?r():n(),u(!1)},onCancel:()=>{u(!1)},title:B,children:Ct("p",{children:P})})},[p,u]=Uu(!1),f=!!o.length,b=f?s.libraryItems.filter(P=>o.includes(P.id)):s.libraryItems,x=f?g("buttons.remove"):g("buttons.resetLibrary"),[w,E]=Uu(!1),[y,v]=Uu(null),C=a8(()=>Cc(Ne,{onCloseRequest:()=>v(null),title:g("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[Ct("p",{children:Ct(ut,{i18nKey:"publishSuccessDialog.content",authorName:y.authorName,link:P=>Ct("a",{href:y?.url,target:"_blank",rel:"noopener noreferrer",children:P})})}),Ct(W,{type:"button",title:g("buttons.close"),"aria-label":g("buttons.close"),label:g("buttons.close"),onClick:()=>v(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[v,y]),S=(P,B)=>{E(!1),v({url:P.url,authorName:P.authorName});let O=B.slice();O.forEach(G=>{o.includes(G.id)&&(G.status="published")}),t.setLibrary(O)},L=async()=>{try{await t.updateLibrary({libraryItems:Rl({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(P){if(P?.name==="AbortError"){console.warn(P);return}e({errorMessage:g("errors.importLibraryError")})}},k=async()=>{let P=f?b:await t.getLatestLibrary();Qf(P).catch(l8).catch(B=>{e({errorMessage:B.message})})},A=()=>Cc(ye,{open:c,children:[Ct(ye.Trigger,{onToggle:()=>d(!c),children:k1}),Cc(ye.Content,{onClickOutside:()=>d(!1),onSelect:()=>d(!1),className:"library-menu",children:[!f&&Ct(ye.Item,{onSelect:L,icon:An,"data-testid":"lib-dropdown--load",children:g("buttons.load")}),!!b.length&&Ct(ye.Item,{onSelect:k,icon:zr,"data-testid":"lib-dropdown--export",children:g("buttons.export")}),!!b.length&&Ct(ye.Item,{onSelect:()=>u(!0),icon:Do,children:x}),f&&Ct(ye.Item,{icon:O0,onSelect:()=>E(!0),"data-testid":"lib-dropdown--remove",children:g("buttons.publishLibrary")})]})]});return Cc("div",{className:i8("library-menu-dropdown-container",l),children:[A(),o.length>0&&Ct("div",{className:"library-actions-counter",children:o.length}),p&&m(),w&&Ct(Dy,{onClose:()=>E(!1),libraryItems:s8(s.libraryItems,o),appState:a,onSuccess:P=>S(P,s.libraryItems),onError:P=>window.alert(P),updateItemsInStorage:()=>t.setLibrary(s.libraryItems),onRemove:P=>i(o.filter(B=>B!==P))}),y&&C()]})},Yu=({selectedItems:e,onSelectItems:o,className:t})=>{let{library:r}=Re(),{clearLibraryCache:n,deleteItemsFromLibraryCache:i}=hc(),a=ge(),l=le(),[s]=se(Qr),c=async m=>{let p=m.filter(u=>!e.includes(u.id));r.setLibrary(p).catch(()=>{l({errorMessage:g("alerts.errorRemovingFromLibrary")})}),i(e),o([])};return Ct(c8,{appState:a,setAppState:l,selectedItems:e,onSelectItems:o,library:r,onRemoveFromLibrary:()=>c(s.libraryItems),resetLibrary:()=>{r.resetLibrary(),n()},className:t})};import{memo as x8,useEffect as E8,useState as y8}from"react";import d8,{useCallback as m8}from"react";function p8(){return[!1,m8(o=>o(),[])]}var Zy=d8.useTransition||p8;import $y from"clsx";import{memo as u8,useEffect as h8,useRef as g8,useState as f8}from"react";import{jsx as Sc,jsxs as b8}from"react/jsx-runtime";var jy=u8(({id:e,elements:o,isPending:t,onClick:r,selected:n,onToggle:i,onDrag:a,svgCache:l})=>{let s=g8(null),c=hy(e,o,l);h8(()=>{let f=s.current;if(f)return c&&(f.innerHTML=c.outerHTML),()=>{f.innerHTML=""}},[c]);let[d,m]=f8(!1),p=ce().editor.isMobile,u=t&&Sc("div",{className:"library-unit__adder",children:S1});return b8("div",{className:$y("library-unit",{"library-unit__active":o,"library-unit--hover":o&&d,"library-unit--selected":n,"library-unit--skeleton":!c}),onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),children:[Sc("div",{className:$y("library-unit__dragger",{"library-unit__pulse":!!t}),ref:s,draggable:!!o,onClick:o||t?f=>{e&&f.shiftKey?i(e,f):r(e)}:void 0,onDragStart:f=>{if(!e){f.preventDefault();return}m(!1),a(e,f)}}),u,e&&o&&(d||p||n)&&Sc(Ca,{checked:n,onChange:(f,b)=>i(e,b),className:"library-unit__checkbox"})]})}),qy=()=>Sc("div",{className:"library-unit library-unit--skeleton"});import{Fragment as w8,jsx as kc}from"react/jsx-runtime";var Wu=({children:e})=>kc("div",{className:"library-menu-items-container__grid",children:e}),Mc=x8(({items:e,onItemSelectToggle:o,onItemDrag:t,isItemSelected:r,onClick:n,svgCache:i,itemsRenderedPerBatch:a})=>{let[,l]=Zy(),[s,c]=y8(0);return E8(()=>{s<e.length&&l(()=>{c(s+a)})},[s,e.length,l,a]),kc(w8,{children:e.map((d,m)=>m<s?kc(jy,{elements:d?.elements,isPending:!d?.id&&!!d?.elements,onClick:n,svgCache:i,id:d?.id,selected:r(d.id),onToggle:o,onDrag:t},d?.id??m):kc(qy,{},m))})});import{Fragment as Qy,jsx as St,jsxs as xi}from"react/jsx-runtime";var M8=17,L8=64;function Vu({isLoading:e,libraryItems:o,onAddToLibrary:t,onInsertLibraryItems:r,pendingElements:n,theme:i,id:a,libraryReturnUrl:l,onSelectItems:s,selectedItems:c}){let d=T8(null),m=Cy(d);v8(()=>{m>0&&d.current?.scrollTo(0,m)},[]);let{svgCache:p}=hc(),u=Jy(()=>o.filter(P=>P.status!=="published"),[o]),f=Jy(()=>o.filter(P=>P.status==="published"),[o]),b=!o.length&&!n.length,x=!n.length&&!u.length&&!f.length,[w,E]=I8(null),y=bi((P,B)=>{let O=!c.includes(P),G=[...u,...f];if(O){if(B.shiftKey&&w){let J=G.findIndex(Z=>Z.id===w),_=G.findIndex(Z=>Z.id===P);if(J===-1||_===-1){s([...c,P]);return}let R=S8(c),X=G.reduce((Z,Y,ae)=>((ae>=J&&ae<=_||R.has(Y.id))&&Z.push(Y.id),Z),[]);s(X)}else s([...c,P]);E(P)}else E(null),s(c.filter(J=>J!==P))},[w,s,f,c,u]),v=bi(P=>{let B;return c.includes(P)?B=o.filter(O=>c.includes(O.id)):B=o.filter(O=>O.id===P),B.map(O=>({...O,elements:k8({type:"everything",elements:O.elements,randomizeSeed:!0}).duplicatedElements}))},[o,c]),C=bi((P,B)=>{B.dataTransfer.setData(C8.excalidrawlib,um(v(P)))},[v]),S=bi(P=>P?c.includes(P):!1,[c]),L=bi(()=>{t(n)},[n,t]),k=bi(P=>{P&&r(v(P))},[v,r]),A=p.size>=o.length?L8:M8;return xi("div",{className:"library-menu-items-container",style:n.length||u.length||f.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[!x&&St(Yu,{selectedItems:c,onSelectItems:s,className:"library-menu-dropdown-container--in-heading"}),xi(Ze.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:f.length>0?1:"0 1 auto",marginBottom:0},ref:d,children:[xi(Qy,{children:[!x&&St("div",{className:"library-menu-items-container__header",children:g("labels.personalLib")}),e&&St("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:St(tt,{})}),!n.length&&!u.length?xi("div",{className:"library-menu-items__no-items",children:[St("div",{className:"library-menu-items__no-items__label",children:g("library.noItems")}),St("div",{className:"library-menu-items__no-items__hint",children:f.length>0?g("library.hint_emptyPrivateLibrary"):g("library.hint_emptyLibrary")})]}):xi(Wu,{children:[n.length>0&&St(Mc,{itemsRenderedPerBatch:A,items:[{id:null,elements:n}],onItemSelectToggle:y,onItemDrag:C,onClick:L,isItemSelected:S,svgCache:p}),St(Mc,{itemsRenderedPerBatch:A,items:u,onItemSelectToggle:y,onItemDrag:C,onClick:k,isItemSelected:S,svgCache:p})]})]}),xi(Qy,{children:[(f.length>0||n.length>0||u.length>0)&&St("div",{className:"library-menu-items-container__header library-menu-items-container__header--excal",children:g("labels.excalidrawLib")}),f.length>0?St(Wu,{children:St(Mc,{itemsRenderedPerBatch:A,items:f,onItemSelectToggle:y,onItemDrag:C,onClick:k,isItemSelected:S,svgCache:p})}):u.length>0?St("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",fontSize:".9rem"},children:g("library.noItems")}):null]}),b&&St(Ec,{style:{padding:"16px 0",width:"100%"},id:a,libraryReturnUrl:l,theme:i,children:St(Yu,{selectedItems:c,onSelectItems:s})})]})]})}import{jsx as mr,jsxs as o2}from"react/jsx-runtime";var gi=he(!1),t2=({children:e})=>mr("div",{className:"layer-ui__library",children:e}),R8=i2(({onInsertLibraryItems:e,pendingElements:o,onAddToLibrary:t,setAppState:r,libraryReturnUrl:n,library:i,id:a,theme:l,selectedItems:s,onSelectItems:c})=>{let[d]=se(Qr),m=Ku(f=>{(async(x,w)=>{re("element","addToLibrary","ui");for(let y of A8)if(x.some(v=>v.type===y))return r({errorMessage:g(`errors.libraryElementTypeError.${y}`)});let E=[{status:"unpublished",elements:x,id:D8(),created:Date.now()},...w];t(),i.setLibrary(E).catch(()=>{r({errorMessage:g("alerts.errorAddingToLibrary")})})})(f,d.libraryItems)},[t,i,r,d.libraryItems]),p=n2(()=>d.libraryItems,[d]);if(d.status==="loading"&&!d.isInitialized)return mr(t2,{children:mr("div",{className:"layer-ui__library-message",children:o2("div",{children:[mr(tt,{size:"2em"}),mr("span",{children:g("labels.libraryLoadingMessage")})]})})});let u=d.libraryItems.length>0||o.length>0;return o2(t2,{children:[mr(Vu,{isLoading:d.status==="loading",libraryItems:p,onAddToLibrary:m,onInsertLibraryItems:e,pendingElements:o,id:a,libraryReturnUrl:n,theme:l,onSelectItems:c,selectedItems:s}),u&&mr(Ec,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:a,libraryReturnUrl:n,theme:l})]})}),Xu=(e,o)=>({elements:e,pending:$(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:o}),N8=(e,o)=>{let t=er(),[r,n]=r2(()=>Xu(t,e.selectedElementIds)),i=P8(new Map);return e2(()=>{for(let a of r.pending)i.current.set(a.id,a.version)},[r.pending]),e2(()=>{o.state.cursorButton==="up"&&o.state.activeTool.type==="selection"&&n(a=>{if(!_8(a.selectedElementIds,e.selectedElementIds))return i.current.clear(),Xu(t,e.selectedElementIds);let l=o.scene.getNonDeletedElementsMap();for(let s of Object.keys(e.selectedElementIds)){let c=l.get(s)?.version;if(c&&c!==i.current.get(s))return Xu(t,e.selectedElementIds)}return a})},[o,o.state.cursorButton,o.state.activeTool.type,e.selectedElementIds,t]),r.pending},a2=i2(()=>{let e=Re(),{onInsertElements:o}=e,t=fo(),r=ge(),n=le(),[i,a]=r2([]),l=n2(()=>e.library,[e.library]),s=N8(r,e),c=Ku(m=>{o(xc(m))},[o]),d=Ku(()=>{n({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[n]);return mr(R8,{pendingElements:s,onInsertLibraryItems:c,onAddToLibrary:d,setAppState:n,libraryReturnUrl:t.libraryReturnUrl,library:l,id:e.id,theme:r.theme,selectedItems:i,onSelectItems:a})});import B8 from"clsx";import{useRef as F8}from"react";import{createPortal as O8}from"react-dom";import{KEYS as z8}from"@excalidraw/common";import{jsx as l2,jsxs as H8}from"react/jsx-runtime";var s2=e=>{let{closeOnClickOutside:o=!0}=e,t=gs({className:"excalidraw-modal-container"}),r=F8(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let n=i=>{i.key===z8.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return O8(H8("div",{className:B8("Modal",e.className,{"animations-disabled":r.current}),role:"dialog","aria-modal":"true",onKeyDown:n,"aria-labelledby":e.labelledBy,"data-prevent-outside-click":!0,children:[l2("div",{className:"Modal__background",onClick:o?e.onCloseRequest:void 0}),l2("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as Lc,jsxs as d2}from"react/jsx-runtime";function V8(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var Ne=e=>{let[o,t]=my(),[r]=Y8(document.activeElement),{id:n}=ze(),i=ce().viewport.isMobile;U8(()=>{if(!o)return;let c=c2(o);setTimeout(()=>{c.length>0&&e.autofocus!==!1&&(c[1]||c[0]).focus()});let d=m=>{if(m.key===W8.TAB){let p=c2(o),{activeElement:u}=document,f=p.findIndex(b=>b===u);f===0&&m.shiftKey?(p[p.length-1].focus(),m.preventDefault()):f===p.length-1&&!m.shiftKey&&(p[0].focus(),m.preventDefault())}};return o.addEventListener("keydown",d),()=>o.removeEventListener("keydown",d)},[o,e.autofocus]);let a=le(),l=wn(gi),s=()=>{a({openMenu:null}),l(!1),r.focus(),e.onCloseRequest()};return Lc(s2,{className:G8("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:V8(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,children:d2(We,{ref:t,children:[e.title&&d2("h2",{id:`${n}-dialog-title`,className:"Dialog__title",children:[Lc("span",{className:"Dialog__titleContent",children:e.title}),e.titleButton]}),i&&Lc("button",{className:"Dialog__close",onClick:s,title:g("buttons.close"),"aria-label":g("buttons.close"),type:"button",children:Ft}),Lc("div",{className:"Dialog__content",children:e.children})]})})};import Zu from"clsx";import{forwardRef as $8,useRef as j8,useImperativeHandle as q8,useLayoutEffect as J8,useState as Q8}from"react";import X8 from"clsx";import{composeEventHandlers as K8}from"@excalidraw/common";import{jsx as Z8}from"react/jsx-runtime";var Rt=({type:e="button",onSelect:o,selected:t,children:r,className:n="",...i})=>Z8("button",{onClick:K8(i.onClick,a=>{o()}),type:e,className:X8("excalidraw-button",n,{selected:t}),...i,children:r});import{jsx as $u,jsxs as m2}from"react/jsx-runtime";var Ei=$8(({onChange:e,label:o,fullWidth:t,placeholder:r,readonly:n,selectOnRender:i,onKeyDown:a,isRedacted:l=!1,icon:s,className:c,...d},m)=>{let p=j8(null);q8(m,()=>p.current),J8(()=>{i&&(p.current?.focus(),p.current?.select())},[i]);let[u,f]=Q8(!1);return m2("div",{className:Zu("ExcTextField",c,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!s}),onClick:()=>{p.current?.focus()},children:[s,o&&$u("div",{className:"ExcTextField__label",children:o}),m2("div",{className:Zu("ExcTextField__input",{"ExcTextField__input--readonly":n}),children:[$u("input",{className:Zu({"is-redacted":"value"in d&&d.value&&l&&!u}),readOnly:n,value:"value"in d?d.value:void 0,defaultValue:"defaultValue"in d?d.defaultValue:void 0,placeholder:r,ref:p,onChange:b=>e?.(b.target.value),onKeyDown:a}),l&&$u(Rt,{onSelect:()=>f(!u),style:{border:0,userSelect:"none"},children:u?K0:Gr})]})]})});import{KEYS as io}from"@excalidraw/common";var pr=[{icon:_1,value:"selection",key:io.V,fillable:!0,myocSimplifiedMode:!0},{icon:Cn,value:"rectangle",key:io.R,fillable:!0,myocSimplifiedMode:!1},{icon:Sn,value:"diamond",key:io.D,fillable:!0,myocSimplifiedMode:!1},{icon:kn,value:"ellipse",key:io.O,fillable:!0,myocSimplifiedMode:!1},{icon:Kl,value:"arrow",key:io.A,fillable:!0,myocSimplifiedMode:!1},{icon:Mn,value:"line",key:io.L,fillable:!0,myocSimplifiedMode:!1},{icon:jo,value:"freedraw",key:[io.P,io.X],fillable:!1,myocSimplifiedMode:!0},{icon:Ln,value:"text",key:io.T,fillable:!1,myocSimplifiedMode:!0},{icon:N1,value:"image",key:[io.I],fillable:!1,myocSimplifiedMode:!0},{icon:B1,value:"eraser",key:io.E,fillable:!1,myocSimplifiedMode:!0}],p2=e=>pr.find((t,r)=>t.key&&(typeof t.key=="string"?t.key===e:t.key.includes(e)))?.value||null;import ju from"clsx";import{useMemo as e7,useState as t7}from"react";import{CLASSES as o7,KEYS as u2,capitalizeString as yi,isTransparent as h2}from"@excalidraw/common";import{shouldAllowVerticalAlign as r7,suppportsHorizontalAlign as n7}from"@excalidraw/element";import{hasBoundTextElement as g2,isElbowArrow as i7,isImageElement as a7,isLinearElement as l7,isTextElement as s7}from"@excalidraw/element";import{hasStrokeColor as f2,toolIsArrow as b2}from"@excalidraw/element";import{Fragment as ur,jsx as Be,jsxs as $e}from"react/jsx-runtime";var qu=(e,o)=>{let t=o[0]?.type||null;for(let r of o)if(r.type!==t){t=null;break}return f2(e.activeTool.type)&&e.activeTool.type!=="image"&&t!=="image"&&t!=="frame"&&t!=="magicframe"||o.some(r=>f2(r.type))},Ju=(e,o)=>Ko(e.activeTool.type)||o.some(t=>Ko(t.type)),Pc=({appState:e,elementsMap:o,renderAction:t,app:r})=>{let n=_l(o,e),i=!1;n.length===2&&(g2(n[0])||g2(n[1]))&&(i=!0);let a=!!(e.editingTextElement||e.newElement),l=ce(),s=document.documentElement.getAttribute("dir")==="rtl",c=Ko(e.activeTool.type)&&!h2(e.currentItemBackgroundColor)||n.some(f=>Ko(f.type)&&!h2(f.backgroundColor)),d=n.length===1||i,m=!e.selectedLinearElement?.isEditing&&n.length===1&&l7(n[0])&&!i7(n[0]),p=!e.croppingElementId&&n.length===1&&a7(n[0]),u=!i&&at(e,r);return $e("div",{className:"selected-shape-actions",children:[Be("div",{children:qu(e,n)&&t("changeStrokeColor")}),Ju(e,n)&&Be("div",{children:t("changeBackgroundColor")}),c&&t("changeFillStyle"),(lm(e.activeTool.type)||n.some(f=>lm(f.type)))&&t("changeStrokeWidth"),(e.activeTool.type==="freedraw"||n.some(f=>f.type==="freedraw"))&&t("changeStrokeShape"),(sm(e.activeTool.type)||n.some(f=>sm(f.type)))&&$e(ur,{children:[t("changeStrokeStyle"),t("changeSloppiness")]}),(cm(e.activeTool.type)||n.some(f=>cm(f.type)))&&Be(ur,{children:t("changeRoundness")}),(b2(e.activeTool.type)||n.some(f=>b2(f.type)))&&Be(ur,{children:t("changeArrowType")}),(e.activeTool.type==="text"||n.some(s7))&&$e(ur,{children:[t("changeFontFamily"),t("changeFontSize"),(e.activeTool.type==="text"||n7(n,o))&&t("changeTextAlign")]}),r7(n,o)&&t("changeVerticalAlign"),(gn(e.activeTool.type)||n.some(f=>gn(f.type)))&&Be(ur,{children:t("changeArrowhead")}),t("changeOpacity"),$e("fieldset",{children:[Be("legend",{children:g("labels.layers")}),$e("div",{className:"buttonList",children:[t("sendToBack"),t("sendBackward"),t("bringForward"),t("bringToFront")]})]}),u&&!i&&$e("fieldset",{children:[Be("legend",{children:g("labels.align")}),$e("div",{className:"buttonList",children:[s?$e(ur,{children:[t("alignRight"),t("alignHorizontallyCentered"),t("alignLeft")]}):$e(ur,{children:[t("alignLeft"),t("alignHorizontallyCentered"),t("alignRight")]}),n.length>2&&t("distributeHorizontally"),Be("div",{style:{flexBasis:"100%",height:0}}),$e("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[t("alignTop"),t("alignVerticallyCentered"),t("alignBottom"),n.length>2&&t("distributeVertically"),Be("div",{style:{flexBasis:"100%",height:0}}),t("arrangeElements")]})]})]}),!a&&n.length>0&&$e("fieldset",{children:[Be("legend",{children:g("labels.actions")}),$e("div",{className:"buttonList",children:[!l.editor.isMobile&&t("duplicateSelection"),!l.editor.isMobile&&t("deleteSelectedElements"),t("group"),t("ungroup"),d&&t("hyperlink"),p&&t("cropEditor"),m&&t("toggleLinearEditor"),t("smartZoom")]})]})]})},Ac=({activeTool:e,appState:o,app:t,UIOptions:r})=>{let[n,i]=t7(!1),a=e.type==="frame",l=e.type==="laser",s=e.type==="lasso",c=e.type==="embeddable",d=pr.filter(p=>p.myocSimplifiedMode===!1),m=e7(()=>{switch(e.type){case"frame":return{icon:_n,highlight:!1};case"lasso":return{icon:ta,highlight:!0};case"embeddable":return{icon:O1,highlight:!0};case"laser":return t.props.isCollaborating?{icon:Om,highlight:!0}:{icon:la,highlight:!0};case"diamond":return{icon:Sn,highlight:!0};case"rectangle":return{icon:Cn,highlight:!0};case"ellipse":return{icon:kn,highlight:!0};case"arrow":return{icon:Kl,highlight:!0};case"line":return{icon:Mn,highlight:!0};default:return{icon:Om,highlight:!1}}},[e.type,t.props.isCollaborating]);return $e(ur,{children:[pr.filter(p=>!o.myocSimplifiedMode||p.myocSimplifiedMode).map(({value:p,icon:u,key:f,fillable:b},x)=>{if(r.tools?.[p]===!1)return null;let w=g(`toolBar.${p}`),E=f&&yi(typeof f=="string"?f:f[0]),y=`${E}`;return Be(W,{className:ju("Shape",{fillable:b}),type:"radio",icon:u,checked:e.type===p,name:"editor-current-shape",title:`${yi(w)} \u2014 ${y}`,keyBindingLabel:E,"aria-label":yi(w),"aria-keyshortcuts":y,"data-testid":`toolbar-${p}`,onPointerDown:({pointerType:v})=>{!o.penDetected&&v==="pen"&&t.togglePenMode(!0),p==="selection"&&(o.activeTool.type==="selection"?t.setActiveTool({type:"lasso"}):t.setActiveTool({type:"selection"}))},onChange:({pointerType:v})=>{o.activeTool.type!==p&&re("toolbar",p,"ui"),p==="image"?t.setActiveTool({type:p}):t.setActiveTool({type:p})}},p)}),$e(ye,{open:n,children:[Be(ye.Trigger,{className:ju("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":m.highlight}),onToggle:()=>i(!n),title:g("toolBar.extraTools"),children:m.icon}),$e(ye.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[Be(ye.Item,{onSelect:()=>t.setActiveTool({type:"lasso"}),icon:ta,"data-testid":"toolbar-lasso",selected:s,children:g("toolBar.lasso")}),d.map(({value:p,icon:u,key:f,fillable:b})=>{let x=g(`toolBar.${p}`),w=f&&yi(typeof f=="string"?f:f[0]);return Be(ye.Item,{onSelect:()=>t.setActiveTool({type:p}),icon:u,"data-testid":`toolbar-${p}`,selected:e.type===p,shortcut:w??void 0,children:yi(x)},p)}),Be("div",{className:"App-toolbar__dropdown-divider"}),Be(ye.Item,{onSelect:()=>t.toggleLock(),icon:o.activeTool.locked?$o:Ao,"data-testid":"toolbar-lock",selected:o.activeTool.locked,shortcut:u2.Q,children:yi(g("toolBar.lock-short"))}),!o.myocSimplifiedMode&&Be(ye.Item,{onSelect:()=>t.setActiveTool({type:"laser"}),icon:la,"data-testid":"toolbar-laser",selected:l,shortcut:u2.K.toLocaleUpperCase(),children:g("toolBar.laser")})]})]})]})},x2=({renderAction:e,zoom:o})=>Be(Ze.Col,{gap:1,className:o7.ZOOM_ACTIONS,children:$e(Ze.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),E2=({renderAction:e,className:o})=>$e("div",{className:`undo-redo-buttons ${o}`,children:[Be("div",{className:"undo-button-container",children:Be(it,{label:g("buttons.undo"),children:e("undo")})}),Be("div",{className:"redo-button-container",children:$e(it,{label:g("buttons.redo"),children:[" ",e("redo")]})})]}),y2=({actionManager:e,showExitZenModeBtn:o})=>Be("button",{type:"button",className:ju("disable-zen-mode",{"disable-zen-mode--visible":o}),onClick:()=>e.executeAction(ii),children:g("buttons.exitZenMode")});import{useRef as c7}from"react";var Qu=e=>{let o=c7({userFn:e});return o.current.userFn=e,o.current.stableFn||(o.current.stableFn=(...t)=>o.current.userFn(...t)),o.current.stableFn};var eh={};Kf(eh,{toggleTheme:()=>d7});var d7={...Vr,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(Vr,"commandPalette")}};import{jsx as st,jsxs as wo}from"react/jsx-runtime";var f7=he(null),Me={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links"},b7=e=>{switch(e){case Me.app:return 1;case Me.export:return 2;case Me.editor:return 3;case Me.tools:return 4;case Me.elements:return 5;case Me.links:return 6;default:return 10}},Rc=({shortcut:e,className:o,children:t})=>{let r=e.replace("++","+$").split("+");return wo("div",{className:T2("shortcut",o),children:[r.map((n,i)=>st("div",{className:"shortcut-wrapper",children:st("div",{className:"shortcut-key",children:n==="$"?"+":n})},n)),st("div",{className:"shortcut-desc",children:t})]})},I2=e=>!e.altKey&&e[ao.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===ao.P||e.key===ao.SLASH),Hce=Object.assign(e=>{let o=ge(),t=le();return _c(()=>{let r=n=>{I2(n)&&(n.preventDefault(),n.stopPropagation(),t(i=>{let a=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return a&&re("command_palette","open","shortcut"),{openDialog:a}}))};return window.addEventListener(Nc.KEYDOWN,r,{capture:!0}),()=>window.removeEventListener(Nc.KEYDOWN,r,{capture:!0})},[t]),o.openDialog?.name!=="commandPalette"?null:st(x7,{...e})},{defaultItems:eh});function x7({customCommandPaletteItems:e}){let o=Re(),t=ge(),r=le(),n=fo(),i=ot(),[a,l]=se(f7),[s,c]=Dc(null),d=p7(null),m=qo({uiAppState:t,customCommandPaletteItems:e,appProps:n});_c(()=>{let{uiAppState:S,customCommandPaletteItems:L,appProps:k}=m,A=G=>{let J="";return G.label&&(typeof G.label=="function"?J=g(G.label(o.scene.getNonDeletedElements(),S,o)):J=g(G.label)),J},P=G=>typeof G.icon=="function"?G.icon(S,o.scene.getNonDeletedElements()):G.icon,B=[],O=(G,J,_)=>{let R={label:A(G),icon:P(G),category:J,shortcut:Se(G.name),keywords:G.keywords,predicate:G.predicate,viewMode:G.viewMode,perform:()=>{i.executeAction(G,"commandPalette")}};return _?_(R,G):R};if(S&&o.scene&&i){let G=[i.actions.group,i.actions.ungroup,i.actions.cut,i.actions.copy,i.actions.deleteSelectedElements,i.actions.wrapSelectionInFrame,i.actions.copyStyles,i.actions.pasteStyles,i.actions.bringToFront,i.actions.bringForward,i.actions.sendBackward,i.actions.sendToBack,i.actions.alignTop,i.actions.alignBottom,i.actions.alignLeft,i.actions.alignRight,i.actions.alignVerticallyCentered,i.actions.alignHorizontallyCentered,i.actions.arrangeElements,i.actions.duplicateSelection,i.actions.smartZoom,i.actions.flipHorizontal,i.actions.flipVertical,i.actions.zoomToFitSelection,i.actions.zoomToFitSelectionInViewport,i.actions.increaseFontSize,i.actions.decreaseFontSize,i.actions.toggleLinearEditor,i.actions.cropEditor,i.actions.togglePolygon,Na,uc,cy].map(Y=>O(Y,Me.elements,(ae,de)=>({...ae,predicate:de.predicate?de.predicate:(me,Ye,Pt,Fr)=>$(me,Ye).length>0}))),J=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool,i.actions.toggleLassoTool].map(Y=>O(Y,Me.tools)),_=[i.actions.undo,i.actions.redo,i.actions.zoomIn,i.actions.zoomOut,i.actions.resetZoom,i.actions.zoomToFit,i.actions.smartZoom,i.actions.zenMode,i.actions.viewMode,i.actions.gridMode,i.actions.objectsSnapMode,i.actions.toggleShortcuts,i.actions.selectAll,i.actions.toggleElementLock,i.actions.unlockAllElements,i.actions.stats].map(Y=>O(Y,Me.editor)),R=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map(Y=>O(Y,Me.export));B=[...G,..._,{label:g("buttons.exportImage"),category:Me.export,icon:jl,shortcut:Se("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{r({openDialog:{name:"imageExport"}})}},...R];let X=[{label:g("toolBar.library"),category:Me.app,icon:In,viewMode:!1,perform:()=>{S.openSidebar?r({openSidebar:null}):r({openSidebar:{name:w2.name,tab:w2.defaultTab}})}},{label:g("search.title"),category:Me.app,icon:At,viewMode:!0,perform:()=>{i.executeAction(Va)}},{label:g("labels.shapeSwitch"),category:Me.elements,icon:sa,perform:()=>{i.executeAction(sy)}},{label:g("labels.changeStroke"),keywords:["color","outline"],category:Me.elements,icon:$l,viewMode:!1,predicate:(Y,ae)=>{let de=$(Y,ae);return de.length>0&&qu(ae,de)},perform:()=>{r(Y=>({openMenu:Y.openMenu==="shape"?null:"shape",openPopup:"elementStroke"}))}},{label:g("labels.changeBackground"),keywords:["color","fill"],icon:$l,category:Me.elements,viewMode:!1,predicate:(Y,ae)=>{let de=$(Y,ae);return de.length>0&&Ju(ae,de)},perform:()=>{r(Y=>({openMenu:Y.openMenu==="shape"?null:"shape",openPopup:"elementBackground"}))}},{label:g("labels.canvasBackground"),keywords:["color"],icon:$l,category:Me.editor,viewMode:!1,perform:()=>{r(Y=>({openMenu:Y.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...pr.reduce((Y,ae)=>{let{value:de,icon:me,key:Ye}=ae;if(k.UIOptions.tools?.[de]===!1)return Y;let Fr=Ye&&u7(typeof Ye=="string"?Ye:Ye[0]),hn={label:g(`toolBar.${de}`),category:Me.tools,shortcut:Fr,icon:me,keywords:["toolbar"],viewMode:!1,perform:({event:nm})=>{de==="image"?o.setActiveTool({type:de}):o.setActiveTool({type:de})}};return Y.push(hn),Y},[]),...J,{label:g("toolBar.lock"),category:Me.tools,icon:S.activeTool.locked?$o:Ao,shortcut:ao.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{o.toggleLock()}},{label:`${g("labels.textToDiagram")}...`,category:Me.tools,icon:$0,viewMode:!1,predicate:k.aiEnabled,perform:()=>{r(Y=>({...Y,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${g("toolBar.mermaidToExcalidraw")}...`,category:Me.tools,icon:W0,viewMode:!1,predicate:k.aiEnabled,perform:()=>{r(Y=>({...Y,openDialog:{name:"ttd",tab:"mermaid"}}))}}],Z=[...B,...X,...L||[]].map(Y=>({...Y,icon:Y.icon||sa,order:Y.order??b7(Y.category),haystack:`${Au(Y.label.toLocaleLowerCase())} ${Y.keywords?.join(" ")||""}`}));c(Z),l(Z.find(Y=>Y.label===a?.label)??null)}},[m,o,i,c,a?.label,l,r]);let[p,u]=Dc(""),[f,b]=Dc(null),[x,w]=Dc({}),E=S=>{r({openDialog:null},S),u("")},y=(S,L)=>{t.openDialog?.name==="commandPalette"&&(L.stopPropagation(),L.preventDefault(),document.body.classList.add("excalidraw-animations-disabled"),E(()=>{S.perform({actionManager:i,event:L}),l(S),requestAnimationFrame(()=>{document.body.classList.remove("excalidraw-animations-disabled")})}))},v=Qu(S=>S.viewMode===!1&&t.viewModeEnabled?!1:typeof S.predicate=="function"?S.predicate(o.scene.getNonDeletedElements(),t,n,o):S.predicate===void 0||S.predicate),C=Qu(S=>{let L=g7(S.target)||I2(S)||S.key===ao.ESCAPE;if(L&&S.key!==ao.ARROW_UP&&S.key!==ao.ARROW_DOWN&&S.key!==ao.ENTER)return;let k=Object.values(x).flat(),A=a&&!p&&v(a);if(S.key===ao.ARROW_UP){S.preventDefault();let P=k.findIndex(G=>G.label===f?.label);if(A){if(P===0){b(a);return}if(f===a){let G=k[k.length-1];G&&b(G);return}}let B;P===-1?B=k.length-1:B=P===0?k.length-1:(P-1)%k.length;let O=k[B];O&&b(O);return}if(S.key===ao.ARROW_DOWN){S.preventDefault();let P=k.findIndex(G=>G.label===f?.label);if(A){if(!f||P===k.length-1){b(a);return}if(f===a){let G=k[0];G&&b(G);return}}let B=(P+1)%k.length,O=k[B];O&&b(O);return}if(S.key===ao.ENTER&&f&&setTimeout(()=>{y(f,S)}),!L){if(S.stopPropagation(),/^[a-zA-Z0-9]$/.test(S.key)){d?.current?.focus();return}S.preventDefault()}});return _c(()=>(window.addEventListener(Nc.KEYDOWN,C,{capture:!0}),()=>window.removeEventListener(Nc.KEYDOWN,C,{capture:!0})),[C]),_c(()=>{if(!s)return;let S=P=>{let B={};for(let O of P)B[O.category]?B[O.category].push(O):B[O.category]=[O];return B},L=s.filter(v).sort((P,B)=>P.order-B.order),k=!p&&a&&v(a);if(!p){w(S(k?L.filter(P=>P.label!==a?.label):L)),b(k?a:L[0]||null);return}let A=Au(p.toLocaleLowerCase().replace(/[<>_| -]/g,""));L=m7.filter(A,L,{extract:P=>P.haystack}).sort((P,B)=>B.score-P.score).map(P=>P.original),w(S(L)),b(L[0]??null)},[p,s,v,a]),wo(Ne,{onCloseRequest:()=>E(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[st(Ei,{value:p,placeholder:g("commandPalette.search.placeholder"),onChange:S=>{u(S)},selectOnRender:!0,ref:d}),!o.device.viewport.isMobile&&wo("div",{className:"shortcuts-wrapper",children:[st(Rc,{shortcut:"\u2191\u2193",children:g("commandPalette.shortcuts.select")}),st(Rc,{shortcut:"\u21B5",children:g("commandPalette.shortcuts.confirm")}),st(Rc,{shortcut:h7("Esc"),children:g("commandPalette.shortcuts.close")})]}),wo("div",{className:"commands",children:[a&&!p&&wo("div",{className:"command-category",children:[wo("div",{className:"command-category-title",children:[g("commandPalette.recents"),st("div",{className:"icon",style:{marginLeft:"6px"},children:j0})]}),st(v2,{command:a,isSelected:a.label===f?.label,onClick:S=>y(a,S),disabled:!v(a),onMouseMove:()=>b(a),showShortcut:!o.device.viewport.isMobile,appState:t})]}),Object.keys(x).length>0?Object.keys(x).map((S,L)=>wo("div",{className:"command-category",children:[st("div",{className:"command-category-title",children:S}),x[S].map(k=>st(v2,{command:k,isSelected:k.label===f?.label,onClick:A=>y(k,A),onMouseMove:()=>b(k),showShortcut:!o.device.viewport.isMobile,appState:t},k.label))]},S)):s?wo("div",{className:"no-match",children:[st("div",{className:"icon",children:At})," ",g("commandPalette.search.noMatch")]}):null]})]})}var v2=({command:e,isSelected:o,disabled:t,onMouseMove:r,onClick:n,showShortcut:i,appState:a})=>{let l=()=>{};return wo("div",{className:T2("command-item",{"item-selected":o,"item-disabled":t}),ref:s=>{o&&!t&&s?.scrollIntoView?.({block:"nearest"})},onClick:t?l:n,onMouseMove:t?l:r,title:t?g("commandPalette.itemNotAvailable"):"",children:[wo("div",{className:"name",children:[e.icon&&st(rr,{icon:typeof e.icon=="function"?e.icon(a):e.icon}),st(ba,{children:e.label})]}),i&&e.shortcut&&st(Rc,{shortcut:e.shortcut})]})};import{getSizeFromPoints as L1e,randomInteger as hD,getUpdatedTimestamp as gD}from"@excalidraw/common";import{simplify as nD}from"points-on-curve";import{pointsOnBezierCurves as Vce}from"points-on-curve";import{invariant as Kce}from"@excalidraw/common";import{curve as $ce,lineSegment as jce,pointFrom as qce,pointDistance as Jce,pointFromArray as Qce,pointFromVector as ede,pointRotateRads as tde,polygon as ode,polygonFromPoints as rde,PRECISION as nde,segmentsIntersectAt as ide,vector as ade,vectorAdd as lde,vectorFromPoint as sde,vectorScale as cde}from"@excalidraw/math";import{getElementAbsoluteCoords as mde}from"@excalidraw/element";var th=e=>{if(!e)return[];for(let o of e.sets)if(o.type==="path")return o.ops;return e.sets[0].ops};import{pointFrom as iD,pointDistance as X2,pointRotateRads as u1e}from"@excalidraw/math";import{ROUGHNESS as aD,isTransparent as ja,assertNever as lD,COLOR_PALETTE as sD,LINE_POLYGON_POINT_MERGE_DISTANCE as g1e}from"@excalidraw/common";import{RoughGenerator as cD}from"roughjs/bin/generator";import Pfe from"roughjs/bin/rough";import{getStroke as q7}from"perfect-freehand";import{isRightAngleRads as _fe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as Nfe,DEFAULT_REDUCED_GLOBAL_ALPHA as Bfe,ELEMENT_READY_TO_ERASE_OPACITY as Ffe,FRAME_STYLE as Ofe,MIME_TYPES as U2,THEME as zfe,distance as Hfe,getFontString as Gfe,isRTL as Ufe,getVerticalOffset as Yfe}from"@excalidraw/common";import Uhe from"roughjs/bin/rough";import{arrayToMap as Whe,invariant as R2,rescalePoints as Vhe,sizeOf as Xhe}from"@excalidraw/common";import{degreesToRadians as uh,lineSegment as Zhe,pointDistance as $he,pointFrom as rt,pointFromArray as N7,pointRotateRads as Ci}from"@excalidraw/math";import{pointsOnBezierCurves as Jhe}from"points-on-curve";import{pointCenter as ahe,pointFrom as lhe,pointRotateRads as she,pointsEqual as che,pointDistance as dhe,vectorFromPoint as mhe,curveLength as phe,curvePointAtLength as uhe}from"@excalidraw/math";import{DRAGGING_THRESHOLD as fhe,KEYS as bhe,shouldRotateWithDiscreteAngle as xhe,getGridPoint as Ehe,invariant as yhe,tupleToCoors as whe,viewportCoordsToSceneCoords as vhe}from"@excalidraw/common";import{deconstructLinearOrFreeDrawElement as Ihe,isPathALoop as Che}from"@excalidraw/element";import{KEYS as iue,arrayToMap as aue,isBindingFallthroughEnabled as lue,tupleToCoors as sue,invariant as cue,isDevEnv as due,isTestEnv as mue}from"@excalidraw/common";import{lineSegment as uue,pointFrom as hue,pointRotateRads as gue,vectorFromPoint as fue,pointDistanceSq as bue,clamp as xue,pointDistance as Eue,pointFromVector as yue,vectorScale as wue,vectorNormalize as vue,vectorCross as Tue,pointsEqual as Iue,lineSegmentIntersectionPoints as Cue,PRECISION as Sue}from"@excalidraw/math";import{isTransparent as Nme}from"@excalidraw/common";import{curveIntersectLineSegment as Fme,isPointWithinBounds as Ome,lineSegment as zme,lineSegmentIntersectionPoints as Hme,pointFrom as Gme,pointFromVector as Ume,pointRotateRads as Yme,pointsEqual as Wme,vectorFromPoint as Vme,vectorNormalize as Xme,vectorScale as Kme}from"@excalidraw/math";import{ellipse as $me,ellipseSegmentInterceptPoints as jme}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as E7,DEFAULT_PROPORTIONAL_RADIUS as oh,LINE_CONFIRM_THRESHOLD as y7,ROUNDNESS as rh}from"@excalidraw/common";import{curve as fde,curveCatmullRomCubicApproxPoints as bde,curveOffsetPoints as xde,lineSegment as Ede,pointDistance as w7,pointFrom as yde,pointFromArray as wde,rectangle as vde}from"@excalidraw/math";var Bc=(e,o=1)=>{if(e.length>=3){let[t,r]=[e[0],e[e.length-1]];return w7(t,r)<=y7/o}return!1},Xa=(e,o)=>{if(o.roundness?.type===rh.PROPORTIONAL_RADIUS||o.roundness?.type===rh.LEGACY)return e*oh;if(o.roundness?.type===rh.ADAPTIVE_RADIUS){let t=o.roundness?.value??E7,r=t/oh;return e<=r?e*oh:t}return 0};import{ROUNDNESS as Lde,assertNever as Pde}from"@excalidraw/common";import{pointsEqual as Dde}from"@excalidraw/math";var C2=e=>!!e&&e.type==="embeddable",S2=e=>!!e&&e.type==="iframe",ih=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),en=e=>e!=null&&e.type==="text";var Fc=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var hr=e=>e!=null&&v7(e.type);var wi=e=>e!=null&&e.type==="arrow",Ka=e=>wi(e)&&e.elbowed;var v7=e=>e==="arrow"||e==="line";var vi=e=>e!==null&&"containerId"in e&&e.containerId!==null&&en(e);import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as lme,ARROW_LABEL_WIDTH_FRACTION as sme,BOUND_TEXT_PADDING as cme,DEFAULT_FONT_SIZE as dme,TEXT_ALIGN as mme,VERTICAL_ALIGN as pme,getFontString as ume,isProdEnv as hme,invariant as gme}from"@excalidraw/common";import{BOUND_TEXT_PADDING as Ode,DEFAULT_FONT_SIZE as zde,DEFAULT_FONT_FAMILY as Hde,getFontString as Gde,isTestEnv as Ude,normalizeEOL as Yde}from"@excalidraw/common";var Wde="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as qde,isTestEnv as Jde}from"@excalidraw/common";import{curvePointDistance as Ime,distanceToLineSegment as Cme,pointRotateRads as Sme}from"@excalidraw/math";import{ellipse as Mme,ellipseDistanceFromPoint as Lme}from"@excalidraw/math/ellipse";import{invariant as spe,isDevEnv as cpe,isTestEnv as dpe}from"@excalidraw/common";import{pointFrom as ppe,pointFromVector as upe,pointRotateRads as hpe,pointScaleFromOrigin as gpe,pointsEqual as fpe,triangleIncludesPoint as bpe,vectorCross as xpe,vectorFromPoint as k7,vectorScale as Epe}from"@excalidraw/math";var mh=[1,0],P2=[0,1],ph=[-1,0],A2=[0,-1],Oc=e=>{let[o,t]=e,r=Math.abs(o),n=Math.abs(t);return o>n?mh:o<=-n?ph:t>r?P2:A2},D2=(e,o)=>Oc(k7(e,o)),zc=(e,o)=>Hc(D2(e,o)),dh=(e,o)=>e[0]===o[0]&&e[1]===o[1],Hc=e=>dh(e,mh)||dh(e,ph);import{clamp as Cpe,pointDistance as Spe,pointFrom as kpe,pointScaleFromOrigin as Mpe,pointsEqual as Lpe,pointTranslate as Ppe,vector as Ape,vectorCross as Dpe,vectorFromPoint as _pe,vectorScale as Rpe}from"@excalidraw/math";import{BinaryHeap as Bpe,invariant as Fpe,isAnyTrue as Ope,tupleToCoors as zpe,getSizeFromPoints as Hpe,isDevEnv as Gpe,arrayToMap as Upe}from"@excalidraw/common";import{SHIFT_LOCKING_ANGLE as Gue,viewportCoordsToSceneCoords as Uue}from"@excalidraw/common";import{normalizeRadians as Wue,radiansBetweenAngles as Vue,radiansDifference as Xue}from"@excalidraw/math";import{pointsEqual as Zue}from"@excalidraw/math";var nh=e=>{let o=Math.floor(e.width/2)+1,t=0,r=e.width,n=Math.floor(e.height/2)+1,i=o,a=e.height;return[o,t,r,n,i,a,0,n]};var B7=e=>{switch(e){case"arrow":return 25;case"diamond":case"diamond_outline":return 12;case"crowfoot_many":case"crowfoot_one":case"crowfoot_one_or_many":return 20;default:return 15}},F7=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},hh=(e,o,t,r)=>{if(o.length<1)return null;let n=th(o[0]);if(n.length<1)return null;let i=t==="start"?1:n.length-1,a=n[i].data;R2(a.length===6,"Op data length is not 6");let l=rt(a[4],a[5]),s=rt(a[2],a[3]),c=rt(a[0],a[1]),d=n[i-1],m=rt(0,0);if(d.op==="move"){let _=N7(d.data);R2(_!=null,"Op data is not a point"),m=_}else d.op==="bcurveTo"&&(m=rt(d.data[4],d.data[5]));let p=(_,R)=>Math.pow(1-_,3)*l[R]+3*_*Math.pow(1-_,2)*s[R]+3*Math.pow(_,2)*(1-_)*c[R]+m[R]*Math.pow(_,3),[u,f]=t==="start"?m:l,[b,x]=[p(.3,0),p(.3,1)],w=Math.hypot(u-b,f-x),E=(u-b)/w,y=(f-x)/w,v=B7(r),C=0;{let[_,R]=t==="end"?e.points[e.points.length-1]:e.points[0],[X,Z]=e.points.length>1?t==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];C=Math.hypot(_-X,R-Z)}let L=Math.min(v,C*(r==="diamond"||r==="diamond_outline"?.25:.5)),k=u-E*L,A=f-y*L;if(r==="dot"||r==="circle"||r==="circle_outline"){let _=Math.hypot(A-f,k-u)+e.strokeWidth-2;return[u,f,_]}let P=F7(r);if(r==="crowfoot_many"||r==="crowfoot_one_or_many"){let[_,R]=Ci(rt(u,f),rt(k,A),uh(-P)),[X,Z]=Ci(rt(u,f),rt(k,A),uh(P));return[k,A,_,R,X,Z]}let[B,O]=Ci(rt(k,A),rt(u,f),-P*Math.PI/180),[G,J]=Ci(rt(k,A),rt(u,f),uh(P));if(r==="diamond"||r==="diamond_outline"){let _,R;if(t==="start"){let[X,Z]=e.points.length>1?e.points[1]:[0,0];[_,R]=Ci(rt(u+L*2,f),rt(u,f),Math.atan2(Z-f,X-u))}else{let[X,Z]=e.points.length>1?e.points[e.points.length-2]:[0,0];[_,R]=Ci(rt(u-L*2,f),rt(u,f),Math.atan2(f-Z,u-X))}return[u,f,B,O,_,R,G,J]}return[u,f,B,O,G,J]};import{pointFrom as pge,pointCenter as uge,pointRotateRads as hge,vectorFromPoint as gge,vectorNormalize as fge,vectorSubtract as bge,vectorAdd as xge,vectorScale as Ege,pointFromVector as yge,clamp as wge,isCloseTo as vge}from"@excalidraw/math";import{arrayToMap as sfe}from"@excalidraw/common";import{isPointWithinBounds as dfe,pointFrom as mfe}from"@excalidraw/math";import{vectorCross as kge,vectorFromPoint as Mge}from"@excalidraw/math";import{arrayToMap as O7}from"@excalidraw/common";import{getElementBounds as z7}from"@excalidraw/element";import{isArrowElement as H7,isExcalidrawElement as G7,isFreeDrawElement as U7,isLinearElement as Y7,isTextElement as W7}from"@excalidraw/element";import{rangeIncludesValue as Gc,pointFrom as Go,pointRotateRads as V7,rangeInclusive as Uc}from"@excalidraw/math";var X7=e=>e.type==="diamond"?[Go(e.width/2,0),Go(e.width,e.height/2),Go(e.width/2,e.height),Go(0,e.height/2)]:[Go(0,0),Go(0+e.width,0),Go(0+e.width,e.height),Go(0,e.height)],K7=e=>Y7(e)||U7(e)?e.points:X7(e),B2=e=>{let o=e.reduce((t,[r,n])=>(t.minY=Math.min(t.minY,n),t.minX=Math.min(t.minX,r),t.maxX=Math.max(t.maxX,r),t.maxY=Math.max(t.maxY,n),t),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,cx:0,cy:0});return o.cx=(o.maxX+o.minX)/2,o.cy=(o.maxY+o.minY)/2,o},F2=e=>{let o=K7(e),{cx:t,cy:r}=B2(o),n=Go(t,r),i=o.map(d=>V7(d,n,e.angle)),{minX:a,minY:l,maxX:s,maxY:c}=B2(i);return[a+e.x,l+e.y,s+e.x,c+e.y]},gh=(e,o,t=!1)=>{let r=F2(e),n=o[0]<=r[0]&&o[2]>=r[2]&&o[1]<=r[1]&&o[3]>=r[3];return t?n?!0:r[0]<=o[0]&&r[2]>=o[2]&&r[1]<=o[1]&&r[3]>=o[3]:n},O2=(e,o)=>{let t=F2(e);return(Gc(t[0],Uc(o[0],o[2]))||Gc(o[0],Uc(t[0],t[2])))&&(Gc(t[1],Uc(o[1],o[3]))||Gc(o[1],Uc(t[1],t[3])))},z2=({elements:e,bounds:o,type:t,errorMargin:r=0})=>{G7(o)&&(o=z7(o,O7(e)));let n=[o[0]-r,o[1]-r,o[2]+r,o[3]+r],i=new Set;for(let a of e){if(i.has(a.id))continue;if(t==="overlap"?O2(a,n):t==="inside"?gh(a,n):gh(a,n,!0)){if(i.add(a.id),a.boundElements)for(let s of a.boundElements)i.add(s.id);W7(a)&&a.containerId&&i.add(a.containerId),H7(a)&&(a.startBinding&&i.add(a.startBinding.elementId),a.endBinding&&i.add(a.endBinding?.elementId))}}return e.filter(a=>i.has(a.id))};import{arrayToMap as Wge,isShallowEqual as $7}from"@excalidraw/common";var Z7=function(){let e=null,o=null,t=null,r=(i,a,l,s)=>{if(t!==void 0&&a===o&&i===e&&l.editingGroupId===t?.editingGroupId)return t;let c={};for(let p of i){let u=p.groupIds;if(l.editingGroupId){let f=u.indexOf(l.editingGroupId);f>-1&&(u=u.slice(0,f))}if(u.length>0){let f=u[u.length-1];c[f]=!0}}let d={},m=a.reduce((p,u)=>{if(u.isDeleted)return p;let f=u.groupIds.find(b=>c[b]);return f&&(p[u.id]=!0,Array.isArray(d[f])?d[f].push(u.id):d[f]=[u.id]),p},{});for(let p of Object.keys(d))d[p].length<2&&c[p]&&(c[p]=!1);return o=a,e=i,t={editingGroupId:l.editingGroupId,selectedGroupIds:c,selectedElementIds:fh({...l.selectedElementIds,...m},s)},t},n=(i,a,l,s)=>{let c=s?s.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):bh(a,i);return c.length?r(c,a,i,l):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:fh(i.selectedElementIds,l)}};return n.clearCache=()=>{o=null,e=null,t=null},n}();var qge=function(){let e=null,o=null,t=null,r=(n,i)=>(t!=null&&n===e&&i.selectedElementIds===o||(t=n.some(a=>i.selectedElementIds[a.id]),e=n,o=i.selectedElementIds),t);return r.clearCache=()=>{e=null,o=null,t=null},r}(),bh=(e,o,t)=>{let r=new Set,n=[];for(let i of e.values()){if(o.selectedElementIds[i.id]){n.push(i),r.add(i.id);continue}if(t?.includeBoundTextElement&&vi(i)&&o.selectedElementIds[i?.containerId]){n.push(i),r.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return n.forEach(a=>{Fc(a)&&H2(e,a.id).forEach(l=>!r.has(l.id)&&i.push(l)),i.push(a)}),i}return n};var fh=(e,o)=>$7(o.selectedElementIds,e)?o.selectedElementIds:e;var H2=(e,o)=>{let t=[];for(let r of e.values())r.frameId===o&&t.push(r);return t};var J7=typeof document<"u"?document.createElement("img"):{src:""};J7.src=`data:${U2.svg},${encodeURIComponent('<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="image" class="svg-inline--fa fa-image fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="#888" d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48zM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56zM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48z"></path></svg>')}`;var Q7=typeof document<"u"?document.createElement("img"):{src:""};Q7.src=`data:${U2.svg},${encodeURIComponent('<svg viewBox="0 0 668 668" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"><path d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48ZM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56ZM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.81709 0 0 .81709 124.825 145.825)"/><path d="M256 8C119.034 8 8 119.033 8 256c0 136.967 111.034 248 248 248s248-111.034 248-248S392.967 8 256 8Zm130.108 117.892c65.448 65.448 70 165.481 20.677 235.637L150.47 105.216c70.204-49.356 170.226-44.735 235.638 20.676ZM125.892 386.108c-65.448-65.448-70-165.481-20.677-235.637L361.53 406.784c-70.203 49.356-170.226 44.736-235.638-20.676Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.30366 0 0 .30366 506.822 60.065)"/></svg>')}`;var Y2=new WeakMap;var eD=new WeakMap([]);function W2(e){let o=tD(e),t=new Path2D(o);return eD.set(e,t),t}function tD(e){let o=e.simulatePressure?e.points:e.points.length?e.points.map(([r,n],i)=>[r,n,e.pressures[i]]):[[0,0,.5]],t={simulatePressure:e.simulatePressure,size:e.strokeWidth*4.25,thinning:.6,smoothing:.5,streamline:.5,easing:r=>Math.sin(r*Math.PI/2),last:!!e.lastCommittedPoint};return rD(q7(o,t))}function G2(e,o){return[(e[0]+o[0])/2,(e[1]+o[1])/2]}var oD=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g;function rD(e){if(!e.length)return"";let o=e.length-1;return e.reduce((t,r,n,i)=>(n===o?t.push(r,G2(r,i[0]),"L",i[0],"Z"):t.push(r,G2(r,i[n+1])),t),["M",e[0],"Q"]).join(" ").replace(oD,"$1")}var V2=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";var ct=class ct{};I(ct,"rg",new cD),I(ct,"cache",new WeakMap),I(ct,"get",o=>ct.cache.get(o)),I(ct,"set",(o,t)=>ct.cache.set(o,t)),I(ct,"delete",o=>ct.cache.delete(o)),I(ct,"destroy",()=>{ct.cache=new WeakMap}),I(ct,"generateElementShape",(o,t)=>{let r=t?.isExporting?void 0:ct.get(o);if(r!==void 0)return r;Y2.delete(o);let n=pD(o,ct.rg,t||{isExporting:!1,canvasBackgroundColor:sD.white,embedsValidationStatus:null});return ct.cache.set(o,n),n});var Ii=ct,dD=e=>[8,8+e],$2=e=>[1.5,6+e];function mD(e){let o=e.roughness,t=Math.max(e.width,e.height),r=Math.min(e.width,e.height);return r>=20&&t>=50||r>=15&&e.roundness&&V2(e.type)||hr(e)&&t>=50?o:Math.min(o/(t<10?3:2),2.5)}var Ho=(e,o=!1)=>{let t={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?dD(e.strokeWidth):e.strokeStyle==="dotted"?$2(e.strokeWidth):void 0,disableMultiStroke:e.strokeStyle!=="solid",strokeWidth:e.strokeStyle!=="solid"?e.strokeWidth+.5:e.strokeWidth,fillWeight:e.strokeWidth/2,hachureGap:e.strokeWidth*4,roughness:mD(e),stroke:e.strokeColor,preserveVertices:o||e.roughness<aD.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return t.fillStyle=e.fillStyle,t.fill=ja(e.backgroundColor)?void 0:e.backgroundColor,e.type==="ellipse"&&(t.curveFitting=1),t;case"line":case"freedraw":return Bc(e.points)&&(t.fillStyle=e.fillStyle,t.fill=e.backgroundColor==="transparent"?void 0:e.backgroundColor),t;case"arrow":return t;default:throw new Error(`Unimplemented type ${e.type}`)}},K2=(e,o,t)=>ih(e)&&(o||C2(e)&&t?.get(e.id)!==!0)&&ja(e.backgroundColor)&&ja(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:S2(e)?{...e,strokeColor:ja(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:ja(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,Z2=(e,o,t,r,n,i,a)=>{let l=hh(e,o,t,r);if(l===null)return[];let s=(c,d)=>{if(c===null)return[];let[,,m,p,u,f]=c;return[n.line(m,p,u,f,d)]};switch(r){case"dot":case"circle":case"circle_outline":{let[c,d,m]=l;return delete i.strokeLineDash,[n.circle(c,d,m,{...i,fill:r==="circle_outline"?a:e.strokeColor,fillStyle:"solid",stroke:e.strokeColor,roughness:Math.min(.5,i.roughness||0)})]}case"triangle":case"triangle_outline":{let[c,d,m,p,u,f]=l;return delete i.strokeLineDash,[n.polygon([[c,d],[m,p],[u,f],[c,d]],{...i,fill:r==="triangle_outline"?a:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"diamond":case"diamond_outline":{let[c,d,m,p,u,f,b,x]=l;return delete i.strokeLineDash,[n.polygon([[c,d],[m,p],[u,f],[b,x],[c,d]],{...i,fill:r==="diamond_outline"?a:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"crowfoot_one":return s(l,i);case"bar":case"arrow":case"crowfoot_many":case"crowfoot_one_or_many":default:{let[c,d,m,p,u,f]=l;if(e.strokeStyle==="dotted"){let b=$2(e.strokeWidth-1);i.strokeLineDash=[b[0],b[1]-1]}else delete i.strokeLineDash;return i.roughness=Math.min(1,i.roughness||0),[n.line(m,p,c,d,i),n.line(u,f,c,d,i),...r==="crowfoot_one_or_many"?s(hh(e,o,t,"crowfoot_one"),i):[]]}}};var pD=(e,o,{isExporting:t,canvasBackgroundColor:r,embedsValidationStatus:n})=>{switch(e.type){case"rectangle":case"iframe":case"embeddable":{let i;if(e.roundness){let a=e.width,l=e.height,s=Xa(Math.min(a,l),e);i=o.path(`M ${s} 0 L ${a-s} 0 Q ${a} 0, ${a} ${s} L ${a} ${l-s} Q ${a} ${l}, ${a-s} ${l} L ${s} ${l} Q 0 ${l}, 0 ${l-s} L 0 ${s} Q 0 0, ${s} 0`,Ho(K2(e,t,n),!0))}else i=o.rectangle(0,0,e.width,e.height,Ho(K2(e,t,n),!1));return i}case"diamond":{let i,[a,l,s,c,d,m,p,u]=nh(e);if(e.roundness){let f=Xa(Math.abs(a-p),e),b=Xa(Math.abs(c-l),e);i=o.path(`M ${a+f} ${l+b} L ${s-f} ${c-b}
9
+ C ${s} ${c}, ${s} ${c}, ${s-f} ${c+b}
10
+ L ${d+f} ${m-b}
11
+ C ${d} ${m}, ${d} ${m}, ${d-f} ${m-b}
12
+ L ${p+f} ${u+b}
13
+ C ${p} ${u}, ${p} ${u}, ${p+f} ${u-b}
14
+ L ${a-f} ${l+b}
15
+ C ${a} ${l}, ${a} ${l}, ${a+f} ${l+b}`,Ho(e,!0))}else i=o.polygon([[a,l],[s,c],[d,m],[p,u]],Ho(e));return i}case"ellipse":return o.ellipse(e.width/2,e.height/2,e.width,e.height,Ho(e));case"line":case"arrow":{let i,a=Ho(e),l=e.points.length?e.points:[iD(0,0)];if(Ka(e)?l.every(s=>Math.abs(s[0])<=1e6&&Math.abs(s[1])<=1e6)?i=[o.path(uD(l,16),Ho(e,!0))]:(console.error("Elbow arrow with extreme point positions detected. Arrow not rendered.",e.id,JSON.stringify(l)),i=[]):e.roundness?i=[o.curve(l,a)]:a.fill?i=[o.polygon(l,a)]:i=[o.linearPath(l,a)],e.type==="arrow"){let{startArrowhead:s=null,endArrowhead:c="arrow"}=e;if(s!==null){let d=Z2(e,i,"start",s,o,a,r);i.push(...d)}if(c!==null){let d=Z2(e,i,"end",c,o,a,r);i.push(...d)}}return i}case"freedraw":{let i;if(W2(e),Bc(e.points)){let a=nD(e.points,.75);i=o.curve(a,{...Ho(e),stroke:"none"})}else i=null;return i}case"frame":case"magicframe":case"text":case"image":return null;default:return lD(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},uD=(e,o)=>{let t=[];for(let n=1;n<e.length-1;n+=1){let i=e[n-1],a=e[n+1],l=e[n],s=zc(l,i),c=zc(a,l),d=Math.min(o,X2(e[n],a)/2,X2(e[n],i)/2);s?i[0]<l[0]?t.push([e[n][0]-d,e[n][1]]):t.push([e[n][0]+d,e[n][1]]):i[1]<l[1]?t.push([e[n][0],e[n][1]-d]):t.push([e[n][0],e[n][1]+d]),t.push(e[n]),c?a[0]<l[0]?t.push([e[n][0]-d,e[n][1]]):t.push([e[n][0]+d,e[n][1]]):a[1]<l[1]?t.push([e[n][0],e[n][1]-d]):t.push([e[n][0],e[n][1]+d])}let r=[`M ${e[0][0]} ${e[0][1]}`];for(let n=0;n<t.length;n+=3)r.push(`L ${t[n][0]} ${t[n][1]}`),r.push(`Q ${t[n+1][0]} ${t[n+1][1]}, ${t[n+2][0]} ${t[n+2][1]}`);return r.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),r.join(" ")};var j2=(e,o,t=!1)=>{let r=!1;for(let n in o){let i=o[n];if(typeof i<"u"){if(e[n]===i&&(typeof i!="object"||i===null))continue;r=!0}}return!r&&!t?e:{...e,...o,version:o.version??e.version+1,versionNonce:o.versionNonce??hD(),updated:gD()}};import{jsx as J2}from"react/jsx-runtime";var ki=N({name:"toggleLinearEditor",category:Me.elements,label:(e,o,t)=>t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return!!(!o.selectedLinearElement?.isEditing&&n.length===1&&bD(n[0])&&!fD(n[0]))},perform(e,o,t,r){let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];xh(n,"No selected element found"),xh(o.selectedLinearElement,"No selected linear element found"),xh(n.id===o.selectedLinearElement.elementId,"Selected element ID and linear editor elementId does not match");let i={...o.selectedLinearElement,isEditing:!o.selectedLinearElement.isEditing};return{appState:{...o,selectedLinearElement:i},captureUpdate:q2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0],n=g(r.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return J2(W,{type:"button",icon:cb,title:n,"aria-label":n,onClick:()=>o(null)})}}),V1e=N({name:"togglePolygon",category:Me.elements,icon:Em,keywords:["loop"],label:(e,o,t)=>!t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds}).some(i=>!Si(i)||!i.polygon)?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds});return n.length>0&&n.every(i=>Si(i)&&i.points.length>=4)},perform(e,o,t,r){let n=r.scene.getSelectedElements(o);if(n.some(s=>!Si(s)))return!1;let i=n,a=i.some(s=>!s.polygon),l=xD(i);return{elements:e.map(s=>!l.has(s.id)||!Si(s)?s:j2(s,{backgroundColor:a?s.backgroundColor:"transparent",...ED(s,a)})),appState:o,captureUpdate:q2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(r.length===0||r.some(a=>!Si(a)||!a.polygon||a.points.length<3))return null;let n=r.every(a=>Si(a)&&a.polygon),i=g(n?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return J2(On,{icon:Em,title:i,"aria-label":i,active:n,onClick:()=>o(null),style:{marginLeft:"auto"}})}});import{KEYS as Q2,CANVAS_SEARCH_TAB as ew,CLASSES as yD,DEFAULT_SIDEBAR as tw}from"@excalidraw/common";import{CaptureUpdateAction as wD}from"@excalidraw/element";var Va=N({name:"searchMenu",icon:At,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,o,t,r){if(o.openDialog)return!1;if(o.openSidebar?.name===tw.name&&o.openSidebar.tab===ew){let n=r.excalidrawContainerValue.container?.querySelector(`.${yD.SEARCH_MENU_INPUT_WRAPPER} input`);return n?.focus(),n?.select(),!1}return{appState:{...o,openSidebar:{name:tw.name,tab:ew},openDialog:null},captureUpdate:wD.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[Q2.CTRL_OR_CMD]&&e.key===Q2.F});import{isImageElement as vD}from"@excalidraw/element";import{CaptureUpdateAction as TD}from"@excalidraw/element";import{jsx as ID}from"react/jsx-runtime";var Eh=N({name:"cropEditor",label:"helpDialog.cropStart",icon:Hm,viewMode:!0,trackEvent:{category:"menu"},keywords:["image","crop"],perform(e,o,t,r){let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...o,isCropping:!1,croppingElementId:n.id},captureUpdate:TD.IMMEDIATELY}},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return!!(!o.croppingElementId&&n.length===1&&vD(n[0]))},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=g("helpDialog.cropStart");return ID(W,{type:"button",icon:Hm,title:r,"aria-label":r,onClick:()=>o(null)})}});import{getNonDeletedElements as CD}from"@excalidraw/element";import{mutateElement as SD}from"@excalidraw/element";import{newFrameElement as kD}from"@excalidraw/element";import{isFrameLikeElement as Yc}from"@excalidraw/element";import{addElementsToFrame as MD,removeAllElementsFromFrame as LD}from"@excalidraw/element";import{getFrameChildren as PD}from"@excalidraw/element";import{updateActiveTool as ow}from"@excalidraw/common";import{getElementsInGroup as AD}from"@excalidraw/element";import{getCommonBounds as DD}from"@excalidraw/element";import{CaptureUpdateAction as tn}from"@excalidraw/element";var rw=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length===1&&Yc(t[0])},nw=N({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o).at(0)||null;if(Yc(n)){let i=PD(CD(e),n.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...o,selectedElementIds:i.reduce((a,l)=>(a[l.id]=!0,a),{})},captureUpdate:tn.IMMEDIATELY}}return{elements:e,appState:o,captureUpdate:tn.EVENTUALLY}},predicate:(e,o,t,r)=>rw(o,r)}),iw=N({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o).at(0)||null;return Yc(n)?{elements:LD(e,n),appState:{...o,selectedElementIds:{[n.id]:!0}},captureUpdate:tn.IMMEDIATELY}:{elements:e,appState:o,captureUpdate:tn.EVENTUALLY}},predicate:(e,o,t,r)=>rw(o,r)}),tbe=N({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o)=>({elements:e,appState:{...o,frameRendering:{...o.frameRendering,enabled:!o.frameRendering.enabled}},captureUpdate:tn.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),obe=N({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:_n,viewMode:!1,perform:(e,o,t,r)=>{let n=ow(o,{type:"frame"});return Dt(r.interactiveCanvas,{...o,activeTool:n}),{elements:e,appState:{...o,activeTool:ow(o,{type:"frame"})},captureUpdate:tn.EVENTUALLY}},keyTest:e=>!1}),aw=N({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=$(e,o);return n.length>0&&!n.some(i=>Yc(i))},perform:(e,o,t,r)=>{let n=$(e,o),i=r.scene.getNonDeletedElementsMap(),[a,l,s,c]=DD(n,i),d=16,m=kD({x:a-d,y:l-d,width:s-a+d*2,height:c-l+d*2});if(o.editingGroupId){let u=AD(n,o.editingGroupId);for(let f of u){let b=f.groupIds.indexOf(o.editingGroupId);SD(f,i,{groupIds:f.groupIds.slice(0,b)})}}return{elements:MD([...r.scene.getElementsIncludingDeleted(),m],n,m,o),appState:{selectedElementIds:{[m.id]:!0}},captureUpdate:tn.IMMEDIATELY}}});import{isWindows as zD,KEYS as Ja,matchKey as vh,arrayToMap as lw}from"@excalidraw/common";import{CaptureUpdateAction as wh}from"@excalidraw/element";import{orderByFractionalIndex as HD}from"@excalidraw/element";import{Emitter as _D}from"@excalidraw/common";import{CaptureUpdateAction as RD,StoreChange as ND,StoreDelta as BD}from"@excalidraw/element";var Mi=class extends BD{applyTo(o,t,r){let[n,i]=this.elements.applyTo(o,r.elements,{excludedProperties:new Set(["version","versionNonce"])}),[a,l]=this.appState.applyTo(t,n);return[n,a,i||l]}static calculate(o,t){return super.calculate(o,t)}static inverse(o){return super.inverse(o)}static applyLatestChanges(o,t,r,n){return super.applyLatestChanges(o,t,r,n)}},on=class{constructor(o=!0,t=!0){this.isUndoStackEmpty=o;this.isRedoStackEmpty=t}},qa=class e{constructor(o){this.store=o;I(this,"onHistoryChangedEmitter",new _D);I(this,"undoStack",[]);I(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(o){if(o.isEmpty()||o instanceof Mi)return;let t=Mi.inverse(o);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new on(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(o,t){return this.perform(o,t,()=>e.pop(this.undoStack),r=>e.push(this.redoStack,r))}redo(o,t){return this.perform(o,t,()=>e.pop(this.redoStack),r=>e.push(this.undoStack,r))}perform(o,t,r,n){try{let i=r();if(i===null)return;let a=RD.IMMEDIATELY,l=this.store.snapshot,s=o,c=t,d=!1;for(;i;){try{[s,c,d]=i.applyTo(s,c,l);let m=l.elements,p=l.maybeClone(a,s,c),u=ND.create(l,p),f=Mi.applyLatestChanges(i,m,s);f.isEmpty()||(this.store.scheduleMicroAction({action:a,change:u,delta:f}),i=f),l=p}finally{n(i)}if(d)break;i=r()}return[s,c]}finally{this.onHistoryChangedEmitter.trigger(new on(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(o){if(!o.length)return null;let t=o.pop();return t!==void 0?t:null}static push(o,t){let r=Mi.inverse(t);return o.push(r)}};import{useEffect as FD,useState as OD}from"react";var yh=(e,o)=>{let[t,r]=OD(o);return FD(()=>{let n=e.on(i=>{r(i)});return()=>{n()}},[e]),t};import{jsx as mw}from"react/jsx-runtime";var sw=(e,o,t)=>{if(!o.multiElement&&!o.resizingElement&&!o.editingTextElement&&!o.newElement&&!o.selectedElementsAreBeingDragged&&!o.selectionElement&&!e.flowChartCreator.isCreatingChart){let r=t();if(!r)return{captureUpdate:wh.EVENTUALLY};let[n,i]=r,a=HD(Array.from(n.values()));return{appState:i,elements:a,captureUpdate:wh.NEVER}}return{captureUpdate:wh.EVENTUALLY}},cw=e=>({name:"undo",label:"buttons.undo",icon:vm,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,r,n)=>sw(n,t,()=>e.undo(lw(o),t)),keyTest:o=>o[Ja.CTRL_OR_CMD]&&vh(o,Ja.Z)&&!o.shiftKey,PanelComponent:({updateData:o,data:t})=>{let{isUndoStackEmpty:r}=yh(e.onHistoryChangedEmitter,new on(e.isUndoStackEmpty,e.isRedoStackEmpty));return mw(W,{type:"button",icon:vm,"aria-label":g("buttons.undo"),onClick:o,size:t?.size||"medium",disabled:r,"data-testid":"button-undo"})}}),dw=e=>({name:"redo",label:"buttons.redo",icon:Tm,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,r,n)=>sw(n,t,()=>e.redo(lw(o),t)),keyTest:o=>o[Ja.CTRL_OR_CMD]&&o.shiftKey&&vh(o,Ja.Z)||zD&&o.ctrlKey&&!o.shiftKey&&vh(o,Ja.Y),PanelComponent:({updateData:o,data:t})=>{let{isRedoStackEmpty:r}=yh(e.onHistoryChangedEmitter,new on(e.isUndoStackEmpty,e.isRedoStackEmpty));return mw(W,{type:"button",icon:Tm,"aria-label":g("buttons.redo"),onClick:o,size:t?.size||"medium",disabled:r,"data-testid":"button-redo"})}});import{getFontString as GD}from"@excalidraw/common";import{newElementWith as UD}from"@excalidraw/element";import{measureText as YD}from"@excalidraw/element";import{isTextElement as pw}from"@excalidraw/element";import{CaptureUpdateAction as WD}from"@excalidraw/element";var uw=N({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=$(e,o);return n.length===1&&pw(n[0])&&!n[0].autoResize},perform:(e,o,t,r)=>{let n=$(e,o);return{appState:o,elements:e.map(i=>{if(i.id===n[0].id&&pw(i)){let a=YD(i.originalText,GD(i),i.lineHeight);return UD(i,{autoResize:!0,width:a.width,height:a.height,text:i.originalText})}return i}),captureUpdate:WD.IMMEDIATELY}}});import{CODES as VD,KEYS as XD}from"@excalidraw/common";import KD from"clsx";import{CaptureUpdateAction as ZD}from"@excalidraw/element";import{jsx as $D}from"react/jsx-runtime";var Th=N({name:"viewMode",label:"labels.viewMode",icon:Gr,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,o){return{appState:{...o,viewModeEnabled:!this.checked(o)},captureUpdate:ZD.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,o,t)=>typeof t.viewModeEnabled>"u",keyTest:e=>!e[XD.CTRL_OR_CMD]&&e.altKey&&e.code===VD.R,PanelComponent:({data:e,updateData:o,appState:t})=>$D(W,{type:"button",icon:Gr,"aria-label":g("labels.viewMode"),onClick:()=>o(null),size:e?.size||"medium","data-testid":"button-view-mode",className:KD({enabled:t.viewModeEnabled})})});import{isPromiseLike as jD}from"@excalidraw/common";import{jsx as qD}from"react/jsx-runtime";var Ih=(e,o,t,r,n,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,r,i))&&re(e.trackEvent.category,e.trackEvent.action||e.name,`${o} (${n.device.editor.isMobile?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},Wc=class{constructor(o,t,r,n){I(this,"actions",{});I(this,"updater");I(this,"getAppState");I(this,"getElementsIncludingDeleted");I(this,"app");I(this,"renderAction",(o,t)=>{let r=this.app.props.UIOptions.canvasActions;if(this.actions[o]&&"PanelComponent"in this.actions[o]&&(!(o in r)||r[o])){let n=this.actions[o],i=n.PanelComponent;i.displayName="PanelComponent";let a=this.getElementsIncludingDeleted(),l=this.getAppState(),s=c=>{Ih(n,"ui",l,a,this.app,c),this.updater(n.perform(this.getElementsIncludingDeleted(),this.getAppState(),c,this.app))};return qD(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:s,appProps:this.app.props,app:this.app,data:t,renderAction:this.renderAction})}return null});I(this,"isActionEnabled",o=>{let t=this.getElementsIncludingDeleted(),r=this.getAppState();return!o.predicate||o.predicate(t,r,this.app.props,this.app)});this.updater=i=>{if(jD(i))i.then(a=>o(a));else return o(i)},this.getAppState=t,this.getElementsIncludingDeleted=r,this.app=n}registerAction(o){this.actions[o.name]=o}registerAll(o){o.forEach(t=>this.registerAction(t))}handleKeyDown(o){let t=this.app.props.UIOptions.canvasActions,r=Object.values(this.actions).sort((s,c)=>(c.keyPriority||0)-(s.keyPriority||0)).filter(s=>(s.name in t?t[s.name]:!0)&&s.keyTest&&s.keyTest(o,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(r.length!==1)return r.length>1&&console.warn("Canceling as multiple actions match this shortcut",r),!1;let n=r[0];if(this.getAppState().viewModeEnabled&&n.viewMode!==!0)return!1;let i=this.getElementsIncludingDeleted(),a=this.getAppState(),l=null;return Ih(n,"keyboard",a,i,this.app,null),o.preventDefault(),o.stopPropagation(),this.updater(r[0].perform(i,a,l,this.app)),!0}executeAction(o,t="api",r=null){let n=this.getElementsIncludingDeleted(),i=this.getAppState();Ih(o,t,i,n,this.app,r),this.updater(o.perform(n,i,r,this.app))}};var Vc=class{constructor(){I(this,"targets",new WeakMap);I(this,"rafIds",new WeakMap)}register(o,t){this.targets.set(o,{callback:t,stopped:!0})}start(o){let t=this.targets.get(o);t&&(this.rafIds.has(o)||(this.targets.set(o,{...t,stopped:!1}),this.scheduleFrame(o)))}stop(o){let t=this.targets.get(o);t&&!t.stopped&&this.targets.set(o,{...t,stopped:!0}),this.cancelFrame(o)}constructFrame(o){return t=>{let r=this.targets.get(o);if(!r)return;let n=this.onFrame(r,t);!r.stopped&&!n?this.scheduleFrame(o):this.cancelFrame(o)}}scheduleFrame(o){let t=requestAnimationFrame(this.constructFrame(o));this.rafIds.set(o,t)}cancelFrame(o){if(this.rafIds.has(o)){let t=this.rafIds.get(o);cancelAnimationFrame(t)}this.rafIds.delete(o)}onFrame(o,t){return o.callback(t)??!1}};var Ch=e=>{let o=Array.from(e.values());return{x:hw(o,t=>t.x)/o.length,y:hw(o,t=>t.y)/o.length}},Sh=([e,o])=>Math.hypot(e.x-o.x,e.y-o.y),hw=(e,o)=>e.reduce((t,r)=>t+o(r),0);import{pointFrom as z,pointRotateRads as gr,rangeInclusive as Yt,rangeIntersection as Xc,rangesOverlap as Kc}from"@excalidraw/math";import{TOOL_TYPE as rn,KEYS as gw}from"@excalidraw/common";import{getCommonBounds as kh,getDraggedElementsBounds as Mh,getElementAbsoluteCoords as JD}from"@excalidraw/element";import{isBoundToContainer as Ew}from"@excalidraw/element";import{getMaximumGroups as yw}from"@excalidraw/element";import{getSelectedElements as QD,getVisibleAndNonSelectedElements as ww}from"@excalidraw/element";var e_=8,fw=99999,Zc=e=>e_/e,ht=class ht{};I(ht,"referenceSnapPoints",null),I(ht,"visibleGaps",null),I(ht,"setReferenceSnapPoints",o=>{ht.referenceSnapPoints=o}),I(ht,"getReferenceSnapPoints",()=>ht.referenceSnapPoints),I(ht,"setVisibleGaps",o=>{ht.visibleGaps=o}),I(ht,"getVisibleGaps",()=>ht.visibleGaps),I(ht,"destroy",()=>{ht.referenceSnapPoints=null,ht.visibleGaps=null});var Wt=ht,fr=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,Uo=({event:e,app:o,selectedElements:t})=>e?o.state.activeTool.type!=="lasso"&&(o.state.objectsSnapModeEnabled&&!e[gw.CTRL_OR_CMD]||!o.state.objectsSnapModeEnabled&&e[gw.CTRL_OR_CMD]&&!fr(o)):t.length===1&&t[0].type==="arrow"?!1:o.state.objectsSnapModeEnabled,t_=(e,o,t=.01)=>Math.abs(e-o)<=t,Qa=(e,o,{omitCenter:t,boundingBoxCorners:r,dragOffset:n}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[l,s,c,d,m,p]=JD(a,o);n&&(l+=n.x,c+=n.x,m+=n.x,s+=n.y,d+=n.y,p+=n.y);let u=(c-l)/2,f=(d-s)/2;if((a.type==="diamond"||a.type==="ellipse")&&!r){let b=gr(z(l,s+f),z(m,p),a.angle),x=gr(z(l+u,s),z(m,p),a.angle),w=gr(z(c,s+f),z(m,p),a.angle),E=gr(z(l+u,d),z(m,p),a.angle),y=z(m,p);i=t?[b,x,w,E]:[b,x,w,E,y]}else{let b=gr(z(l,s),z(m,p),a.angle),x=gr(z(c,s),z(m,p),a.angle),w=gr(z(l,d),z(m,p),a.angle),E=gr(z(c,d),z(m,p),a.angle),y=z(m,p);i=t?[b,x,w,E]:[b,x,w,E,y]}}else if(e.length>1){let[a,l,s,c]=Mh(e,n??{x:0,y:0}),d=s-a,m=c-l,p=z(a,l),u=z(s,l),f=z(a,c),b=z(s,c),x=z(a+d/2,l+m/2);i=t?[p,u,f,b]:[p,u,f,b,x]}return i.map(a=>z(Le(a[0]),Le(a[1])))},vw=(e,o,t,r)=>ww(e,o,t,r),Tw=(e,o,t,r)=>{let n=vw(e,o,t,r),i=yw(n,r).filter(m=>!(m.length===1&&Ew(m[0]))).map(m=>kh(m).map(p=>Le(p))),a=i.sort((m,p)=>m[0]-p[0]),l=[],s=0;e:for(let m=0;m<a.length;m++){let p=a[m];for(let u=m+1;u<a.length;u++){if(++s>fw)break e;let f=a[u],[,b,x,w]=p,[E,y,,v]=f;x<E&&Kc(Yt(b,w),Yt(y,v))&&l.push({startBounds:p,endBounds:f,startSide:[z(x,b),z(x,w)],endSide:[z(E,y),z(E,v)],length:E-x,overlap:Xc(Yt(b,w),Yt(y,v))})}}let c=i.sort((m,p)=>m[1]-p[1]),d=[];s=0;e:for(let m=0;m<c.length;m++){let p=c[m];for(let u=m+1;u<c.length;u++){if(++s>fw)break e;let f=c[u],[b,,x,w]=p,[E,y,v]=f;w<y&&Kc(Yt(b,x),Yt(E,v))&&d.push({startBounds:p,endBounds:f,startSide:[z(b,w),z(x,w)],endSide:[z(E,y),z(v,y)],length:y-w,overlap:Xc(Yt(b,x),Yt(E,v))})}}return{horizontalGaps:l,verticalGaps:d}},bw=(e,o,t,r,n,i,a)=>{if(!Uo({app:t,event:r,selectedElements:e}))return[];if(e.length===0)return[];let l=Wt.getVisibleGaps();if(l){let{horizontalGaps:s,verticalGaps:c}=l,[d,m,p,u]=Mh(e,o).map(x=>Le(x)),f=(d+p)/2,b=(m+u)/2;for(let x of s){if(!Kc(Yt(m,u),x.overlap))continue;let w=x.startSide[0][0]+x.length/2,E=Le(w-f);if(x.length>p-d&&Math.abs(E)<=a.x){Math.abs(E)<a.x&&(n.length=0),a.x=Math.abs(E);let P={type:"gap",direction:"center_horizontal",gap:x,offset:E};n.push(P);continue}let[,,v]=x.endBounds,C=d-v,S=Le(x.length-C);if(Math.abs(S)<=a.x){Math.abs(S)<a.x&&(n.length=0),a.x=Math.abs(S);let P={type:"gap",direction:"side_right",gap:x,offset:S};n.push(P);continue}let[L,,,]=x.startBounds,k=L-p,A=Le(k-x.length);if(Math.abs(A)<=a.x){Math.abs(A)<a.x&&(n.length=0),a.x=Math.abs(A);let P={type:"gap",direction:"side_left",gap:x,offset:A};n.push(P);continue}}for(let x of c){if(!Kc(Yt(d,p),x.overlap))continue;let w=x.startSide[0][1]+x.length/2,E=Le(w-b);if(x.length>u-m&&Math.abs(E)<=a.y){Math.abs(E)<a.y&&(i.length=0),a.y=Math.abs(E);let P={type:"gap",direction:"center_vertical",gap:x,offset:E};i.push(P);continue}let[,v,,]=x.startBounds,C=v-u,S=Le(C-x.length);if(Math.abs(S)<=a.y){Math.abs(S)<a.y&&(i.length=0),a.y=Math.abs(S);let P={type:"gap",direction:"side_top",gap:x,offset:S};i.push(P);continue}let[,,,L]=x.endBounds,k=Le(m-L),A=x.length-k;if(Math.abs(A)<=a.y){Math.abs(A)<a.y&&(i.length=0),a.y=Math.abs(A);let P={type:"gap",direction:"side_bottom",gap:x,offset:A};i.push(P);continue}}}},Iw=(e,o,t,r)=>{let n=vw(e,o,t,r);return yw(n,r).filter(i=>!(i.length===1&&Ew(i[0]))).flatMap(i=>Qa(i,r))},Li=(e,o,t,r,n,i,a)=>{if(!Uo({app:t,event:r,selectedElements:e})||e.length===0&&o.length===0)return[];let l=Wt.getReferenceSnapPoints();if(l)for(let s of o)for(let c of l){let d=c[0]-s[0],m=c[1]-s[1];Math.abs(d)<=a.x&&(Math.abs(d)<a.x&&(n.length=0),n.push({type:"point",points:[s,c],offset:d}),a.x=Math.abs(d)),Math.abs(m)<=a.y&&(Math.abs(m)<a.y&&(i.length=0),i.push({type:"point",points:[s,c],offset:m}),a.y=Math.abs(m))}},Cw=(e,o,t,r,n)=>{let i=t.state,a=QD(e,i);if(!Uo({app:t,event:r,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};o.x=Le(o.x),o.y=Le(o.y);let l=[],s=[],c=Zc(i.zoom.value),d={x:c,y:c},m=Qa(a,n,{dragOffset:o});Li(a,m,t,r,l,s,d),bw(a,o,t,r,l,s,d);let p={x:l[0]?.offset??0,y:s[0]?.offset??0};d.x=0,d.y=0,l.length=0,s.length=0;let u={x:Le(o.x+p.x),y:Le(o.y+p.y)};Li(a,Qa(a,n,{dragOffset:u}),t,r,l,s,d),bw(a,u,t,r,l,s,d);let f=Lh(l,s),b=r_(a,u,[...l,...s].filter(x=>x.type==="gap"));return{snapOffset:p,snapLines:[...f,...b]}},Le=e=>Math.round(e*10**6)/10**6,xw=e=>{let o=new Map;for(let t of e){let r=t.join(",");o.has(r)||o.set(r,t)}return Array.from(o.values())},Lh=(e,o)=>{let t={},r={};if(e.length>0){for(let n of e)if(n.type==="point"){let i=Le(n.points[0][0]);t[i]||(t[i]=[]),t[i].push(...n.points.map(a=>z(Le(a[0]),Le(a[1]))))}}if(o.length>0){for(let n of o)if(n.type==="point"){let i=Le(n.points[0][1]);r[i]||(r[i]=[]),r[i].push(...n.points.map(a=>z(Le(a[0]),Le(a[1]))))}}return Object.entries(t).map(([n,i])=>({type:"points",points:xw(i.map(a=>z(Number(n),a[1])).sort((a,l)=>a[1]-l[1]))})).concat(Object.entries(r).map(([n,i])=>({type:"points",points:xw(i.map(a=>z(a[0],Number(n))).sort((a,l)=>a[0]-l[0]))})))},o_=e=>{let o=new Map;for(let t of e){let r=t.points.flat().map(n=>[Le(n)]).join(",");o.has(r)||o.set(r,t)}return Array.from(o.values())},r_=(e,o,t)=>{let[r,n,i,a]=Mh(e,o),l=[];for(let s of t){let[c,d,m,p]=s.gap.startBounds,[u,f,b,x]=s.gap.endBounds,w=Xc(Yt(n,a),s.gap.overlap),E=Xc(Yt(r,i),s.gap.overlap);switch(s.direction){case"center_horizontal":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[z(s.gap.startSide[0][0],y),z(r,y)]},{type:"gap",direction:"horizontal",points:[z(i,y),z(s.gap.endSide[0][0],y)]})}break}case"center_vertical":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[z(y,s.gap.startSide[0][1]),z(y,n)]},{type:"gap",direction:"vertical",points:[z(y,a),z(y,s.gap.endSide[0][1])]})}break}case"side_right":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[z(m,y),z(u,y)]},{type:"gap",direction:"horizontal",points:[z(b,y),z(r,y)]})}break}case"side_left":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[z(i,y),z(c,y)]},{type:"gap",direction:"horizontal",points:[z(m,y),z(u,y)]})}break}case"side_top":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[z(y,a),z(y,d)]},{type:"gap",direction:"vertical",points:[z(y,p),z(y,f)]})}break}case"side_bottom":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[z(y,p),z(y,f)]},{type:"gap",direction:"vertical",points:[z(y,x),z(y,n)]})}break}}}return o_(l.map(s=>({...s,points:s.points.map(c=>z(Le(c[0]),Le(c[1])))})))},Ph=(e,o,t,r,n,i)=>{if(!Uo({event:r,selectedElements:e,app:t})||e.length===0||e.length===1&&!t_(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,l,s,c]=kh(o);i&&(i.includes("e")?s+=n.x:i.includes("w")&&(a+=n.x),i.includes("n")?l+=n.y:i.includes("s")&&(c+=n.y));let d=[];if(i)switch(i){case"e":{d.push(z(s,l),z(s,c));break}case"w":{d.push(z(a,l),z(a,c));break}case"n":{d.push(z(a,l),z(s,l));break}case"s":{d.push(z(a,c),z(s,c));break}case"ne":{d.push(z(s,l));break}case"nw":{d.push(z(a,l));break}case"se":{d.push(z(s,c));break}case"sw":{d.push(z(a,c));break}}let m=Zc(t.state.zoom.value),p={x:m,y:m},u=[],f=[];Li(o,d,t,r,u,f,p);let b={x:u[0]?.offset??0,y:f[0]?.offset??0};p.x=0,p.y=0,u.length=0,f.length=0;let[x,w,E,y]=kh(e).map(S=>Le(S)),v=[z(x,w),z(x,y),z(E,w),z(E,y)];Li(e,v,t,r,u,f,p);let C=Lh(u,f);return{snapOffset:b,snapLines:C}},Sw=(e,o,t,r,n,i)=>{if(!Uo({event:t,selectedElements:[e],app:o}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[z(r.x+n.x,r.y+n.y)],l=Zc(o.state.zoom.value),s={x:l,y:l},c=[],d=[];Li([e],a,o,t,c,d,s);let m={x:c[0]?.offset??0,y:d[0]?.offset??0};s.x=0,s.y=0,c.length=0,d.length=0;let p=Qa([e],i,{boundingBoxCorners:!0,omitCenter:!0});Li([e],p,o,t,c,d,s);let u=Lh(c,d);return{snapOffset:m,snapLines:u}},kw=(e,o,t,r,n)=>{if(!Uo({event:r,selectedElements:[],app:o}))return{originOffset:{x:0,y:0},snapLines:[]};let i=ww(e,[],o.state,n),a=Zc(o.state.zoom.value),l={x:a,y:a},s=[],c=[];for(let d of i){let m=Qa([d],n);for(let p of m){let u=p[0]-t.x;Math.abs(u)<=Math.abs(l.x)&&(Math.abs(u)<Math.abs(l.x)&&(c.length=0),c.push({type:"pointer",points:[p,z(p[0],t.y)],direction:"vertical"}),l.x=u);let f=p[1]-t.y;Math.abs(f)<=Math.abs(l.y)&&(Math.abs(f)<Math.abs(l.y)&&(s.length=0),s.push({type:"pointer",points:[p,z(t.x,p[1])],direction:"horizontal"}),l.y=f)}}return{originOffset:{x:c.length>0?c[0].points[0][0]-t.x:0,y:s.length>0?s[0].points[0][1]-t.y:0},snapLines:[...c,...s]}},Mw=e=>e===rn.rectangle||e===rn.ellipse||e===rn.diamond||e===rn.frame||e===rn.magicframe||e===rn.image||e===rn.text;import{pointFrom as $c}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as n_,DEFAULT_FONT_SIZE as i_,TEXT_ALIGN as a_,VERTICAL_ALIGN as l_,getSizeFromPoints as s_,randomId as c_,arrayToMap as d_,assertNever as Ah,cloneJSON as Aw,getFontString as m_,isDevEnv as p_,toBrandedType as u_,getLineHeight as h_}from"@excalidraw/common";import{bindLinearElement as Lw}from"@excalidraw/element";import{newArrowElement as g_,newElement as Dh,newFrameElement as f_,newImageElement as b_,newLinearElement as x_,newMagicFrameElement as E_,newTextElement as qc}from"@excalidraw/element";import{measureText as y_,normalizeText as w_}from"@excalidraw/element";import{isArrowElement as v_}from"@excalidraw/element";import{syncInvalidIndices as T_}from"@excalidraw/element";import{redrawTextBoundingBox as I_}from"@excalidraw/element";import{LinearElementEditor as C_}from"@excalidraw/element";import{getCommonBounds as S_}from"@excalidraw/element";import{Scene as k_}from"@excalidraw/element";var jc={width:100,height:0},br=100,M_=(e,o,t)=>{let r=qc({x:0,y:0,textAlign:a_.CENTER,verticalAlign:l_.MIDDLE,...o,containerId:e.id,strokeColor:o.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:r.id})}),I_(r,e,t),[e,r]},Pw=(e,o,t,r,n)=>{let i,a;if(Object.assign(e,{startBinding:e?.startBinding||null,endBinding:e.endBinding||null}),o){let d=o?.width??br,m=o?.height??br,p;o.id&&(p=r.getElement(o.id),p||console.error(`No element for start binding with id ${o.id} found`));let u=o.x||e.x-d,f=o.y||e.y-m/2,b=p?p.type:o.type;if(b){if(b==="text"){let x="";p&&p.type==="text"?x=p.text:o.type==="text"&&(x=o.text),x||console.error(`No text found for start binding text element for ${e.id}`),i=qc({x:u,y:f,type:"text",...p,...o,text:x}),Object.assign(i,{x:o.x||e.x-i.width,y:o.y||e.y-i.height/2})}else switch(b){case"rectangle":case"ellipse":case"diamond":{i=Dh({x:u,y:f,width:d,height:m,...p,...o,type:b});break}default:Ah(e,`Unhandled element start type "${o.type}"`,!0)}Lw(e,i,"start",n)}}if(t){let d=t?.height??br,m=t?.width??br,p;t.id&&(p=r.getElement(t.id),p||console.error(`No element for end binding with id ${t.id} found`));let u=t.x||e.x+e.width,f=t.y||e.y-d/2,b=p?p.type:t.type;if(b){if(b==="text"){let x="";p&&p.type==="text"?x=p.text:t.type==="text"&&(x=t.text),x||console.error(`No text found for end binding text element for ${e.id}`),a=qc({x:u,y:f,type:"text",...p,...t,text:x}),Object.assign(a,{y:t.y||e.y-a.height/2})}else switch(b){case"rectangle":case"ellipse":case"diamond":{a=Dh({x:u,y:f,width:m,height:d,...p,...t,type:b});break}default:Ah(e,`Unhandled element end type "${b}"`,!0)}Lw(e,a,"end",n)}}if(e.points.length<2)return{linearElement:e,startBoundElement:i,endBoundElement:a};let l=e.points.length-1,s=.5,c=Aw(e.points);return e.points[l][0]>e.points[l-1][0]&&(c[0][0]=s,c[l][0]-=s),e.points[l][0]<e.points[l-1][0]&&(c[0][0]=-s,c[l][0]+=s),e.points[l][1]>e.points[l-1][1]&&(c[0][1]=s,c[l][1]-=s),e.points[l][1]<e.points[l-1][1]&&(c[0][1]=-s,c[l][1]+=s),Object.assign(e,C_.getNormalizeElementPointsAndCoords({...e,points:c})),{linearElement:e,startBoundElement:i,endBoundElement:a}},_h=class{constructor(){I(this,"excalidrawElements",new Map);I(this,"add",o=>{o&&this.excalidrawElements.set(o.id,o)});I(this,"getElements",()=>T_(Array.from(this.excalidrawElements.values())));I(this,"getElementsMap",()=>u_(d_(this.getElements())));I(this,"getElement",o=>this.excalidrawElements.get(o))}},Pi=(e,o)=>{if(!e)return[];let t=Aw(e),r=new _h,n=new Map,i=new Map;for(let s of t){let c,d=s.id;switch(o?.regenerateIds!==!1&&Object.assign(s,{id:c_()}),s.type){case"rectangle":case"ellipse":case"diamond":{let p=s?.label?.text&&s.width===void 0?0:s?.width||br,u=s?.label?.text&&s.height===void 0?0:s?.height||br;c=Dh({...s,width:p,height:u});break}case"line":{let p=s.width||jc.width,u=s.height||jc.height;c=x_({width:p,height:u,points:[$c(0,0),$c(p,u)],...s});break}case"arrow":{let p=s.width||jc.width,u=s.height||jc.height;c=g_({width:p,height:u,endArrowhead:"arrow",points:[$c(0,0),$c(p,u)],...s,type:"arrow"}),Object.assign(c,s_(c.points));break}case"text":{let p=s?.fontFamily||n_,u=s?.fontSize||i_,f=s?.lineHeight||h_(p),b=s.text??"",x=w_(b),w=y_(x,m_({fontFamily:p,fontSize:u}),f);c=qc({width:w.width,height:w.height,fontFamily:p,fontSize:u,...s});break}case"image":{c=b_({width:s?.width||br,height:s?.height||br,...s});break}case"frame":{c=f_({x:0,y:0,...s});break}case"magicframe":{c=E_({x:0,y:0,...s});break}case"freedraw":case"iframe":case"embeddable":{c=s;break}default:c=s,Ah(s,`Unhandled element type "${s.type}"`,!0)}r.getElement(c.id)?console.error(`Duplicate id found for ${c.id}`):(r.add(c),n.set(c.id,s),d&&i.set(d,c.id))}let a=r.getElementsMap(),l=new k_(a);for(let[s,c]of n){let d=r.getElement(s);switch(c.type){case"rectangle":case"ellipse":case"diamond":case"arrow":{if(c.label?.text){let[m,p]=M_(d,c?.label,l);if(r.add(m),r.add(p),v_(m)){let u=c.type==="arrow"?c?.start:void 0,f=c.type==="arrow"?c?.end:void 0;if(u&&u.id){let E=i.get(u.id);E&&Object.assign(u,{id:E})}if(f&&f.id){let E=i.get(f.id);E&&Object.assign(f,{id:E})}let{linearElement:b,startBoundElement:x,endBoundElement:w}=Pw(m,u,f,r,l);m=b,r.add(b),r.add(x),r.add(w)}}else switch(c.type){case"arrow":{let{start:m,end:p}=c;if(m&&m.id){let x=i.get(m.id);Object.assign(m,{id:x})}if(p&&p.id){let x=i.get(p.id);Object.assign(p,{id:x})}let{linearElement:u,startBoundElement:f,endBoundElement:b}=Pw(d,m,p,r,l);r.add(u),r.add(f),r.add(b);break}}break}}}for(let[s,c]of n){if(c.type!=="frame"&&c.type!=="magicframe")continue;let d=r.getElement(s);if(!d)throw new Error(`Excalidraw element with id ${s} doesn't exist`);let m=[];c.children.forEach(C=>{let S=i.get(C);if(!S)throw new Error(`Element with ${C} wasn't mapped correctly`);let L=r.getElement(S);if(!L)throw new Error(`Frame element with id ${S} doesn't exist`);Object.assign(L,{frameId:d.id}),L?.boundElements?.forEach(k=>{let A=r.getElement(k.id);if(!A)throw new Error(`Bound element with id ${k.id} doesn't exist`);Object.assign(A,{frameId:d.id}),m.push(A)}),m.push(L)});let[p,u,f,b]=S_(m),x=10;p=p-x,u=u-x,f=f+x,b=b+x;let w=d?.x||p,E=d?.y||u,y=d?.width||f-p,v=d?.height||b-u;Object.assign(d,{x:w,y:E,width:y,height:v}),p_()&&c.children.length&&(d?.x||d?.y||d?.width||d?.height)&&console.info("User provided frame attributes are being considered, if you find this inaccurate, please remove any of the attributes - x, y, width and height so frame coordinates and dimensions are calculated automatically")}return r.getElements()};import{isElementInViewport as nR}from"@excalidraw/element";import{memoize as iR,toBrandedType as aR}from"@excalidraw/common";import{pointFrom as B_,pointsEqual as F_}from"@excalidraw/math";import Qc from"open-color";import{arrayToMap as O_,DEFAULT_TRANSFORM_HANDLE_SPACING as Gh,FRAME_STYLE as Ow,invariant as zw,THEME as z_,throttleRAF as H_}from"@excalidraw/common";import{FIXED_BINDING_DISTANCE as Nh,maxBindingGap as Vw}from"@excalidraw/element";import{LinearElementEditor as xr}from"@excalidraw/element";import{getOmitSidesForDevice as Bh,getTransformHandles as G_,getTransformHandlesFromCoords as U_,shouldShowBoundingBox as Y_}from"@excalidraw/element";import{isElbowArrow as el,isFrameLikeElement as Hw,isImageElement as Gw,isLinearElement as W_,isLineElement as V_,isTextElement as Uw}from"@excalidraw/element";import{renderSelectionElement as X_}from"@excalidraw/element";import{getElementsInGroup as zh,getSelectedGroupIds as K_,isSelectedViaGroup as Z_,selectGroupsFromGivenElements as $_}from"@excalidraw/element";import{getCommonBounds as Hh,getElementAbsoluteCoords as tl}from"@excalidraw/element";import{pointFrom as dt}from"@excalidraw/math";import{THEME as L_}from"@excalidraw/common";var P_="#ff6b6b",A_="#ff0000",Dw=1,_w=2,Rw=(e,o)=>{if(!o.snapLines.length)return;let t=o.theme===L_.LIGHT||o.zenModeEnabled?P_:A_,r=(o.zenModeEnabled?Dw*1.5:Dw)/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY);for(let n of o.snapLines)n.type==="pointer"?(e.lineWidth=r,e.strokeStyle=t,__(n,e,o)):n.type==="gap"?(e.lineWidth=r,e.strokeStyle=t,R_(n.points[0],n.points[1],n.direction,o,e)):n.type==="points"&&(e.lineWidth=r,e.strokeStyle=t,D_(n,e,o));e.restore()},D_=(e,o,t)=>{if(!t.zenModeEnabled){let r=e.points[0],n=e.points[e.points.length-1];Vt(r,n,o)}for(let r of e.points)Nw(r,t,o)},__=(e,o,t)=>{Nw(e.points[0],t,o),t.zenModeEnabled||Vt(e.points[0],e.points[1],o)},Nw=([e,o],t,r)=>{r.save();let n=(t.zenModeEnabled?_w*1.5:_w)/t.zoom.value;r.beginPath(),r.moveTo(e-n,o-n),r.lineTo(e+n,o+n),r.moveTo(e+n,o-n),r.lineTo(e-n,o+n),r.stroke(),r.restore()},Vt=(e,o,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(o[0],o[1]),t.stroke()},R_=(e,o,t,r,n)=>{let i=8/r.zoom.value,a=i/2,l=i/4;if(t==="horizontal"){let s=[(e[0]+o[0])/2,e[1]];r.zenModeEnabled||Vt(dt(e[0],e[1]-i),dt(e[0],e[1]+i),n),Vt(dt(s[0]-l,s[1]-a),dt(s[0]-l,s[1]+a),n),Vt(dt(s[0]+l,s[1]-a),dt(s[0]+l,s[1]+a),n),r.zenModeEnabled||(Vt(dt(o[0],o[1]-i),dt(o[0],o[1]+i),n),Vt(e,o,n))}else{let s=[e[0],(e[1]+o[1])/2];r.zenModeEnabled||Vt(dt(e[0]-i,e[1]),dt(e[0]+i,e[1]),n),Vt(dt(s[0]-a,s[1]-l),dt(s[0]+a,s[1]-l),n),Vt(dt(s[0]-a,s[1]+l),dt(s[0]+a,s[1]+l),n),r.zenModeEnabled||(Vt(dt(o[0]-i,o[1]),dt(o[0]+i,o[1]),n),Vt(e,o,n))}};import{getGlobalCSSVariable as Jc}from"@excalidraw/common";import{getCommonBounds as N_}from"@excalidraw/element";var lo=4,kt=6,Bw="rgba(0,0,0,0.3)",Fw=(e,o,t,r)=>{if(!e.size)return{horizontal:null,vertical:null};let[n,i,a,l]=N_(e),s=o/r.zoom.value,c=t/r.zoom.value,d={top:parseInt(Jc("sat"))||0,bottom:parseInt(Jc("sab"))||0,left:parseInt(Jc("sal"))||0,right:parseInt(Jc("sar"))||0},m=Po().rtl,p=-r.scrollX+d.left,u=-r.scrollY+d.top,f=p+s-d.right,b=u+c-d.bottom,x=Math.min(n,p),w=Math.min(i,u),E=Math.max(a,f),y=Math.max(l,b),v=a-n,C=l-i,S=E-x,L=y-w,k=Math.max(lo*2,d.left+d.right)+kt*2,A=o*(s/S)-k,P=Math.max(lo*2,d.top+d.bottom)+kt*2,B=t*(c/L)-P,O=S>v?S*r.zoom.value/(A+k):o/(A+k),G=L>C?L*r.zoom.value/(B+P):t/(B+P);return{horizontal:p===x&&f===E?null:{x:Math.max(d.left,lo)+kt+(p-x)/S*o,y:t-kt-Math.max(lo,d.bottom),width:A,height:kt,deltaMultiplier:O},vertical:u===w&&b===y?null:{x:m?Math.max(d.left,lo):o-kt-Math.max(d.right,lo),y:Math.max(d.top,lo)+kt+(u-w)/L*t,width:kt,height:B,deltaMultiplier:G}}},Rh=(e,o,t)=>{let[r,n]=[e.horizontal,e.vertical].map(a=>a!=null&&a.x<=o&&o<=a.x+a.width&&a.y<=t&&t<=a.y+a.height);return{isOverEither:r||n,isOverHorizontal:r,isOverVertical:n}};var j_=(e,o)=>{zw(o.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=o.selectedLinearElement;zw(t,"midPointCoords is null"),e.save(),e.translate(o.scrollX,o.scrollY),Xw(t,e,o),e.restore()},q_=(e,o,t)=>{let{elementId:r,hoverPointIndex:n}=o.selectedLinearElement;if(o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(n))return;let i=xr.getElement(r,t);if(!i)return;let a=xr.getPointAtIndexGlobalCoordinates(i,n,t);e.save(),e.translate(o.scrollX,o.scrollY),Xw(a,e,o),e.restore()},Xw=(e,o,t)=>{o.fillStyle="rgba(105, 101, 219, 0.4)",qi(o,e[0],e[1],xr.POINT_HANDLE_SIZE/t.zoom.value,!1)},Fh=(e,o,t,r,n,i,a)=>{e.strokeStyle="#5e5ad8",e.setLineDash([]),e.fillStyle="rgba(255, 255, 255, 0.9)",n?e.fillStyle="rgba(134, 131, 226, 0.9)":i&&(e.fillStyle="rgba(177, 151, 252, 0.7)"),qi(e,t[0],t[1],(a?r*(o.selectedLinearElement?.isEditing?1.5:2):r)/o.zoom.value,!i,!a||n)},J_=(e,o,t,r)=>{let n=Vw(o,o.width,o.height,r);switch(e.fillStyle="rgba(0,0,0,.05)",o.type){case"rectangle":case"text":case"image":case"iframe":case"embeddable":case"frame":case"magicframe":o1(e,o,t,n);break;case"diamond":n1(e,n,o,t);break;case"ellipse":{let[i,a,l,s]=tl(o,t),c=l-i,d=s-a;e.strokeStyle="rgba(0,0,0,.05)",e.lineWidth=n-Nh,r1(e,c+n+Nh,d+n+Nh,i+c/2,a+d/2,o.angle);break}}},Q_=(e,o,t,r)=>{let[n,i,a]=o,l=Vw(a,a.width,a.height,r);e.strokeStyle="rgba(0,0,0,0)",e.fillStyle="rgba(0,0,0,.05)",(i==="both"?[0,-1]:i==="start"?[0]:[-1]).forEach(c=>{let[d,m]=xr.getPointAtIndexGlobalCoordinates(n,c,t);qi(e,d,m,l,!0)})},Kw=(e,o,t)=>{let{angle:r,x1:n,y1:i,x2:a,y2:l,selectionColors:s,cx:c,cy:d,dashed:m,activeEmbeddable:p}=t,u=a-n,f=l-i,x=(t.padding??Gh*2)/o.zoom.value,w=8/o.zoom.value,E=4/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=(p?4:1)/o.zoom.value;let y=s.length;for(let v=0;v<y;++v)e.strokeStyle=s[v],m&&e.setLineDash([w,E+(w+E)*(y-1)]),e.lineDashOffset=(w+E)*v,Ji(e,n-x,i-x,u+x*2,f+x*2,c,d,r);e.restore()},eR=(e,o,t,r)=>{let n=Array.isArray(t)?Q_:J_;e.save(),e.translate(o.scrollX,o.scrollY),n(e,t,r,o.zoom),e.restore()},tR=(e,o,t,r)=>{let[n,i,a,l]=tl(t,r),s=a-n,c=l-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=Ow.strokeWidth/o.zoom.value,e.save(),e.translate(o.scrollX,o.scrollY),Ji(e,n,i,s,c,n+s/2,i+c/2,t.angle,!1,Ow.radius/o.zoom.value),e.restore()},Yw=(e,o,t,r)=>{let{colors:n=["rgb(0,118,255)"],dashed:i=!1}=r||{},a=t.filter(d=>d.groupIds.length===0),l=t.filter(d=>d.groupIds.length>0),s=d=>{let[m,p,u,f]=Hh(d);return{angle:0,x1:m,x2:u,y1:p,y2:f,selectionColors:n,dashed:i,cx:m+(u-m)/2,cy:p+(f-p)/2,activeEmbeddable:!1}},c=d=>{let m=zh(t,d);return s(m)};Object.entries($_(l,o)).filter(([d,m])=>m).map(([d,m])=>d).map(d=>c(d)).concat(a.map(d=>s([d]))).forEach(d=>Kw(e,o,d))},Oh=(e,o,t,r)=>{if(!o.selectedLinearElement)return;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=1/o.zoom.value;let n=xr.getPointsGlobalCoordinates(t,r),{POINT_HANDLE_SIZE:i}=xr,a=o.selectedLinearElement?.isEditing?i:i/2,l=el(t),s=V_(t);if(n.forEach((c,d)=>{if(l&&d!==0&&d!==n.length-1)return;let m=d>0&&(d!==n.length-1||!s||!t.polygon)&&F_(c,d===n.length-1?n[0]:n[d-1],2/o.zoom.value),p=!!o.selectedLinearElement?.isEditing&&!!o.selectedLinearElement?.selectedPointsIndices?.includes(d);s&&t.polygon&&!p&&d===t.points.length-1&&o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(p=!0),Fh(e,o,c,a,p,!1,m)}),el(t)){let c=t.fixedSegments?.map(d=>d.index)||[];n.slice(0,-1).forEach((d,m)=>{xr.isSegmentTooShort(t,n[m+1],n[m],m,o.zoom)||Fh(e,o,B_((d[0]+n[m+1][0])/2,(d[1]+n[m+1][1])/2),i/2,!1,!c.includes(m+1),!1)})}else xr.getEditorMidPoints(t,r,o).filter((d,m,p)=>d!==null&&!(el(t)&&(m===0||m===p.length-1))).forEach(d=>{(o.selectedLinearElement?.isEditing||n.length===2)&&Fh(e,o,d,i/2,!1,!0,!1)});e.restore()},Ww=(e,o,t,r,n)=>{Object.keys(r).forEach(i=>{let a=r[i];if(a!==void 0){let[l,s,c,d]=a;e.save(),e.lineWidth=1/t.zoom.value,o.selectionColor&&(e.strokeStyle=o.selectionColor),i==="rotation"?qi(e,l+c/2,s+d/2,c/2,!0):e.roundRect?(e.beginPath(),e.roundRect(l,s,c,d,2/t.zoom.value),e.fill(),e.stroke()):Ji(e,l,s,c,d,l+c/2,s+d/2,n,!0),e.restore()}})},oR=(e,o,t,r,n)=>{let[i,a,,,l,s]=tl(r,n),c=3,d=20,m=c/t.zoom.value,p=m/2,u=l-i+m,f=s-a+m,b=Math.min(d/t.zoom.value,u),x=Math.min(d/t.zoom.value,f);e.save(),e.fillStyle=o.selectionColor,e.strokeStyle=o.selectionColor,e.lineWidth=m,[[[-u,-f],[0,p],[b,p],[p,0],[p,x]],[[u-p,-f],[p,p],[-b+p,p],[0,0],[0,x]],[[-u,f],[0,-p],[b,-p],[p,0],[p,-x]],[[u-p,f],[p,-p],[-b+p,-p],[0,0],[0,-x]]].forEach(E=>{let[[y,v],[C,S],[L,k],[A,P],[B,O]]=E;e.save(),e.translate(l,s),e.rotate(r.angle),e.beginPath(),e.moveTo(y+C,v+S),e.lineTo(y+L,v+k),e.stroke(),e.beginPath(),e.moveTo(y+A,v+P),e.lineTo(y+B,v+O),e.stroke(),e.restore()}),e.restore()},rR=(e,o,t,r)=>{o.save();let n=Gh*2/t.zoom.value,i=e.width+n*2,a=e.height+n*2,l=e.x+i/2,s=e.y+a/2,c=-(i/2+n),d=-(a/2+n);o.translate(l+t.scrollX,s+t.scrollY),o.rotate(e.angle),o.lineWidth=1/t.zoom.value,o.strokeStyle=r,o.strokeRect(c,d,i,a),o.restore()},Zw=({canvas:e,elementsMap:o,visibleElements:t,selectedElements:r,allElementsMap:n,scale:i,appState:a,renderConfig:l,device:s})=>{if(e===null)return{atLeastOneVisibleElement:!1,elementsMap:o};let[c,d]=Fl(e,i),m=Ol({canvas:e,scale:i,normalizedWidth:c,normalizedHeight:d});m.save(),m.scale(a.zoom.value,a.zoom.value);let p;if(t.forEach(b=>{a.selectedLinearElement?.isEditing&&a.selectedLinearElement.elementId===b.id&&b&&(p=b)}),p&&Oh(m,a,p,o),a.selectionElement&&!a.isCropping)try{X_(a.selectionElement,m,a,l.selectionColor)}catch(b){console.error(b)}if(a.editingTextElement&&Uw(a.editingTextElement)){let b=n.get(a.editingTextElement.id);b&&!b.autoResize&&rR(b,m,a,l.selectionColor)}if(a.isBindingEnabled&&a.suggestedBindings.filter(b=>b!=null).forEach(b=>{eR(m,a,b,o)}),a.frameToHighlight&&tR(m,a,a.frameToHighlight,o),a.elementsToHighlight&&Yw(m,a,a.elementsToHighlight),a.activeLockedId){let b=n.get(a.activeLockedId),x=b?[b]:zh(n,a.activeLockedId);Yw(m,a,x,{colors:["#ced4da"],dashed:!0})}let u=r.some(b=>Hw(b));if(r.length===1&&a.selectedLinearElement?.isEditing&&a.selectedLinearElement.elementId===r[0].id&&Oh(m,a,r[0],o),a.selectedLinearElement){let b=a.selectedLinearElement,x=r.find(w=>w.id===b.elementId);b.segmentMidPointHoveredCoords?j_(m,a):(el(x)?b.hoverPointIndex===0||b.hoverPointIndex===x.points.length-1:b.hoverPointIndex>=0)&&q_(m,a,o)}if(!a.multiElement&&!a.selectedLinearElement?.isEditing){let b=Y_(r,a),x=r.length===1&&W_(r[0]);x&&a.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&Oh(m,a,r[0],o);let w=l.selectionColor||Qc.black;if(b){let E=O_(r),y=[];for(let C of o.values()){let S=[],L=l.remoteSelectedElementIds.get(C.id);if(x&&el(C)&&(C.startBinding||C.endBinding)||(E.has(C.id)&&!Z_(a,C)&&S.push(w),L&&S.push(...L.map(k=>qr(k,a.collaborators.get(k))))),S.length){let[k,A,P,B,O,G]=tl(C,o,!0);y.push({angle:C.angle,x1:k,y1:A,x2:P,y2:B,selectionColors:C.locked?["#ced4da"]:S,dashed:!!L||C.locked,cx:O,cy:G,activeEmbeddable:a.activeEmbeddable?.element===C&&a.activeEmbeddable.state==="active",padding:C.id===a.croppingElementId||Gw(C)?0:void 0})}}let v=C=>{let S=zh(o,C),[L,k,A,P]=Hh(S);y.push({angle:0,x1:L,x2:A,y1:k,y2:P,selectionColors:S.some(B=>B.locked)?["#ced4da"]:[Qc.black],dashed:!0,cx:L+(A-L)/2,cy:k+(P-k)/2,activeEmbeddable:!1})};for(let C of K_(a))v(C);a.editingGroupId&&v(a.editingGroupId),y.forEach(C=>Kw(m,a,C))}if(m.save(),m.translate(a.scrollX,a.scrollY),r.length===1){m.fillStyle=Qc.white;let E=G_(r[0],a.zoom,o,"mouse",Bh(s));if(!a.viewModeEnabled&&b&&!Uw(a.editingTextElement)&&!a.croppingElementId&&Ww(m,l,a,E,r[0].angle),a.croppingElementId&&!a.isCropping){let y=o.get(a.croppingElementId);y&&Gw(y)&&oR(m,l,a,y,o)}}else if(r.length>1&&!a.isRotating&&!r.some(E=>E.locked)){let E=Gh*2/a.zoom.value;m.fillStyle=Qc.white;let[y,v,C,S]=Hh(r,o),L=m.getLineDash();m.setLineDash([2/a.zoom.value]);let k=m.lineWidth;m.lineWidth=1/a.zoom.value,m.strokeStyle=w,Ji(m,y-E,v-E,C-y+E*2,S-v+E*2,(y+C)/2,(v+S)/2,0),m.lineWidth=k,m.setLineDash(L);let A=U_([y,v,C,S,(y+C)/2,(v+S)/2],0,a.zoom,"mouse",u?{...Bh(s),rotation:!0}:Bh(s));r.some(P=>!P.locked)&&Ww(m,l,a,A,0)}m.restore()}a.searchMatches?.matches.forEach(({id:b,focus:x,matchedLines:w})=>{let E=o.get(b);if(E){let[y,v,,,C,S]=tl(E,o,!0);m.save(),a.theme===z_.LIGHT?x?m.fillStyle="rgba(255, 124, 0, 0.4)":m.fillStyle="rgba(255, 226, 0, 0.4)":x?m.fillStyle="rgba(229, 82, 0, 0.4)":m.fillStyle="rgba(99, 52, 0, 0.4)";let L=Hw(E)?a.zoom.value:1;m.translate(a.scrollX,a.scrollY),m.translate(C,S),m.rotate(E.angle),w.forEach(k=>{(k.showOnCanvas||x)&&m.fillRect(y+k.offsetX/L-C,v+k.offsetY/L-S,k.width/L,k.height/L)}),m.restore()}}),Rw(m,a),m.restore(),cE({context:m,renderConfig:l,appState:a,normalizedWidth:c,normalizedHeight:d});let f;return l.renderScrollbars&&(f=Fw(o,c,d,a),m.save(),m.fillStyle=Bw,m.strokeStyle="rgba(255,255,255,0.8)",[f.horizontal,f.vertical].forEach(b=>{b&&qs(m,b.x,b.y,b.width,b.height,kt/2)}),m.restore()),{scrollBars:f,atLeastOneVisibleElement:t.length>0,elementsMap:o}},Uh=H_(e=>{let o=Zw(e);e.callback?.(o)},{trailing:!0}),$w=(e,o)=>{if(o){Uh(e);return}let t=Zw(e);return e.callback(t),t};var ol=class{constructor(o){I(this,"scene");I(this,"getRenderableElements",(()=>{let o=({elementsMap:r,zoom:n,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s,height:c,width:d})=>{let m=[];for(let p of r.values())nR(p,d,c,{zoom:n,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s},r)&&m.push(p);return m},t=({elements:r,editingTextElement:n,newElementId:i})=>{let a=aR(new Map);for(let l of r)i!==l.id&&(!n||n.type!=="text"||l.id!==n.id)&&a.set(l.id,l);return a};return iR(({zoom:r,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:l,height:s,width:c,editingTextElement:d,newElementId:m,sceneNonce:p})=>{let u=this.scene.getNonDeletedElements(),f=t({elements:u,editingTextElement:d,newElementId:m}),b=o({elementsMap:f,zoom:r,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:l,height:s,width:c});return{elementsMap:f,visibleElements:b}})})());this.scene=o}destroy(){Uh.cancel(),a1.cancel(),this.getRenderableElements.clear()}};import{sceneCoordsToViewportCoords as lR}from"@excalidraw/common";import{getElementAbsoluteCoords as sR}from"@excalidraw/element";import{jsx as mR}from"react/jsx-runtime";var cR=5,dR=(e,o,t)=>{let[r,n]=sR(e,t),{x:i,y:a}=lR({sceneX:r+e.width,sceneY:n},o),l=i-o.offsetLeft+10,s=a-o.offsetTop;return{x:l,y:s}},Yh=({children:e,element:o,elementsMap:t})=>{let r=go();if(r.contextMenu||r.newElement||r.resizingElement||r.isRotating||r.openMenu||r.viewModeEnabled)return null;let{x:n,y:i}=dR(o,r,t);return mR("div",{className:"excalidraw-canvas-buttons",style:{top:`${i}px`,left:`${n}px`,padding:cR},children:e})};import{DEFAULT_LASER_COLOR as gR,easeOut as qw}from"@excalidraw/common";import{LaserPointer as pR}from"@excalidraw/laser-pointer";import{SVG_NS as jw,getSvgPathFromStroke as uR,sceneCoordsToViewportCoords as hR}from"@excalidraw/common";var Yo=class{constructor(o,t,r){this.animationFrameHandler=o;this.app=t;this.options=r;I(this,"currentTrail");I(this,"pastTrails",[]);I(this,"container");I(this,"trailElement");I(this,"trailAnimation");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.trailElement=document.createElementNS(jw,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(jw,"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(o,t){if(this.currentTrail){let r=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[r-1][0]===o&&this.currentTrail.originalPoints[r-1][1]===t}return!1}start(o){o&&(this.container=o),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),this.animationFrameHandler.start(this)}stop(){this.animationFrameHandler.stop(this),this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}startPath(o,t){this.currentTrail=new pR(this.options),this.currentTrail.addPoint([o,t,performance.now()]),this.update()}addPointToPath(o,t){this.currentTrail&&(this.currentTrail.addPoint([o,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 o=[];for(let r of this.pastTrails)o.push(this.drawTrail(r,this.app.state));if(this.currentTrail){let r=this.drawTrail(this.currentTrail,this.app.state);o.push(r)}this.pastTrails=this.pastTrails.filter(r=>r.getStrokeOutline().length!==0),o.length===0&&this.stop();let t=o.join(" ").trim();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))}drawTrail(o,t){let r=o.getStrokeOutline(o.options.size/t.zoom.value).map(([i,a])=>{let l=hR({sceneX:i,sceneY:a},t);return[l.x,l.y]}),n=this.trailAnimation?r.slice(0,r.length/2):r;return uR(n,!0)}};var ed=class{constructor(o,t){this.animationFrameHandler=o;this.app=t;I(this,"localTrail");I(this,"collabTrails",new Map);I(this,"container");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.localTrail=new Yo(o,t,{...this.getTrailOptions(),fill:()=>gR})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:o=>{let n=Math.max(0,1-(performance.now()-o.pressure)/1e3),i=(50-Math.min(50,o.totalLength-o.currentIndex))/50;return Math.min(qw(i),qw(n))}}}startPath(o,t){this.localTrail.startPath(o,t)}addPointToPath(o,t){this.localTrail.addPointToPath(o,t)}endPath(){this.localTrail.endPath()}start(o){this.container=o,this.animationFrameHandler.start(this),this.localTrail.start(o)}stop(){this.animationFrameHandler.stop(this),this.localTrail.stop()}onFrame(){this.updateCollabTrails()}updateCollabTrails(){if(!(!this.container||this.app.state.collaborators.size===0)){for(let[o,t]of this.app.state.collaborators.entries()){let r;this.collabTrails.has(o)?r=this.collabTrails.get(o):(r=new Yo(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>t.pointer?.laserColor||qr(o,t)}),r.start(this.container),this.collabTrails.set(o,r)),t.pointer&&t.pointer.tool==="laser"&&(t.button==="down"&&!r.hasCurrentTrail&&r.startPath(t.pointer.x,t.pointer.y),t.button==="down"&&r.hasCurrentTrail&&!r.hasLastPoint(t.pointer.x,t.pointer.y)&&r.addPointToPath(t.pointer.x,t.pointer.y),t.button==="up"&&r.hasCurrentTrail&&(r.addPointToPath(t.pointer.x,t.pointer.y),r.endPath()))}for(let o of this.collabTrails.keys())this.app.state.collaborators.has(o)||(this.collabTrails.get(o).stop(),this.collabTrails.delete(o))}}};import{version as fR}from"react";import{unstable_batchedUpdates as Jw}from"react-dom";import{throttleRAF as bR}from"@excalidraw/common";var Pe=e=>o=>{Jw(e,o)},td=e=>bR(o=>{Jw(e,o)}),Ai=(()=>{let e;try{let t=fR.split(".");e=Number(t[0])>17}catch{e=!1}let o=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(o||(o=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})();import{CODES as Wh,KEYS as rl,CLASSES as Qw,POINTER_BUTTON as xR,isWritableElement as ER,getFontString as ev,getFontFamilyString as tv,isTestEnv as ov}from"@excalidraw/common";import{originalContainerCache as yR,updateOriginalContainerCache as rv}from"@excalidraw/element";import{LinearElementEditor as wR}from"@excalidraw/element";import{bumpVersion as vR}from"@excalidraw/element";import{getBoundTextElementId as TR,getContainerElement as Vh,getTextElementAngle as IR,redrawTextBoundingBox as CR,getBoundTextMaxHeight as SR,getBoundTextMaxWidth as nv,computeContainerDimensionForBoundText as iv,computeBoundTextPosition as kR,getBoundTextElement as MR}from"@excalidraw/element";import{getTextWidth as LR}from"@excalidraw/element";import{normalizeText as av}from"@excalidraw/element";import{wrapText as PR}from"@excalidraw/element";import{isArrowElement as od,isBoundToContainer as AR,isTextElement as lv}from"@excalidraw/element";var DR=(e,o,t,r,n,i)=>{let{zoom:a}=r,l=180*t/Math.PI,s=e*(a.value-1)/2,c=o*(a.value-1)/2;return e>n&&a.value!==1&&(s=n*(a.value-1)/2),o>i&&a.value!==1&&(c=i*(a.value-1)/2),`translate(${s}px, ${c}px) scale(${a.value}) rotate(${l}deg)`},sv=({id:e,onChange:o,onSubmit:t,getViewportCoords:r,element:n,canvas:i,excalidrawContainer:a,app:l,autoSelect:s=!0})=>{let c=(_,R)=>{if(!R.style.fontFamily||!R.style.fontSize)return!1;let X=R.style.fontFamily.replace(/"/g,"");return tv({fontFamily:_.fontFamily})!==X||`${_.fontSize}px`!==R.style.fontSize},d=()=>{let _=l.state,R=l.scene.getElement(e);if(!R)return;let{textAlign:X,verticalAlign:Z}=R,Y=l.scene.getNonDeletedElementsMap();if(R&&lv(R)){let ae=R.x,de=R.y,me=Vh(R,l.scene.getNonDeletedElementsMap()),Ye=R.width,Pt=R.height,Fr=R.width,hn=R.height;if(me&&R.containerId){if(od(me)){let Xo=wR.getBoundTextElementPosition(me,R,Y);ae=Xo.x,de=Xo.y}let Dl=c(R,m),$i;if(Dl?$i=rv(me.id,me.height):($i=yR[me.id],$i||($i=rv(me.id,me.height))),Fr=nv(me,R),hn=SR(me,R),!od(me)&&Pt>hn){let Xo=iv(Pt,me.type);l.scene.mutateElement(me,{height:Xo});return}else if(!od(me)&&me.height>$i.height&&Pt<hn){let Xo=iv(Pt,me.type);l.scene.mutateElement(me,{height:Xo})}else{let{y:Xo}=kR(me,R,Y);de=Xo}}let[nm,Yf]=r(ae,de),eC=m.selectionStart,im=m.selectionEnd,Wf=m.value.length;if(eC===im&&im!==Wf){let Dl=Wf-im;m.selectionStart=m.value.length-Dl,m.selectionEnd=m.value.length-Dl}me?Ye+=.5:(Fr=(_.width-8-nm)/_.zoom.value,Ye=Math.min(Ye,Fr)),Pt*=1.05;let tC=ev(R),Vf=(_.height-Yf)/_.zoom.value;Object.assign(m.style,{font:tC,lineHeight:R.lineHeight,width:`${Ye}px`,height:`${Pt}px`,left:`${nm}px`,top:`${Yf}px`,transform:DR(Ye,Pt,IR(R,me),_,Fr,Vf),textAlign:X,verticalAlign:Z,color:R.strokeColor,opacity:R.opacity/100,filter:"var(--theme-filter)",maxHeight:`${Vf}px`}),m.scrollTop=0,ov()&&(m.style.fontFamily=tv(R)),l.scene.mutateElement(R,{x:ae,y:de})}},m=document.createElement("textarea");m.dir="auto",m.tabIndex=0,m.dataset.type="wysiwyg",m.wrap="off",m.classList.add("excalidraw-wysiwyg");let p="pre",u="normal";(AR(n)||!n.autoResize)&&(p="pre-wrap",u="break-word"),Object.assign(m.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:u,whiteSpace:p,overflowWrap:"break-word",boxSizing:"content-box"}),m.value=n.originalText,d(),o&&(m.onpaste=async _=>{let R=await Ys(_,!0);if(!R.text)return;let X=av(R.text);if(!X)return;let Z=Vh(n,l.scene.getNonDeletedElementsMap()),Y=ev({fontSize:l.state.currentItemFontSize,fontFamily:l.state.currentItemFontFamily});if(Z){let ae=MR(Z,l.scene.getNonDeletedElementsMap()),de=PR(`${m.value}${X}`,Y,nv(Z,ae)),me=LR(de,Y);m.style.width=`${me}px`}},m.oninput=()=>{let _=av(m.value);if(m.value!==_){let R=m.selectionStart;m.value=_,m.selectionStart=R,m.selectionEnd=R}o(m.value)}),m.onkeydown=_=>{if(!_.shiftKey&&_s.keyTest(_))_.preventDefault(),l.actionManager.executeAction(_s),d();else if(!_.shiftKey&&Rs.keyTest(_))_.preventDefault(),l.actionManager.executeAction(Rs),d();else if(!_.shiftKey&&Ns.keyTest(_))_.preventDefault(),l.actionManager.executeAction(Ns),d();else if(Mp.keyTest(_))l.actionManager.executeAction(Mp);else if(Lp.keyTest(_))l.actionManager.executeAction(Lp);else if(_.key===rl.ESCAPE)_.preventDefault(),C=!0,S();else if($r.keyTest(_))_.preventDefault(),S(),l.actionManager.executeAction($r);else if(_.key===rl.ENTER&&_[rl.CTRL_OR_CMD]){if(_.preventDefault(),_.isComposing||_.keyCode===229)return;C=!0,S()}else if(_.key===rl.TAB||_[rl.CTRL_OR_CMD]&&(_.code===Wh.BRACKET_LEFT||_.code===Wh.BRACKET_RIGHT)){if(_.preventDefault(),_.isComposing)return;_.shiftKey||_.code===Wh.BRACKET_LEFT?E():w(),m.dispatchEvent(new Event("input"))}};let f=4,b=" ".repeat(f),x=new RegExp(`^ {1,${f}}`),w=()=>{let{selectionStart:_,selectionEnd:R}=m,X=y(),Z=m.value;X.forEach(Y=>{let ae=Z.slice(0,Y),de=Z.slice(Y);Z=`${ae}${b}${de}`}),m.value=Z,m.selectionStart=_+f,m.selectionEnd=R+f*X.length},E=()=>{let{selectionStart:_,selectionEnd:R}=m,X=y(),Z=[],Y=m.value;X.forEach(ae=>{let de=Y.slice(ae,ae+f).match(x);if(de){let me=Y.slice(0,ae),Ye=Y.slice(ae+de[0].length);Y=`${me}${Ye}`,Z.push(ae)}}),m.value=Y,Z.length&&(_>Z[Z.length-1]?m.selectionStart=Math.max(_-f,Z[Z.length-1]):m.selectionStart=_,m.selectionEnd=Math.max(m.selectionStart,R-f*Z.length))},y=()=>{let{selectionStart:_,selectionEnd:R,value:X}=m,Z=X.slice(0,_).match(/[^\n]*$/)[0].length;return _=_-Z,X.slice(_,R).split(`
16
+ `).reduce((ae,de,me,Ye)=>ae.concat(me?ae[me-1]+Ye[me-1].length+1:_),[]).reverse()},v=_=>{_.target instanceof HTMLCanvasElement&&(_.preventDefault(),_.stopPropagation())},C=!1,S=()=>{if(G)return;G=!0,L();let _=l.scene.getElement(n.id);if(!_)return;let R=Vh(_,l.scene.getNonDeletedElementsMap());if(R){if(m.value.trim()){let X=TR(R);!X||X!==n.id?l.scene.mutateElement(R,{boundElements:(R.boundElements||[]).concat({type:"text",id:n.id})}):od(R)&&vR(R)}else l.scene.mutateElement(R,{boundElements:R.boundElements?.filter(X=>!lv(X))});CR(_,R,l.scene)}t({viaKeyboard:C,nextOriginalText:m.value})},L=()=>{m.onblur=null,m.oninput=null,m.onkeydown=null,J&&J.disconnect(),window.removeEventListener("resize",d),window.removeEventListener("wheel",v,!0),window.removeEventListener("pointerdown",P),window.removeEventListener("pointerup",k),window.removeEventListener("blur",S),window.removeEventListener("beforeunload",S),B(),O(),m.remove()},k=_=>{window.removeEventListener("pointerup",k);let R=_?.target,X=R instanceof HTMLElement&&R.classList.contains("properties-trigger");setTimeout(()=>{m.onblur=S,X||m.focus()})},A=()=>{m.onblur=null,window.addEventListener("pointerup",k),window.addEventListener("blur",S)},P=_=>{let R=_?.target;if(_.button===xR.WHEEL){R instanceof HTMLTextAreaElement&&(_.preventDefault(),l.handleCanvasPanUsingWheelOrSpaceDrag(_)),A();return}let X=R instanceof HTMLElement&&R.classList.contains("properties-trigger");(_.target instanceof HTMLElement||_.target instanceof SVGElement)&&_.target.closest(`.${Qw.SHAPE_ACTIONS_MENU}, .${Qw.ZOOM_ACTIONS}`)&&!ER(_.target)||X?A():_.target instanceof HTMLCanvasElement&&!ov()&&requestAnimationFrame(()=>{S()})},B=l.scene.onUpdate(()=>{d(),!!document.activeElement?.closest(".properties-content")||m.focus()}),O=l.onScrollChangeEmitter.on(()=>{d()}),G=!1;s&&m.select(),k();let J=null;return i&&"ResizeObserver"in window?(J=new window.ResizeObserver(()=>{d()}),J.observe(i)):window.addEventListener("resize",d),m.onpointerdown=_=>_.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",P,{capture:!0})}),window.addEventListener("beforeunload",S),a?.querySelector(".excalidraw-textEditorContainer").appendChild(m),S};var cv=e=>{let o=["flowchart","graph","sequenceDiagram","classDiagram","stateDiagram","stateDiagram-v2","erDiagram","journey","gantt","pie","quadrantChart","requirementDiagram","gitGraph","C4Context","mindmap","timeline","zenuml","sankey","xychart","block"];return new RegExp(`^(?:%%{.*?}%%[\\s\\n]*)?\\b(?:${o.map(r=>`\\s*${r}(-beta)?`).join("|")})\\b`).test(e.trim())};import{pointFrom as UR}from"@excalidraw/math";import{getElementLineSegments as YR}from"@excalidraw/element";import{LinearElementEditor as WR}from"@excalidraw/element";import{isFrameLikeElement as VR,isLinearElement as XR,isTextElement as KR}from"@excalidraw/element";import{getFrameChildren as ZR}from"@excalidraw/element";import{selectGroupsForSelectedElements as $R}from"@excalidraw/element";import{getContainerElement as jR}from"@excalidraw/element";import{arrayToMap as qR,easeOut as uv,isShallowEqual as JR}from"@excalidraw/common";import{simplify as _R}from"points-on-curve";import{polygonFromPoints as RR,lineSegment as dv,polygonIncludesPointNonZero as NR}from"@excalidraw/math";import{computeBoundTextPosition as BR,doBoundsIntersect as FR,getBoundTextElement as OR,getElementBounds as zR,intersectElementWithLineSegment as mv}from"@excalidraw/element";var pv=e=>{let{lassoPath:o,elements:t,elementsMap:r,elementsSegments:n,intersectedElements:i,enclosedElements:a,simplifyDistance:l}=e,s=o;l&&(s=_R(o,l));let c=t.filter(p=>!p.locked);a.clear(),i.clear();let d=o.reduce((p,u)=>[Math.min(p[0],u[0]),Math.min(p[1],u[1]),Math.max(p[2],u[0]),Math.max(p[3],u[1])],[1/0,1/0,-1/0,-1/0]);for(let p of c){let u=zR(p,r);FR(d,u)&&!i.has(p.id)&&!a.has(p.id)&&(HR(s,p,n)?a.add(p.id):GR(s,p,r)&&i.add(p.id))}return{selectedElementIds:[...i,...a]}},HR=(e,o,t)=>{let r=RR(e),n=t.get(o.id);return n?n.some(i=>i.some(a=>NR(a,r))):!1},GR=(e,o,t)=>{let r=e.slice(1).map((i,a)=>dv(e[a],i)).concat([dv(e[e.length-1],e[0])]),n=OR(o,t);return r.some(i=>mv(o,t,i,0,!0).length>0||!!n&&mv({...n,...BR(o,n,t)},t,i,0,!0).length>0)};var rd=class extends Yo{constructor(t,r){super(t,r,{animateTrail:!0,streamline:.4,sizeMapping:n=>{let l=Math.max(0,1-(performance.now()-n.pressure)/(1/0)),s=(5e3-Math.min(5e3,n.totalLength-n.currentIndex))/5e3;return Math.min(uv(s),uv(l))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});I(this,"intersectedElements",new Set);I(this,"enclosedElements",new Set);I(this,"elementsSegments",null);I(this,"canvasTranslate",null);I(this,"keepPreviousSelection",!1);I(this,"selectElementsFromIds",t=>{this.app.setState(r=>{let n=t.reduce((s,c)=>(s[c]=!0,s),{});if(this.keepPreviousSelection)for(let s of Object.keys(r.selectedElementIds))n[s]=!0;for(let[s]of Object.entries(n)){let c=this.app.scene.getNonDeletedElement(s);if(c&&KR(c)){let d=jR(c,this.app.scene.getNonDeletedElementsMap());d&&(n[d.id]=!0,delete n[c.id])}}for(let[s]of Object.entries(n)){let c=this.app.scene.getNonDeletedElement(s);if(c&&VR(c)){let d=ZR(this.app.scene.getNonDeletedElementsMap(),c.id);for(let m of d)delete n[m.id]}}let i=$R({editingGroupId:r.editingGroupId,selectedElementIds:n},this.app.scene.getNonDeletedElements(),r,this.app),a=[...Object.keys(i.selectedElementIds)],l=[...Object.keys(i.selectedGroupIds)];return{selectedElementIds:i.selectedElementIds,selectedGroupIds:i.selectedGroupIds,selectedLinearElement:a.length===1&&!l.length&&XR(this.app.scene.getNonDeletedElement(a[0]))?new WR(this.app.scene.getNonDeletedElement(a[0]),this.app.scene.getNonDeletedElementsMap()):null}})});I(this,"addPointToPath",(t,r,n=!1)=>{super.addPointToPath(t,r),this.keepPreviousSelection=n,this.updateSelection()});I(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(n=>UR(n[0],n[1])),r={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!JR(r,this.canvasTranslate??{})){this.canvasTranslate=r,this.elementsSegments=new Map;let n=qR(this.app.visibleElements);for(let i of this.app.visibleElements){let a=YR(i,n);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:n}=pv({lassoPath:t,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});this.selectElementsFromIds(n)}})}startPath(t,r,n=!1){this.endPath(),super.startPath(t,r),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}};import{KEYS as Xh}from"@excalidraw/common";import{jsx as QR}from"react/jsx-runtime";var hv=N({name:"smartZoom",label:"toolBar.smartZoom",trackEvent:{category:"toolbar"},icon:Um,viewMode:!0,perform:(e,o,t,r)=>{let n={fitToViewport:!0,animate:!0,duration:200,viewportZoomFactor:.8},i=$(e,o);return i.length<1?r.scrollToContent(e,n):r.scrollToContent(i,n),{captureUpdate:gv.NEVER}},keyTest:e=>!e[Xh.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===Xh.F,PanelComponent:({data:e,updateData:o})=>QR(W,{type:"button",icon:Um,"aria-label":g("labels.smartZoom"),onClick:()=>o(null),size:e?.size||"medium","data-testid":"button-smart-zoom",keyBindingLabel:Xh.F.toLocaleUpperCase()})});import{arrayToMap as e9,easeOut as fv,THEME as t9}from"@excalidraw/common";import{computeBoundTextPosition as o9,getBoundTextElement as r9,intersectElementWithLineSegment as bv,isPointInElement as n9}from"@excalidraw/element";import{lineSegment as i9,pointFrom as a9}from"@excalidraw/math";import{getElementsInGroup as xv}from"@excalidraw/element";import{shouldTestInside as l9}from"@excalidraw/element";import{hasBoundTextElement as Ev,isBoundToContainer as yv}from"@excalidraw/element";import{getBoundTextElementId as wv}from"@excalidraw/element";var nd=class extends Yo{constructor(t,r){super(t,r,{streamline:.2,size:5,keepHead:!0,sizeMapping:n=>{let l=Math.max(0,1-(performance.now()-n.pressure)/200),s=(10-Math.min(10,n.totalLength-n.currentIndex))/10;return Math.min(fv(s),fv(l))},fill:()=>r.state.theme===t9.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"});I(this,"elementsToErase",new Set);I(this,"groupsToErase",new Set)}startPath(t,r){this.endPath(),super.startPath(t,r),this.elementsToErase.clear()}addPointToPath(t,r,n=!1){return super.addPointToPath(t,r),this.updateElementsToBeErased(n)}updateElementsToBeErased(t){let r=super.getCurrentTrail()?.originalPoints?.map(l=>a9(l[0],l[1]))||[];if(r.length<2)return[];let n=i9(r[r.length-1],r[r.length-2]),i=this.app.visibleElements.filter(l=>!l.locked),a=e9(i);for(let l of i)if(t&&this.elementsToErase.has(l.id)){if(vv(n,l,a)){let c=l.groupIds.at(-1);if(this.groupsToErase.has(c)){let d=xv(this.app.scene.getNonDeletedElementsMap(),c);for(let m of d)this.elementsToErase.delete(m.id);this.groupsToErase.delete(c)}if(yv(l)&&this.elementsToErase.delete(l.containerId),Ev(l)){let d=wv(l);d&&this.elementsToErase.delete(d)}this.elementsToErase.delete(l.id)}}else if(!t&&!this.elementsToErase.has(l.id)&&vv(n,l,a)){let c=l.groupIds.at(-1);if(!this.groupsToErase.has(c)){let d=xv(this.app.scene.getNonDeletedElementsMap(),c);for(let m of d)this.elementsToErase.add(m.id);this.groupsToErase.add(c)}if(Ev(l)){let d=wv(l);d&&this.elementsToErase.add(d)}yv(l)&&this.elementsToErase.add(l.containerId),this.elementsToErase.add(l.id)}return Array.from(this.elementsToErase)}endPath(){super.endPath(),super.clearTrails(),this.elementsToErase.clear(),this.groupsToErase.clear()}},vv=(e,o,t)=>{let r=e[1];if(l9(o)&&n9(r,o,t))return!0;let n=r9(o,t);return bv(o,t,e,0,!0).length>0||!!n&&bv({...n,...o9(o,n,t)},t,e,0,!0).length>0};import{jsx as Xt,jsxs as Tv}from"react/jsx-runtime";var s9=()=>Tv("div",{"data-testid":"brave-measure-text-error",children:[Xt("p",{children:Xt(ut,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>Xt("span",{style:{fontWeight:600},children:e})})}),Xt("p",{children:Xt(ut,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>Xt("span",{style:{fontWeight:600},children:e})})}),Xt("p",{children:Xt(ut,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>Xt("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),Xt("p",{children:Xt(ut,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>Xt("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>Tv("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),Iv=s9;import h9 from"clsx";import g9 from"react";import{useLayoutEffect as c9,useRef as Cv,useEffect as Sv}from"react";import{unstable_batchedUpdates as d9}from"react-dom";import{KEYS as m9,queryFocusableElements as p9}from"@excalidraw/common";import{jsx as u9}from"react/jsx-runtime";var kv=({children:e,left:o,top:t,onCloseRequest:r,fitInViewport:n=!1,offsetLeft:i=0,offsetTop:a=0,viewportWidth:l=window.innerWidth,viewportHeight:s=window.innerHeight})=>{let c=Cv(null);Sv(()=>{let m=c.current;if(!m)return;m.contains(document.activeElement)||m.focus();let p=u=>{if(u.key===m9.TAB){let f=p9(m),{activeElement:b}=document,x=f.findIndex(w=>w===b);b===m?(u.shiftKey?f[f.length-1]?.focus():f[0].focus(),u.preventDefault(),u.stopImmediatePropagation()):x===0&&u.shiftKey?(f[f.length-1]?.focus(),u.preventDefault(),u.stopImmediatePropagation()):x===f.length-1&&!u.shiftKey&&(f[0]?.focus(),u.preventDefault(),u.stopImmediatePropagation())}};return m.addEventListener("keydown",p),()=>m.removeEventListener("keydown",p)},[]);let d=Cv(null);return c9(()=>{if(n&&c.current&&t!=null&&o!=null){let m=c.current,{width:p,height:u}=m.getBoundingClientRect();if(d.current?.top===t&&d.current?.left===o)return;d.current={top:t,left:o},p>=l?(m.style.width=`${l}px`,m.style.left="0px",m.style.overflowX="scroll"):o+p-i>l?m.style.left=`${l-p-10}px`:m.style.left=`${o}px`,u>=s?(m.style.height=`${s-20}px`,m.style.top="10px",m.style.overflowY="scroll"):t+u-a>s?m.style.top=`${s-u}px`:m.style.top=`${t}px`}},[t,o,n,l,s,i,a]),Sv(()=>{if(r){let m=p=>{c.current?.contains(p.target)||d9(()=>r(p))};return document.addEventListener("pointerdown",m,!1),()=>document.removeEventListener("pointerdown",m,!1)}},[r]),u9("div",{className:"popover",ref:c,tabIndex:-1,children:e})};import{jsx as Di,jsxs as f9}from"react/jsx-runtime";var He="separator",Mv=g9.memo(({actionManager:e,items:o,top:t,left:r,onClose:n})=>{let i=go(),a=er(),l=o.reduce((s,c)=>(c&&(c===He||!c.predicate||c.predicate(a,i,e.app.props,e.app))&&s.push(c),s),[]);return Di(kv,{onCloseRequest:()=>{n()},top:t,left:r,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,children:Di("ul",{className:"context-menu",onContextMenu:s=>s.preventDefault(),children:l.map((s,c)=>{if(s===He)return!l[c-1]||l[c-1]===He?null:Di("hr",{className:"context-menu-item-separator"},c);let d=s.name,m="";return s.label&&(typeof s.label=="function"?m=g(s.label(a,i,e.app)):m=g(s.label)),Di("li",{"data-testid":d,onClick:()=>{n(()=>{e.executeAction(s,"contextMenu")})},children:f9("button",{type:"button",className:h9("context-menu-item",{dangerous:d==="deleteSelectedElements",checkmark:s.checked?.(i)}),children:[Di("div",{className:"context-menu-item__label",children:m}),Di("kbd",{className:"context-menu-item__shortcut",children:d?Se(d):""})]})},c)})})})});import{jsx as Kh,jsxs as Lv}from"react/jsx-runtime";var b9=({height:e,width:o,userToFollow:t,onDisconnect:r})=>Kh("div",{className:"follow-mode",style:{width:o,height:e},children:Lv("div",{className:"follow-mode__badge",children:[Lv("div",{className:"follow-mode__badge__label",children:["Following"," ",Kh("span",{className:"follow-mode__badge__username",title:t.username,children:t.username})]}),Kh("button",{type:"button",onClick:r,className:"follow-mode__disconnect-btn",children:Ft})]})}),Pv=b9;import fl from"clsx";import YO from"react";import{CLASSES as WO,DEFAULT_SIDEBAR as Zg,TOOL_TYPE as uT,arrayToMap as VO,capitalizeString as XO,isShallowEqual as Yd}from"@excalidraw/common";import{mutateElement as KO}from"@excalidraw/element";import{showSelectedShapeActions as ZO}from"@excalidraw/element";import{ShapeCache as $O}from"@excalidraw/element";import{createIsolation as x9}from"jotai-scope";import Zh from"react";import vo from"tunnel-rat";var $h=Zh.createContext(null),Ae=()=>Zh.useContext($h),E9=x9(),Av=()=>Zh.useMemo(()=>({MainMenuTunnel:vo(),WelcomeScreenMenuHintTunnel:vo(),WelcomeScreenToolbarHintTunnel:vo(),WelcomeScreenHelpHintTunnel:vo(),WelcomeScreenCenterTunnel:vo(),FooterCenterTunnel:vo(),DefaultSidebarTriggerTunnel:vo(),DefaultSidebarTabTriggersTunnel:vo(),OverwriteConfirmDialogTunnel:vo(),TTDDialogTriggerTunnel:vo(),tunnelsJotai:E9}),[]);import y9 from"clsx";import{useState as w9,useEffect as v9}from"react";import{THEME as T9}from"@excalidraw/common";import{jsx as jh,jsxs as I9}from"react/jsx-runtime";var id=({delay:e,theme:o})=>{let[t,r]=w9(!!e);return v9(()=>{if(!e)return;let n=setTimeout(()=>{r(!1)},e);return()=>clearTimeout(n)},[e]),t?null:I9("div",{className:y9("LoadingMessage",{"LoadingMessage--dark":o===T9.DARK}),children:[jh("div",{children:jh(tt,{})}),jh("div",{className:"LoadingMessage-text",children:g("labels.loadingScene")})]})};import{showSelectedShapeActions as V9}from"@excalidraw/element";import C9 from"clsx";import{jsx as S9}from"react/jsx-runtime";var ad=({children:e,side:o,className:t})=>S9("div",{className:C9("FixedSideContainer",`FixedSideContainer_side_${o}`,t),children:e});import k9 from"clsx";import{KEYS as Dv}from"@excalidraw/common";import{jsx as M9}from"react/jsx-runtime";var ld=e=>M9(W,{className:k9("Shape",{fillable:!1}),type:"radio",icon:es,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:Dv.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":Dv.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});import{CANVAS_SEARCH_TAB as L9,DEFAULT_SIDEBAR as P9}from"@excalidraw/common";import{isFlowchartNodeElement as A9,isImageElement as _v,isLinearElement as Rv,isLineElement as D9,isTextBindableContainer as _9,isTextElement as R9}from"@excalidraw/element";import{getShortcutKey as qh}from"@excalidraw/common";import{isNodeInFlowchart as N9}from"@excalidraw/element";import{jsx as Nv}from"react/jsx-runtime";var B9=({appState:e,isMobile:o,device:t,app:r})=>{let{activeTool:n,isResizing:i,isRotating:a,lastPointerDownWith:l}=e,s=e.multiElement!==null;if(e.openSidebar?.name===P9.name&&e.openSidebar.tab===L9&&e.searchMatches?.matches.length)return g("hints.dismissSearch");if(e.openSidebar&&!t.editor.canFitSidebar)return null;if(Et(e))return g("hints.eraserRevert");if(n.type==="arrow"||n.type==="line")return s?g("hints.linearElementMulti"):n.type==="arrow"?g("hints.arrowTool",{arrowShortcut:qh("A")}):g("hints.linearElement");if(n.type==="freedraw")return g("hints.freeDraw");if(n.type==="text")return g("hints.text");if(n.type==="embeddable")return g("hints.embeddable");let c=r.scene.getSelectedElements(e);if(i&&l==="mouse"&&c.length===1){let d=c[0];return Rv(d)&&d.points.length===2?g("hints.lockAngle"):_v(d)?g("hints.resizeImage"):g("hints.resize")}if(a&&l==="mouse")return g("hints.rotate");if(c.length===1&&R9(c[0]))return g("hints.text_selected");if(e.editingTextElement)return g("hints.text_editing");if(e.croppingElementId)return g("hints.leaveCropEditor");if(c.length===1&&_v(c[0]))return g("hints.enterCropEditor");if(n.type==="selection"){if(e.selectionElement&&!c.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return[g("hints.deepBoxSelect")];if(fr(r)&&e.selectedElementsAreBeingDragged)return g("hints.disableSnapping");if(!c.length&&!o)return[g("hints.canvasPanning")];if(c.length===1){if(Rv(c[0]))return e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?g("hints.lineEditor_pointSelected"):g("hints.lineEditor_nothingSelected"):D9(c[0])?g("hints.lineEditor_line_info"):g("hints.lineEditor_info");if(!e.newElement&&!e.selectedElementsAreBeingDragged&&_9(c[0]))return A9(c[0])?N9(c[0],r.scene.getNonDeletedElementsMap())?[g("hints.bindTextToElement"),g("hints.createFlowchart")]:[g("hints.bindTextToElement"),g("hints.createFlowchart")]:g("hints.bindTextToElement")}}return null},sd=({appState:e,isMobile:o,device:t,app:r})=>{let n=B9({appState:e,isMobile:o,device:t,app:r});if(!n)return null;let i=Array.isArray(n)?n.map(a=>qh(a).replace(/\. ?$/,"")).join(". "):qh(n);return Nv("div",{className:"HintViewer",children:Nv("span",{children:i})})};import F9 from"clsx";import{jsx as Fv,jsxs as z9}from"react/jsx-runtime";var O9="medium",Bv={CHECKED:$o,UNCHECKED:Ao},Ov=e=>z9("label",{className:F9("ToolIcon ToolIcon__lock",`ToolIcon_size_${O9}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[Fv("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),Fv("div",{className:"ToolIcon__icon",children:e.checked?Bv.CHECKED:Bv.UNCHECKED})]});import H9 from"clsx";import{jsx as zv,jsxs as U9}from"react/jsx-runtime";var G9="medium",cd=e=>e.penDetected?U9("label",{className:H9("ToolIcon ToolIcon__penMode",`ToolIcon_size_${G9}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[zv("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),zv("div",{className:"ToolIcon__icon",children:R1})]}):null;import{Fragment as Y9,jsx as Hv,jsxs as W9}from"react/jsx-runtime";var Er=({heading:e,children:o,...t})=>{let{id:r}=ze(),n=Hv("h2",{className:"visually-hidden",id:`${r}-${e}-title`,children:g(`headings.${e}`)});return Hv("section",{...t,"aria-labelledby":`${r}-${e}-title`,children:typeof o=="function"?o(n):W9(Y9,{children:[n,o]})})};import{Fragment as X9,jsx as gt,jsxs as To}from"react/jsx-runtime";var Gv=({appState:e,elements:o,actionManager:t,setAppState:r,onLockToggle:n,onHandToolToggle:i,onPenModeToggle:a,renderTopRightUI:l,renderCustomStats:s,renderSidebars:c,device:d,renderWelcomeScreen:m,UIOptions:p,app:u})=>{let{WelcomeScreenCenterTunnel:f,MainMenuTunnel:b,DefaultSidebarTriggerTunnel:x}=Ae(),w=()=>To(ad,{side:"top",className:"App-top-bar",children:[m&&gt(f.Out,{}),gt(Er,{heading:"shapes",children:y=>gt(Ze.Col,{gap:4,align:"center",children:To(Ze.Row,{gap:1,className:"App-toolbar-container",children:[To(We,{padding:1,className:"App-toolbar App-toolbar--mobile",children:[y,gt(Ze.Row,{gap:1,children:gt(Ac,{appState:e,activeTool:e.activeTool,UIOptions:p,app:u})})]}),l&&l(!0,e),To("div",{className:"mobile-misc-tools-container",children:[!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&gt(x.Out,{}),gt(cd,{checked:e.penMode,onChange:()=>a(null),title:g("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),gt(Ov,{checked:e.activeTool.locked,onChange:n,title:g("toolBar.lock"),isMobile:!0}),gt(ld,{checked:qt(e),onChange:()=>i(),title:g("toolBar.hand"),isMobile:!0})]})]})})}),gt(sd,{appState:e,isMobile:!0,device:d,app:u})]}),E=()=>e.viewModeEnabled||e.openDialog?.name==="elementLinkSelector"?gt("div",{className:"App-toolbar-content",children:To("div",{children:[t.renderAction("viewMode"),t.renderAction("smartZoom")]})}):To("div",{className:"App-toolbar-content",children:[To("div",{children:[t.renderAction("viewMode"),t.renderAction("smartZoom"),t.renderAction("undo"),t.renderAction("redo")]}),t.renderAction("toggleEditMenu"),t.renderAction(e.multiElement?"finalize":"duplicateSelection"),t.renderAction("deleteSelectedElements")]});return To(X9,{children:[c(),!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&w(),gt("div",{className:"App-bottom-bar",style:{marginBottom:kt+lo*2,marginLeft:kt+lo*2,marginRight:kt+lo*2},children:To(We,{padding:0,children:[e.openMenu==="shape"&&!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&V9(e,o)?gt(Er,{className:"App-mobile-menu",heading:"selectedShapeActions",children:gt(Pc,{appState:e,elementsMap:u.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:u})}):null,To("footer",{className:"App-toolbar",children:[E(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&gt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(y=>({...Or(o,y)}))},children:g("buttons.scrollBackToContent")})]})]})})]})};import K9 from"open-color";import Z9,{useLayoutEffect as $9,useRef as j9,useState as q9}from"react";import{jsx as nl,jsxs as J9}from"react/jsx-runtime";var Uv=e=>{let o=j9(null),[t,r]=q9(null);return $9(()=>{if(!e.spreadsheet)return;let n=Yx(e.chartType,e.spreadsheet,0,0);r(n);let i,a=o.current;return(async()=>(i=await En(n,{exportBackground:!1,viewBackgroundColor:K9.white},null,{skipInliningFonts:!0}),i.querySelector(".style-fonts")?.remove(),a.replaceChildren(),a.appendChild(i),e.selected&&a.parentNode.focus()))(),()=>{a.replaceChildren()}},[e.spreadsheet,e.chartType,e.selected]),nl("button",{type:"button",className:"ChartPreview",onClick:()=>{t&&e.onClick(e.chartType,t)},children:nl("div",{ref:o})})},Yv=({setAppState:e,appState:o,onClose:t})=>{let{onInsertElements:r}=Re(),n=Z9.useCallback(()=>{t&&t()},[t]),i=(a,l)=>{r(l),re("paste","chart",a),e({currentChartType:a,pasteDialog:{shown:!1,data:null}})};return nl(Ne,{size:"small",onCloseRequest:n,title:g("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:J9("div",{className:"container",children:[nl(Uv,{chartType:"bar",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="bar",onClick:i}),nl(Uv,{chartType:"line",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="line",onClick:i})]})})};import*as yr from"@radix-ui/react-popover";import Wv from"clsx";import dd,{useLayoutEffect as Q9}from"react";import{supportsResizeObserver as eN,isShallowEqual as tN}from"@excalidraw/common";import{Fragment as aN,jsx as Io,jsxs as md}from"react/jsx-runtime";var oN=4,rN=8,nN=({shouldWrap:e,children:o,username:t})=>e?Io(it,{label:t||"Unknown user",children:o}):Io(aN,{children:o}),Jh=({actionManager:e,collaborator:o,socketId:t,withName:r=!1,shouldWrapWithTooltip:n=!1,isBeingFollowed:i})=>{let a={socketId:t,collaborator:o,withName:r,isBeingFollowed:i},l=e.renderAction("goToCollaborator",a);return Io(nN,{username:o.username,shouldWrap:n,children:l},t)},iN=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],pd=dd.memo(({className:e,mobile:o,collaborators:t,userToFollow:r})=>{let n=ot(),i=new Map;t.forEach((b,x)=>{let w=b.id||x;i.set(w,{...b,socketId:x})});let a=Array.from(i.values()).filter(b=>b.username?.trim()),[l,s]=dd.useState(""),c=a.filter(b=>b.username?.toLowerCase().includes(l)),d=dd.useRef(null);Q9(()=>{if(d.current){let b=w=>{let E=Math.max(1,Math.min(8,Math.floor(w/38)));p(E)};if(b(d.current.clientWidth),!eN)return;let x=new ResizeObserver(w=>{for(let E of w){let{width:y}=E.contentRect;b(y)}});return x.observe(d.current),()=>{x.disconnect()}}},[]);let[m,p]=dd.useState(oN),f=a.slice(0,m-1).map(b=>Jh({actionManager:n,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===r}));return o?Io("div",{className:Wv("UserList UserList_mobile",e),children:a.map(b=>Jh({actionManager:n,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===r}))}):Io("div",{className:"UserList__wrapper",ref:d,children:md("div",{className:Wv("UserList",e),style:{"--max-avatars":m},children:[f,a.length>m-1&&md(yr.Root,{children:[md(yr.Trigger,{className:"UserList__more",children:["+",a.length-m+1]}),Io(yr.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:md(We,{padding:2,children:[a.length>=rN&&Io(ws,{placeholder:g("quickSearch.placeholder"),onChange:s}),Io(vs,{className:"dropdown-menu UserList__collaborators",placeholder:g("userList.empty"),children:c.length>0?[Io("div",{className:"hint",children:g("userList.hint.text")}),c.map(b=>Jh({actionManager:n,collaborator:b,socketId:b.socketId,withName:!0,isBeingFollowed:b.socketId===r}))]:[]}),Io(yr.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})]})]})})},(e,o)=>{if(e.collaborators.size!==o.collaborators.size||e.mobile!==o.mobile||e.className!==o.className||e.userToFollow!==o.userToFollow)return!1;let t=o.collaborators.keys();for(let[r,n]of e.collaborators){let i=o.collaborators.get(r);if(!i||r!==t.next().value||!tN(n,i,iN))return!1}return!0});import il from"clsx";import{jsx as lN}from"react/jsx-runtime";var Vv=e=>lN("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${g("helpDialog.title")} \u2014 ?`,"aria-label":g("helpDialog.title"),children:Pn});import{jsx as Nt,jsxs as Qh}from"react/jsx-runtime";var Xv=({appState:e,actionManager:o,showExitZenModeBtn:t,renderWelcomeScreen:r})=>{let{FooterCenterTunnel:n,WelcomeScreenHelpHintTunnel:i}=Ae();return Qh("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[Nt("div",{className:il("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:Nt(Ze.Col,{gap:2,children:Qh(Er,{heading:"canvasActions",children:[Nt(it,{label:g("labels.viewMode"),children:Nt("div",{className:il("view-mode-button"),children:o.renderAction("viewMode")})}),Nt(it,{label:g("buttons.smartZoom"),children:Nt("div",{className:il("smart-zoom-button"),children:o.renderAction("smartZoom")})}),Nt(x2,{renderAction:o.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&Nt(E2,{renderAction:o.renderAction,className:il("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),Nt(n.Out,{}),Nt("div",{className:il("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:Qh("div",{style:{position:"relative"},children:[r&&Nt(i.Out,{}),Nt(Vv,{onClick:()=>o.executeAction(jr)})]})}),Nt(y2,{actionManager:o,showExitZenModeBtn:t})]})},Kv=Xv;Xv.displayName="Footer";import gN from"clsx";import{useEffect as n3,useLayoutEffect as i3,useRef as sg,useState as fN,forwardRef as a3,useImperativeHandle as bN,useCallback as t3}from"react";import{EVENT as o3,isDevEnv as xN,KEYS as EN,updateObject as yN}from"@excalidraw/common";import cN from"clsx";import{useContext as dN}from"react";import sN from"react";var ud=sN.createContext({});import{jsx as eg,jsxs as Zv}from"react/jsx-runtime";var tg=({children:e,className:o})=>{let t=ce(),r=dN(ud),n=!!(t.editor.canFitSidebar&&r.shouldRenderDockButton);return Zv("div",{className:cN("sidebar__header",o),"data-testid":"sidebar-header",children:[e,Zv("div",{className:"sidebar__header__buttons",children:[n&&eg(it,{label:g("labels.sidebarLock"),children:eg(Rt,{onSelect:()=>r.onDock?.(!r.docked),selected:!!r.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":g("labels.sidebarLock"),children:M1})}),eg(Rt,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:r.onCloseRequest,"aria-label":g("buttons.close"),children:Ft})]})]})};tg.displayName="SidebarHeader";import*as jv from"@radix-ui/react-tabs";import{jsx as $v}from"react/jsx-runtime";var og=({children:e,tab:o,onSelect:t,...r})=>$v(jv.Trigger,{value:o,asChild:!0,onSelect:t,children:$v("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...r,children:e})});og.displayName="SidebarTabTrigger";import*as qv from"@radix-ui/react-tabs";import{jsx as mN}from"react/jsx-runtime";var rg=({children:e,...o})=>mN(qv.List,{className:"sidebar-triggers",...o,children:e});rg.displayName="SidebarTabTriggers";import pN from"clsx";import{jsx as ng,jsxs as Jv}from"react/jsx-runtime";var ig=({name:e,tab:o,icon:t,title:r,children:n,onToggle:i,className:a,style:l})=>{let s=le(),c=ge();return Jv("label",{title:r,className:"sidebar-trigger__label-element",children:[ng("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:d=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let m=d.target.checked;s({openSidebar:m?{name:e,tab:o}:null}),i?.(m)},checked:c.openSidebar?.name===e,"aria-label":r,"aria-keyshortcuts":"0"}),Jv("div",{className:pN("sidebar-trigger",a),style:l,children:[t&&ng("div",{children:t}),n&&ng("div",{className:"sidebar-trigger__label",children:n})]})]})};ig.displayName="SidebarTrigger";import*as Qv from"@radix-ui/react-tabs";import{jsx as uN}from"react/jsx-runtime";var ag=({children:e,...o})=>{let t=ge(),r=le();if(!t.openSidebar)return null;let{name:n}=t.openSidebar;return uN(Qv.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>r(a=>({...a,openSidebar:{...a.openSidebar,name:n,tab:i}})),...o,children:e})};ag.displayName="SidebarTabs";import*as e3 from"@radix-ui/react-tabs";import{jsx as hN}from"react/jsx-runtime";var lg=({tab:e,children:o,...t})=>hN(e3.Content,{...t,value:e,"data-testid":e,children:o});lg.displayName="SidebarTab";import{jsx as r3}from"react/jsx-runtime";import{createElement as wN}from"react";var al=he(!1),l3=a3(({name:e,children:o,onDock:t,docked:r,className:n,...i},a)=>{xN()&&t&&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 l=le(),s=wn(al);i3(()=>(s(!!r),()=>{s(!1)}),[s,r]);let c=sg({});c.current.onCloseRequest=()=>{l({openSidebar:null})},c.current.onDock=u=>t?.(u),c.current=yN(c.current,{docked:r,shouldRenderDockButton:!!t&&r!=null});let d=sg(null);bN(a,()=>d.current);let m=ce(),p=t3(()=>{document.querySelector(".Dialog")||l({openSidebar:null})},[l]);return zn(d,t3(u=>{u.target.closest(".sidebar-trigger")||(!r||!m.editor.canFitSidebar)&&p()},[p,r,m.editor.canFitSidebar])),n3(()=>{let u=f=>{f.key===EN.ESCAPE&&(!r||!m.editor.canFitSidebar)&&p()};return document.addEventListener(o3.KEYDOWN,u),()=>{document.removeEventListener(o3.KEYDOWN,u)}},[p,r,m.editor.canFitSidebar]),r3(We,{...i,className:gN("sidebar",{"sidebar--docked":r},n),ref:d,children:r3(ud.Provider,{value:c.current,children:o})})});l3.displayName="SidebarInner";var Kt=Object.assign(a3((e,o)=>{let t=ge(),{onStateChange:r}=e,n=sg(t.openSidebar);n3(()=>{(!t.openSidebar&&n?.current?.name===e.name||t.openSidebar?.name===e.name&&n?.current?.name!==e.name||n.current?.name===e.name)&&t.openSidebar!==n.current&&r?.(t.openSidebar?.name!==e.name?null:t.openSidebar),n.current=t.openSidebar},[t.openSidebar,r,e.name]);let[i,a]=fN(!1);return i3(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?wN(l3,{...e,ref:o,key:e.name}):null}),{Header:tg,TabTriggers:rg,TabTrigger:og,Tabs:ag,Tab:lg,Trigger:ig});Kt.displayName="Sidebar";import{composeEventHandlers as PN}from"@excalidraw/common";import{useLayoutEffect as vN,useRef as TN}from"react";import{jsx as IN}from"react/jsx-runtime";var Wo=(e,o)=>{let t=he(0),r=n=>{let{tunnelsJotai:{useAtom:i}}=Ae(),[,a]=i(t),l=TN({preferHost:!1,counter:0});return vN(()=>{let s=l.current;return a(c=>{let d=c+1;return s.counter=d,d}),()=>{a(c=>{let d=c-1;return s.counter=d,d||(s.preferHost=!1),d})}},[a]),n.__fallback||(l.current.preferHost=!0),!l.current.counter&&n.__fallback&&l.current.preferHost||l.current.counter>1&&n.__fallback?null:IN(o,{...n})};return r.displayName=e,r};var mg={};Kf(mg,{ChangeCanvasBackground:()=>y3,CommandPalette:()=>f3,Export:()=>w3,Help:()=>x3,LiveCollaborationTrigger:()=>T3,LoadScene:()=>u3,SaveAsImage:()=>g3,SaveToActiveFile:()=>h3,SearchMenu:()=>b3,Socials:()=>v3,ToggleTheme:()=>E3});import MN from"clsx";import{THEME as wr}from"@excalidraw/common";var cg=he({active:!1});async function s3({title:e,description:o,actionLabel:t,color:r}){return new Promise(n=>{Ke.set(cg,{active:!0,onConfirm:()=>n(!0),onClose:()=>n(!1),onReject:()=>n(!1),title:e,description:o,actionLabel:t,color:r})})}import CN from"clsx";import{jsx as c3,jsxs as SN}from"react/jsx-runtime";var hd=function({onChange:e,value:o,choices:t,name:r}){return c3("div",{className:"RadioGroup",children:t.map(n=>SN("div",{className:CN("RadioGroup__choice",{active:n.value===o}),title:n.ariaLabel,children:[c3("input",{name:r,type:"radio",checked:n.value===o,onChange:()=>e(n.value),"aria-label":n.ariaLabel}),n.label]},String(n.value)))})};import{Fragment as kN,jsx as dg,jsxs as d3}from"react/jsx-runtime";var m3=({value:e,shortcut:o,onChange:t,choices:r,children:n,name:i})=>{let a=ce();return d3(kN,{children:[d3("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[dg("label",{className:"dropdown-menu-item__text",htmlFor:i,children:n}),dg(hd,{name:i,value:e,onChange:t,choices:r})]}),o&&!a.editor.isMobile&&dg("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:o})]})};m3.displayName="DropdownMenuItemContentRadio";var p3=m3;import{Fragment as LN,jsx as je,jsxs as I3}from"react/jsx-runtime";var u3=()=>{let{t:e}=Oe(),o=ot(),t=er();return o.isActionEnabled(Jn)?je(yt,{icon:An,onSelect:async()=>{(!t.length||await s3({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:je(ut,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:n=>je("strong",{children:n}),br:()=>je("br",{})})}))&&o.executeAction(Jn)},"data-testid":"load-button",shortcut:Se("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};u3.displayName="LoadScene";var h3=()=>{let{t:e}=Oe(),o=ot();return o.isActionEnabled($r)?je(yt,{shortcut:Se("saveScene"),"data-testid":"save-button",onSelect:()=>o.executeAction($r),icon:W1,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};h3.displayName="SaveToActiveFile";var g3=()=>{let e=le(),{t:o}=Oe();return je(yt,{icon:jl,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:Se("imageExport"),"aria-label":o("buttons.exportImage"),children:o("buttons.exportImage")})};g3.displayName="SaveAsImage";var f3=e=>{let o=le(),{t}=Oe();return je(yt,{icon:sa,"data-testid":"command-palette-button",onSelect:()=>{re("command_palette","open","menu"),o({openDialog:{name:"commandPalette"}})},shortcut:Se("commandPalette"),"aria-label":t("commandPalette.title"),className:e?.className,children:t("commandPalette.title")})};f3.displayName="CommandPalette";var b3=e=>{let{t:o}=Oe(),t=ot();return je(yt,{icon:At,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(Va)},shortcut:Se("searchMenu"),"aria-label":o("search.title"),className:e?.className,children:o("search.title")})};b3.displayName="SearchMenu";var x3=()=>{let{t:e}=Oe(),o=ot();return je(yt,{"data-testid":"help-menu-item",icon:Pn,onSelect:()=>o.executeAction(jr),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};x3.displayName="Help";var E3=e=>{let{t:o}=Oe(),t=ge(),r=ot(),n=Se("toggleTheme");return r.isActionEnabled(Vr)?e?.allowSystemTheme?je(p3,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:wr.LIGHT,label:na,ariaLabel:`${o("buttons.lightMode")} - ${n}`},{value:wr.DARK,label:ra,ariaLabel:`${o("buttons.darkMode")} - ${n}`},{value:"system",label:lb,ariaLabel:o("buttons.systemMode")}],children:o("labels.theme")}):je(yt,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(t.theme===wr.DARK?wr.LIGHT:wr.DARK);else return r.executeAction(Vr)},icon:t.theme===wr.DARK?na:ra,"data-testid":"toggle-dark-mode",shortcut:n,"aria-label":t.theme===wr.DARK?o("buttons.lightMode"):o("buttons.darkMode"),children:t.theme===wr.DARK?o("buttons.lightMode"):o("buttons.darkMode")}):null};E3.displayName="ToggleTheme";var y3=()=>{let{t:e}=Oe(),o=ge(),t=ot(),r=fo();return o.viewModeEnabled||!r.UIOptions.canvasActions.changeViewBackgroundColor?null:I3("div",{style:{marginTop:"0.5rem"},children:[je("div",{"data-testid":"canvas-background-label",style:{fontSize:".75rem",marginBottom:".5rem"},children:e("labels.canvasBackground")}),je("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};y3.displayName="ChangeCanvasBackground";var w3=()=>{let{t:e}=Oe(),o=le();return je(yt,{icon:zr,onSelect:()=>{o({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};w3.displayName="Export";var v3=()=>{let{t:e}=Oe();return I3(LN,{children:[je(fi,{icon:H1,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),je(fi,{icon:U1,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),je(fi,{icon:G1,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};v3.displayName="Socials";var T3=({onSelect:e,isCollaborating:o})=>{let{t}=Oe();return je(yt,{"data-testid":"collab-button",icon:ql,className:MN({"active-collab":o}),onSelect:e,children:t("labels.liveCollaboration")})};T3.displayName="LiveCollaborationTrigger";import{jsx as gd,jsxs as pg}from"react/jsx-runtime";var AN=Object.assign(Wo("MainMenu",({children:e,onSelect:o})=>{let{MainMenuTunnel:t}=Ae(),r=ce(),n=ge(),i=le(),a=r.editor.isMobile?void 0:()=>i({openMenu:null});return gd(t.In,{children:pg(ye,{open:n.openMenu==="canvas",children:[gd(ye.Trigger,{onToggle:()=>{i({openMenu:n.openMenu==="canvas"?null:"canvas"})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:Zl}),pg(ye.Content,{onClickOutside:a,onSelect:PN(o,()=>{i({openMenu:null})}),children:[e,r.editor.isMobile&&n.collaborators.size>0&&pg("fieldset",{className:"UserList-Wrapper",children:[gd("legend",{children:g("labels.collaborators")}),gd(pd,{mobile:!0,collaborators:n.collaborators,userToFollow:n.userToFollow?.socketId||null})]})]})]})})}),{Trigger:ye.Trigger,Item:ye.Item,ItemLink:ye.ItemLink,ItemCustom:ye.ItemCustom,Group:ye.Group,Separator:ye.Separator,DefaultItems:mg}),ft=AN;import DN from"clsx";import{forwardRef as _N,useState as RN}from"react";import{isPromiseLike as NN}from"@excalidraw/common";import{jsx as fd,jsxs as BN}from"react/jsx-runtime";var vr=_N(({children:e,icon:o,onClick:t,label:r,variant:n="filled",color:i="primary",size:a="medium",fullWidth:l,className:s,status:c},d)=>{let[m,p]=RN(!1),u=async b=>{let x=t?.(b);if(NN(x)){let w=window.setTimeout(()=>{p(!0)},50);try{await x}catch(E){if(E instanceof fn)console.warn(E);else throw E}finally{clearTimeout(w),p(!1)}}},f=m?"loading":c;return i=f==="success"?"success":i,fd("button",{className:DN("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${n}`,`ExcButton--size-${a}`,`ExcButton--status-${f}`,{"ExcButton--fullWidth":l},s),onClick:u,type:"button","aria-label":r,ref:d,disabled:f==="loading"||f==="success",children:BN("div",{className:"ExcButton__contents",children:[f==="loading"?fd(tt,{className:"ExcButton__statusIcon"}):f==="success"&&fd("div",{className:"ExcButton__statusIcon",children:G0}),o&&fd("div",{className:"ExcButton__icon","aria-hidden":!0,children:o}),n!=="icon"&&(e??r)]})})});import{jsx as _i,jsxs as zN}from"react/jsx-runtime";var bd=({title:e,children:o,actionLabel:t,onClick:r})=>zN("div",{className:"OverwriteConfirm__Actions__Action",children:[_i("h4",{children:e}),_i("div",{className:"OverwriteConfirm__Actions__Action__content",children:o}),_i(vr,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:r})]}),FN=()=>{let{t:e}=Oe(),o=ot(),t=le();return _i(bd,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{o.executeAction(Xs,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},ON=()=>{let{t:e}=Oe(),o=ot();return _i(bd,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{o.executeAction(Aa,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},ug=Object.assign(({children:e})=>_i("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:FN,SaveToDisk:ON});import{jsx as Tr,jsxs as C3}from"react/jsx-runtime";var xd=Object.assign(Wo("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:o}=Ae(),[t,r]=se(cg);if(!t.active)return null;let n=()=>{t.onClose(),r(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),r(a=>({...a,active:!1}))};return Tr(o.In,{children:Tr(Ne,{onCloseRequest:n,title:!1,size:916,children:C3("div",{className:"OverwriteConfirm",children:[Tr("h3",{children:t.title}),C3("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[Tr("div",{className:"OverwriteConfirm__Description__icon",children:U0}),Tr("div",{children:t.description}),Tr("div",{className:"OverwriteConfirm__Description__spacer"}),Tr(vr,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),Tr(ug,{children:e})]})})})}),{Actions:ug,Action:bd});import lB from"clsx";import{CANVAS_SEARCH_TAB as xg,DEFAULT_SIDEBAR as sB,LIBRARY_SIDEBAR_TAB as N3,composeEventHandlers as cB}from"@excalidraw/common";import{round as HN}from"@excalidraw/math";import GN from"clsx";import UN from"lodash.debounce";import{Fragment as YN,memo as WN,useEffect as ll,useMemo as S3,useRef as hg,useState as k3}from"react";import{CLASSES as VN,EVENT as XN,FONT_FAMILY as gg,FRAME_STYLE as fg,getLineHeight as KN}from"@excalidraw/common";import{isElementCompletelyInViewport as ZN}from"@excalidraw/element";import{measureText as sl}from"@excalidraw/element";import{KEYS as Ri,randomInteger as M3,addEventListener as $N,getFontString as Ed}from"@excalidraw/common";import{newTextElement as jN}from"@excalidraw/element";import{isTextElement as D3,isFrameLikeElement as yd}from"@excalidraw/element";import{getDefaultFrameName as _3}from"@excalidraw/element/frame";import{Fragment as aB,jsx as qe,jsxs as Co}from"react/jsx-runtime";var qN=he(""),bg=he(null),JN=350,R3=()=>{let e=Re(),o=le(),t=hg(null),[r,n]=se(qN),i=r.trim(),[a,l]=k3(!1),[s,c]=k3({nonce:null,items:[]}),d=hg(null),m=hg(void 0),[p,u]=se(bg),f=e.scene.getNonDeletedElementsMap();ll(()=>{a||(i!==d.current||e.scene.getSceneNonce()!==m.current)&&(d.current=null,A3(i,e,(y,v)=>{c({nonce:M3(),items:y}),d.current=i,m.current=e.scene.getSceneNonce(),o({searchMatches:y.length?{focusedId:null,matches:y.map(C=>({id:C.element.id,focus:!1,matchedLines:C.matchedLines}))}:null})}))},[a,i,f,e,o,u,m]);let b=()=>{s.items.length>0&&u(y=>y===null?0:(y+1)%s.items.length)},x=()=>{s.items.length>0&&u(y=>y===null?0:y-1<0?s.items.length-1:y-1)};ll(()=>{o(y=>y.searchMatches?{searchMatches:{focusedId:p!==null&&y.searchMatches?.matches[p]?.id||null,matches:y.searchMatches.matches.map((C,S)=>S===p?{...C,focus:!0}:{...C,focus:!1})}}:null)},[p,o]),ll(()=>{if(s.items.length>0&&p!==null){let y=s.items[p];if(y){let v=e.state.zoom.value,C=jN({text:y.searchQuery,x:y.element.x+(y.matchedLines[0]?.offsetX??0),y:y.element.y+(y.matchedLines[0]?.offsetY??0),width:y.matchedLines[0]?.width,height:y.matchedLines[0]?.height,fontSize:yd(y.element)?fg.nameFontSize:y.element.fontSize,fontFamily:yd(y.element)?gg.Assistant:y.element.fontFamily}),S=14,L=C.fontSize,k=L*v<S;if(!ZN([C],e.canvas.width/window.devicePixelRatio,e.canvas.height/window.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.getEditorUIOffsets())||k){let A;k?L>=S?A={fitToContent:!0}:A={fitToViewport:!0,maxZoom:HN(S/L,1)}:A={fitToContent:!0},e.scrollToContent(C,{animate:!0,duration:300,...A,canvasOffsets:e.getEditorUIOffsets()})}}}},[p,s,e]),ll(()=>()=>{u(null),d.current=null,m.current=void 0,o({searchMatches:null}),l(!1)},[o,u]);let w=qo({goToNextItem:b,goToPreviousItem:x,searchMatches:s});ll(()=>{let y=v=>{if(v.key===Ri.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){v.preventDefault(),v.stopPropagation(),o({openSidebar:null});return}if(v[Ri.CTRL_OR_CMD]&&v.key===Ri.F){if(v.preventDefault(),v.stopPropagation(),e.state.openDialog)return;t.current?.matches(":focus")||(e.state.openDialog&&o({openDialog:null}),t.current?.focus(),t.current?.select())}v.target instanceof HTMLElement&&v.target.closest(".layer-ui__search")&&w.searchMatches.items.length&&(v.key===Ri.ENTER&&(v.stopPropagation(),w.goToNextItem()),v.key===Ri.ARROW_UP?(v.stopPropagation(),w.goToPreviousItem()):v.key===Ri.ARROW_DOWN&&(v.stopPropagation(),w.goToNextItem()))};return $N(window,XN.KEYDOWN,y,{capture:!0,passive:!1})},[o,w,e]);let E=`${s.items.length} ${s.items.length===1?g("search.singleResult"):g("search.multipleResults")}`;return Co("div",{className:"layer-ui__search",children:[qe("div",{className:"layer-ui__search-header",children:qe(Ei,{className:VN.SEARCH_MENU_INPUT_WRAPPER,value:r,ref:t,placeholder:g("search.placeholder"),icon:At,onChange:y=>{n(y),l(!0);let v=y.trim();A3(v,e,(C,S)=>{c({nonce:M3(),items:C}),u(S),d.current=v,m.current=e.scene.getSceneNonce(),o({searchMatches:C.length?{focusedId:null,matches:C.map(L=>({id:L.element.id,focus:!1,matchedLines:L.matchedLines}))}:null}),l(!1)})},selectOnRender:!0})}),Co("div",{className:"layer-ui__search-count",children:[s.items.length>0&&Co(aB,{children:[p!==null&&p>-1?Co("div",{children:[p+1," / ",E]}):qe("div",{children:E}),Co("div",{className:"result-nav",children:[qe(Rt,{onSelect:()=>{b()},className:"result-nav-btn",children:is}),qe(Rt,{onSelect:()=>{x()},className:"result-nav-btn",children:mb})]})]}),s.items.length===0&&i&&d.current&&qe("div",{style:{margin:"1rem auto"},children:g("search.noMatch")})]}),qe(tB,{matches:s,onItemClick:u,focusIndex:p,searchQuery:i})]})},L3=e=>{let o=[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 qe("div",{tabIndex:-1,className:GN("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:qe("div",{className:"preview-text",children:o.flatMap((t,r)=>qe(YN,{children:r===2?qe("b",{children:t}):t},r))})})},QN=e=>{let o=S3(()=>e.matches.items.filter(r=>yd(r.element)),[e.matches]),t=S3(()=>e.matches.items.filter(r=>D3(r.element)),[e.matches]);return Co("div",{children:[o.length>0&&Co("div",{className:"layer-ui__search-result-container",children:[Co("div",{className:"layer-ui__search-result-title",children:[qe("div",{className:"title-icon",children:_n}),qe("div",{children:g("search.frames")})]}),o.map((r,n)=>qe(L3,{searchQuery:e.searchQuery,preview:r.preview,highlighted:n===e.focusIndex,onClick:()=>e.onItemClick(n)},r.element.id+r.index)),t.length>0&&qe("div",{className:"layer-ui__divider"})]}),t.length>0&&Co("div",{className:"layer-ui__search-result-container",children:[Co("div",{className:"layer-ui__search-result-title",children:[qe("div",{className:"title-icon",children:Ln}),qe("div",{children:g("search.texts")})]}),t.map((r,n)=>qe(L3,{searchQuery:e.searchQuery,preview:r.preview,highlighted:n+o.length===e.focusIndex,onClick:()=>e.onItemClick(n+o.length)},r.element.id+r.index))]})]})},eB=(e,o)=>e.matches.nonce===o.matches.nonce&&e.focusIndex===o.focusIndex,tB=WN(QN,eB),P3=(e,o,t)=>{let i=e.slice(0,o),a=i.split(/\s+/),l=i.endsWith(" "),s=a.length-2-1-(l?0:1),c=a.slice(s<=0?0:s).join(" ")+(l?" ":""),d=20;c=c.length>d?c.slice(-d):c;let m=e.slice(o+t.length),p=m.split(/\s+/),u=!m.startsWith(" "),f=u?6:5,b=(u?"":" ")+p.slice(0,f).join(" ");return{indexInSearchQuery:c.length,previewText:c+t+b,moreBefore:s>0,moreAfter:p.length>f}},oB=(e,o)=>{let t=e.split(`
10
17
  `),r=[],n=0;for(let i=0;i<t.length;i++){let a=t[i],l=t[i+1];if(l){let s=o.indexOf(l,n);if(s>a.length+n){let c=s-(a.length+n);for(;c>0;)a+=" ",c--}}r.push(a),n=n+a.length}return r.join(`
11
- `)},XI=(e,o,t)=>{let n=ZI(e.text,e.originalText).split(`
12
- `),i=[],a=0,l=0;for(let d of n){let p=a,u=p+d.length-1;i.push({line:d,startIndex:p,endIndex:u,lineNumber:l}),a=u+1,l++}let s=t,c=e.originalText.slice(t,t+o.length),m=[];for(let d of i){if(c==="")break;if(s>=d.startIndex&&s<=d.endIndex){let p=d.endIndex+1-s,u=d.line.slice(0,s-d.startIndex),f=c.slice(0,p);c=c.slice(p);let b=vt(u,et(e),e.lineHeight);if(u===""&&(b.width=0),e.textAlign!=="left"&&d.line.length>0){let T=vt(d.line,et(e),e.lineHeight),I=e.textAlign==="center"?(e.width-T.width)/2:e.width-T.width;b.width+=I}let{width:x,height:E}=vt(f,et(e),e.lineHeight),y=b.width,v=d.lineNumber*b.height;m.push({offsetX:y,offsetY:v,width:x,height:E,showOnCanvas:!0}),s+=p}}return m},$I=(e,o,t,r)=>{let n=e.name??Sp(e),i=n.slice(t,t+o.length),a=n.slice(0,t),l=et({fontSize:Pt.nameFontSize,fontFamily:pt.Assistant}),s=zo(pt.Assistant),c=vt(a,l,s);a===""&&(c.width=0);let m=vt(i,l,s),d=c.width,p=-c.height-Pt.strokeWidth,u=m.width;return[{offsetX:d,offsetY:p,width:u,height:m.height,showOnCanvas:d+u<=e.width*r}]},jI=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),Gw=FI((e,o,t)=>{if(!e||e===""){t([],null);return}let r=o.scene.getNonDeletedElements(),n=r.filter(p=>V(p)),i=r.filter(p=>ce(p));n.sort((p,u)=>p.y-u.y),i.sort((p,u)=>p.y-u.y);let a=[],l=new RegExp(jI(e),"gi");for(let p of n){let u=null,f=p.originalText;for(;(u=l.exec(f))!==null;){let b=Uw(f,u.index,e),x=XI(p,e,u.index);x.length>0&&a.push({element:p,searchQuery:e,preview:b,index:u.index,matchedLines:x})}}let s=[];for(let p of i){let u=null,f=p.name??Sp(p);for(;(u=l.exec(f))!==null;){let b=Uw(f,u.index,e),x=$I(p,e,u.index,o.state.zoom.value);x.length>0&&s.push({element:p,searchQuery:e,preview:b,index:u.index,matchedLines:x})}}let c=new Set(o.visibleElements.map(p=>p.id)),m=[...s,...a],d=m.findIndex(p=>c.has(p.element.id))??null;t(m,d)},YI);import{jsx as Qo,jsxs as Ww}from"react/jsx-runtime";import{createElement as QI}from"react";var Vw=Or("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:o}=je();return Qo(o.In,{children:Qo(No.Trigger,{...e,className:"default-sidebar-trigger",name:Dt.name})})});Vw.displayName="DefaultSidebarTrigger";var Kw=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:o}=je();return Qo(o.In,{children:e})};Kw.displayName="DefaultTabTriggers";var Cm=Object.assign(Or("DefaultSidebar",({children:e,className:o,onDock:t,docked:r,...n})=>{let i=Me(),a=ve(),{DefaultSidebarTabTriggersTunnel:l}=je(),s=i.openSidebar?.tab===yr;return QI(No,{...n,name:"default",key:"default",className:JI("default-sidebar",o),docked:s||(r??i.defaultSidebarDockedPreference),onDock:s||t===!1||!t&&r!=null?void 0:Vr(t,c=>{a({defaultSidebarDockedPreference:c})})},Ww(No.Tabs,{children:[Qo(No.Header,{children:Ww(No.TabTriggers,{children:[Qo(No.TabTrigger,{tab:yr,children:uo}),Qo(No.TabTrigger,{tab:tl,children:Ji}),Qo(l.Out,{})]})}),Qo(No.Tab,{tab:tl,children:Qo(Hy,{})}),Qo(No.Tab,{tab:yr,children:Qo(Yw,{})}),e]}))}),{Trigger:Vw,TabTriggers:Kw});import{useEffect as uM,useRef as Og,useState as Rm}from"react";import{useState as qw,useRef as Jw,useEffect as Qw,useDeferredValue as aM}from"react";import{useEffect as eM,useRef as Zw}from"react";import{jsx as tM}from"react/jsx-runtime";var km=({input:e,placeholder:o,onChange:t,onKeyboardSubmit:r})=>{let n=Zw(null),i=Zw(r);return i.current=r,eM(()=>{if(!i.current)return;let a=n.current;if(a){let l=s=>{s[w.CTRL_OR_CMD]&&s.key===w.ENTER&&(s.preventDefault(),i.current?.())};return a.focus(),a.addEventListener("keydown",l),()=>{a.removeEventListener("keydown",l)}}},[]),tM("textarea",{className:"ttd-dialog-input",onChange:t,value:e,placeholder:o,ref:n})};import{jsx as Sm,jsxs as Xw}from"react/jsx-runtime";var oM=({error:e})=>Xw("div",{"data-testid":"ttd-dialog-output-error",className:"ttd-dialog-output-error",children:["Error! ",Sm("p",{children:e})]}),Im=({error:e,canvasRef:o,loaded:t})=>Xw("div",{className:"ttd-dialog-output-wrapper",children:[e&&Sm(oM,{error:e.message}),t?Sm("div",{ref:o,style:{opacity:e?"0.15":1},className:"ttd-dialog-output-canvas-container"}):Sm(At,{size:"2rem"})]});import $w from"clsx";import{jsx as Rg,jsxs as ds}from"react/jsx-runtime";var Ha=({label:e,children:o,panelAction:t,panelActionDisabled:r=!1,onTextSubmitInProgess:n,renderTopRight:i,renderSubmitShortcut:a,renderBottomRight:l})=>ds("div",{className:"ttd-dialog-panel",children:[ds("div",{className:"ttd-dialog-panel__header",children:[Rg("label",{children:e}),i?.()]}),o,ds("div",{className:$w("ttd-dialog-panel-button-container",{invisible:!t}),style:{display:"flex",alignItems:"center"},children:[ds(go,{className:"ttd-dialog-panel-button",onSelect:t?t.action:()=>{},disabled:r||n,children:[ds("div",{className:$w({invisible:n}),children:[t?.label,t?.icon&&Rg("span",{children:t.icon})]}),n&&Rg(At,{})]}),!r&&!n&&a?.(),l?.()]})]});import{jsx as rM}from"react/jsx-runtime";var Mm=({children:e})=>rM("div",{className:"ttd-dialog-panels",children:e});import{jsx as jw,jsxs as nM}from"react/jsx-runtime";var Lm=()=>nM("div",{className:"ttd-dialog-submit-shortcut",children:[jw("div",{className:"ttd-dialog-submit-shortcut__key",children:D("CtrlOrCmd")}),jw("div",{className:"ttd-dialog-submit-shortcut__key",children:D("Enter")})]});var iM=({canvasRef:e,setError:o})=>{let t=e.current;if(!t)return;let r=t.parentElement;r&&(r.style.background="",o(null),t.replaceChildren())},Am=async({canvasRef:e,mermaidToExcalidrawLib:o,mermaidDefinition:t,setError:r,data:n})=>{let i=e.current,a=i?.parentElement;if(!(!i||!a)){if(!t){iM({canvasRef:e,setError:r});return}try{let l=await o.api,s;try{s=await l.parseMermaidToExcalidraw(t)}catch{s=await l.parseMermaidToExcalidraw(t.replace(/"/g,"'"))}let{elements:c,files:m}=s;r(null),n.current={elements:Na(c,{regenerateIds:!0}),files:m};let d=await xn({elements:n.current.elements,files:n.current.files,exportPadding:Ur,maxWidthOrHeight:Math.max(a.offsetWidth,a.offsetHeight)*window.devicePixelRatio});try{await Sr(d)}catch(p){throw p.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):p}a.style.background="var(--default-bg-color)",i.replaceChildren(d)}catch(l){throw a.style.background="var(--default-bg-color)",t&&r(l),l}}},ms=e=>{_o.set(Gr.MERMAID_TO_EXCALIDRAW,e)},_m=({app:e,data:o,text:t,shouldSaveMermaidDataToStorage:r})=>{let{elements:n,files:i}=o.current;n.length&&(e.addElementsFromPasteOrLibrary({elements:n,files:i,position:"center",fitToContent:!0}),e.setOpenDialog(null),r&&t&&ms(t))};import{Fragment as cM,jsx as br,jsxs as t3}from"react/jsx-runtime";var lM=`flowchart TD
18
+ `)},rB=(e,o,t)=>{let n=oB(e.text,e.originalText).split(`
19
+ `),i=[],a=0,l=0;for(let m of n){let p=a,u=p+m.length-1;i.push({line:m,startIndex:p,endIndex:u,lineNumber:l}),a=u+1,l++}let s=t,c=e.originalText.slice(t,t+o.length),d=[];for(let m of i){if(c==="")break;if(s>=m.startIndex&&s<=m.endIndex){let p=m.endIndex+1-s,u=m.line.slice(0,s-m.startIndex),f=c.slice(0,p);c=c.slice(p);let b=sl(u,Ed(e),e.lineHeight);if(u===""&&(b.width=0),e.textAlign!=="left"&&m.line.length>0){let v=sl(m.line,Ed(e),e.lineHeight),C=e.textAlign==="center"?(e.width-v.width)/2:e.width-v.width;b.width+=C}let{width:x,height:w}=sl(f,Ed(e),e.lineHeight),E=b.width,y=m.lineNumber*b.height;d.push({offsetX:E,offsetY:y,width:x,height:w,showOnCanvas:!0}),s+=p}}return d},nB=(e,o,t,r)=>{let n=e.name??_3(e),i=n.slice(t,t+o.length),a=n.slice(0,t),l=Ed({fontSize:fg.nameFontSize,fontFamily:gg.Assistant}),s=KN(gg.Assistant),c=sl(a,l,s);a===""&&(c.width=0);let d=sl(i,l,s),m=c.width,p=-c.height-fg.strokeWidth,u=d.width;return[{offsetX:m,offsetY:p,width:u,height:d.height,showOnCanvas:m+u<=e.width*r}]},iB=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),A3=UN((e,o,t)=>{if(!e||e===""){t([],null);return}let r=o.scene.getNonDeletedElements(),n=r.filter(p=>D3(p)),i=r.filter(p=>yd(p));n.sort((p,u)=>p.y-u.y),i.sort((p,u)=>p.y-u.y);let a=[],l=new RegExp(iB(e),"gi");for(let p of n){let u=null,f=p.originalText;for(;(u=l.exec(f))!==null;){let b=P3(f,u.index,e),x=rB(p,e,u.index);x.length>0&&a.push({element:p,searchQuery:e,preview:b,index:u.index,matchedLines:x})}}let s=[];for(let p of i){let u=null,f=p.name??_3(p);for(;(u=l.exec(f))!==null;){let b=P3(f,u.index,e),x=nB(p,e,u.index,o.state.zoom.value);x.length>0&&s.push({element:p,searchQuery:e,preview:b,index:u.index,matchedLines:x})}}let c=new Set(o.visibleElements.map(p=>p.id)),d=[...s,...a],m=d.findIndex(p=>c.has(p.element.id))??null;t(d,m)},JN);import{jsx as so,jsxs as B3}from"react/jsx-runtime";import{createElement as dB}from"react";var F3=Wo("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:o}=Ae();return so(o.In,{children:so(Kt.Trigger,{...e,className:"default-sidebar-trigger",name:sB.name})})});F3.displayName="DefaultSidebarTrigger";var O3=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:o}=Ae();return so(o.In,{children:e})};O3.displayName="DefaultTabTriggers";var wd=Object.assign(Wo("DefaultSidebar",({children:e,className:o,onDock:t,docked:r,...n})=>{let i=ge(),a=le(),{DefaultSidebarTabTriggersTunnel:l}=Ae(),s=i.openSidebar?.tab===xg;return dB(Kt,{...n,name:"default",key:"default",className:lB("default-sidebar",o),docked:s||(r??i.defaultSidebarDockedPreference),onDock:s||t===!1||!t&&r!=null?void 0:cB(t,c=>{a({defaultSidebarDockedPreference:c})})},B3(Kt.Tabs,{children:[so(Kt.Header,{children:B3(Kt.TabTriggers,{children:[so(Kt.TabTrigger,{tab:xg,children:At}),so(Kt.TabTrigger,{tab:N3,children:In}),so(l.Out,{})]})}),so(Kt.Tab,{tab:N3,children:so(a2,{})}),so(Kt.Tab,{tab:xg,children:so(R3,{})}),e]}))}),{Trigger:F3,TabTriggers:O3});import{useEffect as PB,useRef as wg,useState as Ad}from"react";import{isFiniteNumber as a5}from"@excalidraw/math";import{useState as X3,useRef as K3,useEffect as Z3,useDeferredValue as EB}from"react";import{EDITOR_LS_KEYS as yB,debounce as wB,isDevEnv as vB}from"@excalidraw/common";import{useEffect as mB,useRef as z3}from"react";import{EVENT as H3,KEYS as G3}from"@excalidraw/common";import{jsx as pB}from"react/jsx-runtime";var vd=({input:e,placeholder:o,onChange:t,onKeyboardSubmit:r})=>{let n=z3(null),i=z3(r);return i.current=r,mB(()=>{if(!i.current)return;let a=n.current;if(a){let l=s=>{s[G3.CTRL_OR_CMD]&&s.key===G3.ENTER&&(s.preventDefault(),i.current?.())};return a.focus(),a.addEventListener(H3.KEYDOWN,l),()=>{a.removeEventListener(H3.KEYDOWN,l)}}},[]),pB("textarea",{className:"ttd-dialog-input",onChange:t,value:e,placeholder:o,ref:n})};import{jsx as Td,jsxs as U3}from"react/jsx-runtime";var uB=({error:e})=>U3("div",{"data-testid":"ttd-dialog-output-error",className:"ttd-dialog-output-error",children:["Error! ",Td("p",{children:e})]}),Id=({error:e,canvasRef:o,loaded:t})=>U3("div",{className:"ttd-dialog-output-wrapper",children:[e&&Td(uB,{error:e.message}),t?Td("div",{ref:o,style:{opacity:e?"0.15":1},className:"ttd-dialog-output-canvas-container"}):Td(tt,{size:"2rem"})]});import Y3 from"clsx";import{jsx as Eg,jsxs as cl}from"react/jsx-runtime";var Ni=({label:e,children:o,panelAction:t,panelActionDisabled:r=!1,onTextSubmitInProgess:n,renderTopRight:i,renderSubmitShortcut:a,renderBottomRight:l})=>cl("div",{className:"ttd-dialog-panel",children:[cl("div",{className:"ttd-dialog-panel__header",children:[Eg("label",{children:e}),i?.()]}),o,cl("div",{className:Y3("ttd-dialog-panel-button-container",{invisible:!t}),style:{display:"flex",alignItems:"center"},children:[cl(Rt,{className:"ttd-dialog-panel-button",onSelect:t?t.action:()=>{},disabled:r||n,children:[cl("div",{className:Y3({invisible:n}),children:[t?.label,t?.icon&&Eg("span",{children:t.icon})]}),n&&Eg(tt,{})]}),!r&&!n&&a?.(),l?.()]})]});import{jsx as hB}from"react/jsx-runtime";var Cd=({children:e})=>hB("div",{className:"ttd-dialog-panels",children:e});import{getShortcutKey as W3}from"@excalidraw/common";import{jsx as V3,jsxs as gB}from"react/jsx-runtime";var Sd=()=>gB("div",{className:"ttd-dialog-submit-shortcut",children:[V3("div",{className:"ttd-dialog-submit-shortcut__key",children:W3("CtrlOrCmd")}),V3("div",{className:"ttd-dialog-submit-shortcut__key",children:W3("Enter")})]});import{DEFAULT_EXPORT_PADDING as fB,EDITOR_LS_KEYS as bB}from"@excalidraw/common";var xB=({canvasRef:e,setError:o})=>{let t=e.current;if(!t)return;let r=t.parentElement;r&&(r.style.background="",o(null),t.replaceChildren())},kd=async({canvasRef:e,mermaidToExcalidrawLib:o,mermaidDefinition:t,setError:r,data:n})=>{let i=e.current,a=i?.parentElement;if(!(!i||!a)){if(!t){xB({canvasRef:e,setError:r});return}try{let l=await o.api,s;try{s=await l.parseMermaidToExcalidraw(t)}catch{s=await l.parseMermaidToExcalidraw(t.replace(/"/g,"'"))}let{elements:c,files:d}=s;r(null),n.current={elements:Pi(c,{regenerateIds:!0}),files:d};let m=await cr({elements:n.current.elements,files:n.current.files,exportPadding:fB,maxWidthOrHeight:Math.max(a.offsetWidth,a.offsetHeight)*window.devicePixelRatio});try{await Lo(m)}catch(p){throw p.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):p}a.style.background="var(--default-bg-color)",i.replaceChildren(m)}catch(l){throw a.style.background="var(--default-bg-color)",t&&r(l),l}}},dl=e=>{Ut.set(bB.MERMAID_TO_EXCALIDRAW,e)},Md=({app:e,data:o,text:t,shouldSaveMermaidDataToStorage:r})=>{let{elements:n,files:i}=o.current;n.length&&(e.addElementsFromPasteOrLibrary({elements:n,files:i,position:"center",fitToContent:!0}),e.setOpenDialog(null),r&&t&&dl(t))};import{Fragment as CB,jsx as So,jsxs as j3}from"react/jsx-runtime";var TB=`flowchart TD
13
20
  A[Christmas] -->|Get money| B(Go shopping)
14
21
  B --> C{Let me think}
15
22
  C -->|One| D[Laptop]
16
23
  C -->|Two| E[iPhone]
17
- C -->|Three| F[Car]`,e3=Un(ms,300),sM=({mermaidToExcalidrawLib:e})=>{let[o,t]=qw(()=>_o.get(Gr.MERMAID_TO_EXCALIDRAW)||lM),r=aM(o.trim()),[n,i]=qw(null),a=Jw(null),l=Jw({elements:[],files:null}),s=tt();Qw(()=>{Am({canvasRef:a,data:l,mermaidToExcalidrawLib:e,setError:i,mermaidDefinition:r}).catch(m=>{ft()&&console.error("Failed to parse mermaid definition",m)}),e3(r)},[r,e]),Qw(()=>()=>{e3.flush()},[]);let c=()=>{_m({app:s,data:l,text:o,shouldSaveMermaidDataToStorage:!0})};return t3(cM,{children:[br("div",{className:"ttd-dialog-desc",children:br(Gt,{i18nKey:"mermaid.description",flowchartLink:m=>br("a",{href:"https://mermaid.js.org/syntax/flowchart.html",children:m}),sequenceLink:m=>br("a",{href:"https://mermaid.js.org/syntax/sequenceDiagram.html",children:m}),classLink:m=>br("a",{href:"https://mermaid.js.org/syntax/classDiagram.html",children:m})})}),t3(Mm,{children:[br(Ha,{label:g("mermaid.syntax"),children:br(km,{input:o,placeholder:"Write Mermaid diagram defintion here...",onChange:m=>t(m.target.value),onKeyboardSubmit:()=>{c()}})}),br(Ha,{label:g("mermaid.preview"),panelAction:{action:()=>{c()},label:g("mermaid.button"),icon:na},renderSubmitShortcut:()=>br(Lm,{}),children:br(Im,{canvasRef:a,loaded:e.loaded,error:n})})]})]})},o3=sM;import*as n3 from"@radix-ui/react-tabs";import{useRef as r3}from"react";import{jsx as dM}from"react/jsx-runtime";var i3=e=>{let o=ve(),t=r3(null),r=r3(0);return dM(n3.Root,{ref:t,className:"ttd-dialog-tabs-root",value:e.tab,onValueChange:n=>{if(!n)return;let i=t.current?.closest(".Modal__content");if(i){let a=i.offsetHeight||0;a>r.current&&(r.current=a,i.style.minHeight=`min(${r.current}px, 100%)`)}e.dialog==="ttd"&&Vs(["text-to-diagram","mermaid"],n)&&o({openDialog:{name:e.dialog,tab:n}})},children:e.children})};i3.displayName="TTDDialogTabs";var a3=i3;import*as l3 from"@radix-ui/react-tabs";import{jsx as mM}from"react/jsx-runtime";var Ng=({children:e,...o})=>mM(l3.List,{className:"ttd-dialog-triggers",...o,children:e});Ng.displayName="TTDDialogTabTriggers";import*as c3 from"@radix-ui/react-tabs";import{jsx as s3}from"react/jsx-runtime";var Pm=({children:e,tab:o,onSelect:t,...r})=>s3(c3.Trigger,{value:o,asChild:!0,onSelect:t,children:s3("button",{type:"button",className:"ttd-dialog-tab-trigger",...r,children:e})});Pm.displayName="TTDDialogTabTrigger";import*as d3 from"@radix-ui/react-tabs";import{jsx as pM}from"react/jsx-runtime";var Dm=({tab:e,children:o,...t})=>pM(d3.Content,{...t,value:e,children:o});Dm.displayName="TTDDialogTab";import{jsx as Zt,jsxs as Ln}from"react/jsx-runtime";var Bg=3,Ua=1e3,hM=Ie(null),gM=Ie(null),zg=e=>{let o=Me();return o.openDialog?.name!=="ttd"?null:Zt(fM,{...e,tab:o.openDialog.tab})},fM=Or("TTDDialogBase",({tab:e,...o})=>{let t=tt(),r=ve(),n=Og(null),[i,a]=Ee(gM),[l,s]=Rm(i?.prompt??""),c=l.trim(),m=S=>{s(S.target.value),a(P=>({generatedResponse:P?.generatedResponse??null,prompt:S.target.value}))},[d,p]=Rm(!1),[u,f]=Ee(hM),b=async()=>{if(c.length>Ua||c.length<Bg||d||u?.rateLimitRemaining===0||"__fallback"in o){c.length<Bg&&I(new Error(`Prompt is too short (min ${Bg} characters)`)),c.length>Ua&&I(new Error(`Prompt is too long (max ${Ua} characters)`));return}try{p(!0),me("ai","generate","ttd");let{generatedResponse:S,error:P,rateLimit:M,rateLimitRemaining:O}=await o.onTextSubmit(c);if(typeof S=="string"&&a(R=>({generatedResponse:S,prompt:R?.prompt??null})),ap(M)&&ap(O)&&f({rateLimit:M,rateLimitRemaining:O}),P){I(P);return}if(!S){I(new Error("Generation failed"));return}try{await Am({canvasRef:n,data:v,mermaidToExcalidrawLib:E,setError:I,mermaidDefinition:S}),me("ai","mermaid parse success","ttd")}catch(R){console.info(`%cTTD mermaid render errror: ${R.message}`,"color: red"),console.info(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
18
- TTD mermaid definition render errror: ${R.message}`,"color: yellow"),me("ai","mermaid parse failed","ttd"),I(new Error("Generated an invalid diagram :(. You may also try a different prompt."))}}catch(S){let P=S.message;(!P||P==="Failed to fetch")&&(P="Request failed"),I(new Error(P))}finally{p(!1)}},x=Og(b);x.current=b;let[E,y]=Rm({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw")});uM(()=>{(async()=>{await E.api,y(P=>({...P,loaded:!0}))})()},[E.api]);let v=Og({elements:[],files:null}),[T,I]=Rm(null);return Zt(ot,{className:"ttd-dialog",onCloseRequest:()=>{t.setOpenDialog(null)},size:1200,title:!1,...o,autofocus:!1,children:Ln(a3,{dialog:"ttd",tab:e,children:["__fallback"in o&&o.__fallback?Zt("p",{className:"dialog-mermaid-title",children:g("mermaid.title")}):Ln(Ng,{children:[Zt(Pm,{tab:"text-to-diagram",children:Ln("div",{style:{display:"flex",alignItems:"center"},children:[g("labels.textToDiagram"),Zt("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"1px 6px",marginLeft:"10px",fontSize:10,borderRadius:"12px",background:"var(--color-promo)",color:"var(--color-surface-lowest)"},children:"AI Beta"})]})}),Zt(Pm,{tab:"mermaid",children:"Mermaid"})]}),Zt(Dm,{className:"ttd-dialog-content",tab:"mermaid",children:Zt(o3,{mermaidToExcalidrawLib:E})}),!("__fallback"in o)&&Ln(Dm,{className:"ttd-dialog-content",tab:"text-to-diagram",children:[Zt("div",{className:"ttd-dialog-desc",children:"Currently we use Mermaid as a middle step, so you'll get best results if you describe a diagram, workflow, flow chart, and similar."}),Ln(Mm,{children:[Zt(Ha,{label:g("labels.prompt"),panelAction:{action:b,label:"Generate",icon:na},onTextSubmitInProgess:d,panelActionDisabled:c.length>Ua||u?.rateLimitRemaining===0,renderTopRight:()=>u?Ln("div",{className:"ttd-dialog-rate-limit",style:{fontSize:12,marginLeft:"auto",color:u.rateLimitRemaining===0?"var(--color-danger)":void 0},children:[u.rateLimitRemaining," requests left today"]}):null,renderSubmitShortcut:()=>Zt(Lm,{}),renderBottomRight:()=>{if(typeof i?.generatedResponse=="string")return Ln("div",{className:"excalidraw-link",style:{marginLeft:"auto",fontSize:14},onClick:()=>{typeof i?.generatedResponse=="string"&&(ms(i.generatedResponse),r({openDialog:{name:"ttd",tab:"mermaid"}}))},children:["View as Mermaid",Zt(gn,{icon:na})]});let S=c.length/Ua;return S>.8?Ln("div",{style:{marginLeft:"auto",fontSize:12,fontFamily:"monospace",color:S>1?"var(--color-danger)":void 0},children:["Length: ",c.length,"/",Ua]}):null},children:Zt(km,{onChange:m,input:l,placeholder:"Describe what you want to see...",onKeyboardSubmit:()=>{x.current()}})}),Zt(Ha,{label:"Preview",panelAction:{action:()=>{console.info("Panel action clicked"),_m({app:t,data:v})},label:"Insert",icon:na},children:Zt(Im,{canvasRef:n,error:T,loaded:E.loaded})})]})]})]})})});import i7 from"clsx";import a7 from"lodash.throttle";import{useEffect as T3,useMemo as Wg,useState as l7,memo as s7}from"react";import bM from"clsx";import{useEffect as p3,useRef as Nm,useState as xM}from"react";var m3=.01,ps=10,ao=(e,o)=>!(o==="angle"&&ce(e)),Ve=(e,o)=>{let t=e+o/2;return t-t%o},Ga=(e,o,t)=>Object.keys(e).map(r=>({original:(t??o).get(r),latest:o.get(r)})).filter(r=>r.original!==void 0&&r.latest!==void 0);var gi=(e,o,t,r,n,i=!0)=>{let a=r.getNonDeletedElementsMap(),l=a.get(t.id);if(!l)return;let[s,c]=[t.x+t.width/2,t.y+t.height/2],[m,d]=Re(L(t.x,t.y),L(s,c),t.angle),p=e-m,u=o-d,[f,b]=Re(L(e,o),L(s+p,c+u),-t.angle);r.mutateElement(l,{x:f,y:b},{informMutation:i,isDragging:!1}),jr(l,r);let x=pe(t,n);if(x){let E=a.get(x.id);E&&r.mutateElement(E,{x:x.x+p,y:x.y+u},{informMutation:i,isDragging:!1})}if(ce(t)){let E=Wo(n,t.id);E.forEach(y=>{let v=a.get(y.id);if(!v)return;let[T,I]=[y.x+y.width/2,y.y+y.height/2],[S,P]=Re(L(y.x,y.y),L(T,I),y.angle),M=Math.round(S+p),O=Math.round(P+u),[R,z]=Re(L(M,O),L(T+p,I+u),-y.angle);r.mutateElement(v,{x:R,y:z},{informMutation:i,isDragging:!1}),jr(v,r,{simultaneouslyUpdated:E})})}},Ya=(e,o)=>{let r=Yo(o).map(n=>He(e,n).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(n=>!qr(n)).forEach(n=>{r.push({[n.id]:!0})}),r};import{jsx as Fg,jsxs as yM}from"react/jsx-runtime";var EM=({label:e,icon:o,dragInputCallback:t,value:r,elements:n,editable:i=!0,shouldKeepAspectRatio:a,property:l,scene:s,appState:c,sensitivity:m=1})=>{let d=tt(),p=Nm(null),u=Nm(null),[f,b]=xM(r.toString()),x=Nm(null);x.current||(x.current={originalAppState:jt(c),originalElements:n,lastUpdatedValue:f,updatePending:!1}),p3(()=>{let v=r.toString();b(v),x.current.lastUpdatedValue=v},[r]);let E=(v,T,I)=>{if(!x.current.updatePending)return!1;x.current.updatePending=!1;let S=Number(v);if(isNaN(S)){b(r.toString());return}let P=Number(S.toFixed(2)),M=Number(r);(isNaN(M)||Math.abs(P-M)>=m3)&&(x.current.lastUpdatedValue=v,t({accumulatedChange:0,instantChange:0,originalElements:T,originalElementsMap:d.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:s,nextValue:P,property:l,originalAppState:I,setInputValue:O=>b(String(O))}),d.syncActionResult({captureUpdate:A.IMMEDIATELY}))},y=Nm({});return y.current.handleInputValue=E,p3(()=>{let v=p.current,T=y.current;return()=>{let I=v?.value;I&&T.handleInputValue?.(I,x.current.originalElements,x.current.originalAppState),window.removeEventListener("pointermove",T.onPointerMove,!1),window.removeEventListener("pointerup",T.onPointerUp,!1)}},[i]),i?yM("div",{className:bM("drag-input-container",!i&&"disabled"),"data-testid":e,children:[Fg("div",{className:"drag-input-label",ref:u,onPointerDown:v=>{if(p.current&&i){document.body.classList.add("excalidraw-cursor-resize");let T=Number(p.current.value);isNaN(T)&&(T=0);let I=null,S=d.scene.getNonDeletedElements().reduce((Y,oe)=>(Y.set(oe.id,Vo(oe)),Y),new Map),P=n.map(Y=>S.get(Y.id)),M=jt(c),O=0,R=0,z=Y=>{if(I&&S!==null&&P!==null){let oe=Y.clientX-I.x;oe!==0&&(R+=oe,Math.abs(R)>=m&&(R=Math.sign(R)*Math.floor(Math.abs(R)/m),O+=R,t({accumulatedChange:O,instantChange:R,originalElements:P,originalElementsMap:S,shouldKeepAspectRatio:a,shouldChangeByStepSize:Y.shiftKey,property:l,scene:s,originalAppState:M,setInputValue:H=>b(String(H))}),R=0))}I={x:Y.clientX,y:Y.clientY}},W=()=>{window.removeEventListener("pointermove",z,!1),d.syncActionResult({captureUpdate:A.IMMEDIATELY}),I=null,O=0,R=0,P=null,S=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener("pointerup",W,!1)};y.current.onPointerMove=z,y.current.onPointerUp=W,window.addEventListener("pointermove",z,!1),window.addEventListener("pointerup",W,!1)}},onPointerEnter:()=>{u.current&&(u.current.style.cursor="ew-resize")},children:o?Fg(gn,{icon:o}):e}),Fg("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:v=>{if(i){let T=v.target;T instanceof HTMLInputElement&&v.key===w.ENTER&&(E(T.value,n,c),d.focusContainer())}},ref:p,value:f,onChange:v=>{x.current.updatePending=!0,b(v.target.value)},onFocus:v=>{v.target.select(),x.current.originalElements=n,x.current.originalAppState=jt(c)},onBlur:v=>{f?i&&E(v.target.value,x.current.originalElements,x.current.originalAppState):b(r.toString())},disabled:!i})]}):null},It=EM;import{jsx as CM}from"react/jsx-runtime";var vM=15,wM=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=o[0];if(a&&!se(a)){let l=i.get(a.id);if(!l)return;if(r!==void 0){let u=Ti(r);n.mutateElement(l,{angle:u}),jr(l,n);let f=pe(l,i);f&&!Pe(l)&&n.mutateElement(f,{angle:u});return}let s=Math.round(Ci(a.angle)*100)/100,c=Math.round(e),m=(s+c)%360;t&&(m=Ve(m,vM)),m=m<0?m+360:m;let d=Ti(m);n.mutateElement(l,{angle:d}),jr(l,n);let p=pe(l,i);p&&!Pe(l)&&n.mutateElement(p,{angle:d})}},TM=({element:e,scene:o,appState:t,property:r})=>CM(It,{label:"A",icon:Wc,value:Math.round(Ci(e.angle)%360*100)/100,elements:[e],dragInputCallback:wM,editable:ao(e,"angle"),scene:o,appState:t,property:r}),u3=TM;import{jsx as SM}from"react/jsx-runtime";var h3=5,kM=({property:e,scene:o,appState:t,setAppState:r})=>SM(It,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:n,instantChange:i,shouldChangeByStepSize:a,setInputValue:l})=>{r(s=>{let c;return n?c=n:i&&(c=a?Ve(s.gridStep+h3*Math.sign(i),h3):s.gridStep+i),c?(c=ob(c),l(c),{gridStep:c}):(l(s.gridStep),null)})},scene:o,value:t.gridStep,property:e,appState:t}),g3=kM;import{jsx as AM}from"react/jsx-runtime";var f3=10,IM=e=>e.type==="image",MM=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldKeepAspectRatio:r,shouldChangeByStepSize:n,nextValue:i,property:a,originalAppState:l,instantChange:s,scene:c})=>{let m=c.getNonDeletedElementsMap(),d=o[0],p=m.get(d.id);if(d&&p){let u=r||IM(d),f=d.width/d.height;if(l.croppingElementId===d.id){let v=m.get(d.id);if(!v||!Ne(v)||!v.crop)return;let T=v.crop,I={...T},S=v.scale[0]===-1,P=v.scale[1]===-1,{width:M,height:O}=Wn(v),R=T.naturalWidth/M,z=T.naturalHeight/O,W=S?T.width+T.x:T.naturalWidth-T.x,Y=P?T.height+T.y:T.naturalHeight-T.y,oe=gp*R,H=gp*z;if(i!==void 0){if(a==="width"){let de=i*R,he=Et(de,oe,W);I={...I,width:he,x:S?T.x+T.width-he:T.x}}else if(a==="height"){let de=i*z,he=Et(de,H,Y);I={...I,height:he,y:P?T.y+T.height-he:T.y}}c.mutateElement(v,{crop:I,width:I.width/(T.naturalWidth/M),height:I.height/(T.naturalHeight/O)});return}let F=a==="width"?s:0,ee=a==="height"?s:0,ie=Et(T.width+F,oe,W),X=Et(T.height+ee,oe,Y);I={...T,x:S?T.x+T.width-ie:T.x,y:P?T.y+T.height-X:T.y,width:ie,height:X},c.mutateElement(v,{crop:I,width:I.width/(T.naturalWidth/M),height:I.height/(T.naturalHeight/O)});return}if(i!==void 0){let v=Math.max(a==="width"?i:u?i*f:d.width,$t),T=Math.max(a==="height"?i:u?i/f:d.height,$t);Gi(v,T,p,d,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:u});return}let b=a==="width"?e:0,x=a==="height"?e:0,E=Math.max(0,d.width+b);a==="width"&&(n?E=Ve(E,f3):E=Math.round(E));let y=Math.max(0,d.height+x);a==="height"&&(n?y=Ve(y,f3):y=Math.round(y)),u&&(a==="width"?y=Math.round(E/f*100)/100:E=Math.round(y*f*100)/100),y=Math.max($t,y),E=Math.max($t,E),Gi(E,y,p,d,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:u})}},LM=({property:e,element:o,scene:t,appState:r})=>{let n=Eo(e==="width"?o.width:o.height,2);if(r.croppingElementId&&r.croppingElementId===o.id&&Ne(o)&&o.crop){let{width:i,height:a}=Wn(o);if(e==="width"){let l=i/o.crop.naturalWidth;n=Eo(o.crop.width*l,2)}if(e==="height"){let l=a/o.crop.naturalHeight;n=Eo(o.crop.height*l,2)}}return AM(It,{label:e==="width"?"W":"H",elements:[o],dragInputCallback:MM,value:n,editable:ao(o,e),scene:t,appState:r,property:e})},Hg=LM;import{jsx as RM}from"react/jsx-runtime";var b3=4,_M=4,PM=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=o[0];if(a){let l=i.get(a.id);if(!l||!V(l))return;let s;if(r!==void 0)s=Math.max(Math.round(r),b3);else if(a.type==="text"){let c=Math.round(a.fontSize),m=Math.round(e);s=Math.max(c+m,b3),t&&(s=Ve(s,_M))}s&&(n.mutateElement(l,{fontSize:s}),Ke(l,n.getContainerElement(l),n))}},DM=({element:e,scene:o,appState:t,property:r})=>{let n=V(e)?e:bt(e)?pe(e,o.getNonDeletedElementsMap()):null;return n?RM(It,{label:"F",value:Math.round(n.fontSize*10)/10,elements:[n],dragInputCallback:PM,icon:oi,appState:t,scene:o,property:r}):null},x3=DM;import{jsx as zM}from"react/jsx-runtime";var NM=15,OM=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,property:n,scene:i})=>{let a=i.getNonDeletedElementsMap(),l=o.map(c=>a.get(c.id)).filter(c=>c&&!qr(c)&&ao(c,n)),s=o.filter(c=>!qr(c)&&ao(c,n));if(r!==void 0){let c=Ti(r);for(let m of l){if(!m)continue;i.mutateElement(m,{angle:c});let d=pe(m,a);d&&!Pe(m)&&i.mutateElement(d,{angle:c})}i.triggerUpdate();return}for(let c=0;c<l.length;c++){let m=l[c];if(!m)continue;let d=s[c],p=Math.round(Ci(d.angle)*100)/100,u=Math.round(e),f=(p+u)%360;t&&(f=Ve(f,NM)),f=f<0?f+360:f;let b=Ti(f);i.mutateElement(m,{angle:b});let x=pe(m,a);x&&!Pe(m)&&i.mutateElement(x,{angle:b})}i.triggerUpdate()},BM=({elements:e,scene:o,appState:t,property:r})=>{let n=e.filter(s=>!qr(s)&&ao(s,"angle")),i=n.map(s=>Math.round(Ci(s.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",l=n.some(s=>ao(s,"angle"));return zM(It,{label:"A",icon:Wc,value:a,elements:e,dragInputCallback:OM,editable:l,appState:t,scene:o,property:r})},E3=BM;import{useMemo as FM}from"react";import{jsx as WM}from"react/jsx-runtime";var Wa=10,HM=(e,o,t,r)=>{let n=r.x-e,i=r.y-o,a=r.width*t,l=r.height*t,s=e+n*t,c=o+i*t;return{width:a,height:l,x:s,y:c,...W0(r,a,l,!1),...V(r)?{fontSize:r.fontSize*t}:{}}},UM=(e,o,t,r,n,i,a,l)=>{let s=l.getNonDeletedElementsMap(),c=HM(e,o,r,i);l.mutateElement(n,c);let m=pe(i,a);if(m){let d=m.fontSize*r;$r(n,l,{newSize:{width:c.width,height:c.height}});let p=s.get(m.id);p&&V(p)&&(l.mutateElement(p,{fontSize:d}),K1(n,l,t==="width"?"e":"s",!0))}},y3=(e,o,t,r,n,i,a,l,s,c)=>{i==="width"?o=Math.round(e/r*100)/100:e=Math.round(o*r*100)/100;let m=o/t;for(let d=0;d<l.length;d++){let p=l[d],u=a[d];UM(n[0],n[1],i,m,u,p,s,c)}},GM=({accumulatedChange:e,originalElements:o,originalElementsMap:t,originalAppState:r,shouldChangeByStepSize:n,nextValue:i,scene:a,property:l})=>{let s=a.getNonDeletedElementsMap(),c=Ya(o,r);if(i!==void 0){for(let p of c){let u=Ga(p,s,t);if(u.length>1){let f=u.map(O=>O.latest),b=u.map(O=>O.original),[x,E,y,v]=ye(b),T=y-x,I=v-E,S=T/I,P=Math.max($t,l==="width"?Math.max(0,i):T),M=Math.max($t,l==="height"?Math.max(0,i):I);y3(P,M,I,S,L(x,E),l,f,b,t,a)}else{let[f]=u,b=f?.latest,x=f?.original;if(b&&x&&ao(b,l)){let E=l==="width"?Math.max(0,i):b.width;l==="width"&&(n?E=Ve(E,Wa):E=Math.round(E));let y=l==="height"?Math.max(0,i):b.height;l==="height"&&(n?y=Ve(y,Wa):y=Math.round(y)),E=Math.max($t,E),y=Math.max($t,y),Gi(E,y,b,x,t,a,l==="width"?"e":"s",{shouldInformMutation:!1})}}}a.triggerUpdate();return}let m=l==="width"?e:0,d=l==="height"?e:0;for(let p of c){let u=Ga(p,s,t);if(u.length>1){let f=u.map(O=>O.latest),b=u.map(O=>O.original),[x,E,y,v]=ye(b),T=y-x,I=v-E,S=T/I,P=Math.max(0,T+m);l==="width"&&(n?P=Ve(P,Wa):P=Math.round(P));let M=Math.max(0,I+d);l==="height"&&(n?M=Ve(M,Wa):M=Math.round(M)),P=Math.max($t,P),M=Math.max($t,M),y3(P,M,I,S,L(x,E),l,f,b,t,a)}else{let[f]=u,b=f?.latest,x=f?.original;if(b&&x&&ao(b,l)){let E=Math.max(0,x.width+m);l==="width"&&(n?E=Ve(E,Wa):E=Math.round(E));let y=Math.max(0,x.height+d);l==="height"&&(n?y=Ve(y,Wa):y=Math.round(y)),E=Math.max($t,E),y=Math.max($t,y),Gi(E,y,b,x,t,a,l==="width"?"e":"s",{shouldInformMutation:!1})}}}a.triggerUpdate()},YM=({property:e,elements:o,elementsMap:t,atomicUnits:r,scene:n,appState:i})=>{let a=FM(()=>r.map(c=>{let m=Ga(c,t);if(m.length>1){let[p,u,f,b]=ye(m.map(x=>x.latest));return Math.round((e==="width"?f-p:b-u)*100)/100}let[d]=m;return Math.round((e==="width"?d.latest.width:d.latest.height)*100)/100}),[t,r,e]),l=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",s=a.length>0;return WM(It,{label:e==="width"?"W":"H",elements:o,dragInputCallback:GM,value:l,editable:s,appState:i,property:e,scene:n})},Ug=YM;import{jsx as $M}from"react/jsx-runtime";var v3=4,VM=4,KM=(e,o)=>e.reduce((t,r)=>{if(!r||qr(r))return t;if(V(r))return t.push(r),t;if(bt(r)){let n=pe(r,o);if(n)return t.push(n),t}return t},[]),ZM=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=o.map(s=>i.get(s.id)),l;if(r){l=Math.max(Math.round(r),v3);for(let s of a)n.mutateElement(s,{fontSize:l}),Ke(s,n.getContainerElement(s),n);n.triggerUpdate()}else{let s=o;for(let c=0;c<a.length;c++){let m=a[c],d=s[c],p=Math.round(d.fontSize),u=Math.round(e),f=Math.max(p+u,v3);t&&(f=Ve(f,VM)),n.mutateElement(m,{fontSize:f}),Ke(m,n.getContainerElement(m),n)}n.triggerUpdate()}},XM=({elements:e,scene:o,appState:t,property:r,elementsMap:n})=>{let i=KM(e,n);if(!i.length)return null;let a=i.map(c=>Math.round(c.fontSize*10)/10),l=new Set(a).size===1?a[0]:"Mixed",s=a.length>0;return $M(It,{label:"F",icon:oi,elements:i,dragInputCallback:ZM,value:l,editable:s,scene:o,property:r,appState:t})},w3=XM;import{useMemo as jM}from"react";import{jsx as t7}from"react/jsx-runtime";var qM=(e,o,t,r,n,i)=>{for(let a=0;a<r.length;a++){let l=r[a],[s,c]=[l.x+l.width/2,l.y+l.height/2],[m,d]=Re(L(l.x,l.y),L(s,c),l.angle),p=e==="x"?Math.round(m+o):m,u=e==="y"?Math.round(d+t):d;gi(p,u,l,i,n,!1)}},JM=(e,o,t,r,n)=>{let i=n.getNonDeletedElementsMap(),[a,l,,]=ye(t),s=e-a,c=o-l;for(let m=0;m<t.length;m++){let d=t[m],p=i.get(d.id);if(p&&(!V(p)||!p.containerId)){let[u,f]=[p.x+p.width/2,p.y+p.height/2],[b,x]=Re(L(p.x,p.y),L(u,f),p.angle);gi(b+s,x+c,d,n,r,!1)}}},QM=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldChangeByStepSize:r,nextValue:n,property:i,scene:a,originalAppState:l})=>{let s=a.getNonDeletedElementsMap();if(n!==void 0){for(let p of Ya(o,l)){let u=Ga(p,s,t);if(u.length>1){let[f,b,,]=ye(u.map(y=>y.latest));JM(i==="x"?n:f,i==="y"?n:b,u.map(y=>y.original),t,a)}else{let f=u[0]?.original,b=u[0]?.latest;if(f&&b&&ao(b,i)){let[x,E]=[f.x+f.width/2,f.y+f.height/2],[y,v]=Re(L(f.x,f.y),L(x,E),f.angle);gi(i==="x"?n:y,i==="y"?n:v,f,a,t,!1)}}}a.triggerUpdate();return}let c=r?Ve(e,ps):e;qM(i,i==="x"?c:0,i==="y"?c:0,o,t,a),a.triggerUpdate()},e7=({property:e,elements:o,elementsMap:t,atomicUnits:r,scene:n,appState:i})=>{let a=jM(()=>r.map(s=>{let c=Object.keys(s).map(b=>t.get(b)).filter(b=>b!==void 0);if(c.length>1){let[b,x]=ye(c);return Math.round((e==="x"?b:x)*100)/100}let[m]=c,[d,p]=[m.x+m.width/2,m.y+m.height/2],[u,f]=Re(L(m.x,m.y),L(d,p),m.angle);return Math.round((e==="x"?u:f)*100)/100}),[r,t,e]),l=new Set(a).size===1?a[0]:"Mixed";return t7(It,{label:e==="x"?"X":"Y",elements:o,dragInputCallback:QM,value:l,property:e,scene:n,appState:i})},Gg=e7;import{jsx as n7}from"react/jsx-runtime";var o7=({accumulatedChange:e,instantChange:o,originalElements:t,originalElementsMap:r,shouldChangeByStepSize:n,nextValue:i,property:a,scene:l,originalAppState:s})=>{let c=l.getNonDeletedElementsMap(),m=t[0],[d,p]=[m.x+m.width/2,m.y+m.height/2],[u,f]=Re(L(m.x,m.y),L(d,p),m.angle);if(s.croppingElementId===m.id){let v=c.get(m.id);if(!v||!Ne(v)||!v.crop)return;let T=v.crop,I=T,S=v.scale[0]===-1,P=v.scale[1]===-1,{width:M,height:O}=Wn(v);if(i!==void 0){if(a==="x"){let W=i*(T.naturalWidth/M);S?I={...T,x:Et(T.naturalWidth-W-T.width,0,T.naturalWidth-T.width)}:I={...T,x:Et(i*(T.naturalWidth/M),0,T.naturalWidth-T.width)}}a==="y"&&(I={...T,y:Et(i*(T.naturalHeight/O),0,T.naturalHeight-T.height)}),l.mutateElement(v,{crop:I});return}let R=(a==="x"?o:0)*(S?-1:1),z=(a==="y"?o:0)*(P?-1:1);I={...T,x:Et(T.x+R,0,T.naturalWidth-T.width),y:Et(T.y+z,0,T.naturalHeight-T.height)},l.mutateElement(v,{crop:I});return}if(i!==void 0){gi(a==="x"?i:u,a==="y"?i:f,m,l,r);return}let b=a==="x"?e:0,x=a==="y"?e:0,E=a==="x"?Math.round(n?Ve(m.x+b,ps):u+b):u,y=a==="y"?Math.round(n?Ve(m.y+x,ps):f+x):f;gi(E,y,m,l,r)},r7=({property:e,element:o,elementsMap:t,scene:r,appState:n})=>{let[i,a]=Re(L(o.x,o.y),L(o.x+o.width/2,o.y+o.height/2),o.angle),l=Eo(e==="x"?i:a,2);if(n.croppingElementId===o.id&&Ne(o)&&o.crop){let s=S1(o);s&&(l=Eo(e==="x"?s.x:s.y,2))}return n7(It,{label:e==="x"?"X":"Y",elements:[o],dragInputCallback:o7,scene:r,value:l,property:e,appState:n})},Yg=r7;import{Fragment as Vg,jsx as J,jsxs as lo}from"react/jsx-runtime";var c7=50,us=e=>{let o=sr(),t=e.app.scene.getSceneNonce()||1,r=e.app.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}),n=Tn(e.app);return J(d7,{...e,appState:o,sceneNonce:t,selectedElements:r,gridModeEnabled:n})},Ue=({children:e,columns:o=1,heading:t,style:r,...n})=>J("div",{className:i7("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${o}, 1fr)`,...r},...n,children:e});Ue.displayName="StatsRow";var Om=({children:e,order:o,style:t,...r})=>J("div",{className:"exc-stats__rows",style:{order:o,...t},...r,children:e});Om.displayName="StatsRows";us.StatsRow=Ue;us.StatsRows=Om;var d7=s7(({app:e,onClose:o,renderCustomStats:t,selectedElements:r,appState:n,sceneNonce:i,gridModeEnabled:a})=>{let l=e.scene,s=l.getNonDeletedElements(),c=l.getNonDeletedElementsMap(),m=ve(),d=r.length===1?r[0]:null,p=r.length>1?r:null,u=n.croppingElementId&&Ne(d),f=u?Wn(d):null,[b,x]=l7({width:0,height:0}),E=Wg(()=>a7(T=>{let I=ye(T);x({width:Math.round(I[2])-Math.round(I[0]),height:Math.round(I[3])-Math.round(I[1])})},c7),[]);T3(()=>{E(s)},[i,s,E]),T3(()=>()=>E.cancel(),[E]);let y=Wg(()=>Ya(r,n),[r,n]),v=Wg(()=>pc(r),[r]);return J("div",{className:"exc-stats",children:lo(xt,{padding:3,children:[lo("div",{className:"title",children:[J("h2",{children:g("stats.title")}),J("div",{className:"close",onClick:o,children:ko})]}),lo(Ul,{label:J("h3",{children:g("stats.generalStats")}),open:!!(n.stats.panels&ol.generalStats),openTrigger:()=>m(T=>({stats:{open:!0,panels:T.stats.panels^ol.generalStats}})),children:[lo(Om,{children:[J(Ue,{heading:!0,children:g("stats.scene")}),lo(Ue,{columns:2,children:[J("div",{children:g("stats.shapes")}),J("div",{children:s.length})]}),lo(Ue,{columns:2,children:[J("div",{children:g("stats.width")}),J("div",{children:b.width})]}),lo(Ue,{columns:2,children:[J("div",{children:g("stats.height")}),J("div",{children:b.height})]}),a&&lo(Vg,{children:[J(Ue,{heading:!0,children:"Canvas"}),J(Ue,{children:J(g3,{property:"gridStep",scene:l,appState:n,setAppState:m})})]})]}),t?.(s,n)]}),!v&&r.length>0&&J("div",{id:"elementStats",style:{marginTop:12},children:J(Ul,{label:J("h3",{children:g("stats.elementProperties")}),open:!!(n.stats.panels&ol.elementProperties),openTrigger:()=>m(T=>({stats:{open:!0,panels:T.stats.panels^ol.elementProperties}})),children:lo(Om,{children:[d&&lo(Vg,{children:[u&&J(Ue,{heading:!0,children:g("labels.unCroppedDimension")}),n.croppingElementId&&Ne(d)&&f&&lo(Ue,{columns:2,children:[J("div",{children:g("stats.width")}),J("div",{children:Eo(f.width,2)})]}),n.croppingElementId&&Ne(d)&&f&&lo(Ue,{columns:2,children:[J("div",{children:g("stats.height")}),J("div",{children:Eo(f.height,2)})]}),J(Ue,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:n.croppingElementId?g("labels.imageCropping"):g(`element.${d.type}`)}),J(Ue,{children:J(Yg,{element:d,property:"x",elementsMap:c,scene:l,appState:n})}),J(Ue,{children:J(Yg,{element:d,property:"y",elementsMap:c,scene:l,appState:n})}),J(Ue,{children:J(Hg,{property:"width",element:d,scene:l,appState:n})}),J(Ue,{children:J(Hg,{property:"height",element:d,scene:l,appState:n})}),!se(d)&&J(Ue,{children:J(u3,{property:"angle",element:d,scene:l,appState:n})}),J(Ue,{children:J(x3,{property:"fontSize",element:d,scene:l,appState:n})})]}),p&&lo(Vg,{children:[ac(p)&&J(Ue,{heading:!0,children:g("element.group")}),lo(Ue,{columns:2,style:{margin:"0.3125rem 0"},children:[J("div",{children:g("stats.shapes")}),J("div",{children:r.length})]}),J(Ue,{children:J(Gg,{property:"x",elements:p,elementsMap:c,atomicUnits:y,scene:l,appState:n})}),J(Ue,{children:J(Gg,{property:"y",elements:p,elementsMap:c,atomicUnits:y,scene:l,appState:n})}),J(Ue,{children:J(Ug,{property:"width",elements:p,elementsMap:c,atomicUnits:y,scene:l,appState:n})}),J(Ue,{children:J(Ug,{property:"height",elements:p,elementsMap:c,atomicUnits:y,scene:l,appState:n})}),J(Ue,{children:J(E3,{property:"angle",elements:p,scene:l,appState:n})}),J(Ue,{children:J(w3,{property:"fontSize",elements:p,scene:l,appState:n,elementsMap:c})})]})]})})})]})})},(e,o)=>e.sceneNonce===o.sceneNonce&&e.selectedElements===o.selectedElements&&e.appState.stats.panels===o.appState.stats.panels&&e.gridModeEnabled===o.gridModeEnabled&&e.appState.gridStep===o.appState.gridStep&&e.appState.croppingElementId===o.appState.croppingElementId);import{useCallback as m7,useEffect as C3,useState as k3}from"react";import{jsx as Va,jsxs as Bm}from"react/jsx-runtime";var p7=({sourceElementId:e,onClose:o,appState:t,scene:r,generateLinkForSelection:n=fc})=>{let i=r.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[l,s]=k3(a),[c,m]=k3(!1);C3(()=>{let p=q(i,t),u=a;if(p.length>0&&n){let f=bc(p,t);f&&(u=Uo(n(f.id,f.type)))}s(u)},[i,t,t.selectedElementIds,a,n]);let d=m7(()=>{if(l&&l!==i.get(e)?.link){let p=i.get(e);p&&r.mutateElement(p,{link:l})}if(!l&&c&&e){let p=i.get(e);p&&r.mutateElement(p,{link:null})}o?.()},[e,l,i,c,r,o]);return C3(()=>{let p=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===w.ENTER&&d(),t.openDialog?.name==="elementLinkSelector"&&u.key===w.ESCAPE&&o?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[t,o,d]),Bm("div",{className:"ElementLinkDialog",children:[Bm("div",{className:"ElementLinkDialog__header",children:[Va("h2",{children:g("elementLink.title")}),Va("p",{children:g("elementLink.desc")})]}),Bm("div",{className:"ElementLinkDialog__input",children:[Va(Pa,{value:l??"",onChange:p=>{c||m(!0),s(p)},onKeyDown:p=>{p.key===w.ENTER&&d()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&l&&Va(K,{type:"button",title:g("buttons.remove"),"aria-label":g("buttons.remove"),label:g("buttons.remove"),onClick:()=>{s(null),m(!0)},className:"ElementLinkDialog__remove",icon:Lr})]}),Bm("div",{className:"ElementLinkDialog__actions",children:[Va(Pr,{label:g("buttons.cancel"),onClick:()=>{o?.()},style:{marginRight:10}}),Va(Pr,{label:g("buttons.confirm"),onClick:d,actionType:"primary"})]})]})},S3=p7;import u7,{useState as h7}from"react";import{Fragment as g7,jsx as Kg}from"react/jsx-runtime";var I3=({children:e,onClose:o})=>{let[t,r]=h7(!!e),{container:n}=st(),i=u7.useCallback(()=>{r(!1),o&&o(),n?.focus()},[o,n]);return Kg(g7,{children:t&&Kg(ot,{size:"small",onCloseRequest:i,title:g("errorDialog.title"),children:Kg("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import L3,{useMemo as v7}from"react";import A3 from"clsx";var M3=[{icon:Oc,value:"selection",key:w.V,numericKey:void 0,fillable:!0,myocSimplifiedMode:!0},{icon:nn,value:"rectangle",key:w.R,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:an,value:"diamond",key:w.D,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:ln,value:"ellipse",key:w.O,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Qi,value:"arrow",key:w.A,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:sn,value:"line",key:w.L,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:lr,value:"freedraw",key:[w.P,w.X],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:cn,value:"text",key:w.T,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Bc,value:"image",key:[w.I],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:zc,value:"eraser",key:w.E,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0}];import{Fragment as y7,jsx as Ge,jsxs as fi}from"react/jsx-runtime";var f7=e=>fi(y7,{children:[Ge("h3",{children:e.title}),Ge("div",{className:"HelpDialog__islands-container",children:e.children})]}),Zg=e=>fi("div",{className:`HelpDialog__island ${e.className}`,children:[Ge("h4",{className:"HelpDialog__island-title",children:e.caption}),Ge("div",{className:"HelpDialog__island-content",children:e.children})]});function*b7(e,o){let t=!0;for(let r of e)t||(yield o),t=!1,yield r}var x7=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),Mt=({label:e,shortcuts:o,isOr:t=!0})=>{let r=o.map(n=>(n.endsWith("++")?[...n.slice(0,-2).split("+"),"+"]:n.split("+")).map(a=>Ge(E7,{children:x7(a)},a)));return fi("div",{className:"HelpDialog__shortcut",children:[Ge("div",{children:e}),Ge("div",{className:"HelpDialog__key-container",children:[...b7(r,t?g("helpDialog.or"):null)]})]})},E7=e=>Ge("kbd",{className:"HelpDialog__key",...e});function Xg(){return fi(f7,{title:g("helpDialog.shortcuts"),children:[fi(Zg,{className:"HelpDialog__island--tools",caption:g("helpDialog.tools"),children:[Ge(Mt,{label:g("toolBar.hand"),shortcuts:[w.H]}),vn.filter(({myocSimplifiedMode:e})=>e).map(({value:e,key:o})=>Ge(Mt,{label:g(`toolBar.${e}`),shortcuts:[...o]},e)),Ge(Mt,{label:g("helpDialog.cropStart"),shortcuts:[g("helpDialog.doubleClick"),D("Enter")],isOr:!0}),Ge(Mt,{label:g("helpDialog.cropFinish"),shortcuts:[D("Enter"),D("Escape")],isOr:!0})]}),fi(Zg,{className:"HelpDialog__island--view",caption:g("helpDialog.view"),children:[Ge(Mt,{label:g("helpDialog.smartZoom"),shortcuts:[w.F]}),Ge(Mt,{label:g("buttons.zenMode"),shortcuts:[D("Alt+Z")]}),Ge(Mt,{label:g("buttons.objectsSnapMode"),shortcuts:[D("Alt+S")]}),Ge(Mt,{label:g("commandPalette.title"),shortcuts:xo?[We("commandPalette")]:[We("commandPalette"),We("commandPalette",1)]})]}),fi(Zg,{className:"HelpDialog__island--editor",caption:g("helpDialog.editor"),children:[Ge(Mt,{label:g("labels.pasteAsPlaintext"),shortcuts:[D("CtrlOrCmd+Shift+V")]}),Ge(Mt,{label:g("labels.multiSelect"),shortcuts:[D(`Shift+${g("helpDialog.click")}`)]}),Ge(Mt,{label:g("helpDialog.deepSelect"),shortcuts:[D(`CtrlOrCmd+${g("helpDialog.click")}`)]}),Ge(Mt,{label:g("helpDialog.deepBoxSelect"),shortcuts:[D(`CtrlOrCmd+${g("helpDialog.drag")}`)]}),(bn||xo)&&Ge(Mt,{label:g("labels.copyAsPng"),shortcuts:[D("Shift+Alt+C")]}),Ge(Mt,{label:g("helpDialog.toggleElementLock"),shortcuts:[D("CtrlOrCmd+Shift+L")]}),Ge(Mt,{label:g("labels.group"),shortcuts:[D("CtrlOrCmd+G")]}),Ge(Mt,{label:g("labels.ungroup"),shortcuts:[D("CtrlOrCmd+Shift+G")]}),Ge(Mt,{label:g("labels.flipHorizontal"),shortcuts:[D("Shift+H")]}),Ge(Mt,{label:g("labels.flipVertical"),shortcuts:[D("Shift+V")]})]})]})}import{Fragment as P3,jsx as G,jsxs as bi}from"react/jsx-runtime";var w7=e=>bi(P3,{children:[G("h3",{children:e.title}),G("div",{className:"HelpDialog__islands-container",children:e.children})]}),$g=e=>bi("div",{className:`HelpDialog__island ${e.className}`,children:[G("h4",{className:"HelpDialog__island-title",children:e.caption}),G("div",{className:"HelpDialog__island-content",children:e.children})]});function*T7(e,o){let t=!0;for(let r of e)t||(yield o),t=!1,yield r}var C7=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),Z=({label:e,shortcuts:o,isOr:t=!0})=>{let r=o.map(n=>(n.endsWith("++")?[...n.slice(0,-2).split("+"),"+"]:n.split("+")).map(a=>G(k7,{children:C7(a)},a)));return bi("div",{className:"HelpDialog__shortcut",children:[G("div",{children:e}),G("div",{className:"HelpDialog__key-container",children:[...T7(r,t?g("helpDialog.or"):null)]})]})},k7=e=>G("kbd",{className:"HelpDialog__key",...e}),_3=({onClose:e})=>{let[o,t]=L3.useState(!1),r=L3.useCallback(()=>{e&&e()},[e]),n=v7(()=>o?G("button",{className:A3("toggle-button",{}),onClick:()=>t(!1),children:g("helpDialog.myoc.showingAll")}):G("button",{className:A3("toggle-button",{}),onClick:()=>t(!0),children:g("helpDialog.myoc.showingBasic")}),[o]);return G(P3,{children:G(ot,{onCloseRequest:r,title:g("helpDialog.title"),className:"HelpDialog",titleButton:n,children:o?bi(w7,{title:g("helpDialog.shortcuts"),children:[bi($g,{className:"HelpDialog__island--tools",caption:g("helpDialog.tools"),children:[G(Z,{label:g("toolBar.hand"),shortcuts:[w.H]}),M3.map(({value:i,key:a})=>G(Z,{label:g(`toolBar.${i}`),shortcuts:[...a]},i)),G(Z,{label:g("toolBar.frame"),shortcuts:[w.F]}),G(Z,{label:g("toolBar.laser"),shortcuts:[w.K]}),G(Z,{label:g("labels.eyeDropper"),shortcuts:[w.I,"Shift+S","Shift+G"]}),G(Z,{label:g("helpDialog.editLineArrowPoints"),shortcuts:[D("CtrlOrCmd+Enter")]}),G(Z,{label:g("helpDialog.editText"),shortcuts:[D("Enter")]}),G(Z,{label:g("helpDialog.textNewLine"),shortcuts:[D("Enter"),D("Shift+Enter")]}),G(Z,{label:g("helpDialog.textFinish"),shortcuts:[D("Esc"),D("CtrlOrCmd+Enter")]}),G(Z,{label:g("helpDialog.curvedArrow"),shortcuts:["A",g("helpDialog.click"),g("helpDialog.click"),g("helpDialog.click")],isOr:!1}),G(Z,{label:g("helpDialog.curvedLine"),shortcuts:["L",g("helpDialog.click"),g("helpDialog.click"),g("helpDialog.click")],isOr:!1}),G(Z,{label:g("helpDialog.cropStart"),shortcuts:[g("helpDialog.doubleClick"),D("Enter")],isOr:!0}),G(Z,{label:g("helpDialog.cropFinish"),shortcuts:[D("Enter"),D("Escape")],isOr:!0}),G(Z,{label:g("toolBar.lock"),shortcuts:[w.Q]}),G(Z,{label:g("helpDialog.preventBinding"),shortcuts:[D("CtrlOrCmd")]}),G(Z,{label:g("toolBar.link"),shortcuts:[D("CtrlOrCmd+K")]}),G(Z,{label:g("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),bi($g,{className:"HelpDialog__island--view",caption:g("helpDialog.view"),children:[G(Z,{label:g("helpDialog.smartZoom"),shortcuts:[w.F]}),G(Z,{label:g("buttons.zoomIn"),shortcuts:[D("CtrlOrCmd++")]}),G(Z,{label:g("buttons.zoomOut"),shortcuts:[D("CtrlOrCmd+-")]}),G(Z,{label:g("buttons.resetZoom"),shortcuts:[D("CtrlOrCmd+0")]}),G(Z,{label:g("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),G(Z,{label:g("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),G(Z,{label:g("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),G(Z,{label:g("buttons.zenMode"),shortcuts:[D("Alt+Z")]}),G(Z,{label:g("buttons.objectsSnapMode"),shortcuts:[D("Alt+S")]}),G(Z,{label:g("labels.toggleGrid"),shortcuts:[D("CtrlOrCmd+'")]}),G(Z,{label:g("labels.viewMode"),shortcuts:[D("Alt+R")]}),G(Z,{label:g("stats.fullTitle"),shortcuts:[D("Alt+/")]}),G(Z,{label:g("search.title"),shortcuts:[We("searchMenu")]}),G(Z,{label:g("commandPalette.title"),shortcuts:xo?[We("commandPalette")]:[We("commandPalette"),We("commandPalette",1)]})]}),bi($g,{className:"HelpDialog__island--editor",caption:g("helpDialog.editor"),children:[G(Z,{label:g("labels.moveCanvas"),shortcuts:[D(`Space+${g("helpDialog.drag")}`),D(`Wheel+${g("helpDialog.drag")}`)],isOr:!0}),G(Z,{label:g("labels.delete"),shortcuts:[D("Delete")]}),G(Z,{label:g("labels.cut"),shortcuts:[D("CtrlOrCmd+X")]}),G(Z,{label:g("labels.copy"),shortcuts:[D("CtrlOrCmd+C")]}),G(Z,{label:g("labels.paste"),shortcuts:[D("CtrlOrCmd+V")]}),G(Z,{label:g("labels.pasteAsPlaintext"),shortcuts:[D("CtrlOrCmd+Shift+V")]}),G(Z,{label:g("labels.selectAll"),shortcuts:[D("CtrlOrCmd+A")]}),G(Z,{label:g("labels.multiSelect"),shortcuts:[D(`Shift+${g("helpDialog.click")}`)]}),G(Z,{label:g("helpDialog.deepSelect"),shortcuts:[D(`CtrlOrCmd+${g("helpDialog.click")}`)]}),G(Z,{label:g("helpDialog.deepBoxSelect"),shortcuts:[D(`CtrlOrCmd+${g("helpDialog.drag")}`)]}),(bn||xo)&&G(Z,{label:g("labels.copyAsPng"),shortcuts:[D("Shift+Alt+C")]}),G(Z,{label:g("labels.copyStyles"),shortcuts:[D("CtrlOrCmd+Alt+C")]}),G(Z,{label:g("labels.pasteStyles"),shortcuts:[D("CtrlOrCmd+Alt+V")]}),G(Z,{label:g("labels.sendToBack"),shortcuts:[Bo?D("CtrlOrCmd+Alt+["):D("CtrlOrCmd+Shift+[")]}),G(Z,{label:g("labels.bringToFront"),shortcuts:[Bo?D("CtrlOrCmd+Alt+]"):D("CtrlOrCmd+Shift+]")]}),G(Z,{label:g("labels.sendBackward"),shortcuts:[D("CtrlOrCmd+[")]}),G(Z,{label:g("labels.bringForward"),shortcuts:[D("CtrlOrCmd+]")]}),G(Z,{label:g("labels.alignTop"),shortcuts:[D("CtrlOrCmd+Shift+Up")]}),G(Z,{label:g("labels.alignBottom"),shortcuts:[D("CtrlOrCmd+Shift+Down")]}),G(Z,{label:g("labels.alignLeft"),shortcuts:[D("CtrlOrCmd+Shift+Left")]}),G(Z,{label:g("labels.alignRight"),shortcuts:[D("CtrlOrCmd+Shift+Right")]}),G(Z,{label:g("labels.arrangeElements"),shortcuts:[D("Shift+R")]}),G(Z,{label:g("labels.duplicateSelection"),shortcuts:[D("CtrlOrCmd+D"),D(`Alt+${g("helpDialog.drag")}`)]}),G(Z,{label:g("helpDialog.toggleElementLock"),shortcuts:[D("CtrlOrCmd+Shift+L")]}),G(Z,{label:g("buttons.undo"),shortcuts:[D("CtrlOrCmd+Z")]}),G(Z,{label:g("buttons.redo"),shortcuts:Ls?[D("CtrlOrCmd+Y"),D("CtrlOrCmd+Shift+Z")]:[D("CtrlOrCmd+Shift+Z")]}),G(Z,{label:g("labels.group"),shortcuts:[D("CtrlOrCmd+G")]}),G(Z,{label:g("labels.ungroup"),shortcuts:[D("CtrlOrCmd+Shift+G")]}),G(Z,{label:g("labels.flipHorizontal"),shortcuts:[D("Shift+H")]}),G(Z,{label:g("labels.flipVertical"),shortcuts:[D("Shift+V")]}),G(Z,{label:g("labels.showStroke"),shortcuts:[D("S")]}),G(Z,{label:g("labels.showBackground"),shortcuts:[D("G")]}),G(Z,{label:g("labels.showFonts"),shortcuts:[D("Shift+F")]}),G(Z,{label:g("labels.decreaseFontSize"),shortcuts:[D("CtrlOrCmd+Shift+<")]}),G(Z,{label:g("labels.increaseFontSize"),shortcuts:[D("CtrlOrCmd+Shift+>")]})]})]}):G(Xg,{})})})};import{useEffect as N3,useRef as _7,useState as An}from"react";import{useCallback as S7,useRef as I7,useState as M7}from"react";var L7=2e3,D3=()=>{let[e,o]=M7(null),t=I7(0),r=()=>{clearTimeout(t.current),o("success"),t.current=window.setTimeout(()=>{o(null)},L7)},n=S7(()=>{o(null)},[]);return{copyStatus:e,resetCopyStatus:n,onCopy:r}};import A7 from"clsx";import{jsx as R3}from"react/jsx-runtime";var hs=({title:e,name:o,checked:t,onChange:r,disabled:n=!1})=>R3("div",{className:A7("Switch",{toggled:t,disabled:n}),children:R3("input",{name:o,id:o,title:e,type:"checkbox",checked:t,disabled:n,onChange:()=>r(!t),onKeyDown:i=>{i.key===" "&&r(!t)}})});import{jsx as Ye,jsxs as _n}from"react/jsx-runtime";var P7="filter"in document.createElement("canvas").getContext("2d"),D7=()=>_n("div",{children:[Ye("h3",{children:g("canvasError.cannotShowPreview")}),Ye("p",{children:Ye("span",{children:g("canvasError.canvasTooBig")})}),_n("em",{children:["(",g("canvasError.canvasTooBigTip"),")"]})]}),R7=({appStateSnapshot:e,elementsSnapshot:o,files:t,actionManager:r,onExportImage:n,name:i})=>{let a=De(o,e),[l,s]=An(i),[c,m]=An(a),[d,p]=An(e.exportBackground),[u,f]=An(e.exportWithDarkMode),[b,x]=An(e.exportEmbedScene),[E,y]=An(e.exportScale),v=_7(null),[T,I]=An(null),{onCopy:S,copyStatus:P,resetCopyStatus:M}=D3();N3(()=>{M()},[l,d,u,E,b,M]);let{exportedElements:O,exportingFrame:R}=si(o,e,c);return N3(()=>{let z=v.current;if(!z)return;let W=z.offsetWidth,Y=z.offsetHeight;W&&xn({elements:O,appState:{...e,name:l,exportBackground:d,exportWithDarkMode:u,exportScale:E,exportEmbedScene:b},files:t,exportPadding:Ur,maxWidthOrHeight:Math.max(W,Y),exportingFrame:R}).then(oe=>(I(null),Sr(oe).then(()=>{z.replaceChildren(oe)}).catch(H=>{throw H.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):H}))).catch(oe=>{console.error(oe),I(oe)})},[e,t,O,R,l,d,u,E,b]),_n("div",{className:"ImageExportModal",children:[Ye("h3",{children:g("imageExportDialog.header")}),_n("div",{className:"ImageExportModal__preview",children:[Ye("div",{className:"ImageExportModal__preview__canvas",ref:v,children:T&&Ye(D7,{})}),Ye("div",{className:"ImageExportModal__preview__filename",children:!Ki&&Ye("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:z=>{s(z.target.value),r.executeAction(ah,"ui",z.target.value)}})})]}),_n("div",{className:"ImageExportModal__settings",children:[Ye("h3",{children:g("imageExportDialog.header")}),a&&Ye(gs,{label:g("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Ye(hs,{name:"exportOnlySelected",checked:c,onChange:z=>{m(z)}})}),Ye(gs,{label:g("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Ye(hs,{name:"exportBackgroundSwitch",checked:d,onChange:z=>{p(z),r.executeAction(lh,"ui",z)}})}),P7&&Ye(gs,{label:g("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Ye(hs,{name:"exportDarkModeSwitch",checked:u,onChange:z=>{f(z),r.executeAction(v2,"ui",z)}})}),Ye(gs,{label:g("imageExportDialog.label.embedScene"),tooltip:g("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Ye(hs,{name:"exportEmbedSwitch",checked:b,onChange:z=>{x(z),r.executeAction(Td,"ui",z)}})}),Ye(gs,{label:g("imageExportDialog.label.scale"),name:"exportScale",children:Ye(Em,{name:"exportScale",value:E,onChange:z=>{y(z),r.executeAction(y2,"ui",z)},choices:Ns.map(z=>({value:z,label:`${z}\xD7`}))})}),_n("div",{className:"ImageExportModal__settings__buttons",children:[Ye(In,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToPng"),onClick:()=>n(Ps.png,O,{exportingFrame:R}),icon:xu,children:g("imageExportDialog.button.exportToPng")}),Ye(In,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToSvg"),onClick:()=>n(Ps.svg,O,{exportingFrame:R}),icon:xu,children:g("imageExportDialog.button.exportToSvg")}),(bn||xo)&&Ye(In,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.copyPngToClipboard"),status:P,onClick:async()=>{await n(Ps.clipboard,O,{exportingFrame:R}),S()},icon:oa,children:g("imageExportDialog.button.copyPngToClipboard")})]})]})]})},gs=({label:e,children:o,tooltip:t,name:r})=>_n("div",{className:"ImageExportModal__settings__setting",title:e,children:[_n("label",{htmlFor:r,className:"ImageExportModal__settings__setting__label",children:[e,t&&Ye(Rt,{label:t,long:!0,children:Gx})]}),Ye("div",{className:"ImageExportModal__settings__setting__content",children:o})]}),O3=({elements:e,appState:o,files:t,actionManager:r,onExportImage:n,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:l,elementsSnapshot:s}]=An(()=>({appStateSnapshot:jt(o),elementsSnapshot:jt(e)}));return Ye(ot,{onCloseRequest:i,size:"wide",title:!1,children:Ye(R7,{elementsSnapshot:s,appStateSnapshot:l,files:t,actionManager:r,onExportImage:n,name:a})})};import O7 from"react";import jg from"open-color";import{jsx as N7}from"react/jsx-runtime";var qg=({children:e,color:o})=>N7("div",{className:"Card",style:{"--card-color":o==="primary"?"var(--color-primary)":jg[o][7],"--card-color-darker":o==="primary"?"var(--color-primary-darker)":jg[o][8],"--card-color-darkest":o==="primary"?"var(--color-primary-darkest)":jg[o][9]},children:e});import{Fragment as z7,jsx as er,jsxs as zm}from"react/jsx-runtime";var B7=({elements:e,appState:o,setAppState:t,files:r,actionManager:n,exportOpts:i,canvas:a,onCloseRequest:l})=>{let{onExportToBackend:s}=i;return er("div",{className:"ExportDialog ExportDialog--json",children:zm("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&zm(qg,{color:"lime",children:[er("div",{className:"Card-icon",children:jb}),er("h2",{children:g("exportDialog.disk_title")}),zm("div",{className:"Card-details",children:[g("exportDialog.disk_details"),!Ki&&n.renderAction("changeProjectName")]}),er(K,{className:"Card-button",type:"button",title:g("exportDialog.disk_button"),"aria-label":g("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{n.executeAction(Kl,"ui")}})]}),s&&zm(qg,{color:"pink",children:[er("div",{className:"Card-icon",children:Ml}),er("h2",{children:g("exportDialog.link_title")}),er("div",{className:"Card-details",children:g("exportDialog.link_details")}),er(K,{className:"Card-button",type:"button",title:g("exportDialog.link_button"),"aria-label":g("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{me("export","link",`ui (${v1()})`),await s(e,o,r),l()}catch(c){t({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,o,r,a)]})})},B3=({elements:e,appState:o,files:t,actionManager:r,exportOpts:n,canvas:i,setAppState:a})=>{let l=O7.useCallback(()=>{a({openDialog:null})},[a]);return er(z7,{children:o.openDialog?.name==="jsonExport"&&er(ot,{onCloseRequest:l,title:g("buttons.export"),children:er(B7,{elements:e,appState:o,setAppState:a,files:t,actionManager:r,onCloseRequest:l,exportOpts:n,canvas:i})})})};import F7 from"clsx";import{jsx as z3,jsxs as U7}from"react/jsx-runtime";var H7="small",F3=e=>U7("label",{className:F7("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${H7}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[z3("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),z3("div",{className:"ToolIcon__icon",children:Al})]});import{Fragment as U3,jsx as Q,jsxs as fo}from"react/jsx-runtime";var Y7=({UIOptions:e})=>fo(Kt,{__fallback:!0,children:[Q(Kt.DefaultItems.LoadScene,{}),Q(Kt.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&Q(Kt.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&Q(Kt.DefaultItems.SaveAsImage,{}),Q(Kt.DefaultItems.SearchMenu,{}),Q(Kt.DefaultItems.Help,{}),Q(Kt.Separator,{}),Q(Kt.Group,{title:"Excalidraw links",children:Q(Kt.DefaultItems.Socials,{})}),Q(Kt.Separator,{}),Q(Kt.DefaultItems.ToggleTheme,{}),Q(Kt.DefaultItems.ChangeCanvasBackground,{})]}),W7=()=>fo(Tm,{__fallback:!0,children:[Q(Tm.Actions.SaveToDisk,{}),Q(Tm.Actions.ExportToImage,{})]}),V7=({actionManager:e,appState:o,files:t,setAppState:r,elements:n,canvas:i,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,showExitZenModeBtn:c,renderTopRightUI:m,renderCustomStats:d,UIOptions:p,onExportImage:u,renderWelcomeScreen:f,children:b,app:x,isCollaborating:E,generateLinkForSelection:y})=>{let v=xe(),T=Zv(),I=T.tunnelsJotai.Provider,[S,P]=Ee(mn),M=()=>p.canvasActions.export?Q(B3,{elements:n,appState:o,files:t,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:r}):null,O=()=>!p.canvasActions.saveAsImage||o.openDialog?.name!=="imageExport"?null:Q(O3,{elements:n,appState:o,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>r({openDialog:null}),name:x.getName()}),R=()=>fo("div",{style:{position:"relative"},children:[Q(T.MainMenuTunnel.Out,{}),f&&Q(T.WelcomeScreenMenuHintTunnel.Out,{})]}),z=()=>Q(kn,{heading:"selectedShapeActions",className:fs("selected-shape-actions zen-mode-transition",{"transition-left":o.zenModeEnabled}),children:Q(xt,{className:Bt.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${o.height-166}px`},children:Q(jd,{appState:o,elementsMap:x.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:x})})}),W=()=>{let F=Yi(o,n),ee=o.stats.open&&!o.zenModeEnabled&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector";return Q(mm,{side:"top",children:fo("div",{className:"App-menu App-menu_top",children:[fo(Tt.Col,{gap:6,className:fs("App-menu_top__left"),children:[R(),F&&z()]}),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&Q(kn,{heading:"shapes",className:"shapes-section",children:ie=>fo("div",{style:{position:"relative"},children:[f&&Q(T.WelcomeScreenToolbarHintTunnel.Out,{}),Q(Tt.Col,{gap:4,align:"start",children:fo(Tt.Row,{gap:1,className:fs("App-toolbar-container",{"zen-mode":o.zenModeEnabled}),children:[fo(xt,{padding:1,className:fs("App-toolbar",{"zen-mode":o.zenModeEnabled}),children:[Q(um,{appState:o,isMobile:v.editor.isMobile,device:v,app:x}),ie,fo(Tt.Row,{gap:1,children:[Q(hm,{zenModeEnabled:o.zenModeEnabled,checked:o.penMode,onChange:()=>s(null),title:g("toolBar.penMode"),penDetected:o.penDetected}),Q(pm,{checked:Ko(o),onChange:()=>l(),title:g("toolBar.hand"),isMobile:!0}),Q(qd,{appState:o,activeTool:o.activeTool,UIOptions:p,app:x})]})]}),E&&Q(xt,{style:{marginLeft:8,alignSelf:"center",height:"fit-content"},children:Q(F3,{title:g("toolBar.laser"),checked:o.activeTool.type===Qe.laser,onChange:()=>x.setActiveTool({type:Qe.laser}),isMobile:!0})})]})})]})}),fo("div",{className:fs("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":o.zenModeEnabled}),children:[o.collaborators.size>0&&Q(bm,{collaborators:o.collaborators,userToFollow:o.userToFollow?.socketId||null}),m?.(v.editor.isMobile,o),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&(!oe||o.openSidebar?.name!==Dt.name)&&Q(T.DefaultSidebarTriggerTunnel.Out,{}),ee&&Q(us,{app:x,onClose:()=>{e.executeAction(va)},renderCustomStats:d})]})]})})},Y=()=>Q(Cm,{__fallback:!0,onDock:F=>{me("sidebar",`toggleDock (${F?"dock":"undock"})`,`(${v.editor.isMobile?"mobile":"desktop"})`)}}),oe=Pc(ss),H=fo(U3,{children:[b,Q(Y7,{UIOptions:p}),Q(Cm.Trigger,{__fallback:!0,icon:Ji,title:Fo(g("toolBar.library")),onToggle:F=>{F&&me("sidebar",`${Dt.name} (open)`,`button (${v.editor.isMobile?"mobile":"desktop"})`)},tab:Dt.defaultTab,children:g("toolBar.library")}),Q(W7,{}),o.openDialog?.name==="ttd"&&Q(zg,{__fallback:!0}),o.isLoading&&Q(dm,{delay:250}),o.errorMessage&&Q(I3,{onClose:()=>r({errorMessage:null}),children:o.errorMessage}),S&&!v.editor.isMobile&&Q(EE,{colorPickerType:S.colorPickerType,onCancel:()=>{P(null)},onChange:(F,ee,ie,{altKey:X})=>{if(!(F!=="elementBackground"&&F!=="elementStroke"))if(ie.length){for(let de of ie)Go(de,j(n),{[X&&S.swapPreviewOnAlt?F==="elementBackground"?"strokeColor":"backgroundColor":F==="elementBackground"?"backgroundColor":"strokeColor"]:ee}),To.delete(de);x.scene.triggerUpdate()}else r(F==="elementBackground"?{currentItemBackgroundColor:ee}:{currentItemStrokeColor:ee})},onSelect:(F,ee)=>{P(ie=>ie?.keepOpenOnAlt&&ee.altKey?ie:null),S?.onSelect?.(F,ee)}}),o.openDialog?.name==="help"&&Q(_3,{onClose:()=>{r({openDialog:null})}}),o.openDialog?.name==="elementLinkSelector"&&Q(S3,{sourceElementId:o.openDialog.sourceElementId,onClose:()=>{r({openDialog:null})},scene:x.scene,appState:o,generateLinkForSelection:y}),Q(T.OverwriteConfirmDialogTunnel.Out,{}),O(),M(),o.pasteDialog.shown&&Q(ow,{setAppState:r,appState:o,onClose:()=>r({pasteDialog:{shown:!1,data:null}})}),v.editor.isMobile&&Q(ew,{app:x,appState:o,elements:n,actionManager:e,renderJSONExportDialog:M,renderImageExportDialog:O,setAppState:r,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,renderTopRightUI:m,renderCustomStats:d,renderSidebars:Y,device:v,renderWelcomeScreen:f,UIOptions:p}),!v.editor.isMobile&&fo(U3,{children:[fo("div",{className:"layer-ui__wrapper",style:o.openSidebar&&oe&&v.editor.canFitSidebar?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[f&&Q(T.WelcomeScreenCenterTunnel.Out,{}),W(),Q(aw,{appState:o,actionManager:e,showExitZenModeBtn:c,renderWelcomeScreen:f}),o.scrolledOutside&&Q("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(F=>({...ei(n,F)}))},children:g("buttons.scrollBackToContent")})]}),Y()]})]});return Q(Du.Provider,{value:o,children:Q(I,{children:Q(hg.Provider,{value:T,children:H})})})},H3=e=>{let{suggestedBindings:o,startBoundElement:t,cursorButton:r,scrollX:n,scrollY:i,...a}=e;return a},K7=(e,o)=>{if(e.children!==o.children)return!1;let{canvas:t,appState:r,...n}=e,{canvas:i,appState:a,...l}=o;return nt(H3(r),H3(a),{selectedElementIds:nt,selectedGroupIds:nt})&&nt(n,l)},G3=G7.memo(V7,K7);import Z7 from"clsx";import{jsx as Y3,jsxs as $7}from"react/jsx-runtime";var X7="small",Fm=e=>$7("label",{className:Z7("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${X7}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[Y3("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),Y3("div",{className:"ToolIcon__icon",children:e.icon})]});import{useEffect as j7,useRef as q7}from"react";import{jsx as W3}from"react/jsx-runtime";var V3=({trails:e})=>{let o=q7(null);return j7(()=>{if(o.current)for(let t of e)t.start(o.current);return()=>{for(let t of e)t.stop()}},e),W3("div",{className:"SVGLayer",children:W3("svg",{ref:o})})};import J7,{useEffect as Q7,useRef as eL}from"react";import{jsx as rL}from"react/jsx-runtime";var tL=e=>{let o=eL(!1);return Q7(()=>{if(!o.current){o.current=!0;return}let t=new Map,r=new Map,n=new Map,i=new Map,a=new Map;e.appState.collaborators.forEach((s,c)=>{if(s.selectedElementIds)for(let m of Object.keys(s.selectedElementIds))n.has(m)||n.set(m,[]),n.get(m).push(c);!s.pointer||s.pointer.renderCursor===!1||(s.username&&i.set(c,s.username),s.userState&&a.set(c,s.userState),r.set(c,gt({sceneX:s.pointer.x,sceneY:s.pointer.y},e.appState)),t.set(c,s.button))});let l=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";Pv({canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:r,remotePointerButton:t,remoteSelectedElementIds:n,remotePointerUsernames:i,remotePointerUserStates:a,selectionColor:l,renderScrollbars:e.renderScrollbars},device:e.device,callback:e.renderInteractiveSceneCallback},Oa())}),rL("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?we.GRAB:we.AUTO},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.appState.viewModeEnabled?void 0:e.onDoubleClick,children:g("labels.drawingCanvas")})},K3=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,openDialog:e.openDialog,editingGroupId:e.editingGroupId,editingLinearElement:e.editingLinearElement,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,isBindingEnabled:e.isBindingEnabled,suggestedBindings:e.suggestedBindings,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}),oL=(e,o)=>e.selectionNonce!==o.selectionNonce||e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements||e.selectedElements!==o.selectedElements||e.renderScrollbars!==o.renderScrollbars?!1:nt(K3(e.appState),K3(o.appState)),Jg=J7.memo(tL,oL);import nL,{useEffect as iL,useRef as Z3}from"react";import{jsx as sL}from"react/jsx-runtime";var aL=e=>{let o=Z3(null),t=Z3(!1);return iL(()=>{let r=o.current;if(!r)return;let n=e.canvas;t.current||(t.current=!0,r.replaceChildren(n),n.classList.add("excalidraw__canvas","static"));let i=`${e.appState.width}px`,a=`${e.appState.height}px`;n.style.width!==i&&(n.style.width=i),n.style.height!==a&&(n.style.height=a);let l=e.appState.width*e.scale,s=e.appState.height*e.scale;n.width!==l&&(n.width=l),n.height!==s&&(n.height=s),mb({canvas:n,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},Oa())}),sL("div",{className:"excalidraw__canvas-wrapper",ref:o})},X3=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}),lL=(e,o)=>e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements?!1:nt(X3(e.appState),X3(o.appState))&&nt(e.renderConfig,o.renderConfig),Qg=nL.memo(aL,lL);import{useEffect as dL,useRef as mL}from"react";var $3=({canvas:e,rc:o,newElement:t,elementsMap:r,allElementsMap:n,scale:i,appState:a,renderConfig:l})=>{if(e){let[s,c]=kc(e,i),m=Sc({canvas:e,scale:i,normalizedWidth:s,normalizedHeight:c});m.save(),m.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"?y0(t,r,n,o,m,l,a):m.clearRect(0,0,s,c)}},cL=ki(e=>{$3(e)},{trailing:!0}),j3=(e,o)=>{if(o){cL(e);return}$3(e)};import{jsx as uL}from"react/jsx-runtime";var pL=e=>{let o=mL(null);return dL(()=>{o.current&&j3({canvas:o.current,scale:e.scale,newElement:e.appState.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},Oa())}),uL("canvas",{className:"excalidraw__canvas",style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:o})},q3=pL;import{useCallback as hL,useEffect as gL,useRef as fL}from"react";import{jsx as J3,jsxs as xL}from"react/jsx-runtime";var bL=5e3,Q3=({message:e,onClose:o,closable:t=!1,duration:r=bL,style:n})=>{let i=fL(0),a=r!==1/0,l=hL(()=>{a&&(i.current=window.setTimeout(()=>o(),r))},[o,r,a]);return gL(()=>{if(a)return l(),()=>clearTimeout(i.current)},[l,e,r,a]),xL("div",{className:"Toast",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?l:void 0,style:n,children:[J3("p",{className:"Toast__message",children:e}),t&&J3(K,{icon:ko,"aria-label":"close",type:"icon",onClick:o,className:"close"})]})};import{flushSync as EL}from"react-dom";import{jsx as vL}from"react/jsx-runtime";var yL=({app:e,activeLockedId:o})=>{let t=e.scene.getElement(o),r=t?[t]:He(e.scene.getNonDeletedElementsMap(),o);if(r.length===0)return null;let[n,i]=ye(r),{x:a,y:l}=gt({sceneX:n,sceneY:i},e.state);return vL("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${a-e.state.offsetLeft}px`},onClick:()=>{EL(()=>{let s=Xn(r,e.state);e.setState({selectedElementIds:r.reduce((c,m)=>({...c,[m.id]:!0}),{}),selectedGroupIds:s,activeLockedId:null})}),e.actionManager.executeAction($l)},title:g("labels.elementLock.unlock"),children:Rb})},e5=yL;import{Fragment as SL,jsx as Se,jsxs as Um}from"react/jsx-runtime";var n5=xr.createContext(null),i5=xr.createContext(null),a5={viewport:{isMobile:!1,isLandscape:!1},editor:{isMobile:!1,canFitSidebar:!1},isTouchScreen:!1},nf=xr.createContext(a5);nf.displayName="DeviceContext";var af=xr.createContext({container:null,id:null});af.displayName="ExcalidrawContainerContext";var lf=xr.createContext([]);lf.displayName="ExcalidrawElementsContext";var sf=xr.createContext({...Vi(),width:0,height:0,offsetLeft:0,offsetTop:0});sf.displayName="ExcalidrawAppStateContext";var cf=xr.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});cf.displayName="ExcalidrawSetAppStateContext";var df=xr.createContext(null);df.displayName="ExcalidrawActionManagerContext";var tt=()=>Dn(n5),cr=()=>Dn(i5),xe=()=>Dn(nf),st=()=>Dn(af),pn=()=>Dn(lf),sr=()=>Dn(sf),ve=()=>Dn(cf),_t=()=>Dn(df),bs=!1,ef=0,xi=!1,xs=!1,tf=!1,Es={horizontal:null,vertical:null},Pn=0,ys=!1,of=new Map,Hm=!1,o5=0,r5=!1,vs=null,ke={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},rf=class e extends xr.Component{constructor(t){super(t);k(this,"canvas");k(this,"interactiveCanvas",null);k(this,"rc");k(this,"unmounted",!1);k(this,"actionManager");k(this,"device",a5);k(this,"excalidrawContainerRef",xr.createRef());k(this,"scene");k(this,"fonts");k(this,"renderer");k(this,"visibleElements");k(this,"resizeObserver");k(this,"nearestScrollableContainer");k(this,"library");k(this,"libraryItemsFromStorage");k(this,"id");k(this,"store");k(this,"history");k(this,"excalidrawContainerValue");k(this,"files",{});k(this,"imageCache",new Map);k(this,"iFrameRefs",new Map);k(this,"embedsValidationStatus",new Map);k(this,"initializedEmbeds",new Set);k(this,"elementsPendingErasure",new Set);k(this,"flowChartCreator",new F0);k(this,"flowChartNavigator",new z0);k(this,"hitLinkElement");k(this,"lastPointerDownEvent",null);k(this,"lastPointerUpEvent",null);k(this,"lastPointerMoveEvent",null);k(this,"lastPointerMoveCoords",null);k(this,"lastViewportPosition",{x:0,y:0});k(this,"animationFrameHandler",new om);k(this,"laserTrails",new am(this.animationFrameHandler,this));k(this,"eraserTrail",new cm(this.animationFrameHandler,this));k(this,"lassoTrail",new sm(this.animationFrameHandler,this));k(this,"onChangeEmitter",new yo);k(this,"onPointerDownEmitter",new yo);k(this,"onPointerUpEmitter",new yo);k(this,"onUserFollowEmitter",new yo);k(this,"onScrollChangeEmitter",new yo);k(this,"missingPointerEventCleanupEmitter",new yo);k(this,"onRemoveEventListenersEmitter",new yo);k(this,"updateEditorAtom",(t,...r)=>{let n=wt.set(t,...r);return this.triggerRender(),n});k(this,"getEffectiveGridSize",()=>Tn(this)?this.state.gridSize:null);k(this,"updateEmbedValidationStatus",(t,r)=>{this.embedsValidationStatus.set(t.id,r),To.delete(t)});k(this,"updateEmbeddables",()=>{let t=new Set,r=!1;this.scene.getNonDeletedElements().filter(n=>{if(zt(n)){if(t.add(n.id),!this.embedsValidationStatus.has(n.id)){r=!0;let i=Ui(n.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(n,i)}}else Vn(n)&&t.add(n.id);return!1}),r&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((n,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});k(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);k(this,"frameNameBoundsCache",{get:t=>{let r=this.frameNameBoundsCache._cache.get(t.id);if(!r||r.zoom!==this.state.zoom.value||r.versionNonce!==t.versionNonce){let n=document.getElementById(this.getFrameNameDOMId(t));if(n){let i=n.getBoundingClientRect(),a=ze({clientX:i.x,clientY:i.y},this.state),l=ze({clientX:i.right,clientY:i.bottom},this.state);return r={x:a.x,y:a.y,width:l.x-a.x,height:l.y-a.y,angle:0,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,r),r}return null}return r},_cache:new Map});k(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});k(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===re.DARK,r=this.scene.getNonDeletedFramesLikes(),n=r.length>0&&this.state.searchMatches?.focusedId&&ce(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return r.map(i=>{if(!gl(i,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap()))return this.state.editingFrame===i.id&&this.resetEditingFrame(i),null;let{x:a,y:l}=gt({sceneX:i.x,sceneY:i.y},this.state),s=6,c,m=b0(i);if(i.id===this.state.editingFrame){let d=m;c=Se("input",{autoFocus:!0,value:d,onChange:p=>{this.scene.mutateElement(i,{name:p.target.value})},onFocus:p=>p.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:p=>{(p.key===w.ESCAPE||p.key===w.ENTER)&&this.resetEditingFrame(i)},style:{background:this.state.viewBackgroundColor,filter:t?Zf:"none",zIndex:2,border:"none",display:"block",padding:`${s}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${Pt.nameFontSize}px`,transform:`translate(-${s}px, ${s}px)`,color:"var(--color-gray-80)",overflow:"hidden",maxWidth:`${document.body.clientWidth-a-s}px`},size:d.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else c=m;return Se("div",{id:this.getFrameNameDOMId(i),style:{position:"absolute",bottom:`${this.state.height+Pt.nameOffsetY-l+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:Pt.nameFontSize,color:t?Pt.nameColorDarkTheme:Pt.nameColorLightTheme,lineHeight:Pt.nameLineHeight,width:"max-content",maxWidth:n?.id===i.id&&n?.focus?"none":`${i.width*this.state.zoom.value}px`,overflow:i.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:we.MOVE,pointerEvents:this.state.viewModeEnabled?zn.disabled:zn.enabled},onPointerDown:d=>this.handleCanvasPointerDown(d),onWheel:d=>this.handleWheel(d),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:c},i.id)})});k(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});k(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());k(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());k(this,"getSceneElements",()=>this.scene.getNonDeletedElements());k(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});k(this,"onExportImage",async(t,r,n)=>{me("export",t,"ui");let i=await ci(t,r,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:n.exportingFrame}).catch(Gs).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&Mc(i)&&this.setState({fileHandle:i})});k(this,"magicGenerations",new Map);k(this,"updateMagicGeneration",({frameElement:t,data:r})=>{r.status==="pending"?this.scene.mutateElement(t,{customData:{generationData:void 0}},{informMutation:!1,isDragging:!1}):this.scene.mutateElement(t,{customData:{generationData:r}},{informMutation:!1,isDragging:!1}),this.magicGenerations.set(t.id,r),this.triggerRender()});k(this,"plugins",{});k(this,"onMagicframeToolSelect",()=>{let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(t.length===0)this.setActiveTool({type:Qe.magicframe}),me("ai","tool-select (empty-selection)","d2c");else{let r=t.length===1&&js(t[0])&&t[0];if(!r&&t.some(i=>ce(i)||i.frameId)){this.setActiveTool({type:Qe.magicframe});return}me("ai","tool-select (existing selection)","d2c");let n;if(r)n=r;else{let[i,a,l,s]=ye(t),c=50;n=bl({...Pt,x:i-c,y:a-c,width:l-i+c*2,height:s-a+c*2,opacity:100,locked:!1}),this.scene.insertElement(n);for(let m of t)this.scene.mutateElement(m,{frameId:n.id});this.setState({selectedElementIds:{[n.id]:!0}})}this.onMagicFrameGenerate(n,"upstream")}});k(this,"openEyeDropper",({type:t})=>{this.updateEditorAtom(mn,{swapPreviewOnAlt:!0,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(r,n)=>{let i=t==="background"&&n.altKey||t==="stroke"&&!n.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?i?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:r},captureUpdate:A.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},captureUpdate:A.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?te(l,{[i?"strokeColor":"backgroundColor"]:r}):l),captureUpdate:A.IMMEDIATELY})},keepOpenOnAlt:!1})});k(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.setState({editingLinearElement:null})})});k(this,"syncActionResult",$e(t=>{if(this.unmounted||t===!1)return;this.store.scheduleAction(t.captureUpdate);let r=!1,n=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),r=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||n||this.state.contextMenu){let i=t?.appState?.viewModeEnabled||!1,a=t?.appState?.zenModeEnabled||!1,l=t?.appState?.theme||this.props.theme||re.LIGHT,s=t?.appState?.name??this.state.name,c=t?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(a=this.props.zenModeEnabled),n=t.appState?.editingTextElement||null,t.elements&&n&&t.elements.forEach(m=>{n?.id===m.id&&n!==m&&Yp(m)&&V(m)&&(n=m)}),n?.isDeleted&&(n=null),this.setState(m=>{let d=t.appState||{};return{...m,...d,contextMenu:null,editingTextElement:n,viewModeEnabled:i,zenModeEnabled:a,theme:l,name:s,errorMessage:c}}),r=!0}r||this.scene.triggerUpdate()}));k(this,"onBlur",$e(()=>{xi=!1,this.setState({isBindingEnabled:!0})}));k(this,"onUnload",()=>{this.onBlur()});k(this,"disableEvent",t=>{t.preventDefault()});k(this,"resetHistory",()=>{this.history.clear()});k(this,"resetStore",()=>{this.store.clear()});k(this,"resetScene",$e(t=>{this.scene.replaceAllElements([]),this.setState(r=>({...Vi(),isLoading:t?.resetLoadingState?!1:r.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));k(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async n=>{if(!n.files.length)return;let i=n.files[0],a=await i.getFile();this.loadFileToCanvas(new File([a],a.name||"",{type:a.type}),i)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let t=null;try{typeof this.props.initialData=="function"?t=await this.props.initialData()||null:t=await this.props.initialData||null,t?.libraryItems&&this.library.updateLibrary({libraryItems:t.libraryItems,merge:!0}).catch(n=>{console.error(n)})}catch(n){console.error(n),t={appState:{errorMessage:n.message||"Encountered an error during importing or restoring scene data"}}}let r=Xi(t,null,null,{repairBindings:!0});r.appState={...r.appState,theme:this.props.theme||r.appState.theme,openSidebar:r.appState?.openSidebar||this.state.openSidebar,activeTool:r.appState.activeTool.type==="image"?{...r.appState.activeTool,type:"selection"}:r.appState.activeTool,isLoading:!1,toast:this.state.toast},t?.scrollToContent&&(r.appState={...r.appState,...ei(r.elements,{...r.appState,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})}),this.resetStore(),this.resetHistory(),this.syncActionResult({...r,captureUpdate:A.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(n=>{this.fonts.onLoaded(n)}),Jn(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})});k(this,"isMobileBreakpoint",(t,r)=>t<Xf||r<jf&&t<$f);k(this,"refreshViewportBreakpoints",()=>{if(!this.excalidrawContainerRef.current)return;let{clientWidth:r,clientHeight:n}=document.body,i=this.device.viewport,a=Si(i,{isLandscape:r>n,isMobile:this.isMobileBreakpoint(r,n)});return i!==a?(this.device={...this.device,viewport:a},!0):!1});k(this,"refreshEditorBreakpoints",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:r,height:n}=t.getBoundingClientRect(),i=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:qf,a=this.device.editor,l=Si(a,{isMobile:this.isMobileBreakpoint(r,n),canFitSidebar:r>i});return a!==l?(this.device={...this.device,editor:l},!0):!1});k(this,"onResize",$e(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>To.delete(t)),this.refreshViewportBreakpoints(),this.updateDOMRect(),Xa||this.refreshEditorBreakpoints(),this.setState({})}));k(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});k(this,"renderInteractiveSceneCallback",({atLeastOneVisibleElement:t,scrollBars:r,elementsMap:n})=>{r&&(Es=r);let i=this.state.editingTextElement?!1:!t&&n.size>0;this.state.scrolledOutside!==i&&this.setState({scrolledOutside:i}),this.scheduleImageRefresh()});k(this,"onScroll",Un(()=>{let{offsetTop:t,offsetLeft:r}=this.getCanvasOffsets();this.setState(n=>n.offsetLeft===r&&n.offsetTop===t?null:{offsetTop:t,offsetLeft:r})},Vf));k(this,"onCut",$e(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||or(t.target)||(this.actionManager.executeAction(Sd,"keyboard",t),t.preventDefault(),t.stopPropagation())}));k(this,"onCopy",$e(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||or(t.target)||(this.actionManager.executeAction(Ea,"keyboard",t),t.preventDefault(),t.stopPropagation())}));k(this,"onTouchStart",t=>{if(Rf&&t.preventDefault(),!bs){bs=!0,clearTimeout(ef),ef=window.setTimeout(e.resetTapTwice,Yf);return}if(bs&&t.touches.length===1){let r=t.touches[0];this.handleCanvasDoubleClick({clientX:r.clientX,clientY:r.clientY}),bs=!1,clearTimeout(ef)}t.touches.length===2&&this.setState({selectedElementIds:Te({},this.state),activeEmbeddable:null})});k(this,"onTouchEnd",t=>{this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:Te(this.state.previousSelectedElementIds,this.state)}):ke.pointers.clear()});k(this,"addImageElementsToScene",async({sceneX:t,sceneY:r,files:n,selectAfterInsert:i=!0})=>{let a=await Promise.all(n.map(async s=>{let c=this.createImageElement({sceneX:t,sceneY:r});return await this.insertImageElement(c,s),this.initializeImageDimensions(c),c}));if(i){let s=Object.assign({},...a.map(c=>({[c.id]:!0})));this.setState({selectedElementIds:Te(s,this.state)})}let l=j(a);Tl(this.scene,a,l,this.state.arrangeConfiguration.algorithm,this.state.arrangeConfiguration.gap)});k(this,"pasteFromClipboard",$e(async t=>{let r=!!Hm,n=document.activeElement,i=this.excalidrawContainerRef.current?.contains(n);if(t&&!i)return;let a=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(t&&(!(a instanceof HTMLCanvasElement)||or(n)))return;let{x:l,y:s}=ze({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),c=t.clipboardData?.files[0],m=await vd(t,r);if(!c&&!r){if(m.mixedContent)return this.addElementsFromMixedContentPaste(m.mixedContent,{isPlainPaste:r,sceneX:l,sceneY:s});if(m.text){let d=m.text.trim();d.startsWith("<svg")&&d.endsWith("</svg>")&&(c=Qp(d))}}if(wl(c)&&!m.spreadsheet){if(!this.isToolSupported("image")){this.setState({errorMessage:g("errors.imageToolNotSupported")});return}if(!t.clipboardData)throw new Error("Clipboard data is not available");let d=t.clipboardData.files,p=Array.from(d);this.addImageElementsToScene({sceneX:l,sceneY:s,files:p});return}if(this.props.onPaste)try{if(await this.props.onPaste(m,t)===!1)return}catch(d){console.error(d)}if(m.errorMessage)this.setState({errorMessage:m.errorMessage});else if(m.spreadsheet&&!r)this.setState({pasteDialog:{data:m.spreadsheet,shown:!0}});else if(m.elements){let d=m.programmaticAPI?Na(m.elements):m.elements;this.addElementsFromPasteOrLibrary({elements:d,files:m.files||null,position:"cursor",retainSeed:r})}else if(m.text){if(m.text&&Nv(m.text)){let u=await import("@excalidraw/mermaid-to-excalidraw");try{let{elements:f,files:b}=await u.parseMermaidToExcalidraw(m.text),x=Na(f,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:x,files:b,position:"cursor"});return}catch(f){console.warn(`parsing pasted text as mermaid definition failed: ${f.message}`)}}let d=C1(m.text).split(/\n+/).map(u=>u.trim()).filter(Boolean),p=d.map(u=>B0(u)).filter(u=>Ui(u,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(u)||Qn(u)?.type==="video"));if(!Hm&&p.length>0&&p.length===d.length){let u=[];for(let f of p){let b=u[u.length-1],x=this.insertEmbeddableElement({sceneX:b?b.x+b.width+20:l,sceneY:s,link:Uo(f)});x&&u.push(x)}u.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(u.map(f=>[f.id,!0]))}));return}this.addTextFromPaste(m.text,r)}this.setActiveTool({type:"selection"}),t?.preventDefault()}));k(this,"addElementsFromPasteOrLibrary",t=>{let r=$p(t.elements,null,void 0),[n,i,a,l]=ye(r),s=Gn(n,a)/2,c=Gn(i,l)/2,m=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,d=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop,{x:p,y:u}=ze({clientX:m,clientY:d},this.state),f=p-s,b=u-c,[x,E]=yt(f,b,this.getEffectiveGridSize()),{duplicatedElements:y}=qn({type:"everything",elements:r.map(M=>te(M,{x:M.x+x-n,y:M.y+E-i})),randomizeSeed:!t.retainSeed}),v=this.scene.getElementsIncludingDeleted(),T=[...v,...y];T=this.props.onDuplicate?.(T,v)||T,nr(T,j(y));let S=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(S){let M=g0(y,S);Bi(T,M,S,this.state)}this.scene.replaceAllElements(T),y.forEach(M=>{if(V(M)&&rt(M)){let O=vo(M,this.scene.getElementsMapIncludingDeleted());Ke(M,O,this.scene)}}),Df&&on.loadElementsFonts(y).then(M=>{this.fonts.onLoaded(M)}),t.files&&this.addMissingFiles(t.files);let P=s0(y);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.device.editor.canFitSidebar&&wt.get(ss)?this.state.openSidebar:null,...it({editingGroupId:null,selectedElementIds:P.reduce((M,O)=>(rt(O)||(M[O.id]=!0),M),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:"selection"}),t.fitToContent&&this.scrollToContent(y,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})});k(this,"setAppState",(t,r)=>{this.setState(t,r)});k(this,"removePointer",t=>{Pn&&this.resetContextMenuTimer(),ke.pointers.delete(t.pointerId)});k(this,"toggleLock",(t="ui")=>{this.state.activeTool.locked||me("toolbar","toggleLock",`${t} (${this.device.editor.isMobile?"mobile":"desktop"})`),this.setState(r=>({activeTool:{...r.activeTool,...Le(this.state,r.activeTool.locked?{type:"selection"}:r.activeTool),locked:!r.activeTool.locked}}))});k(this,"updateFrameRendering",t=>{this.setState(r=>{let n=typeof t=="function"?t(r.frameRendering):t;return{frameRendering:{enabled:n?.enabled??r.frameRendering.enabled,clip:n?.clip??r.frameRendering.clip,name:n?.name??r.frameRendering.name,outline:n?.outline??r.frameRendering.outline}}})});k(this,"togglePenMode",t=>{this.setState(r=>({penMode:t??!r.penMode,penDetected:!0}))});k(this,"onHandToolToggle",()=>{this.actionManager.executeAction(n2)});k(this,"zoomCanvas",t=>{this.setState({...Ar({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:ir(t)},this.state)})});k(this,"cancelInProgressAnimation",null);k(this,"scrollToContent",(t=this.scene.getNonDeletedElements(),r)=>{if(typeof t=="string"){let s;if(Jn(t)?s=D0(t):s=t,s){let c=this.scene.getElementsFromId(s);c?.length?this.scrollToContent(c,{fitToContent:r?.fitToContent??!0,animate:r?.animate??!0}):Jn(t)&&this.setState({toast:{message:g("elementLink.notFound"),duration:3e3,closable:!0}})}return}this.cancelInProgressAnimation?.();let n=Array.isArray(t)?t:[t],i=this.state.zoom,a=this.state.scrollX,l=this.state.scrollY;if(r?.fitToContent||r?.fitToViewport){let{appState:s}=Gl({canvasOffsets:r.canvasOffsets,targetElements:n,appState:this.state,fitToViewport:!!r?.fitToViewport,viewportZoomFactor:r?.viewportZoomFactor,minZoom:r?.minZoom,maxZoom:r?.maxZoom});i=s.zoom,a=s.scrollX,l=s.scrollY}else{let s=ei(n,this.state);a=s.scrollX,l=s.scrollY}if(r?.animate){let s=this.state.scrollX,c=this.state.scrollY,m=this.state.zoom.value,d=p1({fromValues:{scrollX:s,scrollY:c,zoom:m},toValues:{scrollX:a,scrollY:l,zoom:i.value},interpolateValue:(p,u,f,b)=>{if(b==="zoom")return p*Math.pow(u/p,Ho(f))},onStep:({scrollX:p,scrollY:u,zoom:f})=>{this.setState({scrollX:p,scrollY:u,zoom:{value:f}})},onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.setState({shouldCacheIgnoreZoom:!1})},duration:r?.duration??500});this.cancelInProgressAnimation=()=>{d(),this.cancelInProgressAnimation=null}}else this.setState({scrollX:a,scrollY:l,zoom:i})});k(this,"maybeUnfollowRemoteUser",()=>{this.state.userToFollow&&this.setState({userToFollow:null})});k(this,"translateCanvas",t=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(t)});k(this,"setToast",t=>{this.setState({toast:t})});k(this,"restoreFileFromShare",async()=>{try{let t=await caches.open("web-share-target"),r=await t.match("shared-file");if(r){let n=await r.blob(),i=new File([n],n.name||"",{type:n.type});this.loadFileToCanvas(i,null),await t.delete("shared-file"),window.history.replaceState(null,$a,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});k(this,"addFiles",$e(t=>{let{addedFiles:r}=this.addMissingFiles(t);this.clearImageShapeCache(r),this.scene.triggerUpdate(),this.addNewImagesToImageCache()}));k(this,"addMissingFiles",(t,r=!1)=>{let n=r?{}:{...this.files},i={},a=Array.isArray(t)?t:Object.values(t);for(let l of a)if(!n[l.id]&&(i[l.id]=l,n[l.id]=l,l.mimeType===ue.svg))try{let s=Eb(Bp(yb(l.dataURL)),ue.svg);l.dataURL!==s&&(l.version=(l.version??1)+1,l.dataURL=s)}catch(s){console.error(s)}return this.files=n,{addedFiles:i}});k(this,"updateScene",$e(t=>{let{elements:r,appState:n,collaborators:i,captureUpdate:a}=t;if(a){let l=r||void 0,s=n?M0({...this.store.snapshot.appState,...n}):void 0;this.store.scheduleMicroAction({action:a,elements:l,appState:s})}n&&this.setState(n),r&&this.scene.replaceAllElements(r),i&&this.setState({collaborators:i})}));k(this,"mutateElement",(t,r,n=!0)=>this.scene.mutateElement(t,r,{informMutation:n,isDragging:!1}));k(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});k(this,"toggleSidebar",({name:t,tab:r,force:n})=>{let i;n===void 0?i=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===r?null:t:i=n?t:null;let a=i?{name:i}:null;return a&&r&&(a.tab=r),this.setState({openSidebar:a}),!!i});k(this,"updateCurrentCursorPosition",$e(t=>{this.lastViewportPosition.x=t.clientX,this.lastViewportPosition.y=t.clientY}));k(this,"getEditorUIOffsets",()=>{let t=this.excalidrawContainerRef?.current?.querySelector(".App-toolbar")?.getBoundingClientRect()?.bottom??0,r=this.excalidrawContainerRef?.current?.querySelector(".sidebar")?.getBoundingClientRect(),n=this.excalidrawContainerRef?.current?.querySelector(".App-menu__left")?.getBoundingClientRect(),i=16;return Ir().rtl?{top:t+i,right:Math.max(this.state.width-(n?.left??this.state.width),0)+i,bottom:i,left:Math.max(r?.right??0,0)+i}:{top:t+i,right:Math.max(this.state.width-(r?.left??this.state.width)+i,0),bottom:i,left:Math.max(n?.right??0,0)+i}});k(this,"onKeyDown",$e(t=>{if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(a,l){let s=a[l];return typeof s=="function"?s.bind(a):l==="key"?t.shiftKey?a.key.toUpperCase():a.key.toLowerCase():s}})),!up(t.target)){if((t.key===w.ESCAPE||t.key===w.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let a=q(this.scene.getNonDeletedElementsMap(),this.state);if(a.length===1&&Ne(a[0])&&t.key===w.ENTER){this.startImageCropping(a[0]);return}if(t.key===w.ESCAPE)this.updateEditorAtom(qo,null);else if(t.key===w.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(Bt.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let s=ka(a);wt.get(qo)?.type==="panel"&&_h(this,{conversionType:s,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),s&&this.updateEditorAtom(qo,{type:"panel"})}if(t.key===w.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let l=Fn(t.key);if(t[w.CTRL_OR_CMD]&&l&&!t.shiftKey){t.preventDefault();let s=q(this.scene.getNonDeletedElementsMap(),this.state);s.length===1&&qs(s[0])&&this.flowChartCreator.createNodes(s[0],this.state,Op(t.key),this.scene),this.flowChartCreator.pendingNodes?.length&&!Fi(this.flowChartCreator.pendingNodes,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(this.flowChartCreator.pendingNodes,{animate:!0,duration:300,fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()});return}if(t.altKey){let s=q(this.scene.getNonDeletedElementsMap(),this.state);if(s.length===1&&l){t.preventDefault();let c=this.flowChartNavigator.exploreByDirection(s[0],this.scene.getNonDeletedElementsMap(),Op(t.key));if(c){this.setState(d=>({selectedElementIds:Te({[c]:!0},d)}));let m=this.scene.getNonDeletedElementsMap().get(c);m&&!Fi([m],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(m,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})}return}}}if(t[w.CTRL_OR_CMD]&&t.key===w.P&&!t.shiftKey&&!t.altKey){this.setToast({message:g("commandPalette.shortcutHint",{shortcut:We("commandPalette")})}),t.preventDefault();return}if(t[w.CTRL_OR_CMD]&&t.key.toLowerCase()===w.V&&(Hm=t.shiftKey,clearTimeout(o5),o5=window.setTimeout(()=>{Hm=!1},100)),t[w.CTRL_OR_CMD]&&or(t.target)&&(t.code===le.MINUS||t.code===le.EQUAL)){t.preventDefault();return}if(or(t.target)&&t.key!==w.ESCAPE||Fn(t.key)&&up(t.target))return;if(t.key===w.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===w.E&&t.shiftKey&&t[w.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(t.key===w.PAGE_UP||t.key===w.PAGE_DOWN){let a=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;t.key===w.PAGE_DOWN&&(a=-a),t.shiftKey?this.translateCanvas(l=>({scrollX:l.scrollX+a})):this.translateCanvas(l=>({scrollY:l.scrollY+a}))}if(this.state.openDialog?.name==="elementLinkSelector"||this.actionManager.handleKeyDown(t)||this.state.viewModeEnabled)return;if(t[w.CTRL_OR_CMD]&&this.state.isBindingEnabled&&this.setState({isBindingEnabled:!1}),Fn(t.key)){let a=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),l=a.find(se),s=new Set;a.filter(se).filter(p=>{let u=p.startBinding&&!a.some(b=>b.id===p.startBinding?.elementId),f=p.endBinding&&!a.some(b=>b.id===p.endBinding?.elementId);return u||f}).forEach(p=>s.add(p.id)),a=a.filter(p=>!s.has(p.id));let c=this.getEffectiveGridSize()&&(t.shiftKey?Xm:this.getEffectiveGridSize())||(t.shiftKey?Of:Xm),m=0,d=0;t.key===w.ARROW_LEFT?m=-c:t.key===w.ARROW_RIGHT?m=c:t.key===w.ARROW_UP?d=-c:t.key===w.ARROW_DOWN&&(d=c),a.forEach(p=>{this.scene.mutateElement(p,{x:p.x+m,y:p.y+d},{informMutation:!1,isDragging:!1}),$r(p,this.scene,{simultaneouslyUpdated:a})}),this.setState({suggestedBindings:rc(a.filter(p=>p.id!==l?.id||c!==0),this.scene.getNonDeletedElementsMap(),this.state.zoom)}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===w.ENTER){let a=this.scene.getSelectedElements(this.state);if(a.length===1){let l=a[0];if(t[w.CTRL_OR_CMD]||qe(l))ge(l)&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==l.id)&&(this.store.scheduleCapture(),se(l)||this.setState({editingLinearElement:new $(l,this.scene.getNonDeletedElementsMap())}));else if(V(l)||j1(l)){let s;V(l)||(s=l);let c=Js(l,this.state,this.scene.getNonDeletedElementsMap()),m=c.x,d=c.y;this.startTextEditing({sceneX:m,sceneY:d,container:s}),t.preventDefault();return}else ce(l)&&this.setState({editingFrame:l.id})}}else if(!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let a=Vy(t.key);a?(this.state.activeTool.type!==a&&me("toolbar",a,`keyboard (${this.device.editor.isMobile?"mobile":"desktop"})`),a==="arrow"&&this.state.activeTool.type==="arrow"&&this.setState(l=>({currentItemArrowType:l.currentItemArrowType===ht.sharp?ht.round:l.currentItemArrowType===ht.round?ht.elbow:ht.sharp})),this.setActiveTool({type:a}),t.stopPropagation()):t.key===w.Q&&(this.toggleLock("keyboard"),t.stopPropagation())}if(t.key===w.SPACE&&ke.pointers.size===0&&(xi=!0,_e(this.interactiveCanvas,we.GRAB),t.preventDefault()),(t.key===w.G||t.key===w.S)&&!t.altKey&&!t[w.CTRL_OR_CMD]){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;t.key===w.G&&(Jr(this.state.activeTool.type)||a.some(l=>Jr(l.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===w.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[w.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===w.F){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;(this.state.activeTool.type==="text"||a.find(l=>V(l)||pe(l,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}if(t.key===w.K&&!t.altKey&&!t[w.CTRL_OR_CMD]){this.state.activeTool.type==="laser"?this.setActiveTool({type:"selection"}):this.setActiveTool({type:"laser"});return}let r=t.key.toLocaleLowerCase(),n=r===w.S&&t.shiftKey,i=t.key===w.I||r===w.G&&t.shiftKey;(n||i)&&this.openEyeDropper({type:n?"stroke":"background"})}));k(this,"onKeyUp",$e(t=>{if(t.key===w.SPACE&&(this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector"?_e(this.interactiveCanvas,we.GRAB):this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"?Lo(this.interactiveCanvas):(ho(this.interactiveCanvas,this.state),this.setState({selectedElementIds:Te({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),xi=!1),!t[w.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),Fn(t.key)&&(pl(this.scene.getSelectedElements(this.state).filter(ge),Xr(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.scene,this.state.zoom),this.setState({suggestedBindings:[]})),t.altKey||this.flowChartNavigator.isExploring&&(this.flowChartNavigator.clear(),this.syncActionResult({captureUpdate:A.IMMEDIATELY})),!t[w.CTRL_OR_CMD]&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.pendingNodes?.length&&this.scene.insertElements(this.flowChartCreator.pendingNodes);let r=this.flowChartCreator.pendingNodes?.[0];r&&(this.setState(n=>({selectedElementIds:Te({[r.id]:!0},n)})),Fi([r],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())||this.scrollToContent(r,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})),this.flowChartCreator.clear(),this.syncActionResult({captureUpdate:A.IMMEDIATELY})}}));k(this,"isToolSupported",t=>this.props.UIOptions.tools?.[t]!==!1);k(this,"setActiveTool",(t,r=!1)=>{if(!this.isToolSupported(t.type)){console.warn(`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`);return}let n=Le(this.state,t);n.type==="hand"?_e(this.interactiveCanvas,we.GRAB):xi||ho(this.interactiveCanvas,{...this.state,activeTool:n}),d1(document.activeElement)&&this.focusContainer(),L1(n.type)||this.setState({suggestedBindings:[]}),n.type==="image"&&this.onImageAction(),this.setState(i=>{let a={snapLines:i.snapLines.length?[]:i.snapLines,originSnapOffset:null,activeEmbeddable:null};return n.type==="freedraw"&&this.store.scheduleCapture(),n.type==="lasso"?{...i,activeTool:n,...r?{}:{selectedElementIds:Te({},i),selectedGroupIds:Te({},i),editingGroupId:null,multiElement:null},...a}:n.type!=="selection"?{...i,activeTool:n,selectedElementIds:Te({},i),selectedGroupIds:Te({},i),editingGroupId:null,multiElement:null,...a}:{...i,activeTool:n,...a}})});k(this,"setOpenDialog",t=>{this.setState({openDialog:t})});k(this,"setCursor",t=>{_e(this.interactiveCanvas,t)});k(this,"resetCursor",()=>{Lo(this.interactiveCanvas)});k(this,"isTouchScreenMultiTouchGesture",()=>ke.pointers.size>=2);k(this,"getName",()=>this.state.name||this.props.name||`${g("labels.untitled")}-${pp()}`);k(this,"onGestureStart",$e(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:Te({},this.state),activeEmbeddable:null}),ke.initialScale=this.state.zoom.value}));k(this,"onGestureChange",$e(t=>{if(t.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let r=ke.initialScale;r&&this.setState(n=>({...Ar({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:ir(r*t.scale)},n)}))}));k(this,"onGestureEnd",$e(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:Te(this.state.previousSelectedElementIds,this.state)}),ke.initialScale=null}));k(this,"startTextEditing",({sceneX:t,sceneY:r,insertAtParentCenter:n=!0,container:i,autoEdit:a=!0})=>{let l=!1,s=n&&this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,i);i&&s&&(pe(i,this.scene.getNonDeletedElementsMap())||(l=!0));let c=null,m=this.scene.getSelectedElements(this.state);m.length===1?V(m[0])?c=m[0]:i?c=pe(m[0],this.scene.getNonDeletedElementsMap()):c=this.getTextElementAtPosition(t,r):c=this.getTextElementAtPosition(t,r);let d=c?.fontFamily||this.state.currentItemFontFamily,p=c?.lineHeight||zo(d),u=this.state.currentItemFontSize;if(!c&&l&&i&&!Pe(i)){let E=H1(et({fontSize:u,fontFamily:d}),p),y=W1(u,p),v=Math.max(i.height,y),T=Math.max(i.width,E);this.scene.mutateElement(i,{height:v,width:T}),t=i.x+T/2,r=i.y+v/2,s&&(s=this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,i))}let f=this.getTopLayerFrameAtSceneCoords({x:t,y:r}),b=c||Ft({x:s?s.elementCenterX:t,y:s?s.elementCenterY:r,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:u,fontFamily:d,textAlign:s?"center":this.state.currentItemTextAlign,verticalAlign:s?Xt.MIDDLE:jm,containerId:l?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:p,angle:i?Pe(i)?0:i.angle:0,frameId:f?f.id:null});if(!c&&l&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:b.id})}),this.setState({editingTextElement:b}),!c)if(i&&l){let x=this.scene.getElementIndex(i.id);this.scene.insertElementAtIndex(b,x+1)}else this.scene.insertElement(b);a||c||i?this.handleTextWysiwyg(b,{isExistingElement:!!c}):this.setState({newElement:b,multiElement:null})});k(this,"startImageCropping",t=>{this.store.scheduleCapture(),this.setState({croppingElementId:t.id})});k(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});k(this,"handleCanvasDoubleClick",t=>{if(this.state.multiElement||this.state.activeTool.type!=="selection")return;let r=this.scene.getSelectedElements(this.state),{x:n,y:i}=ze(t,this.state);if(r.length===1&&ge(r[0])){let l=r[0];if((t[w.CTRL_OR_CMD]&&M1(l)||qe(l))&&this.state.editingLinearElement?.elementId!==l.id){this.store.scheduleCapture(),this.setState({editingLinearElement:new $(l,this.scene.getNonDeletedElementsMap())});return}else if(this.state.selectedLinearElement&&se(r[0])){let s=$.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:n,y:i},this.state,this.scene.getNonDeletedElementsMap()),c=s?$.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,s,this.scene.getNonDeletedElementsMap()):-1;if(c&&c>-1){this.store.scheduleCapture(),$.deleteFixedSegment(r[0],this.scene,c);let m=$.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:n,y:i},this.state,this.scene.getNonDeletedElementsMap()),d=m?$.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,m,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:{...this.state.selectedLinearElement.pointerDownState,segmentMidpoint:{index:d,value:s,added:!1}},segmentMidPointHoveredCoords:m}});return}}else if(this.state.editingLinearElement&&this.state.editingLinearElement.elementId===l.id&&qe(l))return}if(r.length===1&&Ne(r[0])){this.startImageCropping(r[0]);return}if(Lo(this.interactiveCanvas),Yo(this.state).length>0){let l=this.getElementAtPosition(n,i),s=l&&i0(l,this.state.selectedGroupIds);if(s){this.store.scheduleCapture(),this.setState(c=>({...c,...it({editingGroupId:s,selectedElementIds:{[l.id]:!0}},this.scene.getNonDeletedElements(),c,this)}));return}}if(Lo(this.interactiveCanvas),!t[w.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let l=this.getElementAtPosition(n,i);if(Li(l)){this.setState({activeEmbeddable:{element:l,state:"active"}});return}if(!this.state.editingLinearElement){let s=this.getTextBindableContainerAtPosition(n,i);if(s&&(bt(s)||!vr(s.backgroundColor)||Pi({point:L(n,i),element:s,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(s)}))){let c=Js(s,this.state,this.scene.getNonDeletedElementsMap());n=c.x,i=c.y}this.startTextEditing({sceneX:n,sceneY:i,insertAtParentCenter:!t.altKey,container:s})}}});k(this,"getElementLinkAtPosition",(t,r)=>{if(r&&r.locked)return;let n=this.scene.getNonDeletedElements(),i=-1;for(let a=n.length-1;a>=0;a--){let l=n[a];if(r&&l.id===r.id&&(i=a),l.link&&a>=i&&Cc(l,this.scene.getNonDeletedElementsMap(),this.state,L(t.x,t.y),this.device.editor.isMobile))return l}});k(this,"redirectToLink",(t,r)=>{let n=Yr(L(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),L(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||n>Bn)return;let i=ze(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),l=Cc(this.hitLinkElement,a,this.state,L(i.x,i.y),this.device.editor.isMobile),s=ze(this.lastPointerUpEvent,this.state),c=Cc(this.hitLinkElement,a,this.state,L(s.x,s.y),this.device.editor.isMobile);if(l&&c){Ch();let m=this.hitLinkElement.link;if(m){m=Uo(m);let d;if(this.props.onLinkOpen&&(d=Ys("excalidraw-link",t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:m},d)),!d?.defaultPrevented){let p=Xs(m)?"_self":"_blank",u=window.open(void 0,p);u&&(u.opener=null,u.location=m)}}}});k(this,"getTopLayerFrameAtSceneCoords",t=>{let r=this.scene.getNonDeletedElementsMap(),n=this.scene.getNonDeletedFramesLikes().filter(i=>Cp(t,i,r));return n.length?n[n.length-1]:null});k(this,"handleCanvasPointerMove",t=>{this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent,ke.pointers.has(t.pointerId)&&ke.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let r=ke.initialScale;if(ke.pointers.size===2&&ke.lastCenter&&r&&ke.initialDistance){let f=og(ke.pointers),b=f.x-ke.lastCenter.x,x=f.y-ke.lastCenter.y;ke.lastCenter=f;let E=rg(Array.from(ke.pointers.values())),y=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:E/ke.initialDistance,v=y?ir(r*y):this.state.zoom.value;this.setState(T=>{let I=Ar({viewportX:f.x,viewportY:f.y,nextZoom:v},T);this.translateCanvas({zoom:I.zoom,scrollX:I.scrollX+2*(b/v),scrollY:I.scrollY+2*(x/v),shouldCacheIgnoreZoom:!0})}),this.resetShouldCacheIgnoreZoomDebounced()}else ke.lastCenter=ke.initialDistance=ke.initialScale=null;if(xi||xs||tf||Ko(this.state))return;let i=lg(Es,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(i?Lo(this.interactiveCanvas):ho(this.interactiveCanvas,this.state));let a=ze(t,this.state),{x:l,y:s}=a;if(!this.state.newElement&&Ev(this.state.activeTool.type)){let{originOffset:f,snapLines:b}=xv(this.scene.getNonDeletedElements(),this,{x:l,y:s},t,this.scene.getNonDeletedElementsMap());this.setState(x=>{let E=Mi(x.snapLines,b),y=x.originSnapOffset?Mi(x.originSnapOffset,f):f;return x.snapLines===E&&x.originSnapOffset===y?null:{snapLines:E,originSnapOffset:y}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(f=>f.snapLines.length?{snapLines:[]}:null);if(this.state.editingLinearElement&&!this.state.editingLinearElement.isDragging){let f=$.handlePointerMove(t,l,s,this);f&&f!==this.state.editingLinearElement&&Br(()=>{this.setState({editingLinearElement:f})}),f?.lastUncommittedPoint!=null?this.maybeSuggestBindingAtCursor(a,f.elbowed):Br(()=>{this.setState({suggestedBindings:[]})})}if(A1(this.state.activeTool.type)){let{newElement:f}=this.state;Tr(f,!1)?this.maybeSuggestBindingsForLinearElementAtCoords(f,[a],this.state.startBoundElement):this.maybeSuggestBindingAtCursor(a,!1)}if(this.state.multiElement){let{multiElement:f}=this.state,{x:b,y:x}=f,{points:E,lastCommittedPoint:y}=f,v=E[E.length-1];if(ho(this.interactiveCanvas,this.state),v===y)Yr(L(l-b,s-x),v)>=ja?this.scene.mutateElement(f,{points:[...E,L(l-b,s-x)]},{informMutation:!1,isDragging:!1}):_e(this.interactiveCanvas,we.POINTER);else if(E.length>2&&y&&Yr(L(l-b,s-x),y)<ja)_e(this.interactiveCanvas,we.POINTER),this.scene.mutateElement(f,{points:E.slice(0,-1)},{informMutation:!1,isDragging:!1});else{let[T,I]=yt(l,s,t[w.CTRL_OR_CMD]||se(f)?null:this.getEffectiveGridSize()),[S,P]=f?.lastCommittedPoint??[0,0],M=T-b-S,O=I-x-P;Fs(t)&&({width:M,height:O}=Pp(S+b,P+x,T,I)),sl(E,this.state.zoom.value)&&_e(this.interactiveCanvas,we.POINTER),this.scene.mutateElement(f,{points:[...E.slice(0,-1),L(S+M,P+O)]},{isDragging:!0,informMutation:!1}),this.triggerRender(!1)}return}if(!!t.buttons||this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let m=this.scene.getNonDeletedElements(),d=this.scene.getSelectedElements(this.state);if(d.length===1&&!i&&!this.state.editingLinearElement){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,l,s),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&this.state.openDialog?.name!=="elementLinkSelector"&&!(d.length===1&&se(d[0]))){let f=zp(m,this.state,l,s,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);if(f&&f.transformHandleType){_e(this.interactiveCanvas,Hp(f));return}}}else if(d.length>1&&!i&&this.state.openDialog?.name!=="elementLinkSelector"){let f=Fp(ye(d),l,s,this.state.zoom,t.pointerType,this.device);if(f){_e(this.interactiveCanvas,Hp({transformHandleType:f}));return}}let p=this.getElementAtPosition(l,s,{preferSelected:!0,includeLockedElements:!0}),u=null;p&&p.locked?u=null:u=p,this.hitLinkElement=this.getElementLinkAtPosition(a,p),!Jt(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(_e(this.interactiveCanvas,we.POINTER),F2(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):(Ch(),u&&(u.link||zt(u))&&this.state.selectedElementIds[u.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?_e(this.interactiveCanvas,V(u)?we.TEXT:we.CROSSHAIR):this.state.viewModeEnabled?_e(this.interactiveCanvas,we.GRAB):this.state.openDialog?.name==="elementLinkSelector"?_e(this.interactiveCanvas,we.AUTO):i?_e(this.interactiveCanvas,we.AUTO):this.state.selectedLinearElement&&u?.id===this.state.selectedLinearElement.elementId?this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,l,s):t[w.CTRL_OR_CMD]?_e(this.interactiveCanvas,we.AUTO):(u||this.isHittingCommonBoundingBoxOfSelectedElements(a,d))&&!u?.locked&&(u&&Li(u)&&this.isIframeLikeElementCenter(u,t,l,s)?(_e(this.interactiveCanvas,we.POINTER),this.setState({activeEmbeddable:{element:u,state:"hover"}})):(!u||!se(u)||!(u.startBinding||u.endBinding))&&(_e(this.interactiveCanvas,we.MOVE),this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null})))),this.state.openDialog?.name==="elementLinkSelector"&&u?this.setState(f=>({hoveredElementIds:Mi(f.hoveredElementIds,it({editingGroupId:f.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),f,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!u&&this.setState(f=>({hoveredElementIds:Mi(f.hoveredElementIds,{})})))});k(this,"handleEraser",(t,r)=>{let n=this.eraserTrail.addPointToPath(r.x,r.y,t.altKey);this.elementsPendingErasure=new Set(n),this.triggerRender()});k(this,"handleTouchMove",t=>{ys=!0});k(this,"handleCanvasPointerDown",t=>{let r=t.target;if(r.setPointerCapture&&r.setPointerCapture(t.pointerId),this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.searchMatches&&(this.setState(d=>({searchMatches:d.searchMatches&&{focusedId:null,matches:d.searchMatches.matches.map(p=>({...p,focus:!1}))}})),this.updateEditorAtom(Dg,null)),wt.get(qo)&&this.updateEditorAtom(qo,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.updateGestureOnPointerDown(t),t.pointerType==="touch"&&this.state.newElement&&this.state.newElement.type==="freedraw"){let d=this.state.newElement;this.updateScene({...d.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(p=>p.id!==d.id)}:{},appState:{newElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:Te(Object.keys(this.state.selectedElementIds).filter(p=>p!==d.id).reduce((p,u)=>(p[u]=this.state.selectedElementIds[u],p),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?A.EVENTUALLY:A.NEVER});return}let n=document.getSelection();if(n?.anchorNode&&n.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(d=>({penMode:!0,penDetected:!0})),!this.device.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.device=Si(this.device,{isTouchScreen:!0})),xs||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===tr.ERASER&&this.state.activeTool.type!==Qe.eraser){this.setState({activeTool:Le(this.state,{type:Qe.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let d=()=>{p(),u?.(),Jt(this.state)&&this.setState({activeTool:Le(this.state,{...this.state.activeTool.lastActiveTool||{type:Qe.selection},lastActiveToolBeforeEraser:null})})},p=Fe(window,"pointerup",d,{once:!0}),u;requestAnimationFrame(()=>{u=this.missingPointerEventCleanupEmitter.once(d)})});return}if(t.button!==tr.MAIN&&t.button!==tr.TOUCH&&t.button!==tr.ERASER||ke.pointers.size>1)return;let i=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleDraggingScrollBar(t,i)||(this.clearSelectionIfNotUsingSelection(),this.updateBindingEnabledOnPointerMove(t),this.handleSelectionOnPointerDown(t,i))||!(!this.state.penMode||t.pointerType!=="touch"||this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"||this.state.activeTool.type==="text"||this.state.activeTool.type==="image"))return;this.state.activeTool.type==="lasso"?this.lassoTrail.startPath(i.origin.x,i.origin.y,t.shiftKey):this.state.activeTool.type==="text"?this.handleTextOnPointerDown(t,i):this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line"?this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,i):this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,i):this.state.activeTool.type==="custom"?ho(this.interactiveCanvas,this.state):this.state.activeTool.type===Qe.frame||this.state.activeTool.type===Qe.magicframe?this.createFrameElementOnPointerDown(i,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(i.lastCoords.x,i.lastCoords.y):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.state.activeTool.type!=="image"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,i),this.props?.onPointerDown?.(this.state.activeTool,i),this.onPointerDownEmitter.trigger(this.state.activeTool,i,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(i.lastCoords.x,i.lastCoords.y);let l=this.onPointerMoveFromPointerDownHandler(i),s=this.onPointerUpFromPointerDownHandler(i),c=this.onKeyDownFromPointerDownHandler(i),m=this.onKeyUpFromPointerDownHandler(i);this.missingPointerEventCleanupEmitter.once(d=>s(d||t.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener("pointermove",l),window.addEventListener("pointerup",s),window.addEventListener("keydown",c),window.addEventListener("keyup",m),i.eventListeners.onMove=l,i.eventListeners.onUp=s,i.eventListeners.onKeyUp=m,i.eventListeners.onKeyDown=c)});k(this,"handleCanvasPointerUp",t=>{this.removePointer(t),this.lastPointerUpEvent=t;let r=ze({clientX:t.clientX,clientY:t.clientY},this.state),n=t.timeStamp-(this.lastPointerDownEvent?.timeStamp??0);if(this.device.editor.isMobile&&n<300){let i=this.getElementAtPosition(r.x,r.y);if(Li(i)&&this.isIframeLikeElementCenter(i,t,r.x,r.y)){this.handleEmbeddableCenterClick(i);return}}if(this.device.isTouchScreen){let i=this.getElementAtPosition(r.x,r.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(r,i)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?n<300&&Li(this.hitLinkElement)&&!ab(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,L(r.x,r.y))?this.handleEmbeddableCenterClick(this.hitLinkElement):this.redirectToLink(t,this.device.isTouchScreen):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})});k(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(ys=!1,Pn?ys=!0:Pn=window.setTimeout(()=>{Pn=0,ys||this.handleCanvasContextMenu(t)},Wf))});k(this,"resetContextMenuTimer",()=>{clearTimeout(Pn),Pn=0,ys=!1});k(this,"maybeCleanupAfterMissingPointerUp",t=>{vs?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});k(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(ke.pointers.size<=1&&(t.button===tr.WHEEL||t.button===tr.MAIN&&xi||Ko(this.state)||this.state.viewModeEnabled)))return!1;xs=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let r=!1,n=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);_e(this.interactiveCanvas,we.GRABBING);let{clientX:i,clientY:a}=t,l=lm(c=>{let m=i-c.clientX,d=a-c.clientY;if(i=c.clientX,a=c.clientY,n&&!r&&(Math.abs(m)>1||Math.abs(d)>1)){r=!0;let p=f=>{document.body.removeEventListener("paste",p),f.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener("paste",p),window.removeEventListener("pointerup",u)},100)};document.body.addEventListener("paste",p),window.addEventListener("pointerup",u)}this.translateCanvas({scrollX:this.state.scrollX-m/this.state.zoom.value,scrollY:this.state.scrollY-d/this.state.zoom.value})}),s=$e(vs=()=>{vs=null,xs=!1,xi||(this.state.viewModeEnabled?_e(this.interactiveCanvas,we.GRAB):ho(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",s),window.removeEventListener("blur",s),l.flush()});return window.addEventListener("blur",s),window.addEventListener("pointermove",l,{passive:!0}),window.addEventListener("pointerup",s),!0});k(this,"clearSelectionIfNotUsingSelection",()=>{this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.setState({selectedElementIds:Te({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});k(this,"handleSelectionOnPointerDown",(t,r)=>{if(this.state.activeTool.type==="selection"){let n=this.scene.getNonDeletedElements(),i=this.scene.getNonDeletedElementsMap(),a=this.scene.getSelectedElements(this.state);if(a.length===1&&!this.state.editingLinearElement&&!se(a[0])&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let l=zp(n,this.state,r.origin.x,r.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);l!=null&&(l.transformHandleType==="rotation"?(this.setState({resizingElement:l.element}),r.resize.handleType=l.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:l.element}),r.resize.handleType=l.transformHandleType))}else a.length>1&&(r.resize.handleType=Fp(ye(a),r.origin.x,r.origin.y,this.state.zoom,t.pointerType,this.device));if(r.resize.handleType)r.resize.isResizing=!0,r.resize.offset=Us(V0(r.resize.handleType,a,i,r.origin.x,r.origin.y)),a.length===1&&ge(a[0])&&a[0].points.length===2&&(r.resize.arrowDirection=K0(r.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let p=this.state.editingLinearElement||this.state.selectedLinearElement,u=$.handlePointerDown(t,this,this.store,r.origin,p,this.scene);if(u.hitElement&&(r.hit.element=u.hitElement),u.linearElementEditor&&(this.setState({selectedLinearElement:u.linearElementEditor}),this.state.editingLinearElement&&this.setState({editingLinearElement:u.linearElementEditor})),u.didAddPoint)return!0}let l=this.getElementsAtPosition(r.origin.x,r.origin.y,{includeLockedElements:!0}),s=l.filter(p=>!p.locked),c=this.getElementAtPosition(r.origin.x,r.origin.y,{allHitElements:l});if((!c||c.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),c&&c.locked&&!s.some(p=>this.state.selectedElementIds[p.id])?r.hit.element=null:r.hit.element=r.hit.element??this.getElementAtPosition(r.origin.x,r.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(r.origin,c),this.hitLinkElement)return!0;if(this.state.croppingElementId&&r.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),r.hit.element&&this.getElementLinkAtPosition({x:r.origin.x,y:r.origin.y},r.hit.element))return!1;r.hit.allHitElements=s;let m=r.hit.element,d=r.hit.allHitElements.some(p=>this.isASelectedElement(p));if((m===null||!d)&&!t.shiftKey&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&this.clearSelection(m),this.state.editingLinearElement)this.setState({selectedElementIds:Te({[this.state.editingLinearElement.elementId]:!0},this.state)});else if(m!=null){if(t[w.CTRL_OR_CMD])return t.altKey||(this.state.selectedElementIds[m.id]||(r.hit.wasAddedToSelection=!0),this.setState(p=>({...n0(p,m),previousSelectedElementIds:this.state.selectedElementIds}))),!1;this.state.selectedElementIds[m.id]||(this.state.editingGroupId&&!Ni(m,this.state.editingGroupId)&&this.setState({selectedElementIds:Te({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!d&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(p=>{let u={...p.selectedElementIds,[m.id]:!0},f=[];if(Object.keys(p.selectedElementIds).forEach(b=>{let x=this.scene.getElement(b);x&&f.push(x)}),ce(m))Wo(f,m.id).forEach(b=>{delete u[b.id]});else if(m.frameId)u[m.frameId]&&delete u[m.id];else{let b=m.groupIds,x=new Set(b.flatMap(E=>He(this.scene.getNonDeletedElements(),E)).filter(E=>ce(E)).map(E=>E.id));x.size>0&&f.forEach(E=>{E.frameId&&x.has(E.frameId)&&(delete u[E.id],E.groupIds.flatMap(y=>He(this.scene.getNonDeletedElements(),y)).forEach(y=>{delete u[y.id]}))})}return p.openDialog?.name==="elementLinkSelector"&&(m.groupIds.some(b=>p.selectedGroupIds[b])||(u={[m.id]:!0})),{...it({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:m.link||zt(m)?"info":!1}}),r.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});k(this,"handleTextOnPointerDown",(t,r)=>{if(this.state.editingTextElement)return;let n=r.origin.x,i=r.origin.y,a=this.getElementAtPosition(n,i,{includeBoundTextElement:!0}),l=this.getTextBindableContainerAtPosition(n,i);bt(a)&&(l=a,n=a.x+a.width/2,i=a.y+a.height/2),this.startTextEditing({sceneX:n,sceneY:i,insertAtParentCenter:!t.altKey,container:l,autoEdit:!1}),Lo(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:Le(this.state,{type:"selection"})})});k(this,"handleFreeDrawElementOnPointerDown",(t,r,n)=>{let[i,a]=yt(n.origin.x,n.origin.y,null),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),s=t.pressure===.5,c=O0({type:r,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:s,locked:!1,frameId:l?l.id:null,points:[L(0,0)],pressures:s?[]:[t.pressure]});this.scene.insertElement(c),this.setState(d=>{let p={...d.selectedElementIds};return delete p[c.id],{selectedElementIds:Te(p,d)}});let m=ul(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom);this.setState({newElement:c,startBoundElement:m,suggestedBindings:[]})});k(this,"insertIframeElement",({sceneX:t,sceneY:r,width:n,height:i})=>{let[a,l]=yt(t,r,this.lastPointerDownEvent?.[w.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=R0({type:"iframe",x:a,y:l,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:n,height:i});return this.scene.insertElement(s),s});k(this,"insertEmbeddableElement",({sceneX:t,sceneY:r,link:n})=>{let[i,a]=yt(t,r,this.lastPointerDownEvent?.[w.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=Qn(n);if(!l)return;l.error instanceof URIError&&this.setToast({message:g("toast.unrecognizedLinkFormat"),closable:!0});let s=Rp({type:"embeddable",x:i,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("embeddable"),opacity:this.state.currentItemOpacity,locked:!1,width:l.intrinsicSize.w,height:l.intrinsicSize.h,link:n});return this.scene.insertElement(s),s});k(this,"createImageElement",({sceneX:t,sceneY:r,addToFrameUnderCursor:n=!0})=>{let[i,a]=yt(t,r,this.lastPointerDownEvent?.[w.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=n?this.getTopLayerFrameAtSceneCoords({x:i,y:a}):null;return Ec({type:"image",x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:l?l.id:null})});k(this,"handleLinearElementOnPointerDown",(t,r,n)=>{if(this.state.multiElement){let{multiElement:i}=this.state;if(i.type==="line"&&sl(i.points,this.state.zoom.value)){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(Ut);return}if(se(i)&&i.points.length>1){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(Ut);return}let{x:a,y:l,lastCommittedPoint:s}=i;if(i.points.length>1&&s&&Yr(L(n.origin.x-a,n.origin.y-l),s)<ja){this.actionManager.executeAction(Ut);return}this.setState(c=>({selectedElementIds:Te({...c.selectedElementIds,[i.id]:!0},c)})),this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),_e(this.interactiveCanvas,we.POINTER)}else{let[i,a]=yt(n.origin.x,n.origin.y,t[w.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:s,currentItemEndArrowhead:c}=this.state,[m,d]=r==="arrow"?[s,c]:[null,null],p=r==="arrow"?tn({type:r,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemArrowType===ht.round?{type:ut.PROPORTIONAL_RADIUS}:null,startArrowhead:m,endArrowhead:d,locked:!1,frameId:l?l.id:null,elbowed:this.state.currentItemArrowType===ht.elbow,fixedSegments:this.state.currentItemArrowType===ht.elbow?[]:null}):Co({type:r,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness==="round"?{type:ut.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:l?l.id:null});this.setState(f=>{let b={...f.selectedElementIds};return delete b[p.id],{selectedElementIds:Te(b,f)}}),this.scene.mutateElement(p,{points:[...p.points,L(0,0)]});let u=ul(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,se(p),se(p));this.scene.insertElement(p),this.setState({newElement:p,startBoundElement:u,suggestedBindings:[]})}});k(this,"createGenericElementOnPointerDown",(t,r)=>{let[n,i]=yt(r.origin.x,r.origin.y,this.lastPointerDownEvent?.[w.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:n,y:i}),l={x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:a?a.id:null},s;t==="embeddable"?s=Rp({type:"embeddable",...l}):s=qt({type:t,...l}),s.type==="selection"?this.setState({selectionElement:s}):(this.scene.insertElement(s),this.setState({multiElement:null,newElement:s}))});k(this,"createFrameElementOnPointerDown",(t,r)=>{let[n,i]=yt(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[w.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:n,y:i,opacity:this.state.currentItemOpacity,locked:!1,...Pt},l=r===Qe.magicframe?bl(a):Hi(a);this.scene.insertElement(l),this.setState({multiElement:null,newElement:l})});k(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});k(this,"eraseElements",()=>{let t=!1,r=this.scene.getElementsIncludingDeleted().map(n=>this.elementsPendingErasure.has(n.id)||n.frameId&&this.elementsPendingErasure.has(n.frameId)||rt(n)&&this.elementsPendingErasure.has(n.containerId)?(t=!0,te(n,{isDeleted:!0})):n);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(r))});k(this,"initializeImage",async({imageFile:t,imageElement:r})=>{if(!wl(t))throw new Error(g("errors.unsupportedFileType"));let n=t.type,i=t.size>=this.state.dontResizeLimitMBs*1024*1024;if(_e(this.interactiveCanvas,"wait"),n===ue.svg)try{t=Qp(Bp(await t.text()),t.name)}catch(c){throw console.warn(c),new Error(g("errors.svgImageInsertError"))}else if(i)try{t=await Ac(t,{maxWidthOrHeight:Jf}),console.info("Excalidraw: image resized")}catch(c){console.error("Error trying to resizing image file on insertion",c)}if(t.size>op)throw new Error(g("errors.fileTooBig",{maxSize:`${Math.trunc(op/1024/1024)}MB`}));let a=await(this.props.generateIdForFile?.(t)||xb(t));if(console.info("Excalidraw File ID:",a),!a)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(g("errors.imageInsertError"));let l=this.files[a]?.dataURL||await Jp(t),s=te(r,{fileId:a});return new Promise(async(c,m)=>{try{this.addMissingFiles([{mimeType:n,id:a,dataURL:l,created:Date.now(),lastRetrieved:Date.now()}]);let d=this.imageCache.get(a);if(!d){this.addNewImagesToImageCache();let{updatedFiles:u}=await this.updateImageCache([s]);u.size&&To.delete(r),d=this.imageCache.get(a)}let p=await d?.image;if(p&&this.state.newElement?.id!==s.id){let u=this.getImageNaturalDimensions(s,p);s=te(s,u)}c(s)}catch(d){console.error(d),m(new Error(g("errors.imageInsertError")))}})});k(this,"insertImageElement",async(t,r)=>{if(!this.isToolSupported("image")){this.setState({errorMessage:g("errors.imageToolNotSupported")});return}this.scene.insertElement(t);try{let n=await this.initializeImage({imageFile:r,imageElement:t}),i=this.scene.getElementsIncludingDeleted().map(a=>a.id===n.id?n:a);return this.updateScene({captureUpdate:A.NEVER,elements:i}),n}catch(n){return this.scene.mutateElement(t,{isDeleted:!0}),this.actionManager.executeAction(Ut),this.setState({errorMessage:n.message||g("errors.imageInsertError")}),null}});k(this,"onImageAction",async()=>{try{let t=this.state.width/2+this.state.offsetLeft,r=this.state.height/2+this.state.offsetTop,{x:n,y:i}=ze({clientX:t,clientY:r},this.state),a=await wc({description:"Image",extensions:Object.keys(Qa)}),l=this.createImageElement({sceneX:n,sceneY:i,addToFrameUnderCursor:!1});this.insertImageElement(l,a),this.initializeImageDimensions(l),this.store.scheduleCapture(),this.setState({selectedElementIds:Te({[l.id]:!0},this.state)},()=>{this.actionManager.executeAction(Ut)})}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:Le(this.state,{type:"selection"})},()=>{this.actionManager.executeAction(Ut)})}});k(this,"initializeImageDimensions",t=>{let r=wr(t)&&this.imageCache.get(t.fileId)?.image;if(!r||r instanceof Promise){if(t.width<Bn/this.state.zoom.value&&t.height<Bn/this.state.zoom.value){let n=100/this.state.zoom.value;this.scene.mutateElement(t,{x:t.x-n/2,y:t.y-n/2,width:n,height:n})}return}if(t.width<Bn/this.state.zoom.value&&t.height<Bn/this.state.zoom.value){let n=this.getImageNaturalDimensions(t,r);this.scene.mutateElement(t,n)}});k(this,"getImageNaturalDimensions",(t,r)=>{let n=Math.max(this.state.height-120,160),i=Math.min(n,Math.floor(this.state.height*.5)/this.state.zoom.value),a=Math.min(r.naturalHeight,i),l=a*(r.naturalWidth/r.naturalHeight),s=t.x+t.width/2-l/2,c=t.y+t.height/2-a/2;return{x:s,y:c,width:l,height:a,crop:null}});k(this,"updateImageCache",async(t,r=this.files)=>{let{updatedFiles:n,erroredFiles:i}=await U0({imageCache:this.imageCache,fileIds:t.map(a=>a.fileId),files:r});return i.size&&this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(a=>wr(a)&&i.has(a.fileId)?te(a,{status:"error"}):a)),{updatedFiles:n,erroredFiles:i}});k(this,"addNewImagesToImageCache",async(t=G0(this.scene.getNonDeletedElements()),r=this.files)=>{let n=t.filter(i=>!i.isDeleted&&!this.imageCache.has(i.fileId));if(n.length){let{updatedFiles:i}=await this.updateImageCache(n,r);if(i.size)for(let a of n)i.has(a.fileId)&&To.delete(a);i.size&&this.scene.triggerUpdate()}});k(this,"scheduleImageRefresh",wL(()=>{this.addNewImagesToImageCache()},Gf));k(this,"updateBindingEnabledOnPointerMove",t=>{let r=e0(t);this.state.isBindingEnabled!==r&&this.setState({isBindingEnabled:r})});k(this,"maybeSuggestBindingAtCursor",(t,r)=>{let n=ul(t,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,!1,r);this.setState({suggestedBindings:n!=null?[n]:[]})});k(this,"maybeSuggestBindingsForLinearElementAtCoords",(t,r,n)=>{if(!r.length)return;let i=r.reduce((a,l)=>{let s=ul(l,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,se(t),se(t));return s!=null&&!o0(t,n?.id,s)&&a.push(s),a},[]);this.setState({suggestedBindings:i})});k(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.interactiveCanvas.addEventListener("touchstart",this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener("touchend",this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener("touchstart",this.onTouchStart),this.interactiveCanvas?.removeEventListener("touchend",this.onTouchEnd))});k(this,"handleAppOnDrop",async t=>{let{files:r,fileHandle:n}=await wb(t),{x:i,y:a}=ze(t,this.state);if(r===null){console.warn("File is null");return}let l=r?r[0]:null;try{if(r.length>0&&wl(l)&&this.isToolSupported("image")){if(r.length===1&&l.type===ue.png||l.type===ue.svg)try{let m=await Lc(l,this.state,this.scene.getElementsIncludingDeleted(),n);this.syncActionResult({...m,appState:{...m.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:A.IMMEDIATELY});return}catch(m){if(m.name!=="EncodingError")throw new Error(g("alerts.couldNotLoadInvalidFile"))}let c=r.filter(m=>wl(m));if(c.length>0){let m=await Promise.all(c.map(async u=>{let f=this.createImageElement({sceneX:i,sceneY:a});return this.insertImageElement(f,u),this.initializeImageDimensions(f),f}));this.store.scheduleCapture();let d=Object.assign({},...m.map(u=>({[u.id]:!0})));this.setState({selectedElementIds:Te(d,this.state)});let p=j(m);Tl(this.scene,m,p,this.state.arrangeConfiguration.algorithm,this.state.arrangeConfiguration.gap);return}}}catch(c){return this.setState({isLoading:!1,errorMessage:c.message})}let s=t.dataTransfer.getData(ue.excalidrawlib);if(s&&typeof s=="string"){try{let c=bb(s);this.addElementsFromPasteOrLibrary({elements:zd(c),position:t,files:null})}catch(c){this.setState({errorMessage:c.message})}return}if(l&&await this.loadFileToCanvas(l,n),t.dataTransfer?.types?.includes("text/plain")){let c=t.dataTransfer?.getData("text");if(c&&Ui(c,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(c)||Qn(c)?.type==="video")){let m=this.insertEmbeddableElement({sceneX:i,sceneY:a,link:Uo(c)});m&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[m.id]:!0}}))}}});k(this,"loadFileToCanvas",async(t,r)=>{t=await Cb(t);try{let n=this.scene.getElementsIncludingDeleted(),i;try{i=await jp(t,this.state,n,r)}catch(a){let l=a instanceof rb;if(l&&a.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:g("errors.imageToolNotSupported")});return}let s=l?g("alerts.cannotRestoreFromImage"):g("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:s})}if(!i)return;i.type===ue.excalidraw?(en(n.concat(i.data.elements)),this.store.scheduleMicroAction({action:A.NEVER,elements:n,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({...i.data,appState:{...i.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:A.IMMEDIATELY})):i.type===ue.excalidrawlib&&await this.library.updateLibrary({libraryItems:t,merge:!0,openLibraryMenu:!0}).catch(a=>{console.error(a),this.setState({errorMessage:g("errors.importLibraryError")})})}catch(n){this.setState({isLoading:!1,errorMessage:n.message})}});k(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==tr.SECONDARY)&&this.state.activeTool.type!=="selection")return;let{x:r,y:n}=ze(t,this.state),i=this.getElementAtPosition(r,n,{preferSelected:!0,includeLockedElements:!0}),a=this.scene.getSelectedElements(this.state),l=this.isHittingCommonBoundingBoxOfSelectedElements({x:r,y:n},a),s=i||l?"element":"canvas",c=this.excalidrawContainerRef.current,{top:m,left:d}=c.getBoundingClientRect(),p=t.clientX-d,u=t.clientY-m;me("contextMenu","openContextMenu",s),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,...it({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:ge(i)?new $(i,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:p,items:this.getContextMenuItems(s)}})})});k(this,"maybeDragNewGenericElement",(t,r,n=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&this.state.activeTool.type!=="eraser"){Dp({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:Gn(t.origin.x,a.x),height:Gn(t.origin.y,a.y),shouldMaintainAspectRatio:wi(r),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let l=this.state.newElement;if(!l)return;let[s,c]=yt(a.x,a.y,r[w.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=wr(l)&&this.imageCache.get(l.fileId)?.image,d=m&&!(m instanceof Promise)?m.width/m.height:null;this.maybeCacheReferenceSnapPoints(r,[l]);let{snapOffset:p,snapLines:u}=bv(l,this,r,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:s-t.originInGrid.x,y:c-t.originInGrid.y},this.scene.getNonDeletedElementsMap());s+=p.x,c+=p.y,this.setState({snapLines:u}),Dp({newElement:l,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:s,y:c,width:Gn(t.originInGrid.x,s),height:Gn(t.originInGrid.y,c),shouldMaintainAspectRatio:Ne(l)?!wi(r):wi(r),shouldResizeFromCenter:ip(r),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:d,originOffset:this.state.originSnapOffset,informMutation:n}),this.setState({newElement:l}),(this.state.activeTool.type===Qe.frame||this.state.activeTool.type===Qe.magicframe)&&this.setState({elementsToHighlight:Oi(this.scene.getNonDeletedElements(),l,this.state,this.scene.getNonDeletedElementsMap())})});k(this,"maybeHandleCrop",(t,r)=>{if(!this.state.croppingElementId)return!1;let n=t.resize.handleType,i=t.lastCoords,[a,l]=yt(i.x-t.resize.offset.x,i.y-t.resize.offset.y,r[w.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(n&&s&&Ne(s)){let c=t.originalElements.get(s.id),m=wr(s)&&this.imageCache.get(s.fileId)?.image;if(c&&Ne(c)&&m&&!(m instanceof Promise)){let[d,p]=yt(i.x,i.y,r[w.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:d-t.originInGrid.x,y:p-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(r,[s]);let{snapOffset:f,snapLines:b}=ig([s],[c],this,r,u,n);this.scene.mutateElement(s,k1(s,this.scene.getNonDeletedElementsMap(),n,m.naturalWidth,m.naturalHeight,a+f.x,l+f.y,r.shiftKey?c.width/c.height:void 0)),$r(s,this.scene,{newSize:{width:s.width,height:s.height}}),this.setState({isCropping:n&&n!=="rotation",snapLines:b})}return!0}return!1});k(this,"maybeHandleResize",(t,r)=>{let n=this.scene.getSelectedElements(this.state),i=n.filter(d=>ce(d)),a=t.resize.handleType;if(i.length>0&&a==="rotation"||n.length===1&&se(n[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let l=t.lastCoords,[s,c]=yt(l.x-t.resize.offset.x,l.y-t.resize.offset.y,r[w.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=new Map;if(i.forEach(d=>{Wo(this.scene.getNonDeletedElements(),d.id).forEach(u=>{m.set(d.id+u.id,{x:u.x-d.x,y:u.y-d.y})})}),!this.state.selectedElementsAreBeingDragged){let[d,p]=yt(l.x,l.y,r[w.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:d-t.originInGrid.x,y:p-t.originInGrid.y},f=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(r,n);let{snapOffset:b,snapLines:x}=ig(n,q(f,this.state),this,r,u,a);s+=b.x,c+=b.y,this.setState({snapLines:x})}if(Y0(t.originalElements,a,n,this.scene,Fs(r),ip(r),n.some(d=>Ne(d))?!wi(r):wi(r),s,c,t.resize.center.x,t.resize.center.y)){let d=rc(n,this.scene.getNonDeletedElementsMap(),this.state.zoom),p=new Set;return i.forEach(u=>{Oi(this.scene.getNonDeletedElements(),u,this.state,this.scene.getNonDeletedElementsMap()).forEach(f=>p.add(f))}),this.setState({elementsToHighlight:[...p],suggestedBindings:d}),!0}return!1});k(this,"getContextMenuItems",t=>{let r=[];return r.push(Md,Id),t==="canvas"?this.state.viewModeEnabled?[...r,Ad,ya,eg,va]:[fh,ct,Md,Id,Ld,ct,Au,H2,ct,Ad,bh,ya,eg,va]:(r.push(Ld),this.state.viewModeEnabled?[Ea,...r]:[ct,Sd,Ea,fh,ct,tv,ov,rv,ct,Jh,ct,...r,ct,sh,ch,ct,dh,sv,xh,Eh,P2,mh,ct,uh,ct,Su,Iu,Mu,Lu,ct,hh,gh,ct,qh,ct,Xl,Rd,ct,Bv,_u,$l,ct,Rl])});k(this,"handleWheel",$e(t=>{if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement)){t[w.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),xs)return;let{deltaX:r,deltaY:n}=t;if(t.metaKey||t.ctrlKey||this.state.wheelZoomsOnDefault){let i=Math.sign(n),a=yi*100,l=Math.abs(n),s=n;l>a&&(s=a*i);let c=this.state.zoom.value-s/100;c+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,l/20),this.translateCanvas(m=>({...Ar({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:ir(c)},m),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.translateCanvas(({zoom:i,scrollX:a})=>({scrollX:a-(n||r)/i.value}));return}this.translateCanvas(({zoom:i,scrollX:a,scrollY:l})=>({scrollX:a-r/i.value,scrollY:l-n/i.value}))}));k(this,"savePointer",(t,r,n)=>{if(!t||!r)return;let{x:i,y:a}=ze({clientX:t,clientY:r},this.state);isNaN(i)||isNaN(a);let l={x:i,y:a,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:l,button:n,pointersMap:ke.pointers})});k(this,"resetShouldCacheIgnoreZoomDebounced",Un(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));k(this,"updateDOMRect",t=>{if(this.excalidrawContainerRef?.current){let r=this.excalidrawContainerRef.current,{width:n,height:i,left:a,top:l}=r.getBoundingClientRect(),{width:s,height:c,offsetTop:m,offsetLeft:d}=this.state;if(n===s&&i===c&&a===d&&l===m){t&&t();return}this.setState({width:n,height:i,offsetLeft:a,offsetTop:l},()=>{t&&t()})}});k(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});let r=Vi(),{excalidrawAPI:n,viewModeEnabled:i=!1,zenModeEnabled:a=!1,gridModeEnabled:l=!1,objectsSnapModeEnabled:s=!1,theme:c=r.theme,name:m=`${g("labels.untitled")}-${pp()}`,wheelZoomsOnDefault:d=!1}=t;if(this.state={...r,theme:c,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:i,zenModeEnabled:a,objectsSnapModeEnabled:s,gridModeEnabled:l??r.gridModeEnabled,name:m,width:window.innerWidth,height:window.innerHeight,wheelZoomsOnDefault:d},this.id=CL(),this.library=new iy(this),this.actionManager=new tm(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new fl,this.canvas=document.createElement("canvas"),this.rc=TL.canvas(this.canvas),this.renderer=new as(this.scene),this.visibleElements=[],this.store=new k0(this),this.history=new ns(this.store),n){let p={updateScene:this.updateScene,mutateElement:this.mutateElement,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,addImageElementsToScene:this.addImageElementsToScene,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},scrollToContent:this.scrollToContent,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:u=>{this.actionManager.registerAction(u)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.setCursor,resetCursor:this.resetCursor,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:u=>this.onChangeEmitter.on(u),onIncrement:u=>this.store.onStoreIncrementEmitter.on(u),onPointerDown:u=>this.onPointerDownEmitter.on(u),onPointerUp:u=>this.onPointerUpEmitter.on(u),onScrollChange:u=>this.onScrollChangeEmitter.on(u),onUserFollow:u=>this.onUserFollowEmitter.on(u)};typeof n=="function"?n(p):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new on(this.scene),this.history=new ns(this.store),this.actionManager.registerAll(Jc),this.actionManager.registerAction(iv(this.history)),this.actionManager.registerAction(av(this.history))}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let r=null;try{r=JSON.parse(t.data)}catch{}if(r)switch(t.origin){case"https://player.vimeo.com":if(r.method==="paused"){let n=null,i=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!i)break;for(let a of i)a.contentWindow===t.source&&(n=a.contentWindow);n?.postMessage(JSON.stringify({method:r.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(r.event==="infoDelivery"&&r.info&&r.id&&typeof r.info.playerState=="number"){let n=r.id,i=r.info.playerState;Object.values(qa).includes(i)&&of.set(n,i)}break}}cacheEmbeddableRef(t,r){r&&this.iFrameRefs.set(t.id,r)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleEmbeddableCenterClick(t){if(this.state.activeEmbeddable?.element===t&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:t,state:"active"},selectedElementIds:{[t.id]:!0},newElement:null,selectionElement:null})},100),Vn(t)))return;let r=this.getHTMLIFrameElement(t);if(r?.contentWindow){if(r.src.includes("youtube")){let n=of.get(t.id);switch(n||(of.set(t.id,qa.UNSTARTED),r.contentWindow.postMessage(JSON.stringify({event:"listening",id:t.id}),"*")),n){case qa.PLAYING:case qa.BUFFERING:r.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:r.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}r.src.includes("player.vimeo.com")&&r.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*")}}isIframeLikeElementCenter(t,r,n,i){return t&&!r.altKey&&!r.shiftKey&&!r.metaKey&&!r.ctrlKey&&(this.state.activeEmbeddable?.element!==t||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&n>=t.x+t.width/3&&n<=t.x+2*t.width/3&&i>=t.y+t.height/3&&i<=t.y+2*t.height/3}renderEmbeddables(){let t=this.state.zoom.value,r=this.state.width,n=this.state.height,i=this.scene.getNonDeletedElements().filter(a=>zt(a)&&this.embedsValidationStatus.get(a.id)===!0||Vn(a));return Se(SL,{children:i.map(a=>{let{x:l,y:s}=gt({sceneX:a.x,sceneY:a.y},this.state),c=gl(a,r,n,this.state,this.scene.getNonDeletedElementsMap()),m=this.initializedEmbeds.has(a.id);if(c&&!m&&this.initializedEmbeds.add(a.id),!(c||m))return null;let p;if(Vn(a)){p=null;let b=(a.customData?.generationData??this.magicGenerations.get(a.id))||{status:"error",message:"No generation data",code:"ERR_NO_GENERATION_DATA"};if(b.status==="done"){let x=b.html;p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>x}}else if(b.status==="pending")p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>Np(`
24
+ C -->|Three| F[Car]`,$3=wB(dl,300),IB=({mermaidToExcalidrawLib:e})=>{let[o,t]=X3(()=>Ut.get(yB.MERMAID_TO_EXCALIDRAW)||TB),r=EB(o.trim()),[n,i]=X3(null),a=K3(null),l=K3({elements:[],files:null}),s=Re();Z3(()=>{kd({canvasRef:a,data:l,mermaidToExcalidrawLib:e,setError:i,mermaidDefinition:r}).catch(d=>{vB()&&console.error("Failed to parse mermaid definition",d)}),$3(r)},[r,e]),Z3(()=>()=>{$3.flush()},[]);let c=()=>{Md({app:s,data:l,text:o,shouldSaveMermaidDataToStorage:!0})};return j3(CB,{children:[So("div",{className:"ttd-dialog-desc",children:So(ut,{i18nKey:"mermaid.description",flowchartLink:d=>So("a",{href:"https://mermaid.js.org/syntax/flowchart.html",children:d}),sequenceLink:d=>So("a",{href:"https://mermaid.js.org/syntax/sequenceDiagram.html",children:d}),classLink:d=>So("a",{href:"https://mermaid.js.org/syntax/classDiagram.html",children:d})})}),j3(Cd,{children:[So(Ni,{label:g("mermaid.syntax"),children:So(vd,{input:o,placeholder:"Write Mermaid diagram defintion here...",onChange:d=>t(d.target.value),onKeyboardSubmit:()=>{c()}})}),So(Ni,{label:g("mermaid.preview"),panelAction:{action:()=>{c()},label:g("mermaid.button"),icon:Rn},renderSubmitShortcut:()=>So(Sd,{}),children:So(Id,{canvasRef:a,loaded:e.loaded,error:n})})]})]})},q3=IB;import*as Q3 from"@radix-ui/react-tabs";import{useRef as J3}from"react";import{isMemberOf as SB}from"@excalidraw/common";import{jsx as kB}from"react/jsx-runtime";var e5=e=>{let o=le(),t=J3(null),r=J3(0);return kB(Q3.Root,{ref:t,className:"ttd-dialog-tabs-root",value:e.tab,onValueChange:n=>{if(!n)return;let i=t.current?.closest(".Modal__content");if(i){let a=i.offsetHeight||0;a>r.current&&(r.current=a,i.style.minHeight=`min(${r.current}px, 100%)`)}e.dialog==="ttd"&&SB(["text-to-diagram","mermaid"],n)&&o({openDialog:{name:e.dialog,tab:n}})},children:e.children})};e5.displayName="TTDDialogTabs";var t5=e5;import*as o5 from"@radix-ui/react-tabs";import{jsx as MB}from"react/jsx-runtime";var yg=({children:e,...o})=>MB(o5.List,{className:"ttd-dialog-triggers",...o,children:e});yg.displayName="TTDDialogTabTriggers";import*as n5 from"@radix-ui/react-tabs";import{jsx as r5}from"react/jsx-runtime";var Ld=({children:e,tab:o,onSelect:t,...r})=>r5(n5.Trigger,{value:o,asChild:!0,onSelect:t,children:r5("button",{type:"button",className:"ttd-dialog-tab-trigger",...r,children:e})});Ld.displayName="TTDDialogTabTrigger";import*as i5 from"@radix-ui/react-tabs";import{jsx as LB}from"react/jsx-runtime";var Pd=({tab:e,children:o,...t})=>LB(i5.Content,{...t,value:e,children:o});Pd.displayName="TTDDialogTab";import{jsx as bt,jsxs as Ir}from"react/jsx-runtime";var vg=3,Bi=1e3,AB=he(null),DB=he(null),Tg=e=>{let o=ge();return o.openDialog?.name!=="ttd"?null:bt(_B,{...e,tab:o.openDialog.tab})},_B=Wo("TTDDialogBase",({tab:e,...o})=>{let t=Re(),r=le(),n=wg(null),[i,a]=se(DB),[l,s]=Ad(i?.prompt??""),c=l.trim(),d=S=>{s(S.target.value),a(L=>({generatedResponse:L?.generatedResponse??null,prompt:S.target.value}))},[m,p]=Ad(!1),[u,f]=se(AB),b=async()=>{if(c.length>Bi||c.length<vg||m||u?.rateLimitRemaining===0||"__fallback"in o){c.length<vg&&C(new Error(`Prompt is too short (min ${vg} characters)`)),c.length>Bi&&C(new Error(`Prompt is too long (max ${Bi} characters)`));return}try{p(!0),re("ai","generate","ttd");let{generatedResponse:S,error:L,rateLimit:k,rateLimitRemaining:A}=await o.onTextSubmit(c);if(typeof S=="string"&&a(P=>({generatedResponse:S,prompt:P?.prompt??null})),a5(k)&&a5(A)&&f({rateLimit:k,rateLimitRemaining:A}),L){C(L);return}if(!S){C(new Error("Generation failed"));return}try{await kd({canvasRef:n,data:y,mermaidToExcalidrawLib:w,setError:C,mermaidDefinition:S}),re("ai","mermaid parse success","ttd")}catch(P){console.info(`%cTTD mermaid render errror: ${P.message}`,"color: red"),console.info(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
25
+ TTD mermaid definition render errror: ${P.message}`,"color: yellow"),re("ai","mermaid parse failed","ttd"),C(new Error("Generated an invalid diagram :(. You may also try a different prompt."))}}catch(S){let L=S.message;(!L||L==="Failed to fetch")&&(L="Request failed"),C(new Error(L))}finally{p(!1)}},x=wg(b);x.current=b;let[w,E]=Ad({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw")});PB(()=>{(async()=>{await w.api,E(L=>({...L,loaded:!0}))})()},[w.api]);let y=wg({elements:[],files:null}),[v,C]=Ad(null);return bt(Ne,{className:"ttd-dialog",onCloseRequest:()=>{t.setOpenDialog(null)},size:1200,title:!1,...o,autofocus:!1,children:Ir(t5,{dialog:"ttd",tab:e,children:["__fallback"in o&&o.__fallback?bt("p",{className:"dialog-mermaid-title",children:g("mermaid.title")}):Ir(yg,{children:[bt(Ld,{tab:"text-to-diagram",children:Ir("div",{style:{display:"flex",alignItems:"center"},children:[g("labels.textToDiagram"),bt("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"1px 6px",marginLeft:"10px",fontSize:10,borderRadius:"12px",background:"var(--color-promo)",color:"var(--color-surface-lowest)"},children:"AI Beta"})]})}),bt(Ld,{tab:"mermaid",children:"Mermaid"})]}),bt(Pd,{className:"ttd-dialog-content",tab:"mermaid",children:bt(q3,{mermaidToExcalidrawLib:w})}),!("__fallback"in o)&&Ir(Pd,{className:"ttd-dialog-content",tab:"text-to-diagram",children:[bt("div",{className:"ttd-dialog-desc",children:"Currently we use Mermaid as a middle step, so you'll get best results if you describe a diagram, workflow, flow chart, and similar."}),Ir(Cd,{children:[bt(Ni,{label:g("labels.prompt"),panelAction:{action:b,label:"Generate",icon:Rn},onTextSubmitInProgess:m,panelActionDisabled:c.length>Bi||u?.rateLimitRemaining===0,renderTopRight:()=>u?Ir("div",{className:"ttd-dialog-rate-limit",style:{fontSize:12,marginLeft:"auto",color:u.rateLimitRemaining===0?"var(--color-danger)":void 0},children:[u.rateLimitRemaining," requests left today"]}):null,renderSubmitShortcut:()=>bt(Sd,{}),renderBottomRight:()=>{if(typeof i?.generatedResponse=="string")return Ir("div",{className:"excalidraw-link",style:{marginLeft:"auto",fontSize:14},onClick:()=>{typeof i?.generatedResponse=="string"&&(dl(i.generatedResponse),r({openDialog:{name:"ttd",tab:"mermaid"}}))},children:["View as Mermaid",bt(rr,{icon:Rn})]});let S=c.length/Bi;return S>.8?Ir("div",{style:{marginLeft:"auto",fontSize:12,fontFamily:"monospace",color:S>1?"var(--color-danger)":void 0},children:["Length: ",c.length,"/",Bi]}):null},children:bt(vd,{onChange:d,input:l,placeholder:"Describe what you want to see...",onKeyboardSubmit:()=>{x.current()}})}),bt(Ni,{label:"Preview",panelAction:{action:()=>{console.info("Panel action clicked"),Md({app:t,data:y})},label:"Insert",icon:Rn},children:bt(Id,{canvasRef:n,error:v,loaded:w.loaded})})]})]})]})})});import{round as V5}from"@excalidraw/math";import XF from"clsx";import KF from"lodash.throttle";import{useEffect as X5,useMemo as Fg,useState as ZF,memo as $F}from"react";import{STATS_PANELS as zd}from"@excalidraw/common";import{getCommonBounds as jF}from"@excalidraw/element";import{getUncroppedWidthAndHeight as qF}from"@excalidraw/element";import{isElbowArrow as JF,isImageElement as Og}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as QF}from"@excalidraw/element";import{elementsAreInSameGroup as eO}from"@excalidraw/element";import{degreesToRadians as p5,radiansToDegrees as f5}from"@excalidraw/math";import{getBoundTextElement as u5}from"@excalidraw/element";import{isArrowElement as h5,isElbowArrow as VB}from"@excalidraw/element";import{updateBindings as g5}from"@excalidraw/element";import zB from"clsx";import{useEffect as d5,useRef as _d,useState as HB}from"react";import{EVENT as zi,KEYS as GB,cloneJSON as Ig}from"@excalidraw/common";import{deepCopyElement as UB}from"@excalidraw/element";import{CaptureUpdateAction as m5}from"@excalidraw/element";import{pointFrom as Cr,pointRotateRads as Dd}from"@excalidraw/math";import{getBoundTextElement as RB}from"@excalidraw/element";import{isFrameLikeElement as s5}from"@excalidraw/element";import{getSelectedGroupIds as NB,getElementsInGroup as BB,isInGroup as FB}from"@excalidraw/element";import{getFrameChildren as OB}from"@excalidraw/element";import{updateBindings as l5}from"@excalidraw/element";var c5=.01,ml=10,Mt=(e,o)=>!(o==="angle"&&s5(e)),ke=(e,o)=>{let t=e+o/2;return t-t%o},Fi=(e,o,t)=>Object.keys(e).map(r=>({original:(t??o).get(r),latest:o.get(r)})).filter(r=>r.original!==void 0&&r.latest!==void 0);var nn=(e,o,t,r,n,i=!0)=>{let a=r.getNonDeletedElementsMap(),l=a.get(t.id);if(!l)return;let[s,c]=[t.x+t.width/2,t.y+t.height/2],[d,m]=Dd(Cr(t.x,t.y),Cr(s,c),t.angle),p=e-d,u=o-m,[f,b]=Dd(Cr(e,o),Cr(s+p,c+u),-t.angle);r.mutateElement(l,{x:f,y:b},{informMutation:i,isDragging:!1}),l5(l,r);let x=RB(t,n);if(x){let w=a.get(x.id);w&&r.mutateElement(w,{x:x.x+p,y:x.y+u},{informMutation:i,isDragging:!1})}if(s5(t)){let w=OB(n,t.id);w.forEach(E=>{let y=a.get(E.id);if(!y)return;let[v,C]=[E.x+E.width/2,E.y+E.height/2],[S,L]=Dd(Cr(E.x,E.y),Cr(v,C),E.angle),k=Math.round(S+p),A=Math.round(L+u),[P,B]=Dd(Cr(k,A),Cr(v+p,C+u),-E.angle);r.mutateElement(y,{x:P,y:B},{informMutation:i,isDragging:!1}),l5(y,r,{simultaneouslyUpdated:w})})}},Oi=(e,o)=>{let r=NB(o).map(n=>BB(e,n).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(n=>!FB(n)).forEach(n=>{r.push({[n.id]:!0})}),r};import{jsx as Cg,jsxs as WB}from"react/jsx-runtime";var YB=({label:e,icon:o,dragInputCallback:t,value:r,elements:n,editable:i=!0,shouldKeepAspectRatio:a,property:l,scene:s,appState:c,sensitivity:d=1,dragFinishedCallback:m})=>{let p=Re(),u=le(),f=_d(null),b=_d(null),[x,w]=HB(r.toString()),E=_d(null);E.current||(E.current={originalAppState:Ig(c),originalElements:n,lastUpdatedValue:x,updatePending:!1}),d5(()=>{let C=r.toString();w(C),E.current.lastUpdatedValue=C},[r]);let y=(C,S,L)=>{if(!E.current.updatePending)return!1;E.current.updatePending=!1;let k=Number(C);if(isNaN(k)){w(r.toString());return}let A=Number(k.toFixed(2)),P=Number(r);(isNaN(P)||Math.abs(A-P)>=c5)&&(E.current.lastUpdatedValue=C,t({accumulatedChange:0,instantChange:0,originalElements:S,originalElementsMap:p.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:s,nextValue:A,property:l,originalAppState:L,setInputValue:B=>w(String(B)),app:p,setAppState:u}),p.syncActionResult({captureUpdate:m5.IMMEDIATELY}))},v=_d({});return v.current.handleInputValue=y,d5(()=>{let C=f.current,S=v.current;return()=>{let L=C?.value;L&&S.handleInputValue?.(L,E.current.originalElements,E.current.originalAppState),window.removeEventListener(zi.POINTER_MOVE,S.onPointerMove,!1),window.removeEventListener(zi.POINTER_UP,S.onPointerUp,!1)}},[i]),i?WB("div",{className:zB("drag-input-container",!i&&"disabled"),"data-testid":e,children:[Cg("div",{className:"drag-input-label",ref:b,onPointerDown:C=>{if(f.current&&i){document.body.classList.add("excalidraw-cursor-resize");let S=Number(f.current.value);isNaN(S)&&(S=0);let L=null,k=p.scene.getNonDeletedElements().reduce((_,R)=>(_.set(R.id,UB(R)),_),new Map),A=n.map(_=>k.get(_.id)),P=Ig(c),B=0,O=0,G=_=>{if(L&&k!==null&&A!==null){let R=_.clientX-L.x;R!==0&&(O+=R,Math.abs(O)>=d&&(O=Math.sign(O)*Math.floor(Math.abs(O)/d),B+=O,t({accumulatedChange:B,instantChange:O,originalElements:A,originalElementsMap:k,shouldKeepAspectRatio:a,shouldChangeByStepSize:_.shiftKey,property:l,scene:s,originalAppState:P,setInputValue:X=>w(String(X)),app:p,setAppState:u}),O=0))}L={x:_.clientX,y:_.clientY}},J=()=>{window.removeEventListener(zi.POINTER_MOVE,G,!1),p.syncActionResult({captureUpdate:m5.IMMEDIATELY}),m?.({app:p,setAppState:u,originalElements:A,originalAppState:P}),L=null,B=0,O=0,A=null,k=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(zi.POINTER_UP,J,!1)};v.current.onPointerMove=G,v.current.onPointerUp=J,window.addEventListener(zi.POINTER_MOVE,G,!1),window.addEventListener(zi.POINTER_UP,J,!1)}},onPointerEnter:()=>{b.current&&(b.current.style.cursor="ew-resize")},children:o?Cg(rr,{icon:o}):e}),Cg("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:C=>{if(i){let S=C.target;S instanceof HTMLInputElement&&C.key===GB.ENTER&&(y(S.value,n,c),p.focusContainer())}},ref:f,value:x,onChange:C=>{E.current.updatePending=!0,w(C.target.value)},onFocus:C=>{C.target.select(),E.current.originalElements=n,E.current.originalAppState=Ig(c)},onBlur:C=>{x?i&&y(C.target.value,E.current.originalElements,E.current.originalAppState):w(r.toString())},disabled:!i})]}):null},Je=YB;import{jsx as $B}from"react/jsx-runtime";var XB=15,KB=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=o[0];if(a&&!VB(a)){let l=i.get(a.id);if(!l)return;if(r!==void 0){let u=p5(r);n.mutateElement(l,{angle:u}),g5(l,n);let f=u5(l,i);f&&!h5(l)&&n.mutateElement(f,{angle:u});return}let s=Math.round(f5(a.angle)*100)/100,c=Math.round(e),d=(s+c)%360;t&&(d=ke(d,XB)),d=d<0?d+360:d;let m=p5(d);n.mutateElement(l,{angle:m}),g5(l,n);let p=u5(l,i);p&&!h5(l)&&n.mutateElement(p,{angle:m})}},ZB=({element:e,scene:o,appState:t,property:r})=>$B(Je,{label:"A",icon:Ql,value:Math.round(f5(e.angle)%360*100)/100,elements:[e],dragInputCallback:KB,editable:Mt(e,"angle"),scene:o,appState:t,property:r}),b5=ZB;import{jsx as qB}from"react/jsx-runtime";var x5=5,jB=({property:e,scene:o,appState:t,setAppState:r})=>qB(Je,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:n,instantChange:i,shouldChangeByStepSize:a,setInputValue:l})=>{r(s=>{let c;return n?c=n:i&&(c=a?ke(s.gridStep+x5*Math.sign(i),x5):s.gridStep+i),c?(c=jf(c),l(c),{gridStep:c}):(l(s.gridStep),null)})},scene:o,value:t.gridStep,property:e,appState:t}),E5=jB;import{clamp as Rd,round as Sg}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as Nd}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as y5,getUncroppedWidthAndHeight as T5}from"@excalidraw/element";import{resizeSingleElement as w5}from"@excalidraw/element";import{isImageElement as I5}from"@excalidraw/element";import{isFrameLikeElement as kg}from"@excalidraw/element";import{getElementsInResizingFrame as Mg}from"@excalidraw/element";import{replaceAllElementsInFrame as C5}from"@excalidraw/element";import{jsx as oF}from"react/jsx-runtime";var v5=10,JB=e=>e.type==="image",QB=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldKeepAspectRatio:r,shouldChangeByStepSize:n,nextValue:i,property:a,originalAppState:l,instantChange:s,scene:c,app:d,setAppState:m})=>{let p=c.getNonDeletedElementsMap(),u=o[0],f=p.get(u.id);if(u&&f){let b=r||JB(u),x=u.width/u.height;if(l.croppingElementId===u.id){let w=p.get(u.id);if(!w||!I5(w)||!w.crop)return;let E=w.crop,y={...E},v=w.scale[0]===-1,C=w.scale[1]===-1,{width:S,height:L}=T5(w),k=E.naturalWidth/S,A=E.naturalHeight/L,P=v?E.width+E.x:E.naturalWidth-E.x,B=C?E.height+E.y:E.naturalHeight-E.y,O=y5*k,G=y5*A;if(i!==void 0){if(a==="width"){let Z=i*k,Y=Rd(Z,O,P);y={...y,width:Y,x:v?E.x+E.width-Y:E.x}}else if(a==="height"){let Z=i*A,Y=Rd(Z,G,B);y={...y,height:Y,y:C?E.y+E.height-Y:E.y}}c.mutateElement(w,{crop:y,width:y.width/(E.naturalWidth/S),height:y.height/(E.naturalHeight/L)});return}let J=a==="width"?s:0,_=a==="height"?s:0,R=Rd(E.width+J,O,P),X=Rd(E.height+_,O,B);y={...E,x:v?E.x+E.width-R:E.x,y:C?E.y+E.height-X:E.y,width:R,height:X},c.mutateElement(w,{crop:y,width:y.width/(E.naturalWidth/S),height:y.height/(E.naturalHeight/L)});return}if(i!==void 0){let w=Math.max(a==="width"?i:b?i*x:u.width,Nd),E=Math.max(a==="height"?i:b?i/x:u.height,Nd);if(w5(w,E,f,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),kg(f)){let y=Mg(c.getElementsIncludingDeleted(),f,l,c.getNonDeletedElementsMap()),v=C5(c.getElementsIncludingDeleted(),y,f,d);c.replaceAllElements(v)}return}{let w=a==="width"?e:0,E=a==="height"?e:0,y=Math.max(0,u.width+w);a==="width"&&(n?y=ke(y,v5):y=Math.round(y));let v=Math.max(0,u.height+E);if(a==="height"&&(n?v=ke(v,v5):v=Math.round(v)),b&&(a==="width"?v=Math.round(y/x*100)/100:y=Math.round(v*x*100)/100),v=Math.max(Nd,v),y=Math.max(Nd,y),w5(y,v,f,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),kg(f)){let C=Mg(c.getElementsIncludingDeleted(),f,l,c.getNonDeletedElementsMap());m({elementsToHighlight:C})}}}},eF=({setAppState:e,app:o,originalElements:t,originalAppState:r})=>{let n=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&n.get(i.id);if(a&&kg(a)){let l=Mg(o.scene.getElementsIncludingDeleted(),a,r,o.scene.getNonDeletedElementsMap()),s=C5(o.scene.getElementsIncludingDeleted(),l,a,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},tF=({property:e,element:o,scene:t,appState:r})=>{let n=Sg(e==="width"?o.width:o.height,2);if(r.croppingElementId&&r.croppingElementId===o.id&&I5(o)&&o.crop){let{width:i,height:a}=T5(o);if(e==="width"){let l=i/o.crop.naturalWidth;n=Sg(o.crop.width*l,2)}if(e==="height"){let l=a/o.crop.naturalHeight;n=Sg(o.crop.height*l,2)}}return oF(Je,{label:e==="width"?"W":"H",elements:[o],dragInputCallback:QB,value:n,editable:Mt(o,e),scene:t,appState:r,property:e,dragFinishedCallback:eF})},Lg=tF;import{getBoundTextElement as rF,redrawTextBoundingBox as nF}from"@excalidraw/element";import{hasBoundTextElement as iF,isTextElement as k5}from"@excalidraw/element";import{jsx as cF}from"react/jsx-runtime";var S5=4,aF=4,lF=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=o[0];if(a){let l=i.get(a.id);if(!l||!k5(l))return;let s;if(r!==void 0)s=Math.max(Math.round(r),S5);else if(a.type==="text"){let c=Math.round(a.fontSize),d=Math.round(e);s=Math.max(c+d,S5),t&&(s=ke(s,aF))}s&&(n.mutateElement(l,{fontSize:s}),nF(l,n.getContainerElement(l),n))}},sF=({element:e,scene:o,appState:t,property:r})=>{let n=k5(e)?e:iF(e)?rF(e,o.getNonDeletedElementsMap()):null;return n?cF(Je,{label:"F",value:Math.round(n.fontSize*10)/10,elements:[n],dragInputCallback:lF,icon:Hr,appState:t,scene:o,property:r}):null},M5=sF;import{degreesToRadians as L5,radiansToDegrees as D5}from"@excalidraw/math";import{getBoundTextElement as P5}from"@excalidraw/element";import{isArrowElement as A5}from"@excalidraw/element";import{isInGroup as Pg}from"@excalidraw/element";import{jsx as uF}from"react/jsx-runtime";var dF=15,mF=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,property:n,scene:i})=>{let a=i.getNonDeletedElementsMap(),l=o.map(c=>a.get(c.id)).filter(c=>c&&!Pg(c)&&Mt(c,n)),s=o.filter(c=>!Pg(c)&&Mt(c,n));if(r!==void 0){let c=L5(r);for(let d of l){if(!d)continue;i.mutateElement(d,{angle:c});let m=P5(d,a);m&&!A5(d)&&i.mutateElement(m,{angle:c})}i.triggerUpdate();return}for(let c=0;c<l.length;c++){let d=l[c];if(!d)continue;let m=s[c],p=Math.round(D5(m.angle)*100)/100,u=Math.round(e),f=(p+u)%360;t&&(f=ke(f,dF)),f=f<0?f+360:f;let b=L5(f);i.mutateElement(d,{angle:b});let x=P5(d,a);x&&!A5(d)&&i.mutateElement(x,{angle:b})}i.triggerUpdate()},pF=({elements:e,scene:o,appState:t,property:r})=>{let n=e.filter(s=>!Pg(s)&&Mt(s,"angle")),i=n.map(s=>Math.round(D5(s.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",l=n.some(s=>Mt(s,"angle"));return uF(Je,{label:"A",icon:Ql,value:a,elements:e,dragInputCallback:mF,editable:l,appState:t,scene:o,property:r})},_5=pF;import{pointFrom as R5}from"@excalidraw/math";import{useMemo as hF}from"react";import{MIN_WIDTH_OR_HEIGHT as Sr}from"@excalidraw/common";import{getElementsInResizingFrame as Ag,isFrameLikeElement as Dg,replaceAllElementsInFrame as F5,updateBoundElements as gF}from"@excalidraw/element";import{rescalePointsInElement as fF,resizeSingleElement as N5}from"@excalidraw/element";import{getBoundTextElement as bF,handleBindTextResize as xF}from"@excalidraw/element";import{isTextElement as O5}from"@excalidraw/element";import{getCommonBounds as Bd}from"@excalidraw/element";import{jsx as IF}from"react/jsx-runtime";var Hi=10,EF=(e,o,t,r)=>{let n=r.x-e,i=r.y-o,a=r.width*t,l=r.height*t,s=e+n*t,c=o+i*t;return{width:a,height:l,x:s,y:c,...fF(r,a,l,!1),...O5(r)?{fontSize:r.fontSize*t}:{}}},yF=(e,o,t,r,n,i,a,l)=>{let s=l.getNonDeletedElementsMap(),c=EF(e,o,r,i);l.mutateElement(n,c);let d=bF(i,a);if(d){let m=d.fontSize*r;gF(n,l,{newSize:{width:c.width,height:c.height}});let p=s.get(d.id);p&&O5(p)&&(l.mutateElement(p,{fontSize:m}),xF(n,l,t==="width"?"e":"s",!0))}},B5=(e,o,t,r,n,i,a,l,s,c)=>{i==="width"?o=Math.round(e/r*100)/100:e=Math.round(o*r*100)/100;let d=o/t;for(let m=0;m<l.length;m++){let p=l[m],u=a[m];yF(n[0],n[1],i,d,u,p,s,c)}},wF=({accumulatedChange:e,originalElements:o,originalElementsMap:t,originalAppState:r,shouldChangeByStepSize:n,nextValue:i,scene:a,property:l,setAppState:s,app:c})=>{let d=a.getNonDeletedElementsMap(),m=Oi(o,r);if(i!==void 0){for(let b of m){let x=Fi(b,d,t);if(x.length>1){let w=x.map(O=>O.latest),E=x.map(O=>O.original),[y,v,C,S]=Bd(E),L=C-y,k=S-v,A=L/k,P=Math.max(Sr,l==="width"?Math.max(0,i):L),B=Math.max(Sr,l==="height"?Math.max(0,i):k);B5(P,B,k,A,R5(y,v),l,w,E,t,a)}else{let[w]=x,E=w?.latest,y=w?.original;if(E&&y&&Mt(E,l)){let v=l==="width"?Math.max(0,i):E.width;l==="width"&&(n?v=ke(v,Hi):v=Math.round(v));let C=l==="height"?Math.max(0,i):E.height;if(l==="height"&&(n?C=ke(C,Hi):C=Math.round(C)),v=Math.max(Sr,v),C=Math.max(Sr,C),N5(v,C,E,y,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),Dg(E)){let S=Ag(a.getElementsIncludingDeleted(),E,r,a.getNonDeletedElementsMap()),L=F5(a.getElementsIncludingDeleted(),S,E,c);a.replaceAllElements(L)}}}}a.triggerUpdate();return}let p=l==="width"?e:0,u=l==="height"?e:0,f=[];for(let b of m){let x=Fi(b,d,t);if(x.length>1){let w=x.map(O=>O.latest),E=x.map(O=>O.original),[y,v,C,S]=Bd(E),L=C-y,k=S-v,A=L/k,P=Math.max(0,L+p);l==="width"&&(n?P=ke(P,Hi):P=Math.round(P));let B=Math.max(0,k+u);l==="height"&&(n?B=ke(B,Hi):B=Math.round(B)),P=Math.max(Sr,P),B=Math.max(Sr,B),B5(P,B,k,A,R5(y,v),l,w,E,t,a)}else{let[w]=x,E=w?.latest,y=w?.original;if(E&&y&&Mt(E,l)){let v=Math.max(0,y.width+p);l==="width"&&(n?v=ke(v,Hi):v=Math.round(v));let C=Math.max(0,y.height+u);if(l==="height"&&(n?C=ke(C,Hi):C=Math.round(C)),v=Math.max(Sr,v),C=Math.max(Sr,C),N5(v,C,E,y,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),Dg(E)){let S=Ag(a.getElementsIncludingDeleted(),E,r,a.getNonDeletedElementsMap());f.push(...S)}}}}s({elementsToHighlight:f}),a.triggerUpdate()},vF=({setAppState:e,app:o,originalElements:t,originalAppState:r})=>{let n=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&n.get(i.id);if(a&&Dg(a)){let l=Ag(o.scene.getElementsIncludingDeleted(),a,r,o.scene.getNonDeletedElementsMap()),s=F5(o.scene.getElementsIncludingDeleted(),l,a,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},TF=({property:e,elements:o,elementsMap:t,atomicUnits:r,scene:n,appState:i})=>{let a=hF(()=>r.map(c=>{let d=Fi(c,t);if(d.length>1){let[p,u,f,b]=Bd(d.map(x=>x.latest));return Math.round((e==="width"?f-p:b-u)*100)/100}let[m]=d;return Math.round((e==="width"?m.latest.width:m.latest.height)*100)/100}),[t,r,e]),l=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",s=a.length>0;return IF(Je,{label:e==="width"?"W":"H",elements:o,dragInputCallback:wF,value:l,editable:s,appState:i,property:e,scene:n,dragFinishedCallback:vF})},_g=TF;import{getBoundTextElement as CF,redrawTextBoundingBox as z5}from"@excalidraw/element";import{hasBoundTextElement as SF,isTextElement as kF}from"@excalidraw/element";import{isInGroup as MF}from"@excalidraw/element";import{jsx as _F}from"react/jsx-runtime";var H5=4,LF=4,PF=(e,o)=>e.reduce((t,r)=>{if(!r||MF(r))return t;if(kF(r))return t.push(r),t;if(SF(r)){let n=CF(r,o);if(n)return t.push(n),t}return t},[]),AF=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=o.map(s=>i.get(s.id)),l;if(r){l=Math.max(Math.round(r),H5);for(let s of a)n.mutateElement(s,{fontSize:l}),z5(s,n.getContainerElement(s),n);n.triggerUpdate()}else{let s=o;for(let c=0;c<a.length;c++){let d=a[c],m=s[c],p=Math.round(m.fontSize),u=Math.round(e),f=Math.max(p+u,H5);t&&(f=ke(f,LF)),n.mutateElement(d,{fontSize:f}),z5(d,n.getContainerElement(d),n)}n.triggerUpdate()}},DF=({elements:e,scene:o,appState:t,property:r,elementsMap:n})=>{let i=PF(e,n);if(!i.length)return null;let a=i.map(c=>Math.round(c.fontSize*10)/10),l=new Set(a).size===1?a[0]:"Mixed",s=a.length>0;return _F(Je,{label:"F",icon:Hr,elements:i,dragInputCallback:AF,value:l,editable:s,scene:o,property:r,appState:t})},G5=DF;import{pointFrom as kr,pointRotateRads as Fd}from"@excalidraw/math";import{useMemo as RF}from"react";import{isTextElement as NF}from"@excalidraw/element";import{getCommonBounds as Rg}from"@excalidraw/element";import{jsx as HF}from"react/jsx-runtime";var BF=(e,o,t,r,n,i)=>{for(let a=0;a<r.length;a++){let l=r[a],[s,c]=[l.x+l.width/2,l.y+l.height/2],[d,m]=Fd(kr(l.x,l.y),kr(s,c),l.angle),p=e==="x"?Math.round(d+o):d,u=e==="y"?Math.round(m+t):m;nn(p,u,l,i,n,!1)}},FF=(e,o,t,r,n)=>{let i=n.getNonDeletedElementsMap(),[a,l,,]=Rg(t),s=e-a,c=o-l;for(let d=0;d<t.length;d++){let m=t[d],p=i.get(m.id);if(p&&(!NF(p)||!p.containerId)){let[u,f]=[p.x+p.width/2,p.y+p.height/2],[b,x]=Fd(kr(p.x,p.y),kr(u,f),p.angle);nn(b+s,x+c,m,n,r,!1)}}},OF=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldChangeByStepSize:r,nextValue:n,property:i,scene:a,originalAppState:l})=>{let s=a.getNonDeletedElementsMap();if(n!==void 0){for(let p of Oi(o,l)){let u=Fi(p,s,t);if(u.length>1){let[f,b,,]=Rg(u.map(E=>E.latest));FF(i==="x"?n:f,i==="y"?n:b,u.map(E=>E.original),t,a)}else{let f=u[0]?.original,b=u[0]?.latest;if(f&&b&&Mt(b,i)){let[x,w]=[f.x+f.width/2,f.y+f.height/2],[E,y]=Fd(kr(f.x,f.y),kr(x,w),f.angle);nn(i==="x"?n:E,i==="y"?n:y,f,a,t,!1)}}}a.triggerUpdate();return}let c=r?ke(e,ml):e;BF(i,i==="x"?c:0,i==="y"?c:0,o,t,a),a.triggerUpdate()},zF=({property:e,elements:o,elementsMap:t,atomicUnits:r,scene:n,appState:i})=>{let a=RF(()=>r.map(s=>{let c=Object.keys(s).map(b=>t.get(b)).filter(b=>b!==void 0);if(c.length>1){let[b,x]=Rg(c);return Math.round((e==="x"?b:x)*100)/100}let[d]=c,[m,p]=[d.x+d.width/2,d.y+d.height/2],[u,f]=Fd(kr(d.x,d.y),kr(m,p),d.angle);return Math.round((e==="x"?u:f)*100)/100}),[r,t,e]),l=new Set(a).size===1?a[0]:"Mixed";return HF(Je,{label:e==="x"?"X":"Y",elements:o,dragInputCallback:OF,value:l,property:e,scene:n,appState:i})},Ng=zF;import{clamp as pl,pointFrom as Od,pointRotateRads as Y5,round as U5}from"@excalidraw/math";import{getFlipAdjustedCropPosition as GF,getUncroppedWidthAndHeight as UF}from"@excalidraw/element";import{isImageElement as W5}from"@excalidraw/element";import{jsx as VF}from"react/jsx-runtime";var YF=({accumulatedChange:e,instantChange:o,originalElements:t,originalElementsMap:r,shouldChangeByStepSize:n,nextValue:i,property:a,scene:l,originalAppState:s})=>{let c=l.getNonDeletedElementsMap(),d=t[0],[m,p]=[d.x+d.width/2,d.y+d.height/2],[u,f]=Y5(Od(d.x,d.y),Od(m,p),d.angle);if(s.croppingElementId===d.id){let y=c.get(d.id);if(!y||!W5(y)||!y.crop)return;let v=y.crop,C=v,S=y.scale[0]===-1,L=y.scale[1]===-1,{width:k,height:A}=UF(y);if(i!==void 0){if(a==="x"){let O=i*(v.naturalWidth/k);S?C={...v,x:pl(v.naturalWidth-O-v.width,0,v.naturalWidth-v.width)}:C={...v,x:pl(i*(v.naturalWidth/k),0,v.naturalWidth-v.width)}}a==="y"&&(C={...v,y:pl(i*(v.naturalHeight/A),0,v.naturalHeight-v.height)}),l.mutateElement(y,{crop:C});return}let P=(a==="x"?o:0)*(S?-1:1),B=(a==="y"?o:0)*(L?-1:1);C={...v,x:pl(v.x+P,0,v.naturalWidth-v.width),y:pl(v.y+B,0,v.naturalHeight-v.height)},l.mutateElement(y,{crop:C});return}if(i!==void 0){nn(a==="x"?i:u,a==="y"?i:f,d,l,r);return}let b=a==="x"?e:0,x=a==="y"?e:0,w=a==="x"?Math.round(n?ke(d.x+b,ml):u+b):u,E=a==="y"?Math.round(n?ke(d.y+x,ml):f+x):f;nn(w,E,d,l,r)},WF=({property:e,element:o,elementsMap:t,scene:r,appState:n})=>{let[i,a]=Y5(Od(o.x,o.y),Od(o.x+o.width/2,o.y+o.height/2),o.angle),l=U5(e==="x"?i:a,2);if(n.croppingElementId===o.id&&W5(o)&&o.crop){let s=GF(o);s&&(l=U5(e==="x"?s.x:s.y,2))}return VF(Je,{label:e==="x"?"X":"Y",elements:[o],dragInputCallback:YF,scene:r,value:l,property:e,appState:n})},Bg=WF;import{Fragment as zg,jsx as j,jsxs as Lt}from"react/jsx-runtime";var tO=50,ul=e=>{let o=go(),t=e.app.scene.getSceneNonce()||1,r=e.app.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}),n=fr(e.app);return j(oO,{...e,appState:o,sceneNonce:t,selectedElements:r,gridModeEnabled:n})},ve=({children:e,columns:o=1,heading:t,style:r,...n})=>j("div",{className:XF("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${o}, 1fr)`,...r},...n,children:e});ve.displayName="StatsRow";var Hd=({children:e,order:o,style:t,...r})=>j("div",{className:"exc-stats__rows",style:{order:o,...t},...r,children:e});Hd.displayName="StatsRows";ul.StatsRow=ve;ul.StatsRows=Hd;var oO=$F(({app:e,onClose:o,renderCustomStats:t,selectedElements:r,appState:n,sceneNonce:i,gridModeEnabled:a})=>{let l=e.scene,s=l.getNonDeletedElements(),c=l.getNonDeletedElementsMap(),d=le(),m=r.length===1?r[0]:null,p=r.length>1?r:null,u=n.croppingElementId&&Og(m),f=u?qF(m):null,[b,x]=ZF({width:0,height:0}),w=Fg(()=>KF(v=>{let C=jF(v);x({width:Math.round(C[2])-Math.round(C[0]),height:Math.round(C[3])-Math.round(C[1])})},tO),[]);X5(()=>{w(s)},[i,s,w]),X5(()=>()=>w.cancel(),[w]);let E=Fg(()=>Oi(r,n),[r,n]),y=Fg(()=>QF(r),[r]);return j("div",{className:"exc-stats",children:Lt(We,{padding:3,children:[Lt("div",{className:"title",children:[j("h2",{children:g("stats.title")}),j("div",{className:"close",onClick:o,children:Ft})]}),Lt(ya,{label:j("h3",{children:g("stats.generalStats")}),open:!!(n.stats.panels&zd.generalStats),openTrigger:()=>d(v=>({stats:{open:!0,panels:v.stats.panels^zd.generalStats}})),children:[Lt(Hd,{children:[j(ve,{heading:!0,children:g("stats.scene")}),Lt(ve,{columns:2,children:[j("div",{children:g("stats.shapes")}),j("div",{children:s.length})]}),Lt(ve,{columns:2,children:[j("div",{children:g("stats.width")}),j("div",{children:b.width})]}),Lt(ve,{columns:2,children:[j("div",{children:g("stats.height")}),j("div",{children:b.height})]}),a&&Lt(zg,{children:[j(ve,{heading:!0,children:"Canvas"}),j(ve,{children:j(E5,{property:"gridStep",scene:l,appState:n,setAppState:d})})]})]}),t?.(s,n)]}),!y&&r.length>0&&j("div",{id:"elementStats",style:{marginTop:12},children:j(ya,{label:j("h3",{children:g("stats.elementProperties")}),open:!!(n.stats.panels&zd.elementProperties),openTrigger:()=>d(v=>({stats:{open:!0,panels:v.stats.panels^zd.elementProperties}})),children:Lt(Hd,{children:[m&&Lt(zg,{children:[u&&j(ve,{heading:!0,children:g("labels.unCroppedDimension")}),n.croppingElementId&&Og(m)&&f&&Lt(ve,{columns:2,children:[j("div",{children:g("stats.width")}),j("div",{children:V5(f.width,2)})]}),n.croppingElementId&&Og(m)&&f&&Lt(ve,{columns:2,children:[j("div",{children:g("stats.height")}),j("div",{children:V5(f.height,2)})]}),j(ve,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:n.croppingElementId?g("labels.imageCropping"):g(`element.${m.type}`)}),j(ve,{children:j(Bg,{element:m,property:"x",elementsMap:c,scene:l,appState:n})}),j(ve,{children:j(Bg,{element:m,property:"y",elementsMap:c,scene:l,appState:n})}),j(ve,{children:j(Lg,{property:"width",element:m,scene:l,appState:n})}),j(ve,{children:j(Lg,{property:"height",element:m,scene:l,appState:n})}),!JF(m)&&j(ve,{children:j(b5,{property:"angle",element:m,scene:l,appState:n})}),j(ve,{children:j(M5,{property:"fontSize",element:m,scene:l,appState:n})})]}),p&&Lt(zg,{children:[eO(p)&&j(ve,{heading:!0,children:g("element.group")}),Lt(ve,{columns:2,style:{margin:"0.3125rem 0"},children:[j("div",{children:g("stats.shapes")}),j("div",{children:r.length})]}),j(ve,{children:j(Ng,{property:"x",elements:p,elementsMap:c,atomicUnits:E,scene:l,appState:n})}),j(ve,{children:j(Ng,{property:"y",elements:p,elementsMap:c,atomicUnits:E,scene:l,appState:n})}),j(ve,{children:j(_g,{property:"width",elements:p,elementsMap:c,atomicUnits:E,scene:l,appState:n})}),j(ve,{children:j(_g,{property:"height",elements:p,elementsMap:c,atomicUnits:E,scene:l,appState:n})}),j(ve,{children:j(_5,{property:"angle",elements:p,scene:l,appState:n})}),j(ve,{children:j(G5,{property:"fontSize",elements:p,scene:l,appState:n,elementsMap:c})})]})]})})})]})})},(e,o)=>e.sceneNonce===o.sceneNonce&&e.selectedElements===o.selectedElements&&e.appState.stats.panels===o.appState.stats.panels&&e.gridModeEnabled===o.gridModeEnabled&&e.appState.gridStep===o.appState.gridStep&&e.appState.croppingElementId===o.appState.croppingElementId);import{useCallback as rO,useEffect as K5,useState as Z5}from"react";import{normalizeLink as nO,KEYS as Hg}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as iO,getLinkIdAndTypeFromSelection as aO}from"@excalidraw/element";import{jsx as Gi,jsxs as Gd}from"react/jsx-runtime";var lO=({sourceElementId:e,onClose:o,appState:t,scene:r,generateLinkForSelection:n=iO})=>{let i=r.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[l,s]=Z5(a),[c,d]=Z5(!1);K5(()=>{let p=$(i,t),u=a;if(p.length>0&&n){let f=aO(p,t);f&&(u=nO(n(f.id,f.type)))}s(u)},[i,t,t.selectedElementIds,a,n]);let m=rO(()=>{if(l&&l!==i.get(e)?.link){let p=i.get(e);p&&r.mutateElement(p,{link:l})}if(!l&&c&&e){let p=i.get(e);p&&r.mutateElement(p,{link:null})}o?.()},[e,l,i,c,r,o]);return K5(()=>{let p=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===Hg.ENTER&&m(),t.openDialog?.name==="elementLinkSelector"&&u.key===Hg.ESCAPE&&o?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[t,o,m]),Gd("div",{className:"ElementLinkDialog",children:[Gd("div",{className:"ElementLinkDialog__header",children:[Gi("h2",{children:g("elementLink.title")}),Gi("p",{children:g("elementLink.desc")})]}),Gd("div",{className:"ElementLinkDialog__input",children:[Gi(Ei,{value:l??"",onChange:p=>{c||d(!0),s(p)},onKeyDown:p=>{p.key===Hg.ENTER&&m()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&l&&Gi(W,{type:"button",title:g("buttons.remove"),"aria-label":g("buttons.remove"),label:g("buttons.remove"),onClick:()=>{s(null),d(!0)},className:"ElementLinkDialog__remove",icon:Do})]}),Gd("div",{className:"ElementLinkDialog__actions",children:[Gi(Oo,{label:g("buttons.cancel"),onClick:()=>{o?.()},style:{marginRight:10}}),Gi(Oo,{label:g("buttons.confirm"),onClick:m,actionType:"primary"})]})]})},$5=lO;import sO,{useState as cO}from"react";import{Fragment as dO,jsx as Gg}from"react/jsx-runtime";var j5=({children:e,onClose:o})=>{let[t,r]=cO(!!e),{container:n}=ze(),i=sO.useCallback(()=>{r(!1),o&&o(),n?.focus()},[o,n]);return Gg(dO,{children:t&&Gg(Ne,{size:"small",onCloseRequest:i,title:g("errorDialog.title"),children:Gg("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import Q5,{useMemo as fO}from"react";import eT from"clsx";import{isDarwin as tT,isFirefox as oT,isWindows as bO}from"@excalidraw/common";import{KEYS as Ui,getShortcutKey as K}from"@excalidraw/common";import{SHAPES as xO}from"@excalidraw/element/shapes";import{getShortcutKey as xt,isFirefox as q5,KEYS as J5}from"@excalidraw/common";import{Fragment as gO,jsx as Te,jsxs as an}from"react/jsx-runtime";var mO=e=>an(gO,{children:[Te("h3",{children:e.title}),Te("div",{className:"HelpDialog__islands-container",children:e.children})]}),Ug=e=>an("div",{className:`HelpDialog__island ${e.className}`,children:[Te("h4",{className:"HelpDialog__island-title",children:e.caption}),Te("div",{className:"HelpDialog__island-content",children:e.children})]});function*pO(e,o){let t=!0;for(let r of e)t||(yield o),t=!1,yield r}var uO=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),Qe=({label:e,shortcuts:o,isOr:t=!0})=>{let r=o.map(n=>(n.endsWith("++")?[...n.slice(0,-2).split("+"),"+"]:n.split("+")).map(a=>Te(hO,{children:uO(a)},a)));return an("div",{className:"HelpDialog__shortcut",children:[Te("div",{children:e}),Te("div",{className:"HelpDialog__key-container",children:[...pO(r,t?g("helpDialog.or"):null)]})]})},hO=e=>Te("kbd",{className:"HelpDialog__key",...e});function Yg(){return an(mO,{title:g("helpDialog.shortcuts"),children:[an(Ug,{className:"HelpDialog__island--tools",caption:g("helpDialog.tools"),children:[Te(Qe,{label:g("toolBar.hand"),shortcuts:[J5.H]}),pr.filter(({myocSimplifiedMode:e})=>e).map(({value:e,key:o})=>Te(Qe,{label:g(`toolBar.${e}`),shortcuts:[...o]},e)),Te(Qe,{label:g("helpDialog.cropStart"),shortcuts:[g("helpDialog.doubleClick"),xt("Enter")],isOr:!0}),Te(Qe,{label:g("helpDialog.cropFinish"),shortcuts:[xt("Enter"),xt("Escape")],isOr:!0})]}),an(Ug,{className:"HelpDialog__island--view",caption:g("helpDialog.view"),children:[Te(Qe,{label:g("helpDialog.smartZoom"),shortcuts:[J5.F]}),Te(Qe,{label:g("buttons.zenMode"),shortcuts:[xt("Alt+Z")]}),Te(Qe,{label:g("buttons.objectsSnapMode"),shortcuts:[xt("Alt+S")]}),Te(Qe,{label:g("commandPalette.title"),shortcuts:q5?[Se("commandPalette")]:[Se("commandPalette"),Se("commandPalette",1)]})]}),an(Ug,{className:"HelpDialog__island--editor",caption:g("helpDialog.editor"),children:[Te(Qe,{label:g("labels.pasteAsPlaintext"),shortcuts:[xt("CtrlOrCmd+Shift+V")]}),Te(Qe,{label:g("labels.multiSelect"),shortcuts:[xt(`Shift+${g("helpDialog.click")}`)]}),Te(Qe,{label:g("helpDialog.deepSelect"),shortcuts:[xt(`CtrlOrCmd+${g("helpDialog.click")}`)]}),Te(Qe,{label:g("helpDialog.deepBoxSelect"),shortcuts:[xt(`CtrlOrCmd+${g("helpDialog.drag")}`)]}),(lr||q5)&&Te(Qe,{label:g("labels.copyAsPng"),shortcuts:[xt("Shift+Alt+C")]}),Te(Qe,{label:g("helpDialog.toggleElementLock"),shortcuts:[xt("CtrlOrCmd+Shift+L")]}),Te(Qe,{label:g("labels.group"),shortcuts:[xt("CtrlOrCmd+G")]}),Te(Qe,{label:g("labels.ungroup"),shortcuts:[xt("CtrlOrCmd+Shift+G")]}),Te(Qe,{label:g("labels.flipHorizontal"),shortcuts:[xt("Shift+H")]}),Te(Qe,{label:g("labels.flipVertical"),shortcuts:[xt("Shift+V")]})]})]})}import{Fragment as nT,jsx as H,jsxs as ln}from"react/jsx-runtime";var EO=e=>ln(nT,{children:[H("h3",{children:e.title}),H("div",{className:"HelpDialog__islands-container",children:e.children})]}),Wg=e=>ln("div",{className:`HelpDialog__island ${e.className}`,children:[H("h4",{className:"HelpDialog__island-title",children:e.caption}),H("div",{className:"HelpDialog__island-content",children:e.children})]});function*yO(e,o){let t=!0;for(let r of e)t||(yield o),t=!1,yield r}var wO=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),V=({label:e,shortcuts:o,isOr:t=!0})=>{let r=o.map(n=>(n.endsWith("++")?[...n.slice(0,-2).split("+"),"+"]:n.split("+")).map(a=>H(vO,{children:wO(a)},a)));return ln("div",{className:"HelpDialog__shortcut",children:[H("div",{children:e}),H("div",{className:"HelpDialog__key-container",children:[...yO(r,t?g("helpDialog.or"):null)]})]})},vO=e=>H("kbd",{className:"HelpDialog__key",...e}),rT=({onClose:e})=>{let[o,t]=Q5.useState(!1),r=Q5.useCallback(()=>{e&&e()},[e]),n=fO(()=>o?H("button",{className:eT("toggle-button",{}),onClick:()=>t(!1),children:g("helpDialog.myoc.showingAll")}):H("button",{className:eT("toggle-button",{}),onClick:()=>t(!0),children:g("helpDialog.myoc.showingBasic")}),[o]);return H(nT,{children:H(Ne,{onCloseRequest:r,title:g("helpDialog.title"),className:"HelpDialog",titleButton:n,children:o?ln(EO,{title:g("helpDialog.shortcuts"),children:[ln(Wg,{className:"HelpDialog__island--tools",caption:g("helpDialog.tools"),children:[H(V,{label:g("toolBar.hand"),shortcuts:[Ui.H]}),xO.map(({value:i,key:a})=>H(V,{label:g(`toolBar.${i}`),shortcuts:[...a]},i)),H(V,{label:g("toolBar.frame"),shortcuts:[Ui.F]}),H(V,{label:g("toolBar.laser"),shortcuts:[Ui.K]}),H(V,{label:g("labels.eyeDropper"),shortcuts:[Ui.I,"Shift+S","Shift+G"]}),H(V,{label:g("helpDialog.editLineArrowPoints"),shortcuts:[K("CtrlOrCmd+Enter")]}),H(V,{label:g("helpDialog.editText"),shortcuts:[K("Enter")]}),H(V,{label:g("helpDialog.textNewLine"),shortcuts:[K("Enter"),K("Shift+Enter")]}),H(V,{label:g("helpDialog.textFinish"),shortcuts:[K("Esc"),K("CtrlOrCmd+Enter")]}),H(V,{label:g("helpDialog.curvedArrow"),shortcuts:["A",g("helpDialog.click"),g("helpDialog.click"),g("helpDialog.click")],isOr:!1}),H(V,{label:g("helpDialog.curvedLine"),shortcuts:["L",g("helpDialog.click"),g("helpDialog.click"),g("helpDialog.click")],isOr:!1}),H(V,{label:g("helpDialog.cropStart"),shortcuts:[g("helpDialog.doubleClick"),K("Enter")],isOr:!0}),H(V,{label:g("helpDialog.cropFinish"),shortcuts:[K("Enter"),K("Escape")],isOr:!0}),H(V,{label:g("toolBar.lock"),shortcuts:[Ui.Q]}),H(V,{label:g("helpDialog.preventBinding"),shortcuts:[K("CtrlOrCmd")]}),H(V,{label:g("toolBar.link"),shortcuts:[K("CtrlOrCmd+K")]}),H(V,{label:g("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),ln(Wg,{className:"HelpDialog__island--view",caption:g("helpDialog.view"),children:[H(V,{label:g("helpDialog.smartZoom"),shortcuts:[Ui.F]}),H(V,{label:g("buttons.zoomIn"),shortcuts:[K("CtrlOrCmd++")]}),H(V,{label:g("buttons.zoomOut"),shortcuts:[K("CtrlOrCmd+-")]}),H(V,{label:g("buttons.resetZoom"),shortcuts:[K("CtrlOrCmd+0")]}),H(V,{label:g("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),H(V,{label:g("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),H(V,{label:g("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),H(V,{label:g("buttons.zenMode"),shortcuts:[K("Alt+Z")]}),H(V,{label:g("buttons.objectsSnapMode"),shortcuts:[K("Alt+S")]}),H(V,{label:g("labels.toggleGrid"),shortcuts:[K("CtrlOrCmd+'")]}),H(V,{label:g("labels.viewMode"),shortcuts:[K("Alt+R")]}),H(V,{label:g("stats.fullTitle"),shortcuts:[K("Alt+/")]}),H(V,{label:g("search.title"),shortcuts:[Se("searchMenu")]}),H(V,{label:g("commandPalette.title"),shortcuts:oT?[Se("commandPalette")]:[Se("commandPalette"),Se("commandPalette",1)]})]}),ln(Wg,{className:"HelpDialog__island--editor",caption:g("helpDialog.editor"),children:[H(V,{label:g("labels.moveCanvas"),shortcuts:[K(`Space+${g("helpDialog.drag")}`),K(`Wheel+${g("helpDialog.drag")}`)],isOr:!0}),H(V,{label:g("labels.delete"),shortcuts:[K("Delete")]}),H(V,{label:g("labels.cut"),shortcuts:[K("CtrlOrCmd+X")]}),H(V,{label:g("labels.copy"),shortcuts:[K("CtrlOrCmd+C")]}),H(V,{label:g("labels.paste"),shortcuts:[K("CtrlOrCmd+V")]}),H(V,{label:g("labels.pasteAsPlaintext"),shortcuts:[K("CtrlOrCmd+Shift+V")]}),H(V,{label:g("labels.selectAll"),shortcuts:[K("CtrlOrCmd+A")]}),H(V,{label:g("labels.multiSelect"),shortcuts:[K(`Shift+${g("helpDialog.click")}`)]}),H(V,{label:g("helpDialog.deepSelect"),shortcuts:[K(`CtrlOrCmd+${g("helpDialog.click")}`)]}),H(V,{label:g("helpDialog.deepBoxSelect"),shortcuts:[K(`CtrlOrCmd+${g("helpDialog.drag")}`)]}),(lr||oT)&&H(V,{label:g("labels.copyAsPng"),shortcuts:[K("Shift+Alt+C")]}),H(V,{label:g("labels.copyStyles"),shortcuts:[K("CtrlOrCmd+Alt+C")]}),H(V,{label:g("labels.pasteStyles"),shortcuts:[K("CtrlOrCmd+Alt+V")]}),H(V,{label:g("labels.sendToBack"),shortcuts:[tT?K("CtrlOrCmd+Alt+["):K("CtrlOrCmd+Shift+[")]}),H(V,{label:g("labels.bringToFront"),shortcuts:[tT?K("CtrlOrCmd+Alt+]"):K("CtrlOrCmd+Shift+]")]}),H(V,{label:g("labels.sendBackward"),shortcuts:[K("CtrlOrCmd+[")]}),H(V,{label:g("labels.bringForward"),shortcuts:[K("CtrlOrCmd+]")]}),H(V,{label:g("labels.alignTop"),shortcuts:[K("CtrlOrCmd+Shift+Up")]}),H(V,{label:g("labels.alignBottom"),shortcuts:[K("CtrlOrCmd+Shift+Down")]}),H(V,{label:g("labels.alignLeft"),shortcuts:[K("CtrlOrCmd+Shift+Left")]}),H(V,{label:g("labels.alignRight"),shortcuts:[K("CtrlOrCmd+Shift+Right")]}),H(V,{label:g("labels.arrangeElements"),shortcuts:[K("Shift+R")]}),H(V,{label:g("labels.duplicateSelection"),shortcuts:[K("CtrlOrCmd+D"),K(`Alt+${g("helpDialog.drag")}`)]}),H(V,{label:g("helpDialog.toggleElementLock"),shortcuts:[K("CtrlOrCmd+Shift+L")]}),H(V,{label:g("buttons.undo"),shortcuts:[K("CtrlOrCmd+Z")]}),H(V,{label:g("buttons.redo"),shortcuts:bO?[K("CtrlOrCmd+Y"),K("CtrlOrCmd+Shift+Z")]:[K("CtrlOrCmd+Shift+Z")]}),H(V,{label:g("labels.group"),shortcuts:[K("CtrlOrCmd+G")]}),H(V,{label:g("labels.ungroup"),shortcuts:[K("CtrlOrCmd+Shift+G")]}),H(V,{label:g("labels.flipHorizontal"),shortcuts:[K("Shift+H")]}),H(V,{label:g("labels.flipVertical"),shortcuts:[K("Shift+V")]}),H(V,{label:g("labels.showStroke"),shortcuts:[K("S")]}),H(V,{label:g("labels.showBackground"),shortcuts:[K("G")]}),H(V,{label:g("labels.showFonts"),shortcuts:[K("Shift+F")]}),H(V,{label:g("labels.decreaseFontSize"),shortcuts:[K("CtrlOrCmd+Shift+<")]}),H(V,{label:g("labels.increaseFontSize"),shortcuts:[K("CtrlOrCmd+Shift+>")]})]})]}):H(Yg,{})})})};import{useEffect as lT,useRef as MO,useState as Mr}from"react";import{DEFAULT_EXPORT_PADDING as LO,EXPORT_IMAGE_TYPES as Vg,isFirefox as PO,EXPORT_SCALES as AO,cloneJSON as sT}from"@excalidraw/common";import{useCallback as TO,useRef as IO,useState as CO}from"react";var SO=2e3,iT=()=>{let[e,o]=CO(null),t=IO(0),r=()=>{clearTimeout(t.current),o("success"),t.current=window.setTimeout(()=>{o(null)},SO)},n=TO(()=>{o(null)},[]);return{copyStatus:e,resetCopyStatus:n,onCopy:r}};import kO from"clsx";import{jsx as aT}from"react/jsx-runtime";var hl=({title:e,name:o,checked:t,onChange:r,disabled:n=!1})=>aT("div",{className:kO("Switch",{toggled:t,disabled:n}),children:aT("input",{name:o,id:o,title:e,type:"checkbox",checked:t,disabled:n,onChange:()=>r(!t),onKeyDown:i=>{i.key===" "&&r(!t)}})});import{jsx as Ie,jsxs as Lr}from"react/jsx-runtime";var DO="filter"in document.createElement("canvas").getContext("2d"),_O=()=>Lr("div",{children:[Ie("h3",{children:g("canvasError.cannotShowPreview")}),Ie("p",{children:Ie("span",{children:g("canvasError.canvasTooBig")})}),Lr("em",{children:["(",g("canvasError.canvasTooBigTip"),")"]})]}),RO=({appStateSnapshot:e,elementsSnapshot:o,files:t,actionManager:r,onExportImage:n,name:i})=>{let a=Ee(o,e),[l,s]=Mr(i),[c,d]=Mr(a),[m,p]=Mr(e.exportBackground),[u,f]=Mr(e.exportWithDarkMode),[b,x]=Mr(e.exportEmbedScene),[w,E]=Mr(e.exportScale),y=MO(null),[v,C]=Mr(null),{onCopy:S,copyStatus:L,resetCopyStatus:k}=iT();lT(()=>{k()},[l,m,u,w,b,k]);let{exportedElements:A,exportingFrame:P}=Kr(o,e,c);return lT(()=>{let B=y.current;if(!B)return;let O=B.offsetWidth,G=B.offsetHeight;O&&cr({elements:A,appState:{...e,name:l,exportBackground:m,exportWithDarkMode:u,exportScale:w,exportEmbedScene:b},files:t,exportPadding:LO,maxWidthOrHeight:Math.max(O,G),exportingFrame:P}).then(J=>(C(null),Lo(J).then(()=>{B.replaceChildren(J)}).catch(_=>{throw _.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):_}))).catch(J=>{console.error(J),C(J)})},[e,t,A,P,l,m,u,w,b]),Lr("div",{className:"ImageExportModal",children:[Ie("h3",{children:g("imageExportDialog.header")}),Lr("div",{className:"ImageExportModal__preview",children:[Ie("div",{className:"ImageExportModal__preview__canvas",ref:y,children:v&&Ie(_O,{})}),Ie("div",{className:"ImageExportModal__preview__filename",children:!xn&&Ie("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:B=>{s(B.target.value),r.executeAction(Yp,"ui",B.target.value)}})})]}),Lr("div",{className:"ImageExportModal__settings",children:[Ie("h3",{children:g("imageExportDialog.header")}),a&&Ie(gl,{label:g("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Ie(hl,{name:"exportOnlySelected",checked:c,onChange:B=>{d(B)}})}),Ie(gl,{label:g("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Ie(hl,{name:"exportBackgroundSwitch",checked:m,onChange:B=>{p(B),r.executeAction(Wp,"ui",B)}})}),DO&&Ie(gl,{label:g("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Ie(hl,{name:"exportDarkModeSwitch",checked:u,onChange:B=>{f(B),r.executeAction(qx,"ui",B)}})}),Ie(gl,{label:g("imageExportDialog.label.embedScene"),tooltip:g("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Ie(hl,{name:"exportEmbedSwitch",checked:b,onChange:B=>{x(B),r.executeAction(Xs,"ui",B)}})}),Ie(gl,{label:g("imageExportDialog.label.scale"),name:"exportScale",children:Ie(hd,{name:"exportScale",value:w,onChange:B=>{E(B),r.executeAction(jx,"ui",B)},choices:AO.map(B=>({value:B,label:`${B}\xD7`}))})}),Lr("div",{className:"ImageExportModal__settings__buttons",children:[Ie(vr,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToPng"),onClick:()=>n(Vg.png,A,{exportingFrame:P}),icon:Fm,children:g("imageExportDialog.button.exportToPng")}),Ie(vr,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToSvg"),onClick:()=>n(Vg.svg,A,{exportingFrame:P}),icon:Fm,children:g("imageExportDialog.button.exportToSvg")}),(lr||PO)&&Ie(vr,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.copyPngToClipboard"),status:L,onClick:async()=>{await n(Vg.clipboard,A,{exportingFrame:P}),S()},icon:Dn,children:g("imageExportDialog.button.copyPngToClipboard")})]})]})]})},gl=({label:e,children:o,tooltip:t,name:r})=>Lr("div",{className:"ImageExportModal__settings__setting",title:e,children:[Lr("label",{htmlFor:r,className:"ImageExportModal__settings__setting__label",children:[e,t&&Ie(it,{label:t,long:!0,children:H0})]}),Ie("div",{className:"ImageExportModal__settings__setting__content",children:o})]}),cT=({elements:e,appState:o,files:t,actionManager:r,onExportImage:n,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:l,elementsSnapshot:s}]=Mr(()=>({appStateSnapshot:sT(o),elementsSnapshot:sT(e)}));return Ie(Ne,{onCloseRequest:i,size:"wide",title:!1,children:Ie(RO,{elementsSnapshot:s,appStateSnapshot:l,files:t,actionManager:r,onExportImage:n,name:a})})};import BO from"react";import{getFrame as FO}from"@excalidraw/common";import Xg from"open-color";import{jsx as NO}from"react/jsx-runtime";var Kg=({children:e,color:o})=>NO("div",{className:"Card",style:{"--card-color":o==="primary"?"var(--color-primary)":Xg[o][7],"--card-color-darker":o==="primary"?"var(--color-primary-darker)":Xg[o][8],"--card-color-darkest":o==="primary"?"var(--color-primary-darkest)":Xg[o][9]},children:e});import{Fragment as zO,jsx as co,jsxs as Ud}from"react/jsx-runtime";var OO=({elements:e,appState:o,setAppState:t,files:r,actionManager:n,exportOpts:i,canvas:a,onCloseRequest:l})=>{let{onExportToBackend:s}=i;return co("div",{className:"ExportDialog ExportDialog--json",children:Ud("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&Ud(Kg,{color:"lime",children:[co("div",{className:"Card-icon",children:Z1}),co("h2",{children:g("exportDialog.disk_title")}),Ud("div",{className:"Card-details",children:[g("exportDialog.disk_details"),!xn&&n.renderAction("changeProjectName")]}),co(W,{className:"Card-button",type:"button",title:g("exportDialog.disk_button"),"aria-label":g("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{n.executeAction(Aa,"ui")}})]}),s&&Ud(Kg,{color:"pink",children:[co("div",{className:"Card-icon",children:ia}),co("h2",{children:g("exportDialog.link_title")}),co("div",{className:"Card-details",children:g("exportDialog.link_details")}),co(W,{className:"Card-button",type:"button",title:g("exportDialog.link_button"),"aria-label":g("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{re("export","link",`ui (${FO()})`),await s(e,o,r),l()}catch(c){t({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,o,r,a)]})})},dT=({elements:e,appState:o,files:t,actionManager:r,exportOpts:n,canvas:i,setAppState:a})=>{let l=BO.useCallback(()=>{a({openDialog:null})},[a]);return co(zO,{children:o.openDialog?.name==="jsonExport"&&co(Ne,{onCloseRequest:l,title:g("buttons.export"),children:co(OO,{elements:e,appState:o,setAppState:a,files:t,actionManager:r,onCloseRequest:l,exportOpts:n,canvas:i})})})};import HO from"clsx";import{jsx as mT,jsxs as UO}from"react/jsx-runtime";var GO="small",pT=e=>UO("label",{className:HO("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${GO}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[mT("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),mT("div",{className:"ToolIcon__icon",children:la})]});import{Fragment as gT,jsx as q,jsxs as Bt}from"react/jsx-runtime";var jO=({UIOptions:e})=>Bt(ft,{__fallback:!0,children:[q(ft.DefaultItems.LoadScene,{}),q(ft.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&q(ft.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&q(ft.DefaultItems.SaveAsImage,{}),q(ft.DefaultItems.SearchMenu,{}),q(ft.DefaultItems.Help,{}),q(ft.Separator,{}),q(ft.Group,{title:"Excalidraw links",children:q(ft.DefaultItems.Socials,{})}),q(ft.Separator,{}),q(ft.DefaultItems.ToggleTheme,{}),q(ft.DefaultItems.ChangeCanvasBackground,{})]}),qO=()=>Bt(xd,{__fallback:!0,children:[q(xd.Actions.SaveToDisk,{}),q(xd.Actions.ExportToImage,{})]}),JO=({actionManager:e,appState:o,files:t,setAppState:r,elements:n,canvas:i,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,showExitZenModeBtn:c,renderTopRightUI:d,renderCustomStats:m,UIOptions:p,onExportImage:u,renderWelcomeScreen:f,children:b,app:x,isCollaborating:w,generateLinkForSelection:E})=>{let y=ce(),v=Av(),C=v.tunnelsJotai.Provider,[S,L]=se(Qo),k=()=>p.canvasActions.export?q(dT,{elements:n,appState:o,files:t,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:r}):null,A=()=>!p.canvasActions.saveAsImage||o.openDialog?.name!=="imageExport"?null:q(cT,{elements:n,appState:o,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>r({openDialog:null}),name:x.getName()}),P=()=>Bt("div",{style:{position:"relative"},children:[q(v.MainMenuTunnel.Out,{}),f&&q(v.WelcomeScreenMenuHintTunnel.Out,{})]}),B=()=>q(Er,{heading:"selectedShapeActions",className:fl("selected-shape-actions zen-mode-transition",{"transition-left":o.zenModeEnabled}),children:q(We,{className:WO.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${o.height-166}px`},children:q(Pc,{appState:o,elementsMap:x.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:x})})}),O=()=>{let R=ZO(o,n),X=o.stats.open&&!o.zenModeEnabled&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector";return q(ad,{side:"top",children:Bt("div",{className:"App-menu App-menu_top",children:[Bt(Ze.Col,{gap:6,className:fl("App-menu_top__left"),children:[P(),R&&B()]}),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&q(Er,{heading:"shapes",className:"shapes-section",children:Z=>Bt("div",{style:{position:"relative"},children:[f&&q(v.WelcomeScreenToolbarHintTunnel.Out,{}),q(Ze.Col,{gap:4,align:"start",children:Bt(Ze.Row,{gap:1,className:fl("App-toolbar-container",{"zen-mode":o.zenModeEnabled}),children:[Bt(We,{padding:1,className:fl("App-toolbar",{"zen-mode":o.zenModeEnabled}),children:[q(sd,{appState:o,isMobile:y.editor.isMobile,device:y,app:x}),Z,Bt(Ze.Row,{gap:1,children:[q(cd,{zenModeEnabled:o.zenModeEnabled,checked:o.penMode,onChange:()=>s(null),title:g("toolBar.penMode"),penDetected:o.penDetected}),q(ld,{checked:qt(o),onChange:()=>l(),title:g("toolBar.hand"),isMobile:!0}),q(Ac,{appState:o,activeTool:o.activeTool,UIOptions:p,app:x})]})]}),w&&q(We,{style:{marginLeft:8,alignSelf:"center",height:"fit-content"},children:q(pT,{title:g("toolBar.laser"),checked:o.activeTool.type===uT.laser,onChange:()=>x.setActiveTool({type:uT.laser}),isMobile:!0})})]})})]})}),Bt("div",{className:fl("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":o.zenModeEnabled}),children:[o.collaborators.size>0&&q(pd,{collaborators:o.collaborators,userToFollow:o.userToFollow?.socketId||null}),d?.(y.editor.isMobile,o),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&(!J||o.openSidebar?.name!==Zg.name)&&q(v.DefaultSidebarTriggerTunnel.Out,{}),X&&q(ul,{app:x,onClose:()=>{e.executeAction(ai)},renderCustomStats:m})]})]})})},G=()=>q(wd,{__fallback:!0,onDock:R=>{re("sidebar",`toggleDock (${R?"dock":"undock"})`,`(${y.editor.isMobile?"mobile":"desktop"})`)}}),J=Yl(al),_=Bt(gT,{children:[b,q(jO,{UIOptions:p}),q(wd.Trigger,{__fallback:!0,icon:In,title:XO(g("toolBar.library")),onToggle:R=>{R&&re("sidebar",`${Zg.name} (open)`,`button (${y.editor.isMobile?"mobile":"desktop"})`)},tab:Zg.defaultTab,children:g("toolBar.library")}),q(qO,{}),o.openDialog?.name==="ttd"&&q(Tg,{__fallback:!0}),o.isLoading&&q(id,{delay:250}),o.errorMessage&&q(j5,{onClose:()=>r({errorMessage:null}),children:o.errorMessage}),S&&!y.editor.isMobile&&q(Cb,{colorPickerType:S.colorPickerType,onCancel:()=>{L(null)},onChange:(R,X,Z,{altKey:Y})=>{if(!(R!=="elementBackground"&&R!=="elementStroke"))if(Z.length){for(let ae of Z)KO(ae,VO(n),{[Y&&S.swapPreviewOnAlt?R==="elementBackground"?"strokeColor":"backgroundColor":R==="elementBackground"?"backgroundColor":"strokeColor"]:X}),$O.delete(ae);x.scene.triggerUpdate()}else r(R==="elementBackground"?{currentItemBackgroundColor:X}:{currentItemStrokeColor:X})},onSelect:(R,X)=>{L(Z=>Z?.keepOpenOnAlt&&X.altKey?Z:null),S?.onSelect?.(R,X)}}),o.openDialog?.name==="help"&&q(rT,{onClose:()=>{r({openDialog:null})}}),o.openDialog?.name==="elementLinkSelector"&&q($5,{sourceElementId:o.openDialog.sourceElementId,onClose:()=>{r({openDialog:null})},scene:x.scene,appState:o,generateLinkForSelection:E}),q(v.OverwriteConfirmDialogTunnel.Out,{}),A(),k(),o.pasteDialog.shown&&q(Yv,{setAppState:r,appState:o,onClose:()=>r({pasteDialog:{shown:!1,data:null}})}),y.editor.isMobile&&q(Gv,{app:x,appState:o,elements:n,actionManager:e,renderJSONExportDialog:k,renderImageExportDialog:A,setAppState:r,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,renderTopRightUI:d,renderCustomStats:m,renderSidebars:G,device:y,renderWelcomeScreen:f,UIOptions:p}),!y.editor.isMobile&&Bt(gT,{children:[Bt("div",{className:"layer-ui__wrapper",style:o.openSidebar&&J&&y.editor.canFitSidebar?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[f&&q(v.WelcomeScreenCenterTunnel.Out,{}),O(),q(Kv,{appState:o,actionManager:e,showExitZenModeBtn:c,renderWelcomeScreen:f}),o.scrolledOutside&&q("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(R=>({...Or(n,R)}))},children:g("buttons.scrollBackToContent")})]}),G()]})]});return q(tp.Provider,{value:o,children:q(C,{children:q($h.Provider,{value:v,children:_})})})},hT=e=>{let{suggestedBindings:o,startBoundElement:t,cursorButton:r,scrollX:n,scrollY:i,...a}=e;return a},QO=(e,o)=>{if(e.children!==o.children)return!1;let{canvas:t,appState:r,...n}=e,{canvas:i,appState:a,...l}=o;return Yd(hT(r),hT(a),{selectedElementIds:Yd,selectedGroupIds:Yd})&&Yd(n,l)},fT=YO.memo(JO,QO);import ez from"clsx";import{jsx as bT,jsxs as oz}from"react/jsx-runtime";var tz="small",Wd=e=>oz("label",{className:ez("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${tz}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[bT("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),bT("div",{className:"ToolIcon__icon",children:e.icon})]});import{useEffect as rz,useRef as nz}from"react";import{jsx as xT}from"react/jsx-runtime";var ET=({trails:e})=>{let o=nz(null);return rz(()=>{if(o.current)for(let t of e)t.start(o.current);return()=>{for(let t of e)t.stop()}},e),xT("div",{className:"SVGLayer",children:xT("svg",{ref:o})})};import iz,{useEffect as az,useRef as lz}from"react";import{CURSOR_TYPE as yT,isShallowEqual as sz,sceneCoordsToViewportCoords as cz}from"@excalidraw/common";import{jsx as pz}from"react/jsx-runtime";var dz=e=>{let o=lz(!1);return az(()=>{if(!o.current){o.current=!0;return}let t=new Map,r=new Map,n=new Map,i=new Map,a=new Map;e.appState.collaborators.forEach((s,c)=>{if(s.selectedElementIds)for(let d of Object.keys(s.selectedElementIds))n.has(d)||n.set(d,[]),n.get(d).push(c);!s.pointer||s.pointer.renderCursor===!1||(s.username&&i.set(c,s.username),s.userState&&a.set(c,s.userState),r.set(c,cz({sceneX:s.pointer.x,sceneY:s.pointer.y},e.appState)),t.set(c,s.button))});let l=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";$w({canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:r,remotePointerButton:t,remoteSelectedElementIds:n,remotePointerUsernames:i,remotePointerUserStates:a,selectionColor:l,renderScrollbars:e.renderScrollbars},device:e.device,callback:e.renderInteractiveSceneCallback},Ai())}),pz("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?yT.GRAB:yT.AUTO},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.appState.viewModeEnabled?void 0:e.onDoubleClick,children:g("labels.drawingCanvas")})},wT=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,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,isBindingEnabled:e.isBindingEnabled,suggestedBindings:e.suggestedBindings,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}),mz=(e,o)=>e.selectionNonce!==o.selectionNonce||e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements||e.selectedElements!==o.selectedElements||e.renderScrollbars!==o.renderScrollbars?!1:sz(wT(e.appState),wT(o.appState)),$g=iz.memo(dz,mz);import uz,{useEffect as vT,useRef as TT}from"react";import{isShallowEqual as IT}from"@excalidraw/common";import{jsx as fz}from"react/jsx-runtime";var hz=e=>{let o=TT(null),t=TT(!1);return vT(()=>{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]),vT(()=>{let r=o.current;if(!r)return;let n=e.canvas;t.current||(t.current=!0,r.replaceChildren(n),n.classList.add("excalidraw__canvas","static")),l1({canvas:n,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},Ai())}),fz("div",{className:"excalidraw__canvas-wrapper",ref:o})},CT=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}),gz=(e,o)=>e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements?!1:IT(CT(e.appState),CT(o.appState))&&IT(e.renderConfig,o.renderConfig),jg=uz.memo(hz,gz);import{useEffect as Tz,useRef as Iz}from"react";import{throttleRAF as bz}from"@excalidraw/common";import{getTargetFrame as xz,isInvisiblySmallElement as Ez,renderElement as yz,shouldApplyFrameClip as wz}from"@excalidraw/element";var ST=({canvas:e,rc:o,newElement:t,elementsMap:r,allElementsMap:n,scale:i,appState:a,renderConfig:l})=>{if(e){let[s,c]=Fl(e,i),d=Ol({canvas:e,scale:i,normalizedWidth:s,normalizedHeight:c});if(d.save(),d.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"){if(Ez(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let p=xz(t,r,a);p&&wz(t,p,a,r)&&i1(p,d,l,a)}yz(t,r,n,o,d,l,a)}else d.clearRect(0,0,s,c);d.restore()}},vz=bz(e=>{ST(e)},{trailing:!0}),kT=(e,o)=>{if(o){vz(e);return}ST(e)};import{jsx as Sz}from"react/jsx-runtime";var Cz=e=>{let o=Iz(null);return Tz(()=>{o.current&&kT({canvas:o.current,scale:e.scale,newElement:e.appState.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},Ai())}),Sz("canvas",{className:"excalidraw__canvas",style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:o})},MT=Cz;import{useCallback as kz,useEffect as Mz,useRef as Lz}from"react";import{jsx as LT,jsxs as Az}from"react/jsx-runtime";var Pz=5e3,PT=({message:e,onClose:o,closable:t=!1,duration:r=Pz,style:n})=>{let i=Lz(0),a=r!==1/0,l=kz(()=>{a&&(i.current=window.setTimeout(()=>o(),r))},[o,r,a]);return Mz(()=>{if(a)return l(),()=>clearTimeout(i.current)},[l,e,r,a]),Az("div",{className:"Toast",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?l:void 0,style:n,children:[LT("p",{className:"Toast__message",children:e}),t&&LT(W,{icon:Ft,"aria-label":"close",type:"icon",onClick:o,className:"close"})]})};import{getCommonBounds as Dz,getElementsInGroup as _z,selectGroupsFromGivenElements as Rz}from"@excalidraw/element";import{sceneCoordsToViewportCoords as Nz}from"@excalidraw/common";import{flushSync as Bz}from"react-dom";import{jsx as Oz}from"react/jsx-runtime";var Fz=({app:e,activeLockedId:o})=>{let t=e.scene.getElement(o),r=t?[t]:_z(e.scene.getNonDeletedElementsMap(),o);if(r.length===0)return null;let[n,i]=Dz(r),{x:a,y:l}=Nz({sceneX:n,sceneY:i},e.state);return Oz("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${a-e.state.offsetLeft}px`},onClick:()=>{Bz(()=>{let s=Rz(r,e.state);e.setState({selectedElementIds:r.reduce((c,d)=>({...c,[d.id]:!0}),{}),selectedGroupIds:s,activeLockedId:null})}),e.actionManager.executeAction(Ba)},title:g("labels.elementLock.unlock"),children:L1})},AT=Fz;import{Fragment as DG,jsx as ue,jsxs as Qd}from"react/jsx-runtime";var _I=Mo.createContext(null),RI=Mo.createContext(null),NI={viewport:{isMobile:!1,isLandscape:!1},editor:{isMobile:!1,canFitSidebar:!1},isTouchScreen:!1},Mf=Mo.createContext(NI);Mf.displayName="DeviceContext";var Lf=Mo.createContext({container:null,id:null});Lf.displayName="ExcalidrawContainerContext";var Pf=Mo.createContext([]);Pf.displayName="ExcalidrawElementsContext";var Af=Mo.createContext({...bn(),width:0,height:0,offsetLeft:0,offsetTop:0});Af.displayName="ExcalidrawAppStateContext";var Df=Mo.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});Df.displayName="ExcalidrawSetAppStateContext";var _f=Mo.createContext(null);_f.displayName="ExcalidrawActionManagerContext";var Re=()=>Nr(_I),fo=()=>Nr(RI),ce=()=>Nr(Mf),ze=()=>Nr(Lf),er=()=>Nr(Pf),go=()=>Nr(Af),le=()=>Nr(Df),ot=()=>Nr(_f),Cl=!1,Tf=0,un=!1,Sl=!1,If=!1,kl={horizontal:null,vertical:null},Rr=0,Ml=!1,Cf=new Map,Jd=!1,LI=0,PI=!1,Ll=null,pe={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},kf=class e extends Mo.Component{constructor(t){super(t);I(this,"canvas");I(this,"interactiveCanvas",null);I(this,"rc");I(this,"unmounted",!1);I(this,"actionManager");I(this,"device",NI);I(this,"excalidrawContainerRef",Mo.createRef());I(this,"scene");I(this,"fonts");I(this,"renderer");I(this,"visibleElements");I(this,"resizeObserver");I(this,"nearestScrollableContainer");I(this,"library");I(this,"libraryItemsFromStorage");I(this,"id");I(this,"store");I(this,"history");I(this,"excalidrawContainerValue");I(this,"files",{});I(this,"imageCache",new Map);I(this,"iFrameRefs",new Map);I(this,"embedsValidationStatus",new Map);I(this,"initializedEmbeds",new Set);I(this,"handleToastClose",()=>{this.setToast(null)});I(this,"elementsPendingErasure",new Set);I(this,"flowChartCreator",new iG);I(this,"flowChartNavigator",new aG);I(this,"hitLinkElement");I(this,"lastPointerDownEvent",null);I(this,"lastPointerUpEvent",null);I(this,"lastPointerMoveEvent",null);I(this,"lastPointerMoveCoords",null);I(this,"lastViewportPosition",{x:0,y:0});I(this,"animationFrameHandler",new Vc);I(this,"laserTrails",new ed(this.animationFrameHandler,this));I(this,"eraserTrail",new nd(this.animationFrameHandler,this));I(this,"lassoTrail",new rd(this.animationFrameHandler,this));I(this,"onChangeEmitter",new dn);I(this,"onPointerDownEmitter",new dn);I(this,"onPointerUpEmitter",new dn);I(this,"onUserFollowEmitter",new dn);I(this,"onScrollChangeEmitter",new dn);I(this,"missingPointerEventCleanupEmitter",new dn);I(this,"onRemoveEventListenersEmitter",new dn);I(this,"updateEditorAtom",(t,...r)=>{let n=Ke.set(t,...r);return this.triggerRender(),n});I(this,"getEffectiveGridSize",()=>fr(this)?this.state.gridSize:null);I(this,"updateEmbedValidationStatus",(t,r)=>{this.embedsValidationStatus.set(t.id,r),Tl.delete(t)});I(this,"updateEmbeddables",()=>{let t=new Set,r=!1;this.scene.getNonDeletedElements().filter(n=>{if(_r(n)){if(t.add(n.id),!this.embedsValidationStatus.has(n.id)){r=!0;let i=gf(n.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(n,i)}}else Ki(n)&&t.add(n.id);return!1}),r&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((n,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});I(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);I(this,"frameNameBoundsCache",{get:t=>{let r=this.frameNameBoundsCache._cache.get(t.id);if(!r||r.zoom!==this.state.zoom.value||r.versionNonce!==t.versionNonce){let n=document.getElementById(this.getFrameNameDOMId(t));if(n){let i=n.getBoundingClientRect(),a=Fe({clientX:i.x,clientY:i.y},this.state),l=Fe({clientX:i.right,clientY:i.bottom},this.state);return r={x:a.x,y:a.y,width:l.x-a.x,height:l.y-a.y,angle:0,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,r),r}return null}return r},_cache:new Map});I(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});I(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===Kd.DARK,r=this.scene.getNonDeletedFramesLikes(),n=r.length>0&&this.state.searchMatches?.focusedId&&Zt(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return r.map(i=>{if(!sI(i,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap()))return this.state.editingFrame===i.id&&this.resetEditingFrame(i),null;let{x:a,y:l}=$d({sceneX:i.x,sceneY:i.y},this.state),s=6,c,d=QH(i);if(i.id===this.state.editingFrame){let m=d;c=ue("input",{autoFocus:!0,value:m,onChange:p=>{this.scene.mutateElement(i,{name:p.target.value})},onFocus:p=>p.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:p=>{(p.key===U.ESCAPE||p.key===U.ENTER)&&this.resetEditingFrame(i)},style:{background:this.state.viewBackgroundColor,filter:t?nH:"none",zIndex:2,border:"none",display:"block",padding:`${s}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${Pr.nameFontSize}px`,transform:`translate(-${s}px, ${s}px)`,color:"var(--color-gray-80)",overflow:"hidden",maxWidth:`${document.body.clientWidth-a-s}px`},size:m.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else c=d;return ue("div",{id:this.getFrameNameDOMId(i),style:{position:"absolute",bottom:`${this.state.height+Pr.nameOffsetY-l+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:Pr.nameFontSize,color:t?Pr.nameColorDarkTheme:Pr.nameColorLightTheme,lineHeight:Pr.nameLineHeight,width:"max-content",maxWidth:n?.id===i.id&&n?.focus?"none":`${i.width*this.state.zoom.value}px`,overflow:i.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:De.MOVE,pointerEvents:this.state.viewModeEnabled?Wi.disabled:Wi.enabled},onPointerDown:m=>this.handleCanvasPointerDown(m),onWheel:m=>this.handleWheel(m),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:c},i.id)})});I(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});I(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());I(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());I(this,"getSceneElements",()=>this.scene.getNonDeletedElements());I(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});I(this,"onExportImage",async(t,r,n)=>{re("export",t,"ui");let i=await Zr(t,r,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:n.exportingFrame}).catch(yH).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&Hl(i)&&this.setState({fileHandle:i})});I(this,"magicGenerations",new Map);I(this,"updateMagicGeneration",({frameElement:t,data:r})=>{r.status==="pending"?this.scene.mutateElement(t,{customData:{generationData:void 0}},{informMutation:!1,isDragging:!1}):this.scene.mutateElement(t,{customData:{generationData:r}},{informMutation:!1,isDragging:!1}),this.magicGenerations.set(t.id,r),this.triggerRender()});I(this,"plugins",{});I(this,"onMagicframeToolSelect",()=>{let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(t.length===0)this.setActiveTool({type:ko.magicframe}),re("ai","tool-select (empty-selection)","d2c");else{let r=t.length===1&&uf(t[0])&&t[0];if(!r&&t.some(i=>Zt(i)||i.frameId)){this.setActiveTool({type:ko.magicframe});return}re("ai","tool-select (existing selection)","d2c");let n;if(r)n=r;else{let[i,a,l,s]=Xi(t),c=50;n=eI({...Pr,x:i-c,y:a-c,width:l-i+c*2,height:s-a+c*2,opacity:100,locked:!1}),this.scene.insertElement(n);for(let d of t)this.scene.mutateElement(d,{frameId:n.id});this.setState({selectedElementIds:{[n.id]:!0}})}this.onMagicFrameGenerate(n,"upstream")}});I(this,"openEyeDropper",({type:t})=>{this.updateEditorAtom(Qo,{swapPreviewOnAlt:!0,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(r,n)=>{let i=t==="background"&&n.altKey||t==="stroke"&&!n.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?i?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:r},captureUpdate:mt.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},captureUpdate:mt.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?mn(l,{[i?"strokeColor":"backgroundColor"]:r}):l),captureUpdate:mt.IMMEDIATELY})},keepOpenOnAlt:!1})});I(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});I(this,"syncActionResult",Pe(t=>{if(this.unmounted||t===!1)return;this.store.scheduleAction(t.captureUpdate);let r=!1,n=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),r=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||n||this.state.contextMenu){let i=t?.appState?.viewModeEnabled||!1,a=t?.appState?.zenModeEnabled||!1,l=t?.appState?.theme||this.props.theme||Kd.LIGHT,s=t?.appState?.name??this.state.name,c=t?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(a=this.props.zenModeEnabled),n=t.appState?.editingTextElement||null,t.elements&&n&&t.elements.forEach(d=>{n?.id===d.id&&n!==d&&SI(d)&&mo(d)&&(n=d)}),n?.isDeleted&&(n=null),this.setState(d=>{let m=t.appState||{};return{...d,...m,contextMenu:null,editingTextElement:n,viewModeEnabled:i,zenModeEnabled:a,theme:l,name:s,errorMessage:c}}),r=!0}r||this.scene.triggerUpdate()}));I(this,"onBlur",Pe(()=>{un=!1,this.setState({isBindingEnabled:!0})}));I(this,"onUnload",()=>{this.onBlur()});I(this,"disableEvent",t=>{t.preventDefault()});I(this,"resetHistory",()=>{this.history.clear()});I(this,"resetStore",()=>{this.store.clear()});I(this,"resetScene",Pe(t=>{this.scene.replaceAllElements([]),this.setState(r=>({...bn(),isLoading:t?.resetLoadingState?!1:r.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));I(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async n=>{if(!n.files.length)return;let i=n.files[0],a=await i.getFile();this.loadFileToCanvas(new File([a],a.name||"",{type:a.type}),i)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let t=null;try{typeof this.props.initialData=="function"?t=await this.props.initialData()||null:t=await this.props.initialData||null,t?.libraryItems&&this.library.updateLibrary({libraryItems:t.libraryItems,merge:!0}).catch(n=>{console.error(n)})}catch(n){console.error(n),t={appState:{errorMessage:n.message||"Encountered an error during importing or restoring scene data"}}}let r=yn(t,null,null,{repairBindings:!0});r.appState={...r.appState,theme:this.props.theme||r.appState.theme,openSidebar:r.appState?.openSidebar||this.state.openSidebar,activeTool:r.appState.activeTool.type==="image"?{...r.appState.activeTool,type:"selection"}:r.appState.activeTool,isLoading:!1,toast:this.state.toast},t?.scrollToContent&&(r.appState={...r.appState,...Or(r.elements,{...r.appState,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})}),this.resetStore(),this.resetHistory(),this.syncActionResult({...r,captureUpdate:mt.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(n=>{this.fonts.onLoaded(n)}),wf(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})});I(this,"isMobileBreakpoint",(t,r)=>t<Qz||r<qz&&t<Jz);I(this,"refreshViewportBreakpoints",()=>{if(!this.excalidrawContainerRef.current)return;let{clientWidth:r,clientHeight:n}=document.body,i=this.device.viewport,a=nf(i,{isLandscape:r>n,isMobile:this.isMobileBreakpoint(r,n)});return i!==a?(this.device={...this.device,viewport:a},!0):!1});I(this,"refreshEditorBreakpoints",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:r,height:n}=t.getBoundingClientRect(),i=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:eH,a=this.device.editor,l=nf(a,{isMobile:this.isMobileBreakpoint(r,n),canFitSidebar:r>i});return a!==l?(this.device={...this.device,editor:l},!0):!1});I(this,"onResize",Pe(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>Tl.delete(t)),this.refreshViewportBreakpoints(),this.updateDOMRect(),YT||this.refreshEditorBreakpoints(),this.setState({})}));I(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});I(this,"renderInteractiveSceneCallback",({atLeastOneVisibleElement:t,scrollBars:r,elementsMap:n})=>{r&&(kl=r);let i=this.state.editingTextElement?!1:!t&&n.size>0;this.state.scrolledOutside!==i&&this.setState({scrolledOutside:i}),this.scheduleImageRefresh()});I(this,"onScroll",XT(()=>{let{offsetTop:t,offsetLeft:r}=this.getCanvasOffsets();this.setState(n=>n.offsetLeft===r&&n.offsetTop===t?null:{offsetTop:t,offsetLeft:r})},tH));I(this,"onCut",Pe(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||xl(t.target)||(this.actionManager.executeAction(tc,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onCopy",Pe(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||xl(t.target)||(this.actionManager.executeAction(ni,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onTouchStart",t=>{if(sH&&t.preventDefault(),!Cl){Cl=!0,clearTimeout(Tf),Tf=window.setTimeout(e.resetTapTwice,oH);return}if(Cl&&t.touches.length===1){let r=t.touches[0];this.handleCanvasDoubleClick({clientX:r.clientX,clientY:r.clientY}),Cl=!1,clearTimeout(Tf)}t.touches.length===2&&this.setState({selectedElementIds:fe({},this.state),activeEmbeddable:null})});I(this,"onTouchEnd",t=>{this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:fe(this.state.previousSelectedElementIds,this.state)}):pe.pointers.clear()});I(this,"addImageElementsToScene",async({sceneX:t,sceneY:r,files:n,selectAfterInsert:i=!0,addToFrameUnderCursor:a})=>{let l=await Promise.all(n.map(async c=>await this.createImageElement({sceneX:t,sceneY:r,imageFile:c,addToFrameUnderCursor:a})).filter(c=>c?!0:(console.error("Failed to create image element for file",c),!1)));if(i){let c=Object.assign({},...l.map(d=>({[d.id]:!0})));this.setState({selectedElementIds:fe(c,this.state)})}let s=jd(l);return MI(this.scene,l,s,this.state.arrangeConfiguration.algorithm,this.state.arrangeConfiguration.gap),l});I(this,"pasteFromClipboard",Pe(async t=>{let r=!!Jd,n=document.activeElement,i=this.excalidrawContainerRef.current?.contains(n);if(t&&!i)return;let a=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(t&&(!(a instanceof HTMLCanvasElement)||xl(n)))return;let{x:l,y:s}=Fe({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),c=t.clipboardData?.files[0],d=await Ys(t,r);if(!c&&!r){if(d.mixedContent)return this.addElementsFromMixedContentPaste(d.mixedContent,{isPlainPaste:r,sceneX:l,sceneY:s});if(d.text){let m=d.text.trim();m.startsWith("<svg")&&m.endsWith("</svg>")&&(c=xm(m))}}if(ea(c)&&!d.spreadsheet){if(!this.isToolSupported("image")){this.setState({errorMessage:g("errors.imageToolNotSupported")});return}if(!t.clipboardData)throw new Error("Clipboard data is not available");let m=t.clipboardData.files,p=Array.from(m);this.addImageElementsToScene({sceneX:l,sceneY:s,files:p});return}if(this.props.onPaste)try{if(await this.props.onPaste(d,t)===!1)return}catch(m){console.error(m)}if(d.errorMessage)this.setState({errorMessage:d.errorMessage});else if(d.spreadsheet&&!r)this.setState({pasteDialog:{data:d.spreadsheet,shown:!0}});else if(d.elements){let m=d.programmaticAPI?Pi(d.elements):d.elements;this.addElementsFromPasteOrLibrary({elements:m,files:d.files||null,position:"cursor",retainSeed:r})}else if(d.text){if(d.text&&cv(d.text)){let u=await import("@excalidraw/mermaid-to-excalidraw");try{let{elements:f,files:b}=await u.parseMermaidToExcalidraw(d.text),x=Pi(f,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:x,files:b,position:"cursor"});return}catch(f){console.warn(`parsing pasted text as mermaid definition failed: ${f.message}`)}}let m=vH(d.text).split(/\n+/).map(u=>u.trim()).filter(Boolean),p=m.map(u=>YH(u)).filter(u=>gf(u,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(u)||qd(u)?.type==="video"));if(!Jd&&p.length>0&&p.length===m.length){let u=[];for(let f of p){let b=u[u.length-1],x=this.insertEmbeddableElement({sceneX:b?b.x+b.width+20:l,sceneY:s,link:tf(f)});x&&u.push(x)}u.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(u.map(f=>[f.id,!0]))}));return}this.addTextFromPaste(d.text,r)}this.setActiveTool({type:"selection"}),t?.preventDefault()}));I(this,"addElementsFromPasteOrLibrary",t=>{let r=hm(t.elements,null,void 0),[n,i,a,l]=Xi(r),s=Vi(n,a)/2,c=Vi(i,l)/2,d=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,m=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop,{x:p,y:u}=Fe({clientX:d,clientY:m},this.state),f=p-s,b=u-c,[x,w]=nt(f,b,this.getEffectiveGridSize()),{duplicatedElements:E}=rI({type:"everything",elements:r.map(k=>mn(k,{x:k.x+x-n,y:k.y+w-i})),randomizeSeed:!t.retainSeed}),y=this.scene.getElementsIncludingDeleted(),v=[...y,...E];v=this.props.onDuplicate?.(v,y)||v,wI(v,jd(E));let S=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(S){let k=tG(E,S);xf(v,k,S,this.state)}this.scene.replaceAllElements(v),E.forEach(k=>{if(mo(k)&&pf(k)){let A=uI(k,this.scene.getElementsMapIncludingDeleted());KH(k,A,this.scene)}}),mH&&Zo.loadElementsFonts(E).then(k=>{this.fonts.onLoaded(k)}),t.files&&this.addMissingFiles(t.files);let L=wG(E);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.device.editor.canFitSidebar&&Ke.get(al)?this.state.openSidebar:null,...po({editingGroupId:null,selectedElementIds:L.reduce((k,A)=>(pf(A)||(k[A.id]=!0),k),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:"selection"}),t.fitToContent&&this.scrollToContent(E,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})});I(this,"setAppState",(t,r)=>{this.setState(t,r)});I(this,"removePointer",t=>{Rr&&this.resetContextMenuTimer(),pe.pointers.delete(t.pointerId)});I(this,"toggleLock",(t="ui")=>{this.state.activeTool.locked||re("toolbar","toggleLock",`${t} (${this.device.editor.isMobile?"mobile":"desktop"})`),this.setState(r=>({activeTool:{...r.activeTool,...Vo(this.state,r.activeTool.locked?{type:"selection"}:r.activeTool),locked:!r.activeTool.locked}}))});I(this,"updateFrameRendering",t=>{this.setState(r=>{let n=typeof t=="function"?t(r.frameRendering):t;return{frameRendering:{enabled:n?.enabled??r.frameRendering.enabled,clip:n?.clip??r.frameRendering.clip,name:n?.name??r.frameRendering.name,outline:n?.outline??r.frameRendering.outline}}})});I(this,"togglePenMode",t=>{this.setState(r=>({penMode:t??!r.penMode,penDetected:!0}))});I(this,"onHandToolToggle",()=>{this.actionManager.executeAction(vx)});I(this,"zoomCanvas",t=>{this.setState({...No({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:uo(t)},this.state)})});I(this,"cancelInProgressAnimation",null);I(this,"scrollToContent",(t=this.scene.getNonDeletedElements(),r)=>{if(typeof t=="string"){let s;if(wf(t)?s=cG(t):s=t,s){let c=this.scene.getElementsFromId(s);c?.length?this.scrollToContent(c,{fitToContent:r?.fitToContent??!0,animate:r?.animate??!0}):wf(t)&&this.setState({toast:{message:g("elementLink.notFound"),duration:3e3,closable:!0}})}return}this.cancelInProgressAnimation?.();let n=Array.isArray(t)?t:[t],i=this.state.zoom,a=this.state.scrollX,l=this.state.scrollY;if(r?.fitToContent||r?.fitToViewport){let{appState:s}=Ta({canvasOffsets:r.canvasOffsets,targetElements:n,appState:this.state,fitToViewport:!!r?.fitToViewport,viewportZoomFactor:r?.viewportZoomFactor,minZoom:r?.minZoom,maxZoom:r?.maxZoom});i=s.zoom,a=s.scrollX,l=s.scrollY}else{let s=Or(n,this.state);a=s.scrollX,l=s.scrollY}if(r?.animate){let s=this.state.scrollX,c=this.state.scrollY,d=this.state.zoom.value,m=EH({fromValues:{scrollX:s,scrollY:c,zoom:d},toValues:{scrollX:a,scrollY:l,zoom:i.value},interpolateValue:(p,u,f,b)=>{if(b==="zoom")return p*Math.pow(u/p,wH(f))},onStep:({scrollX:p,scrollY:u,zoom:f})=>{this.setState({scrollX:p,scrollY:u,zoom:{value:f}})},onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.setState({shouldCacheIgnoreZoom:!1})},duration:r?.duration??500});this.cancelInProgressAnimation=()=>{m(),this.cancelInProgressAnimation=null}}else this.setState({scrollX:a,scrollY:l,zoom:i})});I(this,"maybeUnfollowRemoteUser",()=>{this.state.userToFollow&&this.setState({userToFollow:null})});I(this,"translateCanvas",t=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(t)});I(this,"setToast",t=>{this.setState({toast:t})});I(this,"restoreFileFromShare",async()=>{try{let t=await caches.open("web-share-target"),r=await t.match("shared-file");if(r){let n=await r.blob(),i=new File([n],n.name||"",{type:n.type});this.loadFileToCanvas(i,null),await t.delete("shared-file"),window.history.replaceState(null,Wz,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});I(this,"addFiles",Pe(t=>{let{addedFiles:r}=this.addMissingFiles(t);this.clearImageShapeCache(r),this.scene.triggerUpdate(),this.addNewImagesToImageCache()}));I(this,"addMissingFiles",(t,r=!1)=>{let n=r?{}:{...this.files},i={},a=Array.isArray(t)?t:Object.values(t);for(let l of a)if(!n[l.id]&&(i[l.id]=l,n[l.id]=l,l.mimeType===Ar.svg))try{let s=g1(pI(f1(l.dataURL)),Ar.svg);l.dataURL!==s&&(l.version=(l.version??1)+1,l.dataURL=s)}catch(s){console.error(s)}return this.files=n,{addedFiles:i}});I(this,"updateScene",Pe(t=>{let{elements:r,appState:n,collaborators:i,captureUpdate:a}=t;if(a){let l=r||void 0,s=n?SH({...this.store.snapshot.appState,...n}):void 0;this.store.scheduleMicroAction({action:a,elements:l,appState:s})}n&&this.setState(n),r&&this.scene.replaceAllElements(r),i&&this.setState({collaborators:i})}));I(this,"mutateElement",(t,r,n=!0)=>this.scene.mutateElement(t,r,{informMutation:n,isDragging:!1}));I(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});I(this,"toggleSidebar",({name:t,tab:r,force:n})=>{let i;n===void 0?i=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===r?null:t:i=n?t:null;let a=i?{name:i}:null;return a&&r&&(a.tab=r),this.setState({openSidebar:a}),!!i});I(this,"updateCurrentCursorPosition",Pe(t=>{this.lastViewportPosition.x=t.clientX,this.lastViewportPosition.y=t.clientY}));I(this,"getEditorUIOffsets",()=>{let t=this.excalidrawContainerRef?.current?.querySelector(".App-toolbar")?.getBoundingClientRect()?.bottom??0,r=this.excalidrawContainerRef?.current?.querySelector(".sidebar")?.getBoundingClientRect(),n=this.excalidrawContainerRef?.current?.querySelector(".App-menu__left")?.getBoundingClientRect(),i=16;return Po().rtl?{top:t+i,right:Math.max(this.state.width-(n?.left??this.state.width),0)+i,bottom:i,left:Math.max(r?.right??0,0)+i}:{top:t+i,right:Math.max(this.state.width-(r?.left??this.state.width)+i,0),bottom:i,left:Math.max(n?.right??0,0)+i}});I(this,"onKeyDown",Pe(t=>{if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(a,l){let s=a[l];return typeof s=="function"?s.bind(a):l==="key"?t.shiftKey?a.key.toUpperCase():a.key.toLowerCase():s}})),!KT(t.target)){if((t.key===U.ESCAPE||t.key===U.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let a=$(this.scene.getNonDeletedElementsMap(),this.state);if(a.length===1&&pn(a[0])&&t.key===U.ENTER){this.startImageCropping(a[0]);return}if(t.key===U.ESCAPE)this.updateEditorAtom(no,null);else if(t.key===U.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(CH.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let s=pi(a);Ke.get(no)?.type==="panel"&&Lu(this,{conversionType:s,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),s&&this.updateEditorAtom(no,{type:"panel"})}if(t.key===U.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let l=Vd(t.key);if(t[U.CTRL_OR_CMD]&&l&&!t.shiftKey){t.preventDefault();let s=$(this.scene.getNonDeletedElementsMap(),this.state);s.length===1&&zH(s[0])&&this.flowChartCreator.createNodes(s[0],this.state,xI(t.key),this.scene),this.flowChartCreator.pendingNodes?.length&&!hf(this.flowChartCreator.pendingNodes,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(this.flowChartCreator.pendingNodes,{animate:!0,duration:300,fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()});return}if(t.altKey){let s=$(this.scene.getNonDeletedElementsMap(),this.state);if(s.length===1&&l){t.preventDefault();let c=this.flowChartNavigator.exploreByDirection(s[0],this.scene.getNonDeletedElementsMap(),xI(t.key));if(c){this.setState(m=>({selectedElementIds:fe({[c]:!0},m)}));let d=this.scene.getNonDeletedElementsMap().get(c);d&&!hf([d],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(d,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})}return}}}if(t[U.CTRL_OR_CMD]&&t.key===U.P&&!t.shiftKey&&!t.altKey){this.setToast({message:g("commandPalette.shortcutHint",{shortcut:Se("commandPalette")})}),t.preventDefault();return}if(t[U.CTRL_OR_CMD]&&t.key.toLowerCase()===U.V&&(Jd=t.shiftKey,clearTimeout(LI),LI=window.setTimeout(()=>{Jd=!1},100)),t[U.CTRL_OR_CMD]&&xl(t.target)&&(t.code===OT.MINUS||t.code===OT.EQUAL)){t.preventDefault();return}if(xl(t.target)&&t.key!==U.ESCAPE||Vd(t.key)&&KT(t.target))return;if(t.key===U.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===U.E&&t.shiftKey&&t[U.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(t.key===U.PAGE_UP||t.key===U.PAGE_DOWN){let a=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;t.key===U.PAGE_DOWN&&(a=-a),t.shiftKey?this.translateCanvas(l=>({scrollX:l.scrollX+a})):this.translateCanvas(l=>({scrollY:l.scrollY+a}))}if(this.state.openDialog?.name==="elementLinkSelector"||this.actionManager.handleKeyDown(t)||this.state.viewModeEnabled)return;if(t[U.CTRL_OR_CMD]&&this.state.isBindingEnabled&&this.setState({isBindingEnabled:!1}),Vd(t.key)){let a=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),l=a.find(Ge),s=new Set;a.filter(Ge).filter(p=>{let u=p.startBinding&&!a.some(b=>b.id===p.startBinding?.elementId),f=p.endBinding&&!a.some(b=>b.id===p.endBinding?.elementId);return u||f}).forEach(p=>s.add(p.id)),a=a.filter(p=>!s.has(p.id));let c=this.getEffectiveGridSize()&&(t.shiftKey?GT:this.getEffectiveGridSize())||(t.shiftKey?Kz:GT),d=0,m=0;t.key===U.ARROW_LEFT?d=-c:t.key===U.ARROW_RIGHT?d=c:t.key===U.ARROW_UP?m=-c:t.key===U.ARROW_DOWN&&(m=c),a.forEach(p=>{this.scene.mutateElement(p,{x:p.x+d,y:p.y+m},{informMutation:!1,isDragging:!1}),sf(p,this.scene,{simultaneouslyUpdated:a})}),this.setState({suggestedBindings:cf(a.filter(p=>p.id!==l?.id||c!==0),this.scene.getNonDeletedElementsMap(),this.state.zoom)}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===U.ENTER){let a=this.scene.getSelectedElements(this.state);if(a.length===1){let l=a[0];if(t[U.CTRL_OR_CMD]||vf(l))$t(l)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)&&(this.store.scheduleCapture(),Ge(l)||this.actionManager.executeAction(ki));else if(mo(l)||XH(l)){let s;mo(l)||(s=l);let c=bf(l,this.state,this.scene.getNonDeletedElementsMap()),d=c.x,m=c.y;this.startTextEditing({sceneX:d,sceneY:m,container:s}),t.preventDefault();return}else Zt(l)&&this.setState({editingFrame:l.id})}}else if(!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let a=p2(t.key);a?(this.state.activeTool.type!==a&&re("toolbar",a,`keyboard (${this.device.editor.isMobile?"mobile":"desktop"})`),a==="arrow"&&this.state.activeTool.type==="arrow"&&this.setState(l=>({currentItemArrowType:l.currentItemArrowType===Dr.sharp?Dr.round:l.currentItemArrowType===Dr.round?Dr.elbow:Dr.sharp})),this.setActiveTool({type:a}),t.stopPropagation()):t.key===U.Q&&(this.toggleLock("keyboard"),t.stopPropagation())}if(t.key===U.SPACE&&pe.pointers.size===0&&(un=!0,xe(this.interactiveCanvas,De.GRAB),t.preventDefault()),(t.key===U.G||t.key===U.S)&&!t.altKey&&!t[U.CTRL_OR_CMD]){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;t.key===U.G&&(Ko(this.state.activeTool.type)||a.some(l=>Ko(l.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===U.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[U.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===U.F){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;(this.state.activeTool.type==="text"||a.find(l=>mo(l)||ff(l,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}if(t.key===U.K&&!t.altKey&&!t[U.CTRL_OR_CMD]){this.state.activeTool.type==="laser"?this.setActiveTool({type:"selection"}):this.setActiveTool({type:"laser"});return}let r=t.key.toLocaleLowerCase(),n=r===U.S&&t.shiftKey,i=t.key===U.I||r===U.G&&t.shiftKey;(n||i)&&this.openEyeDropper({type:n?"stroke":"background"})}));I(this,"onKeyUp",Pe(t=>{if(t.key===U.SPACE&&(this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector"?xe(this.interactiveCanvas,De.GRAB):this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"?Ht(this.interactiveCanvas):(Dt(this.interactiveCanvas,this.state),this.setState({selectedElementIds:fe({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),un=!1),!t[U.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),Vd(t.key)&&(JT(this.scene.getSelectedElements(this.state).filter($t),lf(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.scene,this.state.zoom),this.setState({suggestedBindings:[]})),t.altKey||this.flowChartNavigator.isExploring&&(this.flowChartNavigator.clear(),this.syncActionResult({captureUpdate:mt.IMMEDIATELY})),!t[U.CTRL_OR_CMD]&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.pendingNodes?.length&&this.scene.insertElements(this.flowChartCreator.pendingNodes);let r=this.flowChartCreator.pendingNodes?.[0];r&&(this.setState(n=>({selectedElementIds:fe({[r.id]:!0},n)})),hf([r],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())||this.scrollToContent(r,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})),this.flowChartCreator.clear(),this.syncActionResult({captureUpdate:mt.IMMEDIATELY})}}));I(this,"isToolSupported",t=>this.props.UIOptions.tools?.[t]!==!1);I(this,"setActiveTool",(t,r=!1)=>{if(!this.isToolSupported(t.type)){console.warn(`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`);return}let n=Vo(this.state,t);n.type==="hand"?xe(this.interactiveCanvas,De.GRAB):un||Dt(this.interactiveCanvas,{...this.state,activeTool:n}),gH(document.activeElement)&&this.focusContainer(),FH(n.type)||this.setState({suggestedBindings:[]}),n.type==="image"&&this.onImageAction(),this.setState(i=>{let a={snapLines:i.snapLines.length?[]:i.snapLines,originSnapOffset:null,activeEmbeddable:null};return n.type==="freedraw"&&this.store.scheduleCapture(),n.type==="lasso"?{...i,activeTool:n,...r?{}:{selectedElementIds:fe({},i),selectedGroupIds:fe({},i),editingGroupId:null,multiElement:null},...a}:n.type!=="selection"?{...i,activeTool:n,selectedElementIds:fe({},i),selectedGroupIds:fe({},i),editingGroupId:null,multiElement:null,...a}:{...i,activeTool:n,...a}})});I(this,"setOpenDialog",t=>{this.setState({openDialog:t})});I(this,"setCursor",t=>{xe(this.interactiveCanvas,t)});I(this,"resetCursor",()=>{Ht(this.interactiveCanvas)});I(this,"isTouchScreenMultiTouchGesture",()=>pe.pointers.size>=2);I(this,"getName",()=>this.state.name||this.props.name||`${g("labels.untitled")}-${ZT()}`);I(this,"onGestureStart",Pe(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:fe({},this.state),activeEmbeddable:null}),pe.initialScale=this.state.zoom.value}));I(this,"onGestureChange",Pe(t=>{if(t.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let r=pe.initialScale;r&&this.setState(n=>({...No({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:uo(r*t.scale)},n)}))}));I(this,"onGestureEnd",Pe(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:fe(this.state.previousSelectedElementIds,this.state)}),pe.initialScale=null}));I(this,"startTextEditing",({sceneX:t,sceneY:r,insertAtParentCenter:n=!0,container:i,autoEdit:a=!0})=>{let l=!1,s=n&&this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,i);i&&s&&(ff(i,this.scene.getNonDeletedElementsMap())||(l=!0));let c=null,d=this.scene.getSelectedElements(this.state);d.length===1?mo(d[0])?c=d[0]:i?c=ff(d[0],this.scene.getNonDeletedElementsMap()):c=this.getTextElementAtPosition(t,r):c=this.getTextElementAtPosition(t,r);let m=c?.fontFamily||this.state.currentItemFontFamily,p=c?.lineHeight||VT(m),u=this.state.currentItemFontSize;if(!c&&l&&i&&!df(i)){let w=uG(of({fontSize:u,fontFamily:m}),p),E=hG(u,p),y=Math.max(i.height,E),v=Math.max(i.width,w);this.scene.mutateElement(i,{height:y,width:v}),t=i.x+v/2,r=i.y+y/2,s&&(s=this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,i))}let f=this.getTopLayerFrameAtSceneCoords({x:t,y:r}),b=c||tI({x:s?s.elementCenterX:t,y:s?s.elementCenterY:r,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:u,fontFamily:m,textAlign:s?"center":this.state.currentItemTextAlign,verticalAlign:s?aH.MIDDLE:HT,containerId:l?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:p,angle:i?df(i)?0:i.angle:0,frameId:f?f.id:null});if(!c&&l&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:b.id})}),this.setState({editingTextElement:b}),!c)if(i&&l){let x=this.scene.getElementIndex(i.id);this.scene.insertElementAtIndex(b,x+1)}else this.scene.insertElement(b);a||c||i?this.handleTextWysiwyg(b,{isExistingElement:!!c}):this.setState({newElement:b,multiElement:null})});I(this,"startImageCropping",t=>{this.store.scheduleCapture(),this.setState({croppingElementId:t.id})});I(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});I(this,"handleCanvasDoubleClick",t=>{if(this.state.multiElement||this.state.activeTool.type!=="selection")return;let r=this.scene.getSelectedElements(this.state),{x:n,y:i}=Fe(t,this.state);if(r.length===1&&$t(r[0])){let l=r[0];if((t[U.CTRL_OR_CMD]&&PG(l)||vf(l))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)){this.actionManager.executeAction(ki);return}else if(this.state.selectedLinearElement&&Ge(r[0])){let s=Ce.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:n,y:i},this.state,this.scene.getNonDeletedElementsMap()),c=s?Ce.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,s,this.scene.getNonDeletedElementsMap()):-1;if(c&&c>-1){this.store.scheduleCapture(),Ce.deleteFixedSegment(r[0],this.scene,c);let d=Ce.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:n,y:i},this.state,this.scene.getNonDeletedElementsMap()),m=d?Ce.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,d,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:{...this.state.selectedLinearElement.pointerDownState,segmentMidpoint:{index:m,value:s,added:!1}},segmentMidPointHoveredCoords:d}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===l.id&&vf(l))return}if(r.length===1&&pn(r[0])){this.startImageCropping(r[0]);return}if(Ht(this.interactiveCanvas),EG(this.state).length>0){let l=this.getElementAtPosition(n,i),s=l&&xG(l,this.state.selectedGroupIds);if(s){this.store.scheduleCapture(),this.setState(c=>({...c,...po({editingGroupId:s,selectedElementIds:{[l.id]:!0}},this.scene.getNonDeletedElements(),c,this)}));return}}if(Ht(this.interactiveCanvas),!t[U.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let l=this.getElementAtPosition(n,i);if(wl(l)){this.setState({activeEmbeddable:{element:l,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){let s=this.getTextBindableContainerAtPosition(n,i);if(s&&(nI(s)||!xH(s.backgroundColor)||vl({point:ne(n,i),element:s,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(s)}))){let c=bf(s,this.state,this.scene.getNonDeletedElementsMap());n=c.x,i=c.y}this.startTextEditing({sceneX:n,sceneY:i,insertAtParentCenter:!t.altKey,container:s})}}});I(this,"getElementLinkAtPosition",(t,r)=>{if(r&&r.locked)return;let n=this.scene.getNonDeletedElements(),i=-1;for(let a=n.length-1;a>=0;a--){let l=n[a];if(r&&l.id===r.id&&(i=a),l.link&&a>=i&&Bl(l,this.scene.getNonDeletedElementsMap(),this.state,ne(t.x,t.y),this.device.editor.isMobile))return l}});I(this,"redirectToLink",(t,r)=>{let n=sn(ne(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),ne(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||n>Xz)return;let i=Fe(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),l=Bl(this.hitLinkElement,a,this.state,ne(i.x,i.y),this.device.editor.isMobile),s=Fe(this.lastPointerUpEvent,this.state),c=Bl(this.hitLinkElement,a,this.state,ne(s.x,s.y),this.device.editor.isMobile);if(l&&c){xu();let d=this.hitLinkElement.link;if(d){d=tf(d);let m;if(this.props.onLinkOpen&&(m=fH(ee.EXCALIDRAW_LINK,t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:d},m)),!m?.defaultPrevented){let p=pH(d)?"_self":"_blank",u=window.open(void 0,p);u&&(u.opener=null,u.location=d)}}}});I(this,"getTopLayerFrameAtSceneCoords",t=>{let r=this.scene.getNonDeletedElementsMap(),n=this.scene.getNonDeletedFramesLikes().filter(i=>gI(t,i,r));return n.length?n[n.length-1]:null});I(this,"handleCanvasPointerMove",t=>{this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent,pe.pointers.has(t.pointerId)&&pe.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let r=pe.initialScale;if(pe.pointers.size===2&&pe.lastCenter&&r&&pe.initialDistance){let f=Ch(pe.pointers),b=f.x-pe.lastCenter.x,x=f.y-pe.lastCenter.y;pe.lastCenter=f;let w=Sh(Array.from(pe.pointers.values())),E=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:w/pe.initialDistance,y=E?uo(r*E):this.state.zoom.value;this.setState(v=>{let C=No({viewportX:f.x,viewportY:f.y,nextZoom:y},v);this.translateCanvas({zoom:C.zoom,scrollX:C.scrollX+2*(b/y),scrollY:C.scrollY+2*(x/y),shouldCacheIgnoreZoom:!0})}),this.resetShouldCacheIgnoreZoomDebounced()}else pe.lastCenter=pe.initialDistance=pe.initialScale=null;if(un||Sl||If||qt(this.state))return;let i=Rh(kl,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(i?Ht(this.interactiveCanvas):Dt(this.interactiveCanvas,this.state));let a=Fe(t,this.state),{x:l,y:s}=a;if(!this.state.newElement&&Mw(this.state.activeTool.type)){let{originOffset:f,snapLines:b}=kw(this.scene.getNonDeletedElements(),this,{x:l,y:s},t,this.scene.getNonDeletedElementsMap());this.setState(x=>{let w=El(x.snapLines,b),E=x.originSnapOffset?El(x.originSnapOffset,f):f;return x.snapLines===w&&x.originSnapOffset===E?null:{snapLines:w,originSnapOffset:E}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(f=>f.snapLines.length?{snapLines:[]}:null);if(this.state.selectedLinearElement?.isEditing&&!this.state.selectedLinearElement.isDragging){let f=Ce.handlePointerMove(t,l,s,this),b=f?this.scene.getElement(f.elementId):null;f&&f!==this.state.selectedLinearElement&&Yi(()=>{this.setState({selectedLinearElement:f})}),f?.lastUncommittedPoint!=null&&b&&iI(b.type)?this.maybeSuggestBindingAtCursor(a,f.elbowed):this.state.suggestedBindings.length&&this.setState({suggestedBindings:[]})}if(iI(this.state.activeTool.type)){let{newElement:f}=this.state;mf(f,!1)?this.setState({suggestedBindings:jT(f,[a],this.scene,this.state.zoom,this.state.startBoundElement)}):this.maybeSuggestBindingAtCursor(a,!1)}if(this.state.multiElement){let{multiElement:f}=this.state,{x:b,y:x}=f,{points:w,lastCommittedPoint:E}=f,y=w[w.length-1];if(Dt(this.interactiveCanvas,this.state),y===E)sn(ne(l-b,s-x),y)>=ef?this.scene.mutateElement(f,{points:[...w,ne(l-b,s-x)]},{informMutation:!1,isDragging:!1}):xe(this.interactiveCanvas,De.POINTER);else if(w.length>2&&E&&sn(ne(l-b,s-x),E)<ef)xe(this.interactiveCanvas,De.POINTER),this.scene.mutateElement(f,{points:w.slice(0,-1)},{informMutation:!1,isDragging:!1});else{let[v,C]=nt(l,s,t[U.CTRL_OR_CMD]||Ge(f)?null:this.getEffectiveGridSize()),[S,L]=f?.lastCommittedPoint??[0,0],k=v-b-S,A=C-x-L;Qg(t)&&({width:k,height:A}=lI(S+b,L+x,v,C)),dI(w,this.state.zoom.value)&&xe(this.interactiveCanvas,De.POINTER),this.scene.mutateElement(f,{points:[...w.slice(0,-1),ne(S+k,L+A)]},{isDragging:!0,informMutation:!1}),this.triggerRender(!1)}return}if(!!t.buttons||this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let d=this.scene.getNonDeletedElements(),m=this.scene.getSelectedElements(this.state);if(m.length===1&&!i&&!this.state.selectedLinearElement?.isEditing){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,l,s),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&this.state.openDialog?.name!=="elementLinkSelector"&&!(m.length===1&&Ge(m[0]))){let f=TI(d,this.state,l,s,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);if(f&&f.transformHandleType){xe(this.interactiveCanvas,vI(f));return}}}else if(m.length>1&&!i&&this.state.openDialog?.name!=="elementLinkSelector"){let f=II(Xi(m),l,s,this.state.zoom,t.pointerType,this.device);if(f){xe(this.interactiveCanvas,vI({transformHandleType:f}));return}}let p=this.getElementAtPosition(l,s,{preferSelected:!0,includeLockedElements:!0}),u=null;p&&p.locked?u=null:u=p,this.hitLinkElement=this.getElementLinkAtPosition(a,p),!Et(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(xe(this.interactiveCanvas,De.POINTER),VE(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):(xu(),u&&(u.link||_r(u))&&this.state.selectedElementIds[u.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?xe(this.interactiveCanvas,mo(u)?De.TEXT:De.CROSSHAIR):this.state.viewModeEnabled?xe(this.interactiveCanvas,De.GRAB):this.state.openDialog?.name==="elementLinkSelector"?xe(this.interactiveCanvas,De.AUTO):i?xe(this.interactiveCanvas,De.AUTO):t[U.CTRL_OR_CMD]?xe(this.interactiveCanvas,De.AUTO):(u||this.isHittingCommonBoundingBoxOfSelectedElements(a,m))&&!u?.locked&&(u&&wl(u)&&this.isIframeLikeElementCenter(u,t,l,s)?(xe(this.interactiveCanvas,De.POINTER),this.setState({activeEmbeddable:{element:u,state:"hover"}})):(!u||!Ge(u)||!(u.startBinding||u.endBinding))&&(xe(this.interactiveCanvas,De.MOVE),this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null}))),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,l,s)),this.state.openDialog?.name==="elementLinkSelector"&&u?this.setState(f=>({hoveredElementIds:El(f.hoveredElementIds,po({editingGroupId:f.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),f,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!u&&this.setState(f=>({hoveredElementIds:El(f.hoveredElementIds,{})})))});I(this,"handleEraser",(t,r)=>{let n=this.eraserTrail.addPointToPath(r.x,r.y,t.altKey);this.elementsPendingErasure=new Set(n),this.triggerRender()});I(this,"handleTouchMove",t=>{Ml=!0});I(this,"handleCanvasPointerDown",t=>{let r=t.target;if(r.setPointerCapture&&r.setPointerCapture(t.pointerId),this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.searchMatches&&(this.setState(m=>({searchMatches:m.searchMatches&&{focusedId:null,matches:m.searchMatches.matches.map(p=>({...p,focus:!1}))}})),this.updateEditorAtom(bg,null)),Ke.get(no)&&this.updateEditorAtom(no,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.updateGestureOnPointerDown(t),t.pointerType==="touch"&&this.state.newElement&&this.state.newElement.type==="freedraw"){let m=this.state.newElement;this.updateScene({...m.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(p=>p.id!==m.id)}:{},appState:{newElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:fe(Object.keys(this.state.selectedElementIds).filter(p=>p!==m.id).reduce((p,u)=>(p[u]=this.state.selectedElementIds[u],p),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?mt.EVENTUALLY:mt.NEVER});return}let n=document.getSelection();if(n?.anchorNode&&n.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(m=>({penMode:!0,penDetected:!0})),!this.device.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.device=nf(this.device,{isTouchScreen:!0})),Sl||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===cn.ERASER&&this.state.activeTool.type!==ko.eraser){this.setState({activeTool:Vo(this.state,{type:ko.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let m=()=>{p(),u?.(),Et(this.state)&&this.setState({activeTool:Vo(this.state,{...this.state.activeTool.lastActiveTool||{type:ko.selection},lastActiveToolBeforeEraser:null})})},p=_e(window,ee.POINTER_UP,m,{once:!0}),u;requestAnimationFrame(()=>{u=this.missingPointerEventCleanupEmitter.once(m)})});return}if(t.button!==cn.MAIN&&t.button!==cn.TOUCH&&t.button!==cn.ERASER||pe.pointers.size>1)return;let i=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleDraggingScrollBar(t,i)||(this.clearSelectionIfNotUsingSelection(),this.updateBindingEnabledOnPointerMove(t),this.handleSelectionOnPointerDown(t,i))||!(!this.state.penMode||t.pointerType!=="touch"||this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"||this.state.activeTool.type==="text"||this.state.activeTool.type==="image"))return;this.state.activeTool.type==="lasso"?this.lassoTrail.startPath(i.origin.x,i.origin.y,t.shiftKey):this.state.activeTool.type==="text"?this.handleTextOnPointerDown(t,i):this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line"?this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,i):this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,i):this.state.activeTool.type==="custom"?Dt(this.interactiveCanvas,this.state):this.state.activeTool.type===ko.frame||this.state.activeTool.type===ko.magicframe?this.createFrameElementOnPointerDown(i,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(i.lastCoords.x,i.lastCoords.y):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.state.activeTool.type!=="image"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,i),this.props?.onPointerDown?.(this.state.activeTool,i),this.onPointerDownEmitter.trigger(this.state.activeTool,i,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(i.lastCoords.x,i.lastCoords.y);let l=this.onPointerMoveFromPointerDownHandler(i),s=this.onPointerUpFromPointerDownHandler(i),c=this.onKeyDownFromPointerDownHandler(i),d=this.onKeyUpFromPointerDownHandler(i);this.missingPointerEventCleanupEmitter.once(m=>s(m||t.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener(ee.POINTER_MOVE,l),window.addEventListener(ee.POINTER_UP,s),window.addEventListener(ee.KEYDOWN,c),window.addEventListener(ee.KEYUP,d),i.eventListeners.onMove=l,i.eventListeners.onUp=s,i.eventListeners.onKeyUp=d,i.eventListeners.onKeyDown=c)});I(this,"handleCanvasPointerUp",t=>{this.removePointer(t),this.lastPointerUpEvent=t;let r=Fe({clientX:t.clientX,clientY:t.clientY},this.state),n=t.timeStamp-(this.lastPointerDownEvent?.timeStamp??0);if(this.device.editor.isMobile&&n<300){let i=this.getElementAtPosition(r.x,r.y);if(wl(i)&&this.isIframeLikeElementCenter(i,t,r.x,r.y)){this.handleEmbeddableCenterClick(i);return}}if(this.device.isTouchScreen){let i=this.getElementAtPosition(r.x,r.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(r,i)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?n<300&&wl(this.hitLinkElement)&&!t1(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,ne(r.x,r.y))?this.handleEmbeddableCenterClick(this.hitLinkElement):this.redirectToLink(t,this.device.isTouchScreen):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})});I(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(Ml=!1,Rr?Ml=!0:Rr=window.setTimeout(()=>{Rr=0,Ml||this.handleCanvasContextMenu(t)},iH))});I(this,"resetContextMenuTimer",()=>{clearTimeout(Rr),Rr=0,Ml=!1});I(this,"maybeCleanupAfterMissingPointerUp",t=>{Ll?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});I(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(pe.pointers.size<=1&&(t.button===cn.WHEEL||t.button===cn.MAIN&&un||qt(this.state)||this.state.viewModeEnabled)))return!1;Sl=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let r=!1,n=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);xe(this.interactiveCanvas,De.GRABBING);let{clientX:i,clientY:a}=t,l=td(c=>{let d=i-c.clientX,m=a-c.clientY;if(i=c.clientX,a=c.clientY,n&&!r&&(Math.abs(d)>1||Math.abs(m)>1)){r=!0;let p=f=>{document.body.removeEventListener(ee.PASTE,p),f.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener(ee.PASTE,p),window.removeEventListener(ee.POINTER_UP,u)},100)};document.body.addEventListener(ee.PASTE,p),window.addEventListener(ee.POINTER_UP,u)}this.translateCanvas({scrollX:this.state.scrollX-d/this.state.zoom.value,scrollY:this.state.scrollY-m/this.state.zoom.value})}),s=Pe(Ll=()=>{Ll=null,Sl=!1,un||(this.state.viewModeEnabled?xe(this.interactiveCanvas,De.GRAB):Dt(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(ee.POINTER_MOVE,l),window.removeEventListener(ee.POINTER_UP,s),window.removeEventListener(ee.BLUR,s),l.flush()});return window.addEventListener(ee.BLUR,s),window.addEventListener(ee.POINTER_MOVE,l,{passive:!0}),window.addEventListener(ee.POINTER_UP,s),!0});I(this,"clearSelectionIfNotUsingSelection",()=>{this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.setState({selectedElementIds:fe({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});I(this,"handleSelectionOnPointerDown",(t,r)=>{if(this.state.activeTool.type==="selection"){let n=this.scene.getNonDeletedElements(),i=this.scene.getNonDeletedElementsMap(),a=this.scene.getSelectedElements(this.state);if(a.length===1&&!this.state.selectedLinearElement?.isEditing&&!Ge(a[0])&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let l=TI(n,this.state,r.origin.x,r.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);l!=null&&(l.transformHandleType==="rotation"?(this.setState({resizingElement:l.element}),r.resize.handleType=l.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:l.element}),r.resize.handleType=l.transformHandleType))}else a.length>1&&(r.resize.handleType=II(Xi(a),r.origin.x,r.origin.y,this.state.zoom,t.pointerType,this.device));if(r.resize.handleType)r.resize.isResizing=!0,r.resize.offset=rf(TG(r.resize.handleType,a,i,r.origin.x,r.origin.y)),a.length===1&&$t(a[0])&&a[0].points.length===2&&(r.resize.arrowDirection=IG(r.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement,u=Ce.handlePointerDown(t,this,this.store,r.origin,p,this.scene);if(u.hitElement&&(r.hit.element=u.hitElement),u.linearElementEditor&&this.setState({selectedLinearElement:u.linearElementEditor}),u.didAddPoint)return!0}let l=this.getElementsAtPosition(r.origin.x,r.origin.y,{includeLockedElements:!0}),s=l.filter(p=>!p.locked),c=this.getElementAtPosition(r.origin.x,r.origin.y,{allHitElements:l});if((!c||c.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),c&&c.locked&&!s.some(p=>this.state.selectedElementIds[p.id])?r.hit.element=null:r.hit.element=r.hit.element??this.getElementAtPosition(r.origin.x,r.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(r.origin,c),this.hitLinkElement)return!0;if(this.state.croppingElementId&&r.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),r.hit.element&&this.getElementLinkAtPosition({x:r.origin.x,y:r.origin.y},r.hit.element))return!1;r.hit.allHitElements=s;let d=r.hit.element,m=r.hit.allHitElements.some(p=>this.isASelectedElement(p));if((d===null||!m)&&!t.shiftKey&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&this.clearSelection(d),this.state.selectedLinearElement?.isEditing)this.setState({selectedElementIds:fe({[this.state.selectedLinearElement.elementId]:!0},this.state)});else if(d!=null){if(t[U.CTRL_OR_CMD])return t.altKey||(this.state.selectedElementIds[d.id]||(r.hit.wasAddedToSelection=!0),this.setState(p=>({...bG(p,d),previousSelectedElementIds:this.state.selectedElementIds}))),!1;this.state.selectedElementIds[d.id]||(this.state.editingGroupId&&!yI(d,this.state.editingGroupId)&&this.setState({selectedElementIds:fe({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!m&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(p=>{let u={...p.selectedElementIds,[d.id]:!0},f=[];if(Object.keys(p.selectedElementIds).forEach(b=>{let x=this.scene.getElement(b);x&&f.push(x)}),Zt(d))hI(f,d.id).forEach(b=>{delete u[b.id]});else if(d.frameId)u[d.frameId]&&delete u[d.id];else{let b=d.groupIds,x=new Set(b.flatMap(w=>Il(this.scene.getNonDeletedElements(),w)).filter(w=>Zt(w)).map(w=>w.id));x.size>0&&f.forEach(w=>{w.frameId&&x.has(w.frameId)&&(delete u[w.id],w.groupIds.flatMap(E=>Il(this.scene.getNonDeletedElements(),E)).forEach(E=>{delete u[E.id]}))})}return p.openDialog?.name==="elementLinkSelector"&&(d.groupIds.some(b=>p.selectedGroupIds[b])||(u={[d.id]:!0})),{...po({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:d.link||_r(d)?"info":!1}}),r.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});I(this,"handleTextOnPointerDown",(t,r)=>{if(this.state.editingTextElement)return;let n=r.origin.x,i=r.origin.y,a=this.getElementAtPosition(n,i,{includeBoundTextElement:!0}),l=this.getTextBindableContainerAtPosition(n,i);nI(a)&&(l=a,n=a.x+a.width/2,i=a.y+a.height/2),this.startTextEditing({sceneX:n,sceneY:i,insertAtParentCenter:!t.altKey,container:l,autoEdit:!1}),Ht(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:Vo(this.state,{type:"selection"})})});I(this,"handleFreeDrawElementOnPointerDown",(t,r,n)=>{let[i,a]=nt(n.origin.x,n.origin.y,null),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),s=t.pressure===.5,c=PH({type:r,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:s,locked:!1,frameId:l?l.id:null,points:[ne(0,0)],pressures:s?[]:[t.pressure]});this.scene.insertElement(c),this.setState(m=>{let p={...m.selectedElementIds};return delete p[c.id],{selectedElementIds:fe(p,m)}});let d=af(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom);this.setState({newElement:c,startBoundElement:d,suggestedBindings:[]})});I(this,"insertIframeElement",({sceneX:t,sceneY:r,width:n,height:i})=>{let[a,l]=nt(t,r,this.lastPointerDownEvent?.[U.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=AH({type:"iframe",x:a,y:l,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:n,height:i});return this.scene.insertElement(s),s});I(this,"insertEmbeddableElement",({sceneX:t,sceneY:r,link:n})=>{let[i,a]=nt(t,r,this.lastPointerDownEvent?.[U.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=qd(n);if(!l)return;l.error instanceof URIError&&this.setToast({message:g("toast.unrecognizedLinkFormat"),closable:!0});let s=QT({type:"embeddable",x:i,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("embeddable"),opacity:this.state.currentItemOpacity,locked:!1,width:l.intrinsicSize.w,height:l.intrinsicSize.h,link:n});return this.scene.insertElement(s),s});I(this,"createImageElement",async({sceneX:t,sceneY:r,addToFrameUnderCursor:n=!0,imageFile:i})=>{let[a,l]=nt(t,r,this.lastPointerDownEvent?.[U.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=n?this.getTopLayerFrameAtSceneCoords({x:a,y:l}):null,c=100/this.state.zoom.value,d=RH({type:"image",strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:s?s.id:null,x:a-c/2,y:l-c/2,width:c,height:c});return await this.insertImageElement(d,i)});I(this,"handleLinearElementOnPointerDown",(t,r,n)=>{if(this.state.multiElement){let{multiElement:i}=this.state;if(i.type==="line"&&dI(i.points,this.state.zoom.value)){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(It);return}if(Ge(i)&&i.points.length>1){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(It);return}let{x:a,y:l,lastCommittedPoint:s}=i;if(i.points.length>1&&s&&sn(ne(n.origin.x-a,n.origin.y-l),s)<ef){this.actionManager.executeAction(It);return}this.setState(c=>({selectedElementIds:fe({...c.selectedElementIds,[i.id]:!0},c)})),this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),xe(this.interactiveCanvas,De.POINTER)}else{let[i,a]=nt(n.origin.x,n.origin.y,t[U.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:s,currentItemEndArrowhead:c}=this.state,[d,m]=r==="arrow"?[s,c]:[null,null],p=r==="arrow"?DH({type:r,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemArrowType===Dr.round?{type:Xd.PROPORTIONAL_RADIUS}:null,startArrowhead:d,endArrowhead:m,locked:!1,frameId:l?l.id:null,elbowed:this.state.currentItemArrowType===Dr.elbow,fixedSegments:this.state.currentItemArrowType===Dr.elbow?[]:null}):NH({type:r,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness==="round"?{type:Xd.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:l?l.id:null});this.setState(f=>{let b={...f.selectedElementIds};return delete b[p.id],{selectedElementIds:fe(b,f)}}),this.scene.mutateElement(p,{points:[...p.points,ne(0,0)]});let u=af(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,Ge(p),Ge(p));this.scene.insertElement(p),this.setState({newElement:p,startBoundElement:u,suggestedBindings:[]})}});I(this,"createGenericElementOnPointerDown",(t,r)=>{let[n,i]=nt(r.origin.x,r.origin.y,this.lastPointerDownEvent?.[U.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:n,y:i}),l={x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:a?a.id:null},s;t==="embeddable"?s=QT({type:"embeddable",...l}):s=_H({type:t,...l}),s.type==="selection"?this.setState({selectionElement:s}):(this.scene.insertElement(s),this.setState({multiElement:null,newElement:s}))});I(this,"createFrameElementOnPointerDown",(t,r)=>{let[n,i]=nt(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[U.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:n,y:i,opacity:this.state.currentItemOpacity,locked:!1,...Pr},l=r===ko.magicframe?eI(a):LH(a);this.scene.insertElement(l),this.setState({multiElement:null,newElement:l})});I(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});I(this,"eraseElements",()=>{let t=!1,r=this.scene.getElementsIncludingDeleted().map(n=>this.elementsPendingErasure.has(n.id)||n.frameId&&this.elementsPendingErasure.has(n.frameId)||pf(n)&&this.elementsPendingErasure.has(n.containerId)?(t=!0,mn(n,{isDeleted:!0})):n);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(r))});I(this,"initializeImage",async(t,r)=>{if(!ea(r))throw new Error(g("errors.unsupportedFileType"));let n=r.type,i=r.size>=this.state.dontResizeLimitMBs*1024*1024;if(xe(this.interactiveCanvas,"wait"),n===Ar.svg)try{r=xm(pI(await r.text()),r.name)}catch(s){throw console.warn(s),new Error(g("errors.svgImageInsertError"))}else if(i)try{r=await Ul(r,{maxWidthOrHeight:Vz}),console.info("Excalidraw: image resized")}catch(s){console.error("Error trying to resizing image file on insertion",s)}if(r.size>UT)throw new Error(g("errors.fileTooBig",{maxSize:`${Math.trunc(UT/1024/1024)}MB`}));let a=await(this.props.generateIdForFile?.(r)||h1(r));if(console.info("Excalidraw File ID:",a),!a)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(g("errors.imageInsertError"));let l=this.files[a]?.dataURL||await bm(r);return new Promise(async(s,c)=>{try{let d=this.getLatestInitializedImageElement(t,a);if(this.addMissingFiles([{mimeType:n,id:a,dataURL:l,created:Date.now(),lastRetrieved:Date.now()}]),!this.imageCache.get(a)){this.addNewImagesToImageCache();let{erroredFiles:p}=await this.updateImageCache([d]);if(p.size)throw new Error("Image cache update resulted with an error.")}let m=await this.imageCache.get(a)?.image;if(m&&this.state.newElement?.id!==d.id){d=this.getLatestInitializedImageElement(t,a);let p=this.getImageNaturalDimensions(d,m);Object.assign(d,p)}s(d)}catch(d){console.error(d),c(new Error(g("errors.imageInsertError")))}})});I(this,"getLatestInitializedImageElement",(t,r)=>{let n=this.scene.getElement(t.id)??t;return mn(n,{fileId:r})});I(this,"insertImageElement",async(t,r)=>{if(!this.isToolSupported("image")){this.setState({errorMessage:g("errors.imageToolNotSupported")});return}this.scene.insertElement(t);try{let n=await this.initializeImage(t,r),i=this.scene.getElementsIncludingDeleted().map(a=>a.id===n.id?n:a);return this.updateScene({captureUpdate:mt.IMMEDIATELY,elements:i,appState:{selectedElementIds:fe({[n.id]:!0},this.state)}}),n}catch(n){return this.store.scheduleAction(mt.NEVER),this.scene.mutateElement(t,{isDeleted:!0}),this.actionManager.executeAction(It),this.setState({errorMessage:n.message||g("errors.imageInsertError")}),null}});I(this,"onImageAction",async()=>{try{let t=this.state.width/2+this.state.offsetLeft,r=this.state.height/2+this.state.offsetTop,{x:n,y:i}=Fe({clientX:t,clientY:r},this.state),a=await Rl({description:"Image",extensions:Object.keys(Zz)});await this.addImageElementsToScene({sceneX:n,sceneY:i,addToFrameUnderCursor:!1,files:[a]}),this.setState({},()=>{this.actionManager.executeAction(It)})}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:Vo(this.state,{type:"selection"})},()=>{this.actionManager.executeAction(It)})}});I(this,"getImageNaturalDimensions",(t,r)=>{let n=Math.max(this.state.height-120,160),i=Math.min(n,Math.floor(this.state.height*.5)/this.state.zoom.value),a=Math.min(r.naturalHeight,i),l=a*(r.naturalWidth/r.naturalHeight),s=t.x+t.width/2-l/2,c=t.y+t.height/2-a/2;return{x:s,y:c,width:l,height:a,crop:null}});I(this,"updateImageCache",async(t,r=this.files)=>{let{updatedFiles:n,erroredFiles:i}=await VH({imageCache:this.imageCache,fileIds:t.map(a=>a.fileId),files:r});return i.size&&(this.store.scheduleAction(mt.NEVER),this.scene.replaceAllElements(t.map(a=>yl(a)&&i.has(a.fileId)?mn(a,{status:"error"}):a))),{updatedFiles:n,erroredFiles:i}});I(this,"addNewImagesToImageCache",async(t=WH(this.scene.getNonDeletedElements()),r=this.files)=>{let n=t.filter(i=>!i.isDeleted&&!this.imageCache.has(i.fileId));if(n.length){let{updatedFiles:i}=await this.updateImageCache(n,r);if(i.size)for(let a of n)i.has(a.fileId)&&Tl.delete(a);i.size&&this.scene.triggerUpdate()}});I(this,"scheduleImageRefresh",zz(()=>{this.addNewImagesToImageCache()},$z));I(this,"updateBindingEnabledOnPointerMove",t=>{let r=MH(t);this.state.isBindingEnabled!==r&&this.setState({isBindingEnabled:r})});I(this,"maybeSuggestBindingAtCursor",(t,r)=>{let n=af(t,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,!1,r);this.setState({suggestedBindings:n!=null?[n]:[]})});I(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.interactiveCanvas.addEventListener(ee.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(ee.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener(ee.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(ee.TOUCH_END,this.onTouchEnd))});I(this,"handleAppOnDrop",async t=>{let{files:r,fileHandle:n}=await x1(t),{x:i,y:a}=Fe(t,this.state);if(r===null){console.warn("File is null");return}let l=r?r[0]:null;try{if(r.length>0&&ea(l)&&this.isToolSupported("image")){if(r.length===1&&l.type===Ar.png||l.type===Ar.svg)try{let d=await Gl(l,this.state,this.scene.getElementsIncludingDeleted(),n);this.syncActionResult({...d,appState:{...d.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:mt.IMMEDIATELY});return}catch(d){if(d.name!=="EncodingError")throw new Error(g("alerts.couldNotLoadInvalidFile"))}let c=r.filter(d=>ea(d));if(c.length>0){let d=await this.addImageElementsToScene({sceneX:i,sceneY:a,files:c});this.store.scheduleCapture();let m=Object.assign({},...d.map(u=>({[u.id]:!0})));this.setState({selectedElementIds:fe(m,this.state)});let p=jd(d);MI(this.scene,d,p,this.state.arrangeConfiguration.algorithm,this.state.arrangeConfiguration.gap);return}}}catch(c){return this.setState({isLoading:!1,errorMessage:c.message})}let s=t.dataTransfer.getData(Ar.excalidrawlib);if(s&&typeof s=="string"){try{let c=u1(s);this.addElementsFromPasteOrLibrary({elements:xc(c),position:t,files:null})}catch(c){this.setState({errorMessage:c.message})}return}if(l&&await this.loadFileToCanvas(l,n),t.dataTransfer?.types?.includes("text/plain")){let c=t.dataTransfer?.getData("text");if(c&&gf(c,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(c)||qd(c)?.type==="video")){let d=this.insertEmbeddableElement({sceneX:i,sceneY:a,link:tf(c)});d&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[d.id]:!0}}))}}});I(this,"loadFileToCanvas",async(t,r)=>{t=await y1(t);try{let n=this.scene.getElementsIncludingDeleted(),i;try{i=await gm(t,this.state,n,r)}catch(a){let l=a instanceof Jf;if(l&&a.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:g("errors.imageToolNotSupported")});return}let s=l?g("alerts.cannotRestoreFromImage"):g("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:s})}if(!i)return;i.type===Ar.excalidraw?(DI(n.concat(i.data.elements)),this.store.scheduleMicroAction({action:mt.NEVER,elements:n,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({...i.data,appState:{...i.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:mt.IMMEDIATELY})):i.type===Ar.excalidrawlib&&await this.library.updateLibrary({libraryItems:t,merge:!0,openLibraryMenu:!0}).catch(a=>{console.error(a),this.setState({errorMessage:g("errors.importLibraryError")})})}catch(n){this.setState({isLoading:!1,errorMessage:n.message})}});I(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==cn.SECONDARY)&&this.state.activeTool.type!=="selection")return;let{x:r,y:n}=Fe(t,this.state),i=this.getElementAtPosition(r,n,{preferSelected:!0,includeLockedElements:!0}),a=this.scene.getSelectedElements(this.state),l=this.isHittingCommonBoundingBoxOfSelectedElements({x:r,y:n},a),s=i||l?"element":"canvas",c=this.excalidrawContainerRef.current,{top:d,left:m}=c.getBoundingClientRect(),p=t.clientX-m,u=t.clientY-d;re("contextMenu","openContextMenu",s),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,...po({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:$t(i)?new Ce(i,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:p,items:this.getContextMenuItems(s)}})})});I(this,"maybeDragNewGenericElement",(t,r,n=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&this.state.activeTool.type!=="eraser"){CI({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:Vi(t.origin.x,a.x),height:Vi(t.origin.y,a.y),shouldMaintainAspectRatio:bl(r),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let l=this.state.newElement;if(!l)return;let[s,c]=nt(a.x,a.y,r[U.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=yl(l)&&this.imageCache.get(l.fileId)?.image,m=d&&!(d instanceof Promise)?d.width/d.height:null;this.maybeCacheReferenceSnapPoints(r,[l]);let{snapOffset:p,snapLines:u}=Sw(l,this,r,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:s-t.originInGrid.x,y:c-t.originInGrid.y},this.scene.getNonDeletedElementsMap());s+=p.x,c+=p.y,this.setState({snapLines:u}),CI({newElement:l,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:s,y:c,width:Vi(t.originInGrid.x,s),height:Vi(t.originInGrid.y,c),shouldMaintainAspectRatio:pn(l)?!bl(r):bl(r),shouldResizeFromCenter:zT(r),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:m,originOffset:this.state.originSnapOffset,informMutation:n}),this.setState({newElement:l}),(this.state.activeTool.type===ko.frame||this.state.activeTool.type===ko.magicframe)&&this.setState({elementsToHighlight:Ef(this.scene.getNonDeletedElements(),l,this.state,this.scene.getNonDeletedElementsMap())})});I(this,"maybeHandleCrop",(t,r)=>{if(!this.state.croppingElementId)return!1;let n=t.resize.handleType,i=t.lastCoords,[a,l]=nt(i.x-t.resize.offset.x,i.y-t.resize.offset.y,r[U.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(n&&s&&pn(s)){let c=t.originalElements.get(s.id),d=yl(s)&&this.imageCache.get(s.fileId)?.image;if(c&&pn(c)&&d&&!(d instanceof Promise)){let[m,p]=nt(i.x,i.y,r[U.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:m-t.originInGrid.x,y:p-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(r,[s]);let{snapOffset:f,snapLines:b}=Ph([s],[c],this,r,u,n);this.scene.mutateElement(s,lG(s,this.scene.getNonDeletedElementsMap(),n,d.naturalWidth,d.naturalHeight,a+f.x,l+f.y,r.shiftKey?c.width/c.height:void 0)),sf(s,this.scene,{newSize:{width:s.width,height:s.height}}),this.setState({isCropping:n&&n!=="rotation",snapLines:b})}return!0}return!1});I(this,"maybeHandleResize",(t,r)=>{let n=this.scene.getSelectedElements(this.state),i=n.filter(m=>Zt(m)),a=t.resize.handleType;if(i.length>0&&a==="rotation"||n.length===1&&Ge(n[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let l=t.lastCoords,[s,c]=nt(l.x-t.resize.offset.x,l.y-t.resize.offset.y,r[U.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=new Map;if(i.forEach(m=>{hI(this.scene.getNonDeletedElements(),m.id).forEach(u=>{d.set(m.id+u.id,{x:u.x-m.x,y:u.y-m.y})})}),!this.state.selectedElementsAreBeingDragged){let[m,p]=nt(l.x,l.y,r[U.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:m-t.originInGrid.x,y:p-t.originInGrid.y},f=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(r,n);let{snapOffset:b,snapLines:x}=Ph(n,$(f,this.state),this,r,u,a);s+=b.x,c+=b.y,this.setState({snapLines:x})}if(CG(t.originalElements,a,n,this.scene,Qg(r),zT(r),n.some(m=>pn(m))?!bl(r):bl(r),s,c,t.resize.center.x,t.resize.center.y)){let m=cf(n,this.scene.getNonDeletedElementsMap(),this.state.zoom),p=new Set;return i.forEach(u=>{Ef(this.scene.getNonDeletedElements(),u,this.state,this.scene.getNonDeletedElementsMap()).forEach(f=>p.add(f))}),this.setState({elementsToHighlight:[...p],suggestedBindings:m}),!0}return!1});I(this,"getContextMenuItems",t=>{let r=[];return r.push(rc,oc),t==="canvas"?this.state.viewModeEnabled?[...r,ic,ii,Th,ai]:[nu,He,rc,oc,nc,He,Jm,qE,He,ic,iu,ii,Th,ai]:(r.push(nc),this.state.viewModeEnabled?[ni,...r]:[He,tc,ni,nu,He,nw,iw,aw,He,Eh,He,...r,He,Kp,Zp,He,qp,uw,su,cu,BE,Jp,He,tu,He,Zm,$m,jm,qm,He,ou,ru,He,ki,He,Na,uc,He,hv,Qm,Ba,He,ma])});I(this,"handleWheel",Pe(t=>{if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement)){t[U.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),Sl)return;let{deltaX:r,deltaY:n}=t;if(t.metaKey||t.ctrlKey||this.state.wheelZoomsOnDefault){let i=Math.sign(n),a=lH*100,l=Math.abs(n),s=n;l>a&&(s=a*i);let c=this.state.zoom.value-s/100;c+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,l/20),this.translateCanvas(d=>({...No({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:uo(c)},d),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.translateCanvas(({zoom:i,scrollX:a})=>({scrollX:a-(n||r)/i.value}));return}this.translateCanvas(({zoom:i,scrollX:a,scrollY:l})=>({scrollX:a-r/i.value,scrollY:l-n/i.value}))}));I(this,"savePointer",(t,r,n)=>{if(!t||!r)return;let{x:i,y:a}=Fe({clientX:t,clientY:r},this.state);isNaN(i)||isNaN(a);let l={x:i,y:a,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:l,button:n,pointersMap:pe.pointers})});I(this,"resetShouldCacheIgnoreZoomDebounced",XT(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));I(this,"updateDOMRect",t=>{if(this.excalidrawContainerRef?.current){let r=this.excalidrawContainerRef.current,{width:n,height:i,left:a,top:l}=r.getBoundingClientRect(),{width:s,height:c,offsetTop:d,offsetLeft:m}=this.state;if(n===s&&i===c&&a===m&&l===d){t&&t();return}this.setState({width:n,height:i,offsetLeft:a,offsetTop:l},()=>{t&&t()})}});I(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});let r=bn(),{excalidrawAPI:n,viewModeEnabled:i=!1,zenModeEnabled:a=!1,gridModeEnabled:l=!1,objectsSnapModeEnabled:s=!1,theme:c=r.theme,name:d=`${g("labels.untitled")}-${ZT()}`,wheelZoomsOnDefault:m=!1}=t;if(this.state={...r,theme:c,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:i,zenModeEnabled:a,objectsSnapModeEnabled:s,gridModeEnabled:l??r.gridModeEnabled,name:d,width:window.innerWidth,height:window.innerHeight,wheelZoomsOnDefault:m},this.id=Gz(),this.library=new Ty(this),this.actionManager=new Wc(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new kI,this.canvas=document.createElement("canvas"),this.rc=Hz.canvas(this.canvas),this.renderer=new ol(this.scene),this.visibleElements=[],this.store=new MG(this),this.history=new qa(this.store),n){let p={updateScene:this.updateScene,mutateElement:this.mutateElement,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,addImageElementsToScene:this.addImageElementsToScene,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},scrollToContent:this.scrollToContent,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:u=>{this.actionManager.registerAction(u)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.setCursor,resetCursor:this.resetCursor,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:u=>this.onChangeEmitter.on(u),onIncrement:u=>this.store.onStoreIncrementEmitter.on(u),onPointerDown:u=>this.onPointerDownEmitter.on(u),onPointerUp:u=>this.onPointerUpEmitter.on(u),onScrollChange:u=>this.onScrollChangeEmitter.on(u),onUserFollow:u=>this.onUserFollowEmitter.on(u)};typeof n=="function"?n(p):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new Zo(this.scene),this.history=new qa(this.store),this.actionManager.registerAll(ls),this.actionManager.registerAction(cw(this.history)),this.actionManager.registerAction(dw(this.history))}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let r=null;try{r=JSON.parse(t.data)}catch{}if(r)switch(t.origin){case"https://player.vimeo.com":if(r.method==="paused"){let n=null,i=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!i)break;for(let a of i)a.contentWindow===t.source&&(n=a.contentWindow);n?.postMessage(JSON.stringify({method:r.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(r.event==="infoDelivery"&&r.info&&r.id&&typeof r.info.playerState=="number"){let n=r.id,i=r.info.playerState;Object.values(Zd).includes(i)&&Cf.set(n,i)}break}}cacheEmbeddableRef(t,r){r&&this.iFrameRefs.set(t.id,r)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleEmbeddableCenterClick(t){if(this.state.activeEmbeddable?.element===t&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:t,state:"active"},selectedElementIds:{[t.id]:!0},newElement:null,selectionElement:null})},100),Ki(t)))return;let r=this.getHTMLIFrameElement(t);if(r?.contentWindow){if(r.src.includes("youtube")){let n=Cf.get(t.id);switch(n||(Cf.set(t.id,Zd.UNSTARTED),r.contentWindow.postMessage(JSON.stringify({event:"listening",id:t.id}),"*")),n){case Zd.PLAYING:case Zd.BUFFERING:r.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:r.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}r.src.includes("player.vimeo.com")&&r.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*")}}isIframeLikeElementCenter(t,r,n,i){return t&&!r.altKey&&!r.shiftKey&&!r.metaKey&&!r.ctrlKey&&(this.state.activeEmbeddable?.element!==t||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&n>=t.x+t.width/3&&n<=t.x+2*t.width/3&&i>=t.y+t.height/3&&i<=t.y+2*t.height/3}renderEmbeddables(){let t=this.state.zoom.value,r=this.state.width,n=this.state.height,i=this.scene.getNonDeletedElements().filter(a=>_r(a)&&this.embedsValidationStatus.get(a.id)===!0||Ki(a));return ue(DG,{children:i.map(a=>{let{x:l,y:s}=$d({sceneX:a.x,sceneY:a.y},this.state),c=sI(a,r,n,this.state,this.scene.getNonDeletedElementsMap()),d=this.initializedEmbeds.has(a.id);if(c&&!d&&this.initializedEmbeds.add(a.id),!(c||d))return null;let p;if(Ki(a)){p=null;let b=(a.customData?.generationData??this.magicGenerations.get(a.id))||{status:"error",message:"No generation data",code:"ERR_NO_GENERATION_DATA"};if(b.status==="done"){let x=b.html;p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>x}}else if(b.status==="pending")p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>mI(`
19
26
  <style>
20
27
  html, body {
21
28
  width: 100%;
22
29
  height: 100%;
23
- color: ${this.state.theme===re.DARK?"white":"black"};
30
+ color: ${this.state.theme===Kd.DARK?"white":"black"};
24
31
  }
25
32
  body {
26
33
  display: flex;
@@ -87,7 +94,7 @@ TTD mermaid definition render errror: ${R.message}`,"color: yellow"),me("ai","me
87
94
  </svg>
88
95
  </div>
89
96
  <div>Generating...</div>
90
- `)};else{let x;b.code==="ERR_GENERATION_INTERRUPTED"?x="Generation was interrupted...":x=b.message||"Generation failed",p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>Np(`
97
+ `)};else{let x;b.code==="ERR_GENERATION_INTERRUPTED"?x="Generation was interrupted...":x=b.message||"Generation failed",p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>mI(`
91
98
  <style>
92
99
  html, body {
93
100
  height: 100%;
@@ -97,7 +104,7 @@ TTD mermaid definition render errror: ${R.message}`,"color: yellow"),me("ai","me
97
104
  flex-direction: column;
98
105
  align-items: center;
99
106
  justify-content: center;
100
- color: ${bo.red[3]};
107
+ color: ${Yz.red[3]};
101
108
  }
102
109
  h1, h3 {
103
110
  margin-top: 0;
@@ -106,7 +113,7 @@ TTD mermaid definition render errror: ${R.message}`,"color: yellow"),me("ai","me
106
113
  </style>
107
114
  <h1>Error!</h1>
108
115
  <h3>${x}</h3>
109
- `)}}}else p=Qn($s(a.link||""));let u=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="active",f=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="hover";return Se("div",{className:t5("excalidraw__embeddable-container",{"is-hovered":f}),style:{transform:c?`translate(${l-this.state.offsetLeft}px, ${s-this.state.offsetTop}px) scale(${t})`:"none",display:c?"block":"none",opacity:x0(a,jn(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?t1:1),"--embeddable-radius":`${I1(Math.min(a.width,a.height),a)}px`},children:Um("div",{className:"excalidraw__embeddable-container__inner",style:{width:c?`${a.width}px`:0,height:c?`${a.height}px`:0,transform:c?`rotate(${a.angle}rad)`:"none",pointerEvents:u?zn.enabled:zn.disabled},children:[f&&Se("div",{className:"excalidraw__embeddable-hint",children:g("buttons.embeddableInteractionButton")}),Se("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:(zt(a)?this.props.renderEmbeddable?.(a,this.state):null)??Se("iframe",{ref:b=>this.cacheEmbeddableRef(a,b),className:"excalidraw__embeddable",srcDoc:p?.type==="document"?p.srcdoc(this.state.theme):void 0,src:p?.type!=="document"?p?.link??"":void 0,scrolling:"no",referrerPolicy:"no-referrer-when-downgrade",title:"Excalidraw Embedded Content",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,sandbox:`${p?.sandbox?.allowSameOrigin?"allow-same-origin":""} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})]})},a.id)})})}toggleOverscrollBehavior(t){document.documentElement.style.overscrollBehaviorX=t.type==="pointerenter"?"none":"auto"}render(){let t=this.scene.getSelectedElements(this.state),{renderTopRightUI:r,renderCustomStats:n}=this.props,i=this.scene.getSceneNonce(),{elementsMap:a,visibleElements:l}=this.renderer.getRenderableElements({sceneNonce:i,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,newElementId:this.state.newElement?.id});this.visibleElements=l;let s=this.scene.getNonDeletedElementsMap(),c="setPointerCapture"in HTMLElement.prototype?!1:this.state.selectionElement||this.state.newElement||this.state.selectedElementsAreBeingDragged||this.state.resizingElement||this.state.activeTool.type==="laser"&&this.state.cursorButton==="down",m=t[0],d=wt.get(qo)?.type==="panel";return Se("div",{className:t5("excalidraw excalidraw-container",{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.device.editor.isMobile}),style:{"--ui-pointerEvents":c?zn.disabled:zn.enabled,"--right-sidebar-width":"302px"},ref:this.excalidrawContainerRef,onDrop:this.handleAppOnDrop,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally?void 0:this.onKeyDown,onPointerEnter:this.toggleOverscrollBehavior,onPointerLeave:this.toggleOverscrollBehavior,children:Se(n5.Provider,{value:this,children:Se(i5.Provider,{value:this.props,children:Se(af.Provider,{value:this.excalidrawContainerValue,children:Se(nf.Provider,{value:this.device,children:Se(cf.Provider,{value:this.setAppState,children:Se(sf.Provider,{value:this.state,children:Um(lf.Provider,{value:this.scene.getNonDeletedElements(),children:[Um(df.Provider,{value:this.actionManager,children:[Se(G3,{canvas:this.canvas,appState:this.state,files:this.files,setAppState:this.setAppState,actionManager:this.actionManager,elements:this.scene.getNonDeletedElements(),onLockToggle:this.toggleLock,onPenModeToggle:this.togglePenMode,onHandToolToggle:this.onHandToolToggle,langCode:Ir().code,renderTopRightUI:r,renderCustomStats:n,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==="selection"&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,children:this.props.children}),Se("div",{className:"excalidraw-textEditorContainer"}),Se("div",{className:"excalidraw-contextMenuContainer"}),Se("div",{className:"excalidraw-eye-dropper-container"}),Se(V3,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail]}),t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&Se(B2,{element:m,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},m.id),this.props.aiEnabled!==!1&&t.length===1&&js(m)&&Se(mg,{element:m,elementsMap:a,children:Se(Fm,{title:g("labels.convertToCode"),icon:Zx,checked:!1,onChange:()=>this.onMagicFrameGenerate(m,"button")})}),t.length===1&&Vn(m)&&m.customData?.generationData?.status==="done"&&Um(mg,{element:m,elementsMap:a,children:[Se(Fm,{title:g("labels.copySource"),icon:oa,checked:!1,onChange:()=>this.onIframeSrcCopy(m)}),Se(Fm,{title:"Enter fullscreen",icon:Xx,checked:!1,onChange:()=>{let p=this.getHTMLIFrameElement(m);if(p)try{p.requestFullscreen(),this.setState({activeEmbeddable:{element:m,state:"active"},selectedElementIds:{[m.id]:!0},newElement:null,selectionElement:null})}catch(u){console.warn(u),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),this.state.toast!==null&&Se(Q3,{message:this.state.toast.message,onClose:()=>this.setToast(null),duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&Se(Wv,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:p=>{this.setState({contextMenu:null},()=>{this.focusContainer(),p?.()})}}),Se(Qg,{canvas:this.canvas,rc:this.rc,elementsMap:a,allElementsMap:s,visibleElements:l,sceneNonce:i,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:Tn(this),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowChartCreator.pendingNodes}}),this.state.newElement&&Se(q3,{appState:this.state,scale:window.devicePixelRatio,rc:this.rc,elementsMap:a,allElementsMap:s,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null}}),Se(Jg,{containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:a,visibleElements:l,allElementsMap:s,selectedElements:t,sceneNonce:i,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderScrollbars:this.props.renderScrollbars===!0,device:this.device,renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.state.userToFollow&&Se(Kv,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames(),this.state.activeLockedId&&Se(e5,{app:this,activeLockedId:this.state.activeLockedId}),d&&Se(K2,{app:this})]}),this.renderEmbeddables()]})})})})})})})})}setPlugins(t){Object.assign(this.plugins,t)}async onMagicFrameGenerate(t,r){let n=this.plugins.diagramToCode?.generate;if(!n){this.setState({errorMessage:"No diagram to code plugin found"});return}let i=mc(this.scene.getNonDeletedElements(),t).filter(l=>!js(l));if(!i.length){r==="button"?(this.setState({errorMessage:"Cannot generate from an empty frame"}),me("ai","generate (no-children)","d2c")):this.setActiveTool({type:"magicframe"});return}let a=this.insertIframeElement({sceneX:t.x+t.width+30,sceneY:t.y,width:t.width,height:t.height});if(a){this.updateMagicGeneration({frameElement:a,data:{status:"pending"}}),this.setState({selectedElementIds:{[a.id]:!0}}),me("ai","generate (start)","d2c");try{let{html:l}=await n({frame:t,children:i});if(me("ai","generate (success)","d2c"),!l.trim()){this.updateMagicGeneration({frameElement:a,data:{status:"error",code:"ERR_OAI",message:"Nothing genereated :("}});return}let s=l.includes("<!DOCTYPE html>")&&l.includes("</html>")?l.slice(l.indexOf("<!DOCTYPE html>"),l.indexOf("</html>")+7):l;this.updateMagicGeneration({frameElement:a,data:{status:"done",html:s}})}catch(l){me("ai","generate (failed)","d2c"),this.updateMagicGeneration({frameElement:a,data:{status:"error",code:"ERR_OAI",message:l.message||"Unknown error during generation"}})}}}onIframeSrcCopy(t){t.customData?.generationData?.status==="done"&&(jo(t.customData.generationData.html),this.setToast({message:"copied to clipboard",closable:!1,duration:1500}))}clearImageShapeCache(t){let r=t??this.files;this.scene.getNonDeletedElements().forEach(n=>{wr(n)&&r[n.fileId]&&(this.imageCache.delete(n.fileId),To.delete(n))})}async componentDidMount(){if(this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,rr()||ft()){let n=this.setState.bind(this);Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...i)=>this.setState(...i)},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(n=>{this.history.record(n.delta)});let{onIncrement:t}=this.props;t&&this.store.onStoreIncrementEmitter.on(n=>{t(n)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),rr()||(this.refreshViewportBreakpoints(),this.refreshEditorBreakpoints()),Xa&&this.excalidrawContainerRef.current&&(this.resizeObserver=new ResizeObserver(()=>{this.refreshEditorBreakpoints(),this.updateDOMRect()}),this.resizeObserver?.observe(this.excalidrawContainerRef.current)),new URLSearchParams(window.location.search.slice(1)).has("web-share-target")?this.restoreFileFromShare():this.updateDOMRect(this.initializeScene),Nf()&&!G1()&&this.setState({errorMessage:Se(Hv,{})})}componentWillUnmount(){window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new fl,this.fonts=new on(this.scene),this.renderer=new as(this.scene),this.files={},this.imageCache.clear(),this.resizeObserver?.disconnect(),this.unmounted=!0,this.removeEventListeners(),this.library.destroy(),this.laserTrails.stop(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),this.store.onStoreIncrementEmitter.clear(),this.store.onDurableIncrementEmitter.clear(),To.destroy(),Po.destroy(),clearTimeout(Pn),De.clearCache(),it.clearCache(),Pn=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(Fe(document,"keydown",this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(Fe(this.excalidrawContainerRef.current,"wheel",this.handleWheel,{passive:!1}),Fe(window,"message",this.onWindowMessage,!1),Fe(document,"pointerup",this.removePointer,{passive:!1}),Fe(document,"copy",this.onCopy,{passive:!1}),Fe(document,"keyup",this.onKeyUp,{passive:!0}),Fe(document,"pointermove",this.updateCurrentCursorPosition,{passive:!1}),Fe(document.fonts,"loadingdone",t=>{let r=t.fontfaces;this.fonts.onLoaded(r)},{passive:!1}),Fe(document,"gesturestart",this.onGestureStart,!1),Fe(document,"gesturechange",this.onGestureChange,!1),Fe(document,"gestureend",this.onGestureEnd,!1),Fe(window,"focus",()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(Fe(document,"fullscreenchange",this.onFullscreenChange,{passive:!1}),Fe(document,"paste",this.pasteFromClipboard,{passive:!1}),Fe(document,"cut",this.onCut,{passive:!1}),Fe(window,"resize",this.onResize,!1),Fe(window,"unload",this.onUnload,!1),Fe(window,"blur",this.onBlur,!1),Fe(this.excalidrawContainerRef.current,"wheel",this.handleWheel,{passive:!1}),Fe(this.excalidrawContainerRef.current,"dragover",this.disableEvent,!1),Fe(this.excalidrawContainerRef.current,"drop",this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(Fe(f1(this.excalidrawContainerRef.current),"scroll",this.onScroll,{passive:!1})))}componentDidUpdate(t,r){this.updateEmbeddables();let n=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted();!this.state.showWelcomeScreen&&!n.length&&this.setState({showWelcomeScreen:!0}),t.UIOptions.dockedSidebarBreakpoint!==this.props.UIOptions.dockedSidebarBreakpoint&&this.refreshEditorBreakpoints(),r.userToFollow&&!this.state.collaborators.has(r.userToFollow.socketId)&&this.maybeUnfollowRemoteUser(),(r.zoom.value!==this.state.zoom.value||r.scrollX!==this.state.scrollX||r.scrollY!==this.state.scrollY)&&(this.props?.onScrollChange?.(this.state.scrollX,this.state.scrollY,this.state.zoom),this.onScrollChangeEmitter.trigger(this.state.scrollX,this.state.scrollY,this.state.zoom)),r.userToFollow!==this.state.userToFollow&&(r.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:r.userToFollow,action:"UNFOLLOW"}),this.state.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:this.state.userToFollow,action:"FOLLOW"})),Object.keys(this.state.selectedElementIds).length&&Jt(this.state)&&this.setState({activeTool:Le(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&r.theme!==this.state.theme&&nh(this.interactiveCanvas,this.state.theme),r.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),t.langCode!==this.props.langCode&&this.updateLanguage(),Jt(r)&&!Jt(this.state)&&this.eraserTrail.endPath(),t.viewModeEnabled!==this.props.viewModeEnabled&&this.setState({viewModeEnabled:!!this.props.viewModeEnabled}),r.viewModeEnabled!==this.state.viewModeEnabled&&(this.addEventListeners(),this.deselectElements()),(r.openDialog?.name==="elementLinkSelector"||this.state.openDialog?.name==="elementLinkSelector")&&r.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),t.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),t.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===re.DARK),this.state.editingLinearElement&&!this.state.selectedElementIds[this.state.editingLinearElement.elementId]&&setTimeout(()=>{this.state.editingLinearElement&&this.actionManager.executeAction(Ut)}),this.state.editingTextElement?.isDeleted&&this.setState({editingTextElement:null}),this.state.selectedLinearElement&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&this.setState({selectedLinearElement:null}),this.store.commit(i,this.state),this.state.isLoading||(this.props.onChange?.(n,this.state,this.files),this.onChangeEmitter.trigger(n,this.state,this.files))}static resetTapTwice(){bs=!1}async addElementsFromMixedContentPaste(t,{isPlainPaste:r,sceneX:n,sceneY:i}){if(!r&&t.some(a=>a.type==="imageUrl")&&this.isToolSupported("image")){let a=t.filter(p=>p.type==="imageUrl").map(p=>p.value),l=await Promise.all(a.map(async p=>{try{return{file:await vb(p)}}catch(u){let f=u.message;return u.cause==="FETCH_ERROR"?f=g("errors.failedToFetchImage"):u.cause==="UNSUPPORTED"&&(f=g("errors.unsupportedFileType")),{errorMessage:f}}})),s=i,c=!1,m={};for(let p of l)if(p.file){let u=this.createImageElement({sceneX:n,sceneY:s}),f=await this.insertImageElement(u,p.file);f&&(c||(c=!0,s-=f.height/2),this.scene.mutateElement(f,{y:s},{informMutation:!1,isDragging:!1}),s=u.y+u.height+25,m[u.id]=!0)}this.setState({selectedElementIds:Te(m,this.state)});let d=l.find(p=>!!p.errorMessage);d&&d.errorMessage&&this.setState({errorMessage:d.errorMessage})}else{let a=t.filter(l=>l.type==="text");a.length&&this.addTextFromPaste(a.map(l=>l.value).join(`
116
+ `)}}}else p=qd(uH(a.link||""));let u=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="active",f=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="hover";return ue("div",{className:DT("excalidraw__embeddable-container",{"is-hovered":f}),style:{transform:c?`translate(${l-this.state.offsetLeft}px, ${s-this.state.offsetTop}px) scale(${t})`:"none",display:c?"block":"none",opacity:fG(a,yf(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?dH:1),"--embeddable-radius":`${UH(Math.min(a.width,a.height),a)}px`},children:Qd("div",{className:"excalidraw__embeddable-container__inner",style:{width:c?`${a.width}px`:0,height:c?`${a.height}px`:0,transform:c?`rotate(${a.angle}rad)`:"none",pointerEvents:u?Wi.enabled:Wi.disabled},children:[f&&ue("div",{className:"excalidraw__embeddable-hint",children:g("buttons.embeddableInteractionButton")}),ue("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:(_r(a)?this.props.renderEmbeddable?.(a,this.state):null)??ue("iframe",{ref:b=>this.cacheEmbeddableRef(a,b),className:"excalidraw__embeddable",srcDoc:p?.type==="document"?p.srcdoc(this.state.theme):void 0,src:p?.type!=="document"?p?.link??"":void 0,scrolling:"no",referrerPolicy:"no-referrer-when-downgrade",title:"Excalidraw Embedded Content",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,sandbox:`${p?.sandbox?.allowSameOrigin?"allow-same-origin":""} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})]})},a.id)})})}toggleOverscrollBehavior(t){document.documentElement.style.overscrollBehaviorX=t.type==="pointerenter"?"none":"auto"}render(){let t=this.scene.getSelectedElements(this.state),{renderTopRightUI:r,renderCustomStats:n}=this.props,i=this.scene.getSceneNonce(),{elementsMap:a,visibleElements:l}=this.renderer.getRenderableElements({sceneNonce:i,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,newElementId:this.state.newElement?.id});this.visibleElements=l;let s=this.scene.getNonDeletedElementsMap(),c="setPointerCapture"in 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=t[0],m=Ke.get(no)?.type==="panel";return ue("div",{className:DT("excalidraw excalidraw-container",{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.device.editor.isMobile}),style:{"--ui-pointerEvents":c?Wi.disabled:Wi.enabled,"--right-sidebar-width":"302px"},ref:this.excalidrawContainerRef,onDrop:this.handleAppOnDrop,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally?void 0:this.onKeyDown,onPointerEnter:this.toggleOverscrollBehavior,onPointerLeave:this.toggleOverscrollBehavior,children:ue(_I.Provider,{value:this,children:ue(RI.Provider,{value:this.props,children:ue(Lf.Provider,{value:this.excalidrawContainerValue,children:ue(Mf.Provider,{value:this.device,children:ue(Df.Provider,{value:this.setAppState,children:ue(Af.Provider,{value:this.state,children:Qd(Pf.Provider,{value:this.scene.getNonDeletedElements(),children:[Qd(_f.Provider,{value:this.actionManager,children:[ue(fT,{canvas:this.canvas,appState:this.state,files:this.files,setAppState:this.setAppState,actionManager:this.actionManager,elements:this.scene.getNonDeletedElements(),onLockToggle:this.toggleLock,onPenModeToggle:this.togglePenMode,onHandToolToggle:this.onHandToolToggle,langCode:Po().code,renderTopRightUI:r,renderCustomStats:n,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==="selection"&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,children:this.props.children}),ue("div",{className:"excalidraw-textEditorContainer"}),ue("div",{className:"excalidraw-contextMenuContainer"}),ue("div",{className:"excalidraw-eye-dropper-container"}),ue(ET,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail]}),t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&ue(YE,{element:d,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},d.id),this.props.aiEnabled!==!1&&t.length===1&&uf(d)&&ue(Yh,{element:d,elementsMap:a,children:ue(Wd,{title:g("labels.convertToCode"),icon:V0,checked:!1,onChange:()=>this.onMagicFrameGenerate(d,"button")})}),t.length===1&&Ki(d)&&d.customData?.generationData?.status==="done"&&Qd(Yh,{element:d,elementsMap:a,children:[ue(Wd,{title:g("labels.copySource"),icon:Dn,checked:!1,onChange:()=>this.onIframeSrcCopy(d)}),ue(Wd,{title:"Enter fullscreen",icon:X0,checked:!1,onChange:()=>{let p=this.getHTMLIFrameElement(d);if(p)try{p.requestFullscreen(),this.setState({activeEmbeddable:{element:d,state:"active"},selectedElementIds:{[d.id]:!0},newElement:null,selectionElement:null})}catch(u){console.warn(u),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),this.state.toast!==null&&ue(PT,{message:this.state.toast.message,onClose:this.handleToastClose,duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&ue(Mv,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:p=>{this.setState({contextMenu:null},()=>{this.focusContainer(),p?.()})}}),ue(jg,{canvas:this.canvas,rc:this.rc,elementsMap:a,allElementsMap:s,visibleElements:l,sceneNonce:i,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:fr(this),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowChartCreator.pendingNodes}}),this.state.newElement&&ue(MT,{appState:this.state,scale:window.devicePixelRatio,rc:this.rc,elementsMap:a,allElementsMap:s,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null}}),ue($g,{containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:a,visibleElements:l,allElementsMap:s,selectedElements:t,sceneNonce:i,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderScrollbars:this.props.renderScrollbars===!0,device:this.device,renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.state.userToFollow&&ue(Pv,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames(),this.state.activeLockedId&&ue(AT,{app:this,activeLockedId:this.state.activeLockedId}),m&&ue(ay,{app:this})]}),this.renderEmbeddables()]})})})})})})})})}setPlugins(t){Object.assign(this.plugins,t)}async onMagicFrameGenerate(t,r){let n=this.plugins.diagramToCode?.generate;if(!n){this.setState({errorMessage:"No diagram to code plugin found"});return}let i=eG(this.scene.getNonDeletedElements(),t).filter(l=>!uf(l));if(!i.length){r==="button"?(this.setState({errorMessage:"Cannot generate from an empty frame"}),re("ai","generate (no-children)","d2c")):this.setActiveTool({type:"magicframe"});return}let a=this.insertIframeElement({sceneX:t.x+t.width+30,sceneY:t.y,width:t.width,height:t.height});if(a){this.updateMagicGeneration({frameElement:a,data:{status:"pending"}}),this.setState({selectedElementIds:{[a.id]:!0}}),re("ai","generate (start)","d2c");try{let{html:l}=await n({frame:t,children:i});if(re("ai","generate (success)","d2c"),!l.trim()){this.updateMagicGeneration({frameElement:a,data:{status:"error",code:"ERR_OAI",message:"Nothing genereated :("}});return}let s=l.includes("<!DOCTYPE html>")&&l.includes("</html>")?l.slice(l.indexOf("<!DOCTYPE html>"),l.indexOf("</html>")+7):l;this.updateMagicGeneration({frameElement:a,data:{status:"done",html:s}})}catch(l){re("ai","generate (failed)","d2c"),this.updateMagicGeneration({frameElement:a,data:{status:"error",code:"ERR_OAI",message:l.message||"Unknown error during generation"}})}}}onIframeSrcCopy(t){t.customData?.generationData?.status==="done"&&(oo(t.customData.generationData.html),this.setToast({message:"copied to clipboard",closable:!1,duration:1500}))}clearImageShapeCache(t){let r=t??this.files;this.scene.getNonDeletedElements().forEach(n=>{yl(n)&&r[n.fileId]&&(this.imageCache.delete(n.fileId),Tl.delete(n))})}async componentDidMount(){if(this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,Sf()||AI()){let n=this.setState.bind(this);Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...i)=>this.setState(...i)},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(n=>{this.history.record(n.delta)});let{onIncrement:t}=this.props;t&&this.store.onStoreIncrementEmitter.on(n=>{t(n)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),Sf()||(this.refreshViewportBreakpoints(),this.refreshEditorBreakpoints()),YT&&this.excalidrawContainerRef.current&&(this.resizeObserver=new ResizeObserver(()=>{this.refreshEditorBreakpoints(),this.updateDOMRect()}),this.resizeObserver?.observe(this.excalidrawContainerRef.current)),new URLSearchParams(window.location.search.slice(1)).has("web-share-target")?this.restoreFileFromShare():this.updateDOMRect(this.initializeScene),jz()&&!dG()&&this.setState({errorMessage:ue(Iv,{})})}componentWillUnmount(){window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new kI,this.fonts=new Zo(this.scene),this.renderer=new ol(this.scene),this.files={},this.imageCache.clear(),this.resizeObserver?.disconnect(),this.unmounted=!0,this.removeEventListeners(),this.library.destroy(),this.laserTrails.stop(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),this.store.onStoreIncrementEmitter.clear(),this.store.onDurableIncrementEmitter.clear(),Tl.destroy(),Wt.destroy(),clearTimeout(Rr),Ee.clearCache(),po.clearCache(),Rr=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(_e(document,ee.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(_e(this.excalidrawContainerRef.current,ee.WHEEL,this.handleWheel,{passive:!1}),_e(window,ee.MESSAGE,this.onWindowMessage,!1),_e(document,ee.POINTER_UP,this.removePointer,{passive:!1}),_e(document,ee.COPY,this.onCopy,{passive:!1}),_e(document,ee.KEYUP,this.onKeyUp,{passive:!0}),_e(document,ee.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),_e(document.fonts,"loadingdone",t=>{let r=t.fontfaces;this.fonts.onLoaded(r)},{passive:!1}),_e(document,ee.GESTURE_START,this.onGestureStart,!1),_e(document,ee.GESTURE_CHANGE,this.onGestureChange,!1),_e(document,ee.GESTURE_END,this.onGestureEnd,!1),_e(window,ee.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(_e(document,ee.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),_e(document,ee.PASTE,this.pasteFromClipboard,{passive:!1}),_e(document,ee.CUT,this.onCut,{passive:!1}),_e(window,ee.RESIZE,this.onResize,!1),_e(window,ee.UNLOAD,this.onUnload,!1),_e(window,ee.BLUR,this.onBlur,!1),_e(this.excalidrawContainerRef.current,ee.WHEEL,this.handleWheel,{passive:!1}),_e(this.excalidrawContainerRef.current,ee.DRAG_OVER,this.disableEvent,!1),_e(this.excalidrawContainerRef.current,ee.DROP,this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(_e(hH(this.excalidrawContainerRef.current),ee.SCROLL,this.onScroll,{passive:!1})))}componentDidUpdate(t,r){this.updateEmbeddables();let n=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted();!this.state.showWelcomeScreen&&!n.length&&this.setState({showWelcomeScreen:!0}),t.UIOptions.dockedSidebarBreakpoint!==this.props.UIOptions.dockedSidebarBreakpoint&&this.refreshEditorBreakpoints(),r.userToFollow&&!this.state.collaborators.has(r.userToFollow.socketId)&&this.maybeUnfollowRemoteUser(),(r.zoom.value!==this.state.zoom.value||r.scrollX!==this.state.scrollX||r.scrollY!==this.state.scrollY)&&(this.props?.onScrollChange?.(this.state.scrollX,this.state.scrollY,this.state.zoom),this.onScrollChangeEmitter.trigger(this.state.scrollX,this.state.scrollY,this.state.zoom)),r.userToFollow!==this.state.userToFollow&&(r.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:r.userToFollow,action:"UNFOLLOW"}),this.state.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:this.state.userToFollow,action:"FOLLOW"})),Object.keys(this.state.selectedElementIds).length&&Et(this.state)&&this.setState({activeTool:Vo(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&r.theme!==this.state.theme&&_p(this.interactiveCanvas,this.state.theme),r.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),t.langCode!==this.props.langCode&&this.updateLanguage(),Et(r)&&!Et(this.state)&&this.eraserTrail.endPath(),t.viewModeEnabled!==this.props.viewModeEnabled&&this.setState({viewModeEnabled:!!this.props.viewModeEnabled}),r.viewModeEnabled!==this.state.viewModeEnabled&&(this.addEventListeners(),this.deselectElements()),(r.openDialog?.name==="elementLinkSelector"||this.state.openDialog?.name==="elementLinkSelector")&&r.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),t.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),t.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===Kd.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(It)}),this.state.editingTextElement?.isDeleted&&this.setState({editingTextElement:null}),this.state.selectedLinearElement&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&this.setState({selectedLinearElement:null}),this.store.commit(i,this.state),this.state.isLoading||(this.props.onChange?.(n,this.state,this.files),this.onChangeEmitter.trigger(n,this.state,this.files))}static resetTapTwice(){Cl=!1}async addElementsFromMixedContentPaste(t,{isPlainPaste:r,sceneX:n,sceneY:i}){if(!r&&t.some(a=>a.type==="imageUrl")&&this.isToolSupported("image")){let a=t.filter(p=>p.type==="imageUrl").map(p=>p.value),l=await Promise.all(a.map(async p=>{try{return{file:await b1(p)}}catch(u){let f=u.message;return u.cause==="FETCH_ERROR"?f=g("errors.failedToFetchImage"):u.cause==="UNSUPPORTED"&&(f=g("errors.unsupportedFileType")),{errorMessage:f}}})),s=i,c=!1,d={};for(let p of l)if(p.file){let u=await this.addImageElementsToScene({sceneX:n,sceneY:s,files:[p.file]});if(u.length>0){let f=u[0];c||(c=!0,s-=f.height/2),this.scene.mutateElement(f,{y:s},{informMutation:!1,isDragging:!1}),s=f.y+f.height+25,d[f.id]=!0}}this.setState({selectedElementIds:fe(d,this.state)});let m=l.find(p=>!!p.errorMessage);m&&m.errorMessage&&this.setState({errorMessage:m.errorMessage})}else{let a=t.filter(l=>l.type==="text");a.length&&this.addTextFromPaste(a.map(l=>l.value).join(`
110
117
 
111
- `),r)}}addTextFromPaste(t,r=!1){let{x:n,y:i}=ze({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),a={x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roundness:null,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:t,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:As,verticalAlign:jm,locked:!1},l=et({fontSize:a.fontSize,fontFamily:a.fontFamily}),s=zo(a.fontFamily),[c,,m]=_p(this.state),d=Math.max(Math.min((m-c)*.5,800),200),p=10,u=i,f=r?[t]:t.split(`
112
- `),b=f.reduce((x,E,y)=>{let v=Zn(E).trim();if(v.length){let T=this.getTopLayerFrameAtSceneCoords({x:n,y:u}),I=vt(v,l,s),S=I.width>d,P=S?Ai(v,l,d):v;I=S?vt(P,l,s):I;let M=n-I.width/2,O=u-I.height/2,R=Ft({...a,x:M,y:O,text:P,originalText:v,lineHeight:s,autoResize:!S,frameId:T?T.id:null});x.push(R),u+=R.height+p}else f[y-1]?.trim()&&(u+=Y1(a.fontSize,s)+p);return x},[]);b.length!==0&&(this.scene.insertElements(b),this.store.scheduleCapture(),this.setState({selectedElementIds:Te(Object.fromEntries(b.map(x=>[x.id,!0])),this.state)}),!r&&b.length>1&&r5===!1&&!this.device.editor.isMobile&&(this.setToast({message:g("toast.pasteAsSingleElement",{shortcut:D("CtrlOrCmd+Shift+V")}),duration:5e3}),r5=!0))}handleTextWysiwyg(t,{isExistingElement:r=!1}){let n=this.scene.getElementsMapIncludingDeleted(),i=(a,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(s=>s.id===t.id&&V(s)?te(s,{originalText:a,isDeleted:l??s.isDeleted,...N0(s,vo(s,n),n,a)}):s)])};Rv({id:t.id,canvas:this.canvas,getViewportCoords:(a,l)=>{let{x:s,y:c}=gt({sceneX:a,sceneY:l},this.state);return[s-this.state.offsetLeft,c-this.state.offsetTop]},onChange:$e(a=>{i(a,!1),Yp(t)&&$r(t,this.scene)}),onSubmit:$e(({viaKeyboard:a,nextOriginalText:l})=>{let s=!l.trim();if(i(l,s),!s&&a){let c=t.containerId?t.containerId:t.id;Br(()=>{this.setState(m=>({selectedElementIds:Te({...m.selectedElementIds,[c]:!0},m)}))})}s&&nc(this.scene.getNonDeletedElements(),[t]),(!s||r)&&this.store.scheduleCapture(),Br(()=>{this.setState({newElement:null,editingTextElement:null})}),this.state.activeTool.locked&&ho(this.interactiveCanvas,this.state),this.focusContainer()}),element:t,excalidrawContainer:this.excalidrawContainerRef.current,app:this,autoSelect:!this.device.isTouchScreen}),this.deselectElements(),i(t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:Te({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(t,r){let n=this.getElementAtPosition(t,r,{includeBoundTextElement:!0});return n&&V(n)&&!n.isDeleted?n:null}getElementAtPosition(t,r,n){let i=[];if(n&&"allHitElements"in n?i=n?.allHitElements||[]:i=this.getElementsAtPosition(t,r,{includeBoundTextElement:n?.includeBoundTextElement,includeLockedElements:n?.includeLockedElements}),i.length>1){if(n?.preferSelected){for(let l=i.length-1;l>-1;l--)if(this.state.selectedElementIds[i[l].id])return i[l]}let a=i[i.length-1];return Pi({point:L(t,r),element:a,threshold:this.getElementHitThreshold(a)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:ce(a)?this.frameNameBoundsCache.get(a):null})?a:i[i.length-2]}return i.length===1?i[0]:null}getElementsAtPosition(t,r,n){let i=[],a=this.scene.getNonDeletedElementsMap();return(n?.includeBoundTextElement&&n?.includeLockedElements?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(s=>(n?.includeLockedElements||!s.locked)&&(n?.includeBoundTextElement||!(V(s)&&s.containerId)))).filter(s=>this.hitElement(t,r,s)).filter(s=>{let c=jn(s,a);return c&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?Cp({x:t,y:r},c,a):!0}).filter(s=>Vn(s)?(i.push(s),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(qm/this.state.zoom.value))}hitElement(t,r,n,i=!0){return i&&this.state.selectedElementIds[n.id]&&vc([n],this.state)&&ec(L(t,r),n,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(n))||J1(L(t,r),n,this.scene.getNonDeletedElementsMap())?!0:Pi({point:L(t,r),element:n,threshold:this.getElementHitThreshold(n),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:ce(n)?this.frameNameBoundsCache.get(n):null})}getTextBindableContainerAtPosition(t,r){let n=this.scene.getNonDeletedElements(),i=this.scene.getSelectedElements(this.state);if(i.length===1)return Cr(i[0],!1)?i[0]:null;let a=null;for(let l=n.length-1;l>=0;--l){if(n[l].isDeleted)continue;let[s,c,m,d]=at(n[l],this.scene.getNonDeletedElementsMap());if(Pe(n[l])&&Pi({point:L(t,r),element:n[l],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(n[l])})){a=n[l];break}else if(s<t&&t<m&&c<r&&r<d){a=n[l];break}}return Cr(a,!1)?a:null}handleHoverSelectedLinearElement(t,r,n){let i=this.scene.getNonDeletedElementsMap(),a=$.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let l=-1,s=null;Pi({point:L(r,n),element:a,elementsMap:i,threshold:this.getElementHitThreshold(a)})?(l=$.getPointIndexUnderCursor(a,i,this.state.zoom,r,n),s=$.getSegmentMidpointHitCoords(t,{x:r,y:n},this.state,this.scene.getNonDeletedElementsMap()),(se(a)?l===0||l===a.points.length-1:l>=0)||s?_e(this.interactiveCanvas,we.POINTER):this.hitElement(r,n,a)&&(!se(a)||!(a.startBinding||a.endBinding))&&_e(this.interactiveCanvas,we.MOVE)):this.hitElement(r,n,a)&&(!se(a)||!(a.startBinding||a.endBinding))&&_e(this.interactiveCanvas,we.MOVE),this.state.selectedLinearElement.hoverPointIndex!==l&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:l}}),$.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,s)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:s}})}else _e(this.interactiveCanvas,we.AUTO)}updateGestureOnPointerDown(t){ke.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),ke.pointers.size===2&&(ke.lastCenter=og(ke.pointers),ke.initialScale=this.state.zoom.value,ke.initialDistance=rg(Array.from(ke.pointers.values())))}initialPointerDownState(t){let r=ze(t,this.state),n=this.scene.getSelectedElements(this.state),[i,a,l,s]=ye(n),c=n.findIndex(se)===0;return{origin:r,withCmdOrCtrl:t[w.CTRL_OR_CMD],originInGrid:Us(yt(r.x,r.y,t[w.CTRL_OR_CMD]||c?null:this.getEffectiveGridSize())),scrollbars:lg(Es,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...r},originalElements:this.scene.getNonDeletedElements().reduce((m,d)=>(m.set(d.id,Vo(d)),m),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(l+i)/2,y:(s+a)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(r,n)},drag:{hasOccurred:!1,offset:null,origin:{...r}},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,r){if(!(r.scrollbars.isOverEither&&!this.state.multiElement))return!1;tf=!0,r.lastCoords.x=t.clientX,r.lastCoords.y=t.clientY;let n=lm(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,r)}),i=$e(()=>{vs=null,tf=!1,ho(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener("pointermove",n),window.removeEventListener("pointerup",i),n.flush()});return vs=i,window.addEventListener("pointermove",n),window.addEventListener("pointerup",i),!0}isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,r){if(r.length<2)return!1;let n=Math.max(qm/this.state.zoom.value,1),[i,a,l,s]=ye(r);return t.x>i-n&&t.x<l+n&&t.y>a-n&&t.y<s+n}getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:Kr(t)?ut.ADAPTIVE_RADIUS:ut.PROPORTIONAL_RADIUS}:null}maybeCacheReferenceSnapPoints(t,r,n=!1){Rr({event:t,app:this,selectedElements:r})&&(n||!Po.getReferenceSnapPoints())&&Po.setReferenceSnapPoints(gv(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,r,n=!1){Rr({event:t,app:this,selectedElements:r})&&(n||!Po.getVisibleGaps())&&Po.setVisibleGaps(hv(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return $e(r=>{this.maybeHandleResize(t,r)||this.maybeDragNewGenericElement(t,r)})}onKeyUpFromPointerDownHandler(t){return $e(r=>{r.key===w.ALT&&r.preventDefault(),!this.maybeHandleResize(t,r)&&this.maybeDragNewGenericElement(t,r)})}onPointerMoveFromPointerDownHandler(t){return lm(r=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let n=ze(r,this.state);if(this.state.activeLockedId&&this.setState({activeLockedId:null}),this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index){let[p,u]=yt(n.x,n.y,r[w.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),f=this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index;if(f<0){let x=$.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:p,y:u},this.state,this.scene.getNonDeletedElementsMap());f=x?$.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,x,this.scene.getNonDeletedElementsMap()):-1}let b=$.moveFixedSegment(this.state.selectedLinearElement,f,p,u,this.scene);Br(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:b.segmentMidPointHoveredCoords,pointerDownState:b.pointerDownState}})});return}let i=this.lastPointerMoveCoords??t.origin;if(this.lastPointerMoveCoords=n,t.drag.offset===null&&(t.drag.offset=Us(P0(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(r.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(r,t))return;if(Jt(this.state)){this.handleEraser(r,n);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(n.x,n.y);let[l,s]=yt(n.x,n.y,r[w.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(!t.drag.hasOccurred&&(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")&&Yr(L(n.x,n.y),L(t.origin.x,t.origin.y))<Bn)return;if(t.resize.isResizing&&(t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeHandleCrop(t,r)||this.maybeHandleResize(t,r)))return!0;let c=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.editingLinearElement||this.state.selectedLinearElement;if($.shouldAddMidpoint(this.state.selectedLinearElement,n,this.state,c)){let f=$.addMidpoint(this.state.selectedLinearElement,n,this,!r[w.CTRL_OR_CMD],this.scene);if(!f)return;Br(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:f.pointerDownState,selectedPointsIndices:f.selectedPointsIndices,segmentMidPointHoveredCoords:null}}),this.state.editingLinearElement&&this.setState({editingLinearElement:{...this.state.editingLinearElement,pointerDownState:f.pointerDownState,selectedPointsIndices:f.selectedPointsIndices,segmentMidPointHoveredCoords:null}})});return}else if(p.pointerDownState.segmentMidpoint.value!==null&&!p.pointerDownState.segmentMidpoint.added)return;let u=$.handlePointDragging(r,this,n.x,n.y,(f,b)=>{this.maybeSuggestBindingsForLinearElementAtCoords(f,b)},p,this.scene);if(u){t.lastCoords.x=n.x,t.lastCoords.y=n.y,t.drag.hasOccurred=!0,this.setState({editingLinearElement:this.state.editingLinearElement?u:null,selectedLinearElement:u});return}}let m=t.hit.allHitElements.some(p=>this.isASelectedElement(p)),d=this.state.editingLinearElement&&r.shiftKey&&this.state.editingLinearElement.elementId===t.hit.element?.id;if((m||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!d&&this.state.activeTool.type!=="lasso"){let p=this.scene.getSelectedElements(this.state);if(p.every(x=>x.locked))return;let u=p.find(x=>ce(x)),f=this.getTopLayerFrameAtSceneCoords(n),b=f&&!u?f:null;if(this.state.frameToHighlight!==b&&Br(()=>{this.setState({frameToHighlight:b})}),t.drag.hasOccurred=!0,p.length>0&&!t.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!=="active"){let x={x:n.x-t.drag.origin.x,y:n.y-t.drag.origin.y},E=[...t.originalElements.values()],y=r.shiftKey;if(y){let I=Math.abs(x.x),S=Math.abs(x.y),P=y&&I<S,M=y&&I>S;P&&(x.x=0),M&&(x.y=0)}if(this.state.croppingElementId){let I=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(I&&Ne(I)&&I.crop!==null&&t.hit.element===I){let S=I.crop,P=wr(I)&&this.imageCache.get(I.fileId)?.image;if(P&&!(P instanceof Promise)){let M=a1(lp(n.x-i.x,n.y-i.y),Math.max(this.state.zoom.value,2)),[O,R,z,W,Y,oe]=at(I,c),H=Hs(Re(L(O,R),L(Y,oe),I.angle)),F=Hs(Re(L(z,R),L(Y,oe),I.angle)),ee=Hs(Re(L(O,W),L(Y,oe),I.angle)),ie=dp(cp(F,H)),X=dp(cp(ee,H)),de=lp(sp(M,ie),sp(M,X)),he={...S,x:Et(S.x-de[0]*Math.sign(I.scale[0]),0,P.naturalWidth-S.width),y:Et(S.y-de[1]*Math.sign(I.scale[1]),0,P.naturalHeight-S.height)};this.scene.mutateElement(I,{crop:he});return}}}this.maybeCacheVisibleGaps(r,p),this.maybeCacheReferenceSnapPoints(r,p);let{snapOffset:v,snapLines:T}=fv(E,x,this,r,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:T}),this.state.editingFrame||_0(t,p,x,this.scene,v,r[w.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),(p.length!==1||!se(p[0]))&&this.setState({suggestedBindings:rc(p,this.scene.getNonDeletedElementsMap(),this.state.zoom)}),r.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let I=this.scene.getElementsIncludingDeleted(),S=t.hit.element,P=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});S&&t.hit.wasAddedToSelection&&!P.find(F=>F.id===S.id)&&P.push(S);let M=new Map(P.map(F=>[F.id,F])),{duplicatedElements:O,duplicateElementsMap:R,elementsWithDuplicates:z,origIdToDuplicateId:W}=qn({type:"in-place",elements:I,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:M,overrides:({duplicateElement:F,origElement:ee})=>({frameId:F.frameId??ee.frameId,seed:Yn()})});O.forEach(F=>{t.originalElements.set(F.id,Vo(F))});let Y=z.map(F=>{if(M.has(F.id)){let ee=t.originalElements.get(F.id);if(ee)return te(F,{x:ee.x,y:ee.y})}return F}),oe=this.props.onDuplicate?.(Y,I),H=nr(oe||Y,j(O));Br(()=>{if(t.hit.element){let F=W.get(t.hit.element.id),ee=F&&R.get(F);t.hit.element=ee||null}t.hit.allHitElements=t.hit.allHitElements.reduce((F,ee)=>{let ie=W.get(ee.id),X=ie&&R.get(ie);return X&&F.push(X),F},[]),t.drag.origin=ze(r,this.state),this.setState(F=>({...sc(O,this.scene.getNonDeletedElements(),F)})),this.scene.replaceAllElements(H),this.maybeCacheVisibleGaps(r,P,!0),this.maybeCacheReferenceSnapPoints(r,P,!0)})}return}}if(this.state.selectionElement)t.lastCoords.x=n.x,t.lastCoords.y=n.y,r.altKey?Br(()=>{this.setActiveTool({type:"lasso",fromSelection:!0},r.shiftKey),this.lassoTrail.startPath(t.origin.x,t.origin.y,r.shiftKey),this.setAppState({selectionElement:null})}):this.maybeDragNewGenericElement(t,r);else if(this.state.activeTool.type==="lasso")!r.altKey&&this.state.activeTool.fromSelection?(this.setActiveTool({type:"selection"}),this.createGenericElementOnPointerDown("selection",t),t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeDragNewGenericElement(t,r),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(n.x,n.y,r.shiftKey);else{let p=this.state.newElement;if(!p)return;if(p.type==="freedraw"){let u=p.points,f=n.x-p.x,b=n.y-p.y,x=u.length>0&&u[u.length-1];if(!(x&&x[0]===f&&x[1]===b)){let y=p.simulatePressure?p.pressures:[...p.pressures,r.pressure];this.scene.mutateElement(p,{points:[...u,L(f,b)],pressures:y},{informMutation:!1,isDragging:!1}),this.setState({newElement:p})}}else if(ge(p)){t.drag.hasOccurred=!0;let u=p.points,f=l-p.x,b=s-p.y;Fs(r)&&u.length===2&&({width:f,height:b}=Pp(p.x,p.y,n.x,n.y)),u.length===1?this.scene.mutateElement(p,{points:[...u,L(f,b)]},{informMutation:!1,isDragging:!1}):(u.length===2||u.length>1&&se(p))&&this.scene.mutateElement(p,{points:[...u.slice(0,-1),L(f,b)]},{isDragging:!0,informMutation:!1}),this.setState({newElement:p}),Tr(p,!1)&&this.maybeSuggestBindingsForLinearElementAtCoords(p,[n],this.state.startBoundElement)}else t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeDragNewGenericElement(t,r,!1)}if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let p=this.scene.getNonDeletedElements();if(this.state.editingLinearElement)$.handleBoxSelection(r,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!r.shiftKey&&De(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(b=>it({...b,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),b,this)):u=!1);let f=this.state.selectionElement?c0(p,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1):[];this.setState(b=>{let x={...u&&b.selectedElementIds,...f.reduce((E,y)=>(E[y.id]=!0,E),{})};return t.hit.element&&(f.length?delete x[t.hit.element.id]:x[t.hit.element.id]=!0),b=u?b:{...b,selectedGroupIds:{},editingGroupId:null},{...it({editingGroupId:b.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),b,this),selectedLinearElement:f.length===1&&ge(f[0])?new $(f[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:f.length===1&&(f[0].link||zt(f[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(t,r){if(r.scrollbars.isOverHorizontal){let n=t.clientX,i=n-r.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-i*(Es.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),r.lastCoords.x=n,!0}if(r.scrollbars.isOverVertical){let n=t.clientY,i=n-r.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-i*(Es.vertical?.deltaMultiplier||1)/this.state.zoom.value}),r.lastCoords.y=n,!0}return!1}onPointerUpFromPointerDownHandler(t){return $e(r=>{this.removePointer(r),t.eventListeners.onMove&&t.eventListeners.onMove.flush();let{newElement:n,resizingElement:i,croppingElementId:a,multiElement:l,activeTool:s,isResizing:c,isRotating:m,isCropping:d}=this.state;this.setState(E=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:Mi(E.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.lastPointerMoveCoords=null,Po.setReferenceSnapPoints(null),Po.setVisibleGaps(null),this.savePointer(r.clientX,r.clientY,"up");let p=t.hit.allHitElements;if(this.state.activeTool.type==="selection"&&!t.boxSelection.hasOccurred&&!t.resize.isResizing&&!p.some(E=>this.state.selectedElementIds[E.id])){let E=ze({clientX:r.clientX,clientY:r.clientY},this.state),y=this.getElementAtPosition(E.x,E.y,{includeLockedElements:!0});this.store.scheduleCapture(),y?.locked?this.setState({activeLockedId:y.groupIds.length>0?y.groupIds.at(-1)||"":y.id}):this.setState({activeLockedId:null})}else this.setState({activeLockedId:null});this.setState({selectedElementsAreBeingDragged:!1});let u=this.scene.getNonDeletedElementsMap();if(t.drag.hasOccurred&&t.hit?.element?.id){let E=u.get(t.hit.element.id);_1(E)&&E.boundElements?.filter(y=>y.type==="arrow").map(y=>u.get(y.id)).filter(y=>se(y)).forEach(y=>{y&&this.scene.mutateElement(y,{})})}if(this.state.editingLinearElement)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.editingLinearElement.elementId)this.actionManager.executeAction(Ut);else{let E=$.handlePointerUp(r,this.state.editingLinearElement,this.state,this.scene);E!==this.state.editingLinearElement&&this.setState({editingLinearElement:E,suggestedBindings:[]})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let E=$.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());E&&this.scene.mutateElement(E,{})}t.hit?.element?.id!==this.state.selectedLinearElement.elementId?this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null}):this.state.selectedLinearElement.isDragging&&this.actionManager.executeAction(Ut,"ui",{event:r})}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener("pointermove",t.eventListeners.onMove),window.removeEventListener("pointerup",t.eventListeners.onUp),window.removeEventListener("keydown",t.eventListeners.onKeyDown),window.removeEventListener("keyup",t.eventListeners.onKeyUp),this.props?.onPointerUp?.(s,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,r),n?.type==="freedraw"){let E=ze(r,this.state),y=n.points,v=E.x-n.x,T=E.y-n.y;v===y[0][0]&&T===y[0][1]&&(T+=1e-4,v+=1e-4);let I=n.simulatePressure?[]:[...n.pressures,r.pressure];this.scene.mutateElement(n,{points:[...y,L(v,T)],pressures:I,lastCommittedPoint:L(v,T)}),this.actionManager.executeAction(Ut);return}if(Ne(n)){let E=n;try{this.initializeImageDimensions(E),this.setState({selectedElementIds:Te({[E.id]:!0},this.state)},()=>{this.actionManager.executeAction(Ut)})}catch(y){console.error(y),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().filter(v=>v.id!==E.id)),this.actionManager.executeAction(Ut)}return}if(ge(n)){n.points.length>1&&this.store.scheduleCapture();let E=ze(r,this.state);!t.drag.hasOccurred&&n&&!l?(this.scene.mutateElement(n,{points:[...n.points,L(E.x-n.x,E.y-n.y)]},{informMutation:!1,isDragging:!1}),this.setState({multiElement:n,newElement:n})):t.drag.hasOccurred&&!l&&(Xr(this.state)&&Tr(n,!1)&&this.actionManager.executeAction(Ut),this.setState({suggestedBindings:[],startBoundElement:null}),s.locked?this.setState(y=>({newElement:null})):(Lo(this.interactiveCanvas),this.setState(y=>({newElement:null,activeTool:Le(this.state,{type:"selection"}),selectedElementIds:Te({...y.selectedElementIds,[n.id]:!0},y),selectedLinearElement:new $(n,this.scene.getNonDeletedElementsMap())}))),this.scene.triggerUpdate());return}if(V(n)){let E=U1(et({fontSize:n.fontSize,fontFamily:n.fontFamily}),n.lineHeight);n.width<E&&this.scene.mutateElement(n,{autoResize:!0}),this.resetCursor(),this.handleTextWysiwyg(n,{isExistingElement:!0})}if(s.type!=="selection"&&n&&Qr(n)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==n.id),appState:{newElement:null},captureUpdate:A.NEVER});return}if(ce(n)){let E=h0(this.scene.getElementsIncludingDeleted(),n,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(Bi(this.scene.getElementsMapIncludingDeleted(),E,n,this.state))}if(n&&(this.scene.mutateElement(n,T0(n),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let E=ze(r,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let y=this.scene.getElement(this.state.selectedLinearElement.elementId);if(y?.frameId){let v=jn(y,u);v&&y&&(d0(y,v,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(y,{groupIds:[]}),cc([y],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let y=this.getTopLayerFrameAtSceneCoords(E),v=this.scene.getSelectedElements(this.state),T=this.scene.getElementsMapIncludingDeleted(),I=S=>{if(S.length>0){for(let P of S){let M=P.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(P,{groupIds:P.groupIds.slice(0,M)},{informMutation:!1,isDragging:!1})}T.forEach(P=>{P.groupIds.length&&He(T,P.groupIds[P.groupIds.length-1]).length<2&&this.scene.mutateElement(P,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(y&&!this.state.selectedElementIds[y.id]){let S=v.filter(P=>P.frameId!==y.id&&kp(P,T,this.state));this.state.editingGroupId&&I(S),T=Bi(T,S,y,this.state)}else if(!y&&this.state.editingGroupId){let S=v.filter(P=>P.frameId&&!kp(P,T,this.state));I(S)}T=wo(T,this.state,this),this.scene.replaceAllElements(T)}}if(i&&this.store.scheduleCapture(),i&&Qr(i)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==i.id),captureUpdate:A.NEVER}),t.resize.isResizing){let E=wo(this.scene.getElementsIncludingDeleted(),this.state,this),y=this.scene.getSelectedElements(this.state).filter(v=>ce(v));for(let v of y)E=dc(E,Oi(this.scene.getElementsIncludingDeleted(),v,this.state,u),v,this);this.scene.replaceAllElements(E)}let f=t.hit.element;this.state.selectedLinearElement?.elementId!==f?.id&&ge(f)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new $(f,this.scene.getNonDeletedElementsMap())}),(!a||a&&(!f&&!d||f&&f.id!==a))&&this.finishImageCropping();let b=this.lastPointerDownEvent,x=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(Jt(this.state)&&b&&x){if(this.eraserTrail.endPath(),Yr(L(b.clientX,b.clientY),L(x.clientX,x.clientY))===0){let y=ze({clientX:x.clientX,clientY:x.clientY},this.state);this.getElementsAtPosition(y.x,y.y).forEach(T=>this.elementsPendingErasure.add(T.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(f&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.editingLinearElement||!t.boxSelection.hasOccurred)&&this.state.activeTool.type!=="lasso"&&(r.shiftKey&&!this.state.editingLinearElement?this.state.selectedElementIds[f.id]?ic(this.state,f)?this.setState(E=>{let y={...E.selectedElementIds};for(let v of f.groupIds.flatMap(T=>He(this.scene.getNonDeletedElements(),T)))delete y[v.id];return{selectedGroupIds:{...E.selectedElementIds,...f.groupIds.map(v=>({[v]:!1})).reduce((v,T)=>({...v,...T}),{})},selectedElementIds:Te(y,E)}}):this.state.selectedLinearElement?.isDragging||this.setState(E=>{let y={...E.selectedElementIds};delete y[f.id];let v=q(this.scene.getNonDeletedElements(),{selectedElementIds:y});return{...it({editingGroupId:E.editingGroupId,selectedElementIds:y},this.scene.getNonDeletedElements(),E,this),selectedLinearElement:v.length===1&&ge(v[0])?new $(v[0],this.scene.getNonDeletedElementsMap()):E.selectedLinearElement}}):f.frameId&&this.state.selectedElementIds[f.frameId]?this.setState(E=>{let y={...E.selectedElementIds,[f.id]:!0};return delete y[f.frameId],(this.scene.getElement(f.frameId)?.groupIds??[]).flatMap(v=>He(this.scene.getNonDeletedElements(),v)).forEach(v=>{delete y[v.id]}),{...it({editingGroupId:E.editingGroupId,selectedElementIds:y},this.scene.getNonDeletedElements(),E,this),showHyperlinkPopup:f.link||zt(f)?"info":!1}}):this.setState(E=>({selectedElementIds:Te({...E.selectedElementIds,[f.id]:!0},E)})):this.setState(E=>({...it({editingGroupId:E.editingGroupId,selectedElementIds:{[f.id]:!0}},this.scene.getNonDeletedElements(),E,this),selectedLinearElement:ge(f)&&E.selectedLinearElement?.elementId!==f.id?new $(f,this.scene.getNonDeletedElementsMap()):E.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(f&&se(f))&&!t.drag.hasOccurred&&!this.state.isResizing&&(f&&q1({point:L(t.origin.x,t.origin.y),element:f,elementsMap:u,threshold:this.getElementHitThreshold(f),frameNameBound:ce(f)?this.frameNameBoundsCache.get(f):null},u)||!f&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.editingLinearElement?this.setState({editingLinearElement:null}):this.setState({selectedElementIds:Te({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),_e(this.interactiveCanvas,we.AUTO);return}if(!s.locked&&s.type!=="freedraw"&&n&&this.setState(E=>({selectedElementIds:Te({...E.selectedElementIds,[n.id]:!0},E),showHyperlinkPopup:zt(n)&&!n.link?"editor":E.showHyperlinkPopup})),(s.type!=="selection"||De(this.scene.getNonDeletedElements(),this.state)||!nt(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),t.drag.hasOccurred||c||m||d){let E=this.scene.getSelectedElements(this.state).filter(ge);pl(E,Xr(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.scene,this.state.zoom)}if(s.type==="laser"){this.laserTrails.endPath();return}!s.locked&&s.type!=="freedraw"&&(s.type!=="lasso"||s.type==="lasso"&&s.fromSelection)?(Lo(this.interactiveCanvas),this.setState({newElement:null,suggestedBindings:[],activeTool:Le(this.state,{type:"selection"})})):this.setState({newElement:null,suggestedBindings:[]}),f&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&ke.pointers.size<=1&&Li(f)&&this.isIframeLikeElementCenter(f,this.lastPointerUpEvent,t.origin.x,t.origin.y)&&this.handleEmbeddableCenterClick(f)})}clearSelection(t){this.setState(r=>({selectedElementIds:Te({},r),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:r.editingGroupId&&t!=null&&Ni(t,r.editingGroupId)?r.editingGroupId:null})),this.setState({selectedElementIds:Te({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds})}getTextWysiwygSnappedToCenterPosition(t,r,n,i){if(i){let a=i.x+i.width/2,l=i.y+i.height/2,s=Js(i,n,this.scene.getNonDeletedElementsMap());if(s&&(a=s.x,l=s.y),Math.hypot(t-a,r-l)<Bf){let{x:d,y:p}=gt({sceneX:a,sceneY:l},n);return{viewportX:d,viewportY:p,elementCenterX:a,elementCenterY:l}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let t=this.excalidrawContainerRef.current,{left:r,top:n}=t.getBoundingClientRect();return{offsetLeft:r,offsetTop:n}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=qi.find(r=>r.code===this.props.langCode)||ar;await Nc(t),this.setAppState({})}},kL=()=>{(rr()||ft())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(en(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};kL();var l5=rf;import{useEffect as IL,useState as ML}from"react";import{jsx as LL}from"react/jsx-runtime";var s5=e=>{let[o,t]=ML(!0);return IL(()=>{let r=async()=>{await Nc(n),t(!1)},n=qi.find(i=>i.code===e.langCode)||ar;r()},[e.langCode]),o?LL(dm,{theme:e.theme}):e.children};import AL from"clsx";import{jsx as c5}from"react/jsx-runtime";var d5=({children:e})=>{let{FooterCenterTunnel:o}=je(),t=Me();return c5(o.In,{children:c5("div",{className:AL("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},_L=d5;d5.displayName="FooterCenter";import PL from"clsx";import{jsx as RL,jsxs as NL}from"react/jsx-runtime";var m5=({isCollaborating:e,onSelect:o,...t})=>{let r=Me(),n=r.width<830;return NL(go,{...t,className:PL("collab-button",{active:e}),type:"button",onSelect:o,style:{position:"relative",width:n?void 0:"auto"},title:g("labels.liveCollaboration"),children:[n?Qb:g("labels.share"),r.collaborators.size>0&&RL("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},DL=m5;m5.displayName="LiveCollaborationTrigger";import{jsx as Rn,jsxs as u5}from"react/jsx-runtime";var OL=()=>Rn("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Rn("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"})}),BL=()=>u5("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Rn("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)"}),Rn("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)"}),Rn("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)"}),Rn("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)"})]}),p5=({style:e,size:o="small",withText:t})=>u5("div",{className:`ExcalidrawLogo is-${o}`,style:e,children:[Rn(OL,{}),t&&Rn(BL,{})]});import{Fragment as f5,jsx as dt,jsxs as mf}from"react/jsx-runtime";var pf=({icon:e,shortcut:o,children:t})=>{let r=xe();return mf(f5,{children:[dt("div",{className:"welcome-screen-menu-item__icon",children:e}),dt("div",{className:"welcome-screen-menu-item__text",children:t}),o&&!r.editor.isMobile&&dt("div",{className:"welcome-screen-menu-item__shortcut",children:o})]})};pf.displayName="WelcomeScreenMenuItemContent";var ws=({onSelect:e,children:o,icon:t,shortcut:r,className:n="",...i})=>dt("button",{...i,type:"button",className:`welcome-screen-menu-item ${n}`,onClick:e,children:dt(pf,{icon:t,shortcut:r,children:o})});ws.displayName="WelcomeScreenMenuItem";var h5=({children:e,href:o,icon:t,shortcut:r,className:n="",...i})=>dt("a",{...i,className:`welcome-screen-menu-item ${n}`,href:o,target:"_blank",rel:"noopener",children:dt(pf,{icon:t,shortcut:r,children:e})});h5.displayName="WelcomeScreenMenuItemLink";var Oo=({children:e})=>{let{WelcomeScreenCenterTunnel:o}=je();return dt(o.In,{children:dt("div",{className:"welcome-screen-center",children:e||mf(f5,{children:[dt(uf,{}),dt(hf,{children:g("welcomeScreen.defaults.center_heading")}),mf(gf,{children:[dt(bf,{}),dt(ff,{})]})]})})})};Oo.displayName="Center";var uf=({children:e})=>dt("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||dt(p5,{withText:!0})});uf.displayName="Logo";var hf=({children:e})=>dt("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});hf.displayName="Heading";var gf=({children:e})=>dt("div",{className:"welcome-screen-menu",children:e});gf.displayName="Menu";var ff=()=>{let e=_t();return dt(ws,{onSelect:()=>e.executeAction(mi),shortcut:"?",icon:ea,children:g("helpDialog.title")})};ff.displayName="MenuItemHelp";var bf=()=>{let e=Me(),o=_t();return e.viewModeEnabled?null:dt(ws,{onSelect:()=>o.executeAction(ga),shortcut:We("loadScene"),icon:ta,children:g("buttons.load")})};bf.displayName="MenuItemLoadScene";var g5=({onSelect:e})=>{let{t:o}=lt();return dt(ws,{shortcut:null,onSelect:e,icon:Gc,children:o("labels.liveCollaboration")})};g5.displayName="MenuItemLiveCollaborationTrigger";Oo.Logo=uf;Oo.Heading=hf;Oo.Menu=gf;Oo.MenuItem=ws;Oo.MenuItemLink=h5;Oo.MenuItemHelp=ff;Oo.MenuItemLoadScene=bf;Oo.MenuItemLiveCollaborationTrigger=g5;import{jsx as Ka,jsxs as xf}from"react/jsx-runtime";var Gm=({children:e})=>{let{WelcomeScreenMenuHintTunnel:o}=je();return Ka(o.In,{children:xf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[Nb,Ka("div",{className:"welcome-screen-decor-hint__label",children:e||g("welcomeScreen.defaults.menuHint")})]})})};Gm.displayName="MenuHint";var Ym=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:o}=je();return Ka(o.In,{children:xf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[Ka("div",{className:"welcome-screen-decor-hint__label",children:e||g("welcomeScreen.defaults.toolbarHint")}),Bb]})})};Ym.displayName="ToolbarHint";var Wm=({children:e})=>{let{WelcomeScreenHelpHintTunnel:o}=je();return Ka(o.In,{children:xf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[Ka("div",{children:e||g("welcomeScreen.defaults.helpHint")}),Ob]})})};Wm.displayName="HelpHint";import{Fragment as b5,jsx as Ts,jsxs as FL}from"react/jsx-runtime";var Vm=e=>Ts(b5,{children:e.children||FL(b5,{children:[Ts(Oo,{}),Ts(Gm,{}),Ts(Ym,{}),Ts(Wm,{})]})});Vm.displayName="WelcomeScreen";Vm.Center=Oo;Vm.Hints={MenuHint:Gm,ToolbarHint:Ym,HelpHint:Wm};var zL=Vm;var HL=()=>{Array.prototype.at||Object.defineProperty(Array.prototype,"at",{value:function(e){if(e=Math.trunc(e)||0,e<0&&(e+=this.length),!(e<0||e>=this.length))return this[e]},writable:!0,enumerable:!1,configurable:!0}),Element.prototype.replaceChildren||(Element.prototype.replaceChildren=function(...e){this.innerHTML="",this.append(...e)})},x5=HL;import UL from"lodash.throttle";var GL=(e,o,t)=>!!(o&&(o.id===e.editingTextElement?.id||o.id===e.resizingElement?.id||o.id===e.newElement?.id||o.version>t.version||o.version===t.version&&o.versionNonce<t.versionNonce)),YL=UL((e,o,t)=>{if(ft()||rr()||window?.DEBUG_FRACTIONAL_INDICES){let r=en(e.map(n=>({...n})));L0(r,{shouldThrow:rr()||ft(),includeBoundTextValidation:!0,reconciliationContext:{localElements:o,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),WL=(e,o,t)=>{let r=j(e),n=[],i=new Set;for(let l of o)if(!i.has(l.id)){let s=r.get(l.id),c=GL(t,s,l);s&&c?(n.push(s),i.add(s.id)):(n.push(l),i.add(l.id))}for(let l of e)i.has(l.id)||(n.push(l),i.add(l.id));let a=gc(n);return YL(a,e,o),en(a),a};import{jsx as E5,jsxs as VL}from"react/jsx-runtime";var y5=({children:e,icon:o})=>{let{TTDDialogTriggerTunnel:t}=je(),r=ve();return E5(t.In,{children:VL(Oe.Item,{onSelect:()=>{me("ai","dialog open","ttd"),r({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:o??jx,children:[e??g("labels.textToDiagram"),E5(Oe.Item.Badge,{children:"AI"})]})})};y5.displayName="TTDDialogTrigger";import{useLayoutEffect as KL}from"react";var ZL=e=>{let o=tt();return KL(()=>{o.setPlugins({diagramToCode:{generate:e.generate}})},[o,e.generate]),null};import{jsx as Ef}from"react/jsx-runtime";x5();var jL=e=>{let{onChange:o,onIncrement:t,initialData:r,excalidrawAPI:n,isCollaborating:i=!1,onPointerUpdate:a,renderTopRightUI:l,langCode:s=ar.code,viewModeEnabled:c,zenModeEnabled:m,gridModeEnabled:d,libraryReturnUrl:p,theme:u,name:f,renderCustomStats:b,onPaste:x,detectScroll:E=!0,handleKeyboardGlobally:y=!1,onLibraryChange:v,autoFocus:T=!1,generateIdForFile:I,onLinkOpen:S,generateLinkForSelection:P,onPointerDown:M,onPointerUp:O,onScrollChange:R,onDuplicate:z,children:W,validateEmbeddable:Y,renderEmbeddable:oe,showDeprecatedFonts:H,wheelZoomsOnDefault:F,strokeColorTopPicks:ee,backgroundColorTopPicks:ie,renderScrollbars:X}=e,de=e.UIOptions?.canvasActions,he={...e.UIOptions,canvasActions:{...tp.canvasActions,...de},tools:{image:e.UIOptions?.tools?.image??!0}};return de?.export&&(he.canvasActions.export.saveFileToDisk=de.export?.saveFileToDisk??tp.canvasActions.export.saveFileToDisk),he.canvasActions.toggleTheme===null&&typeof u>"u"&&(he.canvasActions.toggleTheme=!0),$L(()=>{(async()=>{await import("canvas-roundrect-polyfill")})();let mt=so=>{typeof so.scale=="number"&&so.scale!==1&&so.preventDefault()};return document.addEventListener("touchmove",mt,{passive:!1}),()=>{document.removeEventListener("touchmove",mt)}},[]),Ef(Ib,{store:wt,children:Ef(s5,{langCode:s,theme:u,children:Ef(l5,{onChange:o,onIncrement:t,initialData:r,excalidrawAPI:n,isCollaborating:i,onPointerUpdate:a,renderTopRightUI:l,langCode:s,viewModeEnabled:c,zenModeEnabled:m,gridModeEnabled:d,libraryReturnUrl:p,theme:u,name:f,renderCustomStats:b,UIOptions:he,onPaste:x,detectScroll:E,handleKeyboardGlobally:y,onLibraryChange:v,autoFocus:T,generateIdForFile:I,onLinkOpen:S,generateLinkForSelection:P,onPointerDown:M,onPointerUp:O,onScrollChange:R,onDuplicate:z,validateEmbeddable:Y,renderEmbeddable:oe,aiEnabled:!1,showDeprecatedFonts:H,wheelZoomsOnDefault:F,strokeColorTopPicks:ee,backgroundColorTopPicks:ie,renderScrollbars:X,children:W})})})},qL=(e,o)=>{if(e.children!==o.children)return!1;let{initialData:t,UIOptions:r={},...n}=e,{initialData:i,UIOptions:a={},...l}=o,s=Object.keys(r),c=Object.keys(a);return s.length!==c.length?!1:s.every(d=>d==="canvasActions"?Object.keys(r.canvasActions).every(u=>u==="export"&&r?.canvasActions?.export&&a?.canvasActions?.export?r.canvasActions.export.saveFileToDisk===a.canvasActions.export.saveFileToDisk:r?.canvasActions?.[u]===a?.canvasActions?.[u]):r[d]===a[d])&&nt(n,l)},JL=XL.memo(jL,qL);JL.displayName="Excalidraw";export{go as Button,A as CaptureUpdateAction,$m as DEFAULT_LASER_COLOR,Cm as DefaultSidebar,ZL as DiagramToCodePlugin,JL as Excalidraw,pt as FONT_FAMILY,_L as Footer,DL as LiveCollaborationTrigger,ue as MIME_TYPES,Kt as MainMenu,ut as ROUNDNESS,No as Sidebar,us as Stats,re as THEME,zg as TTDDialog,y5 as TTDDialogTrigger,o1 as UserIdleState,zL as WelcomeScreen,kr as bumpVersion,Na as convertToExcalidrawElements,ar as defaultLang,k5 as elementPartiallyOverlapsWithOrContainsBBox,S5 as elementsOverlappingBBox,j2 as exportToBlob,xn as exportToCanvas,cC as exportToClipboard,Sa as exportToSvg,ye as getCommonBounds,Jp as getDataURL,I5 as getFreeDrawSvgPath,Bd as getLibraryItemsHash,fe as getNonDeletedElements,M5 as getSceneVersion,xp as getTextFromElements,_p as getVisibleSceneBounds,Up as hashElementsVersion,Gp as hashString,C5 as isElementInsideBBox,Jn as isElementLink,Qr as isInvisiblySmallElement,ge as isLinearElement,qi as languages,Lc as loadFromBlob,qp as loadLibraryFromBlob,jp as loadSceneOrLibraryFromBlob,ry as mergeLibraryItems,Go as mutateElement,te as newElementWith,Uo as normalizeLink,Nh as parseLibraryTokensFromUrl,WL as reconcileElements,Xi as restore,L5 as restoreAppState,$p as restoreElements,vl as restoreLibraryItems,gt as sceneCoordsToViewportCoords,xl as serializeAsJSON,Xp as serializeLibraryAsJSON,T5 as setCustomTextMetricsProvider,xe as useDevice,gC as useHandleLibrary,lt as useI18n,ze as viewportCoordsToSceneCoords,r2 as zoomToFitBounds};
118
+ `),r)}}addTextFromPaste(t,r=!1){let{x:n,y:i}=Fe({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),a={x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roundness:null,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:t,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:cH,verticalAlign:HT,locked:!1},l=of({fontSize:a.fontSize,fontFamily:a.fontFamily}),s=VT(a.fontFamily),[c,,d]=nG(this.state),m=Math.max(Math.min((d-c)*.5,800),200),p=10,u=i,f=r?[t]:t.split(`
119
+ `),b=f.reduce((x,w,E)=>{let y=mG(w).trim();if(y.length){let v=this.getTopLayerFrameAtSceneCoords({x:n,y:u}),C=EI(y,l,s),S=C.width>m,L=S?sG(y,l,m):y;C=S?EI(L,l,s):C;let k=n-C.width/2,A=u-C.height/2,P=tI({...a,x:k,y:A,text:L,originalText:y,lineHeight:s,autoResize:!S,frameId:v?v.id:null});x.push(P),u+=P.height+p}else f[E-1]?.trim()&&(u+=pG(a.fontSize,s)+p);return x},[]);b.length!==0&&(this.scene.insertElements(b),this.store.scheduleCapture(),this.setState({selectedElementIds:fe(Object.fromEntries(b.map(x=>[x.id,!0])),this.state)}),!r&&b.length>1&&PI===!1&&!this.device.editor.isMobile&&(this.setToast({message:g("toast.pasteAsSingleElement",{shortcut:bH("CtrlOrCmd+Shift+V")}),duration:5e3}),PI=!0))}handleTextWysiwyg(t,{isExistingElement:r=!1}){let n=this.scene.getElementsMapIncludingDeleted(),i=(a,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(s=>s.id===t.id&&mo(s)?mn(s,{originalText:a,isDeleted:l??s.isDeleted,...BH(s,uI(s,n),n,a)}):s)])};sv({id:t.id,canvas:this.canvas,getViewportCoords:(a,l)=>{let{x:s,y:c}=$d({sceneX:a,sceneY:l},this.state);return[s-this.state.offsetLeft,c-this.state.offsetTop]},onChange:Pe(a=>{i(a,!1),SI(t)&&sf(t,this.scene)}),onSubmit:Pe(({viaKeyboard:a,nextOriginalText:l})=>{let s=!l.trim();if(s&&!r?this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().filter(c=>c.id!==t.id)):i(l,s),!s&&a){let c=t.containerId?t.containerId:t.id;Yi(()=>{this.setState(d=>({selectedElementIds:fe({...d.selectedElementIds,[c]:!0},d)}))})}s&&kH(this.scene.getNonDeletedElements(),[t]),this.store.scheduleCapture(),Yi(()=>{this.setState({newElement:null,editingTextElement:null})}),this.state.activeTool.locked&&Dt(this.interactiveCanvas,this.state),this.focusContainer()}),element:t,excalidrawContainer:this.excalidrawContainerRef.current,app:this,autoSelect:!this.device.isTouchScreen}),this.deselectElements(),i(t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:fe({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(t,r){let n=this.getElementAtPosition(t,r,{includeBoundTextElement:!0});return n&&mo(n)&&!n.isDeleted?n:null}getElementAtPosition(t,r,n){let i=[];if(n&&"allHitElements"in n?i=n?.allHitElements||[]:i=this.getElementsAtPosition(t,r,{includeBoundTextElement:n?.includeBoundTextElement,includeLockedElements:n?.includeLockedElements}),i.length>1){if(n?.preferSelected){for(let l=i.length-1;l>-1;l--)if(this.state.selectedElementIds[i[l].id])return i[l]}let a=i[i.length-1];return vl({point:ne(t,r),element:a,threshold:this.getElementHitThreshold(a)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Zt(a)?this.frameNameBoundsCache.get(a):null})?a:i[i.length-2]}return i.length===1?i[0]:null}getElementsAtPosition(t,r,n){let i=[],a=this.scene.getNonDeletedElementsMap();return(n?.includeBoundTextElement&&n?.includeLockedElements?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(s=>(n?.includeLockedElements||!s.locked)&&(n?.includeBoundTextElement||!(mo(s)&&s.containerId)))).filter(s=>this.hitElement(t,r,s)).filter(s=>{let c=yf(s,a);return c&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?gI({x:t,y:r},c,a):!0}).filter(s=>Ki(s)?(i.push(s),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(WT/this.state.zoom.value))}hitElement(t,r,n,i=!0){return i&&this.state.selectedElementIds[n.id]&&ZH([n],this.state)&&LG(ne(t,r),n,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(n))||oG(ne(t,r),n,this.scene.getNonDeletedElementsMap())?!0:vl({point:ne(t,r),element:n,threshold:this.getElementHitThreshold(n),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Zt(n)?this.frameNameBoundsCache.get(n):null})}getTextBindableContainerAtPosition(t,r){let n=this.scene.getNonDeletedElements(),i=this.scene.getSelectedElements(this.state);if(i.length===1)return aI(i[0],!1)?i[0]:null;let a=null;for(let l=n.length-1;l>=0;--l){if(n[l].isDeleted)continue;let[s,c,d,m]=qT(n[l],this.scene.getNonDeletedElementsMap());if(df(n[l])&&vl({point:ne(t,r),element:n[l],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(n[l])})){a=n[l];break}else if(s<t&&t<d&&c<r&&r<m){a=n[l];break}}return aI(a,!1)?a:null}handleHoverSelectedLinearElement(t,r,n){let i=this.scene.getNonDeletedElementsMap(),a=Ce.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let l=-1,s=null;vl({point:ne(r,n),element:a,elementsMap:i,threshold:this.getElementHitThreshold(a)})?(l=Ce.getPointIndexUnderCursor(a,i,this.state.zoom,r,n),s=Ce.getSegmentMidpointHitCoords(t,{x:r,y:n},this.state,this.scene.getNonDeletedElementsMap()),(Ge(a)?l===0||l===a.points.length-1:l>=0)||s?xe(this.interactiveCanvas,De.POINTER):this.hitElement(r,n,a)&&(!Ge(a)||!(a.startBinding||a.endBinding))&&xe(this.interactiveCanvas,De.MOVE)):this.hitElement(r,n,a)&&(!Ge(a)||!(a.startBinding||a.endBinding))&&xe(this.interactiveCanvas,De.MOVE),this.state.selectedLinearElement.hoverPointIndex!==l&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:l}}),Ce.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,s)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:s}})}else xe(this.interactiveCanvas,De.AUTO)}updateGestureOnPointerDown(t){pe.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),pe.pointers.size===2&&(pe.lastCenter=Ch(pe.pointers),pe.initialScale=this.state.zoom.value,pe.initialDistance=Sh(Array.from(pe.pointers.values())))}initialPointerDownState(t){let r=Fe(t,this.state),n=this.scene.getSelectedElements(this.state),[i,a,l,s]=Xi(n),c=n.findIndex(Ge)===0;return{origin:r,withCmdOrCtrl:t[U.CTRL_OR_CMD],originInGrid:rf(nt(r.x,r.y,t[U.CTRL_OR_CMD]||c?null:this.getEffectiveGridSize())),scrollbars:Rh(kl,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...r},originalElements:this.scene.getNonDeletedElements().reduce((d,m)=>(d.set(m.id,oI(m)),d),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(l+i)/2,y:(s+a)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(r,n)},drag:{hasOccurred:!1,offset:null,origin:{...r}},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,r){if(!(r.scrollbars.isOverEither&&!this.state.multiElement))return!1;If=!0,r.lastCoords.x=t.clientX,r.lastCoords.y=t.clientY;let n=td(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,r)}),i=Pe(()=>{Ll=null,If=!1,Dt(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(ee.POINTER_MOVE,n),window.removeEventListener(ee.POINTER_UP,i),n.flush()});return Ll=i,window.addEventListener(ee.POINTER_MOVE,n),window.addEventListener(ee.POINTER_UP,i),!0}isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,r){if(r.length<2)return!1;let n=Math.max(WT/this.state.zoom.value,1),[i,a,l,s]=Xi(r);return t.x>i-n&&t.x<l+n&&t.y>a-n&&t.y<s+n}getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:OH(t)?Xd.ADAPTIVE_RADIUS:Xd.PROPORTIONAL_RADIUS}:null}maybeCacheReferenceSnapPoints(t,r,n=!1){Uo({event:t,app:this,selectedElements:r})&&(n||!Wt.getReferenceSnapPoints())&&Wt.setReferenceSnapPoints(Iw(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,r,n=!1){Uo({event:t,app:this,selectedElements:r})&&(n||!Wt.getVisibleGaps())&&Wt.setVisibleGaps(Tw(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return Pe(r=>{this.maybeHandleResize(t,r)||this.maybeDragNewGenericElement(t,r)})}onKeyUpFromPointerDownHandler(t){return Pe(r=>{r.key===U.ALT&&r.preventDefault(),!this.maybeHandleResize(t,r)&&this.maybeDragNewGenericElement(t,r)})}onPointerMoveFromPointerDownHandler(t){return td(r=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let n=Fe(r,this.state);if(this.state.activeLockedId&&this.setState({activeLockedId:null}),this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index){let[p,u]=nt(n.x,n.y,r[U.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),f=this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index;if(f<0){let x=Ce.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:p,y:u},this.state,this.scene.getNonDeletedElementsMap());f=x?Ce.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,x,this.scene.getNonDeletedElementsMap()):-1}let b=Ce.moveFixedSegment(this.state.selectedLinearElement,f,p,u,this.scene);this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:b.segmentMidPointHoveredCoords,pointerDownState:b.pointerDownState}});return}let i=this.lastPointerMoveCoords??t.origin;if(this.lastPointerMoveCoords=n,t.drag.offset===null&&(t.drag.offset=rf(kG(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(r.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(r,t))return;if(Et(this.state)){this.handleEraser(r,n);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(n.x,n.y);let[l,s]=nt(n.x,n.y,r[U.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(!t.drag.hasOccurred&&(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")&&sn(ne(n.x,n.y),ne(t.origin.x,t.origin.y))*this.state.zoom.value<$T)return;if(t.resize.isResizing&&(t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeHandleCrop(t,r)||this.maybeHandleResize(t,r)))return!0;let c=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement;if(Ce.shouldAddMidpoint(this.state.selectedLinearElement,n,this.state,c)){let f=Ce.addMidpoint(this.state.selectedLinearElement,n,this,!r[U.CTRL_OR_CMD],this.scene);if(!f)return;Yi(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:f.pointerDownState,selectedPointsIndices:f.selectedPointsIndices,segmentMidPointHoveredCoords:null}})});return}else if(p.pointerDownState.segmentMidpoint.value!==null&&!p.pointerDownState.segmentMidpoint.added)return;let u=Ce.handlePointDragging(r,this,n.x,n.y,p);if(u){t.lastCoords.x=n.x,t.lastCoords.y=n.y,t.drag.hasOccurred=!0,this.setState(u);return}}let d=t.hit.allHitElements.some(p=>this.isASelectedElement(p)),m=this.state.selectedLinearElement?.isEditing&&r.shiftKey&&this.state.selectedLinearElement.elementId===t.hit.element?.id;if((d||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!m&&this.state.activeTool.type!=="lasso"){let p=this.scene.getSelectedElements(this.state);if(p.every(x=>x.locked))return;let u=p.find(x=>Zt(x)),f=this.getTopLayerFrameAtSceneCoords(n),b=f&&!u?f:null;if(this.state.frameToHighlight!==b&&Yi(()=>{this.setState({frameToHighlight:b})}),t.drag.hasOccurred=!0,p.length>0&&!t.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!=="active"){let x={x:n.x-t.drag.origin.x,y:n.y-t.drag.origin.y},w=[...t.originalElements.values()],E=r.shiftKey;if(E){let C=Math.abs(x.x),S=Math.abs(x.y),L=E&&C<S,k=E&&C>S;L&&(x.x=0),k&&(x.y=0)}if(this.state.croppingElementId){let C=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(C&&pn(C)&&C.crop!==null&&t.hit.element===C){let S=C.crop,L=yl(C)&&this.imageCache.get(C.fileId)?.image;if(L&&!(L instanceof Promise)){let k=Uz(RT(n.x-i.x,n.y-i.y),Math.max(this.state.zoom.value,2)),[A,P,B,O,G,J]=qT(C,c),_=Jg(qg(ne(A,P),ne(G,J),C.angle)),R=Jg(qg(ne(B,P),ne(G,J),C.angle)),X=Jg(qg(ne(A,O),ne(G,J),C.angle)),Z=FT(NT(R,_)),Y=FT(NT(X,_)),ae=RT(BT(k,Z),BT(k,Y)),de={...S,x:_T(S.x-ae[0]*Math.sign(C.scale[0]),0,L.naturalWidth-S.width),y:_T(S.y-ae[1]*Math.sign(C.scale[1]),0,L.naturalHeight-S.height)};this.scene.mutateElement(C,{crop:de});return}}}this.maybeCacheVisibleGaps(r,p),this.maybeCacheReferenceSnapPoints(r,p);let{snapOffset:y,snapLines:v}=Cw(w,x,this,r,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:v}),this.state.editingFrame||SG(t,p,x,this.scene,y,r[U.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),(p.length!==1||!Ge(p[0]))&&this.setState({suggestedBindings:cf(p,this.scene.getNonDeletedElementsMap(),this.state.zoom)}),r.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let C=this.scene.getElementsIncludingDeleted(),S=t.hit.element,L=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});S&&t.hit.wasAddedToSelection&&!L.find(R=>R.id===S.id)&&L.push(S);let k=new Map(L.map(R=>[R.id,R])),{duplicatedElements:A,duplicateElementsMap:P,elementsWithDuplicates:B,origIdToDuplicateId:O}=rI({type:"in-place",elements:C,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:k,overrides:({duplicateElement:R,origElement:X})=>({frameId:R.frameId??X.frameId,seed:IH()})});A.forEach(R=>{t.originalElements.set(R.id,oI(R))});let G=B.map(R=>{if(k.has(R.id)){let X=t.originalElements.get(R.id);if(X)return mn(R,{x:X.x,y:X.y})}return R}),J=this.props.onDuplicate?.(G,C),_=wI(J||G,jd(A));Yi(()=>{if(t.hit.element){let R=O.get(t.hit.element.id),X=R&&P.get(R);t.hit.element=X||null}t.hit.allHitElements=t.hit.allHitElements.reduce((R,X)=>{let Z=O.get(X.id),Y=Z&&P.get(Z);return Y&&R.push(Y),R},[]),t.drag.origin=Fe(r,this.state),this.setState(R=>({...vG(A,this.scene.getNonDeletedElements(),R)})),this.scene.replaceAllElements(_),this.maybeCacheVisibleGaps(r,L,!0),this.maybeCacheReferenceSnapPoints(r,L,!0)})}return}}if(this.state.selectionElement){if(t.lastCoords.x=n.x,t.lastCoords.y=n.y,r.altKey){this.setActiveTool({type:"lasso",fromSelection:!0},r.shiftKey),this.lassoTrail.startPath(t.origin.x,t.origin.y,r.shiftKey),this.setAppState({selectionElement:null});return}this.maybeDragNewGenericElement(t,r)}else if(this.state.activeTool.type==="lasso")!r.altKey&&this.state.activeTool.fromSelection?(this.setActiveTool({type:"selection"}),this.createGenericElementOnPointerDown("selection",t),t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeDragNewGenericElement(t,r),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(n.x,n.y,r.shiftKey);else{let p=this.state.newElement;if(!p)return;if(p.type==="freedraw"){let u=p.points,f=n.x-p.x,b=n.y-p.y,x=u.length>0&&u[u.length-1];if(!(x&&x[0]===f&&x[1]===b)){let E=p.simulatePressure?p.pressures:[...p.pressures,r.pressure];this.scene.mutateElement(p,{points:[...u,ne(f,b)],pressures:E},{informMutation:!1,isDragging:!1}),this.setState({newElement:p})}}else if($t(p)){t.drag.hasOccurred=!0;let u=p.points,f=l-p.x,b=s-p.y;Qg(r)&&u.length===2&&({width:f,height:b}=lI(p.x,p.y,n.x,n.y)),u.length===1?this.scene.mutateElement(p,{points:[...u,ne(f,b)]},{informMutation:!1,isDragging:!1}):(u.length===2||u.length>1&&Ge(p))&&this.scene.mutateElement(p,{points:[...u.slice(0,-1),ne(f,b)]},{isDragging:!0,informMutation:!1}),this.setState({newElement:p}),mf(p,!1)&&this.setState({suggestedBindings:jT(p,[n],this.scene,this.state.zoom,this.state.startBoundElement)})}else t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeDragNewGenericElement(t,r,!1)}if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let p=this.scene.getNonDeletedElements();if(this.state.selectedLinearElement?.isEditing)Ce.handleBoxSelection(r,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!r.shiftKey&&Ee(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(b=>po({...b,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),b,this)):u=!1);let f=this.state.selectionElement?qf(p,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1):[];this.setState(b=>{let x={...u&&b.selectedElementIds,...f.reduce((w,E)=>(w[E.id]=!0,w),{})};return t.hit.element&&(f.length?delete x[t.hit.element.id]:x[t.hit.element.id]=!0),b=u?b:{...b,selectedGroupIds:{},editingGroupId:null},{...po({editingGroupId:b.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),b,this),selectedLinearElement:f.length===1&&$t(f[0])?new Ce(f[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:f.length===1&&(f[0].link||_r(f[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(t,r){if(r.scrollbars.isOverHorizontal){let n=t.clientX,i=n-r.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-i*(kl.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),r.lastCoords.x=n,!0}if(r.scrollbars.isOverVertical){let n=t.clientY,i=n-r.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-i*(kl.vertical?.deltaMultiplier||1)/this.state.zoom.value}),r.lastCoords.y=n,!0}return!1}onPointerUpFromPointerDownHandler(t){return Pe(r=>{this.removePointer(r),t.eventListeners.onMove&&t.eventListeners.onMove.flush();let{newElement:n,resizingElement:i,croppingElementId:a,multiElement:l,activeTool:s,isResizing:c,isRotating:d,isCropping:m}=this.state;this.setState(E=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:El(E.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.lastPointerMoveCoords=null,Wt.setReferenceSnapPoints(null),Wt.setVisibleGaps(null),this.savePointer(r.clientX,r.clientY,"up");let p=t.hit.allHitElements,u=Fe({clientX:r.clientX,clientY:r.clientY},this.state);if(this.state.activeTool.type==="selection"&&!t.boxSelection.hasOccurred&&!t.resize.isResizing&&!p.some(E=>this.state.selectedElementIds[E.id])){let E=this.getElementAtPosition(u.x,u.y,{includeLockedElements:!0});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});this.setState({selectedElementsAreBeingDragged:!1});let f=this.scene.getNonDeletedElementsMap();if(t.drag.hasOccurred&&t.hit?.element?.id){let E=f.get(t.hit.element.id);HH(E)&&E.boundElements?.filter(y=>y.type==="arrow").map(y=>f.get(y.id)).filter(y=>Ge(y)).forEach(y=>{y&&this.scene.mutateElement(y,{})})}if(this.state.selectedLinearElement?.isEditing)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.selectedLinearElement.elementId)this.actionManager.executeAction(It);else{let E=Ce.handlePointerUp(r,this.state.selectedLinearElement,this.state,this.scene);E!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:E,suggestedBindings:[]})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let E=Ce.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());E&&this.scene.mutateElement(E,{})}t.hit?.element?.id!==this.state.selectedLinearElement.elementId?this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null}):this.state.selectedLinearElement.isDragging&&this.actionManager.executeAction(It,"ui",{event:r,sceneCoords:u})}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener(ee.POINTER_MOVE,t.eventListeners.onMove),window.removeEventListener(ee.POINTER_UP,t.eventListeners.onUp),window.removeEventListener(ee.KEYDOWN,t.eventListeners.onKeyDown),window.removeEventListener(ee.KEYUP,t.eventListeners.onKeyUp),this.props?.onPointerUp?.(s,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,r),n?.type==="freedraw"){let E=Fe(r,this.state),y=n.points,v=E.x-n.x,C=E.y-n.y;v===y[0][0]&&C===y[0][1]&&(C+=1e-4,v+=1e-4);let S=n.simulatePressure?[]:[...n.pressures,r.pressure];this.scene.mutateElement(n,{points:[...y,ne(v,C)],pressures:S,lastCommittedPoint:ne(v,C)}),this.actionManager.executeAction(It);return}if($t(n)){n.points.length>1&&this.store.scheduleCapture();let E=Fe(r,this.state),y=sn(ne(E.x,E.y),ne(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||y<$T)&&n&&!l)if(this.device.isTouchScreen){let v=Math.min(this.state.width*.7/this.state.zoom.value,100);this.scene.mutateElement(n,{x:n.x-v/2,points:[ne(0,0),ne(v,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(It)}else{let v=E.x-n.x,C=E.y-n.y;this.scene.mutateElement(n,{points:[...n.points,ne(v,C)]},{informMutation:!1,isDragging:!1}),this.setState({multiElement:n,newElement:n})}else t.drag.hasOccurred&&!l&&(lf(this.state)&&mf(n,!1)&&this.actionManager.executeAction(It,"ui",{event:r,sceneCoords:u}),this.setState({suggestedBindings:[],startBoundElement:null}),s.locked?this.setState(v=>({newElement:null})):(Ht(this.interactiveCanvas),this.setState(v=>({newElement:null,activeTool:Vo(this.state,{type:"selection"}),selectedElementIds:fe({...v.selectedElementIds,[n.id]:!0},v),selectedLinearElement:new Ce(n,this.scene.getNonDeletedElementsMap())}))),this.scene.triggerUpdate());return}if(mo(n)){let E=gG(of({fontSize:n.fontSize,fontFamily:n.fontFamily}),n.lineHeight);n.width<E&&this.scene.mutateElement(n,{autoResize:!0}),this.resetCursor(),this.handleTextWysiwyg(n,{isExistingElement:!0})}if(s.type!=="selection"&&n&&cI(n)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==n.id),appState:{newElement:null},captureUpdate:mt.NEVER});return}if(Zt(n)){let E=qH(this.scene.getElementsIncludingDeleted(),n,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(xf(this.scene.getElementsMapIncludingDeleted(),E,n,this.state))}if(n&&(this.scene.mutateElement(n,GH(n),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let E=Fe(r,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let y=this.scene.getElement(this.state.selectedLinearElement.elementId);if(y?.frameId){let v=yf(y,f);v&&y&&(JH(y,v,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(y,{groupIds:[]}),jH([y],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let y=this.getTopLayerFrameAtSceneCoords(E),v=this.scene.getSelectedElements(this.state),C=this.scene.getElementsMapIncludingDeleted(),S=L=>{if(L.length>0){for(let k of L){let A=k.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(k,{groupIds:k.groupIds.slice(0,A)},{informMutation:!1,isDragging:!1})}C.forEach(k=>{k.groupIds.length&&Il(C,k.groupIds[k.groupIds.length-1]).length<2&&this.scene.mutateElement(k,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(y&&!this.state.selectedElementIds[y.id]){let L=v.filter(k=>k.frameId!==y.id&&bI(k,C,this.state));this.state.editingGroupId&&S(L),C=xf(C,L,y,this.state)}else if(!y&&this.state.editingGroupId){let L=v.filter(k=>k.frameId&&!bI(k,C,this.state));S(L)}C=fI(C,this.state,this),this.scene.replaceAllElements(C)}}if(i&&this.store.scheduleCapture(),i&&cI(i)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==i.id),captureUpdate:mt.NEVER}),t.resize.isResizing){let E=fI(this.scene.getElementsIncludingDeleted(),this.state,this),y=this.scene.getSelectedElements(this.state).filter(v=>Zt(v));for(let v of y)E=$H(E,Ef(this.scene.getElementsIncludingDeleted(),v,this.state,f),v,this);this.scene.replaceAllElements(E)}let b=t.hit.element;this.state.selectedLinearElement?.elementId!==b?.id&&$t(b)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new Ce(b,this.scene.getNonDeletedElementsMap())}),(!a||a&&(!b&&!m||b&&b.id!==a))&&this.finishImageCropping();let x=this.lastPointerDownEvent,w=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(Et(this.state)&&x&&w){if(this.eraserTrail.endPath(),sn(ne(x.clientX,x.clientY),ne(w.clientX,w.clientY))===0){let y=Fe({clientX:w.clientX,clientY:w.clientY},this.state);this.getElementsAtPosition(y.x,y.y).forEach(C=>this.elementsPendingErasure.add(C.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(b&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.selectedLinearElement?.isEditing||!t.boxSelection.hasOccurred)&&this.state.activeTool.type!=="lasso"&&(r.shiftKey&&!this.state.selectedLinearElement?.isEditing?this.state.selectedElementIds[b.id]?yG(this.state,b)?this.setState(E=>{let y={...E.selectedElementIds};for(let v of b.groupIds.flatMap(C=>Il(this.scene.getNonDeletedElements(),C)))delete y[v.id];return{selectedGroupIds:{...E.selectedElementIds,...b.groupIds.map(v=>({[v]:!1})).reduce((v,C)=>({...v,...C}),{})},selectedElementIds:fe(y,E)}}):this.state.selectedLinearElement?.isDragging||this.setState(E=>{let y={...E.selectedElementIds};delete y[b.id];let v=$(this.scene.getNonDeletedElements(),{selectedElementIds:y});return{...po({editingGroupId:E.editingGroupId,selectedElementIds:y},this.scene.getNonDeletedElements(),E,this),selectedLinearElement:v.length===1&&$t(v[0])?new Ce(v[0],this.scene.getNonDeletedElementsMap()):E.selectedLinearElement}}):b.frameId&&this.state.selectedElementIds[b.frameId]?this.setState(E=>{let y={...E.selectedElementIds,[b.id]:!0};return delete y[b.frameId],(this.scene.getElement(b.frameId)?.groupIds??[]).flatMap(v=>Il(this.scene.getNonDeletedElements(),v)).forEach(v=>{delete y[v.id]}),{...po({editingGroupId:E.editingGroupId,selectedElementIds:y},this.scene.getNonDeletedElements(),E,this),showHyperlinkPopup:b.link||_r(b)?"info":!1}}):this.setState(E=>({selectedElementIds:fe({...E.selectedElementIds,[b.id]:!0},E)})):this.setState(E=>({...po({editingGroupId:E.editingGroupId,selectedElementIds:{[b.id]:!0}},this.scene.getNonDeletedElements(),E,this),selectedLinearElement:$t(b)&&E.selectedLinearElement?.elementId!==b.id?new Ce(b,this.scene.getNonDeletedElementsMap()):E.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(b&&Ge(b))&&!t.drag.hasOccurred&&!this.state.isResizing&&(b&&rG({point:ne(t.origin.x,t.origin.y),element:b,elementsMap:f,threshold:this.getElementHitThreshold(b),frameNameBound:Zt(b)?this.frameNameBoundsCache.get(b):null},f)||!b&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(ki):this.setState({selectedElementIds:fe({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),xe(this.interactiveCanvas,De.AUTO);return}if(!s.locked&&s.type!=="freedraw"&&n&&this.setState(E=>({selectedElementIds:fe({...E.selectedElementIds,[n.id]:!0},E),showHyperlinkPopup:_r(n)&&!n.link?"editor":E.showHyperlinkPopup})),(s.type!=="selection"||Ee(this.scene.getNonDeletedElements(),this.state)||!TH(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),t.drag.hasOccurred&&!this.state.selectedLinearElement||c||d||m){let E=this.scene.getSelectedElements(this.state).filter($t);JT(E,lf(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.scene,this.state.zoom)}if(s.type==="laser"){this.laserTrails.endPath();return}!s.locked&&s.type!=="freedraw"&&(s.type!=="lasso"||s.type==="lasso"&&s.fromSelection)?(Ht(this.interactiveCanvas),this.setState({newElement:null,suggestedBindings:[],activeTool:Vo(this.state,{type:"selection"})})):this.setState({newElement:null,suggestedBindings:[]}),b&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&pe.pointers.size<=1&&wl(b)&&this.isIframeLikeElementCenter(b,this.lastPointerUpEvent,t.origin.x,t.origin.y)&&this.handleEmbeddableCenterClick(b)})}clearSelection(t){this.setState(r=>({selectedElementIds:fe({},r),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:r.editingGroupId&&t!=null&&yI(t,r.editingGroupId)?r.editingGroupId:null})),this.setState({selectedElementIds:fe({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds})}getTextWysiwygSnappedToCenterPosition(t,r,n,i){if(i){let a=i.x+i.width/2,l=i.y+i.height/2,s=bf(i,n,this.scene.getNonDeletedElementsMap());if(s&&(a=s.x,l=s.y),Math.hypot(t-a,r-l)<rH){let{x:m,y:p}=$d({sceneX:a,sceneY:l},n);return{viewportX:m,viewportY:p,elementCenterX:a,elementCenterY:l}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let t=this.excalidrawContainerRef.current,{left:r,top:n}=t.getBoundingClientRect();return{offsetLeft:r,offsetTop:n}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=Tn.find(r=>r.code===this.props.langCode)||ho;await Xl(t),this.setAppState({})}},AG=()=>{(Sf()||AI())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(DI(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};AG();var BI=kf;import{useEffect as _G,useState as RG}from"react";import{jsx as NG}from"react/jsx-runtime";var FI=e=>{let[o,t]=RG(!0);return _G(()=>{let r=async()=>{await Xl(n),t(!1)},n=Tn.find(i=>i.code===e.langCode)||ho;r()},[e.langCode]),o?NG(id,{theme:e.theme}):e.children};import BG from"clsx";import{jsx as OI}from"react/jsx-runtime";var zI=({children:e})=>{let{FooterCenterTunnel:o}=Ae(),t=ge();return OI(o.In,{children:OI("div",{className:BG("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},FG=zI;zI.displayName="FooterCenter";import OG from"clsx";import{jsx as HG,jsxs as GG}from"react/jsx-runtime";var HI=({isCollaborating:e,onSelect:o,...t})=>{let r=ge(),n=r.width<830;return GG(Rt,{...t,className:OG("collab-button",{active:e}),type:"button",onSelect:o,style:{position:"relative",width:n?void 0:"auto"},title:g("labels.liveCollaboration"),children:[n?q1:g("labels.share"),r.collaborators.size>0&&HG("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},zG=HI;HI.displayName="LiveCollaborationTrigger";import{jsx as Br,jsxs as UI}from"react/jsx-runtime";var UG=()=>Br("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Br("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"})}),YG=()=>UI("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Br("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)"}),Br("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)"}),Br("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)"}),Br("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)"})]}),GI=({style:e,size:o="small",withText:t})=>UI("div",{className:`ExcalidrawLogo is-${o}`,style:e,children:[Br(UG,{}),t&&Br(YG,{})]});import{Fragment as VI,jsx as Ue,jsxs as Rf}from"react/jsx-runtime";var Nf=({icon:e,shortcut:o,children:t})=>{let r=ce();return Rf(VI,{children:[Ue("div",{className:"welcome-screen-menu-item__icon",children:e}),Ue("div",{className:"welcome-screen-menu-item__text",children:t}),o&&!r.editor.isMobile&&Ue("div",{className:"welcome-screen-menu-item__shortcut",children:o})]})};Nf.displayName="WelcomeScreenMenuItemContent";var Pl=({onSelect:e,children:o,icon:t,shortcut:r,className:n="",...i})=>Ue("button",{...i,type:"button",className:`welcome-screen-menu-item ${n}`,onClick:e,children:Ue(Nf,{icon:t,shortcut:r,children:o})});Pl.displayName="WelcomeScreenMenuItem";var YI=({children:e,href:o,icon:t,shortcut:r,className:n="",...i})=>Ue("a",{...i,className:`welcome-screen-menu-item ${n}`,href:o,target:"_blank",rel:"noopener",children:Ue(Nf,{icon:t,shortcut:r,children:e})});YI.displayName="WelcomeScreenMenuItemLink";var jt=({children:e})=>{let{WelcomeScreenCenterTunnel:o}=Ae();return Ue(o.In,{children:Ue("div",{className:"welcome-screen-center",children:e||Rf(VI,{children:[Ue(Bf,{}),Ue(Ff,{children:g("welcomeScreen.defaults.center_heading")}),Rf(Of,{children:[Ue(Hf,{}),Ue(zf,{})]})]})})})};jt.displayName="Center";var Bf=({children:e})=>Ue("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||Ue(GI,{withText:!0})});Bf.displayName="Logo";var Ff=({children:e})=>Ue("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});Ff.displayName="Heading";var Of=({children:e})=>Ue("div",{className:"welcome-screen-menu",children:e});Of.displayName="Menu";var zf=()=>{let e=ot();return Ue(Pl,{onSelect:()=>e.executeAction(jr),shortcut:"?",icon:Pn,children:g("helpDialog.title")})};zf.displayName="MenuItemHelp";var Hf=()=>{let e=ge(),o=ot();return e.viewModeEnabled?null:Ue(Pl,{onSelect:()=>o.executeAction(Jn),shortcut:Se("loadScene"),icon:An,children:g("buttons.load")})};Hf.displayName="MenuItemLoadScene";var WI=({onSelect:e})=>{let{t:o}=Oe();return Ue(Pl,{shortcut:null,onSelect:e,icon:ql,children:o("labels.liveCollaboration")})};WI.displayName="MenuItemLiveCollaborationTrigger";jt.Logo=Bf;jt.Heading=Ff;jt.Menu=Of;jt.MenuItem=Pl;jt.MenuItemLink=YI;jt.MenuItemHelp=zf;jt.MenuItemLoadScene=Hf;jt.MenuItemLiveCollaborationTrigger=WI;import{jsx as Zi,jsxs as Gf}from"react/jsx-runtime";var em=({children:e})=>{let{WelcomeScreenMenuHintTunnel:o}=Ae();return Zi(o.In,{children:Gf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[P1,Zi("div",{className:"welcome-screen-decor-hint__label",children:e||g("welcomeScreen.defaults.menuHint")})]})})};em.displayName="MenuHint";var tm=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:o}=Ae();return Zi(o.In,{children:Gf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[Zi("div",{className:"welcome-screen-decor-hint__label",children:e||g("welcomeScreen.defaults.toolbarHint")}),D1]})})};tm.displayName="ToolbarHint";var om=({children:e})=>{let{WelcomeScreenHelpHintTunnel:o}=Ae();return Zi(o.In,{children:Gf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[Zi("div",{children:e||g("welcomeScreen.defaults.helpHint")}),A1]})})};om.displayName="HelpHint";import{Fragment as XI,jsx as Al,jsxs as VG}from"react/jsx-runtime";var rm=e=>Al(XI,{children:e.children||VG(XI,{children:[Al(jt,{}),Al(em,{}),Al(tm,{}),Al(om,{})]})});rm.displayName="WelcomeScreen";rm.Center=jt;rm.Hints={MenuHint:em,ToolbarHint:tm,HelpHint:om};var WG=rm;var XG=()=>{Array.prototype.at||Object.defineProperty(Array.prototype,"at",{value:function(e){if(e=Math.trunc(e)||0,e<0&&(e+=this.length),!(e<0||e>=this.length))return this[e]},writable:!0,enumerable:!1,configurable:!0}),Element.prototype.replaceChildren||(Element.prototype.replaceChildren=function(...e){this.innerHTML="",this.append(...e)})},KI=XG;import{getSceneVersion as z7e,hashElementsVersion as H7e,hashString as G7e,getNonDeletedElements as U7e}from"@excalidraw/element";import{getTextFromElements as W7e}from"@excalidraw/element";import{isInvisiblySmallElement as X7e}from"@excalidraw/element";import KG from"lodash.throttle";import{arrayToMap as ZG,isDevEnv as ZI,isTestEnv as $I}from"@excalidraw/common";import{orderByFractionalIndex as $G,syncInvalidIndices as jI,validateFractionalIndices as jG}from"@excalidraw/element";var qG=(e,o,t)=>!!(o&&(o.id===e.editingTextElement?.id||o.id===e.resizingElement?.id||o.id===e.newElement?.id||o.version>t.version||o.version===t.version&&o.versionNonce<t.versionNonce)),JG=KG((e,o,t)=>{if(ZI()||$I()||window?.DEBUG_FRACTIONAL_INDICES){let r=jI(e.map(n=>({...n})));jG(r,{shouldThrow:$I()||ZI(),includeBoundTextValidation:!0,reconciliationContext:{localElements:o,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),QG=(e,o,t)=>{let r=ZG(e),n=[],i=new Set;for(let l of o)if(!i.has(l.id)){let s=r.get(l.id),c=qG(t,s,l);s&&c?(n.push(s),i.add(s.id)):(n.push(l),i.add(l.id))}for(let l of e)i.has(l.id)||(n.push(l),i.add(l.id));let a=$G(n);return JG(a,e,o),jI(a),a};import{getFreeDrawSvgPath as eDe}from"@excalidraw/element";import{isLinearElement as rDe}from"@excalidraw/element";import{FONT_FAMILY as iDe,THEME as aDe,MIME_TYPES as lDe,ROUNDNESS as dc,DEFAULT_LASER_COLOR as sDe,UserIdleState as cDe,normalizeLink as dDe}from"@excalidraw/common";import{mutateElement as pc,newElementWith as pDe,bumpVersion as ci}from"@excalidraw/element";import{CaptureUpdateAction as gv}from"@excalidraw/element";import{sceneCoordsToViewportCoords as ly,viewportCoordsToSceneCoords as fDe}from"@excalidraw/common";import{jsx as qI,jsxs as eU}from"react/jsx-runtime";var JI=({children:e,icon:o})=>{let{TTDDialogTriggerTunnel:t}=Ae(),r=le();return qI(t.In,{children:eU(ye.Item,{onSelect:()=>{re("ai","dialog open","ttd"),r({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:o??Z0,children:[e??g("labels.textToDiagram"),qI(ye.Item.Badge,{children:"AI"})]})})};JI.displayName="TTDDialogTrigger";import{getCommonBounds as MDe,getVisibleSceneBounds as LDe}from"@excalidraw/element";import{useLayoutEffect as tU}from"react";var oU=e=>{let o=Re();return tU(()=>{o.setPlugins({diagramToCode:{generate:e.generate}})},[o,e.generate]),null};import{isElementLink as RDe}from"@excalidraw/element";import{setCustomTextMetricsProvider as BDe}from"@excalidraw/element";import{jsx as Uf}from"react/jsx-runtime";KI();var aU=e=>{let{onChange:o,onIncrement:t,initialData:r,excalidrawAPI:n,isCollaborating:i=!1,onPointerUpdate:a,renderTopRightUI:l,langCode:s=ho.code,viewModeEnabled:c,zenModeEnabled:d,gridModeEnabled:m,libraryReturnUrl:p,theme:u,name:f,renderCustomStats:b,onPaste:x,detectScroll:w=!0,handleKeyboardGlobally:E=!1,onLibraryChange:y,autoFocus:v=!1,generateIdForFile:C,onLinkOpen:S,generateLinkForSelection:L,onPointerDown:k,onPointerUp:A,onScrollChange:P,onDuplicate:B,children:O,validateEmbeddable:G,renderEmbeddable:J,showDeprecatedFonts:_,wheelZoomsOnDefault:R,strokeColorTopPicks:X,backgroundColorTopPicks:Z,renderScrollbars:Y}=e,ae=e.UIOptions?.canvasActions,de={...e.UIOptions,canvasActions:{...QI.canvasActions,...ae},tools:{image:e.UIOptions?.tools?.image??!0}};return ae?.export&&(de.canvasActions.export.saveFileToDisk=ae.export?.saveFileToDisk??QI.canvasActions.export.saveFileToDisk),de.canvasActions.toggleTheme===null&&typeof u>"u"&&(de.canvasActions.toggleTheme=!0),nU(()=>{(async()=>{await import("canvas-roundrect-polyfill")})();let Ye=Pt=>{typeof Pt.scale=="number"&&Pt.scale!==1&&Pt.preventDefault()};return document.addEventListener("touchmove",Ye,{passive:!1}),()=>{document.removeEventListener("touchmove",Ye)}},[]),Uf(v1,{store:Ke,children:Uf(FI,{langCode:s,theme:u,children:Uf(BI,{onChange:o,onIncrement:t,initialData:r,excalidrawAPI:n,isCollaborating:i,onPointerUpdate:a,renderTopRightUI:l,langCode:s,viewModeEnabled:c,zenModeEnabled:d,gridModeEnabled:m,libraryReturnUrl:p,theme:u,name:f,renderCustomStats:b,UIOptions:de,onPaste:x,detectScroll:w,handleKeyboardGlobally:E,onLibraryChange:y,autoFocus:v,generateIdForFile:C,onLinkOpen:S,generateLinkForSelection:L,onPointerDown:k,onPointerUp:A,onScrollChange:P,onDuplicate:B,validateEmbeddable:G,renderEmbeddable:J,aiEnabled:!1,showDeprecatedFonts:_,wheelZoomsOnDefault:R,strokeColorTopPicks:X,backgroundColorTopPicks:Z,renderScrollbars:Y,children:O})})})},lU=(e,o)=>{if(e.children!==o.children)return!1;let{initialData:t,UIOptions:r={},...n}=e,{initialData:i,UIOptions:a={},...l}=o,s=Object.keys(r),c=Object.keys(a);return s.length!==c.length?!1:s.every(m=>m==="canvasActions"?Object.keys(r.canvasActions).every(u=>u==="export"&&r?.canvasActions?.export&&a?.canvasActions?.export?r.canvasActions.export.saveFileToDisk===a.canvasActions.export.saveFileToDisk:r?.canvasActions?.[u]===a?.canvasActions?.[u]):r[m]===a[m])&&iU(n,l)},sU=rU.memo(aU,lU);sU.displayName="Excalidraw";export{Rt as Button,gv as CaptureUpdateAction,sDe as DEFAULT_LASER_COLOR,wd as DefaultSidebar,oU as DiagramToCodePlugin,ba as Ellipsify,sU as Excalidraw,iDe as FONT_FAMILY,FG as Footer,zG as LiveCollaborationTrigger,lDe as MIME_TYPES,ft as MainMenu,dc as ROUNDNESS,Kt as Sidebar,ul as Stats,aDe as THEME,Tg as TTDDialog,JI as TTDDialogTrigger,cDe as UserIdleState,WG as WelcomeScreen,ci as bumpVersion,Pi as convertToExcalidrawElements,ho as defaultLang,O2 as elementPartiallyOverlapsWithOrContainsBBox,z2 as elementsOverlappingBBox,py as exportToBlob,cr as exportToCanvas,tA as exportToClipboard,ui as exportToSvg,MDe as getCommonBounds,bm as getDataURL,eDe as getFreeDrawSvgPath,bc as getLibraryItemsHash,U7e as getNonDeletedElements,z7e as getSceneVersion,W7e as getTextFromElements,LDe as getVisibleSceneBounds,H7e as hashElementsVersion,G7e as hashString,gh as isElementInsideBBox,RDe as isElementLink,X7e as isInvisiblySmallElement,rDe as isLinearElement,Tn as languages,Gl as loadFromBlob,fm as loadLibraryFromBlob,gm as loadSceneOrLibraryFromBlob,wy as mergeLibraryItems,pc as mutateElement,pDe as newElementWith,dDe as normalizeLink,Ou as parseLibraryTokensFromUrl,QG as reconcileElements,yn as restore,oC as restoreAppState,hm as restoreElements,Qi as restoreLibraryItems,ly as sceneCoordsToViewportCoords,ji as serializeAsJSON,um as serializeLibraryAsJSON,BDe as setCustomTextMetricsProvider,ce as useDevice,xA as useHandleLibrary,Oe as useI18n,fDe as viewportCoordsToSceneCoords,wx as zoomToFitBounds};