@excalidraw/excalidraw 0.18.0-a30e1b2 → 0.18.0-a8acc82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev/chunk-6MX365WZ.js +5666 -0
- package/dist/dev/chunk-6MX365WZ.js.map +7 -0
- package/dist/dev/chunk-CP5DND7P.js +7 -0
- package/dist/dev/chunk-CP5DND7P.js.map +7 -0
- package/dist/dev/{chunk-CARD3WJZ.js → chunk-QF5FRM6O.js} +7 -2
- package/dist/dev/chunk-QF5FRM6O.js.map +7 -0
- package/dist/dev/data/{image-AYLHSOBV.js → image-GQCFJKGM.js} +3 -3
- package/dist/dev/index.css +187 -21
- package/dist/dev/index.css.map +3 -3
- package/dist/dev/index.js +15073 -16288
- package/dist/dev/index.js.map +4 -4
- package/dist/dev/locales/{en-E3O5XSXJ.js → en-SMAPCEOQ.js} +2 -2
- package/dist/dev/subset-shared.chunk.js +1 -1
- package/dist/dev/subset-worker.chunk.js +1 -1
- package/dist/prod/chunk-A66AFZZU.js +7 -0
- package/dist/prod/chunk-I4UNSFV6.js +12 -0
- package/dist/prod/chunk-R2M7VUMD.js +4 -0
- package/dist/prod/data/image-JWK7QZ22.js +1 -0
- package/dist/prod/index.css +1 -1
- package/dist/prod/index.js +27 -20
- package/dist/prod/locales/{en-44IKVKYT.js → en-TYY6KWIJ.js} +1 -1
- package/dist/prod/subset-shared.chunk.js +1 -1
- package/dist/prod/subset-worker.chunk.js +1 -1
- package/dist/types/common/src/constants.d.ts +38 -7
- package/dist/types/common/src/utils.d.ts +7 -5
- package/dist/types/element/src/Scene.d.ts +10 -6
- package/dist/types/element/src/align.d.ts +3 -2
- package/dist/types/element/src/binding.d.ts +11 -8
- package/dist/types/element/src/bounds.d.ts +12 -4
- package/dist/types/element/src/collision.d.ts +18 -12
- package/dist/types/element/src/cropElement.d.ts +1 -1
- package/dist/types/element/src/delta.d.ts +41 -9
- package/dist/types/element/src/distance.d.ts +2 -2
- package/dist/types/element/src/distribute.d.ts +2 -1
- package/dist/types/element/src/dragElements.d.ts +1 -1
- package/dist/types/element/src/flowchart.d.ts +1 -1
- package/dist/types/element/src/fractionalIndex.d.ts +8 -2
- package/dist/types/element/src/frame.d.ts +2 -2
- package/dist/types/element/src/groups.d.ts +1 -0
- package/dist/types/element/src/index.d.ts +42 -0
- package/dist/types/element/src/linearElementEditor.d.ts +15 -24
- package/dist/types/element/src/mutateElement.d.ts +1 -1
- package/dist/types/element/src/newElement.d.ts +3 -2
- package/dist/types/element/src/positionElementsOnGrid.d.ts +2 -0
- package/dist/types/element/src/renderElement.d.ts +4 -1
- package/dist/types/element/src/resizeElements.d.ts +2 -1
- package/dist/types/element/src/selection.d.ts +0 -5
- package/dist/types/element/src/shape.d.ts +42 -0
- package/dist/types/element/src/sizeHelpers.d.ts +2 -1
- package/dist/types/element/src/store.d.ts +19 -9
- package/dist/types/element/src/textElement.d.ts +2 -2
- package/dist/types/element/src/transformHandles.d.ts +2 -2
- package/dist/types/element/src/typeChecks.d.ts +16 -1
- package/dist/types/element/src/types.d.ts +10 -4
- package/dist/types/element/src/utils.d.ts +16 -6
- package/dist/types/element/src/zindex.d.ts +3 -3
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +24 -15
- package/dist/types/excalidraw/actions/actionAlign.d.ts +8 -8
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +16 -10
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +134 -94
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +53 -33
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +8 -5
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +27 -17
- package/dist/types/excalidraw/actions/actionDistribute.d.ts +4 -4
- package/dist/types/excalidraw/actions/actionDuplicateSelection.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +8 -5
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +31 -26
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +8 -5
- package/dist/types/excalidraw/actions/actionExport.d.ts +94 -67
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +66 -19
- package/dist/types/excalidraw/actions/actionFlip.d.ts +4 -4
- package/dist/types/excalidraw/actions/actionFrame.d.ts +81 -69
- package/dist/types/excalidraw/actions/actionGroup.d.ts +20 -14
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +534 -7
- package/dist/types/excalidraw/actions/actionLink.d.ts +10 -7
- package/dist/types/excalidraw/actions/actionMenu.d.ts +26 -17
- package/dist/types/excalidraw/actions/actionNavigate.d.ts +16 -10
- package/dist/types/excalidraw/actions/actionProperties.d.ts +145 -83
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +10 -7
- package/dist/types/excalidraw/actions/actionStyles.d.ts +12 -9
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +10 -7
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +10 -7
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +10 -7
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +10 -7
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +10 -7
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +10 -7
- package/dist/types/excalidraw/actions/actionZindex.d.ts +10 -10
- package/dist/types/excalidraw/actions/index.d.ts +1 -1
- package/dist/types/excalidraw/actions/types.d.ts +3 -2
- package/dist/types/excalidraw/appState.d.ts +20 -10
- package/dist/types/excalidraw/clipboard.d.ts +64 -1
- package/dist/types/excalidraw/components/Actions.d.ts +8 -5
- package/dist/types/excalidraw/components/App.d.ts +22 -21
- package/dist/types/excalidraw/components/ButtonIcon.d.ts +1 -0
- package/dist/types/excalidraw/components/ColorPicker/ColorInput.d.ts +2 -1
- package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +7 -2
- package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +1 -1
- package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +2 -3
- package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +2 -3
- package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +2 -2
- package/dist/types/excalidraw/components/ColorPicker/TopPicks.d.ts +1 -1
- package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -1
- package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +1 -1
- package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +2 -28
- package/dist/types/excalidraw/components/ElementLinkDialog.d.ts +1 -1
- package/dist/types/excalidraw/components/Ellipsify.d.ts +4 -0
- package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +2 -1
- package/dist/types/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +2 -1
- package/dist/types/excalidraw/components/PropertiesPopover.d.ts +1 -0
- package/dist/types/excalidraw/components/{ButtonIconSelect.d.ts → RadioSelection.d.ts} +1 -1
- package/dist/types/excalidraw/components/Range.d.ts +3 -3
- package/dist/types/excalidraw/components/Stats/Angle.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/CanvasGrid.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/Dimension.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/DragInput.d.ts +12 -2
- package/dist/types/excalidraw/components/Stats/FontSize.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/MultiFontSize.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/Position.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/utils.d.ts +1 -1
- package/dist/types/excalidraw/components/UnlockPopup.d.ts +8 -0
- package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +1 -1
- package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +2 -1
- package/dist/types/excalidraw/components/icons.d.ts +9 -0
- package/dist/types/excalidraw/components/shapes.d.ts +129 -1
- package/dist/types/excalidraw/data/blob.d.ts +3 -7
- package/dist/types/excalidraw/data/reconcile.d.ts +1 -0
- package/dist/types/excalidraw/data/restore.d.ts +6 -1
- package/dist/types/excalidraw/data/transform.d.ts +1 -1
- package/dist/types/excalidraw/data/types.d.ts +4 -1
- package/dist/types/excalidraw/eraser/index.d.ts +0 -2
- package/dist/types/excalidraw/fonts/Fonts.d.ts +1 -1
- package/dist/types/excalidraw/history.d.ts +21 -5
- package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +14 -0
- package/dist/types/excalidraw/index.d.ts +11 -10
- package/dist/types/excalidraw/lasso/index.d.ts +1 -0
- package/dist/types/excalidraw/lasso/utils.d.ts +2 -1
- package/dist/types/excalidraw/renderer/helpers.d.ts +4 -4
- package/dist/types/excalidraw/renderer/staticScene.d.ts +4 -1
- package/dist/types/excalidraw/scene/Renderer.d.ts +1 -2
- package/dist/types/excalidraw/scene/index.d.ts +2 -2
- package/dist/types/excalidraw/snapping.d.ts +2 -2
- package/dist/types/excalidraw/types.d.ts +24 -13
- package/dist/types/math/src/angle.d.ts +2 -0
- package/dist/types/math/src/constants.d.ts +3 -0
- package/dist/types/math/src/curve.d.ts +32 -0
- package/dist/types/math/src/index.d.ts +1 -0
- package/dist/types/math/src/point.d.ts +1 -1
- package/dist/types/math/src/rectangle.d.ts +2 -0
- package/dist/types/math/src/segment.d.ts +1 -0
- package/dist/types/math/src/vector.d.ts +4 -2
- package/dist/types/utils/src/bbox.d.ts +1 -1
- package/dist/types/utils/src/index.d.ts +1 -1
- package/dist/types/utils/src/withinBounds.d.ts +1 -1
- package/history.ts +108 -45
- package/package.json +13 -10
- package/dist/dev/chunk-CARD3WJZ.js.map +0 -7
- package/dist/dev/chunk-ETWEPOFC.js +0 -18701
- package/dist/dev/chunk-ETWEPOFC.js.map +0 -7
- package/dist/dev/chunk-RS23HYC4.js +0 -7
- package/dist/dev/chunk-RS23HYC4.js.map +0 -7
- package/dist/prod/chunk-6BSJPDKJ.js +0 -33
- package/dist/prod/chunk-FGHASORR.js +0 -12
- package/dist/prod/chunk-SBKTMZM7.js +0 -7
- package/dist/prod/data/image-VAYKYPXV.js +0 -1
- package/dist/types/element/src/Shape.d.ts +0 -17
- package/dist/types/element/src/ShapeCache.d.ts +0 -25
- package/dist/types/element/src/shapes.d.ts +0 -23
- package/dist/types/excalidraw/components/ButtonSelect.d.ts +0 -9
- package/dist/types/excalidraw/visualdebug.d.ts +0 -41
- package/dist/types/utils/src/collision.d.ts +0 -8
- /package/dist/dev/data/{image-AYLHSOBV.js.map → image-GQCFJKGM.js.map} +0 -0
- /package/dist/dev/locales/{en-E3O5XSXJ.js.map → en-SMAPCEOQ.js.map} +0 -0
package/dist/prod/index.js
CHANGED
|
@@ -1,26 +1,33 @@
|
|
|
1
|
-
import{$ as N1,$a as It,$b as mb,$c as Sb,$d as uu,$e as Eu,$f as Iu,$g as Y0,A as L1,Aa as $p,Ab as mt,Ac as vb,Ad as _l,Ae as l0,Af as S0,Ag as Jc,Ah as ad,B as Hp,Ba as io,Bb as iu,Bc as Br,Bd as Ub,Be as s0,Bf as Vc,Bg as la,Bh as Ou,C as D1,Ca as Tl,Cb as dn,Cc as su,Cd as Gb,Ce as fu,Cf as Yc,Cg as At,Ch as ld,D as El,Da as Ct,Db as ib,Dc as Tc,Dd as ut,De as Ue,Df as C0,Dg as tr,Dh as rx,E as Up,Ea as uc,Eb as au,Ec as $o,Ed as kc,Ee as c0,Ef as Bl,Eg as RT,Eh as Bu,F as Ce,Fa as Sl,Fb as ab,Fc as Ht,Fd as ji,Fe as Q,Ff as Fl,Fg as Gl,Fh as Gr,G as hr,Ga as Nr,Gb as gr,Gc as jo,Gd as Vb,Ge as Pc,Gf as I0,Gg as Vl,Gh as nx,H as $n,Ha as zt,Hb as Jn,Hc as Sc,Hd as li,He as Me,Hf as $,Hg as ye,Hh as sd,I as yl,Ia as hc,Ib as Ge,Ic as Cc,Id as Yb,Ie as Rc,If as Ur,Ig as Yl,Ih as ix,J as Wt,Ja as at,Jb as Qn,Jc as Kt,Jd as Mc,Je as d0,Jf as k0,Jg as U0,Jh as ax,K as yt,Ka as cn,Kb as Wi,Kc as Fr,Kd as AT,Ke as m0,Kf as M0,Kg as hi,Kh as lx,L as se,La as $1,Lb as Zo,Lc as xe,Ld as Wb,Le as Nc,Lf as A0,Lg as yr,Lh as $l,M as Ft,Ma as Cl,Mb as lb,Mc as Zt,Md as fn,Me as bu,Mf as zl,Mg as G0,Mh as Fu,N as ic,Na as ao,Nb as sb,Nc as ri,Nd as Xe,Ne as p0,Nf as yn,Ng as sa,Nh as sx,O as Rr,Oa as vt,Ob as ei,Oc as Xi,Od as Pl,Oe as so,Of as Hl,Og as V0,Oh as cx,P as nn,Pa as j1,Pb as Ne,Pc as K,Pd as Ac,Pe as u0,Pf as wu,Pg as Du,Ph as dx,Q as ac,Qa as q1,Qb as N,Qc as wb,Qd as _o,Qe as h0,Qf as Tu,Qg as vn,Qh as mx,R as Gp,Ra as J1,Rb as Ke,Rc as Ic,Rd as pe,Re as ea,Rf as Su,Rg as wn,S as an,Sa as Ko,Sb as Pt,Sc as J,Sd as Ut,Se as g0,Sf as Cu,Sg as co,T as lc,Ta as Q1,Tb as Al,Tc as cu,Td as Lc,Te as di,Tf as ra,Tg as or,U as _1,Ua as me,Ub as mn,Uc as le,Ud as Kb,Ue as f0,Uf as Ve,Ug as ca,V as vl,Va as T,Vb as yc,Vc as Ie,Vd as Zb,Ve as ta,Vf as Wc,Vg as Qc,W as P1,Wa as gc,Wb as lu,Wc as ee,Wd as Xb,We as Oc,Wf as L0,Wg as _u,X as R1,Xa as jn,Xb as Or,Xc as du,Xd as $b,Xe as b0,Xf as Ee,Xg as Wl,Y as Vp,Ya as jp,Yb as ti,Yc as mu,Yd as qi,Ye as Bc,Yf as Kc,Yg as ed,Z as wl,Za as Gi,Zb as cb,Zc as Tb,Zd as bn,Ze as xr,Zf as na,Zg as Pu,_ as ge,_a as fc,_b as db,_c as zr,_d as Dc,_e as xu,_f as Mt,_g as Ru,a as Js,aa as sc,ab as Do,ac as pb,ad as ni,ae as LT,af as x0,ag as D0,ah as W0,b as x1,ba as ln,bb as eb,bc as ub,bd as Hr,be as DT,bf as Fc,bg as Zc,bh as K0,c as Zn,ca as O1,cb as qp,cc as q,cd as Cb,ce as _T,cf as zc,cg as Rt,ch as td,d as E1,da as B1,db as Il,dc as hb,dd as ii,de as si,df as E0,dg as ku,dh as Kl,e as y1,ea as F1,eb as Vi,ec as fr,ed as it,ee as Rl,ef as y0,eg as _0,eh as od,f as v1,fa as z1,fb as Yi,fc as gb,fd as He,fe as Ji,ff as v0,fg as ia,fh as rd,g as no,ga as H1,gb as Jp,gc as oi,gd as Ib,ge as hu,gf as PT,gg as Ul,gh as Z0,h as Qs,ha as Ui,hb as bc,hc as fb,hd as gn,he as gu,hf as Er,hg as Xt,hh as X0,i as ec,ia as Yp,ib as Qp,ic as et,id as kb,ie as jb,if as oa,ig as P0,ih as Zl,j as tc,ja as Wp,jb as eu,jc as Oe,jd as Mb,je as qb,jf as kt,jg as R0,jh as $0,k as w1,ka as U1,kb as tb,kc as bb,kd as Ab,ke as ht,kf as re,kg as yo,kh as j0,l as T1,la as G1,lb as tu,lc as vc,ld as $i,le as _c,lf as Jo,lg as er,lh as q0,m as S1,ma as cc,mb as M,mc as Ki,md as Lb,me as Jb,mf as w0,mg as Xc,mh as nd,n as C1,na as dc,nb as ie,nc as xb,nd as Db,ne as qo,nf as mi,ng as Mu,nh as da,o as Wo,oa as Kp,ob as ou,oc as pn,od as _b,oe as Qb,of as Hc,og as pi,oh as J0,p as oc,pa as V1,pb as qn,pc as Ll,pd as Pb,pe as e0,pf as Uc,pg as N0,ph as Nu,q as I1,qa as Y1,qb as xc,qc as pt,qd as Rb,qe as Qi,qf as Nl,qg as aa,qh as NT,r as Pr,ra as W1,rb as ru,rc as un,rd as Nb,re as Be,rf as Gc,rg as O0,rh as ma,s as k1,sa as K1,sb as Ec,sc as Xo,sd as Ob,se as t0,sf as Ol,sg as B0,sh as Xl,t as rc,ta as mc,tb as ob,tc as hn,td as Dl,te as o0,tf as Qo,tg as F0,u as M1,ua as sn,ub as rb,uc as Eb,ud as Bb,ue as r0,uf as T0,ug as Au,uh as Q0,v as bl,va as Z1,vb as Eo,vc as wc,vd as pu,ve as ci,vf as xn,vg as $c,w as xl,wa as Zp,wb as kl,wc as lo,wd as Fb,we as n0,wf as gt,wg as jc,wh as ex,x as A1,xa as Xp,xb as Ml,xc as Zi,xd as ai,xe as i0,xf as En,xg as qc,xh as tx,y as Xn,ya as X1,yb as nb,yc as Ze,yd as zb,ye as br,yf as yu,yg as ui,yh as id,z as nc,za as pc,zb as nu,zc as yb,zd as Hb,ze as a0,zf as vu,zg as z0,zh as ox}from"./chunk-6BSJPDKJ.js";import{a as k}from"./chunk-SBKTMZM7.js";import{J as Lu}from"./chunk-FGHASORR.js";import{c as H0}from"./chunk-Z3N5DIM6.js";import{b as f1,c as b1,d as S}from"./chunk-SRAX5OIU.js";import b7,{useEffect as x7}from"react";import cT from"clsx";import W8 from"lodash.throttle";import _r,{useContext as Wn}from"react";import{flushSync as Vn}from"react-dom";import K8 from"roughjs/bin/rough";import{nanoid as Z8}from"nanoid";var OT=e=>{let t=e.slice(),o=new Set,r=i=>{let a=i[0]?.groupIds?.join(""),l=[i[0]],s=[];for(let c of i.slice(1))c.groupIds?.join("")===a?l.push(c):s.push(c);return s.length?[...l,...r(s)]:l},n=new Map;return t.forEach((i,a)=>{if(!n.has(i.id))if(i.groupIds?.length){let l=i.groupIds[i.groupIds.length-1],s=t.slice(a).filter(c=>{let m=c?.groupIds?.some(d=>d===l);return m&&n.set(c.id,!0),m});for(let c of r(s))o.add(c)}else o.add(i)}),o.size!==e.length?(console.error("normalizeGroupElementOrder: lost some elements... bailing!"),e):[...o]},BT=e=>{let t=hb(e),o=e.slice(),r=new Set;return o.forEach((n,i)=>{n&&(n.boundElements?.length?(r.add(n),o[i]=null,n.boundElements.forEach(a=>{let l=t.get(a.id);l&&a.type==="text"&&(r.add(l[0]),o[l[1]]=null)})):n.type==="text"&&n.containerId&&t.get(n.containerId)?.[0].boundElements?.find(l=>l.id===n.id)||(r.add(n),o[i]=null))}),r.size!==e.length?(console.error("normalizeBoundElementsOrder: lost some elements... bailing!"),e):[...r]},px=e=>BT(OT(e));var FT=(e,t,o,r)=>{let n=mo(o);return et()&&zT(n,o.id),n.id=Ht(),n.updated=ub(),r&&(n.seed=$o(),Jo(n)),n.groupIds=a0(n.groupIds,e,i=>(t.has(i)||t.set(i,Ht()),t.get(i))),n},gi=e=>{let{elements:t}=e,o="appState"in e?e.appState:{editingGroupId:null,selectedGroupIds:{}},r=new Map,n=new Map,i=[],a=[],l=new Map,s=new Map,c=new Map,m=q(t),d=e.type==="in-place"?e.idsOfElementsToDuplicate:new Map(t.map(b=>[b.id,b]));if(e.type==="in-place")for(let b of Object.keys(e.appState.selectedGroupIds))t.filter(E=>E.groupIds?.includes(b)).forEach(E=>d.set(E.id,E));t=px(t);let p=t.slice(),u=b=>{let w=Tc(b).reduce((y,v)=>{if(r.has(v.id))return y;r.set(v.id,!0);let C=FT(o.editingGroupId,n,v,e.randomizeSeed);return r.set(C.id,!0),c.set(C.id,C),l.set(v.id,C.id),s.set(C.id,v),a.push(v),i.push(C),y.push(C),y},[]);return Array.isArray(b)?w:w[0]||null},h=(b,E)=>{if(E){if(b>p.length-1){p.push(...Tc(E));return}p.splice(b+1,0,...Tc(E))}},x=new Set(t.filter(b=>d.has(b.id)&&J(b)).map(b=>b.id));for(let b of t){if(r.has(b.id)||!d.has(b.id))continue;let E=Jb(o,b);if(E){let w=Be(t,E).flatMap(v=>J(v)?[...so(t,v.id),v]:[v]),y=Or(p,v=>v.groupIds?.includes(E));h(y,u(w));continue}if(!(b.frameId&&x.has(b.frameId))){if(J(b)){let w=b.id,y=so(t,w),v=Or(p,C=>C.frameId===w||C.id===w);h(v,u([...y,b]));continue}if(it(b)){let w=pe(b,m),y=Or(p,v=>v.id===b.id||"containerId"in v&&v.containerId===b.id);w?h(y,u([b,w])):h(y,u(b));continue}if(He(b)){let w=Ut(b,m),y=Or(p,v=>v.id===b.id||v.id===w?.id);w?h(y,u([w,b])):h(y,u(b));continue}h(Or(p,w=>w.id===b.id),u(b))}}if(S0(i,l,c),d0(p,a,l),e.overrides)for(let b of i){let E=s.get(b.id);E&&Object.assign(b,e.overrides({duplicateElement:b,origElement:E,origIdToDuplicateId:l}))}return{duplicatedElements:i,duplicateElementsMap:c,elementsWithDuplicates:p,origIdToDuplicateId:l}},zu=(e,t=0)=>{if(e==null||typeof e!="object")return e;let o=Object.prototype.toString.call(e);if(o==="[object Object]"){let r=typeof e.constructor=="function"?Object.create(Object.getPrototypeOf(e)):{};for(let n in e)if(e.hasOwnProperty(n)){if(t===0&&(n==="shape"||n==="canvas"))continue;r[n]=zu(e[n],t+1)}return r}if(Array.isArray(e)){let r=e.length,n=new Array(r);for(;r--;)n[r]=zu(e[r],t+1);return n}return k.DEV&&o!=="[object Object]"&&o!=="[object Array]"&&o.startsWith("[object ")&&console.warn(`_deepCloneElement: unexpected object type ${o}. This value will not be cloned!`),e},mo=e=>zu(e),zT=(e,t)=>{Object.defineProperty(e,q1,{value:t,writable:!1,enumerable:!1})};var ux={mouse:8,pen:16,touch:28},HT=16,gx={e:!0,s:!0,n:!0,w:!0};var hx={e:!0,s:!0,n:!0,w:!0,nw:!0,se:!0},Hu={e:!0,s:!0,n:!0,w:!0},Vr=(e,t,o,r,n,i,a)=>{let[l,s]=ie(M(e+o/2,t+r/2),M(n,i),a);return[l-o/2,s-r/2,o,r]},cd=e=>!(e.viewport.isMobile||e.isTouchScreen&&(I1||rc)),fi=e=>cd(e)?gx:{},jl=([e,t,o,r,n,i],a,l,s,c={},m=4,d=an)=>{let p=ux[s],u=p/l.value,h=p/l.value,x=p/l.value,b=p/l.value,E=o-e,w=r-t,y=m/l.value,v=(p-d*2)/(2*l.value),C={nw:c.nw?void 0:Vr(e-y-x+v,t-y-b+v,u,h,n,i,a),ne:c.ne?void 0:Vr(o+y-v,t-y-b+v,u,h,n,i,a),sw:c.sw?void 0:Vr(e-y-x+v,r+y-v,u,h,n,i,a),se:c.se?void 0:Vr(o+y-v,r+y-v,u,h,n,i,a),rotation:c.rotation?void 0:Vr(e+E/2-u/2,t-y-b+v-HT/l.value,u,h,n,i,a)},I=5*ux.mouse/l.value;return Math.abs(E)>I&&(c.n||(C.n=Vr(e+E/2-u/2,t-y-b+v,u,h,n,i,a)),c.s||(C.s=Vr(e+E/2-u/2,r+y-v,u,h,n,i,a))),Math.abs(w)>I&&(c.w||(C.w=Vr(e-y-x+v,t+w/2-h/2,u,h,n,i,a)),c.e||(C.e=Vr(o+y-v,t+w/2-h/2,u,h,n,i,a))),C},dd=(e,t,o,r="mouse",n=gx)=>{if(e.locked||ee(e))return{};if(e.type==="freedraw"||le(e)){if(e.points.length===2){let[,a]=e.points;a[0]===0||a[1]===0?n=Hu:a[0]>0&&a[1]<0?n=hx:a[0]>0&&a[1]>0?n=Hu:a[0]<0&&a[1]>0?n=hx:a[0]<0&&a[1]<0&&(n=Hu)}}else J(e)&&(n={...n,rotation:!0});let i=le(e)?an+8:xe(e)?0:an;return jl(Ve(e,o,!0),e.angle,t,r,n,i,xe(e)?0:void 0)},md=(e,t)=>{if(t.editingLinearElement)return!1;if(e.length>1)return!0;let o=e[0];return ee(o)?!1:le(o)?o.points.length>2:!0};var pa=100,bi=100,Vu=e=>{switch(e){case T.ARROW_UP:return"up";case T.ARROW_DOWN:return"down";case T.ARROW_RIGHT:return"right";case T.ARROW_LEFT:return"left";default:return"right"}},fx=(e,t,o,r)=>{let n=[...o.values()].reduce((i,a)=>{let l;if(ee(a)&&(l=a[e==="predecessors"?"startBinding":"endBinding"])&&a[e==="predecessors"?"endBinding":"startBinding"]?.elementId===t.id){let s=o.get(l.elementId);if(!s)return i;hn(ni(s),"not an ExcalidrawBindableElement");let c=e==="predecessors"?a.points[a.points.length-1]:[0,0],m=Bb(t,M0(t),[c[0]+a.x,c[1]+a.y]);i.push({relative:s,heading:m})}return i},[]);switch(r){case"up":return n.filter(i=>Dl(i.heading,Ob)).map(i=>i.relative);case"down":return n.filter(i=>Dl(i.heading,Rb)).map(i=>i.relative);case"right":return n.filter(i=>Dl(i.heading,Pb)).map(i=>i.relative);case"left":return n.filter(i=>Dl(i.heading,Nb)).map(i=>i.relative)}},Uu=(e,t,o)=>fx("successors",e,t,o),Gu=(e,t,o)=>fx("predecessors",e,t,o),UT=(e,t,o)=>{let r=bi+e.width;if(o==="up"||o==="down"){let l=pa+e.height,s=e.x,c=e.x+e.width;if(t.every(m=>m.x+m.width<s||m.x>c))return{x:0,y:l*(o==="up"?-1:1)}}else if(o==="right"||o==="left"){let l=e.y,s=e.y+e.height;if(t.every(c=>c.y+c.height<l||c.y>s))return{x:(bi+e.width)*(o==="left"?-1:1),y:0}}if(o==="up"||o==="down"){let l=pa+e.height,s=(t.length===0,l),c=t.length===0?0:(t.length+1)%2===0?(t.length+1)/2*r:t.length/2*r*-1;return o==="up"?{x:c,y:s*-1}:{x:c,y:s}}let n=pa+e.height,i=(t.length===0,bi+e.width),a=t.length===0?0:(t.length+1)%2===0?(t.length+1)/2*n:t.length/2*n*-1;return o==="left"?{x:i*-1,y:a}:{x:i,y:a}},GT=(e,t,o,r)=>{let n=r.getNonDeletedElementsMap(),i=Uu(e,n,o),a=Gu(e,n,o),l=UT(e,[...i,...a],o),s=Rt({type:e.type,x:e.x+l.x,y:e.y+l.y,width:e.width,height:e.height,roundness:e.roundness,roughness:e.roughness,backgroundColor:e.backgroundColor,strokeColor:e.strokeColor,strokeWidth:e.strokeWidth,opacity:e.opacity,fillStyle:e.fillStyle,strokeStyle:e.strokeStyle});hn(ii(s),"not an ExcalidrawFlowchartNodeElement");let c=bx(e,s,o,t,r);return{nextNode:s,bindingArrow:c}},VT=(e,t,o,r,n)=>{let i=[];for(let a=0;a<n;a++){let l,s;if(o==="left"||o==="right"){let d=pa*(n-1)+n*e.height,p=e.y+e.height/2-d/2,u=bi+e.width;o==="left"&&(u*=-1),l=e.x+u;let h=(pa+e.height)*a;s=p+h}else{let d=bi*(n-1)+n*e.width,p=e.x+e.width/2-d/2,u=pa+e.height;o==="up"&&(u*=-1),s=e.y+u;let h=(bi+e.width)*a;l=p+h}let c=Rt({type:e.type,x:l,y:s,width:e.width,height:e.height,roundness:e.roundness,roughness:e.roughness,backgroundColor:e.backgroundColor,strokeColor:e.strokeColor,strokeWidth:e.strokeWidth,opacity:e.opacity,fillStyle:e.fillStyle,strokeStyle:e.strokeStyle});hn(ii(c),"not an ExcalidrawFlowchartNodeElement");let m=bx(e,c,o,t,r);i.push(c),i.push(m)}return i},bx=(e,t,o,r,n)=>{let i,a;switch(o){case"up":{i=e.x+e.width/2,a=e.y-6;break}case"down":{i=e.x+e.width/2,a=e.y+e.height+6;break}case"right":{i=e.x+e.width+6,a=e.y+e.height/2;break}case"left":{i=e.x-6,a=e.y+e.height/2;break}}let s,c;switch(o){case"up":{s=t.x+t.width/2-i,c=t.y+t.height-a+6;break}case"down":{s=t.x+t.width/2-i,c=t.y-a-6;break}case"right":{s=t.x-i-6,c=t.y-a+t.height/2;break}case"left":{s=t.x+t.width-i+6,c=t.y-a+t.height/2;break}}let m=er({type:"arrow",x:i,y:a,startArrowhead:null,endArrowhead:r.currentItemEndArrowhead,strokeColor:e.strokeColor,strokeStyle:e.strokeStyle,strokeWidth:e.strokeWidth,opacity:e.opacity,roughness:e.roughness,points:[M(0,0),M(s,c)],elbowed:!0}),d=n.getNonDeletedElementsMap();Qo(m,e,"start",n),Qo(m,t,"end",n);let p=new Map;p.set(e.id,e),p.set(t.id,t),p.set(m.id,m),$.movePoints(m,n,new Map([[1,{point:m.points[1]}]]));let u=oa(m,Br(new Map([...d.entries(),[e.id,e],[t.id,t],[m.id,m]])),{points:m.points});return{...m,...u}},pd=class{constructor(){S(this,"isExploring",!1);S(this,"sameLevelNodes",[]);S(this,"sameLevelIndex",0);S(this,"direction",null);S(this,"visitedNodes",new Set)}clear(){this.isExploring=!1,this.sameLevelNodes=[],this.sameLevelIndex=0,this.direction=null,this.visitedNodes.clear()}exploreByDirection(t,o,r){if(!ni(t))return null;if(r!==this.direction&&this.clear(),this.visitedNodes.has(t.id)||this.visitedNodes.add(t.id),this.isExploring&&r===this.direction&&this.sameLevelNodes.length>1)return this.sameLevelIndex=(this.sameLevelIndex+1)%this.sameLevelNodes.length,this.sameLevelNodes[this.sameLevelIndex].id;let n=[...Uu(t,o,r),...Gu(t,o,r)];if(n.length>0)return this.sameLevelIndex=0,this.isExploring=!0,this.sameLevelNodes=n,this.direction=r,this.visitedNodes.add(n[0].id),n[0].id;if(r===this.direction||!this.isExploring){this.isExploring||this.visitedNodes.add(t.id);let a=["up","right","down","left"].filter(l=>l!==r).map(l=>[...Uu(t,o,l),...Gu(t,o,l)]).flat().filter(l=>!this.visitedNodes.has(l.id));for(let l of a)if(!this.visitedNodes.has(l.id))return this.visitedNodes.add(l.id),this.isExploring=!0,this.direction=r,l.id}return null}},ud=class{constructor(){S(this,"isCreatingChart",!1);S(this,"numberOfNodes",0);S(this,"direction","right");S(this,"pendingNodes",null)}createNodes(t,o,r,n){let i=n.getNonDeletedElementsMap();if(r!==this.direction){let{nextNode:a,bindingArrow:l}=GT(t,o,r,n);this.numberOfNodes=1,this.isCreatingChart=!0,this.direction=r,this.pendingNodes=[a,l]}else{this.numberOfNodes+=1;let a=VT(t,o,r,n,this.numberOfNodes);this.isCreatingChart=!0,this.direction=r,this.pendingNodes=a}if(t.frameId){let a=i.get(t.frameId);hn(a&&wb(a),"not an ExcalidrawFrameElement"),a&&this.pendingNodes.every(l=>m0([l],a,i)||Nc(l,a,i))&&(this.pendingNodes=this.pendingNodes.map(l=>kt(l,i,{frameId:t.frameId})))}}clear(){this.isCreatingChart=!1,this.pendingNodes=null,this.direction=null,this.numberOfNodes=0}},xx=(e,t)=>{for(let[,o]of t)if(o.type==="arrow"&&(o.startBinding?.elementId===e.id||o.endBinding?.elementId===e.id))return!0;return!1};var Ex=(e,t,o,r,n,i,a,l,s,c,m)=>{let d=r.getNonDeletedElementsMap();if(o.length===1){let[p]=o;if(t==="rotation")ee(p)||(YT(p,r,l,s,n),gt(p,r));else{if(K(p)&&t)return WT(e,p,r,t,i,l,s),gt(p,r),!0;if(t){let u=o[0].id,h=d.get(u),x=e.get(u);if(h&&x){let{nextWidth:b,nextHeight:E}=$T(h,x,t,l,s,{shouldMaintainAspectRatio:a,shouldResizeFromCenter:i});xi(b,E,h,x,e,r,t,{shouldMaintainAspectRatio:a,shouldResizeFromCenter:i})}}}return!0}else if(o.length>1){if(t==="rotation")return KT(e,o,r,l,s,n,c,m),!0;if(t){let{nextWidth:p,nextHeight:u,flipByX:h,flipByY:x,originalBoundingBox:b}=jT(o,e,d,t,l,s,{shouldMaintainAspectRatio:a,shouldResizeFromCenter:i});return Wu(o,d,t,r,e,{shouldResizeFromCenter:i,shouldMaintainAspectRatio:a,flipByX:h,flipByY:x,nextWidth:p,nextHeight:u,originalBoundingBox:b}),!0}}return!1},YT=(e,t,o,r,n)=>{let[i,a,l,s]=Ve(e,t.getNonDeletedElementsMap()),c=(i+l)/2,m=(a+s)/2,d;J(e)?d=0:(d=5*Math.PI/2+Math.atan2(r-m,o-c),n&&(d=d+El/2,d=d-d%El),d=Il(d));let p=_o(e);if(t.mutateElement(e,{angle:d}),p){let u=t.getElement(p);u&&!Ie(e)&&t.mutateElement(u,{angle:d})}},hd=(e,t,o,r)=>le(e)||cu(e)?{points:nu(0,t,nu(1,o,e.points,r),r)}:{},Yu=(e,t,o)=>{let r=e.width;if(He(e)){let a=Ut(e,t);a&&(r=bn(a,e))}let i=e.fontSize*(o/r);return i<ic?null:{size:i}},WT=(e,t,o,r,n,i,a)=>{let l=o.getNonDeletedElementsMap(),[s,c,m,d,p,u]=Ve(t,l),[h,x]=ie(M(i,a),M(p,u),-t.angle),b=0,E=0;r!=="e"&&r!=="w"&&(r.includes("e")&&(b=(h-s)/(m-s)),r.includes("w")&&(b=(m-h)/(m-s)),r.includes("n")&&(E=(d-x)/(d-c)),r.includes("s")&&(E=(x-c)/(d-c)));let w=Math.max(b,E);if(w>0){let y=t.width*w,v=t.height*w,C=Yu(t,l,y);if(C===null)return;let I=[s,c],L=[m,d],A=[p,u],R=M(s,c);if(["n","w","nw"].includes(r)&&(R=M(L[0]-Math.abs(y),L[1]-Math.abs(v))),r==="ne"){let B=[I[0],L[1]];R=M(B[0],B[1]-Math.abs(v))}if(r==="sw"){let B=[L[0],I[1]];R=M(B[0]-Math.abs(y),B[1])}["s","n"].includes(r)&&(R[0]=A[0]-y/2),["e","w"].includes(r)&&(R[1]=A[1]-v/2),n&&(R[0]=A[0]-Math.abs(y)/2,R[1]=A[1]-Math.abs(v)/2);let _=t.angle,z=ie(R,M(p,u),_),W=M(R[0]+Math.abs(y)/2,R[1]+Math.abs(v)/2),G=ie(W,M(p,u),_);R=ie(z,G,-_);let[j,H]=R;o.mutateElement(t,{fontSize:C.size,width:y,height:v,x:j,y:H})}if(r==="e"||r==="w"){let y=e.get(t.id),[v,C,I,L]=na(y,y.width,y.height,!0),A=M(v,C),R=M(I,L),_=ou(A,R),z=ie(M(i,a),_,-y.angle),[W,,G]=na(t,t.width,t.height,!0),j=G-W,H=R[0]-A[0],B=ji(Ge({fontSize:t.fontSize,fontFamily:t.fontFamily}),t.lineHeight),U=H/j;r.includes("e")&&(U=(z[0]-A[0])/j),r.includes("w")&&(U=(R[0]-z[0])/j);let oe=t.width*U<B?B:t.width*U,Z=fn(t.originalText,Ge(t),Math.abs(oe)),ce=ut(Z,Ge(t),t.lineHeight),ue=ce.height,[he,nt,to,pr]=na(y,oe,ue,!0),Yo=to-he,tn=pr-nt,oo=[...A];["n","w","nw"].includes(r)&&(oo=[R[0]-Math.abs(Yo),A[1]]);let ur=y.angle,ro=ie(oo,_,ur),on=M(oo[0]+Math.abs(Yo)/2,oo[1]+Math.abs(tn)/2),xo=ie(on,_,ur);oo=ie(ro,xo,-ur);let js={width:Math.abs(oe),height:Math.abs(ce.height),x:oo[0],y:oo[1],text:Z,autoResize:!1};o.mutateElement(t,js)}},KT=(e,t,o,r,n,i,a,l)=>{let s=o.getNonDeletedElementsMap(),c=5*Math.PI/2+Math.atan2(n-l,r-a);i&&(c+=El/2,c-=c%El);for(let m of t)if(!J(m)){let[d,p,u,h]=Ve(m,s),x=(d+u)/2,b=(p+h)/2,E=e.get(m.id)?.angle??m.angle,[w,y]=ie(M(x,b),M(a,l),c+E-m.angle),v=ee(m)?{points:I0(m,s)}:{x:m.x+(w-x),y:m.y+(y-b),angle:Il(c+E)};o.mutateElement(m,v),gt(m,o,{simultaneouslyUpdated:t});let C=pe(m,s);C&&!Ie(m)&&o.mutateElement(C,{x:C.x+(w-x),y:C.y+(y-b),angle:Il(c+E)})}o.triggerUpdate()},yx=(e,t,o,r,n)=>{let[i,a,l,s]=t.length===1?Ve(t[0],o):Ee(t),c=(i+l)/2,m=(a+s)/2,d=t.length===1?t[0].angle:0;switch([r,n]=ie(M(r,n),M(c,m),-d),e){case"n":return ie(M(r-(i+l)/2,n-a),M(0,0),d);case"s":return ie(M(r-(i+l)/2,n-s),M(0,0),d);case"w":return ie(M(r-i,n-(a+s)/2),M(0,0),d);case"e":return ie(M(r-l,n-(a+s)/2),M(0,0),d);case"nw":return ie(M(r-i,n-a),M(0,0),d);case"ne":return ie(M(r-l,n-a),M(0,0),d);case"sw":return ie(M(r-i,n-s),M(0,0),d);case"se":return ie(M(r-l,n-s),M(0,0),d);default:return[0,0]}},vx=(e,t)=>{let[,[o,r]]=t.points;return e==="nw"&&(o<0||r<0)||e==="ne"&&o>=0||e==="sw"&&o<=0||e==="se"&&(o>0||r>0)?"end":"origin"},ZT=(e,t,o)=>{if(o)return"center";if(t)switch(e){case"n":return"south-side";case"e":return"west-side";case"s":return"north-side";case"w":return"east-side";case"ne":return"bottom-left";case"nw":return"bottom-right";case"se":return"top-left";case"sw":return"top-right"}return["e","se","s"].includes(e)?"top-left":["n","nw","w"].includes(e)?"bottom-right":e==="ne"?"bottom-left":"top-right"},XT=(e,t,o,r,n,i,a,l,s)=>{let c=ZT(a,l,s),[m,d]=e;switch(c){case"top-left":return{x:m+(t-r)/2+(r-t)/2*Math.cos(i)+(o-n)/2*Math.sin(i),y:d+(o-n)/2+(r-t)/2*Math.sin(i)+(n-o)/2*Math.cos(i)};case"top-right":return{x:m+(t-r)/2*(Math.cos(i)+1)+(o-n)/2*Math.sin(i),y:d+(o-n)/2+(t-r)/2*Math.sin(i)+(n-o)/2*Math.cos(i)};case"bottom-left":return{x:m+(t-r)/2*(1-Math.cos(i))+(n-o)/2*Math.sin(i),y:d+(o-n)/2*(Math.cos(i)+1)+(r-t)/2*Math.sin(i)};case"bottom-right":return{x:m+(t-r)/2*(Math.cos(i)+1)+(n-o)/2*Math.sin(i),y:d+(o-n)/2*(Math.cos(i)+1)+(t-r)/2*Math.sin(i)};case"center":return{x:m-(r-t)/2,y:d-(n-o)/2};case"east-side":return{x:m+(t-r)/2*(Math.cos(i)+1),y:d+(t-r)/2*Math.sin(i)+(o-n)/2};case"west-side":return{x:m+(t-r)/2*(1-Math.cos(i)),y:d+(r-t)/2*Math.sin(i)+(o-n)/2};case"north-side":return{x:m+(t-r)/2+(o-n)/2*Math.sin(i),y:d+(n-o)/2*(Math.cos(i)-1)};case"south-side":return{x:m+(t-r)/2+(n-o)/2*Math.sin(i),y:d+(o-n)/2*(Math.cos(i)+1)}}},xi=(e,t,o,r,n,i,a,{shouldInformMutation:l=!0,shouldMaintainAspectRatio:s=!1,shouldResizeFromCenter:c=!1}={})=>{let m={},d=i.getNonDeletedElementsMap(),p=pe(o,d);if(p){let b=n.get(p.id);if(b&&(m={fontSize:b.fontSize}),s){let E={...o,width:e,height:t},w=Yu(p,d,bn(E,p));if(w===null)return;m={fontSize:w.size}}else{let E=kc(Ge(p),p.lineHeight),w=Mc(p.fontSize,p.lineHeight);e=Math.max(e,E),t=Math.max(t,w)}}let u=hd(r,e,t,!0),h=M(r.x,r.y);if(le(r)){let[b,E]=L0(r,n);h=M(b,E)}let x=XT(h,r.width,r.height,e,t,r.angle,a,s,c);if(le(r)&&u.points){let b=r.x-h[0],E=r.y-h[1];x.x+=b,x.y+=E;let w=u.points[0][0],y=u.points[0][1];x.x+=w,x.y+=y,u.points=u.points.map(v=>M(v[0]-w,v[1]-y))}if(e<0&&(x.x=x.x+e),t<0&&(x.y=x.y+t),"scale"in o&&"scale"in r&&i.mutateElement(o,{scale:[(Math.sign(e)||r.scale[0])*r.scale[0],(Math.sign(t)||r.scale[1])*r.scale[1]]}),Ie(o)&&p&&s){let b=e/o.width*p.fontSize;if(b<ic)return;m.fontSize=b}if(e!==0&&t!==0&&Number.isFinite(x.x)&&Number.isFinite(x.y)){let b={...x,width:Math.abs(e),height:Math.abs(t),...u};i.mutateElement(o,b,{informMutation:l,isDragging:!1}),p&&m!=null&&i.mutateElement(p,{fontSize:m.fontSize}),Pl(o,i,a,s),gt(o,i,{newSize:{width:e,height:t}})}},$T=(e,t,o,r,n,{shouldMaintainAspectRatio:i=!1,shouldResizeFromCenter:a=!1}={})=>{let[l,s,c,m]=na(t,t.width,t.height,!0),d=M(l,s),p=M(c,m),u=ou(d,p),h=ie(M(r,n),u,-t.angle),[x,b,E,w]=na(e,e.width,e.height,!0),y=E-x,v=w-b,C=p[0]-d[0],I=p[1]-d[1],L=C/y,A=I/v;o.includes("e")&&(L=(h[0]-d[0])/y),o.includes("s")&&(A=(h[1]-d[1])/v),o.includes("w")&&(L=(p[0]-h[0])/y),o.includes("n")&&(A=(p[1]-h[1])/v);let R=e.width*L,_=e.height*A;if(a&&(R=2*R-t.width,_=2*_-t.height),i){let z=Math.abs(R)/t.width,W=Math.abs(_)/t.height;if(o.length===1&&(_*=z,R*=W),o.length===2){let G=Math.max(z,W);R=t.width*G*Math.sign(R),_=t.height*G*Math.sign(_)}}return{nextWidth:R,nextHeight:_}},jT=(e,t,o,r,n,i,{shouldMaintainAspectRatio:a=!1,shouldResizeFromCenter:l=!1}={})=>{let s=e.map(G=>t.get(G.id)),c=s.reduce((G,j)=>{if(!le(j))return G;let H=_o(j);if(!H)return G;let B=t.get(H)??null;return He(B)?[...G,{...B,...$.getBoundTextElementPosition(j,B,o)}]:G},[]),m=Mt(s.map(G=>G).concat(c)),{minX:d,minY:p,maxX:u,maxY:h,midX:x,midY:b}=m,E=u-d,w=h-p,y={ne:[d,h],se:[d,p],sw:[u,p],nw:[u,h],e:[d,p+w/2],w:[u,p+w/2],n:[d+E/2,h],s:[d+E/2,p]},[v,C]=l?[x,b]:y[r],I=l?2:1,L=Math.max(Math.abs(n-v)/E||0,Math.abs(i-C)/w||0)*I,A=r.includes("e")||r.includes("w")?Math.abs(n-v)*I:E,R=r.includes("n")||r.includes("s")?Math.abs(i-C)*I:w;a&&(A=E*L*Math.sign(n-v),R=w*L*Math.sign(i-C));let _={ne:[n<v,i>C],se:[n<v,i<C],sw:[n>v,i<C],nw:[n>v,i>C],e:[n<v,!1],w:[n>v,!1],n:[!1,i>C],s:[!1,i<C]},[z,W]=_[r].map(G=>G);return{originalBoundingBox:m,nextWidth:A,nextHeight:R,flipByX:z,flipByY:W}},Wu=(e,t,o,r,n,{shouldMaintainAspectRatio:i=!1,shouldResizeFromCenter:a=!1,flipByX:l=!1,flipByY:s=!1,nextHeight:c,nextWidth:m,originalBoundingBox:d}={})=>{if(m===void 0&&c===void 0&&l===void 0&&s===void 0||c===0||m===0)return;n||(n=t);let p=e.reduce((I,L)=>{let A=n.get(L.id);return A&&I.push({orig:A,latest:L}),I},[]),u;if(d)u=d;else{let I=p.reduce((L,{orig:A})=>{if(!le(A))return L;let R=_o(A);if(!R)return L;let _=n.get(R)??null;return He(_)?[...L,{..._,...$.getBoundTextElementPosition(A,_,t)}]:L},[]);u=Mt(p.map(({orig:L})=>L).concat(I))}let{minX:h,minY:x,maxX:b,maxY:E,midX:w,midY:y}=u,v=b-h,C=E-x;if(m===void 0&&c===void 0&&(m=v,c=C),i&&(m===void 0?m=c*(v/C):c===void 0?c=m*(C/v):Math.abs(m/c-v/C)>.001&&(m=c*(v/C))),m&&c){let I=o.includes("e")||o.includes("w")?Math.abs(m)/v:1,L=o.includes("n")||o.includes("s")?Math.abs(c)/C:1,A;o.length===1?A=o.includes("e")||o.includes("w")?I:L:A=Math.max(Math.abs(m)/v||0,Math.abs(c)/C||0);let R={ne:[h,E],se:[h,x],sw:[b,x],nw:[b,E],e:[h,x+C/2],w:[b,x+C/2],n:[h+v/2,E],s:[h+v/2,x]},[_,z]=a?[w,y]:R[o],W=i||p.some(U=>U.latest.angle!==0||K(U.latest)||br(U.latest));W&&(I=A,L=A);let[G,j]=[l?-1:1,s?-1:1],H=[];for(let{orig:U,latest:oe}of p){if(K(U)&&He(U))continue;let Z=U.width*I,ce=U.height*L,ue=Il(U.angle*G*j),he=le(U)||cu(U),nt=U.x-_,to=U.y-z,pr=l&&!he?Z:0,Yo=s&&!he?ce:0,tn=_+G*(nt*I+pr),oo=z+j*(to*L+Yo),ur=hd(U,Z*G,ce*j,!1),ro={x:tn,y:oo,width:Z,height:ce,angle:ue,...ur};if(ee(U)&&(U.startBinding&&(ro.startBinding={...U.startBinding,fixedPoint:[l?-U.startBinding.fixedPoint[0]+1:U.startBinding.fixedPoint[0],s?-U.startBinding.fixedPoint[1]+1:U.startBinding.fixedPoint[1]]}),U.endBinding&&(ro.endBinding={...U.endBinding,fixedPoint:[l?-U.endBinding.fixedPoint[0]+1:U.endBinding.fixedPoint[0],s?-U.endBinding.fixedPoint[1]+1:U.endBinding.fixedPoint[1]]}),U.fixedSegments&&ur.points&&(ro.fixedSegments=U.fixedSegments.map(xo=>({...xo,start:ur.points[xo.index-1],end:ur.points[xo.index]})))),xe(U)&&(ro.scale=[U.scale[0]*G,U.scale[1]*j]),K(U)){let xo=Yu(U,t,Z);if(!xo)return;ro.fontSize=xo.size}let on=n.get(_o(U)??"");if(on)if(W){let xo=on.fontSize*A;if(xo<ic)return;ro.boundTextFontSize=xo}else ro.boundTextFontSize=on.fontSize;H.push({element:oe,update:ro})}let B=H.map(({element:U})=>U);for(let{element:U,update:{boundTextFontSize:oe,...Z}}of H){let{width:ce,height:ue,angle:he}=Z;r.mutateElement(U,Z,{informMutation:!0,isDragging:!0}),gt(U,r,{simultaneouslyUpdated:B,newSize:{width:ce,height:ue}});let nt=pe(U,t);nt&&oe&&(r.mutateElement(nt,{fontSize:oe,angle:le(U)?void 0:he}),Pl(U,r,o,!0))}r.triggerUpdate()}};var Zu=(e,t,o)=>t>=e[0]&&t<=e[0]+e[2]&&o>=e[1]&&o<=e[1]+e[3],qT=(e,t,o,r,n,i,a,l)=>{if(!o.selectedElementIds[e.id])return!1;let{rotation:s,...c}=dd(e,i,t,a,fi(l));if(s&&Zu(s,r,n))return"rotation";let m=Object.keys(c).filter(d=>{let p=c[d];return p?Zu(p,r,n):!1});if(m.length>0)return m[0];if(cd(l)){let[d,p,u,h,x,b]=Ve(e,t);if(!(le(e)&&e.points.length<=2)){let E=xe(e)?0:lc/i.value,w=lc/i.value,y=wx(M(d-E,p-E),M(u+E,h+E),M(x,b),e.angle);for(let[v,C]of Object.entries(y))if(ru(M(r,n),C,w))return v}}return!1},Xu=(e,t,o,r,n,i,a,l)=>e.reduce((s,c)=>{if(s)return s;let m=qT(c,a,t,o,r,n,i,l);return m?{element:c,transformHandleType:m}:null},null),$u=([e,t,o,r],n,i,a,l,s)=>{let c=jl([e,t,o,r,(e+o)/2,(t+r)/2],0,a,l,fi(s)),m=Object.keys(c).find(d=>{let p=c[d];return p&&Zu(p,n,i)});if(m)return m;if(cd(s)){let d=(e+o)/2,p=(t+r)/2,u=lc/a.value,h=wx(M(e-u,t-u),M(o+u,r+u),M(d,p),0);for(let[x,b]of Object.entries(h))if(ru(M(n,i),b,u))return x}return!1},Ku=["ns","nesw","ew","nwse"],JT=(e,t)=>{let o=Ku.indexOf(e);if(o>=0){let r=Math.round(t/(Math.PI/4));e=Ku[(o+r)%Ku.length]}return e},ju=e=>{let{element:t,transformHandleType:o}=e,r=t&&Math.sign(t.height)*Math.sign(t.width)===-1,n=null;switch(o){case"n":case"s":n="ns";break;case"w":case"e":n="ew";break;case"nw":case"se":r?n="nesw":n="nwse";break;case"ne":case"sw":r?n="nwse":n="nesw";break;case"rotation":return"grab"}return n&&t&&(n=JT(n,t.angle)),n?`${n}-resize`:""},wx=([e,t],[o,r],n,i)=>{let a=ie(M(e,t),n,i),l=ie(M(o,t),n,i),s=ie(M(e,r),n,i),c=ie(M(o,r),n,i);return{n:[a,l],e:[l,c],s:[c,s],w:[s,a]}};var Sx=(e,t,o,r,n,i)=>{if(t.length===1&&ee(t[0])&&(t[0].startBinding||t[0].endBinding))return;let a=t.filter(d=>{if(ee(d)&&d.startBinding&&d.endBinding){let p=t.find(h=>h.id===d.startBinding?.elementId),u=t.find(h=>h.id===d.endBinding?.elementId);return p&&u}return!0}),l=new Set(a),s=a.filter(d=>J(d)).map(d=>d.id);if(s.length>0)for(let d of r.getNonDeletedElements())d.frameId!==null&&s.includes(d.frameId)&&l.add(d);let c=[];for(let d of l){let p=e.originalElements.get(d.id);if(!p)return;c.push(p)}let m=QT(Ee(c),o,n,i);l.forEach(d=>{if(Tx(e,d,r,m),!Ie(d)){let p=pe(d,r.getNonDeletedElementsMap());p&&Tx(e,p,r,m),gt(d,r,{simultaneouslyUpdated:Array.from(l)})}})},QT=(e,t,o,r)=>{let[n,i]=e,a=n+t.x+o.x,l=i+t.y+o.y;if(o.x===0||o.y===0){let[s,c]=mt(n+t.x,i+t.y,r);o.x===0&&(a=s),o.y===0&&(l=c)}return{x:a-n,y:l-i}},Tx=(e,t,o,r)=>{let n=e.originalElements.get(t.id)??t,i=n.x+r.x,a=n.y+r.y;o.mutateElement(t,{x:i,y:a})},Cx=(e,t,o)=>{let[r,n]=Ee(e);return[t-r,o-n]},qu=({newElement:e,elementType:t,originX:o,originY:r,x:n,y:i,width:a,height:l,shouldMaintainAspectRatio:s,shouldResizeFromCenter:c,zoom:m,scene:d,widthAspectRatio:p=null,originOffset:u=null,informMutation:h=!0})=>{s&&e.type!=="selection"&&(p?l=a/p:(Math.abs(i-r)>Math.abs(n-o)?{width:a,height:l}=hu(t,l,n<o?-a:a):{width:a,height:l}=hu(t,a,i<r?-l:l),l<0&&(l=-l)));let x=n<o?o-a:o,b=i<r?r-l:r;c&&(a+=a,l+=l,x=o-a/2,b=r-l/2);let E=null;if(K(e)){l=e.height;let w=ji(Ge({fontSize:e.fontSize,fontFamily:e.fontFamily}),e.lineHeight);a=Math.max(a,w),Math.abs(n-o)>A1/m&&(E={autoResize:!1}),b=r,c&&(x=o-a/2)}if(a!==0&&l!==0){let w=null;xe(e)&&(w={initialWidth:a,initialHeight:l}),d.mutateElement(e,{x:x+(u?.x??0),y:b+(u?.y??0),width:a,height:l,...E,...w},{informMutation:h,isDragging:!1})}};import e6 from"lodash.throttle";var Ix=e=>{let t=new Map,o=[];for(let r of e)r.isDeleted||(o.push(r),t.set(r.id,r));return{elementsMap:t,elements:o}},t6=e6(e=>{(Oe()||et()||window?.DEBUG_FRACTIONAL_INDICES)&&Jc(e,{shouldThrow:Oe()||et(),includeBoundTextValidation:!0})},1e3*60,{leading:!0,trailing:!1}),o6=e=>{let t=["includeBoundTextElement","includeElementsInFrames"],o="";for(let r of t)o+=`${r}:${e[r]?"1":"0"}`;return o},Ju=class{constructor(t=null){S(this,"callbacks",new Set);S(this,"nonDeletedElements",[]);S(this,"nonDeletedElementsMap",Br(new Map));S(this,"elements",[]);S(this,"nonDeletedFramesLikes",[]);S(this,"frames",[]);S(this,"elementsMap",Br(new Map));S(this,"selectedElementsCache",{selectedElementIds:null,elements:null,cache:new Map});S(this,"sceneNonce");S(this,"insertElement",t=>{let o=t.frameId?this.getElementIndex(t.frameId):this.elements.length;this.insertElementAtIndex(t,o)});S(this,"insertElements",t=>{if(!t.length)return;let o=t[0]?.frameId?this.getElementIndex(t[0].frameId):this.elements.length;this.insertElementsAtIndex(t,o)});S(this,"getContainerElement",t=>t&&t.containerId&&this.getElement(t.containerId)||null);S(this,"getElementsFromId",t=>{let o=this.getNonDeletedElementsMap(),r=o.get(t);return r?[r]:Be(o,t)});t&&this.replaceAllElements(t)}getSceneNonce(){return this.sceneNonce}getNonDeletedElementsMap(){return this.nonDeletedElementsMap}getElementsIncludingDeleted(){return this.elements}getElementsMapIncludingDeleted(){return this.elementsMap}getNonDeletedElements(){return this.nonDeletedElements}getFramesIncludingDeleted(){return this.frames}getSelectedElements(t){let o=o6(t),r=t?.elements||this.nonDeletedElements;if(this.selectedElementsCache.elements===r&&this.selectedElementsCache.selectedElementIds===t.selectedElementIds){let i=this.selectedElementsCache.cache.get(o);if(i)return i}else t?.elements==null&&this.selectedElementsCache.cache.clear();let n=Q(r,{selectedElementIds:t.selectedElementIds},t);return t?.elements==null&&(this.selectedElementsCache.selectedElementIds=t.selectedElementIds,this.selectedElementsCache.elements=this.nonDeletedElements,this.selectedElementsCache.cache.set(o,n)),n}getNonDeletedFramesLikes(){return this.nonDeletedFramesLikes}getElement(t){return this.elementsMap.get(t)||null}getNonDeletedElement(t){let o=this.getElement(t);return o&&Yl(o)?o:null}mapElements(t){let o=!1,r=this.elements.map(n=>{let i=t(n);return i!==n&&(o=!0),i});return o&&this.replaceAllElements(r),o}replaceAllElements(t){let o=fb(t),r=[];t6(o),this.elements=tr(o),this.elementsMap.clear(),this.elements.forEach(i=>{J(i)&&r.push(i),this.elementsMap.set(i.id,i)});let n=Ix(this.elements);this.nonDeletedElements=n.elements,this.nonDeletedElementsMap=n.elementsMap,this.frames=r,this.nonDeletedFramesLikes=Ix(this.frames).elements,this.triggerUpdate()}triggerUpdate(){this.sceneNonce=$o();for(let t of Array.from(this.callbacks))t()}onUpdate(t){if(this.callbacks.has(t))throw new Error;return this.callbacks.add(t),()=>{if(!this.callbacks.has(t))throw new Error;this.callbacks.delete(t)}}destroy(){this.elements=[],this.nonDeletedElements=[],this.nonDeletedFramesLikes=[],this.frames=[],this.elementsMap.clear(),this.selectedElementsCache.selectedElementIds=null,this.selectedElementsCache.elements=null,this.selectedElementsCache.cache.clear(),this.callbacks.clear()}insertElementAtIndex(t,o){if(!Number.isFinite(o)||o<0)throw new Error("insertElementAtIndex can only be called with index >= 0");let r=[...this.elements.slice(0,o),t,...this.elements.slice(o)];At(r,q([t])),this.replaceAllElements(r)}insertElementsAtIndex(t,o){if(!t.length)return;if(!Number.isFinite(o)||o<0)throw new Error("insertElementAtIndex can only be called with index >= 0");let r=[...this.elements.slice(0,o),...t,...this.elements.slice(o)];At(r,q(t)),this.replaceAllElements(r)}getElementIndex(t){return this.elements.findIndex(o=>o.id===t)}mutateElement(t,o,r={informMutation:!0,isDragging:!1}){let n=this.getNonDeletedElementsMap(),{version:i}=t,{version:a}=kt(t,n,o,r);return this.elementsMap.has(t.id)&&i!==a&&r.informMutation&&this.triggerUpdate(),t}},Ei=Ju;var $e=class e{constructor(t,o){this.deleted=t;this.inserted=o}static create(t,o,r,n){let i=r&&n!=="inserted"?r(t):t,a=r&&n!=="deleted"?r(o):o;return new e(i,a)}static calculate(t,o,r,n){if(t===o)return e.empty();let i={},a={};for(let c of this.distinctKeysIterator("full",t,o))i[c]=t[c],a[c]=o[c];let[l,s]=n?n(i,a):[i,a];return e.create(l,s,r)}static empty(){return new e({},{})}static isEmpty(t){return!Object.keys(t.deleted).length&&!Object.keys(t.inserted).length}static mergeObjects(t,o,r){let n={...t};for(let i of Object.keys(r))delete n[i];return{...n,...o}}static mergeArrays(t,o,r,n){return Object.values(e.mergeObjects(fr(t??[],n),fr(o??[],n),fr(r??[],n)))}static diffObjects(t,o,r,n){if(!(!t[r]&&!o[r])&&(typeof t[r]=="object"||typeof o[r]=="object")){let i=t[r]??{},a=o[r]??{},l=e.getLeftDifferences(i,a).reduce((c,m)=>(c[m]=n(i[m]),c),{}),s=e.getRightDifferences(i,a).reduce((c,m)=>(c[m]=n(a[m]),c),{});Object.keys(l).length||Object.keys(s).length?(Reflect.set(t,r,l),Reflect.set(o,r,s)):(Reflect.deleteProperty(t,r),Reflect.deleteProperty(o,r))}}static diffArrays(t,o,r,n){if(!(!t[r]&&!o[r])&&(Array.isArray(t[r])||Array.isArray(o[r]))){let i=Array.isArray(t[r])?t[r]:[],a=Array.isArray(o[r])?o[r]:[],l=fr(e.getLeftDifferences(fr(i,n),fr(a,n))),s=fr(e.getRightDifferences(fr(i,n),fr(a,n)));if(Object.keys(l).length||Object.keys(s).length){let c=i.filter(d=>l[n?n(d):String(d)]),m=a.filter(d=>s[n?n(d):String(d)]);Reflect.set(t,r,c),Reflect.set(o,r,m)}else Reflect.deleteProperty(t,r),Reflect.deleteProperty(o,r)}}static isLeftDifferent(t,o,r=!1){return!!this.distinctKeysIterator("left",t,o,r).next().value}static isRightDifferent(t,o,r=!1){return!!this.distinctKeysIterator("right",t,o,r).next().value}static getLeftDifferences(t,o,r=!1){return Array.from(this.distinctKeysIterator("left",t,o,r)).sort()}static getRightDifferences(t,o,r=!1){return Array.from(this.distinctKeysIterator("right",t,o,r)).sort()}static*distinctKeysIterator(t,o,r,n=!1){if(o===r)return;let i=[];t==="left"?i=Object.keys(o):t==="right"?i=Object.keys(r):t==="full"?i=Array.from(new Set([...Object.keys(o),...Object.keys(r)])):Xo(t,`Unknown distinctKeysIterator's join param "${t}"`,!0);for(let a of i){let l=o[a],s=r[a];if(l!==s){if(!n&&typeof l=="object"&&typeof s=="object"&&l!==null&&s!==null&&pt(l,s))continue;yield a}}}},yi=class e{constructor(t){this.delta=t}static calculate(t,o){let r=$e.calculate(t,o,e.orderAppStateKeys,e.postProcess);return new e(r)}static restore(t){let{delta:o}=t;return new e(o)}static empty(){return new e($e.create({},{}))}inverse(){let t=$e.create(this.delta.inserted,this.delta.deleted);return new e(t)}applyTo(t,o){try{let{selectedElementIds:r={},selectedGroupIds:n={}}=this.delta.deleted,{selectedElementIds:i={},selectedGroupIds:a={},selectedLinearElementId:l,editingLinearElementId:s,...c}=this.delta.inserted,m=$e.mergeObjects(t.selectedElementIds,i,r),d=$e.mergeObjects(t.selectedGroupIds,a,n),p=l&&o.has(l)?new $(o.get(l),o):null,u=s&&o.has(s)?new $(o.get(s),o):null,h={...t,...c,selectedElementIds:m,selectedGroupIds:d,selectedLinearElement:typeof l<"u"?p:t.selectedLinearElement,editingLinearElement:typeof s<"u"?u:t.editingLinearElement},x=this.filterInvisibleChanges(t,h,o);return[h,x]}catch(r){if(console.error("Couldn't apply appstate change",r),et()||Oe())throw r;return[t,!1]}}isEmpty(){return $e.isEmpty(this.delta)}filterInvisibleChanges(t,o,r){let n=ql(t),i=ql(o),a=$e.isRightDifferent(e.stripElementsProps(n),e.stripElementsProps(i)),l=$e.isRightDifferent(e.stripStandaloneProps(n),e.stripStandaloneProps(i));if(!a&&!l)return!1;let s={value:a};if(l){let c=$e.getRightDifferences(e.stripStandaloneProps(n),e.stripStandaloneProps(i)),m=new Set;(c.includes("editingGroupId")||c.includes("selectedGroupIds"))&&(m=n0(r));for(let d of c)switch(d){case"selectedElementIds":o[d]=e.filterSelectedElements(o[d],r,s);break;case"selectedGroupIds":o[d]=e.filterSelectedGroups(o[d],m,s);break;case"croppingElementId":{let x=o[d],b=x&&r.get(x);b&&!b.isDeleted?s.value=!0:o[d]=null;break}case"editingGroupId":let p=o[d];p?m.has(p)?s.value=!0:o[d]=null:s.value=!0;break;case"selectedLinearElementId":case"editingLinearElementId":let u=e.convertToAppStateKey(d),h=o[u];if(!h)s.value=!0;else{let x=r.get(h.elementId);x&&!x.isDeleted?s.value=!0:o[u]=null}break;default:Xo(d,`Unknown ObservedElementsAppState's key "${d}"`,!0)}}return s.value}static convertToAppStateKey(t){switch(t){case"selectedLinearElementId":return"selectedLinearElement";case"editingLinearElementId":return"editingLinearElement"}}static filterSelectedElements(t,o,r){let n=Object.keys(t);if(!n.length)return r.value=!0,t;let i={...t};for(let a of n){let l=o.get(a);l&&!l.isDeleted?r.value=!0:delete i[a]}return i}static filterSelectedGroups(t,o,r){if(!Object.keys(t).length)return r.value=!0,t;let i={...t};for(let a of Object.keys(i))o.has(a)?r.value=!0:delete i[a];return i}static stripElementsProps(t){let{editingGroupId:o,selectedGroupIds:r,selectedElementIds:n,editingLinearElementId:i,selectedLinearElementId:a,croppingElementId:l,...s}=t;return s}static stripStandaloneProps(t){let{name:o,viewBackgroundColor:r,...n}=t;return n}static postProcess(t,o){try{$e.diffObjects(t,o,"selectedElementIds",r=>!0),$e.diffObjects(t,o,"selectedGroupIds",r=>r??!1)}catch(r){if(console.error("Couldn't postprocess appstate change deltas."),et()||Oe())throw r}finally{return[t,o]}}static orderAppStateKeys(t){let o={};for(let r of Object.keys(t).sort())o[r]=t[r];return o}},Ae=class Ae{constructor(t,o,r){this.added=t;this.removed=o;this.updated=r}static create(t,o,r,n={shouldRedistribute:!1}){let i;if(n.shouldRedistribute){let a={},l={},s={},c=[...Object.entries(t),...Object.entries(o),...Object.entries(r)];for(let[m,d]of c)this.satisfiesAddition(d)?a[m]=d:this.satisfiesRemoval(d)?l[m]=d:s[m]=d;i=new Ae(a,l,s)}else i=new Ae(t,o,r);return(et()||Oe())&&(Ae.validate(i,"added",this.satisfiesAddition),Ae.validate(i,"removed",this.satisfiesRemoval),Ae.validate(i,"updated",this.satisfiesUpdate)),i}static restore(t){let{added:o,removed:r,updated:n}=t;return Ae.create(o,r,n)}static validate(t,o,r){for(let[n,i]of Object.entries(t[o]))if(!r(i))throw console.error(`Broken invariant for "${o}" delta, element "${n}", delta:`,i),new Error(`ElementsDelta invariant broken for element "${n}".`)}static calculate(t,o){if(t===o)return Ae.empty();let r={},n={},i={};for(let a of t.values())if(!o.get(a.id)){let s={...a,isDeleted:!1},c={isDeleted:!0},m=$e.create(s,c,Ae.stripIrrelevantProps);n[a.id]=m}for(let a of o.values()){let l=t.get(a.id);if(!l){let s={isDeleted:!0},c={...a,isDeleted:!1},m=$e.create(s,c,Ae.stripIrrelevantProps);r[a.id]=m;continue}if(l.versionNonce!==a.versionNonce){let s=$e.calculate(l,a,Ae.stripIrrelevantProps,Ae.postProcess);if(typeof l.isDeleted=="boolean"&&typeof a.isDeleted=="boolean"&&l.isDeleted!==a.isDeleted){l.isDeleted&&!a.isDeleted?r[a.id]=s:n[a.id]=s;continue}$e.isEmpty(s)||(i[a.id]=s)}}return Ae.create(r,n,i)}static empty(){return Ae.create({},{},{})}inverse(){let t=i=>{let a={};for(let[l,s]of Object.entries(i))a[l]=$e.create(s.inserted,s.deleted);return a},o=t(this.added),r=t(this.removed),n=t(this.updated);return Ae.create(r,o,n)}isEmpty(){return Object.keys(this.added).length===0&&Object.keys(this.removed).length===0&&Object.keys(this.updated).length===0}applyLatestChanges(t,o){let r=s=>c=>{let m={};for(let d of Object.keys(c))switch(d){case"boundElements":m[d]=c[d];break;default:m[d]=s[d]}return m},n=s=>{let c={};for(let[m,d]of Object.entries(s)){let p=t.get(m);if(p){let u=$e.create(d.deleted,d.inserted,r(p),o);c[m]=u}else c[m]=d}return c},i=n(this.added),a=n(this.removed),l=n(this.updated);return Ae.create(i,a,l,{shouldRedistribute:!0})}applyTo(t,o){let r=new Map(t),n,i={containsVisibleDifference:!1,containsZindexDifference:!1};try{let a=Ae.createApplier(r,o,i),l=a("added",this.added),s=a("removed",this.removed),c=a("updated",this.updated),m=this.resolveConflicts(t,r);n=new Map([...l,...s,...c,...m])}catch(a){if(console.error("Couldn't apply elements delta",a),et()||Oe())throw a;return[t,!0]}try{r=Ae.reorderElements(r,n,i);let a=new Ei(r);Ae.redrawTextBoundingBoxes(a,n),Ae.redrawBoundArrows(a,n)}catch(a){if(console.error("Couldn't mutate elements after applying elements change",a),et()||Oe())throw a}finally{return[r,i.containsVisibleDifference]}}static applyDelta(t,o,r={containsVisibleDifference:!0,containsZindexDifference:!0}){let{boundElements:n,...i}=o.inserted;if(o.deleted.boundElements?.length||o.inserted.boundElements?.length){let a=$e.mergeArrays(t.boundElements,o.inserted.boundElements,o.deleted.boundElements,l=>l.id);Object.assign(i,{boundElements:a})}if(t.type==="image"){let a=o;(a.deleted.crop||a.inserted.crop)&&Object.assign(i,{crop:a.inserted.crop??null})}if(!r.containsVisibleDifference){let{index:a,...l}=i,s=Ae.checkForVisibleDifference(t,l);r.containsVisibleDifference=s}return r.containsZindexDifference||(r.containsZindexDifference=o.deleted.index!==o.inserted.index),re(t,i)}static checkForVisibleDifference(t,o){return t.isDeleted&&o.isDeleted!==!1?!1:t.isDeleted&&o.isDeleted===!1||t.isDeleted===!1&&o.isDeleted?!0:$e.isRightDifferent(t,o)}resolveConflicts(t,o){let r=new Map,n=(c,m)=>{let d=o.get(c.id);if(!d)return;let p;t.get(c.id)===d?p=re(d,m):p=kt(d,o,m),r.set(p.id,p),o.set(p.id,p)};for(let c of Object.keys(this.removed))Ae.unbindAffected(t,o,c,n);for(let c of Object.keys(this.added))Ae.rebindAffected(t,o,c,n);for(let[c]of Array.from(Object.entries(this.updated)).filter(([m,d])=>Object.keys({...d.deleted,...d.inserted}).find(p=>C0.has(p)))){let m=o.get(c);!m||m.isDeleted||Ae.rebindAffected(t,o,c,n)}let i=new Map(Array.from(t).filter(([c])=>r.has(c))),{added:a,removed:l,updated:s}=Ae.calculate(i,r);for(let[c,m]of Object.entries(a))this.added[c]=m;for(let[c,m]of Object.entries(l))this.removed[c]=m;for(let[c,m]of Object.entries(s))this.updated[c]=m;return r}static unbindAffected(t,o,r,n){let i=()=>t.get(r),a=()=>o.get(r);Bl.unbindAffected(o,i(),n),Bl.unbindAffected(o,a(),n),Fl.unbindAffected(o,i(),n),Fl.unbindAffected(o,a(),n)}static rebindAffected(t,o,r,n){let i=()=>t.get(r),a=()=>o.get(r);Bl.unbindAffected(o,i(),n),Bl.rebindAffected(o,a(),n),Fl.unbindAffected(o,i(),(l,s)=>{K(l)&&n(l,s)}),Fl.rebindAffected(o,a(),n)}static redrawTextBoundingBoxes(t,o){let r=t.getNonDeletedElementsMap(),n=new Map;for(let i of o.values()){if(He(i)){let{containerId:a}=i,l=a?r.get(a):void 0;l&&n.set(l.id,{container:l,boundText:i})}if(it(i)){let a=_o(i),l=a?r.get(a):void 0;l&&n.set(i.id,{container:i,boundText:l})}}for(let{container:i,boundText:a}of n.values())i.isDeleted||a.isDeleted||Xe(a,i,t)}static redrawBoundArrows(t,o){for(let r of o.values())!r.isDeleted&&ni(r)&>(r,t,{changedElements:o})}static reorderElements(t,o,r){if(!r.containsZindexDifference)return t;let n=Array.from(t.values()),i=la([...n]),a=$e.getRightDifferences(n,i,!0).reduce((l,s)=>{let c=n[Number(s)];return c&&o.has(c.id)&&l.set(c.id,c),l},new Map);return!r.containsVisibleDifference&&a.size&&(r.containsVisibleDifference=!0),q(At(i,a))}static postProcess(t,o){try{$e.diffArrays(t,o,"boundElements",r=>r.id)}catch(r){if(console.error("Couldn't postprocess elements delta."),et()||Oe())throw r}finally{return[t,o]}}static stripIrrelevantProps(t){let{id:o,updated:r,version:n,versionNonce:i,...a}=t;return a}};S(Ae,"satisfiesAddition",({deleted:t,inserted:o})=>t.isDeleted===!0&&!o.isDeleted),S(Ae,"satisfiesRemoval",({deleted:t,inserted:o})=>!t.isDeleted&&o.isDeleted===!0),S(Ae,"satisfiesUpdate",({deleted:t,inserted:o})=>!!t.isDeleted==!!o.isDeleted),S(Ae,"createApplier",(t,o,r)=>(n,i)=>{let a=Ae.createGetter(n,t,o,r);return Object.entries(i).reduce((l,[s,c])=>{let m=a(s,c.inserted);if(m){let d=Ae.applyDelta(m,c,r);t.set(d.id,d),l.set(d.id,d)}return l},new Map)}),S(Ae,"createGetter",(t,o,r,n)=>(i,a)=>{let l=o.get(i);return l||(l=r.get(i),l?(n.containsZindexDifference=!0,(a.isDeleted===!1||a.isDeleted!==!0&&l.isDeleted===!1)&&(n.containsVisibleDifference=!0)):l=re({id:i,version:1},{...a})),l});var vi=Ae;var D={IMMEDIATELY:"IMMEDIATELY",NEVER:"NEVER",EVENTUALLY:"EVENTUALLY"},gd=class{constructor(t){this.app=t;S(this,"onDurableIncrementEmitter",new Kt);S(this,"onStoreIncrementEmitter",new Kt);S(this,"scheduledMacroActions",new Set);S(this,"scheduledMicroActions",[]);S(this,"_snapshot",ua.empty())}get snapshot(){return this._snapshot}set snapshot(t){this._snapshot=t}scheduleAction(t){this.scheduledMacroActions.add(t),this.satisfiesScheduledActionsInvariant()}scheduleCapture(){this.scheduleAction(D.IMMEDIATELY)}scheduleMicroAction(t){let{action:o}=t,r;if("change"in t)r=t.change;else{let i=ua.create(this.app.scene.getElementsMapIncludingDeleted(),this.app.state),a=i.maybeClone(o,t.elements,t.appState);r=wi.create(i,a)}let n="delta"in t?t.delta:void 0;this.scheduledMicroActions.push(()=>this.processAction({action:o,change:r,delta:n}))}commit(t,o){this.flushMicroActions();try{let r=this.getScheduledMacroAction();this.processAction({action:r,elements:t,appState:o})}finally{this.satisfiesScheduledActionsInvariant(),this.scheduledMacroActions=new Set}}clear(){this.snapshot=ua.empty(),this.scheduledMacroActions=new Set}emitDurableIncrement(t,o=void 0,r=void 0){let n=this.snapshot,i,a;if(o?i=o:i=wi.create(n,t),r)a=r;else{let l=t.metadata.didElementsChange?vi.calculate(n.elements,t.elements):vi.empty(),s=t.metadata.didAppStateChange?yi.calculate(n.appState,t.appState):yi.empty();a=ha.create(l,s)}if(!a.isEmpty()){let l=new Qu(i,a);this.onDurableIncrementEmitter.trigger(l),this.onStoreIncrementEmitter.trigger(l)}}emitEphemeralIncrement(t,o=void 0){let r;if(o)r=o;else{let i=this.snapshot;r=wi.create(i,t)}let n=new eh(r);this.onStoreIncrementEmitter.trigger(n)}applyChangeToSnapshot(t){let o=this.snapshot,r=this.snapshot.applyChange(t);return o===r?null:r}maybeCloneSnapshot(t,o,r){if(!o&&!r)return null;let n=this.snapshot,i=this.snapshot.maybeClone(t,o,r);return n===i?null:i}flushMicroActions(){for(let t of this.scheduledMicroActions)try{t()}catch(o){console.error("Failed to execute scheduled micro action",o)}this.scheduledMicroActions=[]}processAction(t){let{action:o}=t;if(o===D.EVENTUALLY&&!this.onStoreIncrementEmitter.subscribers.length)return;let r;if("change"in t?r=this.applyChangeToSnapshot(t.change):r=this.maybeCloneSnapshot(o,t.elements,t.appState),!r)return;let n="change"in t?t.change:void 0,i="delta"in t?t.delta:void 0;try{switch(o){case D.IMMEDIATELY:this.emitDurableIncrement(r,n,i);break;case D.NEVER:case D.EVENTUALLY:this.emitEphemeralIncrement(r,n);break;default:Xo(o,"Unknown store action")}}finally{switch(o){case D.IMMEDIATELY:case D.NEVER:this.snapshot=r;break}}}getScheduledMacroAction(){let t;return this.scheduledMacroActions.has(D.IMMEDIATELY)?t=D.IMMEDIATELY:this.scheduledMacroActions.has(D.NEVER)?t=D.NEVER:t=D.EVENTUALLY,t}satisfiesScheduledActionsInvariant(){if(!(this.scheduledMacroActions.size>=0&&this.scheduledMacroActions.size<=Object.keys(D).length)){let t=`There can be at most three store actions scheduled at the same time, but there are "${this.scheduledMacroActions.size}".`;if(console.error(t,this.scheduledMacroActions.values()),et()||Oe())throw new Error(t)}}},wi=class e{constructor(t,o){this.elements=t;this.appState=o}static create(t,o){let r=o.getChangedElements(t),n=o.getChangedAppState(t);return new e(r,n)}},fd=class{constructor(t,o){this.type=t;this.change=o}static isDurable(t){return t.type==="durable"}static isEphemeral(t){return t.type==="ephemeral"}},Qu=class extends fd{constructor(o,r){super("durable",o);this.change=o;this.delta=r}},eh=class extends fd{constructor(o){super("ephemeral",o);this.change=o}},ha=class{constructor(t,o,r){this.id=t;this.elements=o;this.appState=r}static create(t,o,r={id:Ht()}){return new this(r.id,t,o)}static restore(t){let{id:o,elements:r,appState:n}=t;return new this(o,vi.restore(r),yi.restore(n))}static load({id:t,elements:{added:o,removed:r,updated:n}}){let i=vi.create(o,r,n,{shouldRedistribute:!1});return new this(t,i,yi.empty())}static inverse(t){return this.create(t.elements.inverse(),t.appState.inverse())}static applyLatestChanges(t,o,r){return this.create(t.elements.applyLatestChanges(o,r),t.appState,{id:t.id})}static applyTo(t,o,r,n=ua.empty()){let[i,a]=t.elements.applyTo(o,n.elements),[l,s]=t.appState.applyTo(r,i);return[i,l,a||s]}isEmpty(){return this.elements.isEmpty()&&this.appState.isEmpty()}},ua=class e{constructor(t,o,r={didElementsChange:!1,didAppStateChange:!1,isEmpty:!1}){this.elements=t;this.appState=o;this.metadata=r;S(this,"_lastChangedElementsHash",0);S(this,"_lastChangedAppStateHash",0)}static create(t,o,r={didElementsChange:!1,didAppStateChange:!1}){return new e(t,kx(o)?o:ql(o),r)}static empty(){return new e(new Map,r6(),{didElementsChange:!1,didAppStateChange:!1,isEmpty:!0})}getChangedElements(t){let o={};for(let r of oi(t.elements))this.elements.get(r.id)||(o[r.id]=re(r,{isDeleted:!0}));for(let r of oi(this.elements))t.elements.get(r.id)!==r&&(o[r.id]=r);return o}getChangedAppState(t){return $e.getRightDifferences(t.appState,this.appState).reduce((o,r)=>Object.assign(o,{[r]:this.appState[r]}),{})}isEmpty(){return this.metadata.isEmpty}applyChange(t){let o=new Map(this.elements);for(let[n,i]of Object.entries(t.elements))o.set(n,i);let r=Object.assign({},this.appState,t.appState);return e.create(o,r,{didElementsChange:Object.keys(t.elements).length>0,didAppStateChange:Object.keys(t.appState).length>0})}maybeClone(t,o,r){let n={shouldCompareHashes:!1};t===D.EVENTUALLY&&(n.shouldCompareHashes=!0);let i=this.maybeCreateElementsSnapshot(o,n),a=this.maybeCreateAppStateSnapshot(r,n),l=!1,s=!1;return this.elements!==i&&(l=!0),this.appState!==a&&(s=!0),!l&&!s?this:new e(i,a,{didElementsChange:l,didAppStateChange:s})}maybeCreateAppStateSnapshot(t,o={shouldCompareHashes:!1}){if(!t)return this.appState;let r=kx(t)?t:ql(t);return this.detectChangedAppState(r,o)?r:this.appState}maybeCreateElementsSnapshot(t,o={shouldCompareHashes:!1}){if(!t)return this.elements;let r=this.detectChangedElements(t,o);return r?.size?this.createElementsSnapshot(r):this.elements}detectChangedAppState(t,o={shouldCompareHashes:!1}){if(this.appState===t)return;let r=$e.isRightDifferent(this.appState,t);if(!r)return;let n=Vl(JSON.stringify(t));if(!(o.shouldCompareHashes&&this._lastChangedAppStateHash===n))return this._lastChangedAppStateHash=n,r}detectChangedElements(t,o={shouldCompareHashes:!1}){if(this.elements===t)return;let r=new Map;for(let i of oi(this.elements))t.get(i.id)||r.set(i.id,re(i,{isDeleted:!0}));for(let i of oi(t)){let a=this.elements.get(i.id);(!a||a.version<i.version)&&r.set(i.id,i)}if(!r.size)return;let n=Gl(r);if(!(o.shouldCompareHashes&&this._lastChangedElementsHash===n))return this._lastChangedElementsHash=n,r}createElementsSnapshot(t){let o=new Map;for(let r of oi(this.elements))o.set(r.id,r);for(let r of oi(t))o.set(r.id,mo(r));return o}},Mx="__observedAppState",r6=()=>({name:null,editingGroupId:null,viewBackgroundColor:no.white,selectedElementIds:{},selectedGroupIds:{},editingLinearElementId:null,selectedLinearElementId:null,croppingElementId:null}),ql=e=>{let t={name:e.name,editingGroupId:e.editingGroupId,viewBackgroundColor:e.viewBackgroundColor,selectedElementIds:e.selectedElementIds,selectedGroupIds:e.selectedGroupIds,editingLinearElementId:e.editingLinearElement?.elementId||null,selectedLinearElementId:e.selectedLinearElement?.elementId||null,croppingElementId:e.croppingElementId};return Reflect.defineProperty(t,Mx,{value:!0,enumerable:!1}),t},kx=e=>!!Reflect.get(e,Mx);import{atom as ke,createStore as n6}from"jotai";import{createIsolation as i6}from"jotai-scope";var Ax=i6();var{useAtom:ve,useSetAtom:rr,useAtomValue:bd,useStore:d_}=Ax,Lx=Ax.Provider,Fe=n6();var a6=f1({"./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-44IKVKYT.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 l6=85,vr={code:"en",label:"English"},fa=[vr,...[{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=>H0[e.code]>=l6).sort((e,t)=>e.label>t.label?1:-1)],Ed="__test__";Oe()&&fa.unshift({code:Ed,label:"test language"},{code:`${Ed}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var ga=vr,xd={},yd=async e=>{if(ga=e,document.documentElement.dir=ga.rtl?"rtl":"ltr",document.documentElement.lang=ga.code,e.code.startsWith(Ed))xd={};else try{xd=await a6(`./locales/${ga.code}.json`)}catch(t){console.error(`Failed to load language ${e.code}:`,t.message),xd=Lu}Fe.set(_x,e.code)},Yr=()=>ga,Dx=(e,t)=>{for(let o=0;o<t.length;++o){let r=t[o];if(e[r]===void 0)return;e=e[r]}if(typeof e=="string")return e},f=(e,t,o)=>{if(ga.code.startsWith(Ed))return`\u202A[[${t?`${e}(${JSON.stringify(t).slice(1,-1)})`:e}]]\u202C`;let r=e.split("."),n=Dx(xd,r)||Dx(Lu,r)||o;if(n===void 0){let i=`Can't find translation for ${e}`;if(k.PROD)return console.warn(i),"";throw new Error(i)}if(t)for(let i in t)n=n.replace(`{{${i}}}`,String(t[i]));return n},_x=ke(vr.code),dt=()=>{let e=bd(_x);return{t:f,langCode:e}};import s6 from"clsx";import c6 from"open-color";import Nt from"react";import{Fragment as ze,jsx as g,jsxs as O}from"react/jsx-runtime";var nr=e=>"var(--icon-fill-color)",Px=e=>e===se.LIGHT?c6.white:"#1e1e1e",P=(e,t=512)=>{let{width:o=512,height:r=o,mirror:n,style:i,...a}=typeof t=="number"?{width:t}:t;return g("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${o} ${r}`,className:s6({"rtl-mirror":n}),style:i,...a,children:typeof e=="string"?g("path",{fill:"currentColor",d:e}):e})},Y={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},de={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},I_=P(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("rect",{x:3,y:8,width:18,height:4,rx:1}),g("line",{x1:12,y1:8,x2:12,y2:21}),g("path",{d:"M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"}),g("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"})]}),Y),ba=P(O("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),g("path",{d:"M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),g("line",{x1:"3",y1:"6",x2:"3",y2:"19"}),g("line",{x1:"12",y1:"6",x2:"12",y2:"19"}),g("line",{x1:"21",y1:"6",x2:"21",y2:"19"})]}),Y),Rx=P(O("svg",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),g("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),Y),Nx=P(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"1"}),g("circle",{cx:"12",cy:"19",r:"1"}),g("circle",{cx:"12",cy:"5",r:"1"})]}),Y),Ox=P(O("svg",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),g("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),g("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),Y),Ti=P(O("g",{children:[g("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"}),g("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"}),g("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:g("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"})}),g("g",{mask:"url(#UnlockedIcon)",children:g("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"})})]}),de),xa=P(O("g",{strokeWidth:"1.25",children:[g("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"}),g("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),g("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"})]}),de),Bx=P(O(ze,{children:[g("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"}),g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),g("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"}),Fx=P(O(ze,{children:[g("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"}),g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),g("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"}),zx=P(O(ze,{children:[g("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"}),g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),g("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"}),k_=P(g("g",{fill:"currentColor",children:g("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"}),Hx=P(O("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),Jl=P(O("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,children:[g("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"}),g("path",{d:"M5 15m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M5 17c0 1.42 .316 2.805 1 4"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),vd=P(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),Y),wd=P(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"})]}),Y),Td=P(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"9"})]}),Y),Ux=P(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),g("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),g("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),Y),Sd=P(g("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),de),Gx=P(O("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),g("path",{d:"M16 7h4"}),g("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),Y),Tn=P(O("g",{strokeWidth:"1.25",children:[g("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"}),g("path",{d:"m11.25 5.417 3.333 3.333"})]}),de),Ea=P(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),g("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),g("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),g("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),g("polyline",{points:"5 20 11 4 13 4 20 20"})]}),Y),Vx=P(O("g",{strokeWidth:"1.25",children:[g("path",{d:"M12.5 6.667h.01"}),g("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"}),g("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),g("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),de),Yx=P(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M18 13.3l-6.3 -6.3"})]}),Y),th=P(g("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),de),oh=P(g("path",{d:"M5 10h10",strokeWidth:"1.25"}),de),Wx=P(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M21 21l-6 -6"}),g("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"}),g("path",{d:"M3 4v4h4"})]}),Y),vo=P(g("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"}),de),rh=P(O("g",{strokeWidth:"1.5",children:[g("polyline",{points:"12 16 18 10 12 4"}),g("polyline",{points:"8 4 2 10 8 16"})]}),de),Ql=P(O("g",{strokeWidth:"1.25",children:[g("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"}),g("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"})]}),de),es=P(g("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"}),de),ts=P(g("g",{stroke:"currentColor",strokeLinejoin:"round",children:g("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"})}),{...de,strokeWidth:1.5}),Cd=P(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),g("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),g("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),Y),Si=P(g("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"}),de),ya=P(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"9"}),g("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),g("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),Y),Kx=P(O("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"9"}),g("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),g("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),Y),nh=P(g("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"}),de),Id=P(g("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"}),de),Zx=P(O("g",{strokeWidth:"1.25",children:[g("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"}),g("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"})]}),de),Xx=P(O("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),g("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),Y),$x=P(g("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),os=P(O("g",{strokeWidth:"1.25",children:[g("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"}),g("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"})]}),de),jx=P("M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z",{width:448,height:512}),qx=P("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}),va=P(g("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"}),de),M_=P("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}),Jx=P("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"),kd=P(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z"}),g("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"}),g("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"})]}),Y),Md=P(O("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15 8h.01"}),g("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),g("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),g("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),g("path",{d:"M19 16v6"}),g("path",{d:"M22 19l-3 3l-3 -3"})]}),Y),Qx=P("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}),A_=P("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}),L_=P("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}),eE=P("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"),D_=P("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"),ih=P(g("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"}),de),ah=P(g("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"}),de),tE=P("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}),oE=P(g("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"}),de),__=P("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"),P_=P("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}),R_=P(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M12 14v-11"}),g("path",{d:"M9 6l3 -3l3 3"})]}),Y),N_=P(O(ze,{children:[g("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"}),g("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}),O_=P(g("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}),rE=O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 10l0 10"}),g("path",{d:"M12 10l4 4"}),g("path",{d:"M12 10l-4 4"}),g("path",{d:"M4 4l16 0"})]}),nE=O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 5l0 14"}),g("path",{d:"M16 9l-4 -4"}),g("path",{d:"M8 9l4 -4"})]}),lh=P(nE,Y),sh=P(nE,{...Y,style:{transform:"rotate(180deg)"}}),ch=P(rE,Y),dh=P(rE,{...Y,style:{transform:"rotate(180deg)"}}),mh=P(O(ze,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("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"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),de),ph=P(O(ze,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("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"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),de),uh=P(O(ze,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("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"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),de),hh=P(O(ze,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("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"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),de),iE=P(O(ze,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("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"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),de),aE=P(O(ze,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("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"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),de),gh=P(O("g",{stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),g("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),g("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"})]}),de),fh=P(O("g",{stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),g("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),g("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"})]}),de),Ad=P(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"9",cy:"7",r:"4"}),g("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),g("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),g("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),Y),B_=P("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"),F_=P("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"),Po=P(O(ze,{children:[g("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:g("path",{d:"M15 5 5 15M5 5l10 10"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),de),z_=P("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}),H_=P("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}),U_=P("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}),bh=Nt.memo(({theme:e})=>P(O(ze,{children:[g("path",{d:"M25 26H111V111H25",fill:nr(e)}),g("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:nr(e),strokeWidth:"2"}),g("path",{d:"M100 100H160V160H100",fill:nr(e)}),g("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:nr(e),strokeWidth:"2"}),O("g",{fill:Px(e),stroke:nr(e),strokeWidth:"6",children:[g("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),g("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),xh=Nt.memo(({theme:e})=>P(O(ze,{children:[g("path",{d:"M25 26H111V111H25",fill:nr(e)}),g("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:nr(e),strokeWidth:"2"}),g("path",{d:"M100 100H160V160H100",fill:nr(e)}),g("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:nr(e),strokeWidth:"2"}),O("g",{fill:Px(e),stroke:nr(e),strokeWidth:"6",children:[g("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),g("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),g("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),g("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),lE=P(g("g",{strokeWidth:1.25,children:g("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"})}),de),sE=P(O(ze,{children:[g("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"}),g("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:g("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"})}),g("g",{mask:"url(#FillHachureIcon)",children:g("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"})})]}),de),cE=P(O(ze,{children:[O("g",{clipPath:"url(#a)",children:[g("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"}),g("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:g("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"})}),g("g",{mask:"url(#FillCrossHatchIcon)",children:g("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"})})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),de),dE=P(O(ze,{children:[g("g",{clipPath:"url(#a)",children:g("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"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...de,fill:"currentColor"}),Eh=P(g(ze,{children:g("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),de),mE=P(g("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),de),pE=P(g("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),de),G_=Nt.memo(({theme:e})=>P(g("path",{d:"M6 10H34",stroke:nr(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),uE=P(O("g",{strokeWidth:"2",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 12h2"}),g("path",{d:"M17 12h2"}),g("path",{d:"M11 12h2"})]}),Y),hE=P(O("g",{strokeWidth:"2",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 12v.01"}),g("path",{d:"M8 12v.01"}),g("path",{d:"M12 12v.01"}),g("path",{d:"M16 12v.01"}),g("path",{d:"M20 12v.01"})]}),Y),gE=P(g("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"}),de),fE=P(g("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"}),de),bE=P(g("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"}),de),xE=P(O("svg",{strokeWidth:"1.5",children:[g("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"}),g("path",{d:"M13.3333 3.33331V3.34331"}),g("path",{d:"M16.6667 3.33331V3.34331"}),g("path",{d:"M16.6667 6.66669V6.67669"}),g("path",{d:"M16.6667 10V10.01"}),g("path",{d:"M3.33334 13.3333V13.3433"}),g("path",{d:"M16.6667 13.3333V13.3433"}),g("path",{d:"M3.33334 16.6667V16.6767"}),g("path",{d:"M6.66666 16.6667V16.6767"}),g("path",{d:"M10 16.6667V16.6767"}),g("path",{d:"M13.3333 16.6667V16.6767"}),g("path",{d:"M16.6667 16.6667V16.6767"})]}),de),EE=P(O("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),g("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),g("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),g("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),g("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),g("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),g("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),g("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),g("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),g("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),g("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),g("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),Y),yE=P(O("g",{stroke:"currentColor",opacity:.3,strokeWidth:2,children:[g("path",{d:"M12 12l9 0"}),g("path",{d:"M3 9l6 6"}),g("path",{d:"M3 15l6 -6"})]}),Y),vE=Nt.memo(({flip:e=!1})=>P(O("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",children:[g("path",{d:"M34 10H6M34 10L27 5M34 10L27 15"}),g("path",{d:"M27.5 5L34.5 10L27.5 15"})]}),{width:40,height:20})),wE=Nt.memo(({flip:e=!1})=>P(O("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[g("path",{d:"M32 10L6 10",strokeWidth:2}),g("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),TE=Nt.memo(({flip:e=!1})=>P(O("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[g("path",{d:"M26 10L6 10"}),g("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),SE=Nt.memo(({flip:e=!1})=>P(g("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",children:g("path",{d:"M34 10H5.99996M34 10L34 5M34 10L34 15",stroke:"currentColor",strokeWidth:2,fill:"none"})}),{width:40,height:20})),CE=Nt.memo(({flip:e=!1})=>P(O("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[g("path",{d:"M32 10L6 10",strokeWidth:2}),g("path",{d:"M27.5 5.5L34.5 10L27.5 14.5L27.5 5.5"})]}),{width:40,height:20})),IE=Nt.memo(({flip:e=!1})=>P(O("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",children:[g("path",{d:"M6,9.5H27"}),g("path",{d:"M27,5L34,10L27,14Z",fill:"none"})]}),{width:40,height:20})),kE=Nt.memo(({flip:e=!1})=>P(O("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[g("path",{d:"M6,9.5H20"}),g("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),ME=Nt.memo(({flip:e=!1})=>P(O("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[g("path",{d:"M6,9.5H20"}),g("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),AE=Nt.memo(({flip:e=!1})=>P(g("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:g("path",{d:"M34,10 H6 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),LE=Nt.memo(({flip:e=!1})=>P(g("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:g("path",{d:"M34,10 H6 M15,10 L15,15 L15,5"})}),{width:40,height:20})),DE=Nt.memo(({flip:e=!1})=>P(g("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:g("path",{d:"M34,10 H6 M15,10 L15,16 L15,4 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),_E=P(O(ze,{children:[g("g",{clipPath:"url(#a)",children:g("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"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),de),PE=P(O(ze,{children:[g("g",{clipPath:"url(#a)",children:g("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),de),RE=P(O(ze,{children:[g("g",{clipPath:"url(#a)",children:g("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),de),NE=P(g(ze,{children:g("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"})}),de),Ci=P(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 7v-2h13v2"}),g("path",{d:"M10 5v14"}),g("path",{d:"M12 19h-4"}),g("path",{d:"M15 13v-1h6v1"}),g("path",{d:"M18 12v7"}),g("path",{d:"M17 19h2"})]}),Y),OE=P(g(ze,{children:O("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M7 12h10"}),g("path",{d:"M7 5v14"}),g("path",{d:"M17 5v14"}),g("path",{d:"M15 19h4"}),g("path",{d:"M15 5h4"}),g("path",{d:"M5 19h4"}),g("path",{d:"M5 5h4"})]})}),Y),rs=P(g(ze,{children:g("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:g("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"})})}),de),Ld=P(O(ze,{children:[g("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:g("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"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),de),BE=P(O("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),g("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),g("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),Y),FE=P(O("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),g("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),g("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),Y),zE=P(O("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),g("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),g("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),Y),HE=Nt.memo(({theme:e})=>P(O("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),g("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),Y)),UE=Nt.memo(({theme:e})=>P(O("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),g("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),Y)),GE=Nt.memo(({theme:e})=>P(O("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),g("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),g("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),Y)),Dd=P(O("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M21 19h-18l9 -15"}),g("path",{d:"M20.615 15.171h.015"}),g("path",{d:"M19.515 11.771h.015"}),g("path",{d:"M17.715 8.671h.015"}),g("path",{d:"M15.415 5.971h.015"})]}),Y),VE=P(g("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}),V_=P(g("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"})),_d=P(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),g("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),g("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),g("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"})]}),Y),yh=P(O(ze,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),g("path",{d:"M7 11l5 5l5 -5"}),g("path",{d:"M12 4l0 12"})]}),Y),wa=P(O(ze,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),Y),YE=P(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),g("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),g("path",{d:"M9.15 14.85l8.85 -10.85"}),g("path",{d:"M6 4l8.85 10.85"})]}),Y),WE=P(O(ze,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),g("path",{d:"M12 17l0 .01"}),g("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),Y),Y_=P(O(ze,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M7 4v16l13 -8z"})]}),Y),W_=P(O(ze,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"})]}),Y),KE=P(O(ze,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 12l5 5l10 -10"})]}),Y),ZE=P(O(ze,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M12 9v4"}),g("path",{d:"M12 17h.01"})]}),Y),XE=P(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M11 7l6 6"}),g("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"})]}),Y),$E=P(O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 3l-4 7h8z"}),g("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),g("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"})]}),Y),Ii=P(O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 7l16 0"}),g("path",{d:"M4 17l16 0"}),g("path",{d:"M7 4l0 16"}),g("path",{d:"M17 4l0 16"})]}),Y),Pd=P(g("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"})),Ta=P(O("g",{strokeWidth:"1.25",children:[g("path",{d:"M4.16602 10H15.8327"}),g("path",{d:"M12.5 13.3333L15.8333 10"}),g("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),de),ns=P(O("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[g("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"}),g("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),Rd=P(O("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z"}),g("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),g("path",{d:"M15 6l3 3"}),g("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"}),g("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"})]}),Y),K_=P(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z"}),g("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),g("path",{d:"M15 6l3 3"}),g("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"}),g("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"})]}),Y),Z_=P(O("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),g("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),g("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"}),g("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),g("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),g("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"})]}),Y),jE=P(O("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),g("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),g("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),g("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),Y),Sa=P(O("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),g("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"})]}),Y),qE=P(O("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),g("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"}),g("path",{d:"M3 3l18 18"})]}),Y),JE=P(O("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("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"}),g("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),g("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),g("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),g("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),Y),QE=P(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("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"}),g("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),g("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),g("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),g("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),Y),wo=P(O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),g("path",{d:"M21 21l-6 -6"})]}),Y),ey=P(O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),g("path",{d:"M12 7v5l3 3"}),g("path",{d:"M19 16l-2 3h4l-2 3"})]}),Y),ty=P(O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M5 10a7 7 0 0 0 14 0"}),g("path",{d:"M8 21l8 0"}),g("path",{d:"M12 17l0 4"})]}),Y),oy=P(O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 3l18 18"}),g("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"}),g("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),g("path",{d:"M8 21l8 0"}),g("path",{d:"M12 17l0 4"})]}),Y),is=P(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),Y),ry=P(O("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M12 20v.01"}),g("path",{d:"M16 20v.01"}),g("path",{d:"M8 20v.01"}),g("path",{d:"M4 20v.01"}),g("path",{d:"M4 16v.01"}),g("path",{d:"M4 12v.01"}),g("path",{d:"M4 8v.01"}),g("path",{d:"M4 4v.01"}),g("path",{d:"M8 4v.01"}),g("path",{d:"M12 4v.01"}),g("path",{d:"M16 4v.01"}),g("path",{d:"M20 4v.01"}),g("path",{d:"M20 8v.01"}),g("path",{d:"M20 12v.01"}),g("path",{d:"M20 16v.01"}),g("path",{d:"M20 20v.01"})]}),Y),ny=P(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 3v18"}),g("path",{d:"M19 21v-18"}),g("path",{d:"M5 7h14"}),g("path",{d:"M5 15h14"}),g("path",{d:"M8 13v4"}),g("path",{d:"M11 13v4"}),g("path",{d:"M16 13v4"}),g("path",{d:"M14 5v4"}),g("path",{d:"M11 5v4"}),g("path",{d:"M8 5v4"}),g("path",{d:"M3 21h18"})]}),Y),iy=P(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 12l18 0"}),g("path",{d:"M7 16l10 0l-10 5l0 -5"}),g("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),Y),ay=P(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 3l0 18"}),g("path",{d:"M16 7l0 10l5 0l-5 -10"}),g("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),Y),vh=P(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),g("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"})]}),Y),Nd=P(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),g("path",{d:"M22 22l-3 -3"}),g("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),g("path",{d:"M3 11v-1"}),g("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),g("path",{d:"M10 3h1"}),g("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),Y),ly=P(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),g("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),g("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"}),g("path",{d:"M10 15l2 6l2 -6"}),g("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),Y),sy=P(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),g("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),g("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),g("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),g("path",{d:"M11 21v-6l3 6v-6"})]}),Y),cy=P(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M4 8l5 0"}),g("path",{d:"M15 8l4 0"})]}),Y),dy=P(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),g("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),g("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),g("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),Y),my=P(O("g",{stroke:"currentColor",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"})]}),{...Y,strokeWidth:1.5}),X_=P(O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M21 12h-13l3 -3"}),g("path",{d:"M11 15l-3 -3"})]}),Y),py=P(O("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M10 9l5 3l-5 3z"})]}),Y),uy=P(O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 6h18"}),g("path",{d:"M3 12h18"}),g("path",{d:"M3 18h18"}),g("path",{d:"M6 3v18"}),g("path",{d:"M12 3v18"}),g("path",{d:"M18 3v18"})]}),Y),hy=P(O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("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"}),g("path",{d:"M17 5c-6.627 0 -12 5.373 -12 12"})]}),Y),Od=P(O("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 18l12 -12"}),g("path",{d:"M18 10v-4h-4"})]}),Y),Bd=P(O("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7"}),g("path",{d:"M18 4l3 3l-3 3"})]}),Y),Fd=P(O("g",{children:[g("path",{d:"M16,12L20,9L16,6"}),g("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),Y),zd=P(O("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 9l6 6l6 -6"})]}),Y),gy=P(O("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 15l6 -6l6 6"})]}),Y),fy=P(O("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 15l6 -6l6 6"})]}),Y),wh=P(O("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 5v10a1 1 0 0 0 1 1h10"}),g("path",{d:"M5 8h10a1 1 0 0 1 1 1v10"})]}),Y),Hd=P(O("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M5 7l0 10"}),g("path",{d:"M7 5l10 0"}),g("path",{d:"M7 19l10 0"}),g("path",{d:"M19 7l0 10"})]}),Y);import by from"clsx";import Sh,{useEffect as p6,useRef as xy,useState as u6}from"react";import d6 from"react";import{jsx as Th}from"react/jsx-runtime";var m6=({size:e="1em",circleWidth:t=8,synchronized:o=!1,className:r=""})=>{let i=-(d6.useRef(Date.now()).current%1600);return Th("div",{className:`Spinner ${r}`,children:Th("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":o?`${i}ms`:0},children:Th("circle",{cx:"50",cy:"50",r:50-t/2,strokeWidth:t,fill:"none",strokeMiterlimit:"10"})})})},Ot=m6;import{jsx as as,jsxs as ls}from"react/jsx-runtime";var te=Sh.forwardRef(({size:e="medium",visible:t=!0,className:o="",...r},n)=>{let{id:i}=ft(),a=Sh.useRef(null);Sh.useImperativeHandle(n,()=>a.current);let l=`ToolIcon_size_${e}`,[s,c]=u6(!1),m=xy(!0),d=async u=>{let h="onClick"in r&&r.onClick?.(u);if(pn(h))try{c(!0),await h}catch(x){if(x instanceof sa)console.warn(x);else throw x}finally{m.current&&c(!1)}};p6(()=>(m.current=!0,()=>{m.current=!1}),[]);let p=xy(null);if(r.type==="button"||r.type==="icon"||r.type==="submit"){let u=r.type==="icon"?"button":r.type;return ls("button",{className:by("ToolIcon_type_button",l,o,t&&!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)&&ls("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!r.disabled,children:[r.icon||r.label,r.keyBindingLabel&&as("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel}),r.isLoading&&as(Ot,{})]}),r.showAriaLabel&&ls("div",{className:"ToolIcon__label",children:[r["aria-label"]," ",s&&as(Ot,{})]}),r.children]})}return ls("label",{className:by("ToolIcon",o),title:r.title,onPointerDown:u=>{p.current=u.pointerType||null,r.onPointerDown?.({pointerType:u.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{p.current=null})},children:[as("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}),ls("div",{className:"ToolIcon__icon",children:[r.icon,r.keyBindingLabel&&as("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel})]})]})});te.displayName="ToolButton";var Ud=[],F=e=>(Ud=Ud.concat(e),e);import{jsx as g6}from"react/jsx-runtime";var h6=(e,t,o)=>{let r=new Set(Q(e.filter(m=>J(m)),t).map(m=>m.id)),n={},i=o.scene.getNonDeletedElementsMap(),a=new Set;for(let m of r){let d=so(e,m);for(let p of d)if(!a.has(p.id)){if(He(p)){let u=Ut(p,i);u&&(n[u.id]=!0)}else n[p.id]=!0;a.add(p.id)}}let l=!0,s=e.map(m=>{if(t.selectedElementIds[m.id]){let d=He(m)?Ut(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=o.scene.getNonDeletedElementsMap().get(p.id);u&&ee(u)&&o.scene.mutateElement(u,{startBinding:m.id===u.startBinding?.elementId?null:u.startBinding,endBinding:m.id===u.endBinding?.elementId?null:u.endBinding})}),re(m,{isDeleted:!0}))}return m.frameId&&r.has(m.frameId)?(l=!1,He(m)||(n[m.id]=!0),re(m,{frameId:null})):He(m)&&t.selectedElementIds[m.containerId]?re(m,{isDeleted:!0}):m}),c=t.editingGroupId;if(l&&t.editingGroupId){let m=Be(s,t.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(h=>h===t.editingGroupId),u=d.groupIds[p+1];if(u){let h=Be(s,u).filter(x=>!x.isDeleted);h.length>1&&(c=u,h.forEach(x=>{n[x.id]=!0}))}}}}return{elements:s,appState:{...t,...ht({selectedElementIds:n,editingGroupId:c},s,t,null)}}},Ey=(e,t)=>{if(e.editingGroupId){let o=Be(ye(t),e.editingGroupId);if(o.length)return{...e,selectedElementIds:{[o[0].id]:!0}}}return e},ss=F({name:"deleteSelectedElements",label:"labels.delete",icon:vo,trackEvent:{category:"element",action:"delete"},perform:(e,t,o,r)=>{if(t.editingLinearElement){let{elementId:a,selectedPointsIndices:l,startBindingElement:s,endBindingElement:c}=t.editingLinearElement,m=r.scene.getNonDeletedElementsMap(),d=$.getElement(a,m);if(!d||l==null)return!1;if(d.points.length<2){let u=e.map(x=>x.id===d.id?re(x,{isDeleted:!0}):x),h=Ey(t,u);return{elements:u,appState:{...h,editingLinearElement:null},captureUpdate:D.IMMEDIATELY}}let p={startBindingElement:l?.includes(0)?null:s,endBindingElement:l?.includes(d.points.length-1)?null:c};return $.deletePoints(d,r.scene,l),{elements:e,appState:{...t,editingLinearElement:{...t.editingLinearElement,...p,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},captureUpdate:D.IMMEDIATELY}}let{elements:n,appState:i}=h6(e,t,r);return Vc(n,n.filter(a=>a.isDeleted)),i=Ey(i,n),{elements:n,appState:{...i,activeTool:Ne(t,{type:"selection"}),multiElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Ue(ye(e),t)?D.IMMEDIATELY:D.EVENTUALLY}},keyTest:(e,t,o)=>(e.key===T.BACKSPACE||e.key===T.DELETE)&&!e[T.CTRL_OR_CMD],PanelComponent:({elements:e,appState:t,updateData:o})=>g6(te,{type:"button",icon:vo,title:f("labels.delete"),"aria-label":f("labels.delete"),onClick:()=>o(null),visible:Ue(ye(e),t)})});var Ch=(e,t)=>e.frameId===t||e.id===t,vy=(e,t,o)=>{let r=[],n=[],i=null,a=-1,l=q(o||Q(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0}));for(;++a<e.length;){let s=e[a];l.get(s.id)?(n.length&&(r=r.concat(n),n=[]),r.push(a),i=a+1):s.isDeleted&&i===a?(i=a+1,n.push(a)):n=[]}return r},f6=e=>{let t=0;return e.reduce((o,r,n)=>(n>0&&e[n-1]!==r-1&&(t=++t),(o[t]||(o[t]=[])).push(r),o),[])},yy=(e,t,o,r)=>{if("containerId"in e&&e.containerId){let n=r.getElement(e.containerId);if(n)return o==="left"?Math.min(t.indexOf(n),t.indexOf(e)):Math.max(t.indexOf(n),t.indexOf(e))}else{let n=e.boundElements?.find(i=>i.type!=="arrow")?.id;if(n){let i=r.getElement(n);if(i)return o==="left"?Math.min(t.indexOf(i),t.indexOf(e)):Math.max(t.indexOf(i),t.indexOf(e))}}},b6=(e,t)=>{let o=-1,r=-1;return e.forEach((n,i)=>{Ch(n,t)&&(o===-1&&(o=i),r=i)}),o===-1?[]:e.slice(o,r+1)},x6=(e,t,o,r,n,i)=>{let a=t[o],l=p=>p.isDeleted?!1:n?p.frameId===n:e.editingGroupId?p.groupIds.includes(e.editingGroupId):!0,s=r==="left"?Or(t,p=>l(p),Math.max(0,o-1)):lu(t,p=>l(p),o+1),c=t[s];if(!c)return-1;if(e.editingGroupId){if(a?.groupIds.join("")===c?.groupIds.join(""))return yy(c,t,r,i)??s;if(!c?.groupIds.includes(e.editingGroupId))return-1}if(!n&&(c.frameId||J(c))){let p=b6(t,c.frameId||c.id);return r==="left"?t.indexOf(p[0]):t.indexOf(p[p.length-1])}if(!c.groupIds.length)return yy(c,t,r,i)??s;let m=e.editingGroupId?c.groupIds[c.groupIds.indexOf(e.editingGroupId)-1]:c.groupIds[c.groupIds.length-1],d=Be(t,m);return d.length?r==="left"?t.indexOf(d[0]):t.indexOf(d[d.length-1]):s},wy=(e,t)=>t.reduce((o,r)=>{let n=e[r];return o.set(n.id,n),o},new Map),Ty=(e,t,o,r)=>{let n=vy(e,t),i=wy(e,n),a=f6(n);o==="right"&&(a=a.reverse());let l=new Set(n.filter(s=>J(e[s])).map(s=>e[s].id));return a.forEach((s,c)=>{let m=s[0],d=s[s.length-1],p=o==="left"?m:d,u=s.some(y=>{let v=e[y];return v.frameId&&l.has(v.frameId)})?null:e[p]?.frameId,h=x6(t,e,p,o,u,r);if(h===-1||p===h)return;let x=o==="left"?e.slice(0,h):e.slice(0,m),b=e.slice(m,d+1),E=o==="left"?e.slice(h,m):e.slice(d+1,h+1),w=o==="left"?e.slice(d+1):e.slice(h+1);e=o==="left"?[...x,...b,...E,...w]:[...x,...E,...b,...w]}),At(e,i),e},Sy=(e,t,o,r,n)=>{let i=vy(e,t,n),a=wy(e,i),l=[],s,c;if(o==="left"){if(r)s=lu(e,h=>Ch(h,r));else if(t.editingGroupId){let h=Be(e,t.editingGroupId);if(!h.length)return e;s=e.indexOf(h[0])}else s=0;c=i[i.length-1]}else{if(r)c=Or(e,h=>Ch(h,r));else if(t.editingGroupId){let h=Be(e,t.editingGroupId);if(!h.length)return e;c=e.indexOf(h[h.length-1])}else c=e.length-1;s=i[0]}s===-1&&(s=0);for(let h=s;h<c+1;h++)i.includes(h)||l.push(e[h]);let m=Array.from(a.values()),d=e.slice(0,s),p=e.slice(c+1),u=o==="left"?[...d,...m,...l,...p]:[...d,...l,...m,...p];return At(u,a),u};function Cy(e,t,o,r){let n=q(Q(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),i={regularElements:[],frameChildren:new Map},a=new Set;for(let c of e)n.has(c.id)&&J(c)&&a.add(c.id);for(let c of e)if(n.has(c.id))if(J(c)||c.frameId&&a.has(c.frameId))i.regularElements.push(c);else if(!c.frameId)i.regularElements.push(c);else{let m=i.frameChildren.get(c.frameId)||[];m.push(c),i.frameChildren.set(c.frameId,m)}let l=e,s=Array.from(i.frameChildren.entries());for(let[c,m]of s)l=r(e,t,o,c,m);return r(l,t,o,null,i.regularElements)}var Iy=(e,t,o)=>Ty(e,t,"left",o),ky=(e,t,o)=>Ty(e,t,"right",o),My=(e,t)=>Cy(e,t,"left",Sy),Ay=(e,t)=>Cy(e,t,"right",Sy);import{jsx as Gd}from"react/jsx-runtime";var Ih=F({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:sh,trackEvent:{category:"element"},perform:(e,t,o,r)=>({elements:Iy(e,t,r.scene),appState:t,captureUpdate:D.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[T.CTRL_OR_CMD]&&!e.shiftKey&&e.code===me.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>Gd("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendBackward")} \u2014 ${N("CtrlOrCmd+[")}`,children:sh})}),kh=F({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:lh,trackEvent:{category:"element"},perform:(e,t,o,r)=>({elements:ky(e,t,r.scene),appState:t,captureUpdate:D.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[T.CTRL_OR_CMD]&&!e.shiftKey&&e.code===me.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>Gd("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.bringForward")} \u2014 ${N("CtrlOrCmd+]")}`,children:lh})}),Mh=F({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:dh,trackEvent:{category:"element"},perform:(e,t)=>({elements:My(e,t),appState:t,captureUpdate:D.IMMEDIATELY}),keyTest:e=>Wo?e[T.CTRL_OR_CMD]&&e.altKey&&e.code===me.BRACKET_LEFT:e[T.CTRL_OR_CMD]&&e.shiftKey&&e.code===me.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>Gd("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendToBack")} \u2014 ${Wo?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")}`,children:dh})}),Ah=F({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:ch,trackEvent:{category:"element"},perform:(e,t)=>({elements:Ay(e,t),appState:t,captureUpdate:D.IMMEDIATELY}),keyTest:e=>Wo?e[T.CTRL_OR_CMD]&&e.altKey&&e.code===me.BRACKET_RIGHT:e[T.CTRL_OR_CMD]&&e.shiftKey&&e.code===me.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>Gd("button",{type:"button",className:"zIndexButton",onClick:o=>e(null),title:`${f("labels.bringToFront")} \u2014 ${Wo?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")}`,children:ch})});var Lh=F({name:"selectAll",label:"labels.selectAll",icon:ry,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,t,o,r)=>{if(t.editingLinearElement)return!1;let n=e.filter(i=>!i.isDeleted&&!(K(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...t,...ht({editingGroupId:null,selectedElementIds:n},ye(e),t,r),selectedLinearElement:Object.keys(n).length===1&&le(e[0])?new $(e[0],q(e)):null},captureUpdate:D.IMMEDIATELY}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.A});import{jsx as E6}from"react/jsx-runtime";var Dh=F({name:"duplicateSelection",label:"labels.duplicateSelection",icon:Ql,trackEvent:{category:"element"},perform:(e,t,o,r)=>{if(t.selectedElementsAreBeingDragged)return!1;if(t.editingLinearElement)try{let a=$.duplicateSelectedPoints(t,r.scene);return{elements:e,appState:a,captureUpdate:D.IMMEDIATELY}}catch{return!1}let{duplicatedElements:n,elementsWithDuplicates:i}=gi({type:"in-place",elements:e,idsOfElementsToDuplicate:q(Q(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:t,randomizeSeed:!0,overrides:({origElement:a,origIdToDuplicateId:l})=>{let s=a.frameId&&l.get(a.frameId);return{x:a.x+Vp/2,y:a.y+Vp/2,frameId:s??a.frameId}}});if(r.props.onDuplicate&&i){let a=r.props.onDuplicate(i,e);a&&(i=a)}return{elements:At(i,q(n)),appState:{...t,...Rc(n,ye(i),t)},captureUpdate:D.IMMEDIATELY}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.D,PanelComponent:({elements:e,appState:t,updateData:o})=>E6(te,{type:"button",icon:Ql,title:`${f("labels.duplicateSelection")} \u2014 ${N("CtrlOrCmd+D")}`,"aria-label":f("labels.duplicateSelection"),onClick:()=>o(null),visible:Ue(ye(e),t)})});import{useEffect as jh,useMemo as ZS,useRef as qh,useState as XS}from"react";var y6=new Set(["command_palette","export"]),fe=(e,t,o,r)=>{try{if(typeof window>"u"||k.VITE_WORKER_ID||k.VITE_APP_ENABLE_TRACKING!=="true"||!y6.has(e)||Oe())return;k.PROD||console.info("trackEvent",{category:e,action:t,label:o,value:r}),window.sa_event&&window.sa_event(t,{category:e,label:o,value:r})}catch(n){console.error("error during analytics",n)}};import S6 from"clsx";import v6 from"clsx";import{forwardRef as w6}from"react";import{jsx as T6}from"react/jsx-runtime";var Vd=w6((e,t)=>{let{title:o,className:r,testId:n,active:i,standalone:a,icon:l,onClick:s}=e;return T6("button",{type:"button",ref:t,title:o,"data-testid":n,className:v6(r,{standalone:a,active:i}),onClick:s,children:l},o)});import{jsx as _h,jsxs as C6}from"react/jsx-runtime";var Ro=e=>_h("div",{className:"buttonList",children:e.options.map(t=>e.type==="button"?_h(Vd,{icon:t.icon,title:t.text,testId:t.testId,active:t.active??e.value===t.value,onClick:o=>e.onClick(t.value,o)},t.text):C6("label",{className:S6({active:e.value===t.value}),title:t.text,children:[_h("input",{type:"radio",name:e.group,onChange:()=>e.onChange(t.value),checked:e.value===t.value,"data-testid":t.testId}),t.icon]},t.text))});import*as $d from"@radix-ui/react-popover";import cS from"clsx";import{useRef as dS}from"react";import{jsx as I6}from"react/jsx-runtime";var Yd=()=>I6("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as L6,useRef as D6}from"react";import{createPortal as _6}from"react-dom";import Ly from"react";var Ph=Ly.createContext(null),_e=()=>Ly.useContext(Ph);import{useState as k6,useLayoutEffect as Dy}from"react";var Wd=e=>{let[t,o]=k6(null),r=Te(),{theme:n}=_e(),{container:i}=ft();return Dy(()=>{t&&(t.className="",t.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),t.classList.toggle("excalidraw--mobile",r.editor.isMobile),t.classList.toggle("theme--dark",n===se.DARK))},[t,n,r.editor.isMobile,e?.className]),Dy(()=>{let a=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!a)return;let l=document.createElement("div");return a.appendChild(l),o(l),()=>{a.removeChild(l)}},[i,e?.parentSelector]),t};import{useEffect as M6}from"react";function Ca(e,t,o){M6(()=>{function r(n){let i=n;if(!e.current)return;let a=o?.(i,e.current);if(a===!0)return;if(a===!1)return t(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]")||t(i)}return document.addEventListener("pointerdown",r),document.addEventListener("touchstart",r),()=>{document.removeEventListener("pointerdown",r),document.removeEventListener("touchstart",r)}},[e,t,o])}import{useRef as A6}from"react";var Sn=e=>{let t=A6(e);return Object.assign(t.current,e),t.current};import{jsx as P6}from"react/jsx-runtime";var Cn=ke(null),_y=({onCancel:e,onChange:t,onSelect:o,colorPickerType:r})=>{let n=Wd({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=_e(),a=In(),l=lt(),s=Q(a,i),c=Sn({app:l,onCancel:e,onChange:t,onSelect:o,selectedElements:s}),{container:m}=ft();L6(()=>{let p=d.current;if(!p||!l.canvas||!n)return;let u=!1,h=l.canvas.getContext("2d"),x=({clientX:I,clientY:L})=>{let A=h.getImageData((I-i.offsetLeft)*window.devicePixelRatio,(L-i.offsetTop)*window.devicePixelRatio,1,1).data;return C1(A[0],A[1],A[2])},b=({clientX:I,clientY:L,altKey:A})=>{p.style.top=`${L+20}px`,p.style.left=`${I+20}px`;let R=x({clientX:I,clientY:L});u&&c.onChange(r,R,c.selectedElements,{altKey:A}),p.style.background=R},E=()=>{c.onCancel()},w=(I,L)=>{c.onSelect(I,L)},y=I=>{u=!0,I.stopImmediatePropagation()},v=I=>{u=!1,m?.focus(),I.stopImmediatePropagation(),I.preventDefault(),w(x(I),I)},C=I=>{I.key===T.ESCAPE&&(I.preventDefault(),I.stopImmediatePropagation(),E())};return n.tabIndex=-1,n.focus(),b({clientX:c.app.lastViewportPosition.x,clientY:c.app.lastViewportPosition.y,altKey:!1}),n.addEventListener("keydown",C),n.addEventListener("pointerdown",y),n.addEventListener("pointerup",v),window.addEventListener("pointermove",b,{passive:!0}),window.addEventListener("blur",E),()=>{u=!1,n.removeEventListener("keydown",C),n.removeEventListener("pointerdown",y),n.removeEventListener("pointerup",v),window.removeEventListener("pointermove",b),window.removeEventListener("blur",E)}},[c,l.canvas,n,r,m,i.offsetLeft,i.offsetTop]);let d=D6(null);return Ca(d,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),n?_6(P6("div",{ref:d,className:"excalidraw-eye-dropper-preview"}),n):null};import*as Ia from"@radix-ui/react-popover";import B6 from"clsx";import F6 from"react";import R6 from"react";import N6 from"clsx";import{jsx as O6}from"react/jsx-runtime";var wt=R6.forwardRef(({children:e,padding:t,className:o,style:r},n)=>O6("div",{className:N6("Island",o),style:{"--padding":t,...r},ref:n,children:e}));import{jsx as Rh,jsxs as z6}from"react/jsx-runtime";var Kd=F6.forwardRef(({className:e,container:t,children:o,style:r,onClose:n,onKeyDown:i,onFocusOutside:a,onPointerLeave:l,onPointerDownOutside:s},c)=>{let m=Te();return Rh(Ia.Portal,{container:t,children:z6(Ia.Content,{ref:c,className:B6("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(),t&&!ab(document.activeElement)&&t.focus(),n()},children:[Rh(wt,{padding:3,style:r,children:o}),Rh(Ia.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})});import H6 from"clsx";import{useCallback as U6,useEffect as Oh,useRef as Ny,useState as G6}from"react";var kn=({palette:e,color:t})=>{for(let[o,r]of Object.entries(e))if(Array.isArray(r)){let n=r.indexOf(t);if(n>-1)return{colorName:o,shade:n}}else if(r===t)return{colorName:o,shade:null};return null},cs=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),Nh=({color:e,palette:t})=>!Object.values(t).flat().includes(e),Ry=(e,t,o)=>{let r={elementBackground:"backgroundColor",elementStroke:"strokeColor"},n=e.filter(a=>{if(a.isDeleted)return!1;let l=a[r[t]];return Nh({color:l,palette:o})}),i=new Map;return n.forEach(a=>{let l=a[r[t]];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,x1)},Oo=ke(null),Py=(e,t,o)=>(e*299+t*587+o*114)/1e3,ka=(e,t=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 Py(s,c,m)<t}return!0}let o=parseInt(e.slice(1,3),16),r=parseInt(e.slice(3,5),16),n=parseInt(e.slice(5,7),16);return Py(o,r,n)<t};import{Fragment as V6,jsx as Zd,jsxs as Oy}from"react/jsx-runtime";var By=({color:e,onChange:t,label:o,colorPickerType:r})=>{let n=Te(),[i,a]=G6(e),[l,s]=ve(Oo);Oh(()=>{a(e)},[e]);let c=U6(h=>{let x=h.toLowerCase(),b=Fy(x);b&&t(b),a(x)},[t]),m=Ny(null),d=Ny(null);Oh(()=>{m.current&&m.current.focus()},[l]);let[p,u]=ve(Cn);return Oh(()=>()=>{u(null)},[u]),Oy("div",{className:"color-picker__input-label",children:[Zd("div",{className:"color-picker__input-hash",children:"#"}),Zd("input",{ref:l==="hex"?m:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":o,onChange:h=>{c(h.target.value)},value:(i||"").replace(/^#/,""),onBlur:()=>{a(e)},tabIndex:-1,onFocus:()=>s("hex"),onKeyDown:h=>{h.key!==T.TAB&&(h.key===T.ESCAPE&&d.current?.focus(),h.stopPropagation())}}),!n.editor.isMobile&&Oy(V6,{children:[Zd("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),Zd("div",{ref:d,className:H6("excalidraw-eye-dropper-trigger",{selected:p}),onClick:()=>u(h=>h?null:{keepOpenOnAlt:!1,onSelect:x=>t(x),colorPickerType:r}),title:`${f("labels.eyeDropper")} \u2014 ${T.I.toLocaleUpperCase()} or ${N("Alt")} `,children:XE})]})]})};import Yy,{useEffect as Wy,useState as lS}from"react";import K6 from"clsx";import{useEffect as Z6,useRef as X6}from"react";import{jsxs as W6}from"react/jsx-runtime";var Y6=({color:e,keyLabel:t,isShade:o=!1})=>W6("div",{className:"color-picker__button__hotkey-label",style:{color:ka(e)?"#fff":"#000"},children:[o&&"\u21E7",t]}),Ma=Y6;import{jsx as Bh,jsxs as $6}from"react/jsx-runtime";var zy=({colors:e,color:t,onChange:o,label:r})=>{let[n,i]=ve(Oo),a=X6(null);return Z6(()=>{a.current&&a.current.focus()},[t,n]),Bh("div",{className:"color-picker-content--default",children:e.map((l,s)=>$6("button",{ref:t===l?a:void 0,tabIndex:-1,type:"button",className:K6("color-picker__button color-picker__button--large has-outline",{active:t===l,"is-transparent":l==="transparent"||!l}),onClick:()=>{o(l),i("custom")},title:l,"aria-label":r,style:{"--swatch-color":l},children:[Bh("div",{className:"color-picker__button-outline"}),Bh(Ma,{color:l,keyLabel:s+1})]},s))})};import j6 from"clsx";import{useEffect as q6,useRef as J6}from"react";import{jsx as Fh,jsxs as eS}from"react/jsx-runtime";var Q6=({palette:e,color:t,onChange:o,label:r,activeShade:n})=>{let i=kn({color:t||"transparent",palette:e}),[a,l]=ve(Oo),s=J6(null);return q6(()=>{s.current&&a==="baseColors"&&s.current.focus()},[i?.colorName,a]),Fh("div",{className:"color-picker-content--default",children:Object.entries(e).map(([c,m],d)=>{let p=(Array.isArray(m)?m[n]:m)||"transparent",u=cs[d],h=f(`colors.${c.replace(/\d+/,"")}`,null,"");return eS("button",{ref:i?.colorName===c?s:void 0,tabIndex:-1,type:"button",className:j6("color-picker__button color-picker__button--large has-outline",{active:i?.colorName===c,"is-transparent":p==="transparent"||!p}),onClick:()=>{o(p),l("baseColors")},title:`${h}${p.startsWith("#")?` ${p}`:""} \u2014 ${u}`,"aria-label":`${h} \u2014 ${u}`,style:p?{"--swatch-color":p}:void 0,"data-testid":`color-${c}`,children:[Fh("div",{className:"color-picker__button-outline"}),Fh(Ma,{color:p,keyLabel:u})]},c)})})},Hy=Q6;import{jsx as oS}from"react/jsx-runtime";var tS=({children:e})=>oS("div",{className:"color-picker__heading",children:e}),Aa=tS;import rS from"clsx";import{useEffect as nS,useRef as iS}from"react";import{jsx as ds,jsxs as Uy}from"react/jsx-runtime";var Gy=({hex:e,onChange:t,palette:o})=>{let r=kn({color:e||"transparent",palette:o}),[n,i]=ve(Oo),a=iS(null);if(nS(()=>{a.current&&n==="shades"&&a.current.focus()},[r,n]),r){let{colorName:l,shade:s}=r,c=o[l];if(Array.isArray(c))return ds("div",{className:"color-picker-content--default shades",children:c.map((m,d)=>Uy("button",{ref:d===s&&n==="shades"?a:void 0,tabIndex:-1,type:"button",className:rS("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:()=>{t(m),i("shades")},children:[ds("div",{className:"color-picker__button-outline"}),ds(Ma,{color:m,keyLabel:d+1,isShade:!0})]},d))})}return Uy("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[ds("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),ds("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:f("colorPicker.noShades")})]})};var zh=(e,t,o)=>{let r=Math.ceil(o/Zn);switch(t=t??-1,e){case"ArrowLeft":{let n=t-1;return n<0?o-1:n}case"ArrowRight":return(t+1)%o;case"ArrowDown":{let n=t+Zn;return n>=o?t%Zn:n}case"ArrowUp":{let n=t-Zn,i=n<0?Zn*r+n:n;return i>=o?void 0:i}}},aS=({e,colorObj:t,onChange:o,palette:r,customColors:n,setActiveColorPickerSection:i,activeShade:a})=>{if(t?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let l=Number(e.code.slice(-1))-1;return o(r[t.colorName][l]),i("shades"),!0}if(["1","2","3","4","5"].includes(e.key)&&n[Number(e.key)-1])return o(n[Number(e.key)-1]),i("custom"),!0;if(cs.includes(e.key)){let l=cs.indexOf(e.key),s=Object.keys(r)[l],c=r[s],m=Array.isArray(c)?c[a]:c;return o(m),i("baseColors"),!0}return!1},Vy=({event:e,activeColorPickerSection:t,palette:o,color:r,onChange:n,customColors:i,setActiveColorPickerSection:a,updateData:l,activeShade:s,onEyeDropperToggle:c,onEscape:m})=>{if(e[T.CTRL_OR_CMD])return!1;if(e.key===T.ESCAPE)return m(e),!0;if(e.key===T.ALT)return c(!0),!0;if(e.key===T.I)return c(),!0;let d=kn({color:r,palette:o});if(e.key===T.TAB){let p={custom:!!i.length,baseColors:!0,shades:d?.shade!=null,hex:!0},u=Object.entries(p).reduce((w,[y,v])=>(v&&w.push(y),w),[]),h=u.indexOf(t),x=e.shiftKey?-1:1,b=h+x>u.length-1?0:h+x<0?u.length-1:h+x,E=u[b];return E&&a(E),E==="custom"?n(i[0]):E==="baseColors"&&(Object.entries(o).find(([y,v])=>Array.isArray(v)?v.includes(r):v===r?y:null)||n(no.black)),e.preventDefault(),e.stopPropagation(),!0}if(aS({e,colorObj:d,onChange:n,palette:o,customColors:i,setActiveColorPickerSection:a,activeShade:s}))return!0;if(t==="shades"&&d){let{shade:p}=d,u=zh(e.key,p,Zn);if(u!==void 0)return n(o[d.colorName][u]),!0}if(t==="baseColors"&&d){let{colorName:p}=d,u=Object.keys(o),h=u.indexOf(p),x=zh(e.key,h,u.length);if(x!==void 0){let b=u[x],E=o[b];return n(Array.isArray(E)?E[s]:E),!0}}if(t==="custom"){let p=i.indexOf(r),u=zh(e.key,p,i.length);if(u!==void 0){let h=i[u];return n(h),!0}}return!1};import{jsx as ki,jsxs as Xd}from"react/jsx-runtime";var Ky=({color:e,onChange:t,label:o,type:r,elements:n,palette:i,updateData:a,children:l,onEyeDropperToggle:s,onEscape:c})=>{let[m]=Yy.useState(()=>r==="canvasBackground"?[]:Ry(n,r,i)),[d,p]=ve(Oo),u=kn({color:e,palette:i});Wy(()=>{if(!d){let E=Nh({color:e,palette:i}),w=E&&!m.includes(e);p(w?"hex":E?"custom":u?.shade!=null?"shades":"baseColors")}},[d,e,i,p,u,m]);let[h,x]=lS(u?.shade??(r==="elementBackground"?v1:y1));Wy(()=>{u?.shade!=null&&x(u.shade);let E=w=>{w.key===T.ALT&&s(!1)};return document.addEventListener("keyup",E,{capture:!0}),()=>{document.removeEventListener("keyup",E,{capture:!0})}},[u,s]);let b=Yy.useRef(null);return ki("div",{role:"dialog","aria-modal":"true","aria-label":f("labels.colorPicker"),children:Xd("div",{ref:b,onKeyDown:E=>{Vy({event:E,activeColorPickerSection:d,palette:i,color:e,onChange:t,onEyeDropperToggle:s,customColors:m,setActiveColorPickerSection:p,updateData:a,activeShade:h,onEscape:c})&&(E.preventDefault(),E.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[!!m.length&&Xd("div",{children:[ki(Aa,{children:f("colorPicker.mostUsedCustomColors")}),ki(zy,{colors:m,color:e,label:f("colorPicker.mostUsedCustomColors"),onChange:t})]}),Xd("div",{children:[ki(Aa,{children:f("colorPicker.colors")}),ki(Hy,{color:e,label:o,palette:i,onChange:t,activeShade:h})]}),Xd("div",{children:[ki(Aa,{children:f("colorPicker.shades")}),ki(Gy,{hex:e,onChange:t,palette:i})]}),l]})})};import sS from"clsx";import{jsx as Hh}from"react/jsx-runtime";var Zy=({onChange:e,type:t,activeColor:o,topPicks:r})=>{let n;return t==="elementStroke"&&(n=Qs),t==="elementBackground"&&(n=ec),t==="canvasBackground"&&(n=tc),r&&(n=r),n?Hh("div",{className:"color-picker__top-picks",children:n.map(i=>Hh("button",{className:sS("color-picker__button",{active:i===o,"is-transparent":i==="transparent"||!i,"has-outline":!ka(i,Js)}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:Hh("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};import{jsx as ir,jsxs as Uh}from"react/jsx-runtime";var Xy=e=>{let t=new Option().style;return t.color=e,!!t.color},Fy=e=>ti(e)?e:Xy(`#${e}`)?`#${e}`:Xy(e)?e:null,mS=({type:e,color:t,onChange:o,label:r,elements:n,palette:i=no,updateData:a})=>{let{container:l}=ft(),[,s]=ve(Oo),[c,m]=ve(Cn),d=Uh("div",{children:[ir(Aa,{children:f("colorPicker.hexCode")}),ir(By,{color:t,label:r,onChange:h=>{o(h)},colorPickerType:e})]}),p=dS(null),u=()=>{p.current?.querySelector(".color-picker-content")?.focus()};return ir(Kd,{container:l,style:{maxWidth:"13rem"},onFocusOutside:h=>{u(),h.preventDefault()},onPointerDownOutside:h=>{c&&h.preventDefault()},onClose:()=>{a({openPopup:null}),s(null)},children:i?ir(Ky,{palette:i,color:t,onChange:h=>{o(h)},onEyeDropperToggle:h=>{m(x=>h?(x=x||{keepOpenOnAlt:!0,onSelect:o,colorPickerType:e},x.keepOpenOnAlt=!0,x):h===!1||x?null:{keepOpenOnAlt:!1,onSelect:o,colorPickerType:e})},onEscape:h=>{c?m(null):a({openPopup:null})},label:r,type:e,elements:n,updateData:a,children:d}):d})},pS=({label:e,color:t,type:o})=>ir($d.Trigger,{type:"button",className:cS("color-picker__button active-color properties-trigger",{"is-transparent":t==="transparent"||!t,"has-outline":!ka(t,Js)}),"aria-label":e,style:t?{"--swatch-color":t}:void 0,title:o==="elementStroke"?f("labels.showStroke"):f("labels.showBackground"),children:ir("div",{className:"color-picker__button-outline"})}),ms=({type:e,color:t,onChange:o,label:r,elements:n,palette:i=no,topPicks:a,updateData:l,appState:s})=>ir("div",{children:Uh("div",{role:"dialog","aria-modal":"true",className:"color-picker-container",children:[ir(Zy,{activeColor:t,onChange:o,type:e,topPicks:a}),ir(Yd,{}),Uh($d.Root,{open:s.openPopup===e,onOpenChange:c=>{l({openPopup:c?e:null})},children:[ir(pS,{color:t,label:r,type:e}),s.openPopup===e&&ir(mS,{type:e,color:t,onChange:o,label:r,elements:n,palette:i,updateData:l})]})]})});import*as n2 from"@radix-ui/react-popover";import NS,{useCallback as OS,useMemo as BS}from"react";import MS,{useMemo as Mn,useState as AS,useRef as LS,useEffect as DS,useCallback as _S}from"react";import uS from"clsx";import hS from"react";import{jsx as gS,jsxs as fS}from"react/jsx-runtime";var jd=hS.forwardRef(({className:e,placeholder:t,onChange:o},r)=>fS("div",{className:uS("QuickSearch__wrapper",e),children:[wo,gS("input",{ref:r,className:"QuickSearch__input",type:"text",placeholder:t,onChange:n=>o(n.target.value.trim().toLowerCase())})]}));import bS from"clsx";import{Children as xS}from"react";import{jsx as $y}from"react/jsx-runtime";var qd=({className:e,placeholder:t,children:o})=>{let r=!xS.count(o);return $y("div",{className:bS("ScrollableList__wrapper",e),role:"menu",children:r?$y("div",{className:"empty",children:t}):o})};import{jsx as ES,jsxs as yS}from"react/jsx-runtime";var jy=({children:e,className:t="",style:o,title:r})=>yS("div",{className:`dropdown-menu-group ${t}`,style:o,children:[r&&ES("p",{className:"dropdown-menu-group-title",children:r}),e]}),ps=jy;jy.displayName="DropdownMenuGroup";import{useEffect as IS,useRef as kS}from"react";import{Fragment as wS,jsx as Gh,jsxs as TS}from"react/jsx-runtime";var vS=({textStyle:e,icon:t,shortcut:o,children:r})=>{let n=Te();return TS(wS,{children:[t&&Gh("div",{className:"dropdown-menu-item__icon",children:t}),Gh("div",{style:e,className:"dropdown-menu-item__text",children:r}),o&&!n.editor.isMobile&&Gh("div",{className:"dropdown-menu-item__shortcut",children:o})]})},Jd=vS;import SS,{useContext as CS}from"react";var Vh=SS.createContext({}),Qd=(e="",t=!1,o=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e}
|
|
2
|
-
${t?"dropdown-menu-item--selected":""} ${o?"dropdown-menu-item--hovered":""}`.trim(),em=(e,t)=>{let o=CS(Vh);return un(e,r=>{let n=new CustomEvent("menu.itemSelect",{bubbles:!0,cancelable:!0});t?.(n),n.defaultPrevented||o.onSelect?.(n)})};import{jsx as Yh}from"react/jsx-runtime";var Wh=({icon:e,value:t,order:o,children:r,shortcut:n,className:i,hovered:a,selected:l,textStyle:s,onSelect:c,onClick:m,...d})=>{let p=em(m,c),u=kS(null);return IS(()=>{a&&(o===0?u.current?.scrollIntoView({block:"end"}):u.current?.scrollIntoView({block:"nearest"}))},[a,o]),Yh("button",{...d,ref:u,value:t,onClick:p,className:Qd(i,l,a),title:d.title??d["aria-label"],children:Yh(Jd,{textStyle:s,icon:e,shortcut:n,children:r})})};Wh.displayName="DropdownMenuItem";var La={GREEN:"green",RED:"red",BLUE:"blue"},tm=({type:e=La.BLUE,children:t})=>{let{theme:o}=wr(),r={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:o===se.LIGHT?"1.5px solid white":"none"};switch(e){case La.GREEN:Object.assign(r,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case La.RED:Object.assign(r,{backgroundColor:"pink",color:"darkred"});break;case La.BLUE:default:Object.assign(r,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return Yh("div",{className:"DropDownMenuItemBadge",style:r,children:t})};tm.displayName="DropdownMenuItemBadge";Wh.Badge=tm;var $t=Wh;var qy=({event:e,inputRef:t,hoveredFont:o,filteredFonts:r,onClose:n,onSelect:i,onHover:a})=>{if(!e[T.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===T.F)return t.current?.focus(),!0;if(e.key===T.ESCAPE)return n(),!0;if(e.key===T.ENTER)return o?.value&&i(o.value),!0;if(e.key===T.ARROW_DOWN)return o?.next?a(o.next.value):r[0]?.value&&a(r[0].value),!0;if(e.key===T.ARROW_UP)return o?.prev?a(o.prev.value):r[r.length-1]?.value&&a(r[r.length-1].value),!0};import{jsx as us,jsxs as Jy}from"react/jsx-runtime";var PS=e=>{switch(e){case yt.Excalifont:case yt.Virgil:return Tn;case yt.Nunito:case yt.Helvetica:return rs;case yt["Lilita One"]:return OE;case yt["Comic Shanns"]:case yt.Cascadia:return Ld;default:return rs}},Qy=MS.memo(({selectedFontFamily:e,hoveredFontFamily:t,onSelect:o,onHover:r,onLeave:n,onOpen:i,onClose:a})=>{let{container:l}=ft(),{fonts:s}=lt(),{showDeprecatedFonts:c}=Tr(),[m,d]=AS(""),p=LS(null),u=Mn(()=>Array.from(vn.registered.entries()).filter(([A,{metadata:R}])=>!R.private&&!R.fallback).map(([A,{metadata:R,fontFaces:_}])=>{let z={value:A,icon:PS(A),text:_[0]?.fontFace?.family??"Unknown"};return R.deprecated&&Object.assign(z,{deprecated:R.deprecated,badge:{type:La.RED,placeholder:f("fontList.badge.old")}}),z}).sort((A,R)=>A.text.toLowerCase()>R.text.toLowerCase()?1:-1),[]),h=Mn(()=>new Set(s.getSceneFamilies()),[e]),x=Mn(()=>u.filter(A=>h.has(A.value)),[u,h]),b=Mn(()=>u.filter(A=>!h.has(A.value)&&(c||!A.deprecated)),[u,h,c]),E=Mn(()=>gb([...x,...b].filter(A=>A.text?.toLowerCase().includes(m))),[x,b,m]),w=Mn(()=>{let A;return t?A=E.find(R=>R.value===t):e&&(A=E.find(R=>R.value===e)),!A&&m&&(E[0]?.value?r(E[0].value):n()),A},[t,e,m,E,r,n]),y=_S(A=>{qy({event:A,inputRef:p,hoveredFont:w,filteredFonts:E,onSelect:o,onHover:r,onClose:a})&&(A.preventDefault(),A.stopPropagation())},[w,E,o,r,a]);DS(()=>(i(),()=>{a()}),[]);let v=Mn(()=>E.filter(A=>h.has(A.value)),[E,h]),C=Mn(()=>E.filter(A=>!h.has(A.value)),[E,h]),I=(A,R)=>Jy($t,{icon:A.icon,value:A.value,order:R,textStyle:{fontFamily:Jn({fontFamily:A.value})},hovered:A.value===w?.value,selected:A.value===e,tabIndex:A.value===e?0:-1,onClick:_=>{o(Number(_.currentTarget.value))},onMouseMove:()=>{w?.value!==A.value&&r(A.value)},children:[A.text,A.badge&&us(tm,{type:A.badge.type,children:A.badge.placeholder})]},A.value),L=[];return v.length&&L.push(us(ps,{title:f("fontList.sceneFonts"),children:v.map(I)},"group_1")),C.length&&L.push(us(ps,{title:f("fontList.availableFonts"),children:C.map((A,R)=>I(A,R+v.length))},"group_2")),Jy(Kd,{className:"properties-content",container:l,style:{width:"15rem"},onClose:a,onPointerLeave:n,onKeyDown:y,children:[us(jd,{ref:p,placeholder:f("quickSearch.placeholder"),onChange:Qn(d,20)}),us(qd,{className:"dropdown-menu fonts manual-hover",placeholder:f("fontList.empty"),children:L.length?L:null})]})},(e,t)=>e.selectedFontFamily===t.selectedFontFamily&&e.hoveredFontFamily===t.hoveredFontFamily);import*as e2 from"@radix-ui/react-popover";import{useMemo as RS}from"react";import{jsx as Kh}from"react/jsx-runtime";var t2=({selectedFontFamily:e})=>{let t=RS(()=>!!(e&&!o2(e)),[e]);return Kh(e2.Trigger,{asChild:!0,children:Kh("div",{children:Kh(Vd,{standalone:!0,icon:Ea,title:f("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:t,onClick:()=>{}})})})};import{jsx as om,jsxs as r2}from"react/jsx-runtime";var i2=[{value:yt.Excalifont,icon:Tn,text:f("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:yt.Nunito,icon:rs,text:f("labels.normal"),testId:"font-family-normal"},{value:yt["Comic Shanns"],icon:Ld,text:f("labels.code"),testId:"font-family-code"}],FS=new Set(i2.map(e=>e.value)),o2=e=>e?FS.has(e):!1,a2=NS.memo(({isOpened:e,selectedFontFamily:t,hoveredFontFamily:o,onSelect:r,onHover:n,onLeave:i,onPopupChange:a})=>{let l=BS(()=>i2,[]),s=OS(c=>{c&&r(c)},[r]);return r2("div",{role:"dialog","aria-modal":"true",className:"FontPicker__container",children:[om(Ro,{type:"button",options:l,value:t,onClick:s}),om(Yd,{}),r2(n2.Root,{open:e,onOpenChange:a,children:[om(t2,{selectedFontFamily:t}),e&&om(Qy,{selectedFontFamily:t,hoveredFontFamily:o,onSelect:s,onHover:n,onLeave:i,onOpen:()=>a(!0),onClose:()=>a(!1)})]})]})},(e,t)=>e.isOpened===t.isOpened&&e.selectedFontFamily===t.selectedFontFamily&&e.hoveredFontFamily===t.hoveredFontFamily);import*as Da from"@radix-ui/react-popover";import GS from"clsx";import rm,{useEffect as VS}from"react";import{jsx as zS}from"react/jsx-runtime";var An=({icon:e})=>zS("span",{style:{width:"1em",margin:"0 0.5ex 0 0.5ex",display:"inline-block",lineHeight:0,verticalAlign:"middle"},children:e});import{Fragment as US,jsx as l2,jsxs as s2}from"react/jsx-runtime";var HS=({label:e,open:t,openTrigger:o,children:r,className:n,showCollapsedIcon:i=!0})=>s2(US,{children:[s2("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:n,onClick:o,children:[e,i&&l2(An,{icon:t?gy:zd})]}),t&&l2("div",{style:{display:"flex",flexDirection:"column"},children:r})]}),hs=HS;import{jsx as Mi,jsxs as Zh}from"react/jsx-runtime";var YS=ke(!1);function WS({options:e,value:t,label:o,onChange:r,onClose:n,numberOfOptionsToAlwaysShow:i=e.length}){let a=Te(),l=u=>{let h=e.find(x=>x.keyBinding===u.key.toLowerCase());if(!(u.metaKey||u.altKey||u.ctrlKey)&&h)r(h.value),u.preventDefault();else if(u.key===T.TAB){let x=e.findIndex(E=>E.value===t),b=u.shiftKey?(e.length+x-1)%e.length:(x+1)%e.length;r(e[b].value)}else if(jn(u.key)){let x=Yr().rtl,b=e.findIndex(E=>E.value===t);if(b!==-1){let E=e.length,w=b;switch(u.key){case(x?T.ARROW_LEFT:T.ARROW_RIGHT):w=(b+1)%E;break;case(x?T.ARROW_RIGHT:T.ARROW_LEFT):w=(E+b-1)%E;break;case T.ARROW_DOWN:{w=(b+(i??1))%E;break}case T.ARROW_UP:{w=(E+b-(i??1))%E;break}}r(e[w].value)}u.preventDefault()}else(u.key===T.ESCAPE||u.key===T.ENTER)&&(u.preventDefault(),n());u.nativeEvent.stopImmediatePropagation(),u.stopPropagation()},[s,c]=ve(YS),m=rm.useMemo(()=>e.slice(0,i),[e,i]),d=rm.useMemo(()=>e.slice(i),[e,i]);VS(()=>{m.some(u=>u.value===t)||c(!0)},[t,m,c]);let p=u=>Mi("div",{className:"picker-content",children:u.map((h,x)=>Zh("button",{type:"button",className:GS("picker-option",{active:t===h.value}),onClick:b=>{r(h.value)},title:`${h.text} ${h.keyBinding&&`\u2014 ${h.keyBinding.toUpperCase()}`}`,"aria-label":h.text||"none","aria-keyshortcuts":h.keyBinding||void 0,ref:b=>{t===h.value&&setTimeout(()=>{b?.focus()},0)},children:[h.icon,h.keyBinding&&Mi("span",{className:"picker-keybinding",children:h.keyBinding})]},h.text))});return Mi(Da.Content,{side:a.editor.isMobile&&!a.viewport.isLandscape?"top":"bottom",align:"start",sideOffset:12,style:{zIndex:"var(--zIndex-popup)"},onKeyDown:l,children:Zh("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":o,children:[p(m),d.length>0&&Mi(hs,{label:f("labels.more_options"),open:s,openTrigger:()=>{c(u=>!u)},className:"picker-collapsible",children:p(d)})]})})}function Xh({value:e,label:t,options:o,onChange:r,group:n="",numberOfOptionsToAlwaysShow:i}){let[a,l]=rm.useState(!1),s=rm.useRef(null);return Mi("div",{children:Zh(Da.Root,{open:a,onOpenChange:c=>l(c),children:[Mi(Da.Trigger,{name:n,type:"button","aria-label":t,onClick:()=>l(!a),ref:s,className:a?"active":"",children:o.find(c=>c.value===e)?.icon}),a&&Mi(WS,{options:o,value:e,label:t,onChange:r,onClose:()=>{l(!1)},numberOfOptionsToAlwaysShow:i})]})})}import c2,{useEffect as KS}from"react";import{jsx as $h,jsxs as d2}from"react/jsx-runtime";var m2=({updateData:e,appState:t,elements:o,testId:r})=>{let n=c2.useRef(null),i=c2.useRef(null),a=Gt(o,t,l=>l.opacity,!0,t.currentItemOpacity);return KS(()=>{if(n.current&&i.current){let l=n.current,s=i.current,c=l.offsetWidth,m=15,d=a/100*(c-m)+m/2;s.style.left=`${d}px`,l.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${a}%, var(--button-bg) ${a}%, var(--button-bg) 100%)`}},[a]),d2("label",{className:"control-label",children:[f("labels.opacity"),d2("div",{className:"range-wrapper",children:[$h("input",{ref:n,type:"range",min:"0",max:"100",step:"10",onChange:l=>{e(+l.target.value)},value:a,className:"range-input","data-testid":r}),$h("div",{className:"value-bubble",ref:i,children:a!==0?a:null}),$h("div",{className:"zero-label",children:"0"})]})]})};import{Fragment as h2,jsx as be,jsxs as To}from"react/jsx-runtime";var u2=.1,jt=(e,t,o,r=!1)=>{let n=q(Q(e,t,{includeBoundTextElement:r}));return e.map(i=>n.get(i.id)||i.id===t.editingTextElement?.id?o(i):i)},Gt=function(e,t,o,r,n){let i=t.editingTextElement,a=ye(e),l=null;return i&&(l=o(i)),l||(Ue(a,t)?l=c0(r===!0?a:a.filter(c=>r(c)),t,o)??(typeof n=="function"?n(!0):n):l=typeof n=="function"?n(!1):n),l},$S=(e,t,o)=>He(t)||!t.autoResize?t:o.mutateElement(t,{x:e.textAlign==="left"?e.x:e.x+(e.width-t.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-t.height)/2}),Jh=(e,t,o,r,n)=>{let i=new Set,a=jt(e,t,l=>{if(K(l)){let s=r(l);i.add(s);let c=re(l,{fontSize:s});return Xe(c,o.scene.getContainerElement(l),o.scene),c=$S(l,c,o.scene),c}return l},!0);return Q(e,t,{includeBoundTextElement:!0}).forEach(l=>{K(l)&>(l,o.scene)}),{elements:a,appState:{...t,currentItemFontSize:i.size===1?[...i][0]:n??t.currentItemFontSize},captureUpdate:D.IMMEDIATELY}},jS=F({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,t,o)=>({...o.currentItemStrokeColor&&{elements:jt(e,t,r=>Hl(r.type)?re(r,{strokeColor:o.currentItemStrokeColor}):r,!0)},appState:{...t,...o},captureUpdate:o.currentItemStrokeColor?D.IMMEDIATELY:D.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:o,appProps:r})=>To(h2,{children:[be("h3",{"aria-hidden":"true",children:f("labels.stroke")}),be(ms,{topPicks:Qs,palette:w1,type:"elementStroke",label:f("labels.stroke"),color:Gt(e,t,n=>n.strokeColor,!0,t.currentItemStrokeColor),onChange:n=>o({currentItemStrokeColor:n}),elements:e,appState:t,updateData:o})]})}),qS=F({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,t,o)=>({...o.currentItemBackgroundColor&&{elements:jt(e,t,r=>re(r,{backgroundColor:o.currentItemBackgroundColor}))},appState:{...t,...o},captureUpdate:o.currentItemBackgroundColor?D.IMMEDIATELY:D.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:o,appProps:r})=>To(h2,{children:[be("h3",{"aria-hidden":"true",children:f("labels.background")}),be(ms,{topPicks:ec,palette:T1,type:"elementBackground",label:f("labels.background"),color:Gt(e,t,n=>n.backgroundColor,!0,t.currentItemBackgroundColor),onChange:n=>o({currentItemBackgroundColor:n}),elements:e,appState:t,updateData:o})]})}),JS=F({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,t,o,r)=>(fe("element","changeFillStyle",`${o} (${r.device.editor.isMobile?"mobile":"desktop"})`),{elements:jt(e,t,n=>re(n,{fillStyle:o})),appState:{...t,currentItemFillStyle:o},captureUpdate:D.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o})=>{let r=Q(e,t),n=r.length>0&&r.every(i=>i.fillStyle==="zigzag");return To("fieldset",{children:[be("legend",{children:f("labels.fill")}),be(Ro,{type:"button",options:[{value:"hachure",text:`${n?f("labels.zigzag"):f("labels.hachure")} (${N("Alt-Click")})`,icon:n?lE:sE,active:n?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:f("labels.crossHatch"),icon:cE,testId:"fill-cross-hatch"},{value:"solid",text:f("labels.solid"),icon:dE,testId:"fill-solid"}],value:Gt(e,t,i=>i.fillStyle,i=>i.hasOwnProperty("fillStyle"),i=>i?null:t.currentItemFillStyle),onClick:(i,a)=>{let l=a.altKey&&i==="hachure"&&r.every(s=>s.fillStyle==="hachure")?"zigzag":i;o(l)}})]})}}),QS=F({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,t,o)=>({elements:jt(e,t,r=>re(r,{strokeWidth:o})),appState:{...t,currentItemStrokeWidth:o},captureUpdate:D.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o})=>To("fieldset",{children:[be("legend",{children:f("labels.strokeWidth")}),be(Ro,{group:"stroke-width",options:[{value:uc.thin,text:f("labels.thin"),icon:Eh,testId:"strokeWidth-thin"},{value:uc.bold,text:f("labels.bold"),icon:mE,testId:"strokeWidth-bold"},{value:uc.extraBold,text:f("labels.extraBold"),icon:pE,testId:"strokeWidth-extraBold"}],value:Gt(e,t,r=>r.strokeWidth,r=>r.hasOwnProperty("strokeWidth"),r=>r?null:t.currentItemStrokeWidth),onChange:r=>o(r)})]})}),eC=F({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,t,o)=>({elements:jt(e,t,r=>re(r,{seed:$o(),roughness:o})),appState:{...t,currentItemRoughness:o},captureUpdate:D.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o})=>To("fieldset",{children:[be("legend",{children:f("labels.sloppiness")}),be(Ro,{group:"sloppiness",options:[{value:0,text:f("labels.architect"),icon:gE},{value:1,text:f("labels.artist"),icon:fE},{value:2,text:f("labels.cartoonist"),icon:bE}],value:Gt(e,t,r=>r.roughness,r=>r.hasOwnProperty("roughness"),r=>r?null:t.currentItemRoughness),onChange:r=>o(r)})]})}),WF=F({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,t,o)=>({elements:jt(e,t,r=>re(r,{strokeStyle:o})),appState:{...t,currentItemStrokeStyle:o},captureUpdate:D.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o})=>To("fieldset",{children:[be("legend",{children:f("labels.strokeStyle")}),be(Ro,{group:"strokeStyle",options:[{value:"solid",text:f("labels.strokeStyle_solid"),icon:Eh},{value:"dashed",text:f("labels.strokeStyle_dashed"),icon:uE},{value:"dotted",text:f("labels.strokeStyle_dotted"),icon:hE}],value:Gt(e,t,r=>r.strokeStyle,r=>r.hasOwnProperty("strokeStyle"),r=>r?null:t.currentItemStrokeStyle),onChange:r=>o(r)})]})}),tC=F({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,t,o)=>({elements:jt(e,t,r=>re(r,{opacity:o}),!0),appState:{...t,currentItemOpacity:o},captureUpdate:D.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o})=>be(m2,{updateData:o,elements:e,appState:t,testId:"opacity"})}),oC=F({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,t,o,r)=>Jh(e,t,r,()=>o,o),PanelComponent:({elements:e,appState:t,updateData:o,app:r})=>To("fieldset",{children:[be("legend",{children:f("labels.fontSize")}),be(Ro,{group:"font-size",options:[{value:16,text:f("labels.small"),icon:_E,testId:"fontSize-small"},{value:20,text:f("labels.medium"),icon:PE,testId:"fontSize-medium"},{value:28,text:f("labels.large"),icon:RE,testId:"fontSize-large"},{value:36,text:f("labels.veryLarge"),icon:NE,testId:"fontSize-veryLarge"}],value:Gt(e,t,n=>{if(K(n))return n.fontSize;let i=pe(n,r.scene.getNonDeletedElementsMap());return i?i.fontSize:null},n=>K(n)||pe(n,r.scene.getNonDeletedElementsMap())!==null,n=>n?null:t.currentItemFontSize||Rr),onChange:n=>o(n)})]})}),Qh=F({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:Ci,trackEvent:!1,perform:(e,t,o,r)=>Jh(e,t,r,n=>Math.round(1/(1+u2)*n.fontSize)),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&(e.key===T.CHEVRON_LEFT||e.key===T.COMMA)}),eg=F({name:"increaseFontSize",label:"labels.increaseFontSize",icon:Ci,trackEvent:!1,perform:(e,t,o,r)=>Jh(e,t,r,n=>Math.round(n.fontSize*(1+u2))),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&(e.key===T.CHEVRON_RIGHT||e.key===T.PERIOD)}),rC=F({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,t,o,r)=>{let{cachedElements:n,resetAll:i,resetContainers:a,...l}=o;if(i)return{elements:jt(e,t,x=>{let b=n?.get(x.id);return b?re(x,{...b}):x},!0),appState:{...t,...l},captureUpdate:D.NEVER};let{currentItemFontFamily:s,currentHoveredFontFamily:c}=o,m=D.EVENTUALLY,d,p=!1;if(s)d=s,m=D.IMMEDIATELY;else if(c){d=c,m=D.EVENTUALLY;let h=Q(e,t,{includeBoundTextElement:!0}).filter(x=>K(x));if(h.length>200)p=!0;else{let x=0,b=0;for(;x<h.length&&b<5e3;){let E=h[x];b+=E?.originalText.length||0,x++}b>5e3&&(p=!0)}}let u={appState:{...t,...l},captureUpdate:m};if(d&&!p){let h=new Map,x=new Set,b=!1,E=Array.from(vn.loadedFontsCache.values()),w=Object.entries(yt).find(([C,I])=>I===d)?.[0];c&&w&&E.some(C=>C.startsWith(w))&&(b=!0),Object.assign(u,{elements:jt(e,t,C=>{if(K(C)&&(C.fontFamily!==d||s)){let I=re(C,{fontFamily:d,lineHeight:Ko(d)}),L=n?.get(C.containerId||"")||{},A=r.scene.getContainerElement(C);return a&&A&&L&&r.scene.mutateElement(A,{...L}),b||(x=new Set([...x,...Array.from(I.originalText)])),h.set(I,A),I}return C},!0)});let y=`10px ${Jn({fontFamily:d})}`,v=Array.from(x.values()).join();if(b||window.document.fonts.check(y,v))for(let[C,I]of h)Xe(C,I,r.scene);else window.document.fonts.load(y,v).then(C=>{for(let[I,L]of h){let A=r.scene.getElement(I.id),R=L?r.scene.getElement(L.id):null;A&&Xe(A,R,r.scene)}r.fonts.onLoaded(C)})}return u},PanelComponent:({elements:e,appState:t,app:o,updateData:r})=>{let n=qh(new Map),i=qh(null),[a,l]=XS({}),s=qh(!0),c=ZS(()=>{let m=(d,p)=>Gt(d,t,u=>{if(K(u))return u.fontFamily;let h=pe(u,p);return h?h.fontFamily:null},u=>K(u)||pe(u,p)!==null,u=>u?null:t.currentItemFontFamily||nn);return a.openPopup==="fontFamily"&&t.openPopup==="fontFamily"?m(Array.from(n.current?.values()??[]),n.current):!a.openPopup&&t.openPopup!=="fontFamily"?m(e,o.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,t,e,o.scene]);return jh(()=>{i.current=c},[c]),jh(()=>{Object.keys(a).length&&(r(a),l({}))},[a]),jh(()=>(s.current=!1,()=>{s.current=!0}),[]),To("fieldset",{children:[be("legend",{children:f("labels.fontFamily")}),be(a2,{isOpened:t.openPopup==="fontFamily",selectedFontFamily:c,hoveredFontFamily:t.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}=t;if(d?.type==="text"){let p=o.scene.getElement(d.id);n.current.set(d.id,re(p||d,{},!0))}else{let p=Q(e,t,{includeBoundTextElement:!0});for(let u of p)n.current.set(u.id,re(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()}}})]})}}),nC=F({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,t,o,r)=>({elements:jt(e,t,n=>{if(K(n)){let i=re(n,{textAlign:o});return Xe(i,r.scene.getContainerElement(n),r.scene),i}return n},!0),appState:{...t,currentItemTextAlign:o},captureUpdate:D.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:r})=>{let n=r.scene.getNonDeletedElementsMap();return To("fieldset",{children:[be("legend",{children:f("labels.textAlign")}),be(Ro,{group:"text-align",options:[{value:"left",text:f("labels.left"),icon:BE,testId:"align-left"},{value:"center",text:f("labels.center"),icon:FE,testId:"align-horizontal-center"},{value:"right",text:f("labels.right"),icon:zE,testId:"align-right"}],value:Gt(e,t,i=>{if(K(i))return i.textAlign;let a=pe(i,n);return a?a.textAlign:null},i=>K(i)||pe(i,n)!==null,i=>i?null:t.currentItemTextAlign),onChange:i=>o(i)})]})}}),iC=F({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,t,o,r)=>({elements:jt(e,t,n=>{if(K(n)){let i=re(n,{verticalAlign:o});return Xe(i,r.scene.getContainerElement(n),r.scene),i}return n},!0),appState:{...t},captureUpdate:D.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:r})=>be("fieldset",{children:be(Ro,{group:"text-align",options:[{value:io.TOP,text:f("labels.alignTop"),icon:be(HE,{theme:t.theme}),testId:"align-top"},{value:io.MIDDLE,text:f("labels.centerVertically"),icon:be(GE,{theme:t.theme}),testId:"align-middle"},{value:io.BOTTOM,text:f("labels.alignBottom"),icon:be(UE,{theme:t.theme}),testId:"align-bottom"}],value:Gt(e,t,n=>{if(K(n)&&n.containerId)return n.verticalAlign;let i=pe(n,r.scene.getNonDeletedElementsMap());return i?i.verticalAlign:null},n=>K(n)||pe(n,r.scene.getNonDeletedElementsMap())!==null,n=>n?null:io.MIDDLE),onChange:n=>o(n)})})}),KF=F({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,t,o)=>({elements:jt(e,t,r=>ee(r)?r:re(r,{roundness:o==="round"?{type:gn(r.type)?Ct.ADAPTIVE_RADIUS:Ct.PROPORTIONAL_RADIUS}:null})),appState:{...t,currentItemRoundness:o},captureUpdate:D.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o})=>{let n=Pc(ye(e),t).some(i=>i.roundness?.type===Ct.LEGACY);return To("fieldset",{children:[be("legend",{children:f("labels.edges")}),be(Ro,{group:"edges",options:[{value:"sharp",text:f("labels.sharp"),icon:xE},{value:"round",text:f("labels.round"),icon:EE}],value:Gt(e,t,i=>n?null:i.roundness?"round":"sharp",i=>!Ie(i)&&i.hasOwnProperty("roundness"),i=>i?null:t.currentItemRoundness),onChange:i=>o(i)})]})}}),p2=e=>[{value:null,text:f("labels.arrowhead_none"),keyBinding:"q",icon:yE},{value:"arrow",text:f("labels.arrowhead_arrow"),keyBinding:"w",icon:be(vE,{flip:e})},{value:"triangle",text:f("labels.arrowhead_triangle"),icon:be(CE,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:f("labels.arrowhead_triangle_outline"),icon:be(IE,{flip:e}),keyBinding:"r"},{value:"circle",text:f("labels.arrowhead_circle"),keyBinding:"a",icon:be(wE,{flip:e})},{value:"circle_outline",text:f("labels.arrowhead_circle_outline"),keyBinding:"s",icon:be(TE,{flip:e})},{value:"diamond",text:f("labels.arrowhead_diamond"),icon:be(kE,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:f("labels.arrowhead_diamond_outline"),icon:be(ME,{flip:e}),keyBinding:"f"},{value:"bar",text:f("labels.arrowhead_bar"),keyBinding:"z",icon:be(SE,{flip:e})},{value:"crowfoot_one",text:f("labels.arrowhead_crowfoot_one"),icon:be(LE,{flip:e}),keyBinding:"c"},{value:"crowfoot_many",text:f("labels.arrowhead_crowfoot_many"),icon:be(AE,{flip:e}),keyBinding:"x"},{value:"crowfoot_one_or_many",text:f("labels.arrowhead_crowfoot_one_or_many"),icon:be(DE,{flip:e}),keyBinding:"v"}],ZF=F({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,t,o)=>({elements:jt(e,t,r=>{if(le(r)){let{position:n,type:i}=o;if(n==="start")return re(r,{startArrowhead:i});if(n==="end")return re(r,{endArrowhead:i})}return r}),appState:{...t,[o.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:o.type},captureUpdate:D.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o})=>{let r=Yr().rtl;return To("fieldset",{children:[be("legend",{children:f("labels.arrowheads")}),To("div",{className:"iconSelectList buttonList",children:[be(Xh,{label:"arrowhead_start",options:p2(!r),value:Gt(e,t,n=>le(n)&&ra(n.type)?n.startArrowhead:t.currentItemStartArrowhead,!0,t.currentItemStartArrowhead),onChange:n=>o({position:"start",type:n}),numberOfOptionsToAlwaysShow:4}),be(Xh,{label:"arrowhead_end",group:"arrowheads",options:p2(!!r),value:Gt(e,t,n=>le(n)&&ra(n.type)?n.endArrowhead:t.currentItemEndArrowhead,!0,t.currentItemEndArrowhead),onChange:n=>o({position:"end",type:n}),numberOfOptionsToAlwaysShow:4})]})]})}}),XF=F({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,t,o,r)=>{let n=jt(e,t,l=>{if(!Ie(l))return l;let s=re(l,{roundness:o===vt.round?{type:Ct.PROPORTIONAL_RADIUS}:null,elbowed:o===vt.elbow,points:o===vt.elbow||l.elbowed?[l.points[0],l.points[l.points.length-1]]:l.points});if(ee(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&&xn(mn(m),e,c,t.zoom,!1,!0),u=!s.endBinding&&xn(mn(d),e,c,t.zoom,!1,!0),h=p||s.startBinding&&c.get(s.startBinding.elementId),x=u||s.endBinding&&c.get(s.endBinding.elementId),b=p?yu(s,p,"start"):m,E=u?yu(s,u,"end"):d;p&&Qo(s,p,"start",r.scene),u&&Qo(s,u,"end",r.scene);let w=h&&s.startBinding?{...s.startBinding,...vu(s,h,"start")}:null,y=x&&s.endBinding?{...s.endBinding,...vu(s,x,"end")}:null;s={...s,startBinding:w,endBinding:y,...oa(s,c,{points:[b,E].map(v=>M(v[0]-s.x,v[1]-s.y)),startBinding:w,endBinding:y,fixedSegments:null})},$.updateEditorMidPointsCache(s,c,r.state)}else{let c=r.scene.getNonDeletedElementsMap();if(s.startBinding){let m=c.get(s.startBinding.elementId);m&&Qo(s,m,"start",r.scene)}if(s.endBinding){let m=c.get(s.endBinding.elementId);m&&Qo(s,m,"end",r.scene)}}return s}),i={...t,currentItemArrowType:o},a=t.selectedLinearElement?.elementId;if(a){let l=n.find(s=>s.id===a);l&&(i.selectedLinearElement=new $(l,q(e)))}return{elements:n,appState:i,captureUpdate:D.IMMEDIATELY}},PanelComponent:({elements:e,appState:t,updateData:o})=>To("fieldset",{children:[be("legend",{children:f("labels.arrowtypes")}),be(Ro,{group:"arrowtypes",options:[{value:vt.sharp,text:f("labels.arrowtype_sharp"),icon:Od,testId:"sharp-arrow"},{value:vt.round,text:f("labels.arrowtype_round"),icon:Fd,testId:"round-arrow"},{value:vt.elbow,text:f("labels.arrowtype_elbowed"),icon:Bd,testId:"elbow-arrow"}],value:Gt(e,t,r=>Ie(r)?r.elbowed?vt.elbow:r.roundness?vt.round:vt.sharp:null,r=>Ie(r),r=>r?null:t.currentItemArrowType),onChange:r=>o(r)})]})});import{useEffect as aC}from"react";import{jsx as sC}from"react/jsx-runtime";var _a=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let t=document.createElement("div");return document.body.appendChild(t),t.classList.add("excalidraw-tooltip"),t},tg=(e,t,o="bottom")=>{let r=e.getBoundingClientRect(),n=window.innerWidth,i=window.innerHeight,a=5,l=t.left+t.width/2-r.width/2;l<0?l=a:l+r.width>=n&&(l=n-r.width-a);let s;o==="bottom"?(s=t.top+t.height+a,s+r.height>=i&&(s=t.top-r.height-a)):(s=t.top-r.height-a,s<0&&(s=t.top+t.height+a)),Object.assign(e.style,{top:`${s}px`,left:`${l}px`})},lC=(e,t,o,r)=>{t.classList.add("excalidraw-tooltip--visible"),t.style.minWidth=r?"50ch":"10ch",t.style.maxWidth=r?"50ch":"15ch",t.textContent=o;let n=e.getBoundingClientRect();tg(t,n)},So=({children:e,label:t,long:o=!1,style:r,disabled:n})=>(aC(()=>()=>_a().classList.remove("excalidraw-tooltip--visible"),[]),n?null:sC("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>lC(i.currentTarget,_a(),t,o),onPointerLeave:()=>_a().classList.remove("excalidraw-tooltip--visible"),style:r,children:e}));import nm from"open-color";var f2='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',cC='<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"/>',b2='<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"/>',dC=`data:${ge.svg},${encodeURIComponent(`${f2}${b2}</svg>`)}`,mC=`data:${ge.svg},${encodeURIComponent(`${f2}${cC}${b2}</svg>`)}`,Co=e=>{e&&(e.style.cursor="")},Le=(e,t)=>{e&&(e.style.cursor=t)},Sr,g2,og=(e,t)=>{let r=()=>{let n=t===se.DARK;Sr=document.createElement("canvas"),Sr.theme=t,Sr.height=20,Sr.width=20;let i=Sr.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(Sr.width/2,Sr.height/2,5,0,2*Math.PI),i.fillStyle=n?nm.black:nm.white,i.fill(),i.strokeStyle=n?nm.white:nm.black,i.stroke(),g2=Sr.toDataURL(ge.svg)};(!Sr||Sr.theme!==t)&&r(),Le(e,`url(${g2}) ${20/2} ${20/2}, auto`)},Io=(e,t)=>{if(e)if(t.activeTool.type==="selection")Co(e);else if(or(t))e.style.cursor=Ce.GRAB;else if(co(t))og(e,t.theme);else if(t.activeTool.type==="laser"){let o=t.theme===se.LIGHT?dC:mC;e.style.cursor=`url(${o}), auto`}else["image","custom"].includes(t.activeTool.type)?t.activeTool.type!=="image"&&(e.style.cursor=Ce.AUTO):e.style.cursor=Ce.CROSSHAIR};var Wr=({viewportX:e,viewportY:t,nextZoom:o},r)=>{let n=e-r.offsetLeft,i=t-r.offsetTop,a=r.zoom.value,l=r.scrollX+(n-n/a),s=r.scrollY+(i-i/a),c=-(n-n/o),m=-(i-i/o);return{scrollX:l+c,scrollY:s+m,zoom:{value:o}}};import{jsx as sm,jsxs as gC}from"react/jsx-runtime";var pC=F({name:"changeViewBackgroundColor",label:"labels.canvasBackground",trackEvent:!1,predicate:(e,t,o,r)=>!!r.props.UIOptions.canvasActions.changeViewBackgroundColor&&!t.viewModeEnabled,perform:(e,t,o)=>({appState:{...t,...o},captureUpdate:o.viewBackgroundColor?D.IMMEDIATELY:D.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:o,appProps:r})=>sm(ms,{palette:null,topPicks:tc,label:f("labels.canvasBackground"),type:"canvasBackground",color:t.viewBackgroundColor,onChange:n=>o({viewBackgroundColor:n}),"data-testid":"canvas-background-picker",elements:e,appState:t,updateData:o})}),Kr=F({name:"clearCanvas",label:"labels.clearCanvas",icon:vo,trackEvent:{category:"canvas"},predicate:(e,t,o,r)=>!!r.props.UIOptions.canvasActions.clearCanvas&&!t.viewModeEnabled&&t.openDialog?.name!=="elementLinkSelector",perform:(e,t,o,r)=>(r.imageCache.clear(),{elements:e.map(n=>re(n,{isDeleted:!0})),appState:{...wn(),files:{},theme:t.theme,penMode:t.penMode,penDetected:t.penDetected,exportBackground:t.exportBackground,exportEmbedScene:t.exportEmbedScene,gridSize:t.gridSize,gridStep:t.gridStep,gridModeEnabled:t.gridModeEnabled,stats:t.stats,pasteDialog:t.pasteDialog,activeTool:t.activeTool.type==="image"?{...t.activeTool,type:"selection"}:t.activeTool},captureUpdate:D.IMMEDIATELY})}),im=F({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:th,trackEvent:{category:"canvas"},perform:(e,t,o,r)=>({appState:{...t,...Wr({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:yr(t.zoom.value+Ui)},t),userToFollow:null},captureUpdate:D.EVENTUALLY}),PanelComponent:({updateData:e,appState:t})=>sm(te,{type:"button",className:"zoom-in-button zoom-button",icon:th,title:`${f("buttons.zoomIn")} \u2014 ${N("CtrlOrCmd++")}`,"aria-label":f("buttons.zoomIn"),disabled:t.zoom.value>=Wp,onClick:()=>{e(null)}}),keyTest:e=>(e.code===me.EQUAL||e.code===me.NUM_ADD)&&(e[T.CTRL_OR_CMD]||e.shiftKey)}),am=F({name:"zoomOut",label:"buttons.zoomOut",icon:oh,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,o,r)=>({appState:{...t,...Wr({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:yr(t.zoom.value-Ui)},t),userToFollow:null},captureUpdate:D.EVENTUALLY}),PanelComponent:({updateData:e,appState:t})=>sm(te,{type:"button",className:"zoom-out-button zoom-button",icon:oh,title:`${f("buttons.zoomOut")} \u2014 ${N("CtrlOrCmd+-")}`,"aria-label":f("buttons.zoomOut"),disabled:t.zoom.value<=Yp,onClick:()=>{e(null)}}),keyTest:e=>(e.code===me.MINUS||e.code===me.NUM_SUBTRACT)&&(e[T.CTRL_OR_CMD]||e.shiftKey)}),lm=F({name:"resetZoom",label:"buttons.resetZoom",icon:Wx,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,o,r)=>({appState:{...t,...Wr({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:yr(1)},t),userToFollow:null},captureUpdate:D.EVENTUALLY}),PanelComponent:({updateData:e,appState:t})=>sm(So,{label:f("buttons.resetZoom"),style:{height:"100%"},children:gC(te,{type:"button",className:"reset-zoom-button zoom-button",title:f("buttons.resetZoom"),"aria-label":f("buttons.resetZoom"),onClick:()=>{e(null)},children:[(t.zoom.value*100).toFixed(0),"%"]})}),keyTest:e=>(e.code===me.ZERO||e.code===me.NUM_ZERO)&&(e[T.CTRL_OR_CMD]||e.shiftKey)}),uC=(e,t,o=1)=>{let[r,n,i,a]=e,l=i-r,s=t.width/l,c=a-n,m=t.height/c,p=Math.min(s,m)*It(o,.1,1);return Math.min(p,1)},x2=({bounds:e,appState:t,canvasOffsets:o,fitToViewport:r=!1,viewportZoomFactor:n=1,minZoom:i=-1/0,maxZoom:a=1/0})=>{n=It(n,Yp,Wp);let[l,s,c,m]=e,d=(l+c)/2,p=(s+m)/2,u=o?.left??0,h=o?.top??0,x=o?.right??0,b=o?.bottom??0,E=t.width-u-x,w=t.height-h-b,y;if(r){let I=c-l,L=m-s;y=Math.min(E/I,w/L)*n}else y=uC(e,{width:E,height:w},n);let v=yr(It(eb(y,Ui,"floor"),i,a)),C=U0({scenePoint:{x:d,y:p},viewportDimensions:{width:t.width,height:t.height},offsets:o,zoom:{value:v}});return{appState:{...t,scrollX:C.scrollX,scrollY:C.scrollY,zoom:{value:v}},captureUpdate:D.EVENTUALLY}},gs=({canvasOffsets:e,targetElements:t,appState:o,fitToViewport:r,viewportZoomFactor:n,minZoom:i,maxZoom:a})=>{let l=Ee(ye(t));return x2({canvasOffsets:e,bounds:l,appState:o,fitToViewport:r,viewportZoomFactor:n,minZoom:i,maxZoom:a})},Lz=F({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:Nd,trackEvent:{category:"canvas"},perform:(e,t,o,r)=>{let n=r.scene.getSelectedElements(t);return gs({targetElements:n.length?n:e,appState:{...t,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()})},keyTest:e=>e.code===me.TWO&&e.shiftKey&&!e.altKey&&!e[T.CTRL_OR_CMD]}),Dz=F({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:Nd,trackEvent:{category:"canvas"},perform:(e,t,o,r)=>{let n=r.scene.getSelectedElements(t);return gs({targetElements:n.length?n:e,appState:{...t,userToFollow:null},fitToViewport:!0,canvasOffsets:r.getEditorUIOffsets()})},keyTest:e=>e.code===me.THREE&&e.shiftKey&&!e.altKey&&!e[T.CTRL_OR_CMD]}),hC=F({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:Nd,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,o,r)=>gs({targetElements:e,appState:{...t,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()}),keyTest:e=>e.code===me.ONE&&e.shiftKey&&!e.altKey&&!e[T.CTRL_OR_CMD]}),Ai=F({name:"toggleTheme",label:(e,t)=>t.theme===se.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:e=>e.theme===se.LIGHT?es:ts,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,o)=>({appState:{...t,theme:o||(t.theme===se.LIGHT?se.DARK:se.LIGHT)},captureUpdate:D.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===me.D,predicate:(e,t,o,r)=>!!r.props.UIOptions.canvasActions.toggleTheme}),_z=F({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,t)=>{let o;return co(t)?o=Ne(t,{...t.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):o=Ne(t,{type:"eraser",lastActiveToolBeforeEraser:t.activeTool}),{appState:{...t,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:o},captureUpdate:D.IMMEDIATELY}},keyTest:e=>e.key===T.E}),Pz=F({name:"toggleLassoTool",label:"toolBar.lasso",icon:Jl,trackEvent:{category:"toolbar"},perform:(e,t,o,r)=>{let n;return t.activeTool.type!=="lasso"?(n=Ne(t,{type:"lasso",fromSelection:!1}),Le(r.interactiveCanvas,Ce.CROSSHAIR)):n=Ne(t,{type:"selection"}),{appState:{...t,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:D.NEVER}}}),E2=F({name:"toggleHandTool",label:"toolBar.hand",trackEvent:{category:"toolbar"},icon:_d,viewMode:!1,perform:(e,t,o,r)=>{let n;return or(t)?n=Ne(t,{...t.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(n=Ne(t,{type:"hand",lastActiveToolBeforeEraser:t.activeTool}),Le(r.interactiveCanvas,Ce.GRAB)),{appState:{...t,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:D.IMMEDIATELY}},keyTest:e=>!e.altKey&&!e[T.CTRL_OR_CMD]&&e.key===T.H});var fC=F({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,t,o,r)=>{let n=Ne(t,{type:"embeddable"});return Io(r.canvas,{...t,activeTool:n}),{elements:e,appState:{...t,activeTool:Ne(t,{type:"embeddable"})},captureUpdate:D.EVENTUALLY}}});import{jsx as bC}from"react/jsx-runtime";var ko=F({name:"finalize",label:"",trackEvent:!1,perform:(e,t,o,r)=>{let{interactiveCanvas:n,focusContainer:i,scene:a}=r,l=a.getNonDeletedElementsMap();if(t.editingLinearElement){let{elementId:p,startBindingElement:u,endBindingElement:h}=t.editingLinearElement,x=$.getElement(p,l);if(x)return zr(x)&&Uc(x,u,h,a),{elements:x.points.length<2||si(x)?e.filter(b=>b.id!==x.id):void 0,appState:{...t,cursorButton:"up",editingLinearElement:null},captureUpdate:D.IMMEDIATELY}}let s=e,c=t.pendingImageElementId&&a.getElement(t.pendingImageElementId);c&&a.mutateElement(c,{isDeleted:!0},{informMutation:!1,isDragging:!1}),window.document.activeElement instanceof HTMLElement&&i();let m=t.multiElement?t.multiElement:t.newElement?.type==="freedraw"?t.newElement:null;if(m){if(m.type!=="freedraw"&&t.lastPointerDownWith!=="touch"){let{points:u,lastCommittedPoint:h}=m;(!h||u[u.length-1]!==h)&&a.mutateElement(m,{points:m.points.slice(0,-1)})}si(m)&&(s=s.filter(u=>u.id!==m.id));let p=zl(m.points,t.zoom.value);if((m.type==="line"||m.type==="freedraw")&&p){let u=m.points,h=u[0];a.mutateElement(m,{points:u.map((x,b)=>b===u.length-1?M(h[0],h[1]):x)})}if(zr(m)&&!p&&m.points.length>1){let[u,h]=$.getPointAtIndexGlobalCoordinates(m,-1,q(e));Ol(m,t,{x:u,y:h},a)}}(!t.activeTool.locked&&t.activeTool.type!=="freedraw"||!m)&&Co(n);let d;return t.activeTool.type==="eraser"?d=Ne(t,{...t.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):d=Ne(t,{type:"selection"}),{elements:s,appState:{...t,cursorButton:"up",activeTool:(t.activeTool.locked||t.activeTool.type==="freedraw")&&m?t.activeTool:d,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:m&&!t.activeTool.locked&&t.activeTool.type!=="freedraw"?{...t.selectedElementIds,[m.id]:!0}:t.selectedElementIds,selectedLinearElement:m&&le(m)?new $(m,q(s)):t.selectedLinearElement,pendingImageElementId:null},captureUpdate:D.IMMEDIATELY}},keyTest:(e,t)=>e.key===T.ESCAPE&&(t.editingLinearElement!==null||!t.newElement&&t.multiElement===null)||(e.key===T.ESCAPE||e.key===T.ENTER)&&t.multiElement!==null,PanelComponent:({appState:e,updateData:t,data:o})=>bC(te,{type:"button",icon:eE,title:f("buttons.done"),"aria-label":f("buttons.done"),onClick:t,visible:e.multiElement!=null,size:o?.size||"medium",style:{pointerEvents:"all"}})});import xC from"clsx";import{jsx as y2,jsxs as EC}from"react/jsx-runtime";var fs=({children:e,checked:t,onChange:o,className:r})=>EC("div",{className:xC("Checkbox",r,{"is-checked":t}),onClick:n=>{o(!t,n),n.currentTarget.querySelector(".Checkbox-box").focus()},children:[y2("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":t,children:$x}),y2("div",{className:"Checkbox-label",children:e})]});import{jsx as bs}from"react/jsx-runtime";var w2=e=>{let t=e.title||(e.value===se.DARK?f("buttons.lightMode"):f("buttons.darkMode"));return bs(te,{type:"icon",icon:e.value===se.LIGHT?v2.MOON:v2.SUN,title:t,"aria-label":t,onClick:()=>e.onChange(e.value===se.DARK?se.LIGHT:se.DARK),"data-testid":"toggle-dark-mode"})},v2={SUN:bs("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:bs("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:bs("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:bs("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 yC}from"react";import{jsx as T2,jsxs as vC}from"react/jsx-runtime";var S2=e=>{let{id:t}=ft(),[o,r]=yC(e.value),n=a=>{e.ignoreFocus||mb(a.target);let l=a.target.value;l!==e.value&&e.onChange(l)},i=a=>{if(a.key===T.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return vC("div",{className:"ProjectName",children:[T2("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),T2("input",{type:"text",className:"TextInput",onBlur:n,onKeyDown:i,id:`${t}-filename`,value:o,onChange:a=>r(a.target.value)})]})};var ar=32,Ye=12,Ln=256,I2=50,Li="NOT_SPREADSHEET",Pa="VALID_SPREADSHEET",xs=e=>{let t=/^([-+]?)[$€£¥₩]?([-+]?)([\d.,]+)[%]?$/.exec(e);return t?parseFloat(`${(t[1]||t[2])+t[3]}`.replace(/,/g,"")):null},rg=(e,t)=>e.slice(1).every(o=>xs(o[t])!==null),C2=e=>{let t=e[0].length;if(t>2)return{type:Li,reason:"More than 2 columns"};if(t===1){if(!rg(e,0))return{type:Li,reason:"Value is not numeric"};let s=xs(e[0][0])===null,c=(s?e.slice(1):e).map(m=>xs(m[0]));return c.length<2?{type:Li,reason:"Less than two rows"}:{type:Pa,spreadsheet:{title:s?e[0][0]:null,labels:null,values:c}}}let o=rg(e,0),r=rg(e,1);if(!o&&!r)return{type:Li,reason:"Value is not numeric"};let[n,i]=r?[0,1]:[1,0],a=xs(e[0][i])===null,l=a?e.slice(1):e;return l.length<2?{type:Li,reason:"Less than 2 rows"}:{type:Pa,spreadsheet:{title:a?e[0][i]:null,labels:l.map(s=>s[n]),values:l.map(s=>xs(s[i]))}}},wC=e=>{let t=[];for(let o=0;o<e[0].length;o++){let r=[];for(let n=0;n<e.length;n++)r.push(e[n][o]);t.push(r)}return t},k2=e=>{let t=e.trim().split(`
|
|
3
|
-
`).map(i=>i.trim().split(" "));if(
|
|
4
|
-
`).map(i=>i.trim().split(","))),
|
|
5
|
-
`).trim()}:
|
|
1
|
+
import{$ as L1,A as MC,B as x1,C as E1,D as y1,E as Wl,F as oa,G as Vl,H as Xl,I as w1,J as v1,K as na,L as T1,M as I1,N as C1,O as S1,P as Kl,Q as Cr,R as k1,S as PC,T as Lm,U as LC,V as Sr,W as ra,Y as M1,_ as P1,a as h1,aa as Zl,b as Gn,ba as A1,c as ho,ca as Am,d as g1,da as Dm,e as we,ea as $l,f as f1,fa as D1,g as j,ga as _m,h as ea,ha as Ao,i as go,ia as _1,j as Un,ja as Rm,k as Yn,ka as R1,l as vr,la as N1,m as Wn,ma as jl,n as Tr,na as Nm,o as b1,oa as B1,p as km,pa as F1,q as Jo,qa as O1,r as Qo,ra as ia,s as yt,t as Qt,u as Ir,v as Ul,w as Mm,x as ta,y as Yl,z as Pm}from"./chunk-R2M7VUMD.js";import{a as T}from"./chunk-A66AFZZU.js";import{J as Sm}from"./chunk-I4UNSFV6.js";import{c as u1}from"./chunk-Z3N5DIM6.js";import{b as m1,c as p1,d as I}from"./chunk-SRAX5OIU.js";import kU,{useEffect as MU}from"react";import{DEFAULT_UI_OPTIONS as IC,isShallowEqual as PU}from"@excalidraw/common";import rI from"clsx";import rH from"lodash.throttle";import Lo,{useContext as zn}from"react";import{flushSync as Ki}from"react-dom";import iH from"roughjs/bin/rough";import{nanoid as aH}from"nanoid";import{clamp as iI,pointFrom as ie,pointDistance as Rn,vector as aI,pointRotateRads as ff,vectorScale as lH,vectorFromPoint as bf,vectorSubtract as lI,vectorDot as sI,vectorNormalize as cI}from"@excalidraw/math";import{COLOR_PALETTE as sH,CODES as dI,shouldResizeFromCenter as mI,shouldMaintainAspectRatio as Cl,shouldRotateWithDiscreteAngle as xf,isArrowKey as mm,KEYS as V,APP_NAME as cH,CURSOR_TYPE as _e,DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT as dH,DEFAULT_VERTICAL_ALIGN as pI,DRAGGING_THRESHOLD as mH,ELEMENT_SHIFT_TRANSLATE_AMOUNT as pH,ELEMENT_TRANSLATE_AMOUNT as uI,EVENT as te,FRAME_STYLE as Nn,IMAGE_MIME_TYPES as uH,IMAGE_RENDER_TIMEOUT as hH,isBrave as gH,LINE_CONFIRM_THRESHOLD as Ef,MAX_ALLOWED_FILE_BYTES as hI,MIME_TYPES as Mo,MQ_RIGHT_SIDEBAR_MIN_WIDTH as fH,POINTER_BUTTON as hr,ROUNDNESS as pm,SCROLL_TIMEOUT as bH,TAP_TWICE_TIMEOUT as xH,TEXT_TO_CENTER_SNAP_THRESHOLD as EH,THEME as um,THEME_FILTER as yH,TOUCH_CTX_MENU_TIMEOUT as wH,VERTICAL_ALIGN as vH,YOUTUBE_STATES as hm,ZOOM_STEP as TH,POINTER_EVENTS as Zi,TOOL_TYPE as Po,isIOS as IH,supportsResizeObserver as gI,DEFAULT_COLLISION_THRESHOLD as fI,DEFAULT_TEXT_ALIGN as CH,ARROW_TYPE as Bn,DEFAULT_REDUCED_GLOBAL_ALPHA as SH,isSafari as kH,isLocalLink as MH,normalizeLink as yf,toValidURL as PH,getGridPoint as rt,getLineHeight as bI,debounce as xI,distance as $i,getFontString as wf,getNearestScrollableContainer as LH,isInputLike as EI,isToolIcon as AH,isWritableElement as Sl,sceneCoordsToViewportCoords as gm,tupleToCoors as vf,viewportCoordsToSceneCoords as He,wrapEvent as DH,updateObject as Tf,updateActiveTool as $o,getShortcutKey as _H,isTransparent as RH,easeToValuesRAF as NH,muteFSAbortError as BH,isTestEnv as Xf,isDevEnv as oC,easeOut as FH,updateStable as kl,addEventListener as Re,normalizeEOL as OH,getDateTime as yI,isShallowEqual as zH,arrayToMap as fm,randomInteger as HH,CLASSES as GH,Emitter as gr,MINIMUM_ARROW_SIZE as wI,DOUBLE_TAP_POSITION_THRESHOLD as UH,isMobileOrTablet as fr,MQ_MAX_MOBILE as YH,MQ_MIN_TABLET as WH,MQ_MAX_TABLET as VH,MQ_MAX_HEIGHT_LANDSCAPE as XH,MQ_MAX_WIDTH_LANDSCAPE as KH}from"@excalidraw/common";import{getObservedAppState as ZH,getCommonBounds as ji,maybeSuggestBindingsForLinearElementAtCoords as vI,getElementAbsoluteCoords as TI,bindOrUnbindLinearElements as II,fixBindingsAfterDeletion as $H,getHoveredElementForBinding as If,isBindingEnabled as Cf,shouldEnableBindingForPointerEvent as jH,updateBoundElements as Sf,getSuggestedBindingsForArrows as kf,LinearElementEditor as Ie,newElementWith as Fn,newFrameElement as qH,newFreeDrawElement as JH,newEmbeddableElement as CI,newMagicFrameElement as SI,newIframeElement as QH,newArrowElement as eG,newElement as tG,newImageElement as oG,newLinearElement as nG,newTextElement as kI,refreshTextDimensions as rG,deepCopyElement as MI,duplicateElements as Mf,hasBoundTextElement as PI,isArrowElement as Pf,isBindingElement as Lf,isBindingElementType as LI,isBoundToContainer as Af,isFrameLikeElement as kt,isImageElement as br,isEmbeddableElement as jo,isInitializedImageElement as Ml,isLinearElement as jt,isLinearElementType as iG,isUsingAdaptiveRadius as aG,isIframeElement as qi,isIframeLikeElement as Pl,isMagicFrameElement as Df,isTextBindableContainer as AI,isElbowArrow as Xe,isFlowchartNodeElement as lG,isBindableElement as sG,isTextElement as po,getLockedLinearCursorAlignSize as DI,getNormalizedDimensions as cG,isElementCompletelyInViewport as _f,isElementInViewport as _I,isInvisiblySmallElement as RI,getCornerRadius as dG,isPathALoop as NI,createSrcDoc as BI,embeddableURLValidator as Rf,maybeParseEmbedSrc as mG,getEmbedLink as bm,getInitializedImageElements as pG,normalizeSVG as FI,updateImageCache as uG,getBoundTextElement as Nf,getContainerCenter as Bf,getContainerElement as OI,isValidTextContainer as hG,redrawTextBoundingBox as gG,shouldShowBoundingBox as fG,getFrameChildren as Ff,isCursorInFrame as zI,addElementsToFrame as Of,replaceAllElementsInFrame as bG,removeElementsFromFrame as xG,getElementsInResizingFrame as zf,getElementsInNewFrame as EG,getContainingFrame as Hf,elementOverlapsWithFrame as yG,updateFrameMembershipOfSelectedElements as HI,isElementInFrame as GI,getFrameLikeTitle as wG,getElementsOverlappingFrame as vG,filterElementsEligibleAsFrameChildren as TG,hitElementBoundText as IG,hitElementBoundingBoxOnly as CG,hitElementItself as Ll,getVisibleSceneBounds as SG,FlowChartCreator as kG,FlowChartNavigator as MG,getLinkDirectionFromKey as UI,cropElement as PG,wrapText as LG,isElementLink as Gf,parseElementLinkFromURL as AG,isMeasureTextSupported as DG,normalizeText as _G,measureText as YI,getLineHeightInPx as RG,getApproxMinLineWidth as NG,getApproxMinLineHeight as BG,getMinTextElementWidth as FG,ShapeCache as Al,getRenderOpacity as OG,editGroupForSelectedElement as zG,getElementsInGroup as xr,getSelectedGroupIdForElement as HG,getSelectedGroupIds as GG,isElementInGroup as WI,isSelectedViaGroup as UG,selectGroupsForSelectedElements as qt,syncInvalidIndices as nC,syncMovedIndices as VI,excludeElementsInFramesFromSelection as YG,getSelectionStateForElements as WG,makeNextSelectedElementIds as ve,getResizeOffsetXY as VG,getResizeArrowDirection as XG,transformElements as KG,getCursorForResizingElement as XI,getElementWithTransformHandleType as KI,getTransformHandleTypeFromCoords as ZI,dragNewElement as $I,dragSelectedElements as ZG,getDragOffsetXY as $G,isNonDeletedElement as jI,Scene as qI,Store as jG,CaptureUpdateAction as Et,hitElementBoundingBox as qG,isLineElement as xm,isSimpleArrow as JG,StoreDelta as JI,positionElementsOnGrid as QI}from"@excalidraw/element";import{KEYS as sp,updateActiveTool as WC}from"@excalidraw/common";import{getNonDeletedElements as cp}from"@excalidraw/element";import{fixBindingsAfterDeletion as VC}from"@excalidraw/element";import{LinearElementEditor as Nb}from"@excalidraw/element";import{newElementWith as ws}from"@excalidraw/element";import{getContainerElement as Bb}from"@excalidraw/element";import{isBoundToContainer as Es,isElbowArrow as XC,isFrameLikeElement as KC}from"@excalidraw/element";import{getFrameChildren as ZC}from"@excalidraw/element";import{getElementsInGroup as dp,selectGroupsForSelectedElements as $C}from"@excalidraw/element";import{CaptureUpdateAction as ys}from"@excalidraw/element";import{isDevEnv as RC}from"@excalidraw/common";import{atom as he,createStore as AC}from"jotai";import{createIsolation as DC}from"jotai-scope";var z1=DC();var{useAtom:le,useSetAtom:en,useAtomValue:ql,useStore:NU}=z1,H1=z1.Provider,Ue=AC();var _C=m1({"./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-TYY6KWIJ.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 NC=85,fo={code:"en",label:"English"},Mr=[fo,...[{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=>u1[e.code]>=NC).sort((e,o)=>e.label>o.label?1:-1)],Ql="__test__";RC()&&Mr.unshift({code:Ql,label:"test language"},{code:`${Ql}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var kr=fo,Jl={},es=async e=>{if(kr=e,document.documentElement.dir=kr.rtl?"rtl":"ltr",document.documentElement.lang=kr.code,e.code.startsWith(Ql))Jl={};else try{Jl=await _C(`./locales/${kr.code}.json`)}catch(o){console.error(`Failed to load language ${e.code}:`,o.message),Jl=Sm}Ue.set(U1,e.code)},Do=()=>kr,G1=(e,o)=>{for(let t=0;t<o.length;++t){let n=o[t];if(e[n]===void 0)return;e=e[n]}if(typeof e=="string")return e},g=(e,o,t)=>{if(kr.code.startsWith(Ql))return`\u202A[[${o?`${e}(${JSON.stringify(o).slice(1,-1)})`:e}]]\u202C`;let n=e.split("."),r=G1(Jl,n)||G1(Sm,n)||t;if(r===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)r=r.replace(`{{${i}}}`,String(o[i]));return r},U1=he(fo.code),Ge=()=>{let e=ql(U1);return{t:g,langCode:e}};import BC from"clsx";import FC from"open-color";import et from"react";import{THEME as OC}from"@excalidraw/common";import{Fragment as Ee,jsx as h,jsxs as D}from"react/jsx-runtime";var eo=e=>"var(--icon-fill-color)",Y1=e=>e===OC.LIGHT?FC.white:"#1e1e1e",M=(e,o=512)=>{let{width:t=512,height:n=t,mirror:r,style:i,...a}=typeof o=="number"?{width:o}:o;return h("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${t} ${n}`,className:BC({"rtl-mirror":r}),style:i,...a,children:typeof e=="string"?h("path",{fill:"currentColor",d:e}):e})},O={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},oe={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},qU=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"})]}),O),Pr=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"})]}),O),W1=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"})]}),O),V1=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"})]}),O),X1=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),h("path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),h("path",{d:"M19 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"})]}),O),K1=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"})]}),O),Bm=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"})]}),O),Vn=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"})})]}),oe),Lr=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"})]}),oe),Z1=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}),$1=M(D(Ee,{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"}),j1=M(D(Ee,{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"}),q1=M(D(Ee,{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"}),JU=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"}),Fm=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}),aa=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}),ts=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"})]}),O),os=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"})]}),O),ns=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"})]}),O),J1=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"})]}),O),rs=M(h("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),oe),Q1=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"})]}),O),tn=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"})]}),oe),Ar=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"})]}),O),e0=M(D("g",{stroke:"currentColor",strokeWidth:"1.5",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"})]}),O),t0=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"})]}),oe),o0=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"})]}),O),Om=M(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),oe),zm=M(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),oe),n0=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"})]}),O),Mt=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"}),oe),Hm=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"})]}),oe),la=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"})]}),oe),sa=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"}),oe),ca=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"})}),{...oe,strokeWidth:1.5}),is=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"})]}),O),Xn=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"}),oe),Dr=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"})]}),O),r0=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"})]}),O),Gm=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"}),oe),as=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"}),oe),i0=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"})]}),oe),a0=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"})]}),O),l0=M(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),da=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"})]}),oe),s0=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}),c0=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}),_r=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"}),oe),QU=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}),d0=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"),ls=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"})]}),O),m0=M(h("g",{strokeWidth:1.5,children:h("path",{d:"M6 18l12 -12"})}),O),ss=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"})]}),O),p0=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}),eY=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}),tY=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}),u0=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"),oY=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"),Um=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"}),oe),Ym=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"}),oe),h0=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}),g0=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"}),oe),nY=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"),rY=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}),iY=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"})]}),O),aY=M(D(Ee,{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}),lY=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}),f0=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"})]}),b0=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"})]}),Wm=M(b0,O),Vm=M(b0,{...O,style:{transform:"rotate(180deg)"}}),Xm=M(f0,O),Km=M(f0,{...O,style:{transform:"rotate(180deg)"}}),Zm=M(D(Ee,{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"})})})]}),oe),$m=M(D(Ee,{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"})})})]}),oe),jm=M(D(Ee,{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"})})})]}),oe),qm=M(D(Ee,{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"})})})]}),oe),x0=M(D(Ee,{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"})})})]}),oe),E0=M(D(Ee,{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"})})})]}),oe),Jm=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"})]}),oe),Qm=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"})]}),oe),cs=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"})]}),O),sY=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"),cY=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"),zt=M(D(Ee,{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"})})})]}),oe),dY=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}),mY=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}),pY=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}),ep=et.memo(({theme:e})=>M(D(Ee,{children:[h("path",{d:"M25 26H111V111H25",fill:eo(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:eo(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:eo(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:eo(e),strokeWidth:"2"}),D("g",{fill:Y1(e),stroke:eo(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})),tp=et.memo(({theme:e})=>M(D(Ee,{children:[h("path",{d:"M25 26H111V111H25",fill:eo(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:eo(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:eo(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:eo(e),strokeWidth:"2"}),D("g",{fill:Y1(e),stroke:eo(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})),y0=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"})}),oe),w0=M(D(Ee,{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"})})]}),oe),v0=M(D(Ee,{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"})})})]}),oe),T0=M(D(Ee,{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"})})})]}),{...oe,fill:"currentColor"}),op=M(h(Ee,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),oe),I0=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),oe),C0=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),oe),uY=et.memo(({theme:e})=>M(h("path",{d:"M6 10H34",stroke:eo(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"})]}),O),k0=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"})]}),O),M0=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"}),oe),P0=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"}),oe),L0=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"}),oe),A0=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"})]}),oe),D0=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"})]}),O),_0=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"})]}),O),R0=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})),N0=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})),B0=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})),F0=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})),O0=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})),z0=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})),H0=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})),G0=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})),U0=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})),Y0=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})),W0=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})),V0=M(D(Ee,{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"})})})]}),oe),X0=M(D(Ee,{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"})})})]}),oe),K0=M(D(Ee,{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"})})})]}),oe),Z0=M(h(Ee,{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"})}),oe),Kn=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"})]}),O),$0=M(h(Ee,{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"})]})}),O),ma=M(h(Ee,{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"})})}),oe),ds=M(D(Ee,{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"})})})]}),oe),j0=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"})]}),O),q0=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"})]}),O),J0=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"})]}),O),Q0=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"})]}),O)),eb=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"})]}),O)),tb=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"})]}),O)),ms=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"})]}),O),ob=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}),hY=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"})),ps=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"})]}),O),np=M(D(Ee,{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"})]}),O),Rr=M(D(Ee,{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"})]}),O),nb=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"})]}),O),rb=M(D(Ee,{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"})]}),O),gY=M(D(Ee,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),O),fY=M(D(Ee,{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"})]}),O),ib=M(D(Ee,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),O),ab=M(D(Ee,{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"})]}),O),lb=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"})]}),O),sb=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"})]}),O),Zn=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"})]}),O),us=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"})),Nr=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"})]}),oe),pa=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),hs=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"})]}),O),bY=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"})]}),O),xY=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"})]}),O),cb=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"})]}),O),Br=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"})]}),O),db=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"})]}),O),mb=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"})]}),O),pb=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"})]}),O),Pt=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"})]}),O),ub=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"})]}),O),hb=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"})]}),O),gb=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"})]}),O),ua=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"})]}),O),fb=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"})]}),O),bb=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"})]}),O),xb=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"})]}),O),Eb=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"})]}),O),rp=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"})]}),O),gs=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"})]}),O),yb=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"})]}),O),wb=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"})]}),O),vb=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"})]}),O),Tb=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"})]}),O),Ib=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"})]}),{...O,strokeWidth:1.5}),EY=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"})]}),O),Cb=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"})]}),O),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"})]}),O),kb=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"})]}),O),Fr=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"})]}),O),Or=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"})]}),O),zr=M(D("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),O),fs=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),O),Mb=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),O),Pb=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),O),ip=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"})]}),O),bs=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"})]}),O),yY=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 11v8a1 1 0 0 0 1 1h8m-9 -14v-1a1 1 0 0 1 1 -1h1m5 0h2m5 0h1a1 1 0 0 1 1 1v1m0 5v2m0 5v1a1 1 0 0 1 -1 1h-1"}),h("path",{d:"M4 12h7a1 1 0 0 1 1 1v7"})]}),O),Lb=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 6l8 0"}),h("path",{d:"M16 6l4 0"}),h("path",{d:"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 12l2 0"}),h("path",{d:"M10 12l10 0"}),h("path",{d:"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 18l11 0"}),h("path",{d:"M19 18l1 0"})]}),O),Ab=M(D("g",{strokeWidth:1,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 10l4 -4"}),h("path",{d:"M6 14l8 -8"}),h("path",{d:"M6 18l12 -12"}),h("path",{d:"M10 18l8 -8"}),h("path",{d:"M14 18l4 -4"})]}),O),Db=M(D("g",{strokeWidth:1,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:"6",y:"6",width:"12",height:"12",fill:"none"})]}),O);import _b from"clsx";import lp,{useEffect as GC,useRef as Rb,useState as UC}from"react";import{isPromiseLike as YC}from"@excalidraw/common";import zC from"react";import{jsx as ap}from"react/jsx-runtime";var HC=({size:e="1em",circleWidth:o=8,synchronized:t=!1,className:n=""})=>{let i=-(zC.useRef(Date.now()).current%1600);return ap("div",{className:`Spinner ${n}`,children:ap("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:ap("circle",{cx:"50",cy:"50",r:50-o/2,strokeWidth:o,fill:"none",strokeMiterlimit:"10"})})})},tt=HC;import{jsx as ha,jsxs as ga}from"react/jsx-runtime";var Z=lp.forwardRef(({size:e="medium",visible:o=!0,className:t="",...n},r)=>{let{id:i}=Ne(),a=lp.useRef(null);lp.useImperativeHandle(r,()=>a.current);let l=`ToolIcon_size_${e}`,[s,m]=UC(!1),d=Rb(!0),c=async u=>{let f="onClick"in n&&n.onClick?.(u);if(YC(f))try{m(!0),await f}catch(b){if(b instanceof Tr)console.warn(b);else throw b}finally{d.current&&m(!1)}};GC(()=>(d.current=!0,()=>{d.current=!1}),[]);let p=Rb(null);if(n.type==="button"||n.type==="icon"||n.type==="submit"){let u=n.type==="icon"?"button":n.type;return ga("button",{className:_b("ToolIcon_type_button",l,t,o&&!n.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!n.hidden,"ToolIcon--selected":n.selected,"ToolIcon--plain":n.type==="icon"}),style:n.style,"data-testid":n["data-testid"],hidden:n.hidden,title:n.title,"aria-label":n["aria-label"],type:u,onClick:c,ref:a,disabled:s||n.isLoading||!!n.disabled,children:[(n.icon||n.label)&&ga("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!n.disabled,children:[n.icon||n.label,n.keyBindingLabel&&ha("span",{className:"ToolIcon__keybinding",children:n.keyBindingLabel}),n.isLoading&&ha(tt,{})]}),n.showAriaLabel&&ga("div",{className:"ToolIcon__label",children:[n["aria-label"]," ",s&&ha(tt,{})]}),n.children]})}return ga("label",{className:_b("ToolIcon",t),title:n.title,onPointerDown:u=>{p.current=u.pointerType||null,n.onPointerDown?.({pointerType:u.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{p.current=null})},children:[ha("input",{className:`ToolIcon_type_radio ${l}`,type:"radio",name:n.name,"aria-label":n["aria-label"],"aria-keyshortcuts":n["aria-keyshortcuts"],"data-testid":n["data-testid"],id:`${i}-${n.id}`,onChange:()=>{n.onChange?.({pointerType:p.current})},checked:n.checked,ref:a}),ga("div",{className:"ToolIcon__icon",children:[n.icon,n.keyBindingLabel&&ha("span",{className:"ToolIcon__keybinding",children:n.keyBindingLabel})]})]})});Z.displayName="ToolButton";var xs=[],N=e=>(xs=xs.concat(e),e);import{jsx as qC}from"react/jsx-runtime";var jC=(e,o,t)=>{let n=new Set(j(e.filter(d=>KC(d)),o).map(d=>d.id)),r={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let d of n){let c=ZC(e,d);for(let p of c)if(!a.has(p.id)){if(Es(p)){let u=Bb(p,i);u&&(r[u.id]=!0)}else r[p.id]=!0;a.add(p.id)}}let l=!0,s=e.map(d=>{if(o.selectedElementIds[d.id]){let c=Es(d)?Bb(d,i):null;return d.frameId&&n.has(d.frameId)?(l=!1,r[d.id]=!0,d):c?.frameId&&n.has(c?.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})}),ws(d,{isDeleted:!0}))}return d.frameId&&n.has(d.frameId)?(l=!1,Es(d)||(r[d.id]=!0),ws(d,{frameId:null})):Es(d)&&o.selectedElementIds[d.containerId]?ws(d,{isDeleted:!0}):d}),m=o.editingGroupId;if(l&&o.editingGroupId){let d=dp(s,o.editingGroupId).filter(c=>!c.isDeleted);if(d.length>1)d[0]&&(r[d[0].id]=!0);else{m=null,d[0]&&(r[d[0].id]=!0);let c=d[0];if(c){let p=c.groupIds.findIndex(f=>f===o.editingGroupId),u=c.groupIds[p+1];if(u){let f=dp(s,u).filter(b=>!b.isDeleted);f.length>1&&(m=u,f.forEach(b=>{r[b.id]=!0}))}}}}return{elements:s,appState:{...o,...$C({selectedElementIds:r,editingGroupId:m},s,o,null)}}},Fb=(e,o)=>{if(e.editingGroupId){let t=dp(cp(o),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},fa=N({name:"deleteSelectedElements",label:"labels.delete",icon:Mt,trackEvent:{category:"element",action:"delete"},perform:(e,o,t,n)=>{if(o.selectedLinearElement?.isEditing){let{elementId:a,selectedPointsIndices:l,startBindingElement:s,endBindingElement:m}=o.selectedLinearElement,d=n.scene.getNonDeletedElementsMap(),c=Nb.getElement(a,d);if(!c||l==null)return!1;if(l.length>=c.points.length){let u=e.map(b=>b.id===c.id?ws(b,{isDeleted:!0}):b),f=Fb(o,u);return{elements:u,appState:{...f,selectedLinearElement:null},captureUpdate:ys.IMMEDIATELY}}let p={startBindingElement:l?.includes(0)?null:s,endBindingElement:l?.includes(c.points.length-1)?null:m};return Nb.deletePoints(c,n,l),{elements:e,appState:{...o,selectedLinearElement:{...o.selectedLinearElement,...p,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},captureUpdate:ys.IMMEDIATELY}}let{elements:r,appState:i}=jC(e,o,n);return VC(r,r.filter(a=>a.isDeleted)),i=Fb(i,r),{elements:r,appState:{...i,activeTool:WC(o,{type:n.defaultSelectionTool}),multiElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:we(cp(e),o)?ys.IMMEDIATELY:ys.EVENTUALLY}},keyTest:(e,o,t)=>(e.key===sp.BACKSPACE||e.key===sp.DELETE)&&!e[sp.CTRL_OR_CMD],PanelComponent:({elements:e,appState:o,updateData:t})=>qC(Z,{type:"button",icon:Mt,title:g("labels.delete"),"aria-label":g("labels.delete"),onClick:()=>t(null),visible:we(cp(e),o)})});import{KEYS as Hr,CODES as Gr,getShortcutKey as Ur,isDarwin as vs}from"@excalidraw/common";import{moveOneLeft as JC,moveOneRight as QC,moveAllLeft as eS,moveAllRight as tS}from"@excalidraw/element";import{CaptureUpdateAction as Ts}from"@excalidraw/element";import{jsx as Is}from"react/jsx-runtime";var mp=N({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:Vm,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:JC(e,o,n.scene),appState:o,captureUpdate:Ts.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Hr.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Gr.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>Is("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendBackward")} \u2014 ${Ur("CtrlOrCmd+[")}`,children:Vm})}),pp=N({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:Wm,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:QC(e,o,n.scene),appState:o,captureUpdate:Ts.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Hr.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Gr.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>Is("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.bringForward")} \u2014 ${Ur("CtrlOrCmd+]")}`,children:Wm})}),up=N({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:Km,trackEvent:{category:"element"},perform:(e,o)=>({elements:eS(e,o),appState:o,captureUpdate:Ts.IMMEDIATELY}),keyTest:e=>vs?e[Hr.CTRL_OR_CMD]&&e.altKey&&e.code===Gr.BRACKET_LEFT:e[Hr.CTRL_OR_CMD]&&e.shiftKey&&e.code===Gr.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>Is("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendToBack")} \u2014 ${vs?Ur("CtrlOrCmd+Alt+["):Ur("CtrlOrCmd+Shift+[")}`,children:Km})}),hp=N({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:Xm,trackEvent:{category:"element"},perform:(e,o)=>({elements:tS(e,o),appState:o,captureUpdate:Ts.IMMEDIATELY}),keyTest:e=>vs?e[Hr.CTRL_OR_CMD]&&e.altKey&&e.code===Gr.BRACKET_RIGHT:e[Hr.CTRL_OR_CMD]&&e.shiftKey&&e.code===Gr.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>Is("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${g("labels.bringToFront")} \u2014 ${vs?Ur("CtrlOrCmd+Alt+]"):Ur("CtrlOrCmd+Shift+]")}`,children:Xm})});import{getNonDeletedElements as oS}from"@excalidraw/element";import{LinearElementEditor as nS}from"@excalidraw/element";import{isLinearElement as rS,isTextElement as iS}from"@excalidraw/element";import{arrayToMap as aS,KEYS as Ob}from"@excalidraw/common";import{selectGroupsForSelectedElements as lS}from"@excalidraw/element";import{CaptureUpdateAction as sS}from"@excalidraw/element";var gp=N({name:"selectAll",label:"labels.selectAll",icon:fb,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,o,t,n)=>{if(o.selectedLinearElement?.isEditing)return!1;let r=e.filter(i=>!i.isDeleted&&!(iS(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...o,...lS({editingGroupId:null,selectedElementIds:r},oS(e),o,n),selectedLinearElement:Object.keys(r).length===1&&rS(e[0])?new nS(e[0],aS(e)):null},captureUpdate:sS.IMMEDIATELY}},keyTest:e=>e[Ob.CTRL_OR_CMD]&&e.key===Ob.A});import{DEFAULT_GRID_SIZE as zb,KEYS as Hb,arrayToMap as Gb,getShortcutKey as cS}from"@excalidraw/common";import{getNonDeletedElements as Ub}from"@excalidraw/element";import{LinearElementEditor as dS}from"@excalidraw/element";import{getSelectedElements as mS,getSelectionStateForElements as pS}from"@excalidraw/element";import{syncMovedIndices as uS}from"@excalidraw/element";import{duplicateElements as hS}from"@excalidraw/element";import{CaptureUpdateAction as Yb}from"@excalidraw/element";import{jsx as gS}from"react/jsx-runtime";var fp=N({name:"duplicateSelection",label:"labels.duplicateSelection",icon:la,trackEvent:{category:"element"},perform:(e,o,t,n)=>{if(o.selectedElementsAreBeingDragged)return!1;if(o.selectedLinearElement?.isEditing)try{let a=dS.duplicateSelectedPoints(o,n.scene);return{elements:e,appState:a,captureUpdate:Yb.IMMEDIATELY}}catch{return!1}let{duplicatedElements:r,elementsWithDuplicates:i}=hS({type:"in-place",elements:e,idsOfElementsToDuplicate:Gb(mS(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+zb/2,y:a.y+zb/2,frameId:s??a.frameId}}});if(n.props.onDuplicate&&i){let a=n.props.onDuplicate(i,e);a&&(i=a)}return{elements:uS(i,Gb(r)),appState:{...o,...pS(r,Ub(i),o)},captureUpdate:Yb.IMMEDIATELY}},keyTest:e=>e[Hb.CTRL_OR_CMD]&&e.key===Hb.D,PanelComponent:({elements:e,appState:o,updateData:t})=>gS(Z,{type:"button",icon:la,title:`${g("labels.duplicateSelection")} \u2014 ${cS("CtrlOrCmd+D")}`,"aria-label":g("labels.duplicateSelection"),onClick:()=>t(null),visible:we(Ub(e),o)})});import{pointFrom as u4}from"@excalidraw/math";import{useEffect as zp,useMemo as h4,useRef as Hp,useState as g4}from"react";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as f4,DEFAULT_ELEMENT_BACKGROUND_PICKS as b4,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as x4,DEFAULT_ELEMENT_STROKE_PICKS as E4,ARROW_TYPE as No,DEFAULT_FONT_FAMILY as y4,DEFAULT_FONT_SIZE as w4,FONT_FAMILY as v4,ROUNDNESS as Ys,STROKE_WIDTH as Gp,VERTICAL_ALIGN as Us,KEYS as Jr,randomInteger as T4,arrayToMap as Wp,getFontFamilyString as I4,getShortcutKey as C4,getLineHeight as S4,isTransparent as k4,reduceToCommonValue as M4}from"@excalidraw/common";import{canBecomePolygon as P4,getNonDeletedElements as Rx}from"@excalidraw/element";import{bindLinearElement as Lx,calculateFixedPointForElbowArrowBinding as Ax,updateBoundElements as L4}from"@excalidraw/element";import{LinearElementEditor as Up}from"@excalidraw/element";import{newElementWith as Ze}from"@excalidraw/element";import{getBoundTextElement as mn,redrawTextBoundingBox as Ma}from"@excalidraw/element";import{isArrowElement as Ws,isBoundToContainer as A4,isElbowArrow as Nx,isLinearElement as Yp,isLineElement as Dx,isTextElement as wt,isUsingAdaptiveRadius as D4}from"@excalidraw/element";import{hasStrokeColor as _4}from"@excalidraw/element";import{updateElbowArrowPoints as R4,CaptureUpdateAction as $e,toggleLinePolygonState as N4}from"@excalidraw/element";import{isDevEnv as fS}from"@excalidraw/common";var bS=new Set(["command_palette","export"]),re=(e,o,t,n)=>{try{if(typeof window>"u"||T.VITE_WORKER_ID||T.VITE_APP_ENABLE_TRACKING!=="true"||!bS.has(e)||fS())return;T.PROD||console.info("trackEvent",{category:e,action:o,label:t,value:n}),window.sa_event&&window.sa_event(o,{category:e,label:t,value:n})}catch(r){console.error("error during analytics",r)}};import wS from"clsx";import xS from"clsx";import{forwardRef as ES}from"react";import{jsx as yS}from"react/jsx-runtime";var Yr=ES((e,o)=>{let{title:t,className:n,testId:r,active:i,standalone:a,icon:l,onClick:s}=e;return yS("button",{type:"button",ref:o,title:t,"data-testid":r,className:xS(n,{standalone:a,active:i}),onClick:s,style:e.style,children:l},t)});import{Fragment as TS,jsx as bp,jsxs as vS}from"react/jsx-runtime";var Ht=e=>bp(TS,{children:e.options.map(o=>e.type==="button"?bp(Yr,{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):vS("label",{className:wS({active:e.value===o.value}),title:o.text,children:[bp("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 _s from"@radix-ui/react-popover";import dx from"clsx";import{useRef as mx,useEffect as T6}from"react";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as Lp,COLOR_PALETTE as px,isTransparent as I6}from"@excalidraw/common";import{jsx as IS}from"react/jsx-runtime";var Cs=()=>IS("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as PS,useRef as LS}from"react";import{createPortal as AS}from"react-dom";import{EVENT as nn,KEYS as DS,rgbToHex as _S}from"@excalidraw/common";import Wb from"react";var xp=Wb.createContext(null),be=()=>Wb.useContext(xp);import{useState as CS,useLayoutEffect as Vb}from"react";import{THEME as SS}from"@excalidraw/common";var Ss=e=>{let[o,t]=CS(null),n=de(),{theme:r}=be(),{container:i}=Ne();return Vb(()=>{o&&(o.className="",o.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),o.classList.toggle("excalidraw--mobile",n.editor.isMobile),o.classList.toggle("theme--dark",r===SS.DARK))},[o,r,n.editor.isMobile,e?.className]),Vb(()=>{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 kS}from"react";import{EVENT as ks}from"@excalidraw/common";function Wr(e,o,t){kS(()=>{function n(r){let i=r;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(ks.POINTER_DOWN,n),document.addEventListener(ks.TOUCH_START,n),()=>{document.removeEventListener(ks.POINTER_DOWN,n),document.removeEventListener(ks.TOUCH_START,n)}},[e,o,t])}import{useRef as MS}from"react";var on=e=>{let o=MS(e);return Object.assign(o.current,e),o.current};import{jsx as RS}from"react/jsx-runtime";var rn=he(null),Xb=({onCancel:e,onChange:o,onSelect:t,colorPickerType:n})=>{let r=Ss({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=be(),a=an(),l=Be(),s=j(a,i),m=on({app:l,onCancel:e,onChange:o,onSelect:t,selectedElements:s}),{container:d}=Ne();PS(()=>{let p=c.current;if(!p||!l.canvas||!r)return;let u=!1,f=l.canvas.getContext("2d"),b=({clientX:S,clientY:L})=>{let P=f.getImageData((S-i.offsetLeft)*window.devicePixelRatio,(L-i.offsetTop)*window.devicePixelRatio,1,1).data;return _S(P[0],P[1],P[2])},x=({clientX:S,clientY:L,altKey:P})=>{p.style.top=`${L+20}px`,p.style.left=`${S+20}px`;let B=b({clientX:S,clientY:L});u&&m.onChange(n,B,m.selectedElements,{altKey:P}),p.style.background=B},y=()=>{m.onCancel()},E=(S,L)=>{m.onSelect(S,L)},w=S=>{u=!0,S.stopImmediatePropagation()},v=S=>{u=!1,d?.focus(),S.stopImmediatePropagation(),S.preventDefault(),E(b(S),S)},C=S=>{S.key===DS.ESCAPE&&(S.preventDefault(),S.stopImmediatePropagation(),y())};return r.tabIndex=-1,r.focus(),x({clientX:m.app.lastViewportPosition.x,clientY:m.app.lastViewportPosition.y,altKey:!1}),r.addEventListener(nn.KEYDOWN,C),r.addEventListener(nn.POINTER_DOWN,w),r.addEventListener(nn.POINTER_UP,v),window.addEventListener("pointermove",x,{passive:!0}),window.addEventListener(nn.BLUR,y),()=>{u=!1,r.removeEventListener(nn.KEYDOWN,C),r.removeEventListener(nn.POINTER_DOWN,w),r.removeEventListener(nn.POINTER_UP,v),window.removeEventListener("pointermove",x),window.removeEventListener(nn.BLUR,y)}},[m,l.canvas,r,n,d,i.offsetLeft,i.offsetTop]);let c=LS(null);return Wr(c,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),r?AS(RS("div",{ref:c,className:"excalidraw-eye-dropper-preview"}),r):null};import*as Vr from"@radix-ui/react-popover";import OS from"clsx";import zS from"react";import{isInteractive as HS}from"@excalidraw/common";import NS from"react";import BS from"clsx";import{jsx as FS}from"react/jsx-runtime";var Ye=NS.forwardRef(({children:e,padding:o,className:t,style:n},r)=>FS("div",{className:BS("Island",t),style:{"--padding":o,...n},ref:r,children:e}));import{jsx as Ep,jsxs as GS}from"react/jsx-runtime";var _o=zS.forwardRef(({className:e,container:o,children:t,style:n,onClose:r,onKeyDown:i,onFocusOutside:a,onPointerLeave:l,onPointerDownOutside:s,preventAutoFocusOnTouch:m=!1},d)=>{let c=de();return Ep(Vr.Portal,{container:o,children:GS(Vr.Content,{ref:d,className:OS("focus-visible-none",e),"data-prevent-outside-click":!0,side:c.editor.isMobile&&!c.viewport.isLandscape?"bottom":"right",align:c.editor.isMobile&&!c.viewport.isLandscape?"center":"start",alignOffset:-16,sideOffset:20,style:{zIndex:"var(--zIndex-popup)"},onPointerLeave:l,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:s,onOpenAutoFocus:p=>{m&&c.isTouchScreen&&p.preventDefault()},onCloseAutoFocus:p=>{p.stopPropagation(),p.preventDefault(),o&&!HS(document.activeElement)&&o.focus(),r()},children:[Ep(Ye,{padding:3,style:n,children:t}),Ep(Vr.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})});import{useState as US,useCallback as yp}from"react";var Ms=()=>document.querySelector(".excalidraw-wysiwyg"),Ps=()=>{let e=Ms();return e?{start:e.selectionStart,end:e.selectionEnd}:null},ba=e=>{setTimeout(()=>{let o=Ms();o&&(o.focus(),e&&(o.selectionStart=e.start,o.selectionEnd=e.end))},0)},xa=(e,o,t,n)=>{o&&n&&n();let r=o&&t?Ps():null;e(),o&&t&&ba(r)},Kb=()=>{let[e,o]=US(null),t=yp(()=>{let i=Ps();o(i)},[]),n=yp(()=>{setTimeout(()=>{let i=Ms();i&&(i.focus(),e&&(i.selectionStart=e.start,i.selectionEnd=e.end,o(null)))},0)},[e]),r=yp(()=>{o(null)},[]);return{saveCaretPosition:t,restoreCaretPosition:n,clearSavedPosition:r,hasSavedPosition:!!e}},Zb=(e=100)=>{let o=Ms();if(o){let t=o.onblur;o.onblur=null,setTimeout(()=>{o.onblur=t},e)}};import WS from"clsx";import{useCallback as VS,useEffect as vp,useRef as qb,useState as XS}from"react";import{KEYS as Tp,getShortcutKey as KS}from"@excalidraw/common";import{MAX_CUSTOM_COLORS_USED_IN_CANVAS as YS}from"@excalidraw/common";var ln=({palette:e,color:o})=>{if(!o)return null;for(let[t,n]of Object.entries(e))if(Array.isArray(n)){let r=n.indexOf(o);if(r>-1)return{colorName:t,shade:r}}else if(n===o)return{colorName:t,shade:null};return null},Ea=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),wp=({color:e,palette:o})=>!Object.values(o).flat().includes(e),jb=(e,o,t)=>{let n={elementBackground:"backgroundColor",elementStroke:"strokeColor"},r=e.filter(a=>{if(a.isDeleted)return!1;let l=a[n[o]];return wp({color:l,palette:t})}),i=new Map;return r.forEach(a=>{let l=a[n[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,YS)},Gt=he(null),$b=(e,o,t)=>(e*299+o*587+t*114)/1e3,sn=(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]),m=parseInt(l[1]),d=parseInt(l[2]);return $b(s,m,d)<o}return!0}let t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16);return $b(t,n,r)<o};import{Fragment as ZS,jsx as Ls,jsxs as Jb}from"react/jsx-runtime";var Qb=({color:e,onChange:o,label:t,colorPickerType:n,placeholder:r})=>{let i=de(),[a,l]=XS(e),[s,m]=le(Gt);vp(()=>{l(e)},[e]);let d=VS(b=>{let x=b.toLowerCase(),y=ex(x);y&&o(y),l(x)},[o]),c=qb(null),p=qb(null);vp(()=>{c.current&&c.current.focus()},[s]);let[u,f]=le(rn);return vp(()=>()=>{f(null)},[f]),Jb("div",{className:"color-picker__input-label",children:[Ls("div",{className:"color-picker__input-hash",children:"#"}),Ls("input",{ref:s==="hex"?c: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:()=>m("hex"),onKeyDown:b=>{b.key!==Tp.TAB&&(b.key===Tp.ESCAPE&&p.current?.focus(),b.stopPropagation())},placeholder:r}),!i.editor.isMobile&&Jb(ZS,{children:[Ls("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),Ls("div",{ref:p,className:WS("excalidraw-eye-dropper-trigger",{selected:u}),onClick:()=>f(b=>b?null:{keepOpenOnAlt:!1,onSelect:x=>o(x),colorPickerType:n}),title:`${g("labels.eyeDropper")} \u2014 ${Tp.I.toLocaleUpperCase()} or ${KS("Alt")} `,children:lb})]})]})};import kp,{useEffect as Mp,useImperativeHandle as u6,useState as h6}from"react";import{EVENT as ax}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as g6,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as f6,KEYS as b6}from"@excalidraw/common";import qS from"clsx";import{useEffect as JS,useRef as QS}from"react";import{jsxs as jS}from"react/jsx-runtime";var $S=({color:e,keyLabel:o,isShade:t=!1})=>jS("div",{className:"color-picker__button__hotkey-label",style:{color:sn(e)?"#fff":"#000"},children:[t&&"\u21E7",o]}),Xr=$S;import{jsx as Ip,jsxs as e6}from"react/jsx-runtime";var tx=({colors:e,color:o,onChange:t,label:n})=>{let[r,i]=le(Gt),a=QS(null);return JS(()=>{a.current&&a.current.focus()},[o,r]),Ip("div",{className:"color-picker-content--default",children:e.map((l,s)=>e6("button",{ref:o===l?a:void 0,tabIndex:-1,type:"button",className:qS("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":n,style:{"--swatch-color":l},children:[Ip("div",{className:"color-picker__button-outline"}),Ip(Xr,{color:l,keyLabel:s+1})]},s))})};import t6 from"clsx";import{useEffect as o6,useRef as n6}from"react";import{jsx as Cp,jsxs as i6}from"react/jsx-runtime";var r6=({palette:e,color:o,onChange:t,activeShade:n})=>{let r=ln({color:o,palette:e}),[i,a]=le(Gt),l=n6(null);return o6(()=>{l.current&&i==="baseColors"&&l.current.focus()},[r?.colorName,i]),Cp("div",{className:"color-picker-content--default",children:Object.entries(e).map(([s,m],d)=>{let c=(Array.isArray(m)?m[n]:m)||"transparent",p=Ea[d],u=g(`colors.${s.replace(/\d+/,"")}`,null,"");return i6("button",{ref:r?.colorName===s?l:void 0,tabIndex:-1,type:"button",className:t6("color-picker__button color-picker__button--large has-outline",{active:r?.colorName===s,"is-transparent":c==="transparent"||!c}),onClick:()=>{t(c),a("baseColors")},title:`${u}${c.startsWith("#")?` ${c}`:""} \u2014 ${p}`,"aria-label":`${u} \u2014 ${p}`,style:c?{"--swatch-color":c}:void 0,"data-testid":`color-${s}`,children:[Cp("div",{className:"color-picker__button-outline"}),Cp(Xr,{color:c,keyLabel:p})]},s)})})},ox=r6;import{jsx as l6}from"react/jsx-runtime";var a6=({children:e})=>l6("div",{className:"color-picker__heading",children:e}),Kr=a6;import s6 from"clsx";import{useEffect as c6,useRef as d6}from"react";import{jsx as ya,jsxs as nx}from"react/jsx-runtime";var rx=({color:e,onChange:o,palette:t})=>{let n=ln({color:e||"transparent",palette:t}),[r,i]=le(Gt),a=d6(null);if(c6(()=>{a.current&&r==="shades"&&a.current.focus()},[n,r]),n){let{colorName:l,shade:s}=n,m=t[l];if(Array.isArray(m))return ya("div",{className:"color-picker-content--default shades",children:m.map((d,c)=>nx("button",{ref:c===s&&r==="shades"?a:void 0,tabIndex:-1,type:"button",className:s6("color-picker__button color-picker__button--large has-outline",{active:c===s}),"aria-label":"Shade",title:`${l} - ${c+1}`,style:d?{"--swatch-color":d}:void 0,onClick:()=>{o(d),i("shades")},children:[ya("div",{className:"color-picker__button-outline"}),ya(Xr,{color:d,keyLabel:c+1,isShade:!0})]},c))})}return nx("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[ya("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),ya("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 Zr,COLOR_PALETTE as m6,KEYS as wa}from"@excalidraw/common";var Sp=(e,o,t)=>{let n=Math.ceil(t/Zr);switch(o=o??-1,e){case"ArrowLeft":{let r=o-1;return r<0?t-1:r}case"ArrowRight":return(o+1)%t;case"ArrowDown":{let r=o+Zr;return r>=t?o%Zr:r}case"ArrowUp":{let r=o-Zr,i=r<0?Zr*n+r:r;return i>=t?void 0:i}}},p6=({e,colorObj:o,onChange:t,palette:n,customColors:r,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(n[o.colorName][l]),i("shades"),!0}if(["1","2","3","4","5"].includes(e.key)&&r[Number(e.key)-1])return t(r[Number(e.key)-1]),i("custom"),!0;if(Ea.includes(e.key)){let l=Ea.indexOf(e.key),s=Object.keys(n)[l],m=n[s],d=Array.isArray(m)?m[a]:m;return t(d),i("baseColors"),!0}return!1},ix=({event:e,activeColorPickerSection:o,palette:t,color:n,onChange:r,customColors:i,setActiveColorPickerSection:a,updateData:l,activeShade:s,onEyeDropperToggle:m,onEscape:d})=>{if(e[wa.CTRL_OR_CMD])return!1;if(e.key===wa.ESCAPE)return d(e),!0;if(e.key===wa.ALT)return m(!0),!0;if(e.key===wa.I)return m(),!0;let c=ln({color:n,palette:t});if(e.key===wa.TAB){let p={custom:!!i.length,baseColors:!0,shades:c?.shade!=null,hex:!0},u=Object.entries(p).reduce((E,[w,v])=>(v&&E.push(w),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,y=u[x];return y&&a(y),y==="custom"?r(i[0]):y==="baseColors"&&(Object.entries(t).find(([w,v])=>Array.isArray(v)?v.includes(n):v===n?w:null)||r(m6.black)),e.preventDefault(),e.stopPropagation(),!0}if(p6({e,colorObj:c,onChange:r,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:s}))return!0;if(o==="shades"&&c){let{shade:p}=c,u=Sp(e.key,p,Zr);if(u!==void 0)return r(t[c.colorName][u]),!0}if(o==="baseColors"&&c){let{colorName:p}=c,u=Object.keys(t),f=u.indexOf(p),b=Sp(e.key,f,u.length);if(b!==void 0){let x=u[b],y=t[x];return r(Array.isArray(y)?y[s]:y),!0}}if(o==="custom"){let p=n!=null?i.indexOf(n):0,u=Sp(e.key,p,i.length);if(u!==void 0){let f=i[u];return r(f),!0}}return!1};import{jsx as $n,jsxs as As}from"react/jsx-runtime";var lx=kp.forwardRef(({color:e,onChange:o,type:t,elements:n,palette:r,updateData:i,children:a,onEyeDropperToggle:l,onEscape:s},m)=>{let[d]=kp.useState(()=>t==="canvasBackground"?[]:jb(n,t,r)),[c,p]=le(Gt),u=ln({color:e,palette:r});Mp(()=>{if(!c){let y=!!e&&wp({color:e,palette:r}),E=y&&!d.includes(e);p(E?null:y?"custom":u?.shade!=null?"shades":"baseColors")}},[c,e,r,p,u,d]);let[f,b]=h6(u?.shade??(t==="elementBackground"?g6:f6));Mp(()=>{u?.shade!=null&&b(u.shade);let y=E=>{E.key===b6.ALT&&l(!1)};return document.addEventListener(ax.KEYUP,y,{capture:!0}),()=>{document.removeEventListener(ax.KEYUP,y,{capture:!0})}},[u,l]);let x=kp.useRef(null);return u6(m,()=>x.current),Mp(()=>{x?.current?.focus()},[]),$n("div",{role:"dialog","aria-modal":"true","aria-label":g("labels.colorPicker"),children:As("div",{ref:x,onKeyDown:y=>{ix({event:y,activeColorPickerSection:c,palette:r,color:e,onChange:o,onEyeDropperToggle:l,customColors:d,setActiveColorPickerSection:p,updateData:i,activeShade:f,onEscape:s})&&(y.preventDefault(),y.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[!!d.length&&As("div",{children:[$n(Kr,{children:g("colorPicker.mostUsedCustomColors")}),$n(tx,{colors:d,color:e,label:g("colorPicker.mostUsedCustomColors"),onChange:o})]}),As("div",{children:[$n(Kr,{children:g("colorPicker.colors")}),$n(ox,{color:e,palette:r,onChange:o,activeShade:f})]}),As("div",{children:[$n(Kr,{children:g("colorPicker.shades")}),$n(rx,{color:e,onChange:o,palette:r})]}),a]})})});import x6 from"clsx";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as E6,DEFAULT_CANVAS_BACKGROUND_PICKS as y6,DEFAULT_ELEMENT_BACKGROUND_PICKS as w6,DEFAULT_ELEMENT_STROKE_PICKS as v6}from"@excalidraw/common";import{jsx as Pp}from"react/jsx-runtime";var sx=({onChange:e,type:o,activeColor:t,topPicks:n})=>{let r;return o==="elementStroke"&&(r=v6),o==="elementBackground"&&(r=w6),o==="canvasBackground"&&(r=y6),n&&(r=n),r?Pp("div",{className:"color-picker__top-picks",children:r.map(i=>Pp("button",{className:x6("color-picker__button",{active:i===t,"is-transparent":i==="transparent"||!i,"has-outline":!sn(i,E6)}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:Pp("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};import{jsx as Lt,jsxs as Ds}from"react/jsx-runtime";var cx=e=>{let o=new Option().style;return o.color=e,!!o.color},ex=e=>I6(e)?e:cx(`#${e}`)?`#${e}`:cx(e)?e:null,C6=({type:e,color:o,onChange:t,label:n,elements:r,palette:i=px,updateData:a,getOpenPopup:l,appState:s})=>{let{container:m}=Ne(),[,d]=le(Gt),[c,p]=le(rn),u=Ds("div",{children:[Lt(Kr,{children:g("colorPicker.hexCode")}),Lt(Qb,{color:o||"",label:n,onChange:x=>{t(x)},colorPickerType:e,placeholder:g("colorPicker.color")})]}),f=mx(null),b=()=>{f.current?.focus()};return Lt(_o,{container:m,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!s.editingTextElement,onFocusOutside:x=>{b(),x.preventDefault()},onPointerDownOutside:x=>{c&&x.preventDefault()},onClose:()=>{l()===e&&a({openPopup:null}),d(null),s.editingTextElement&&setTimeout(()=>{let x=document.querySelector(".excalidraw-wysiwyg");x&&x.focus()},0)},children:i?Lt(lx,{ref:f,palette:i,color:o,onChange:x=>{let y=s.editingTextElement?Ps():null;t(x),s.editingTextElement&&y&&ba(y)},onEyeDropperToggle:x=>{p(y=>x?(y=y||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},y.keepOpenOnAlt=!0,y):x===!1||y?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:x=>{c?p(null):a({openPopup:null})},type:e,elements:r,updateData:a,children:u}):u})},S6=({label:e,color:o,type:t,compactMode:n=!1,mode:r="background",onToggle:i,editingTextElement:a})=>{let l=s=>{s.preventDefault(),s.stopPropagation(),a&&Zb(),i()};return Ds(_s.Trigger,{type:"button",className:dx("color-picker__button active-color properties-trigger",{"is-transparent":!o||o==="transparent","has-outline":!o||!sn(o,Lp)}),"aria-label":e,style:o?{"--swatch-color":o}:void 0,title:t==="elementStroke"?g("labels.showStroke"):g("labels.showBackground"),"data-openpopup":t,onClick:l,children:[Lt("div",{className:"color-picker__button-outline",children:!o&&m0}),n&&o&&Lt("div",{className:"color-picker__button-background",children:r==="background"?Lt("span",{style:{color:o&&sn(o,Lp)?"#fff":"#111"},children:Ab}):Lt("span",{style:{color:o&&sn(o,Lp)?"#fff":"#111"},children:Db})})]})},va=({type:e,color:o,onChange:t,label:n,elements:r,palette:i=px,topPicks:a,updateData:l,appState:s,compactMode:m=!1})=>{let d=mx(s.openPopup);return T6(()=>{d.current=s.openPopup},[s.openPopup]),Lt("div",{children:Ds("div",{role:"dialog","aria-modal":"true",className:dx("color-picker-container",{"color-picker-container--no-top-picks":m}),children:[!m&&Lt(sx,{activeColor:o,onChange:t,type:e,topPicks:a}),!m&&Lt(Cs,{}),Ds(_s.Root,{open:s.openPopup===e,onOpenChange:c=>{c&&l({openPopup:e})},children:[Lt(S6,{color:o,label:n,type:e,compactMode:m,mode:e==="elementStroke"?"stroke":"background",editingTextElement:!!s.editingTextElement,onToggle:()=>{s.openPopup===e?l({openPopup:null}):s.openPopup?l({openPopup:e}):l({openPopup:e})}}),s.openPopup===e&&Lt(C6,{type:e,color:o,onChange:t,label:n,elements:r,palette:i,updateData:l,getOpenPopup:()=>d.current,appState:s})]})]})})};import*as vx from"@radix-ui/react-popover";import e4 from"clsx";import t4,{useCallback as o4,useMemo as n4}from"react";import{FONT_FAMILY as Np}from"@excalidraw/common";import X6,{useMemo as cn,useState as K6,useRef as Z6,useEffect as $6,useCallback as fx}from"react";import{arrayToList as j6,debounce as q6,FONT_FAMILY as jn,getFontFamilyString as J6}from"@excalidraw/common";import k6 from"clsx";import M6 from"react";import{jsx as P6,jsxs as L6}from"react/jsx-runtime";var Rs=M6.forwardRef(({className:e,placeholder:o,onChange:t},n)=>L6("div",{className:k6("QuickSearch__wrapper",e),children:[Pt,P6("input",{ref:n,className:"QuickSearch__input",type:"text",placeholder:o,onChange:r=>t(r.target.value.trim().toLowerCase())})]}));import A6 from"clsx";import{Children as D6}from"react";import{jsx as ux}from"react/jsx-runtime";var Ns=({className:e,placeholder:o,children:t})=>{let n=!D6.count(t);return ux("div",{className:A6("ScrollableList__wrapper",e),role:"menu",children:n?ux("div",{className:"empty",children:o}):t})};import{jsx as _6,jsxs as R6}from"react/jsx-runtime";var hx=({children:e,className:o="",style:t,title:n})=>R6("div",{className:`dropdown-menu-group ${o}`,style:t,children:[n&&_6("p",{className:"dropdown-menu-group-title",children:n}),e]}),Ta=hx;hx.displayName="DropdownMenuGroup";import{useEffect as Y6,useRef as W6}from"react";import{THEME as V6}from"@excalidraw/common";import{jsx as N6}from"react/jsx-runtime";var Ia=({children:e,...o})=>N6("span",{...o,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...o.style},children:e});import{Fragment as F6,jsx as Bs,jsxs as O6}from"react/jsx-runtime";var B6=({textStyle:e,icon:o,shortcut:t,children:n})=>{let r=de();return O6(F6,{children:[o&&Bs("div",{className:"dropdown-menu-item__icon",children:o}),Bs("div",{style:e,className:"dropdown-menu-item__text",children:Bs(Ia,{children:n})}),t&&!r.editor.isMobile&&Bs("div",{className:"dropdown-menu-item__shortcut",children:t})]})},Fs=B6;import z6,{useContext as H6}from"react";import{EVENT as G6,composeEventHandlers as U6}from"@excalidraw/common";var Ap=z6.createContext({}),Os=(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(),zs=(e,o)=>{let t=H6(Ap);return U6(e,n=>{let r=new CustomEvent(G6.MENU_ITEM_SELECT,{bubbles:!0,cancelable:!0});o?.(r),r.defaultPrevented||t.onSelect?.(r)})};import{jsx as Dp}from"react/jsx-runtime";var _p=({icon:e,value:o,order:t,children:n,shortcut:r,className:i,hovered:a,selected:l,textStyle:s,onSelect:m,onClick:d,...c})=>{let p=zs(d,m),u=W6(null);return Y6(()=>{a&&(t===0?u.current?.scrollIntoView({block:"end"}):u.current?.scrollIntoView({block:"nearest"}))},[a,t]),Dp("button",{...c,ref:u,value:o,onClick:p,className:Os(i,l,a),title:c.title??c["aria-label"],children:Dp(Fs,{textStyle:s,icon:e,shortcut:r,children:n})})};_p.displayName="DropdownMenuItem";var $r={GREEN:"green",RED:"red",BLUE:"blue"},Hs=({type:e=$r.BLUE,children:o})=>{let{theme:t}=bo(),n={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===V6.LIGHT?"1.5px solid white":"none"};switch(e){case $r.GREEN:Object.assign(n,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case $r.RED:Object.assign(n,{backgroundColor:"pink",color:"darkred"});break;case $r.BLUE:default:Object.assign(n,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return Dp("div",{className:"DropDownMenuItemBadge",style:n,children:o})};Hs.displayName="DropdownMenuItemBadge";_p.Badge=Hs;var pt=_p;import{KEYS as jr}from"@excalidraw/common";var gx=({event:e,inputRef:o,hoveredFont:t,filteredFonts:n,onClose:r,onSelect:i,onHover:a})=>{if(!e[jr.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===jr.F)return o.current?.focus(),!0;if(e.key===jr.ESCAPE)return r(),!0;if(e.key===jr.ENTER)return t?.value&&i(t.value),!0;if(e.key===jr.ARROW_DOWN)return t?.next?a(t.next.value):n[0]?.value&&a(n[0].value),!0;if(e.key===jr.ARROW_UP)return t?.prev?a(t.prev.value):n[n.length-1]?.value&&a(n[n.length-1].value),!0};import{jsx as Ca,jsxs as bx}from"react/jsx-runtime";var Q6=e=>{switch(e){case jn.Excalifont:case jn.Virgil:return tn;case jn.Nunito:case jn.Helvetica:return ma;case jn["Lilita One"]:return $0;case jn["Comic Shanns"]:case jn.Cascadia:return ds;default:return ma}},xx=X6.memo(({selectedFontFamily:e,hoveredFontFamily:o,onSelect:t,onHover:n,onLeave:r,onOpen:i,onClose:a})=>{let{container:l}=Ne(),s=Be(),{fonts:m}=s,{showDeprecatedFonts:d}=xo(),[c,p]=K6(""),u=Z6(null),f=cn(()=>Array.from(Jo.registered.entries()).filter(([k,{metadata:A}])=>!A.private&&!A.fallback).map(([k,{metadata:A,fontFaces:F}])=>{let Y={value:k,icon:Q6(k),text:F[0]?.fontFace?.family??"Unknown"};return A.deprecated&&Object.assign(Y,{deprecated:A.deprecated,badge:{type:$r.RED,placeholder:g("fontList.badge.old")}}),Y}).sort((k,A)=>k.text.toLowerCase()>A.text.toLowerCase()?1:-1),[]),b=cn(()=>new Set(m.getSceneFamilies()),[e]),x=cn(()=>f.filter(k=>b.has(k.value)),[f,b]),y=cn(()=>f.filter(k=>!b.has(k.value)&&(d||!k.deprecated)),[f,b,d]),E=cn(()=>j6([...x,...y].filter(k=>k.text?.toLowerCase().includes(c))),[x,y,c]),w=cn(()=>{let k;return o?k=E.find(A=>A.value===o):e&&(k=E.find(A=>A.value===e)),!k&&c&&(E[0]?.value?n(E[0].value):r()),k},[o,e,c,E,n,r]),v=fx(k=>{let A=null;if(s.state.editingTextElement){let F=document.querySelector(".excalidraw-wysiwyg");F&&(A={start:F.selectionStart,end:F.selectionEnd})}t(k),s.state.editingTextElement&&A&&setTimeout(()=>{let F=document.querySelector(".excalidraw-wysiwyg");F&&A&&(F.focus(),F.selectionStart=A.start,F.selectionEnd=A.end)},0)},[t,s.state.editingTextElement]),C=fx(k=>{gx({event:k,inputRef:u,hoveredFont:w,filteredFonts:E,onSelect:v,onHover:n,onClose:a})&&(k.preventDefault(),k.stopPropagation())},[w,E,v,n,a]);$6(()=>(i(),()=>{a()}),[]);let S=cn(()=>E.filter(k=>b.has(k.value)),[E,b]),L=cn(()=>E.filter(k=>!b.has(k.value)),[E,b]),P=(k,A)=>bx(pt,{icon:k.icon,value:k.value,order:A,textStyle:{fontFamily:J6({fontFamily:k.value})},hovered:k.value===w?.value,selected:k.value===e,tabIndex:k.value===e?0:-1,onClick:F=>{v(Number(F.currentTarget.value))},onMouseMove:()=>{w?.value!==k.value&&n(k.value)},children:[k.text,k.badge&&Ca(Hs,{type:k.badge.type,children:k.badge.placeholder})]},k.value),B=[];return S.length&&B.push(Ca(Ta,{title:g("fontList.sceneFonts"),children:S.map(P)},"group_1")),L.length&&B.push(Ca(Ta,{title:g("fontList.availableFonts"),children:L.map((k,A)=>P(k,A+S.length))},"group_2")),bx(_o,{className:"properties-content",container:l,style:{width:"15rem"},onClose:()=>{a(),s.state.editingTextElement&&setTimeout(()=>{let k=document.querySelector(".excalidraw-wysiwyg");k&&k.focus()},0)},onPointerLeave:r,onKeyDown:C,preventAutoFocusOnTouch:!!s.state.editingTextElement,children:[Ca(Rs,{ref:u,placeholder:g("quickSearch.placeholder"),onChange:q6(p,20)}),Ca(Ns,{className:"dropdown-menu fonts manual-hover",placeholder:g("fontList.empty"),children:B.length?B:null})]})},(e,o)=>e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as Ex from"@radix-ui/react-popover";import{jsx as Rp}from"react/jsx-runtime";var yx=({selectedFontFamily:e,isOpened:o=!1})=>{let t=ae();return Rp(Ex.Trigger,{asChild:!0,children:Rp("div",{"data-openpopup":"fontFamily",className:"properties-trigger",children:Rp(Yr,{standalone:!0,icon:Ar,title:g("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:o,onClick:()=>{t(n=>({openPopup:n.openPopup==="fontFamily"?null:n.openPopup}))},style:{border:"none"}})})})};import{jsx as Sa,jsxs as wx}from"react/jsx-runtime";var Tx=[{value:Np.Excalifont,icon:tn,text:g("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:Np.Nunito,icon:ma,text:g("labels.normal"),testId:"font-family-normal"},{value:Np["Comic Shanns"],icon:ds,text:g("labels.code"),testId:"font-family-code"}],b$=new Set(Tx.map(e=>e.value));var Ix=t4.memo(({isOpened:e,selectedFontFamily:o,hoveredFontFamily:t,onSelect:n,onHover:r,onLeave:i,onPopupChange:a,compactMode:l=!1})=>{let s=n4(()=>Tx,[]),m=o4(d=>{d&&n(d)},[n]);return wx("div",{role:"dialog","aria-modal":"true",className:e4("FontPicker__container",{"FontPicker__container--compact":l}),children:[!l&&Sa("div",{className:"buttonList",children:Sa(Ht,{type:"button",options:s,value:o,onClick:m})}),!l&&Sa(Cs,{}),wx(vx.Root,{open:e,onOpenChange:a,children:[Sa(yx,{selectedFontFamily:o,isOpened:e}),e&&Sa(xx,{selectedFontFamily:o,hoveredFontFamily:t,onSelect:m,onHover:r,onLeave:i,onOpen:()=>a(!0),onClose:()=>a(!1)})]})]})},(e,o)=>e.isOpened===o.isOpened&&e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as qr from"@radix-ui/react-popover";import l4 from"clsx";import Gs,{useEffect as s4}from"react";import{isArrowKey as c4,KEYS as Ro}from"@excalidraw/common";import{jsx as r4}from"react/jsx-runtime";var dn=({icon:e})=>r4("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 a4,jsx as Cx,jsxs as Sx}from"react/jsx-runtime";var i4=({label:e,open:o,openTrigger:t,children:n,className:r,showCollapsedIcon:i=!0})=>Sx(a4,{children:[Sx("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:r,onClick:t,children:[e,i&&Cx(dn,{icon:o?Mb:fs})]}),o&&Cx("div",{style:{display:"flex",flexDirection:"column"},children:n})]}),ka=i4;import{jsx as qn,jsxs as Bp}from"react/jsx-runtime";var d4=he(!1);function m4({options:e,value:o,label:t,onChange:n,onClose:r,numberOfOptionsToAlwaysShow:i=e.length}){let a=de(),l=u=>{let f=e.find(b=>b.keyBinding===u.key.toLowerCase());if(!(u.metaKey||u.altKey||u.ctrlKey)&&f)n(f.value),u.preventDefault();else if(u.key===Ro.TAB){let b=e.findIndex(y=>y.value===o),x=u.shiftKey?(e.length+b-1)%e.length:(b+1)%e.length;n(e[x].value)}else if(c4(u.key)){let b=Do().rtl,x=e.findIndex(y=>y.value===o);if(x!==-1){let y=e.length,E=x;switch(u.key){case(b?Ro.ARROW_LEFT:Ro.ARROW_RIGHT):E=(x+1)%y;break;case(b?Ro.ARROW_RIGHT:Ro.ARROW_LEFT):E=(y+x-1)%y;break;case Ro.ARROW_DOWN:{E=(x+(i??1))%y;break}case Ro.ARROW_UP:{E=(y+x-(i??1))%y;break}}n(e[E].value)}u.preventDefault()}else(u.key===Ro.ESCAPE||u.key===Ro.ENTER)&&(u.preventDefault(),r());u.nativeEvent.stopImmediatePropagation(),u.stopPropagation()},[s,m]=le(d4),d=Gs.useMemo(()=>e.slice(0,i),[e,i]),c=Gs.useMemo(()=>e.slice(i),[e,i]);s4(()=>{d.some(u=>u.value===o)||m(!0)},[o,d,m]);let p=u=>qn("div",{className:"picker-content",children:u.map((f,b)=>Bp("button",{type:"button",className:l4("picker-option",{active:o===f.value}),onClick:x=>{n(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&&qn("span",{className:"picker-keybinding",children:f.keyBinding})]},f.text))});return qn(qr.Content,{side:a.editor.isMobile&&!a.viewport.isLandscape?"top":"bottom",align:"start",sideOffset:12,style:{zIndex:"var(--zIndex-popup)"},onKeyDown:l,children:Bp("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":t,children:[p(d),c.length>0&&qn(ka,{label:g("labels.more_options"),open:s,openTrigger:()=>{m(u=>!u)},className:"picker-collapsible",children:p(c)})]})})}function Fp({value:e,label:o,options:t,onChange:n,group:r="",numberOfOptionsToAlwaysShow:i}){let[a,l]=Gs.useState(!1),s=Gs.useRef(null);return qn("div",{children:Bp(qr.Root,{open:a,onOpenChange:m=>l(m),children:[qn(qr.Trigger,{name:r,type:"button","aria-label":o,onClick:()=>l(!a),ref:s,className:a?"active":"",children:t.find(m=>m.value===e)?.icon}),a&&qn(m4,{options:t,value:e,label:o,onChange:n,onClose:()=>{l(!1)},numberOfOptionsToAlwaysShow:i})]})})}import kx,{useEffect as p4}from"react";import{jsx as Op,jsxs as Mx}from"react/jsx-runtime";var Px=({updateData:e,app:o,testId:t})=>{let n=kx.useRef(null),r=kx.useRef(null),i=o.scene.getSelectedElements(o.state),a=!0,l=i.at(0),m=i.reduce((d,c)=>(d!=null&&d!==c.opacity&&(a=!1),d==null||d>c.opacity?c.opacity:d),l?.opacity??null)??o.state.currentItemOpacity;return p4(()=>{if(n.current&&r.current){let d=n.current,c=r.current,p=d.offsetWidth,u=15,f=m/100*(p-u)+u/2;c.style.left=`${f}px`,d.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${m}%, var(--button-bg) ${m}%, var(--button-bg) 100%)`}},[m]),Mx("label",{className:"control-label",children:[g("labels.opacity"),Mx("div",{className:"range-wrapper",children:[Op("input",{style:{"--color-slider-track":a?void 0:"var(--button-bg)"},ref:n,type:"range",min:"0",max:"100",step:"10",onChange:d=>{e(+d.target.value)},value:m,className:"range-input","data-testid":t}),Op("div",{className:"value-bubble",ref:r,children:m!==0?m:null}),Op("div",{className:"zero-label",children:"0"})]})]})};import{Fragment as Fx,jsx as ee,jsxs as ht}from"react/jsx-runtime";var Bx=.1,ut=(e,o,t,n=!1)=>{let r=Wp(j(e,o,{includeBoundTextElement:n}));return e.map(i=>r.get(i.id)||i.id===o.editingTextElement?.id?t(i):i)},at=function(e,o,t,n,r){let i=o.state.editingTextElement,a=Rx(e),l=null;if(i&&(l=t(i)),!l)if(we(a,o.state)){let m=o.scene.getSelectedElements(o.state),d=n===!0?m:m.filter(c=>n(c));l=M4(d,t)??(typeof r=="function"?r(!0):r)}else l=typeof r=="function"?r(!1):r;return l},B4=(e,o,t)=>A4(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}),Vp=(e,o,t,n,r)=>{let i=new Set,a=ut(e,o,l=>{if(wt(l)){let s=n(l);i.add(s);let m=Ze(l,{fontSize:s});return Ma(m,t.scene.getContainerElement(l),t.scene),m=B4(l,m,t.scene),m}return l},!0);return j(e,o,{includeBoundTextElement:!0}).forEach(l=>{wt(l)&&L4(l,t.scene)}),{elements:a,appState:{...o,currentItemFontSize:i.size===1?[...i][0]:r??o.currentItemFontSize},captureUpdate:$e.IMMEDIATELY}},F4=N({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,o,t)=>({...t.currentItemStrokeColor&&{elements:ut(e,o,n=>_4(n.type)?Ze(n,{strokeColor:t.currentItemStrokeColor}):n,!0)},appState:{...o,...t},captureUpdate:t.currentItemStrokeColor?$e.IMMEDIATELY:$e.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>ht(Fx,{children:[o.stylesPanelMode==="full"&&ee("h3",{"aria-hidden":"true",children:g("labels.stroke")}),ee(va,{topPicks:E4,palette:x4,type:"elementStroke",label:g("labels.stroke"),color:at(e,n,i=>i.strokeColor,!0,i=>i?null:o.currentItemStrokeColor),onChange:i=>t({currentItemStrokeColor:i}),elements:e,appState:o,updateData:t,compactMode:o.stylesPanelMode==="compact"})]})}),O4=N({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,o,t,n)=>{if(!t.currentItemBackgroundColor)return{appState:{...o,...t},captureUpdate:$e.EVENTUALLY};let r,i=n.scene.getSelectedElements(o);if(!k4(t.currentItemBackgroundColor)&&i.every(l=>Dx(l)&&P4(l.points))){let l=Wp(i);r=e.map(s=>l.has(s.id)&&Dx(s)?Ze(s,{backgroundColor:t.currentItemBackgroundColor,...N4(s,!0)}):s)}else r=ut(e,o,l=>Ze(l,{backgroundColor:t.currentItemBackgroundColor}));return{elements:r,appState:{...o,...t},captureUpdate:$e.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>ht(Fx,{children:[o.stylesPanelMode==="full"&&ee("h3",{"aria-hidden":"true",children:g("labels.background")}),ee(va,{topPicks:b4,palette:f4,type:"elementBackground",label:g("labels.background"),color:at(e,n,i=>i.backgroundColor,!0,i=>i?null:o.currentItemBackgroundColor),onChange:i=>t({currentItemBackgroundColor:i}),elements:e,appState:o,updateData:t,compactMode:o.stylesPanelMode==="compact"})]})}),z4=N({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,o,t,n)=>(re("element","changeFillStyle",`${t} (${n.device.editor.isMobile?"mobile":"desktop"})`),{elements:ut(e,o,r=>Ze(r,{fillStyle:t})),appState:{...o,currentItemFillStyle:t},captureUpdate:$e.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=j(e,o),i=r.length>0&&r.every(a=>a.fillStyle==="zigzag");return ht("fieldset",{children:[ee("legend",{children:g("labels.fill")}),ee("div",{className:"buttonList",children:ee(Ht,{type:"button",options:[{value:"hachure",text:`${i?g("labels.zigzag"):g("labels.hachure")} (${C4("Alt-Click")})`,icon:i?y0:w0,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:g("labels.crossHatch"),icon:v0,testId:"fill-cross-hatch"},{value:"solid",text:g("labels.solid"),icon:T0,testId:"fill-solid"}],value:at(e,n,a=>a.fillStyle,a=>a.hasOwnProperty("fillStyle"),a=>a?null:o.currentItemFillStyle),onClick:(a,l)=>{let s=l.altKey&&a==="hachure"&&r.every(m=>m.fillStyle==="hachure")?"zigzag":a;t(s)}})})]})}}),H4=N({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,n=>Ze(n,{strokeWidth:t})),appState:{...o,currentItemStrokeWidth:t},captureUpdate:$e.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>ht("fieldset",{children:[o.stylesPanelMode==="full"&&ee("legend",{children:g("labels.strokeWidth")}),ee("div",{className:"buttonList",children:ee(Ht,{group:"stroke-width",options:[{value:Gp.thin,text:g("labels.thin"),icon:op,testId:"strokeWidth-thin"},{value:Gp.bold,text:g("labels.bold"),icon:I0,testId:"strokeWidth-bold"},{value:Gp.extraBold,text:g("labels.extraBold"),icon:C0,testId:"strokeWidth-extraBold"}],value:at(e,n,i=>i.strokeWidth,i=>i.hasOwnProperty("strokeWidth"),i=>i?null:o.currentItemStrokeWidth),onChange:i=>t(i)})})]})}),G4=N({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,n=>Ze(n,{seed:T4(),roughness:t})),appState:{...o,currentItemRoughness:t},captureUpdate:$e.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>ht("fieldset",{children:[o.stylesPanelMode==="full"&&ee("legend",{children:g("labels.sloppiness")}),ee("div",{className:"buttonList",children:ee(Ht,{group:"sloppiness",options:[{value:0,text:g("labels.architect"),icon:M0},{value:1,text:g("labels.artist"),icon:P0},{value:2,text:g("labels.cartoonist"),icon:L0}],value:at(e,n,i=>i.roughness,i=>i.hasOwnProperty("roughness"),i=>i?null:o.currentItemRoughness),onChange:i=>t(i)})})]})}),Ej=N({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,n=>Ze(n,{strokeStyle:t})),appState:{...o,currentItemStrokeStyle:t},captureUpdate:$e.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>ht("fieldset",{children:[o.stylesPanelMode==="full"&&ee("legend",{children:g("labels.strokeStyle")}),ee("div",{className:"buttonList",children:ee(Ht,{group:"strokeStyle",options:[{value:"solid",text:g("labels.strokeStyle_solid"),icon:op},{value:"dashed",text:g("labels.strokeStyle_dashed"),icon:S0},{value:"dotted",text:g("labels.strokeStyle_dotted"),icon:k0}],value:at(e,n,i=>i.strokeStyle,i=>i.hasOwnProperty("strokeStyle"),i=>i?null:o.currentItemStrokeStyle),onChange:i=>t(i)})})]})}),U4=N({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,n=>Ze(n,{opacity:t}),!0),appState:{...o,currentItemOpacity:t},captureUpdate:$e.IMMEDIATELY}),PanelComponent:({app:e,updateData:o})=>ee(Px,{updateData:o,app:e,testId:"opacity"})}),Y4=N({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,o,t,n)=>Vp(e,o,n,()=>t,t),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>ht("fieldset",{children:[ee("legend",{children:g("labels.fontSize")}),ee("div",{className:"buttonList",children:ee(Ht,{group:"font-size",options:[{value:16,text:g("labels.small"),icon:V0,testId:"fontSize-small"},{value:20,text:g("labels.medium"),icon:X0,testId:"fontSize-medium"},{value:28,text:g("labels.large"),icon:K0,testId:"fontSize-large"},{value:36,text:g("labels.veryLarge"),icon:Z0,testId:"fontSize-veryLarge"}],value:at(e,n,i=>{if(wt(i))return i.fontSize;let a=mn(i,n.scene.getNonDeletedElementsMap());return a?a.fontSize:null},i=>wt(i)||mn(i,n.scene.getNonDeletedElementsMap())!==null,i=>i?null:o.currentItemFontSize||w4),onChange:i=>{xa(()=>t(i),o.stylesPanelMode==="compact",!!o.editingTextElement,r?.onPreventClose)}})})]})}),Xp=N({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:Kn,trackEvent:!1,perform:(e,o,t,n)=>Vp(e,o,n,r=>Math.round(1/(1+Bx)*r.fontSize)),keyTest:e=>e[Jr.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Jr.CHEVRON_LEFT||e.key===Jr.COMMA)}),Kp=N({name:"increaseFontSize",label:"labels.increaseFontSize",icon:Kn,trackEvent:!1,perform:(e,o,t,n)=>Vp(e,o,n,r=>Math.round(r.fontSize*(1+Bx))),keyTest:e=>e[Jr.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Jr.CHEVRON_RIGHT||e.key===Jr.PERIOD)}),W4=N({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,o,t,n)=>{let{cachedElements:r,resetAll:i,resetContainers:a,...l}=t;if(i)return{elements:ut(e,o,b=>{let x=r?.get(b.id);return x?Ze(b,{...x}):b},!0),appState:{...o,...l},captureUpdate:$e.NEVER};let{currentItemFontFamily:s,currentHoveredFontFamily:m}=t,d=$e.EVENTUALLY,c,p=!1;if(s)c=s,d=$e.IMMEDIATELY;else if(m){c=m,d=$e.EVENTUALLY;let f=j(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 y=f[b];x+=y?.originalText.length||0,b++}x>5e3&&(p=!0)}}let u={appState:{...o,...l},captureUpdate:d};if(c&&!p){let f=new Map,b=new Set,x=!1,y=Array.from(Jo.loadedFontsCache.values()),E=Object.entries(v4).find(([C,S])=>S===c)?.[0];m&&E&&y.some(C=>C.startsWith(E))&&(x=!0),Object.assign(u,{elements:ut(e,o,C=>{if(wt(C)&&(C.fontFamily!==c||s)){let S=Ze(C,{fontFamily:c,lineHeight:S4(c)}),L=r?.get(C.containerId||"")||{},P=n.scene.getContainerElement(C);return a&&P&&L&&n.scene.mutateElement(P,{...L}),x||(b=new Set([...b,...Array.from(S.originalText)])),f.set(S,P),S}return C},!0)});let w=`10px ${I4({fontFamily:c})}`,v=Array.from(b.values()).join();if(x||window.document.fonts.check(w,v))for(let[C,S]of f)Ma(C,S,n.scene);else window.document.fonts.load(w,v).then(C=>{for(let[S,L]of f){let P=n.scene.getElement(S.id),B=L?n.scene.getElement(L.id):null;P&&Ma(P,B,n.scene)}n.fonts.onLoaded(C)})}return u},PanelComponent:({elements:e,appState:o,app:t,updateData:n,data:r})=>{let i=Hp(new Map),a=Hp(null),[l,s]=g4({}),m=Hp(!0),d=h4(()=>{let c=(p,u)=>at(p,t,f=>{if(wt(f))return f.fontFamily;let b=mn(f,u);return b?b.fontFamily:null},f=>wt(f)||mn(f,u)!==null,f=>f?null:o.currentItemFontFamily||y4);return l.openPopup==="fontFamily"&&o.openPopup==="fontFamily"?c(Array.from(i.current?.values()??[]),i.current):!l.openPopup&&o.openPopup!=="fontFamily"?c(e,t.scene.getNonDeletedElementsMap()):a.current},[l.openPopup,o,e,t]);return zp(()=>{a.current=d},[d]),zp(()=>{Object.keys(l).length&&(n(l),s({}))},[l]),zp(()=>(m.current=!1,()=>{m.current=!0}),[]),ht("fieldset",{children:[o.stylesPanelMode==="full"&&ee("legend",{children:g("labels.fontFamily")}),ee(Ix,{isOpened:o.openPopup==="fontFamily",selectedFontFamily:d,hoveredFontFamily:o.currentHoveredFontFamily,compactMode:o.stylesPanelMode==="compact",onSelect:c=>{xa(()=>{s({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:c}),i.current.clear()},o.stylesPanelMode==="compact",!!o.editingTextElement)},onHover:c=>{s({currentHoveredFontFamily:c,cachedElements:new Map(i.current),resetContainers:!0})},onLeave:()=>{s({currentHoveredFontFamily:null,cachedElements:new Map(i.current),resetAll:!0})},onPopupChange:c=>{if(c){i.current.clear();let{editingTextElement:p}=o;if(p?.type==="text"){let u=t.scene.getElement(p.id);i.current.set(p.id,Ze(u||p,{},!0))}else{let u=j(e,o,{includeBoundTextElement:!0});for(let f of u)i.current.set(f.id,Ze(f,{},!0))}s({...l,openPopup:"fontFamily"})}else{let p={currentHoveredFontFamily:null,cachedElements:new Map(i.current),resetAll:!0};s({...p}),i.current.clear(),o.stylesPanelMode==="compact"&&o.editingTextElement&&ba(null)}}})]})}}),V4=N({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,o,t,n)=>({elements:ut(e,o,r=>{if(wt(r)){let i=Ze(r,{textAlign:t});return Ma(i,n.scene.getContainerElement(r),n.scene),i}return r},!0),appState:{...o,currentItemTextAlign:t},captureUpdate:$e.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let i=n.scene.getNonDeletedElementsMap();return ht("fieldset",{children:[ee("legend",{children:g("labels.textAlign")}),ee("div",{className:"buttonList",children:ee(Ht,{group:"text-align",options:[{value:"left",text:g("labels.left"),icon:j0,testId:"align-left"},{value:"center",text:g("labels.center"),icon:q0,testId:"align-horizontal-center"},{value:"right",text:g("labels.right"),icon:J0,testId:"align-right"}],value:at(e,n,a=>{if(wt(a))return a.textAlign;let l=mn(a,i);return l?l.textAlign:null},a=>wt(a)||mn(a,i)!==null,a=>a?null:o.currentItemTextAlign),onChange:a=>{xa(()=>t(a),o.stylesPanelMode==="compact",!!o.editingTextElement,r?.onPreventClose)}})})]})}}),X4=N({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:ut(e,o,r=>{if(wt(r)){let i=Ze(r,{verticalAlign:t});return Ma(i,n.scene.getContainerElement(r),n.scene),i}return r},!0),appState:{...o},captureUpdate:$e.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>ee("fieldset",{children:ee("div",{className:"buttonList",children:ee(Ht,{group:"text-align",options:[{value:Us.TOP,text:g("labels.alignTop"),icon:ee(Q0,{theme:o.theme}),testId:"align-top"},{value:Us.MIDDLE,text:g("labels.centerVertically"),icon:ee(tb,{theme:o.theme}),testId:"align-middle"},{value:Us.BOTTOM,text:g("labels.alignBottom"),icon:ee(eb,{theme:o.theme}),testId:"align-bottom"}],value:at(e,n,i=>{if(wt(i)&&i.containerId)return i.verticalAlign;let a=mn(i,n.scene.getNonDeletedElementsMap());return a?a.verticalAlign:null},i=>wt(i)||mn(i,n.scene.getNonDeletedElementsMap())!==null,i=>i?null:Us.MIDDLE),onChange:i=>{xa(()=>t(i),o.stylesPanelMode==="compact",!!o.editingTextElement,r?.onPreventClose)}})})})}),yj=N({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,n=>Nx(n)?n:Ze(n,{roundness:t==="round"?{type:D4(n.type)?Ys.ADAPTIVE_RADIUS:Ys.PROPORTIONAL_RADIUS}:null})),appState:{...o,currentItemRoundness:t},captureUpdate:$e.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,renderAction:r})=>{let a=ea(Rx(e),o).some(l=>l.roundness?.type===Ys.LEGACY);return ht("fieldset",{children:[ee("legend",{children:g("labels.edges")}),ht("div",{className:"buttonList",children:[ee(Ht,{group:"edges",options:[{value:"sharp",text:g("labels.sharp"),icon:A0},{value:"round",text:g("labels.round"),icon:D0}],value:at(e,n,l=>a?null:l.roundness?"round":"sharp",l=>!Ws(l)&&l.hasOwnProperty("roundness"),l=>l?null:o.currentItemRoundness),onChange:l=>t(l)}),r("togglePolygon")]})]})}}),_x=e=>[{value:null,text:g("labels.arrowhead_none"),keyBinding:"q",icon:_0},{value:"arrow",text:g("labels.arrowhead_arrow"),keyBinding:"w",icon:ee(R0,{flip:e})},{value:"triangle",text:g("labels.arrowhead_triangle"),icon:ee(O0,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:g("labels.arrowhead_triangle_outline"),icon:ee(z0,{flip:e}),keyBinding:"r"},{value:"circle",text:g("labels.arrowhead_circle"),keyBinding:"a",icon:ee(N0,{flip:e})},{value:"circle_outline",text:g("labels.arrowhead_circle_outline"),keyBinding:"s",icon:ee(B0,{flip:e})},{value:"diamond",text:g("labels.arrowhead_diamond"),icon:ee(H0,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:g("labels.arrowhead_diamond_outline"),icon:ee(G0,{flip:e}),keyBinding:"f"},{value:"bar",text:g("labels.arrowhead_bar"),keyBinding:"z",icon:ee(F0,{flip:e})},{value:"crowfoot_one",text:g("labels.arrowhead_crowfoot_one"),icon:ee(Y0,{flip:e}),keyBinding:"x"},{value:"crowfoot_many",text:g("labels.arrowhead_crowfoot_many"),icon:ee(U0,{flip:e}),keyBinding:"c"},{value:"crowfoot_one_or_many",text:g("labels.arrowhead_crowfoot_one_or_many"),icon:ee(W0,{flip:e}),keyBinding:"v"}],wj=N({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,n=>{if(Yp(n)){let{position:r,type:i}=t;if(r==="start")return Ze(n,{startArrowhead:i});if(r==="end")return Ze(n,{endArrowhead:i})}return n}),appState:{...o,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:$e.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=Do().rtl;return ht("fieldset",{children:[ee("legend",{children:g("labels.arrowheads")}),ht("div",{className:"iconSelectList buttonList",children:[ee(Fp,{label:"arrowhead_start",options:_x(!r),value:at(e,n,i=>Yp(i)&&vr(i.type)?i.startArrowhead:o.currentItemStartArrowhead,!0,o.currentItemStartArrowhead),onChange:i=>t({position:"start",type:i}),numberOfOptionsToAlwaysShow:4}),ee(Fp,{label:"arrowhead_end",group:"arrowheads",options:_x(!!r),value:at(e,n,i=>Yp(i)&&vr(i.type)?i.endArrowhead:o.currentItemEndArrowhead,!0,o.currentItemEndArrowhead),onChange:i=>t({position:"end",type:i}),numberOfOptionsToAlwaysShow:4})]})]})}}),K4=N({name:"changeArrowProperties",label:"Change arrow properties",trackEvent:!1,perform:(e,o,t,n)=>!1,PanelComponent:({elements:e,appState:o,updateData:t,app:n,renderAction:r})=>ht("div",{className:"selected-shape-actions",children:[r("changeArrowType"),r("changeArrowhead")]})}),vj=N({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,o,t,n)=>{let r=ut(e,o,l=>{if(!Ws(l))return l;let s=Ze(l,{roundness:t===No.round?{type:Ys.PROPORTIONAL_RADIUS}:null,elbowed:t===No.elbow,points:t===No.elbow||l.elbowed?[l.points[0],l.points[l.points.length-1]]:l.points});if(Nx(s)){s.fixedSegments=null;let m=n.scene.getNonDeletedElementsMap();n.dismissLinearEditor();let d=Up.getPointAtIndexGlobalCoordinates(s,0,m),c=Up.getPointAtIndexGlobalCoordinates(s,-1,m),p=s.startBinding&&m.get(s.startBinding.elementId),u=s.endBinding&&m.get(s.endBinding.elementId),f=p&&s.startBinding?{...s.startBinding,...Ax(s,p,"start",m)}:null,b=u&&s.endBinding?{...s.endBinding,...Ax(s,u,"end",m)}:null;s={...s,startBinding:f,endBinding:b,...R4(s,m,{points:[d,c].map(x=>u4(x[0]-s.x,x[1]-s.y)),startBinding:f,endBinding:b,fixedSegments:null})}}else{let m=n.scene.getNonDeletedElementsMap();if(s.startBinding){let d=m.get(s.startBinding.elementId);d&&Lx(s,d,"start",n.scene)}if(s.endBinding){let d=m.get(s.endBinding.elementId);d&&Lx(s,d,"end",n.scene)}}return s}),i={...o,currentItemArrowType:t},a=o.selectedLinearElement?.elementId;if(a){let l=r.find(s=>s.id===a);l&&(i.selectedLinearElement=new Up(l,Wp(e)))}return{elements:r,appState:i,captureUpdate:$e.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>ht("fieldset",{children:[ee("legend",{children:g("labels.arrowtypes")}),ee("div",{className:"buttonList",children:ee(Ht,{group:"arrowtypes",options:[{value:No.sharp,text:g("labels.arrowtype_sharp"),icon:Fr,testId:"sharp-arrow"},{value:No.round,text:g("labels.arrowtype_round"),icon:zr,testId:"round-arrow"},{value:No.elbow,text:g("labels.arrowtype_elbowed"),icon:Or,testId:"elbow-arrow"}],value:at(e,n,r=>Ws(r)?r.elbowed?No.elbow:r.roundness?No.round:No.sharp:null,r=>Ws(r),r=>r?null:o.currentItemArrowType),onChange:r=>t(r)})})]})});import{clamp as Jp,roundToStep as ek}from"@excalidraw/math";import{DEFAULT_CANVAS_BACKGROUND_PICKS as tk,CURSOR_TYPE as Ux,MAX_ZOOM as Yx,MIN_ZOOM as Wx,THEME as Pa,ZOOM_STEP as Qp,getShortcutKey as Vx,updateActiveTool as ei,CODES as yo,KEYS as Fo}from"@excalidraw/common";import{getNonDeletedElements as ok}from"@excalidraw/element";import{newElementWith as nk}from"@excalidraw/element";import{getCommonBounds as rk}from"@excalidraw/element";import{CaptureUpdateAction as to}from"@excalidraw/element";import{useEffect as Z4}from"react";import{jsx as j4}from"react/jsx-runtime";var Qr=()=>{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},Zp=(e,o,t="bottom")=>{let n=e.getBoundingClientRect(),r=window.innerWidth,i=window.innerHeight,a=5,l=o.left+o.width/2-n.width/2;l<0?l=a:l+n.width>=r&&(l=r-n.width-a);let s;t==="bottom"?(s=o.top+o.height+a,s+n.height>=i&&(s=o.top-n.height-a)):(s=o.top-n.height-a,s<0&&(s=o.top+o.height+a)),Object.assign(e.style,{top:`${s}px`,left:`${l}px`})},$4=(e,o,t,n)=>{o.classList.add("excalidraw-tooltip--visible"),o.style.minWidth=n?"50ch":"10ch",o.style.maxWidth=n?"50ch":"15ch",o.textContent=t;let r=e.getBoundingClientRect();Zp(o,r)},At=({children:e,label:o,long:t=!1,style:n,disabled:r})=>(Z4(()=>()=>Qr().classList.remove("excalidraw-tooltip--visible"),[]),r?null:j4("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>$4(i.currentTarget,Qr(),o,t),onPointerLeave:()=>Qr().classList.remove("excalidraw-tooltip--visible"),style:n,children:e}));import Vs from"open-color";import{CURSOR_TYPE as $p,MIME_TYPES as jp,THEME as zx}from"@excalidraw/common";var Hx='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',q4='<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"/>',Gx='<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"/>',J4=`data:${jp.svg},${encodeURIComponent(`${Hx}${Gx}</svg>`)}`,Q4=`data:${jp.svg},${encodeURIComponent(`${Hx}${q4}${Gx}</svg>`)}`,Ut=e=>{e&&(e.style.cursor="")},ye=(e,o)=>{e&&(e.style.cursor=o)},Eo,Ox,qp=(e,o)=>{let n=()=>{let r=o===zx.DARK;Eo=document.createElement("canvas"),Eo.theme=o,Eo.height=20,Eo.width=20;let i=Eo.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(Eo.width/2,Eo.height/2,5,0,2*Math.PI),i.fillStyle=r?Vs.black:Vs.white,i.fill(),i.strokeStyle=r?Vs.white:Vs.black,i.stroke(),Ox=Eo.toDataURL(jp.svg)};(!Eo||Eo.theme!==o)&&n(),ye(e,`url(${Ox}) ${20/2} ${20/2}, auto`)},Dt=(e,o)=>{if(e)if(o.activeTool.type==="selection")Ut(e);else if(Qt(o))e.style.cursor=$p.GRAB;else if(yt(o))qp(e,o.theme);else if(o.activeTool.type==="laser"){let t=o.theme===zx.LIGHT?J4:Q4;e.style.cursor=`url(${t}), auto`}else["image","custom"].includes(o.activeTool.type)?o.activeTool.type!=="image"&&(e.style.cursor=$p.AUTO):e.style.cursor=$p.CROSSHAIR};var Bo=({viewportX:e,viewportY:o,nextZoom:t},n)=>{let r=e-n.offsetLeft,i=o-n.offsetTop,a=n.zoom.value,l=n.scrollX+(r-r/a),s=n.scrollY+(i-i/a),m=-(r-r/t),d=-(i-i/t);return{scrollX:l+m,scrollY:s+d,zoom:{value:t}}};import{jsx as $s,jsxs as sk}from"react/jsx-runtime";var ik=N({name:"changeViewBackgroundColor",label:"labels.canvasBackground",trackEvent:!1,predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.changeViewBackgroundColor&&!o.viewModeEnabled,perform:(e,o,t)=>({appState:{...o,...t},captureUpdate:t.viewBackgroundColor?to.IMMEDIATELY:to.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:n,data:r})=>$s(va,{palette:null,topPicks:tk,label:g("labels.canvasBackground"),type:"canvasBackground",color:o.viewBackgroundColor,onChange:i=>t({viewBackgroundColor:i}),"data-testid":"canvas-background-picker",elements:e,appState:o,updateData:t,compactMode:o.stylesPanelMode==="compact"})}),Oo=N({name:"clearCanvas",label:"labels.clearCanvas",icon:Mt,trackEvent:{category:"canvas"},predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.clearCanvas&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector",perform:(e,o,t,n)=>(n.imageCache.clear(),{elements:e.map(r=>nk(r,{isDeleted:!0})),appState:{...Qo(),files:{},theme:o.theme,penMode:o.penMode,penDetected:o.penDetected,exportBackground:o.exportBackground,exportEmbedScene:o.exportEmbedScene,gridSize:o.gridSize,gridStep:o.gridStep,gridModeEnabled:o.gridModeEnabled,stats:o.stats,pasteDialog:o.pasteDialog,activeTool:o.activeTool.type==="image"?{...o.activeTool,type:n.defaultSelectionTool}:o.activeTool},captureUpdate:to.IMMEDIATELY})}),Xs=N({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:Om,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>({appState:{...o,...Bo({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:ho(o.zoom.value+Qp)},o),userToFollow:null},captureUpdate:to.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>$s(Z,{type:"button",className:"zoom-in-button zoom-button",icon:Om,title:`${g("buttons.zoomIn")} \u2014 ${Vx("CtrlOrCmd++")}`,"aria-label":g("buttons.zoomIn"),disabled:o.zoom.value>=Yx,onClick:()=>{e(null)}}),keyTest:e=>(e.code===yo.EQUAL||e.code===yo.NUM_ADD)&&(e[Fo.CTRL_OR_CMD]||e.shiftKey)}),Ks=N({name:"zoomOut",label:"buttons.zoomOut",icon:zm,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>({appState:{...o,...Bo({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:ho(o.zoom.value-Qp)},o),userToFollow:null},captureUpdate:to.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>$s(Z,{type:"button",className:"zoom-out-button zoom-button",icon:zm,title:`${g("buttons.zoomOut")} \u2014 ${Vx("CtrlOrCmd+-")}`,"aria-label":g("buttons.zoomOut"),disabled:o.zoom.value<=Wx,onClick:()=>{e(null)}}),keyTest:e=>(e.code===yo.MINUS||e.code===yo.NUM_SUBTRACT)&&(e[Fo.CTRL_OR_CMD]||e.shiftKey)}),Zs=N({name:"resetZoom",label:"buttons.resetZoom",icon:n0,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>({appState:{...o,...Bo({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:ho(1)},o),userToFollow:null},captureUpdate:to.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>$s(At,{label:g("buttons.resetZoom"),style:{height:"100%"},children:sk(Z,{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===yo.ZERO||e.code===yo.NUM_ZERO)&&(e[Fo.CTRL_OR_CMD]||e.shiftKey)}),ak=(e,o,t=1)=>{let[n,r,i,a]=e,l=i-n,s=o.width/l,m=a-r,d=o.height/m,p=Math.min(s,d)*Jp(t,.1,1);return Math.min(p,1)},Xx=({bounds:e,appState:o,canvasOffsets:t,fitToViewport:n=!1,viewportZoomFactor:r=1,minZoom:i=-1/0,maxZoom:a=1/0})=>{r=Jp(r,Wx,Yx);let[l,s,m,d]=e,c=(l+m)/2,p=(s+d)/2,u=t?.left??0,f=t?.top??0,b=t?.right??0,x=t?.bottom??0,y=o.width-u-b,E=o.height-f-x,w;if(n){let S=m-l,L=d-s;w=Math.min(y/S,E/L)*r}else w=ak(e,{width:y,height:E},r);let v=ho(Jp(ek(w,Qp,"floor"),i,a)),C=h1({scenePoint:{x:c,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:to.EVENTUALLY}},La=({canvasOffsets:e,targetElements:o,appState:t,fitToViewport:n,viewportZoomFactor:r,minZoom:i,maxZoom:a})=>{let l=rk(ok(o));return Xx({canvasOffsets:e,bounds:l,appState:t,fitToViewport:n,viewportZoomFactor:r,minZoom:i,maxZoom:a})},rq=N({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:gs,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return La({targetElements:r.length?r:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:n.getEditorUIOffsets()})},keyTest:e=>e.code===yo.TWO&&e.shiftKey&&!e.altKey&&!e[Fo.CTRL_OR_CMD]}),iq=N({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:gs,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return La({targetElements:r.length?r:e,appState:{...o,userToFollow:null},fitToViewport:!0,canvasOffsets:n.getEditorUIOffsets()})},keyTest:e=>e.code===yo.THREE&&e.shiftKey&&!e.altKey&&!e[Fo.CTRL_OR_CMD]}),lk=N({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:gs,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>La({targetElements:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:n.getEditorUIOffsets()}),keyTest:e=>e.code===yo.ONE&&e.shiftKey&&!e.altKey&&!e[Fo.CTRL_OR_CMD]}),Jn=N({name:"toggleTheme",label:(e,o)=>o.theme===Pa.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:e=>e.theme===Pa.LIGHT?sa:ca,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t)=>({appState:{...o,theme:t||(o.theme===Pa.LIGHT?Pa.DARK:Pa.LIGHT)},captureUpdate:to.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===yo.D,predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.toggleTheme}),aq=N({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,o,t,n)=>{let r;return yt(o)?r=ei(o,{...o.activeTool.lastActiveTool||{type:n.defaultSelectionTool},lastActiveToolBeforeEraser:null}):r=ei(o,{type:"eraser",lastActiveToolBeforeEraser:o.activeTool}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:to.IMMEDIATELY}},keyTest:e=>e.key===Fo.E}),lq=N({name:"toggleLassoTool",label:"toolBar.lasso",icon:aa,trackEvent:{category:"toolbar"},predicate:(e,o,t,n)=>n.defaultSelectionTool!=="lasso",perform:(e,o,t,n)=>{let r;return o.activeTool.type!=="lasso"?(r=ei(o,{type:"lasso",fromSelection:!1}),ye(n.interactiveCanvas,Ux.CROSSHAIR)):r=ei(o,{type:"selection"}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:to.NEVER}}}),Kx=N({name:"toggleHandTool",label:"toolBar.hand",trackEvent:{category:"toolbar"},icon:ps,viewMode:!1,perform:(e,o,t,n)=>{let r;return Qt(o)?r=ei(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(r=ei(o,{type:"hand",lastActiveToolBeforeEraser:o.activeTool}),ye(n.interactiveCanvas,Ux.GRAB)),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:to.IMMEDIATELY}},keyTest:e=>!e.altKey&&!e[Fo.CTRL_OR_CMD]&&e.key===Fo.H});import{updateActiveTool as Zx}from"@excalidraw/common";import{CaptureUpdateAction as ck}from"@excalidraw/element";var dk=N({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,o,t,n)=>{let r=Zx(o,{type:"embeddable"});return Dt(n.canvas,{...o,activeTool:r}),{elements:e,appState:{...o,activeTool:Zx(o,{type:"embeddable"})},captureUpdate:ck.EVENTUALLY}}});import{pointFrom as mk}from"@excalidraw/math";import{maybeBindLinearElement as pk,bindOrUnbindLinearElement as $x,isBindingEnabled as uk}from"@excalidraw/element/binding";import{isValidPolygon as jx,LinearElementEditor as Aa,newElementWith as eu}from"@excalidraw/element";import{isBindingElement as js,isFreeDrawElement as qx,isLinearElement as Jx,isLineElement as qs}from"@excalidraw/element";import{KEYS as tu,arrayToMap as ou,tupleToCoors as hk,updateActiveTool as Qx}from"@excalidraw/common";import{isPathALoop as gk}from"@excalidraw/element";import{isInvisiblySmallElement as nu}from"@excalidraw/element";import{CaptureUpdateAction as ru}from"@excalidraw/element";import{jsx as fk}from"react/jsx-runtime";var _t=N({name:"finalize",label:"",trackEvent:!1,perform:(e,o,t,n)=>{let{interactiveCanvas:r,focusContainer:i,scene:a}=n,{event:l,sceneCoords:s}=t??{},m=a.getNonDeletedElementsMap();if(l&&o.selectedLinearElement){let u=Aa.handlePointerUp(l,o.selectedLinearElement,o,n.scene),{startBindingElement:f,endBindingElement:b}=u,x=n.scene.getElement(u.elementId);if(js(x)&&$x(x,f,b,n.scene),u!==o.selectedLinearElement){let y=e;return x&&nu(x)&&(y=y.map(E=>E.id===x.id?eu(E,{isDeleted:!0}):E)),{elements:y,appState:{selectedLinearElement:{...u,selectedPointsIndices:null},suggestedBindings:[]},captureUpdate:ru.IMMEDIATELY}}}if(o.selectedLinearElement?.isEditing){let{elementId:u,startBindingElement:f,endBindingElement:b}=o.selectedLinearElement,x=Aa.getElement(u,m);if(x)return js(x)&&$x(x,f,b,a),qs(x)&&!jx(x.points)&&a.mutateElement(x,{polygon:!1}),{elements:x.points.length<2||nu(x)?e.map(y=>y.id===x.id?eu(y,{isDeleted:!0}):y):void 0,appState:{...o,cursorButton:"up",selectedLinearElement:new Aa(x,ou(m),!1)},captureUpdate:ru.IMMEDIATELY}}let d=e;window.document.activeElement instanceof HTMLElement&&i();let c=null;if(o.multiElement)c=o.multiElement;else if(o.newElement?.type==="freedraw"||js(o.newElement))c=o.newElement;else if(Object.keys(o.selectedElementIds).length===1){let u=m.get(Object.keys(o.selectedElementIds)[0]);u&&(c=u)}if(c){if(o.multiElement&&c.type!=="freedraw"){let{points:u,lastCommittedPoint:f}=c;(!f||u[u.length-1]!==f)&&a.mutateElement(c,{points:c.points.slice(0,-1)})}if(c&&nu(c)&&(d=d.map(u=>u.id===c?.id?eu(u,{isDeleted:!0}):u)),Jx(c)||qx(c)){let u=gk(c.points,o.zoom.value);if(u&&(qs(c)||qx(c))){let f=c.points,b=f[0],x=f.map((y,E)=>E===f.length-1?mk(b[0],b[1]):y);qs(c)?a.mutateElement(c,{points:x,polygon:!0}):a.mutateElement(c,{points:x})}if(qs(c)&&!jx(c.points)&&a.mutateElement(c,{polygon:!1}),js(c)&&!u&&c.points.length>1&&uk(o)){let f=s??hk(Aa.getPointAtIndexGlobalCoordinates(c,-1,ou(e)));pk(c,o,f,a)}}}(!o.activeTool.locked&&o.activeTool.type!=="freedraw"||!c)&&Ut(r);let p;return o.activeTool.type==="eraser"?p=Qx(o,{...o.activeTool.lastActiveTool||{type:n.defaultSelectionTool},lastActiveToolBeforeEraser:null}):p=Qx(o,{type:n.defaultSelectionTool}),{elements:d,appState:{...o,cursorButton:"up",activeTool:(o.activeTool.locked||o.activeTool.type==="freedraw")&&c?o.activeTool:p,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&&Jx(c)?new Aa(c,ou(d)):o.selectedLinearElement},captureUpdate:ru.IMMEDIATELY}},keyTest:(e,o)=>e.key===tu.ESCAPE&&(o.selectedLinearElement?.isEditing||!o.newElement&&o.multiElement===null)||(e.key===tu.ESCAPE||e.key===tu.ENTER)&&o.multiElement!==null,PanelComponent:({appState:e,updateData:o,data:t})=>fk(Z,{type:"button",icon:u0,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 ni,DEFAULT_EXPORT_PADDING as aM,EXPORT_SCALES as lM,THEME as lu}from"@excalidraw/common";import{getNonDeletedElements as sM}from"@excalidraw/element";import{CaptureUpdateAction as io}from"@excalidraw/element";import bk from"clsx";import{jsx as eE,jsxs as xk}from"react/jsx-runtime";var Da=({children:e,checked:o,onChange:t,className:n})=>xk("div",{className:bk("Checkbox",n,{"is-checked":o}),onClick:r=>{t(!o,r),r.currentTarget.querySelector(".Checkbox-box").focus()},children:[eE("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":o,children:l0}),eE("div",{className:"Checkbox-label",children:e})]});import{THEME as _a}from"@excalidraw/common";import{jsx as Ra}from"react/jsx-runtime";var oE=e=>{let o=e.title||(e.value===_a.DARK?g("buttons.lightMode"):g("buttons.darkMode"));return Ra(Z,{type:"icon",icon:e.value===_a.LIGHT?tE.MOON:tE.SUN,title:o,"aria-label":o,onClick:()=>e.onChange(e.value===_a.DARK?_a.LIGHT:_a.DARK),"data-testid":"toggle-dark-mode"})},tE={SUN:Ra("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Ra("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:Ra("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Ra("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 Ek}from"react";import{focusNearestParent as yk,KEYS as wk}from"@excalidraw/common";import{jsx as nE,jsxs as vk}from"react/jsx-runtime";var rE=e=>{let{id:o}=Ne(),[t,n]=Ek(e.value),r=a=>{e.ignoreFocus||yk(a.target);let l=a.target.value;l!==e.value&&e.onChange(l)},i=a=>{if(a.key===wk.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return vk("div",{className:"ProjectName",children:[nE("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),nE("input",{type:"text",className:"TextInput",onBlur:r,onKeyDown:i,id:`${o}-filename`,value:t,onChange:a=>n(a.target.value)})]})};import{DEFAULT_EXPORT_PADDING as qk,DEFAULT_FILENAME as Jk,IMAGE_MIME_TYPES as yE,isFirefox as Qk,MIME_TYPES as eM,cloneJSON as tM,SVG_DOCUMENT_PREAMBLE as oM}from"@excalidraw/common";import{getNonDeletedElements as nM}from"@excalidraw/element";import{isFrameLikeElement as rM}from"@excalidraw/element";import{getElementsOverlappingFrame as iM}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as _k,EXPORT_DATA_TYPES as Fa,MIME_TYPES as no,arrayToMap as Rk,isMemberOf as Nk,isPromiseLike as Bk,EVENT as ec}from"@excalidraw/common";import{mutateElement as Fk}from"@excalidraw/element";import{deepCopyElement as Ok}from"@excalidraw/element";import{isFrameLikeElement as zk,isInitializedImageElement as Hk}from"@excalidraw/element";import{getContainingFrame as gE}from"@excalidraw/element";import{pointFrom as pn}from"@excalidraw/math";import{COLOR_PALETTE as aE,DEFAULT_CHART_COLOR_INDEX as Tk,getAllColorsSpecificShade as Ik,DEFAULT_FONT_FAMILY as Ck,DEFAULT_FONT_SIZE as lE,VERTICAL_ALIGN as Sk,randomId as sE,isDevEnv as cE}from"@excalidraw/common";import{newTextElement as Js,newLinearElement as Ba,newElement as au}from"@excalidraw/element";var oo=32,Te=12,un=256,dE=50,Qn="NOT_SPREADSHEET",ti="VALID_SPREADSHEET",Na=e=>{let o=/^([-+]?)[$€£¥₩]?([-+]?)([\d.,]+)[%]?$/.exec(e);return o?parseFloat(`${(o[1]||o[2])+o[3]}`.replace(/,/g,"")):null},iu=(e,o)=>e.slice(1).every(t=>Na(t[o])!==null),iE=e=>{let o=e[0].length;if(o>2)return{type:Qn,reason:"More than 2 columns"};if(o===1){if(!iu(e,0))return{type:Qn,reason:"Value is not numeric"};let s=Na(e[0][0])===null,m=(s?e.slice(1):e).map(d=>Na(d[0]));return m.length<2?{type:Qn,reason:"Less than two rows"}:{type:ti,spreadsheet:{title:s?e[0][0]:null,labels:null,values:m}}}let t=iu(e,0),n=iu(e,1);if(!t&&!n)return{type:Qn,reason:"Value is not numeric"};let[r,i]=n?[0,1]:[1,0],a=Na(e[0][i])===null,l=a?e.slice(1):e;return l.length<2?{type:Qn,reason:"Less than 2 rows"}:{type:ti,spreadsheet:{title:a?e[0][i]:null,labels:l.map(s=>s[r]),values:l.map(s=>Na(s[i]))}}},kk=e=>{let o=[];for(let t=0;t<e[0].length;t++){let n=[];for(let r=0;r<e.length;r++)n.push(e[r][t]);o.push(n)}return o},mE=e=>{let o=e.trim().split(`
|
|
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:Qn,reason:"No values"};let t=o[0].length;if(!o.every(i=>i.length===t))return{type:Qn,reason:"All rows don't have same number of columns"};let r=iE(o);if(r.type!==ti){let i=iE(kk(o));if(i.type===ti)return i}return r},Qs=Ik(Tk),Yt={fillStyle:"hachure",fontFamily:Ck,fontSize:lE,opacity:100,roughness:1,strokeColor:aE.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:Sk.MIDDLE,locked:!1},pE=e=>{let o=(oo+Te)*e.values.length+Te,t=un+Te*2;return{chartWidth:o,chartHeight:t}},Mk=(e,o,t,n,r)=>e.labels?.map((i,a)=>Js({groupIds:[n],backgroundColor:r,...Yt,text:i.length>8?`${i.slice(0,5)}...`:i,x:o+a*(oo+Te)+Te*2,y:t+Te/2,width:oo,angle:5.87,fontSize:16,textAlign:"center",verticalAlign:"top"}))||[],Pk=(e,o,t,n,r)=>{let i=Js({groupIds:[n],backgroundColor:r,...Yt,x:o-Te,y:t-Te,text:"0",textAlign:"right"}),a=Js({groupIds:[n],backgroundColor:r,...Yt,x:o-Te,y:t-un-i.height/2,text:Math.max(...e.values).toLocaleString(),textAlign:"right"});return[i,a]},Lk=(e,o,t,n,r)=>{let{chartWidth:i,chartHeight:a}=pE(e),l=Ba({backgroundColor:r,groupIds:[n],...Yt,type:"line",x:o,y:t,width:i,points:[pn(0,0),pn(i,0)]}),s=Ba({backgroundColor:r,groupIds:[n],...Yt,type:"line",x:o,y:t,height:a,points:[pn(0,0),pn(0,-a)]}),m=Ba({backgroundColor:r,groupIds:[n],...Yt,type:"line",x:o,y:t-un-Te,strokeStyle:"dotted",width:i,opacity:dE,points:[pn(0,0),pn(i,0)]});return[l,s,m]},uE=(e,o,t,n,r,i)=>{let{chartWidth:a,chartHeight:l}=pE(e),s=e.title?Js({backgroundColor:r,groupIds:[n],...Yt,text:e.title,x:o+a/2,y:t-un-Te*2-lE,roundness:null,textAlign:"center"}):null,m=i?au({backgroundColor:r,groupIds:[n],...Yt,type:"rectangle",x:o,y:t-l,width:a,height:l,strokeColor:aE.black,fillStyle:"solid",opacity:6}):null;return[...m?[m]:[],...s?[s]:[],...Mk(e,o,t,n,r),...Pk(e,o,t,n,r),...Lk(e,o,t,n,r)]},Ak=(e,o,t)=>{let n=Math.max(...e.values),r=sE(),i=Qs[Math.floor(Math.random()*Qs.length)];return[...e.values.map((l,s)=>{let m=l/n*un;return au({backgroundColor:i,groupIds:[r],...Yt,type:"rectangle",x:o+s*(oo+Te)+Te,y:t-m-Te,width:oo,height:m})}),...uE(e,o,t,r,i,cE())]},Dk=(e,o,t)=>{let n=Math.max(...e.values),r=sE(),i=Qs[Math.floor(Math.random()*Qs.length)],a=0,l=[];for(let b of e.values){let x=a*(oo+Te),y=-(b/n)*un;l.push([x,y]),a++}let s=Math.max(...l.map(b=>b[0])),m=Math.max(...l.map(b=>b[1])),d=Math.min(...l.map(b=>b[0])),c=Math.min(...l.map(b=>b[1])),p=Ba({backgroundColor:i,groupIds:[r],...Yt,type:"line",x:o+Te+oo/2,y:t-Te,height:m-c,width:s-d,strokeWidth:2,points:l}),u=e.values.map((b,x)=>{let y=x*(oo+Te)+Te/2,E=-(b/n)*un+Te/2;return au({backgroundColor:i,groupIds:[r],...Yt,fillStyle:"solid",strokeWidth:2,type:"ellipse",x:o+y+oo/2,y:t+E-Te*2,width:Te,height:Te})}),f=e.values.map((b,x)=>{let y=x*(oo+Te)+Te/2,E=b/n*un+Te/2+Te;return Ba({backgroundColor:i,groupIds:[r],...Yt,type:"line",x:o+y+oo/2+Te/2,y:t-E,height:E,strokeStyle:"dotted",opacity:dE,points:[pn(0,0),pn(0,E)]})});return[...uE(e,o,t,r,i,cE()),p,...f,...u]},hE=(e,o,t,n)=>e==="line"?Dk(o,t,n):Ak(o,t,n);var yJ="clipboard"in navigator&&"readText"in navigator.clipboard,tc="clipboard"in navigator&&"writeText"in navigator.clipboard,oi="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,Gk=e=>!!([Fa.excalidraw,Fa.excalidrawClipboard,Fa.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),fE=({types:e,files:o})=>{!e&&!o&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent(ec.PASTE,{clipboardData:new DataTransfer});if(e)for(let[n,r]of Object.entries(e)){if(typeof r!="string"){o=o||[],o.push(r),t.clipboardData?.items.add(r);continue}try{if(t.clipboardData?.items.add(r,n),t.clipboardData?.getData(n)!==r)throw new Error(`Failed to set "${n}" as clipboardData item`)}catch(i){throw new Error(i.message)}}if(o){let n=-1;for(let r of o){n++;try{if(t.clipboardData?.items.add(r),t.clipboardData?.files[n]!==r)throw new Error(`Failed to set file "${r.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return t},Uk=({elements:e,files:o})=>{let t=Rk(e),n=new Set(e.filter(l=>zk(l))),r=!1,i=e.reduce((l,s)=>(Hk(s)&&(r=!0,o&&o[s.fileId]&&(l[s.fileId]=o[s.fileId])),l),{});r&&!o&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:Fa.excalidrawClipboard,elements:e.map(l=>{if(gE(l,t)&&!n.has(gE(l,t))){let s=Ok(l);return Fk(s,t,{frameId:null}),s}return l}),files:o?i:void 0};return JSON.stringify(a)},oc=async(e,o,t)=>{await ro(Uk({elements:e,files:o}),t)},Yk=e=>{let o=mE(e);return o.type===ti?{spreadsheet:o.spreadsheet}:null};function bE(e){let o=[];for(let t of e.childNodes)if(t.nodeType===3){let n=t.textContent?.trim();n&&o.push({type:"text",value:n})}else if(t instanceof HTMLImageElement){let n=t.getAttribute("src");n&&n.startsWith("http")&&o.push({type:"imageUrl",value:n})}else o=o.concat(bE(t));return o}var Wk=e=>{let o=e.value;try{let t=new DOMParser().parseFromString(o,no.html),n=bE(t.body);if(n.length)return{type:"mixedContent",value:n}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},xE=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 n=await navigator.clipboard?.readText();if(n)return{[no.text]:n}}}catch(n){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${n.message}). Failling back to navigator.clipboard.read()`);else{if(n.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${n.message}`),e;throw n}}throw t}for(let t of o)for(let n of t.types)if(Nk(_k,n))try{if(n===no.text||n===no.html)e[n]=await(await t.getType(n)).text();else if(A1(n)){let r=await t.getType(n),i=O1(r,n,void 0);e[n]=i}else throw new km(`Unsupported clipboard type: ${n}`)}catch(r){console.warn(r instanceof km?r.message:`Cannot retrieve ${n} from clipboardItem: ${r.message}`)}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},Vk=async(e,o=!1)=>{try{let t=e.findByType(no.html),n=!o&&t&&Wk(t);return n?n.value.every(r=>r.type==="text")?{type:"text",value:e.getData(no.text)??n.value.map(r=>r.value).join(`
|
|
5
|
+
`).trim()}:n:{type:"text",value:(e.getData(no.text)||"").trim()}}catch{return{type:"text",value:""}}},Xk=function(e){return this.find(o=>o.type===e)||null},Kk=function(e){return this.find(t=>t.type===e)?.value??null},Zk=function(){return this.filter(e=>e.kind==="file")},Oa=async e=>{let o;jk(e)?o=e.clipboardData?.items:o=e.dataTransfer?.items;let t=(await Promise.all(Array.from(o||[]).map(async n=>{if(n.kind==="file"){let r=n.getAsFile();if(r){let i=await F1(n);return r=await ia(r),{type:r.type,kind:"file",file:r,fileHandle:i}}}else if(n.kind==="string"){let{type:r}=n,i;return"clipboardData"in e&&e.clipboardData?i=e.clipboardData?.getData(r):i=await new Promise(a=>{n.getAsString(l=>a(l))}),{type:r,kind:"string",value:i}}return null}))).filter(n=>n!=null);return Object.assign(t,{findByType:Xk,getData:Kk,getFiles:Zk})},EE=async(e,o=!1)=>{let t=await Vk(e,o);if(t.type==="mixedContent")return{mixedContent:t.value};try{let n=!o&&Yk(t.value);if(n)return n}catch(n){console.error(n)}try{let n=JSON.parse(t.value),r=n.type===Fa.excalidrawClipboardWithAPI;if(Gk(n))return{elements:n.elements,files:n.files,text:o?JSON.stringify(n.elements,null,2):void 0,programmaticAPI:r}}catch{}return{text:t.value}},nc=async e=>{try{await navigator.clipboard.write([new window.ClipboardItem({[no.png]:e})])}catch(o){if(Bk(e))await navigator.clipboard.write([new window.ClipboardItem({[no.png]:await e})]);else throw o}},ro=async(e,o)=>{if(tc)try{await navigator.clipboard.writeText(e||"");return}catch(t){console.error(t)}try{if(o){if(o.clipboardData?.setData(no.text,e||""),o.clipboardData?.getData(no.text)!==e)throw new Error("Failed to setData on clipboardEvent");return}}catch(t){console.error(t)}if(!$k(e))throw new Error("Error copying to clipboard.")},$k=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 n=window.pageYOffset||document.documentElement.scrollTop;t.style.top=`${n}px`,t.style.fontSize="12pt",t.setAttribute("readonly",""),t.value=e,document.body.appendChild(t);let r=!1;try{t.select(),t.setSelectionRange(0,t.value.length),r=document.execCommand("copy")}catch(i){console.error(i)}return t.remove(),r},jk=e=>e.type===ec.PASTE||e.type===ec.COPY||e.type===ec.CUT;var er=(e,{selectedElementIds:o},t)=>{e=nM(e);let n=t&&we(e,{selectedElementIds:o}),r=null,i=n?j(e,{selectedElementIds:o},{includeBoundTextElement:!0}):e;return n&&(i.length===1&&rM(i[0])?(r=i[0],i=iM(e,r)):i.length>1&&(i=j(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:r,exportedElements:tM(i)}},tr=async(e,o,t,n,{exportBackground:r,exportPadding:i=qk,viewBackgroundColor:a,name:l=t.name||Jk,fileHandle:s=null,exportingFrame:m=null})=>{if(o.length===0)throw new Error(g("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let c=Cr(o,{exportBackground:r,exportWithDarkMode:t.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:t.exportScale,exportEmbedScene:t.exportEmbedScene&&e==="svg"},n,{exportingFrame:m});if(e==="svg")return Mm(c.then(p=>new Blob([oM+p.outerHTML],{type:eM.svg})),{description:"Export to SVG",name:l,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[yE.svg],fileHandle:s});if(e==="clipboard-svg"){let p=await c.then(u=>u.outerHTML);try{await ro(p)}catch{throw new Error(g("errors.copyToSystemClipboardFailed"))}return}}let d=Kl(o,t,n,{exportBackground:r,viewBackgroundColor:a,exportPadding:i,exportingFrame:m});if(e==="png"){let c=Ao(d);return t.exportEmbedScene&&(c=c.then(p=>import("./data/image-JWK7QZ22.js").then(({encodePngMetadata:u})=>u({blob:p,metadata:ta(o,t,n,"local")})))),Mm(c,{description:"Export to PNG",name:l,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[yE.png],fileHandle:s})}else if(e==="clipboard")try{let c=Ao(d);await nc(c)}catch(c){throw console.warn(c),c.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):Qk&&c.name==="TypeError"?new Error(`${g("alerts.couldNotCopyToClipboard")}
|
|
6
6
|
|
|
7
|
-
${f("hints.firefox_clipboard_write")}`):new Error(f("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var R2=async(e,t,o,r)=>{let{exportBackground:n,viewBackgroundColor:i,fileHandle:a}=t,l=ex(a);if(!a||!tx(l))throw new Error("fileHandle should exist and should be of type svg or png when resaving");t={...t,exportEmbedScene:!0};let{exportedElements:s,exportingFrame:c}=Di(e,t,!1);return await _i(l,s,t,o,{exportBackground:n,viewBackgroundColor:i,name:r,fileHandle:a,exportingFrame:c}),{fileHandle:a}};import{Fragment as RC,jsx as Zr,jsxs as NC}from"react/jsx-runtime";var ng=F({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,t,o)=>({appState:{...t,name:o},captureUpdate:D.EVENTUALLY}),PanelComponent:({appState:e,updateData:t,appProps:o,data:r,app:n})=>Zr(S2,{label:f("labels.fileTitle"),value:n.getName(),onChange:i=>t(i),ignoreFocus:r?.ignoreFocus??!1})}),N2=F({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,t,o)=>({appState:{...t,exportScale:o},captureUpdate:D.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:o})=>{let r=ye(e),i=Ue(r,t)?Q(r,t):r;return Zr(RC,{children:mc.map(a=>{let[l,s]=J0(i,sn,a),c=`${f("imageExportDialog.label.scale")} ${a}x (${l}x${s})`;return Zr(te,{size:"small",type:"radio",icon:`${a}x`,name:"export-canvas-scale",title:c,"aria-label":c,id:"export-canvas-scale",checked:a===t.exportScale,onChange:()=>o(a)},a)})})}}),ig=F({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,t,o)=>({appState:{...t,exportBackground:o},captureUpdate:D.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>Zr(fs,{checked:e.exportBackground,onChange:o=>t(o),children:f("imageExportDialog.label.withBackground")})}),hm=F({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,t,o)=>({appState:{...t,exportEmbedScene:o},captureUpdate:D.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>NC(fs,{checked:e.exportEmbedScene,onChange:o=>t(o),children:[f("imageExportDialog.label.embedScene"),Zr(So,{label:f("imageExportDialog.tooltip.embedScene"),long:!0,children:Zr("div",{className:"excalidraw-tooltip-icon",children:tE})})]})}),Pi=F({name:"saveToActiveFile",label:"buttons.save",icon:Si,trackEvent:{category:"export"},predicate:(e,t,o,r)=>!!r.props.UIOptions.canvasActions.saveToActiveFile&&!!t.fileHandle&&!t.viewModeEnabled,perform:async(e,t,o,r)=>{let n=!!t.fileHandle;try{let{fileHandle:i}=id(t.fileHandle)?await R2(e,t,r.files,r.getName()):await ed(e,t,r.files,r.getName());return{captureUpdate:D.EVENTUALLY,appState:{...t,fileHandle:i,toast:n?{message:i?.name?f("toast.fileSavedToFilename").replace("{filename}",`"${i.name}"`):f("toast.fileSaved")}:null}}}catch(i){return i?.name!=="AbortError"?console.error(i):console.warn(i),{captureUpdate:D.EVENTUALLY}}},keyTest:e=>e.key===T.S&&e[T.CTRL_OR_CMD]&&!e.shiftKey}),Es=F({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:Si,viewMode:!0,trackEvent:{category:"export"},perform:async(e,t,o,r)=>{try{let{fileHandle:n}=await ed(e,{...t,fileHandle:null},r.files,r.getName());return{captureUpdate:D.EVENTUALLY,appState:{...t,openDialog:null,fileHandle:n,toast:{message:f("toast.fileSaved")}}}}catch(n){return n?.name!=="AbortError"?console.error(n):console.warn(n),{captureUpdate:D.EVENTUALLY}}},keyTest:e=>e.key===T.S&&e.shiftKey&&e[T.CTRL_OR_CMD],PanelComponent:({updateData:e})=>Zr(te,{type:"button",icon:qx,title:f("buttons.saveAs"),"aria-label":f("buttons.saveAs"),showAriaLabel:Te().editor.isMobile,hidden:!ca,onClick:()=>e(null),"data-testid":"save-as-button"})}),Na=F({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,t,o,r)=>!!r.props.UIOptions.canvasActions.loadScene&&!t.viewModeEnabled,perform:async(e,t,o,r)=>{try{let{elements:n,appState:i,files:a}=await Pu(t,e);return{elements:n,appState:i,files:a,captureUpdate:D.IMMEDIATELY}}catch(n){return n?.name==="AbortError"?(console.warn(n),!1):{elements:e,appState:{...t,errorMessage:n.message},files:r.files,captureUpdate:D.EVENTUALLY}}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.O}),O2=F({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,t,o)=>({appState:{...t,exportWithDarkMode:o},captureUpdate:D.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>Zr("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:Zr(w2,{value:e.exportWithDarkMode?se.DARK:se.LIGHT,onChange:o=>{t(o===se.DARK)},title:f("imageExportDialog.label.darkMode")})})});var B2="{}",ag=F({name:"copyStyles",label:"labels.copyStyles",icon:vh,trackEvent:{category:"element"},perform:(e,t,o,r)=>{let n=[],i=e.find(a=>t.selectedElementIds[a.id]);if(n.push(i),i&&it(i)){let a=pe(i,r.scene.getNonDeletedElementsMap());n.push(a)}return i&&(B2=JSON.stringify(n)),{appState:{...t,toast:{message:f("toast.copyStyles")}},captureUpdate:D.EVENTUALLY}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.altKey&&e.code===me.C}),lg=F({name:"pasteStyles",label:"labels.pasteStyles",icon:vh,trackEvent:{category:"element"},perform:(e,t,o,r)=>{let n=JSON.parse(B2),i=n[0],a=n[1];if(!Cb(i))return{elements:e,captureUpdate:D.EVENTUALLY};let l=Q(e,t,{includeBoundTextElement:!0}),s=l.map(c=>c.id);return{elements:e.map(c=>{if(s.includes(c.id)){let m=i;if(K(c)&&c.containerId&&(m=a),!m)return c;let d=re(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?kb(m.roundness.type,c)?m.roundness:Mb(c):null});if(K(d)){let p=m.fontSize||Rr,u=m.fontFamily||nn;d=re(d,{fontSize:p,fontFamily:u,textAlign:m.textAlign||ac,lineHeight:m.lineHeight||Ko(u)});let h=null;d.containerId&&(h=l.find(x=>K(d)&&x.id===d.containerId)||null),Xe(d,h,r.scene)}return d.type==="arrow"&&Ie(m)&&(d=re(d,{startArrowhead:m.startArrowhead,endArrowhead:m.endArrowhead})),J(c)&&(d=re(d,{roundness:null,backgroundColor:"transparent"})),d}return c}),captureUpdate:D.IMMEDIATELY}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.altKey&&e.code===me.V});var Oa=(e,t)=>!!(!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&(e.activeTool.type!=="custom"&&(e.editingTextElement||e.activeTool.type!=="selection"&&e.activeTool.type!=="lasso"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser")||Q(t,e).length));import{jsx as F2}from"react/jsx-runtime";var OC=F({name:"toggleCanvasMenu",label:"buttons.menu",trackEvent:{category:"menu"},perform:(e,t)=>({appState:{...t,openMenu:t.openMenu==="canvas"?null:"canvas"},captureUpdate:D.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>F2(te,{type:"button",icon:Cd,"aria-label":f("buttons.menu"),onClick:t,selected:e.openMenu==="canvas"})}),BC=F({name:"toggleEditMenu",label:"buttons.edit",trackEvent:{category:"menu"},perform:(e,t)=>({appState:{...t,openMenu:t.openMenu==="shape"?null:"shape"},captureUpdate:D.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:o})=>F2(te,{visible:Oa(t,ye(e)),type:"button",icon:Jx,"aria-label":f("buttons.edit"),onClick:o,selected:t.openMenu==="shape"})}),Ri=F({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:Kx,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,t,o,{focusContainer:r})=>(t.openDialog?.name==="help"&&r(),{appState:{...t,openDialog:t.openDialog?.name==="help"?null:{name:"help"}},captureUpdate:D.EVENTUALLY}),keyTest:e=>e.key===T.QUESTION_MARK});import{jsx as Ba}from"react/jsx-runtime";var FC=e=>{if(e.length>=2){let t=e[0].groupIds;for(let o of t)if(e.reduce((r,n)=>r&&Qi(n,o),!0))return!0}return!1},z2=(e,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0});return r.length>=2&&!FC(r)&&!zc(r)},sg=F({name:"group",label:"labels.group",icon:e=>Ba(bh,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,t,o,r)=>{let n=h0(r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}));if(n.length<2)return{appState:t,elements:e,captureUpdate:D.EVENTUALLY};let i=qo(t);if(i.length===1){let b=i[0],E=new Set(Be(e,b).map(v=>v.id)),w=new Set(n.map(v=>v.id));if(new Set([...Array.from(E),...Array.from(w)]).size===E.size)return{appState:t,elements:e,captureUpdate:D.EVENTUALLY}}let a=[...e];new Set(n.map(b=>b.frameId)).size>1&&p0(n).forEach((E,w)=>{Oc(E,r.scene.getNonDeletedElementsMap())});let s=Ht(),c=q(n);a=a.map(b=>c.get(b.id)?re(b,{groupIds:o0(b.groupIds,s,t.editingGroupId)}):b);let m=Be(a,s),d=m[m.length-1],p=a.lastIndexOf(d),u=a.slice(p+1),h=a.slice(0,p).filter(b=>!Qi(b,s)),x=At([...h,...m,...u],q(m));return{appState:{...t,...qb(s,{...t,selectedGroupIds:{}},ye(a))},elements:x,captureUpdate:D.IMMEDIATELY}},predicate:(e,t,o,r)=>z2(e,t,r),keyTest:e=>!e.shiftKey&&e[T.CTRL_OR_CMD]&&e.key===T.G,PanelComponent:({elements:e,appState:t,updateData:o,app:r})=>Ba(te,{hidden:!z2(e,t,r),type:"button",icon:Ba(bh,{theme:t.theme}),onClick:()=>o(null),title:`${f("labels.group")} \u2014 ${N("CtrlOrCmd+G")}`,"aria-label":f("labels.group"),visible:Ue(ye(e),t)})}),cg=F({name:"ungroup",label:"labels.ungroup",icon:e=>Ba(xh,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,t,o,r)=>{let n=qo(t),i=q(e);if(n.length===0)return{appState:t,elements:e,captureUpdate:D.EVENTUALLY};let a=[...e],l=[];a=a.map(p=>{He(p)&&l.push(p.id);let u=r0(p.groupIds,t.selectedGroupIds);return u.length===p.groupIds.length?p:re(p,{groupIds:u})});let s=ht(t,ye(a),t,null),c=r.scene.getSelectedElements(t),m=new Set(c.filter(p=>p.frameId).map(p=>p.frameId));return u0(e).filter(p=>m.has(p.id)).forEach(p=>{p&&(a=Bc(a,ea(a,p,t,i),p,r))}),s.selectedElementIds=Object.entries(s.selectedElementIds).reduce((p,[u,h])=>(h&&!l.includes(u)&&(p[u]=!0),p),{}),{appState:{...t,...s},elements:a,captureUpdate:D.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[T.CTRL_OR_CMD]&&e.key===T.G.toUpperCase(),predicate:(e,t)=>qo(t).length>0,PanelComponent:({elements:e,appState:t,updateData:o})=>Ba(te,{type:"button",hidden:qo(t).length===0,icon:Ba(xh,{theme:t.theme}),onClick:()=>o(null),title:`${f("labels.ungroup")} \u2014 ${N("CtrlOrCmd+Shift+G")}`,"aria-label":f("labels.ungroup"),visible:Ue(ye(e),t)})});import GC from"clsx";var gm=(e,t,o,r,n,i,a)=>{e.beginPath(),e.moveTo(t+i,o),e.lineTo(t+r-i,o),e.quadraticCurveTo(t+r,o,t+r,o+i),e.lineTo(t+r,o+n-i),e.quadraticCurveTo(t+r,o+n,t+r-i,o+n),e.lineTo(t+i,o+n),e.quadraticCurveTo(t,o+n,t,o+n-i),e.lineTo(t,o+i),e.quadraticCurveTo(t,o,t+i,o),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};function zC(e){let t=0;if(e.length===0)return t;for(let o=0;o<e.length;o++){let r=e.charCodeAt(o);t=(t<<5)-t+r}return t}var Ni=(e,t)=>`hsl(${Math.abs(zC(t?.id||e))%37*10}, 100%, 83%)`,H2=e=>{let t=e?.trim()?.codePointAt(0);return(t?String.fromCodePoint(t):"?").toUpperCase()},U2=({context:e,renderConfig:t,appState:o,normalizedWidth:r,normalizedHeight:n})=>{for(let[i,a]of t.remotePointerViewportCoords){let{x:l,y:s}=a,c=o.collaborators.get(i);l-=o.offsetLeft,s-=o.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=Ni(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let h=t.remotePointerUserStates.get(i),x=p||h==="idle"||h==="away";x&&(e.globalAlpha=.3),t.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 b=o.theme===se.DARK?"#2f6330":R1,E=c?.isSpeaking;E&&(e.fillStyle=b,e.strokeStyle=b,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=vl,e.strokeStyle=vl,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(),x?(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 w=t.remotePointerUsernames.get(i)||"";if(!p&&w){e.font="600 12px sans-serif";let y=(E?l+0:l)+m/2,v=(E?s+0:s)+d+2,C=5,I=3,L=e.measureText(w),A=L.actualBoundingBoxDescent+L.actualBoundingBoxAscent,R=Math.max(A,12),_=y-1,z=v-1,W=L.width+2+C*2+2,G=R+2+I*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(_,z,W,G,8),e.fillStyle=u,e.fill(),e.strokeStyle=vl,e.stroke(),E&&(e.beginPath(),e.roundRect(_-2,z-2,W+4,G+4,8),e.strokeStyle=b,e.stroke())):gm(e,_,z,W,G,8,vl),e.fillStyle=P1,e.fillText(w,y+C+1,v+I+L.actualBoundingBoxAscent+Math.floor((R-A)/2)+2),E){e.fillStyle=b;let j=8,H=8,B=5;e.fillRect(_+W+H,z+(G/2-j/2),2,j),e.fillRect(_+W+H+B,z+(G/2-j*2/2),2,j*2),e.fillRect(_+W+H+B*2,z+(G/2-j/2),2,j)}}e.restore(),e.closePath()}};import HC from"clsx";import{useState as UC}from"react";import{jsx as G2}from"react/jsx-runtime";var dg=({color:e,onClick:t,name:o,src:r,className:n})=>{let i=H2(o),[a,l]=UC(!1),s=!a&&r,c=s?void 0:{background:e};return G2("div",{className:HC("Avatar",n),style:c,onClick:t,children:s?G2("img",{className:"Avatar-img",src:r,alt:i,referrerPolicy:"no-referrer",onError:()=>l(!0)}):i})};import{jsx as Cr,jsxs as fm}from"react/jsx-runtime";var VC=F({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,t,o)=>!o.socketId||t.userToFollow?.socketId===o.socketId||o.isCurrentUser?{appState:{...t,userToFollow:null},captureUpdate:D.EVENTUALLY}:{appState:{...t,userToFollow:{socketId:o.socketId,username:o.username||""},openMenu:t.openMenu==="canvas"?null:t.openMenu},captureUpdate:D.EVENTUALLY},PanelComponent:({updateData:e,data:t,appState:o})=>{let{socketId:r,collaborator:n,withName:i,isBeingFollowed:a}=t,l=Ni(r,n),s=GC({"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?fm("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:f("userList.hint.isSpeaking"),children:[Cr("div",{}),Cr("div",{}),Cr("div",{})]}):n.isMuted?Cr("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:f("userList.hint.micMuted"),children:oy}):Cr("div",{title:f("userList.hint.inCall"),children:ty}):null;return i?fm("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(n),children:[Cr(dg,{color:l,onClick:()=>{},name:n.username||"",src:n.avatarUrl,className:s}),Cr("div",{className:"UserList__collaborator-name",children:n.username}),fm("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&Cr("div",{className:"UserList__collaborator-status-icon-is-followed",title:f("userList.hint.followStatus"),children:Sa}),c]})]}):fm("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[Cr(dg,{color:l,onClick:()=>{e(n)},name:n.username||"",src:n.avatarUrl,className:s}),c&&Cr("div",{className:"UserList__collaborator-status-icon",children:c})]})}});var mg=F({name:"addToLibrary",trackEvent:{category:"element"},perform:(e,t,o,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let i of hc)if(n.some(a=>a.type===i))return{captureUpdate:D.EVENTUALLY,appState:{...t,errorMessage:f(`errors.libraryElementTypeError.${i}`)}};return r.library.getLatestLibrary().then(i=>r.library.setLibrary([{id:Ht(),status:"unpublished",elements:n.map(mo),created:Date.now()},...i])).then(()=>({captureUpdate:D.EVENTUALLY,appState:{...t,toast:{message:f("toast.addedToLibrary")}}})).catch(i=>({captureUpdate:D.EVENTUALLY,appState:{...t,errorMessage:i.message}}))},label:"labels.addToLibrary"});var V2=(e,t,o)=>{let r=o.getNonDeletedElementsMap(),n=ci(e,r),i=Mt(e);return n.flatMap(a=>{let l=YC(a,i,t);return a.map(s=>{let c=o.mutateElement(s,{x:s.x+l.x,y:s.y+l.y});return gt(s,o,{simultaneouslyUpdated:a}),c})})},YC=(e,t,{axis:o,position:r})=>{let n=Mt(e),[i,a]=o==="x"?["minX","maxX"]:["minY","maxY"],l={x:0,y:0};return r==="start"?{...l,[o]:t[i]-n[i]}:r==="end"?{...l,[o]:t[a]-n[a]}:{...l,[o]:(t[i]+t[a])/2-(n[i]+n[a])/2}};import{jsx as za}from"react/jsx-runtime";var po=(e,t)=>{let o=t.scene.getSelectedElements(e);return o.length>1&&!o.some(r=>J(r))},Fa=(e,t,o,r)=>{let n=o.scene.getSelectedElements(t),i=V2(n,r,o.scene),a=q(i);return xr(e.map(l=>a.get(l.id)||l),t,o)},WC=F({name:"alignTop",label:"labels.alignTop",icon:mh,trackEvent:{category:"element"},predicate:(e,t,o,r)=>po(t,r),perform:(e,t,o,r)=>({appState:t,elements:Fa(e,t,r,{position:"start",axis:"y"}),captureUpdate:D.IMMEDIATELY}),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&e.key===T.ARROW_UP,PanelComponent:({elements:e,appState:t,updateData:o,app:r})=>za(te,{hidden:!po(t,r),type:"button",icon:mh,onClick:()=>o(null),title:`${f("labels.alignTop")} \u2014 ${N("CtrlOrCmd+Shift+Up")}`,"aria-label":f("labels.alignTop"),visible:Ue(ye(e),t)})}),KC=F({name:"alignBottom",label:"labels.alignBottom",icon:ph,trackEvent:{category:"element"},predicate:(e,t,o,r)=>po(t,r),perform:(e,t,o,r)=>({appState:t,elements:Fa(e,t,r,{position:"end",axis:"y"}),captureUpdate:D.IMMEDIATELY}),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&e.key===T.ARROW_DOWN,PanelComponent:({elements:e,appState:t,updateData:o,app:r})=>za(te,{hidden:!po(t,r),type:"button",icon:ph,onClick:()=>o(null),title:`${f("labels.alignBottom")} \u2014 ${N("CtrlOrCmd+Shift+Down")}`,"aria-label":f("labels.alignBottom"),visible:Ue(ye(e),t)})}),ZC=F({name:"alignLeft",label:"labels.alignLeft",icon:uh,trackEvent:{category:"element"},predicate:(e,t,o,r)=>po(t,r),perform:(e,t,o,r)=>({appState:t,elements:Fa(e,t,r,{position:"start",axis:"x"}),captureUpdate:D.IMMEDIATELY}),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&e.key===T.ARROW_LEFT,PanelComponent:({elements:e,appState:t,updateData:o,app:r})=>za(te,{hidden:!po(t,r),type:"button",icon:uh,onClick:()=>o(null),title:`${f("labels.alignLeft")} \u2014 ${N("CtrlOrCmd+Shift+Left")}`,"aria-label":f("labels.alignLeft"),visible:Ue(ye(e),t)})}),XC=F({name:"alignRight",label:"labels.alignRight",icon:hh,trackEvent:{category:"element"},predicate:(e,t,o,r)=>po(t,r),perform:(e,t,o,r)=>({appState:t,elements:Fa(e,t,r,{position:"end",axis:"x"}),captureUpdate:D.IMMEDIATELY}),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&e.key===T.ARROW_RIGHT,PanelComponent:({elements:e,appState:t,updateData:o,app:r})=>za(te,{hidden:!po(t,r),type:"button",icon:hh,onClick:()=>o(null),title:`${f("labels.alignRight")} \u2014 ${N("CtrlOrCmd+Shift+Right")}`,"aria-label":f("labels.alignRight"),visible:Ue(ye(e),t)})}),$C=F({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:gh,trackEvent:{category:"element"},predicate:(e,t,o,r)=>po(t,r),perform:(e,t,o,r)=>({appState:t,elements:Fa(e,t,r,{position:"center",axis:"y"}),captureUpdate:D.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:r})=>za(te,{hidden:!po(t,r),type:"button",icon:gh,onClick:()=>o(null),title:f("labels.centerVertically"),"aria-label":f("labels.centerVertically"),visible:Ue(ye(e),t)})}),jC=F({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:fh,trackEvent:{category:"element"},predicate:(e,t,o,r)=>po(t,r),perform:(e,t,o,r)=>({appState:t,elements:Fa(e,t,r,{position:"center",axis:"x"}),captureUpdate:D.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:r})=>za(te,{hidden:!po(t,r),type:"button",icon:fh,onClick:()=>o(null),title:f("labels.centerHorizontally"),"aria-label":f("labels.centerHorizontally"),visible:Ue(ye(e),t)})});var Y2=(e,t,o)=>{let[r,n,i,a]=o.axis==="x"?["minX","midX","maxX","width"]:["minY","midY","maxY","height"],l=Mt(e),s=ci(e,t).map(p=>[p,Mt(p)]).sort((p,u)=>p[1][n]-u[1][n]),c=0;for(let p of s)c+=p[1][a];let m=(l[a]-c)/(s.length-1);if(m<0){let p=s.findIndex(b=>b[1][r]===l[r]),u=s.findIndex(b=>b[1][i]===l[i]),h=(s[u][1][n]-s[p][1][n])/(s.length-1),x=s[p][1][n];return s.flatMap(([b,E],w)=>{let y={x:0,y:0};return w!==p&&w!==u&&(x+=h,y[o.axis]=x-E[n]),b.map(v=>re(v,{x:v.x+y.x,y:v.y+y.y}))})}let d=l[r];return s.flatMap(([p,u])=>{let h={x:0,y:0};return h[o.axis]=d-u[r],d+=m,d+=u[a],p.map(x=>re(x,{x:x.x+h.x,y:x.y+h.y}))})};import{jsx as Z2}from"react/jsx-runtime";var W2=(e,t)=>{let o=t.scene.getSelectedElements(e);return o.length>1&&!o.some(r=>J(r))},K2=(e,t,o,r)=>{let n=o.scene.getSelectedElements(t),i=Y2(n,o.scene.getNonDeletedElementsMap(),r),a=q(i);return xr(e.map(l=>a.get(l.id)||l),t,o)},qC=F({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,t,o,r)=>({appState:t,elements:K2(e,t,r,{space:"between",axis:"x"}),captureUpdate:D.IMMEDIATELY}),keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===me.H,PanelComponent:({elements:e,appState:t,updateData:o,app:r})=>Z2(te,{hidden:!W2(t,r),type:"button",icon:iE,onClick:()=>o(null),title:`${f("labels.distributeHorizontally")} \u2014 ${N("Alt+H")}`,"aria-label":f("labels.distributeHorizontally"),visible:Ue(ye(e),t)})}),JC=F({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,t,o,r)=>({appState:t,elements:K2(e,t,r,{space:"between",axis:"y"}),captureUpdate:D.IMMEDIATELY}),keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===me.V,PanelComponent:({elements:e,appState:t,updateData:o,app:r})=>Z2(te,{hidden:!W2(t,r),type:"button",icon:aE,onClick:()=>o(null),title:`${f("labels.distributeVertically")} \u2014 ${N("Alt+V")}`,"aria-label":f("labels.distributeVertically"),visible:Ue(ye(e),t)})});var pg=F({name:"flipHorizontal",label:"labels.flipHorizontal",icon:ay,trackEvent:{category:"element"},perform:(e,t,o,r)=>({elements:xr(X2(e,r.scene.getNonDeletedElementsMap(),t,"horizontal",r),t,r),appState:t,captureUpdate:D.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===me.H}),ug=F({name:"flipVertical",label:"labels.flipVertical",icon:iy,trackEvent:{category:"element"},perform:(e,t,o,r)=>({elements:xr(X2(e,r.scene.getNonDeletedElementsMap(),t,"vertical",r),t,r),appState:t,captureUpdate:D.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===me.V&&!e[T.CTRL_OR_CMD]}),X2=(e,t,o,r,n)=>{let i=Q(ye(e),o,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=QC(i,t,o,r,n),l=q(a);return e.map(s=>l.get(s.id)||s)},QC=(e,t,o,r,n)=>{if(e.every(u=>Ie(u)&&(u.startBinding||u.endBinding)))return e.map(u=>{let h=u;return re(h,{startArrowhead:h.endArrowhead,endArrowhead:h.startArrowhead})});let{midX:i,midY:a}=Mt(e);Wu(e,t,"nw",n.scene,new Map(Array.from(t.values()).map(u=>[u.id,mo(u)])),{flipByX:r==="horizontal",flipByY:r==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),Nl(e.filter(le),mi(o),[],n.scene,o.zoom);let{elbowArrows:l,otherElements:s}=e.reduce((u,h)=>ee(h)?{...u,elbowArrows:u.elbowArrows.concat(h)}:{...u,otherElements:u.otherElements.concat(h)},{elbowArrows:[],otherElements:[]}),{midX:c,midY:m}=Mt(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 Ha=F({name:"copy",label:"labels.copy",icon:Ql,trackEvent:{category:"element"},perform:async(e,t,o,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await mm(n,r.files,o)}catch(i){return{captureUpdate:D.EVENTUALLY,appState:{...t,errorMessage:i.message}}}return{captureUpdate:D.EVENTUALLY}},keyTest:void 0}),hg=F({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,t,o,r)=>{let n;try{n=await P2()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),Pr?{captureUpdate:D.EVENTUALLY,appState:{...t,errorMessage:f("hints.firefox_clipboard_write")}}:{captureUpdate:D.EVENTUALLY,appState:{...t,errorMessage:f("errors.asyncPasteFailedOnRead")}})}try{r.pasteFromClipboard(D2({types:n}))}catch(i){return console.error(i),{captureUpdate:D.EVENTUALLY,appState:{...t,errorMessage:f("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:D.EVENTUALLY}},keyTest:void 0}),bm=F({name:"cut",label:"labels.cut",icon:YE,trackEvent:{category:"element"},perform:(e,t,o,r)=>(Ha.perform(e,t,o,r),ss.perform(e,t,null,r)),keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.X}),xm=F({name:"copyAsSvg",label:"labels.copyAsSvg",icon:ly,trackEvent:{category:"element"},perform:async(e,t,o,r)=>{if(!r.canvas)return{captureUpdate:D.EVENTUALLY};let{exportedElements:n,exportingFrame:i}=Di(e,t,!0);try{await _i("clipboard-svg",n,t,r.files,{...t,exportingFrame:i,name:r.getName()});let a=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:f("toast.copyToClipboardAsSvg",{exportSelection:a.length?f("toast.selection"):f("toast.canvas"),exportColorScheme:t.exportWithDarkMode?f("buttons.darkMode"):f("buttons.lightMode")})}},captureUpdate:D.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:D.EVENTUALLY}}},predicate:e=>dm&&e.length>0,keywords:["svg","clipboard","copy"]}),Em=F({name:"copyAsPng",label:"labels.copyAsPng",icon:sy,trackEvent:{category:"element"},perform:async(e,t,o,r)=>{if(!r.canvas)return{captureUpdate:D.EVENTUALLY};let n=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=Di(e,t,!0);try{return await _i("clipboard",i,t,r.files,{...t,exportingFrame:a,name:r.getName()}),{appState:{...t,toast:{message:f("toast.copyToClipboardAsPng",{exportSelection:n.length?f("toast.selection"):f("toast.canvas"),exportColorScheme:t.exportWithDarkMode?f("buttons.darkMode"):f("buttons.lightMode")})}},captureUpdate:D.EVENTUALLY}}catch(l){return console.error(l),{appState:{...t,errorMessage:l.message},captureUpdate:D.EVENTUALLY}}},predicate:e=>Ra&&e.length>0,keyTest:e=>e.code===me.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),ym=F({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,t,o,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0});try{lr(uu(n))}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return{captureUpdate:D.EVENTUALLY}},predicate:(e,t,o,r)=>dm&&r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}).some(K),keywords:["text","clipboard","copy"]});var vm=F({name:"gridMode",icon:uy,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>e.gridModeEnabled},perform(e,t){return{appState:{...t,gridModeEnabled:!this.checked(t),objectsSnapModeEnabled:!1},captureUpdate:D.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,t,o)=>o.gridModeEnabled===void 0,keyTest:e=>e[T.CTRL_OR_CMD]&&e.code===me.QUOTE});var Ua=F({name:"zenMode",label:"buttons.zenMode",icon:dy,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,t){return{appState:{...t,zenModeEnabled:!this.checked(t)},captureUpdate:D.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,t,o)=>typeof o.zenModeEnabled>"u",keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===me.Z});var gg=F({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:cy,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,t){return{appState:{...t,objectsSnapModeEnabled:!this.checked(t),gridModeEnabled:!1},captureUpdate:D.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,t,o)=>typeof o.objectsSnapModeEnabled>"u",keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===me.S});var Ga=F({name:"stats",label:"stats.fullTitle",icon:ny,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,t){return{appState:{...t,stats:{...t.stats,open:!this.checked(t)}},captureUpdate:D.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===me.SLASH});var fg=F({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,t,o,r)=>r.scene.getSelectedElements(t).some(i=>it(i)),perform:(e,t,o,r)=>{let n=r.scene.getSelectedElements(t),i=r.scene.getNonDeletedElementsMap();return n.forEach(a=>{let l=pe(a,i);if(l){let{width:s,height:c}=ut(l.originalText,Ge(l),l.lineHeight),m=Gb(a.id);Ub(a.id);let{x:d,y:p}=Ac(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:t,captureUpdate:D.IMMEDIATELY}}}),bg=F({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,t,o,r)=>{let n=r.scene.getSelectedElements(t);if(n.length===2){let i=K(n[0])||K(n[1]),a;if(Hr(n[0])?a=n[0]:Hr(n[1])&&(a=n[1]),i&&a&&pe(a,r.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,t,o,r)=>{let n=r.scene.getSelectedElements(t),i,a;K(n[0])&&Hr(n[1])?(i=n[0],a=n[1]):(i=n[1],a=n[0]),r.scene.mutateElement(i,{containerId:a.id,verticalAlign:io.MIDDLE,textAlign:Tl.CENTER,autoResize:!0,angle:Ie(a)?0:a?.angle??0}),r.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let l=a.height;return Xe(i,a,r.scene),_l(a.id,l),{elements:e4(e,a,i),appState:{...t,selectedElementIds:{[a.id]:!0}},captureUpdate:D.IMMEDIATELY}}}),e4=(e,t,o)=>{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+1,0,o),At(r,q([t,o])),r},t4=(e,t,o)=>{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,0,t),At(r,q([t,o])),r},$2=F({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,t,o,r)=>{let n=r.scene.getSelectedElements(t),i=n.some(a=>K(a));return n.length>0&&i},perform:(e,t,o,r)=>{let n=r.scene.getSelectedElements(t),i=e.slice(),a={};for(let l of n)if(K(l)){let s=Rt({type:"rectangle",backgroundColor:t.currentItemBackgroundColor,boundElements:[...l.boundElements||[],{id:l.id,type:"text"}],angle:l.angle,fillStyle:t.currentItemFillStyle,strokeColor:t.currentItemStrokeColor,roughness:t.currentItemRoughness,strokeWidth:t.currentItemStrokeWidth,strokeStyle:t.currentItemStrokeStyle,roundness:t.currentItemRoundness==="round"?{type:gn("rectangle")?Ct.ADAPTIVE_RADIUS:Ct.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:l.x-$p,y:l.y-$p,width:qi(l.width,"rectangle"),height:qi(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:io.MIDDLE,boundElements:null,textAlign:Tl.CENTER,autoResize:!0}),Xe(l,s,r.scene),i=t4([...i,s],s,l),a[s.id]=!0}return{elements:i,appState:{...t,selectedElementIds:a},captureUpdate:D.IMMEDIATELY}}});import o4 from"clsx";import{useCallback as j2,useEffect as q2,useLayoutEffect as r4,useRef as n4,useState as i4}from"react";import{jsx as Va,jsxs as J2}from"react/jsx-runtime";var yg=380,a4=42,xg=5,Q2=85,l4=500,Eg=!1,wm=new Map,ev=({element:e,scene:t,setAppState:o,onLinkOpen:r,setToast:n,updateEmbedValidationStatus:i})=>{let a=t.getNonDeletedElementsMap(),l=wr(),s=Tr(),c=Te(),m=e.link||"",[d,p]=i4(m),u=n4(null),h=l.showHyperlinkPopup==="editor",x=j2(()=>{if(!u.current)return;let v=jo(u.current.value)||null;if(!e.link&&v&&fe("hyperlink","create"),Zt(e)){if(l.activeEmbeddable?.element===e&&o({activeEmbeddable:null}),!v){t.mutateElement(e,{link:null}),i(e,!1);return}if(!aa(v,s.validateEmbeddable))v&&n({message:f("toast.unableToEmbed"),closable:!0}),e.link&&wm.set(e.id,e.link),t.mutateElement(e,{link:v}),i(e,!1);else{let{width:C,height:I}=e,L=pi(v);L?.error instanceof URIError&&n({message:f("toast.unrecognizedLinkFormat"),closable:!0});let A=L?L.intrinsicSize.w/L.intrinsicSize.h:1,R=wm.get(e.id)!==e.link;t.mutateElement(e,{...R?{width:L?.type==="video"?C>I?C:I*A:C,height:L?.type==="video"&&C>I?C/A:I}:{},link:v}),i(e,!0),wm.has(e.id)&&wm.delete(e.id)}}else t.mutateElement(e,{link:v})},[e,t,n,s.validateEmbeddable,l.activeEmbeddable,o,i]);r4(()=>()=>{x()},[x]),q2(()=>{h&&u?.current&&!(c.viewport.isMobile||c.isTouchScreen)&&u.current.select()},[h,c.viewport.isMobile,c.isTouchScreen]),q2(()=>{let v=null,C=I=>{if(h)return;v&&clearTimeout(v),c4(e,a,l,M(I.clientX,I.clientY))&&(v=window.setTimeout(()=>{o({showHyperlinkPopup:!1})},l4))};return window.addEventListener("pointermove",C,!1),()=>{window.removeEventListener("pointermove",C,!1),v&&clearTimeout(v)}},[l,e,h,o,a]);let b=j2(()=>{fe("hyperlink","delete"),t.mutateElement(e,{link:null}),o({showHyperlinkPopup:!1})},[o,e,t]),E=()=>{fe("hyperlink","edit","popup-ui"),o({showHyperlinkPopup:"editor"})},{x:w,y}=tv(e,l,a);return l.contextMenu||l.selectedElementsAreBeingDragged||l.resizingElement||l.isRotating||l.openMenu||l.viewModeEnabled?null:J2("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${y}px`,left:`${w}px`,width:yg,padding:xg},children:[h?Va("input",{className:o4("excalidraw-hyperlinkContainer-input"),placeholder:f("labels.link.hint"),ref:u,value:d,onChange:v=>p(v.target.value),autoFocus:!0,onKeyDown:v=>{v.stopPropagation(),v[T.CTRL_OR_CMD]&&v.key===T.K&&v.preventDefault(),(v.key===T.ENTER||v.key===T.ESCAPE)&&(x(),o({showHyperlinkPopup:"info"}))}}):e.link?Va("a",{href:jo(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:Sc(e.link)?"_self":"_blank",onClick:v=>{if(e.link&&r){let C=vc("excalidraw-link",v.nativeEvent);r({...e,link:jo(e.link)},C),C.defaultPrevented&&v.preventDefault()}},rel:"noopener noreferrer",children:e.link}):Va("div",{className:"excalidraw-hyperlinkContainer-link",children:f("labels.link.empty")}),J2("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!h&&Va(te,{type:"button",title:f("buttons.edit"),"aria-label":f("buttons.edit"),label:f("buttons.edit"),onClick:E,className:"excalidraw-hyperlinkContainer--edit",icon:Tn}),Va(te,{type:"button",title:f("labels.linkToElement"),"aria-label":f("labels.linkToElement"),label:f("labels.linkToElement"),onClick:()=>{o({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:Hd}),m&&!Zt(e)&&Va(te,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:b,className:"excalidraw-hyperlinkContainer--remove",icon:vo})]})]})},tv=(e,t,o)=>{let[r,n]=Ve(e,o),{x:i,y:a}=Pt({sceneX:r+e.width/2,sceneY:n},t),l=i-t.offsetLeft-yg/2,s=a-t.offsetTop-Q2;return{x:l,y:s}},vg=(e,t)=>{let o=Q(e,t);return Zt(o[0])?"labels.link.editEmbed":o[0]?.link?"labels.link.edit":"labels.link.create"},ys=null,ov=(e,t,o)=>{ys&&clearTimeout(ys),ys=window.setTimeout(()=>s4(e,t,o),U1)},s4=(e,t,o)=>{if(!e.link)return;let r=_a();r.classList.add("excalidraw-tooltip--visible"),r.style.maxWidth="20rem",r.textContent=ui(e.link)?f("labels.link.goToElement"):e.link;let[n,i,a,l]=Ve(e,o),[s,c,m,d]=W0([n,i,a,l],e.angle,t),p=Pt({sceneX:s,sceneY:c},t);tg(r,{left:p.x,top:p.y,width:m,height:d},"top"),fe("hyperlink","tooltip","link-icon"),Eg=!0},wg=()=>{ys&&clearTimeout(ys),Eg&&(Eg=!1,_a().classList.remove("excalidraw-tooltip--visible"))},c4=(e,t,o,[r,n])=>{let{x:i,y:a}=Ke({clientX:r,clientY:n},o),l=15/o.zoom.value;if(Lb(i,a,e,t))return!1;let[s,c,m]=Ve(e,t);if(i>=s&&i<=m&&a>=c-Q2&&a<=c)return!1;let{x:d,y:p}=tv(e,o,t);return!(r>=d-l&&r<=d+yg+xg*2+l&&n>=p-l&&n<=p+l+xg*2+a4)};import{jsx as d4}from"react/jsx-runtime";var vs=F({name:"hyperlink",label:(e,t)=>vg(e,t),icon:os,perform:(e,t)=>t.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...t,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:D.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.K,predicate:(e,t)=>Q(e,t).length===1,PanelComponent:({elements:e,appState:t,updateData:o})=>{let r=Q(e,t);return d4(te,{type:"button",icon:os,"aria-label":f(vg(e,t)),title:`${Zt(e[0])?f("labels.link.labelEmbed"):f("labels.link.label")} - ${N("CtrlOrCmd+K")}`,onClick:()=>o(null),selected:r.length===1&&!!r[0].link})}});var Tg=e=>e.every(t=>!t.locked),Sg=F({name:"toggleElementLock",label:(e,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1});return r.length===1&&!J(r[0])?r[0].locked?"labels.elementLock.unlock":"labels.elementLock.lock":Tg(r)?"labels.elementLock.lockAll":"labels.elementLock.unlockAll"},icon:(e,t)=>{let o=Q(t,e);return Tg(o)?xa:Ti},trackEvent:{category:"element"},predicate:(e,t,o,r)=>{let n=r.scene.getSelectedElements(t);return n.length>0&&!n.some(i=>i.locked&&i.frameId)},perform:(e,t,o,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!n.length)return!1;let i=Tg(n),a=q(n);return{elements:e.map(l=>a.has(l.id)?re(l,{locked:i}):l),appState:{...t,selectedLinearElement:i?null:t.selectedLinearElement},captureUpdate:D.IMMEDIATELY}},keyTest:(e,t,o,r)=>e.key.toLocaleLowerCase()===T.L&&e[T.CTRL_OR_CMD]&&e.shiftKey&&r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}).length>0}),rv=F({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:Ti,predicate:(e,t)=>Q(e,t).length===0&&e.some(r=>r.locked),perform:(e,t)=>{let o=e.filter(r=>r.locked);return{elements:e.map(r=>r.locked?re(r,{locked:!1}):r),appState:{...t,selectedElementIds:Object.fromEntries(o.map(r=>[r.id,!0]))},captureUpdate:D.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import uw from"clsx";import bk from"fuzzy";import{useEffect as Wm,useRef as xk,useState as Ym}from"react";import{useEffect as Ss,useMemo as nv,useRef as Ig,useState as m4}from"react";import{jsx as Mg}from"react/jsx-runtime";var p4=8,u4=10,ws=["rectangle","diamond","ellipse"],Ts=["line","sharpArrow","curvedArrow","elbowArrow"],h4=new Set(ws),g4=new Set(Ts),Xa=e=>h4.has(e),Cm=e=>e==="arrow"||g4.has(e),sr=ke(null),Ka=ke(null),Za=ke(null),f4=({app:e})=>{let t=rr(Ka),o=rr(Za),r=e.scene.getSelectedElements(e.state),n=Ig(null);return Ss(()=>{if(r.length===0){e.updateEditorAtom(sr,null);return}let i=$a(r);i&&!n.current?n.current=i:(n.current&&!i||n.current&&i!==n.current)&&(e.updateEditorAtom(sr,null),n.current=null)},[r,e]),Ss(()=>()=>{t(null),o(null)},[t,o]),Mg(b4,{app:e,elements:r})},b4=({app:e,elements:t})=>{let o=$a(t),r=nv(()=>o==="generic"?lv(t):[],[o,t]),n=nv(()=>o==="linear"?kg(t):[],[o,t]),i=o==="generic"?r.every(d=>d.type===r[0].type):o==="linear"?n.every(d=>Wa(d)===Wa(n[0])):!1,[a,l]=m4({x:0,y:0}),s=Ig(""),c=Ig(null);Ss(()=>{let d=[...r,...n].sort((b,E)=>b.id.localeCompare(E.id)),p=`
|
|
8
|
-
${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${d.map(b=>b.id).join(",")}`;if(p===s.current)return;s.current=p;let u;if(d.length===1){let[b,,,E,w,y]=Ve(d[0],e.scene.getNonDeletedElementsMap());u=ie(M(b,E),M(w,y),d[0].angle)}else{let{minX:b,maxY:E}=Mt(d);u=M(b,E)}let{x:h,y:x}=Pt({sceneX:u[0],sceneY:u[1]},e.state);l({x:h,y:x})},[r,n,e.scene,e.state]),Ss(()=>{if(!Fe.get(Za))for(let d of n){let p=Wa(d),u=p==="line"?E4(d):p==="sharpArrow"?y4(d):p==="curvedArrow"?v4(d):p==="elbowArrow"?w4(d):{};Fe.set(Za,{...Fe.get(Za),[d.id]:{properties:u,initialType:p}})}},[n]),Ss(()=>{if(!Fe.get(Ka))for(let d of r){let p=pe(d,e.scene.getNonDeletedElementsMap());p&&Fe.set(Ka,{...Fe.get(Ka),[d.id]:{fontSize:p.fontSize,elementType:d.type}})}},[r,e.scene]);let m=o==="linear"?[["line",Sd],["sharpArrow",Od],["curvedArrow",Fd],["elbowArrow",Bd]]:o==="generic"?[["rectangle",vd],["diamond",wd],["ellipse",Td]]:[];return Mg("div",{ref:c,tabIndex:-1,style:{position:"absolute",top:`${a.y+(u4+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-p4}px`,zIndex:2},className:Wt.CONVERT_ELEMENT_TYPE_POPUP,children:m.map(([d,p])=>{let u=i&&(o==="generic"&&r[0].type===d||o==="linear"&&Wa(n[0])===d);return Mg(te,{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&&fe("convertElementType",d,"ui"),Ag(e,{conversionType:o,nextType:d}),c.current?.focus()}},`${t[0].id}${t[0].version}_${d}`)})})},x4=(e,t,o)=>{let r=bn(e,t),n=Dc(e,t),i=fn(t.text,Ge(t),r),a=ut(i,Ge(t),t.lineHeight),l=t.fontSize;for(;(a.width>r||a.height>n)&&l>0;){l-=1;let s={...t,fontSize:l};a=ut(t.text,Ge(s),t.lineHeight)}kt(t,o.getNonDeletedElementsMap(),{fontSize:l,width:a.width,height:a.height}),Xe(t,e,o)},Ag=(e,{conversionType:t,nextType:o,direction:r="right"})=>{if(!t)return!1;let n=e.scene.getSelectedElements(e.state),i=n.reduce((l,s)=>({...l,[s.id]:!0}),{}),a=r==="right"?1:-1;if(t==="generic"){let l=lv(n),c=l.every(m=>m.type===l[0].type)?ws.indexOf(l[0].type):-1;if(o=o??ws[(c+ws.length+a)%ws.length],o&&Xa(o)){let m={};for(let p of l){let u=Sm(p,o,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&&(Fe.get(Ka)?.[p.id]?.elementType===o&&kt(u,e.scene.getNonDeletedElementsMap(),{fontSize:Fe.get(Ka)?.[p.id]?.fontSize??u.fontSize}),x4(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:Ne(p,{type:"selection"})}))}}if(t==="linear"){let l=kg(n),s=Wa(l[0]),m=l.every(p=>Wa(p)===s)?Ts.indexOf(s):-1;if(o=o??Ts[(m+Ts.length+a)%Ts.length],o&&Cm(o)){let p={};for(let h of l){let{properties:x,initialType:b}=Fe.get(Za)?.[h.id]||{};if(b&&x&&ee(h)&&b!=="elbowArrow"&&o!=="elbowArrow"){let E=Sm(h,b,e),w=Sm(b==="line"?yo({...E,...x,type:"line"}):er({...E,...x,type:"arrow"}),o,e);p[w.id]=w}else{let E=Sm(h,o,e);p[E.id]=E}}let u=[];for(let h of e.scene.getElementsIncludingDeleted())p[h.id]?u.push(p[h.id]):u.push(h);e.scene.replaceAllElements(u);for(let h of Object.values(p)){let x=Fe.get(Za)?.[h.id];if(x){let{properties:b,initialType:E}=x;if(E===o){kt(h,e.scene.getNonDeletedElementsMap(),b);continue}}if(ee(h)){let b=T4(h);if(b.length<2)continue;let E=[];for(let y=0;y<b.length-1;y++)E.push({start:b[y],end:b[y+1],index:y+1});let w=oa(h,e.scene.getNonDeletedElementsMap(),{points:b,fixedSegments:E});kt(h,e.scene.getNonDeletedElementsMap(),{...w})}}}let d=kg(e.scene.getSelectedElements(e.state));e.setState(p=>({selectedElementIds:i,selectedLinearElement:d.length===1?new $(d[0],e.scene.getNonDeletedElementsMap()):null,activeTool:Ne(p,{type:"selection"})}))}return!0},$a=e=>{if(e.length===0)return null;let t=!1;for(let o of e){if(Xa(o.type))return"generic";av(o)&&(t=!0)}return t?"linear":null},av=e=>le(e)&&(!Ie(e)||!Ib(e)&&!it(e)),Wa=e=>du(e)?"sharpArrow":mu(e)?"curvedArrow":ee(e)?"elbowArrow":"line",E4=e=>e.type==="line"?{points:e.points,roundness:e.roundness}:{},y4=e=>du(e)?{points:e.points,startArrowhead:e.startArrowhead,endArrowhead:e.endArrowhead,startBinding:e.startBinding,endBinding:e.endBinding,roundness:null}:{},v4=e=>mu(e)?{points:e.points,startArrowhead:e.startArrowhead,endArrowhead:e.endArrowhead,startBinding:e.startBinding,endBinding:e.endBinding,roundness:e.roundness}:{},w4=e=>ee(e)?{points:e.points,startArrowhead:e.startArrowhead,endArrowhead:e.endArrowhead,startBinding:e.startBinding,endBinding:e.endBinding,roundness:null,fixedSegments:e.fixedSegments,startIsSpecial:e.startIsSpecial,endIsSpecial:e.endIsSpecial}:{},lv=e=>e.filter(t=>Xa(t.type)),kg=e=>e.filter(t=>av(t)),Tm=20,Ya=(e,t)=>e[0]===t[0],Cg=(e,t)=>e[1]===t[1],iv=(e,t)=>Ya(e,t)?Math.abs(e[1]-t[1]):Math.abs(e[0]-t[0]),T4=e=>{let t=[e.points[0]],o=S4(e.points);for(let i=1;i<o.length;++i){let a=t[t.length-1],l=[...o[i]];Math.abs(l[0]-a[0])<Tm?l[0]=a[0]:Math.abs(l[1]-a[1])<Tm&&(l[1]=a[1]),Ya(a,l)||Cg(a,l)||t.push(M(a[0],l[1])),t.push(l)}let r=[t[0]];for(let i=1;i<t.length-1;++i)Ya(t[i-1],t[i])&&Ya(t[i],t[i+1])||Cg(t[i-1],t[i])&&Cg(t[i],t[i+1])||r.push(t[i]);r.push(t[t.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=Ya(a,l),m=Ya(l,s);if(c!==m){let d=iv(a,l),p=iv(l,s);if(d<Tm||p<Tm){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},S4=e=>{if(e.length===0)return[];let t=[e[0]];for(let o=1;o<e.length;o++){let[r,n]=t[t.length-1],[i,a]=e[o];(r!==i||n!==a)&&t.push(e[o])}return t},Sm=(e,t,o)=>{if(!C4(e.type,t)){if(!bb())throw Error(`Invalid conversion from ${e.type} to ${t}.`);return e}if(e.type===t)return e;if(Er.delete(e),Xa(t)){let r=Jo(Rt({...e,type:t,roundness:t==="diamond"&&e.roundness?{type:gn(t)?Ct.ADAPTIVE_RADIUS:Ct.PROPORTIONAL_RADIUS}:e.roundness}));return En(r,o.scene),r}if(Cm(t))switch(t){case"line":return Jo(yo({...e,type:"line"}));case"sharpArrow":return Jo(er({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:o.state.currentItemStartArrowhead,endArrowhead:o.state.currentItemEndArrowhead}));case"curvedArrow":return Jo(er({...e,type:"arrow",elbowed:!1,roundness:{type:Ct.PROPORTIONAL_RADIUS},startArrowhead:o.state.currentItemStartArrowhead,endArrowhead:o.state.currentItemEndArrowhead}));case"elbowArrow":return Jo(er({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return Xo(t,`unhandled conversion type: ${t}`),e},C4=(e,t)=>!!(Xa(e)&&Xa(t)||Cm(e)&&Cm(t)),sv=f4;var cv=F({name:"toggleShapeSwitch",label:"labels.shapeSwitch",icon:()=>null,viewMode:!0,trackEvent:{category:"shape_switch",action:"toggle"},keywords:["change","switch","swap"],perform(e,t,o,r){return Fe.set(sr,{type:"panel"}),{captureUpdate:D.NEVER}},checked:e=>e.gridModeEnabled,predicate:(e,t,o)=>$a(e)!==null});var Im=F({name:"copyElementLink",label:"labels.copyElementLink",icon:wa,trackEvent:{category:"element"},perform:async(e,t,o,r)=>{let n=Q(e,t);try{if(window.location){let i=jc(n,t);return i?(await lr(r.props.generateLinkForSelection?r.props.generateLinkForSelection(i.id,i.type):$c(i.id,i.type)),{appState:{toast:{message:f("toast.elementLinkCopied"),closable:!0}},captureUpdate:D.EVENTUALLY}):{appState:t,elements:e,app:r,captureUpdate:D.EVENTUALLY}}}catch(i){console.error(i)}return{appState:t,elements:e,app:r,captureUpdate:D.EVENTUALLY}},predicate:(e,t)=>qc(Q(e,t))}),dv=F({name:"linkToElement",label:"labels.linkToElement",icon:Hd,perform:(e,t,o,r)=>{let n=Q(e,t);return n.length!==1||!qc(n)?{elements:e,appState:t,app:r,captureUpdate:D.EVENTUALLY}:{appState:{...t,openDialog:{name:"elementLinkSelector",sourceElementId:Q(e,t)[0].id}},captureUpdate:D.IMMEDIATELY}},predicate:(e,t,o,r)=>{let n=Q(e,t);return t.openDialog?.name!=="elementLinkSelector"&&n.length===1&&qc(n)},trackEvent:!1});var I4={toggleTheme:[N("Shift+Alt+D")],saveScene:[N("CtrlOrCmd+S")],loadScene:[N("CtrlOrCmd+O")],clearCanvas:[N("CtrlOrCmd+Delete")],imageExport:[N("CtrlOrCmd+Shift+E")],commandPalette:[N("CtrlOrCmd+/"),N("CtrlOrCmd+Shift+P")],cut:[N("CtrlOrCmd+X")],copy:[N("CtrlOrCmd+C")],paste:[N("CtrlOrCmd+V")],copyStyles:[N("CtrlOrCmd+Alt+C")],pasteStyles:[N("CtrlOrCmd+Alt+V")],selectAll:[N("CtrlOrCmd+A")],deleteSelectedElements:[N("Delete")],duplicateSelection:[N("CtrlOrCmd+D"),N(`Alt+${f("helpDialog.drag")}`)],sendBackward:[N("CtrlOrCmd+[")],bringForward:[N("CtrlOrCmd+]")],sendToBack:[Wo?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")],bringToFront:[Wo?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")],copyAsPng:[N("Shift+Alt+C")],group:[N("CtrlOrCmd+G")],ungroup:[N("CtrlOrCmd+Shift+G")],gridMode:[N("CtrlOrCmd+'")],zenMode:[N("Alt+Z")],objectsSnapMode:[N("Alt+S")],stats:[N("Alt+/")],addToLibrary:[],flipHorizontal:[N("Shift+H")],flipVertical:[N("Shift+V")],viewMode:[N("Alt+R")],hyperlink:[N("CtrlOrCmd+K")],toggleElementLock:[N("CtrlOrCmd+Shift+L")],resetZoom:[N("CtrlOrCmd+0")],zoomOut:[N("CtrlOrCmd+-")],zoomIn:[N("CtrlOrCmd++")],zoomToFitSelection:[N("Shift+3")],zoomToFit:[N("Shift+1")],zoomToFitSelectionInViewport:[N("Shift+2")],toggleEraserTool:[N("E")],toggleHandTool:[N("H")],setFrameAsActiveTool:[N("F")],saveFileToDisk:[N("CtrlOrCmd+S")],saveToActiveFile:[N("CtrlOrCmd+S")],toggleShortcuts:[N("?")],searchMenu:[N("CtrlOrCmd+F")],wrapSelectionInFrame:[]},st=(e,t=0)=>{let o=I4[e];return o&&o.length>0?o[t]||o[0]:""};var k4="\\u0300-\\u036f",M4="\\ufe20-\\ufe2f",A4="\\u20d0-\\u20ff",L4=k4+M4+A4,D4=`[${L4}]`,_4=RegExp(D4,"g"),P4=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,R4={\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"},Lg=e=>e.replace(P4,t=>R4[t]||t).replace(_4,"");import JI from"clsx";import{useEffect as QI,useState as ek}from"react";import{useCallback as N4,useState as O4}from"react";var mv=()=>{let[e,t]=O4(null),o=N4(r=>t(r),[]);return[e,o]};import{useState as Jv,useCallback as Ug,useMemo as Qv,useEffect as $v,memo as ew,useRef as WI}from"react";import{useEffect as gv,useRef as fv}from"react";var Dn=({elements:e,appState:t,files:o,maxWidthOrHeight:r,getDimensions:n,exportPadding:i,exportingFrame:a})=>{let{elements:l,appState:s}=ma({elements:e,appState:t},null,null),{exportBackground:c,viewBackgroundColor:m}=s;return nd(l,{...s,offsetTop:0,offsetLeft:0,width:0,height:0},o||{},{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 x=Math.max(d,p),b=r<x?r/x:t?.exportScale??1;return u.width=d*b,u.height=p*b,{canvas:u,scale:b}}let h=n?.(d,p)||{width:d,height:p};return u.width=h.width,u.height=h.height,{canvas:u,scale:h.scale??1}})},pv=async e=>{let{mimeType:t=ge.png,quality:o}=e;t===ge.png&&typeof o=="number"&&console.warn(`"quality" will be ignored for "${ge.png}" mimeType`),t==="image/jpg"&&(t=ge.jpg),t===ge.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${ge.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let r=await Dn(e);return o=o||(/image\/jpe?g/.test(t)?.92:.8),new Promise((n,i)=>{r.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&t===ge.png&&e.appState?.exportEmbedScene&&(a=await Q0({blob:a,metadata:Wl(e.elements,e.appState,e.files||{},"local")})),n(a)},t,o)})},ja=async({elements:e,appState:t=wn(),files:o={},exportPadding:r,renderEmbeddables:n,exportingFrame:i,skipInliningFonts:a,reuseImages:l})=>{let{elements:s,appState:c}=ma({elements:e,appState:t},null,null),m={...c,exportPadding:r};return da(s,m,o,{exportingFrame:i,renderEmbeddables:n,skipInliningFonts:a,reuseImages:l})},B4=async e=>{if(e.type==="svg"){let t=await ja(e);await lr(t.outerHTML)}else if(e.type==="png")await um(pv(e));else if(e.type==="json")await mm(e.elements,e.files);else throw new Error("Invalid export type")};import{useEffect as F4,useState as z4}from"react";var Dg=ke(new Map),uv=async e=>await ja({elements:e,appState:{exportBackground:!1,viewBackgroundColor:no.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),hv=(e,t,o)=>{let[r,n]=z4();return F4(()=>{if(t)if(e){let i=o.get(e);i?n(i):(async()=>{let a=await uv(t);a.querySelector(".style-fonts")?.remove(),a&&(o.set(e,a),n(a))})()}else(async()=>{let i=await uv(t);n(i)})()},[e,t,o,n]),r},km=()=>{let[e]=ve(Dg);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:r=>{r.forEach(n=>e.delete(n))},svgCache:e}};var H4=["excalidraw.com","raw.githubusercontent.com/excalidraw/excalidraw-libraries"],xv=new Kt,Oi=ke({status:"loaded",isInitialized:!1,libraryItems:[]}),Cs=e=>lo(e),U4=(e,t)=>!e.find(o=>o.elements.length!==t.elements.length?!1:o.elements.every((r,n)=>r.id===t.elements[n].id&&r.versionNonce===t.elements[n].versionNonce)),Ev=(e,t)=>{let o=[];for(let r of t)U4(e,r)&&o.push(r);return[...o,...e]},yv=(e,t)=>{let o=q(t),r={deletedItems:new Map,addedItems:new Map};for(let i of e)o.has(i.id)||r.deletedItems.set(i.id,i);let n=q(e);for(let i of t)n.has(i.id)||r.addedItems.set(i.id,i);return r},_g=class{constructor(t){S(this,"currLibraryItems",[]);S(this,"prevLibraryItems",Cs(this.currLibraryItems));S(this,"app");S(this,"updateQueue",[]);S(this,"getLastUpdateTask",()=>this.updateQueue[this.updateQueue.length-1]);S(this,"notifyListeners",()=>{if(this.updateQueue.length>0)Fe.set(Oi,t=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:t.isInitialized}));else{Fe.set(Oi,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let t=this.prevLibraryItems;this.prevLibraryItems=Cs(this.currLibraryItems);let o=Cs(this.currLibraryItems);this.app.props.onLibraryChange?.(o),xv.trigger(yv(t,o),o)}catch(t){console.error(t)}}});S(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],Fe.set(Dg,new Map)});S(this,"resetLibrary",()=>this.setLibrary([]));S(this,"getLatestLibrary",()=>new Promise(async t=>{try{let o=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?t(this.getLatestLibrary()):t(Cs(o))}catch{return t(this.currLibraryItems)}}));S(this,"updateLibrary",async({libraryItems:t,prompt:o=!1,merge:r=!1,openLibraryMenu:n=!1,defaultStatus:i="unpublished"})=>(n&&this.app.setState({openSidebar:{name:zt.name,tab:Sl}}),this.setLibrary(()=>new Promise(async(a,l)=>{try{let s=await(typeof t=="function"&&!(t instanceof Blob)?t(this.currLibraryItems):t),c;s instanceof Blob?c=await Bu(s,i):c=Xl(s,i),!o||window.confirm(f("alerts.confirmAddLibrary",{numShapes:c.length}))?(o&&this.app.focusContainer(),a(r?Ev(this.currLibraryItems,c):c)):l(new sa)}catch(s){l(s)}}))));S(this,"setLibrary",t=>{let o=new Promise(async(r,n)=>{try{await this.getLastUpdateTask(),typeof t=="function"&&(t=t(this.currLibraryItems)),this.currLibraryItems=Cs(await t),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!==o),this.notifyListeners()});return this.updateQueue.push(o),this.notifyListeners(),o});this.app=t}},vv=_g,Lm=e=>{let o=Math.ceil(Math.sqrt(e.length)),r=[],n=u=>e.slice(u*o,u*o+o).reduce((x,b)=>{let{height:E}=Mt(b.elements);return Math.max(x,E)},0),i=u=>{let h=0,x=0,b=0;for(let E of e){if(h%o===0&&(x=0),x===u){let{width:w}=Mt(E.elements);b=Math.max(b,w)}h++,x++}return b},a=0,l=0,s=0,c=0,m=0,d=0,p=0;for(let u of e){m&&m%o===0&&(l+=s+50,a=0,d=0,p++),d===0&&(s=n(p)),c=i(d);let{minX:h,minY:x,width:b,height:E}=Mt(u.elements),w=(c-b)/2,y=(s-E)/2;r.push(...u.elements.map(v=>({...v,x:v.x+a+w-h,y:v.y+l+y-x}))),a+=c+50,m++,d++}return r},G4=(e,t=H4)=>{if(typeof t=="function"?t(e):t.some(o=>{let r=new URL(`https://${o.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}"`)},Pg=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(dc.addLibrary)||new URLSearchParams(window.location.search).get(cc.addLibrary),t=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:t}:null},_n=class _n{constructor(t){S(this,"adapter");this.adapter=t}static async getLibraryItems(t,o,r=!0){let n=()=>new Promise(async(i,a)=>{try{let l=await t.load({source:o});i(Xl(l?.libraryItems||[],"published"))}catch(l){a(l)}});return r?_n.queue.push(n):n()}getLibraryItems(t){return _n.getLibraryItems(this.adapter,t,!1)}};S(_n,"queue",new Q1),S(_n,"run",async(t,o)=>{let r=new _n(t);return _n.queue.push(()=>o(r))});var qa=_n,Is=0,Mm=0,Am=e=>Vl(e.map(t=>`${t.id}:${Gl(t.elements)}`).sort().join()),bv=async(e,t)=>{try{return Mm++,await qa.run(e,async o=>{let r=q(await o.getLibraryItems("save"));for(let[l]of t.deletedItems)r.delete(l);let n=[];for(let[l,s]of t.addedItems)r.has(l)?r.set(l,s):n.push(s);let i=n.concat(Array.from(r.values())),a=Am(i);return a!==Is&&await e.save({libraryItems:i}),Is=a,i})}finally{Mm--}},V4=e=>{let{excalidrawAPI:t}=e,o=fv(e);o.current=e;let r=fv(!1);gv(()=>{if(!t)return;r.current=!1;let n=async({libraryUrl:l,idToken:s})=>{let c=new Promise(async(d,p)=>{try{l=decodeURIComponent(l),l=Cc(l),G4(l,o.current.validateLibraryUrl);let h=await(await fetch(l)).blob();d(h)}catch(u){p(u)}}),m=s!==t.id;await(m&&document.hidden?new Promise(d=>{window.addEventListener("focus",()=>d(),{once:!0})}):null);try{await t.updateLibrary({libraryItems:c,prompt:m,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(d){throw t.updateScene({appState:{errorMessage:d.message}}),d}finally{if(window.location.hash.includes(dc.addLibrary)){let d=new URLSearchParams(window.location.hash.slice(1));d.delete(dc.addLibrary),window.history.replaceState({},xl,`#${d.toString()}`)}else if(window.location.search.includes(cc.addLibrary)){let d=new URLSearchParams(window.location.search);d.delete(cc.addLibrary),window.history.replaceState({},xl,`?${d.toString()}`)}}},i=l=>{l.preventDefault();let s=Pg();s&&(l.stopImmediatePropagation(),window.history.replaceState({},"",l.oldURL),n(s))},a=Pg();if(a&&n(a),"getInitialLibraryItems"in o.current&&o.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(o.current.getInitialLibraryItems()).then(l=>{t.updateLibrary({libraryItems:l,merge:!0})}).catch(l=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${l?.message}`)})),"adapter"in o.current&&o.current.adapter){let l=o.current.adapter,s=o.current.migrationAdapter,c=cb();s?c.resolve(su(s.load).then(async m=>{let d=null;try{if(!m)return qa.getLibraryItems(l,"load");d=Xl(m.libraryItems||[],"published");let p=await bv(l,yv([],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}`),qa.getLibraryItems(l,"load")))):c.resolve(su(qa.getLibraryItems,l,"load")),t.updateLibrary({libraryItems:c.then(m=>{let d=m||[];return Is=Am(d),d}),merge:!0}).finally(()=>{r.current=!0})}return window.addEventListener("hashchange",i),()=>{window.removeEventListener("hashchange",i)}},[t]),gv(()=>{let n=xv.on(async(a,l)=>{let s=r.current,c="adapter"in o.current&&o.current.adapter||null;try{c&&Is!==Am(l)&&await bv(c,a)}catch(m){console.error(`couldn't persist library update: ${m.message}`,a),s&&o.current.excalidrawAPI&&o.current.excalidrawAPI.updateScene({appState:{errorMessage:f("errors.saveLibraryError")}})}}),i=a=>{Mm&&pb(a)};return window.addEventListener("beforeunload",i),()=>{window.removeEventListener("beforeunload",i),n(),Is=0,Mm=0}},[])};import K4 from"clsx";import{jsx as W4}from"react/jsx-runtime";var Y4=({theme:e,id:t,libraryReturnUrl:o})=>{let r=o||window.location.origin+window.location.pathname;return W4("a",{className:"library-menu-browse-button",href:`${k.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${r}&useHash=true&token=${t}&theme=${e}&version=${pc.excalidrawLibrary}`,target:"_excalidraw_libraries",children:f("labels.libraries")})},wv=Y4;import{jsx as Z4,jsxs as X4}from"react/jsx-runtime";var Dm=({libraryReturnUrl:e,theme:t,id:o,style:r,children:n,className:i})=>X4("div",{className:K4("library-menu-control-buttons",i),style:r,children:[Z4(wv,{id:o,libraryReturnUrl:e,theme:t}),n]});import{useCallback as el,useEffect as HI,useMemo as Zv,useRef as UI,useState as GI}from"react";import $4 from"lodash.throttle";import{useEffect as j4}from"react";var q4=ke(0),Tv=e=>{let[t,o]=ve(q4);return j4(()=>{let{current:r}=e;if(!r)return;let n=$4(()=>{let{scrollTop:i}=r;o(i)},200);return r.addEventListener("scroll",n),()=>{n.cancel(),r.removeEventListener("scroll",n)}},[e,o]),t};import SI from"clsx";import{useCallback as CI,useState as Og}from"react";import{flushSync as Sv}from"react-dom";import J4 from"clsx";import{jsx as _m,jsxs as eI}from"react/jsx-runtime";var Q4=({label:e,onClick:t,className:o,children:r,actionType:n,type:i="button",isLoading:a,...l})=>{let s=n?`Dialog__action-button--${n}`:"";return eI("button",{className:J4("Dialog__action-button",s,o),type:i,"aria-label":e,onClick:t,...l,children:[r&&_m("div",{style:a?{visibility:"hidden"}:{},children:r}),_m("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&_m("div",{style:{position:"absolute",inset:0},children:_m(Ot,{})})]})},Xr=Q4;import{jsx as Cv,jsxs as Iv}from"react/jsx-runtime";var tI=e=>{let{onConfirm:t,onCancel:o,children:r,confirmText:n=f("buttons.confirm"),cancelText:i=f("buttons.cancel"),className:a="",...l}=e,s=Se(),c=rr(Ja),{container:m}=ft();return Iv(ct,{onCloseRequest:o,size:"small",...l,className:`confirm-dialog ${a}`,children:[r,Iv("div",{className:"confirm-dialog-buttons",children:[Cv(Xr,{label:i,onClick:()=>{s({openMenu:null}),c(!1),Sv(()=>{o()}),m?.focus()}}),Cv(Xr,{label:n,onClick:()=>{s({openMenu:null}),c(!1),Sv(()=>{t()}),m?.focus()},actionType:"danger"})]})]})},Pm=tI;import Nm from"open-color";import{useCallback as sI,useEffect as Ng,useRef as kv,useState as Rg}from"react";var Fo=class{static has(t){try{return!!window.localStorage.getItem(t)}catch(o){return console.warn(`localStorage.getItem error: ${o.message}`),!1}}static get(t){try{let o=window.localStorage.getItem(t);return o?JSON.parse(o):null}catch(o){return console.warn(`localStorage.getItem error: ${o.message}`),null}}};S(Fo,"set",(t,o)=>{try{return window.localStorage.setItem(t,JSON.stringify(o)),!0}catch(r){return console.warn(`localStorage.setItem error: ${r.message}`),!1}}),S(Fo,"delete",t=>{try{window.localStorage.removeItem(t)}catch(o){console.warn(`localStorage.removeItem error: ${o.message}`)}});import Rm from"react";var oI=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,rI=/{{([\w-]+)}}/,nI=/<([\w-]+)>/,iI=/<\/([\w-]+)>/,aI=(e,t)=>{let o=[{name:"",children:[]}];return e.split(oI).filter(Boolean).forEach(r=>{let n=r.match(nI),i=r.match(iI),a=r.match(rI);if(n!==null){let l=n[1];t.hasOwnProperty(l)?o.push({name:l,children:[]}):console.warn(`Trans: missed to pass in prop ${l} for interpolating ${e}`)}else if(i!==null)if(i[1]===o[o.length-1].name){let s=o.pop(),c=Rm.createElement(Rm.Fragment,{},...s.children),m=t[s.name];typeof m=="function"&&o[o.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];t.hasOwnProperty(l)?o[o.length-1].children.push(t[l]):console.warn(`Trans: key ${l} not in props for interpolating ${e}`)}else o[o.length-1].children.push(r)}),o.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),o[0].children},lI=({i18nKey:e,children:t,...o})=>{let{t:r}=dt();return Rm.createElement(Rm.Fragment,{},...aI(r(e),o))},qt=lI;import{jsx as we,jsxs as Vt}from"react/jsx-runtime";var cI=async e=>{let r=Math.round(8),n=Math.max(Math.round(128/64),2),i=sb(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=Nm.white,l.fillRect(0,0,a.width,a.height);for(let[s,c]of e.entries()){let m=await Dn({elements:c.elements,files:null,maxWidthOrHeight:128}),{width:d,height:p}=m,u=Math.floor(s/6)*(128+r*2),h=s%6*(128+r*2);l.drawImage(m,h+(128-d)/2+r,u+(128-p)/2+r),l.lineWidth=n,l.strokeStyle=Nm.gray[4],l.strokeRect(h+r/2,u+r/2,128+r,128+r)}return await $l(new File([await Gr(a)],"preview",{type:ge.png}),{outputType:ge.jpg,maxWidthOrHeight:5e3})},dI=({libItem:e,appState:t,index:o,onChange:r,onRemove:n})=>{let i=kv(null),a=kv(null);return Ng(()=>{let l=i.current;l&&(async()=>{let s=await ja({elements:e.elements,appState:{...t,viewBackgroundColor:Nm.white,exportBackground:!0},files:null,skipInliningFonts:!0});l.innerHTML=s.outerHTML})()},[e.elements,t]),Vt("div",{className:"single-library-item",children:[e.status==="published"&&we("span",{className:"single-library-item-status",children:f("labels.statusPublished")}),we("div",{ref:i,className:"single-library-item__svg"}),we(te,{"aria-label":f("buttons.remove"),type:"button",icon:Po,className:"single-library-item--remove",onClick:n.bind(null,e.id),title:f("buttons.remove")}),Vt("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[Vt("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[Vt("div",{style:{padding:"0.5em 0"},children:[we("span",{style:{fontWeight:500,color:Nm.gray[6]},children:f("publishDialog.itemName")}),we("span",{"aria-hidden":"true",className:"required",children:"*"})]}),we("input",{type:"text",ref:a,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:l=>{r(l.target.value,o)}})]}),we("span",{className:"error",children:e.error})]})]})},mI=({onClose:e,libraryItems:t,appState:o,onSuccess:r,onError:n,updateItemsInStorage:i,onRemove:a})=>{let[l,s]=Rg({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[c,m]=Rg(!1);Ng(()=>{let y=Fo.get(cn.PUBLISH_LIBRARY);y&&s(y)},[]);let[d,p]=Rg(t.slice());Ng(()=>{p(t.slice())},[t]);let u=y=>{s({...l,[y.target.name]:y.target.value})},h=async y=>{y.preventDefault(),m(!0);let v=[],C=!1;if(d.forEach(z=>{let W="";z.name||(W=f("publishDialog.errors.required"),C=!0),v.push({...z,error:W})}),C){p(v),m(!1);return}let I=await cI(d),L={type:ln.excalidrawLibrary,version:pc.excalidrawLibrary,source:O1,libraryItems:d},A=JSON.stringify(L,null,2),R=new Blob([A],{type:"application/json"}),_=new FormData;_.append("excalidrawLib",R),_.append("previewImage",I),_.append("previewImageType",I.type),_.append("title",l.name),_.append("authorName",l.authorName),_.append("githubHandle",l.githubHandle),_.append("name",l.name),_.append("description",l.description),_.append("twitterHandle",l.twitterHandle),_.append("website",l.website),fetch(`${k.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:_}).then(z=>z.ok?z.json().then(({url:W})=>{Fo.delete(cn.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)})},x=()=>{let y=[];return d.forEach((v,C)=>{y.push(we("div",{className:"single-library-item-wrapper",children:we(dI,{libItem:v,appState:o,index:C,onChange:(I,L)=>{let A=d.slice();A[L].name=I,p(A)},onRemove:a})},C))}),we("div",{className:"selected-library-items",children:y})},b=sI(()=>{i(d),Fo.set(cn.PUBLISH_LIBRARY,l),e()},[d,e,i,l]),E=!!t.length,w=t.some(y=>y.status==="published");return we(ct,{onCloseRequest:b,title:f("publishDialog.title"),className:"publish-library",children:E?Vt("form",{onSubmit:h,children:[we("div",{className:"publish-library-note",children:we(qt,{i18nKey:"publishDialog.noteDescription",link:y=>we("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener",children:y})})}),we("span",{className:"publish-library-note",children:we(qt,{i18nKey:"publishDialog.noteGuidelines",link:y=>we("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:y})})}),we("div",{className:"publish-library-note",children:f("publishDialog.noteItems")}),w&&we("span",{className:"publish-library-note publish-library-warning",children:f("publishDialog.republishWarning")}),x(),Vt("div",{className:"publish-library__fields",children:[Vt("label",{children:[Vt("div",{children:[we("span",{children:f("publishDialog.libraryName")}),we("span",{"aria-hidden":"true",className:"required",children:"*"})]}),we("input",{type:"text",name:"name",required:!0,value:l.name,onChange:u,placeholder:f("publishDialog.placeholder.libraryName")})]}),Vt("label",{style:{alignItems:"flex-start"},children:[Vt("div",{children:[we("span",{children:f("publishDialog.libraryDesc")}),we("span",{"aria-hidden":"true",className:"required",children:"*"})]}),we("textarea",{name:"description",rows:4,required:!0,value:l.description,onChange:u,placeholder:f("publishDialog.placeholder.libraryDesc")})]}),Vt("label",{children:[Vt("div",{children:[we("span",{children:f("publishDialog.authorName")}),we("span",{"aria-hidden":"true",className:"required",children:"*"})]}),we("input",{type:"text",name:"authorName",required:!0,value:l.authorName,onChange:u,placeholder:f("publishDialog.placeholder.authorName")})]}),Vt("label",{children:[we("span",{children:f("publishDialog.githubUsername")}),we("input",{type:"text",name:"githubHandle",value:l.githubHandle,onChange:u,placeholder:f("publishDialog.placeholder.githubHandle")})]}),Vt("label",{children:[we("span",{children:f("publishDialog.twitterUsername")}),we("input",{type:"text",name:"twitterHandle",value:l.twitterHandle,onChange:u,placeholder:f("publishDialog.placeholder.twitterHandle")})]}),Vt("label",{children:[we("span",{children:f("publishDialog.website")}),we("input",{type:"text",name:"website",pattern:"https?://.+",title:f("publishDialog.errors.website"),value:l.website,onChange:u,placeholder:f("publishDialog.placeholder.website")})]}),we("span",{className:"publish-library-note",children:we(qt,{i18nKey:"publishDialog.noteLicense",link:y=>we("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:y})})})]}),Vt("div",{className:"publish-library__buttons",children:[we(Xr,{label:f("buttons.cancel"),onClick:b,"data-testid":"cancel-clear-canvas-button"}),we(Xr,{type:"submit",label:f("buttons.submit"),actionType:"primary",isLoading:c})]})]}):we("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:f("publishDialog.atleastOneLibItem")})})},Mv=mI;import hI from"clsx";import{useEffect as gI,useRef as fI}from"react";import{forwardRef as Av}from"react";import Lv from"clsx";import{jsx as Dv}from"react/jsx-runtime";var pI=Av(({children:e,gap:t,align:o,justifyContent:r,className:n,style:i},a)=>Dv("div",{className:Lv("Stack Stack_horizontal",n),style:{"--gap":t,alignItems:o,justifyContent:r,...i},ref:a,children:e})),uI=Av(({children:e,gap:t,align:o,justifyContent:r,className:n,style:i},a)=>Dv("div",{className:Lv("Stack Stack_vertical",n),style:{"--gap":t,justifyItems:o,justifyContent:r,...i},ref:a,children:e})),Lt={Row:pI,Col:uI};import{jsx as Om}from"react/jsx-runtime";var _v=({children:e,onClickOutside:t,className:o="",onSelect:r,style:n})=>{let i=Te(),a=fI(null),l=Sn({onClickOutside:t});Ca(a,()=>{l.onClickOutside?.()}),gI(()=>{let c=d=>{d.key===T.ESCAPE&&(d.stopImmediatePropagation(),l.onClickOutside?.())},m={capture:!0};return document.addEventListener("keydown",c,m),()=>{document.removeEventListener("keydown",c,m)}},[l]);let s=hI(`dropdown-menu ${o}`,{"dropdown-menu--mobile":i.editor.isMobile}).trim();return Om(Vh.Provider,{value:{onSelect:r},children:Om("div",{ref:a,className:s,style:n,"data-testid":"dropdown-menu",children:i.editor.isMobile?Om(Lt.Col,{className:"dropdown-menu-container",children:e}):Om(wt,{className:"dropdown-menu-container",padding:2,style:{zIndex:2},children:e})})})};_v.displayName="DropdownMenuContent";var Pv=_v;import{jsx as xI}from"react/jsx-runtime";var bI=({children:e,className:t="",selected:o,...r})=>xI("div",{...r,className:`dropdown-menu-item-base dropdown-menu-item-custom ${t} ${o?"dropdown-menu-item--selected":""}`.trim(),children:e}),Rv=bI;import{jsx as Nv}from"react/jsx-runtime";var Ov=({icon:e,shortcut:t,href:o,children:r,onSelect:n,className:i="",selected:a,rel:l="noopener",...s})=>{let c=em(s.onClick,n);return Nv("a",{...s,href:o,target:"_blank",rel:l||"noopener",className:Qd(i,a),title:s.title??s["aria-label"],onClick:c,children:Nv(Jd,{icon:e,shortcut:t,children:r})})},Qa=Ov;Ov.displayName="DropdownMenuItemLink";import{jsx as EI}from"react/jsx-runtime";var Bv=()=>EI("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0"}}),Fv=Bv;Bv.displayName="DropdownMenuSeparator";import yI from"clsx";import{jsx as vI}from"react/jsx-runtime";var zv=({className:e="",children:t,onToggle:o,title:r,...n})=>{let i=Te(),a=yI(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.editor.isMobile}).trim();return vI("button",{"data-prevent-outside-click":!0,className:a,onClick:o,type:"button","data-testid":"dropdown-menu-button",title:r,...n,children:t})},Hv=zv;zv.displayName="DropdownMenuTrigger";import Bm from"react";var Uv=e=>{let t=Bm.Children.toArray(e).find(o=>Bm.isValidElement(o)&&typeof o.type!="string"&&o?.type.displayName&&o.type.displayName==="DropdownMenuTrigger");return t||null},Gv=e=>{let t=Bm.Children.toArray(e).find(o=>Bm.isValidElement(o)&&typeof o.type!="string"&&o?.type.displayName&&o.type.displayName==="DropdownMenuContent");return t||null};import{Fragment as wI,jsxs as TI}from"react/jsx-runtime";var $r=({children:e,open:t})=>{let o=Uv(e),r=Gv(e);return TI(wI,{children:[o,t&&r]})};$r.Trigger=Hv;$r.Content=Pv;$r.Item=$t;$r.ItemLink=Qa;$r.ItemCustom=Rv;$r.Group=ps;$r.Separator=Fv;var Pe=$r;$r.displayName="DropdownMenu";import{jsx as uo,jsxs as Fm}from"react/jsx-runtime";var II=(e,t)=>e.filter(o=>t.includes(o.id)),kI=({setAppState:e,selectedItems:t,library:o,onRemoveFromLibrary:r,resetLibrary:n,onSelectItems:i,appState:a,className:l})=>{let[s]=ve(Oi),[c,m]=ve(Ja),d=()=>{let _=t.length?f("alerts.removeItemsFromsLibrary",{count:t.length}):f("alerts.resetLibrary"),z=t.length?f("confirmDialog.removeItemsFromLib"):f("confirmDialog.resetLibrary");return uo(Pm,{onConfirm:()=>{t.length?r():n(),u(!1)},onCancel:()=>{u(!1)},title:z,children:uo("p",{children:_})})},[p,u]=Og(!1),h=!!t.length,x=h?s.libraryItems.filter(_=>t.includes(_.id)):s.libraryItems,b=h?f("buttons.remove"):f("buttons.resetLibrary"),[E,w]=Og(!1),[y,v]=Og(null),C=CI(()=>Fm(ct,{onCloseRequest:()=>v(null),title:f("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[uo("p",{children:uo(qt,{i18nKey:"publishSuccessDialog.content",authorName:y.authorName,link:_=>uo("a",{href:y?.url,target:"_blank",rel:"noopener noreferrer",children:_})})}),uo(te,{type:"button",title:f("buttons.close"),"aria-label":f("buttons.close"),label:f("buttons.close"),onClick:()=>v(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[v,y]),I=(_,z)=>{w(!1),v({url:_.url,authorName:_.authorName});let W=z.slice();W.forEach(G=>{t.includes(G.id)&&(G.status="published")}),o.setLibrary(W)},L=async()=>{try{await o.updateLibrary({libraryItems:Qc({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(_){if(_?.name==="AbortError"){console.warn(_);return}e({errorMessage:f("errors.importLibraryError")})}},A=async()=>{let _=h?x:await o.getLatestLibrary();Y0(_).catch(yc).catch(z=>{e({errorMessage:z.message})})},R=()=>Fm(Pe,{open:c,children:[uo(Pe.Trigger,{onToggle:()=>m(!c),children:Nx}),Fm(Pe.Content,{onClickOutside:()=>m(!1),onSelect:()=>m(!1),className:"library-menu",children:[!h&&uo(Pe.Item,{onSelect:L,icon:va,"data-testid":"lib-dropdown--load",children:f("buttons.load")}),!!x.length&&uo(Pe.Item,{onSelect:A,icon:Si,"data-testid":"lib-dropdown--export",children:f("buttons.export")}),!!x.length&&uo(Pe.Item,{onSelect:()=>u(!0),icon:vo,children:b}),h&&uo(Pe.Item,{icon:VE,onSelect:()=>w(!0),"data-testid":"lib-dropdown--remove",children:f("buttons.publishLibrary")})]})]});return Fm("div",{className:SI("library-menu-dropdown-container",l),children:[R(),t.length>0&&uo("div",{className:"library-actions-counter",children:t.length}),p&&d(),E&&uo(Mv,{onClose:()=>w(!1),libraryItems:II(s.libraryItems,t),appState:a,onSuccess:_=>I(_,s.libraryItems),onError:_=>window.alert(_),updateItemsInStorage:()=>o.setLibrary(s.libraryItems),onRemove:_=>i(t.filter(z=>z!==_))}),y&&C()]})},Bg=({selectedItems:e,onSelectItems:t,className:o})=>{let{library:r}=lt(),{clearLibraryCache:n,deleteItemsFromLibraryCache:i}=km(),a=_e(),l=Se(),[s]=ve(Oi),c=async d=>{let p=d.filter(u=>!e.includes(u.id));r.setLibrary(p).catch(()=>{l({errorMessage:f("alerts.errorRemovingFromLibrary")})}),i(e),t([])};return uo(kI,{appState:a,setAppState:l,selectedItems:e,onSelectItems:t,library:r,onRemoveFromLibrary:()=>c(s.libraryItems),resetLibrary:()=>{r.resetLibrary(),n()},className:o})};import{memo as OI,useEffect as BI,useState as FI}from"react";import MI,{useCallback as AI}from"react";function LI(){return[!1,AI(t=>t(),[])]}var Vv=MI.useTransition||LI;import Yv from"clsx";import{memo as DI,useEffect as _I,useRef as PI,useState as RI}from"react";import{jsx as zm,jsxs as NI}from"react/jsx-runtime";var Wv=DI(({id:e,elements:t,isPending:o,onClick:r,selected:n,onToggle:i,onDrag:a,svgCache:l})=>{let s=PI(null),c=hv(e,t,l);_I(()=>{let h=s.current;if(h)return c&&(h.innerHTML=c.outerHTML),()=>{h.innerHTML=""}},[c]);let[m,d]=RI(!1),p=Te().editor.isMobile,u=o&&zm("div",{className:"library-unit__adder",children:Rx});return NI("div",{className:Yv("library-unit",{"library-unit__active":t,"library-unit--hover":t&&m,"library-unit--selected":n,"library-unit--skeleton":!c}),onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[zm("div",{className:Yv("library-unit__dragger",{"library-unit__pulse":!!o}),ref:s,draggable:!!t,onClick:t||o?h=>{e&&h.shiftKey?i(e,h):r(e)}:void 0,onDragStart:h=>{if(!e){h.preventDefault();return}d(!1),a(e,h)}}),u,e&&t&&(m||p||n)&&zm(fs,{checked:n,onChange:(h,x)=>i(e,x),className:"library-unit__checkbox"})]})}),Kv=()=>zm("div",{className:"library-unit library-unit--skeleton"});import{Fragment as zI,jsx as Hm}from"react/jsx-runtime";var Fg=({children:e})=>Hm("div",{className:"library-menu-items-container__grid",children:e}),Um=OI(({items:e,onItemSelectToggle:t,onItemDrag:o,isItemSelected:r,onClick:n,svgCache:i,itemsRenderedPerBatch:a})=>{let[,l]=Vv(),[s,c]=FI(0);return BI(()=>{s<e.length&&l(()=>{c(s+a)})},[s,e.length,l,a]),Hm(zI,{children:e.map((m,d)=>d<s?Hm(Wv,{elements:m?.elements,isPending:!m?.id&&!!m?.elements,onClick:n,svgCache:i,id:m?.id,selected:r(m.id),onToggle:t,onDrag:o},m?.id??d):Hm(Kv,{},d))})});import{Fragment as Xv,jsx as ho,jsxs as tl}from"react/jsx-runtime";var VI=17,YI=64;function zg({isLoading:e,libraryItems:t,onAddToLibrary:o,onInsertLibraryItems:r,pendingElements:n,theme:i,id:a,libraryReturnUrl:l,onSelectItems:s,selectedItems:c}){let m=UI(null),d=Tv(m);HI(()=>{d>0&&m.current?.scrollTo(0,d)},[]);let{svgCache:p}=km(),u=Zv(()=>t.filter(_=>_.status!=="published"),[t]),h=Zv(()=>t.filter(_=>_.status==="published"),[t]),x=!t.length&&!n.length,b=!n.length&&!u.length&&!h.length,[E,w]=GI(null),y=el((_,z)=>{let W=!c.includes(_),G=[...u,...h];if(W){if(z.shiftKey&&E){let j=G.findIndex(oe=>oe.id===E),H=G.findIndex(oe=>oe.id===_);if(j===-1||H===-1){s([...c,_]);return}let B=q(c),U=G.reduce((oe,Z,ce)=>((ce>=j&&ce<=H||B.has(Z.id))&&oe.push(Z.id),oe),[]);s(U)}else s([...c,_]);w(_)}else w(null),s(c.filter(j=>j!==_))},[E,s,h,c,u]),v=el(_=>{let z;return c.includes(_)?z=t.filter(W=>c.includes(W.id)):z=t.filter(W=>W.id===_),z.map(W=>({...W,elements:gi({type:"everything",elements:W.elements,randomizeSeed:!0}).duplicatedElements}))},[t,c]),C=el((_,z)=>{z.dataTransfer.setData(ge.excalidrawlib,Ru(v(_)))},[v]),I=el(_=>_?c.includes(_):!1,[c]),L=el(()=>{o(n)},[n,o]),A=el(_=>{_&&r(v(_))},[v,r]),R=p.size>=t.length?YI:VI;return tl("div",{className:"library-menu-items-container",style:n.length||u.length||h.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[!b&&ho(Bg,{selectedItems:c,onSelectItems:s,className:"library-menu-dropdown-container--in-heading"}),tl(Lt.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:h.length>0?1:"0 1 auto",marginBottom:0},ref:m,children:[tl(Xv,{children:[!b&&ho("div",{className:"library-menu-items-container__header",children:f("labels.personalLib")}),e&&ho("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:ho(Ot,{})}),!n.length&&!u.length?tl("div",{className:"library-menu-items__no-items",children:[ho("div",{className:"library-menu-items__no-items__label",children:f("library.noItems")}),ho("div",{className:"library-menu-items__no-items__hint",children:h.length>0?f("library.hint_emptyPrivateLibrary"):f("library.hint_emptyLibrary")})]}):tl(Fg,{children:[n.length>0&&ho(Um,{itemsRenderedPerBatch:R,items:[{id:null,elements:n}],onItemSelectToggle:y,onItemDrag:C,onClick:L,isItemSelected:I,svgCache:p}),ho(Um,{itemsRenderedPerBatch:R,items:u,onItemSelectToggle:y,onItemDrag:C,onClick:A,isItemSelected:I,svgCache:p})]})]}),tl(Xv,{children:[(h.length>0||n.length>0||u.length>0)&&ho("div",{className:"library-menu-items-container__header library-menu-items-container__header--excal",children:f("labels.excalidrawLib")}),h.length>0?ho(Fg,{children:ho(Um,{itemsRenderedPerBatch:R,items:h,onItemSelectToggle:y,onItemDrag:C,onClick:A,isItemSelected:I,svgCache:p})}):u.length>0?ho("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",fontSize:".9rem"},children:f("library.noItems")}):null]}),x&&ho(Dm,{style:{padding:"16px 0",width:"100%"},id:a,libraryReturnUrl:l,theme:i,children:ho(Bg,{selectedItems:c,onSelectItems:s})})]})]})}import{jsx as Pn,jsxs as qv}from"react/jsx-runtime";var Ja=ke(!1),jv=({children:e})=>Pn("div",{className:"layer-ui__library",children:e}),KI=ew(({onInsertLibraryItems:e,pendingElements:t,onAddToLibrary:o,setAppState:r,libraryReturnUrl:n,library:i,id:a,theme:l,selectedItems:s,onSelectItems:c})=>{let[m]=ve(Oi),d=Ug(h=>{(async(b,E)=>{fe("element","addToLibrary","ui");for(let y of hc)if(b.some(v=>v.type===y))return r({errorMessage:f(`errors.libraryElementTypeError.${y}`)});let w=[{status:"unpublished",elements:b,id:Ht(),created:Date.now()},...E];o(),i.setLibrary(w).catch(()=>{r({errorMessage:f("alerts.errorAddingToLibrary")})})})(h,m.libraryItems)},[o,i,r,m.libraryItems]),p=Qv(()=>m.libraryItems,[m]);if(m.status==="loading"&&!m.isInitialized)return Pn(jv,{children:Pn("div",{className:"layer-ui__library-message",children:qv("div",{children:[Pn(Ot,{size:"2em"}),Pn("span",{children:f("labels.libraryLoadingMessage")})]})})});let u=m.libraryItems.length>0||t.length>0;return qv(jv,{children:[Pn(zg,{isLoading:m.status==="loading",libraryItems:p,onAddToLibrary:d,onInsertLibraryItems:e,pendingElements:t,id:a,libraryReturnUrl:n,theme:l,onSelectItems:c,selectedItems:s}),u&&Pn(Dm,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:a,libraryReturnUrl:n,theme:l})]})}),Hg=(e,t)=>({elements:e,pending:Q(e,{selectedElementIds:t},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:t}),ZI=(e,t)=>{let o=In(),[r,n]=Jv(()=>Hg(o,e.selectedElementIds)),i=WI(new Map);return $v(()=>{for(let a of r.pending)i.current.set(a.id,a.version)},[r.pending]),$v(()=>{t.state.cursorButton==="up"&&t.state.activeTool.type==="selection"&&n(a=>{if(!pt(a.selectedElementIds,e.selectedElementIds))return i.current.clear(),Hg(o,e.selectedElementIds);let l=t.scene.getNonDeletedElementsMap();for(let s of Object.keys(e.selectedElementIds)){let c=l.get(s)?.version;if(c&&c!==i.current.get(s))return Hg(o,e.selectedElementIds)}return a})},[t,t.state.cursorButton,t.state.activeTool.type,e.selectedElementIds,o]),r.pending},tw=ew(()=>{let e=lt(),{onInsertElements:t}=e,o=Tr(),r=_e(),n=Se(),[i,a]=Jv([]),l=Qv(()=>e.library,[e.library]),s=ZI(r,e),c=Ug(d=>{t(Lm(d))},[t]),m=Ug(()=>{n({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[n]);return Pn(KI,{pendingElements:s,onInsertLibraryItems:c,onAddToLibrary:m,setAppState:n,libraryReturnUrl:o.libraryReturnUrl,library:l,id:e.id,theme:r.theme,selectedItems:i,onSelectItems:a})});import XI from"clsx";import{useRef as $I}from"react";import{createPortal as jI}from"react-dom";import{jsx as ow,jsxs as qI}from"react/jsx-runtime";var rw=e=>{let{closeOnClickOutside:t=!0}=e,o=Wd({className:"excalidraw-modal-container"}),r=$I(document.body.classList.contains("excalidraw-animations-disabled"));if(!o)return null;let n=i=>{i.key===T.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return jI(qI("div",{className:XI("Modal",e.className,{"animations-disabled":r.current}),role:"dialog","aria-modal":"true",onKeyDown:n,"aria-labelledby":e.labelledBy,"data-prevent-outside-click":!0,children:[ow("div",{className:"Modal__background",onClick:t?e.onCloseRequest:void 0}),ow("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),o)};import{jsx as ks,jsxs as ok}from"react/jsx-runtime";function tk(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var ct=e=>{let[t,o]=mv(),[r]=ek(document.activeElement),{id:n}=ft(),i=Te().viewport.isMobile;QI(()=>{if(!t)return;let c=Ll(t);setTimeout(()=>{c.length>0&&e.autofocus!==!1&&(c[1]||c[0]).focus()});let m=d=>{if(d.key===T.TAB){let p=Ll(t),{activeElement:u}=document,h=p.findIndex(x=>x===u);h===0&&d.shiftKey?(p[p.length-1].focus(),d.preventDefault()):h===p.length-1&&!d.shiftKey&&(p[0].focus(),d.preventDefault())}};return t.addEventListener("keydown",m),()=>t.removeEventListener("keydown",m)},[t,e.autofocus]);let a=Se(),l=rr(Ja),s=()=>{a({openMenu:null}),l(!1),r.focus(),e.onCloseRequest()};return ks(rw,{className:JI("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:tk(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,children:ok(wt,{ref:o,children:[e.title&&ks("h2",{id:`${n}-dialog-title`,className:"Dialog__title",children:ks("span",{className:"Dialog__titleContent",children:e.title})}),i&&ks("button",{className:"Dialog__close",onClick:s,title:f("buttons.close"),"aria-label":f("buttons.close"),type:"button",children:Po}),ks("div",{className:"Dialog__content",children:e.children})]})})};import Gg from"clsx";import{forwardRef as ik,useRef as ak,useImperativeHandle as lk,useLayoutEffect as sk,useState as ck}from"react";import rk from"clsx";import{jsx as nk}from"react/jsx-runtime";var Mo=({type:e="button",onSelect:t,selected:o,children:r,className:n="",...i})=>nk("button",{onClick:un(i.onClick,a=>{t()}),type:e,className:rk("excalidraw-button",n,{selected:o}),...i,children:r});import{jsx as Vg,jsxs as nw}from"react/jsx-runtime";var ol=ik(({onChange:e,label:t,fullWidth:o,placeholder:r,readonly:n,selectOnRender:i,onKeyDown:a,isRedacted:l=!1,icon:s,className:c,...m},d)=>{let p=ak(null);lk(d,()=>p.current),sk(()=>{i&&(p.current?.focus(),p.current?.select())},[i]);let[u,h]=ck(!1);return nw("div",{className:Gg("ExcTextField",c,{"ExcTextField--fullWidth":o,"ExcTextField--hasIcon":!!s}),onClick:()=>{p.current?.focus()},children:[s,t&&Vg("div",{className:"ExcTextField__label",children:t}),nw("div",{className:Gg("ExcTextField__input",{"ExcTextField__input--readonly":n}),children:[Vg("input",{className:Gg({"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:x=>e?.(x.target.value),onKeyDown:a}),l&&Vg(Mo,{onSelect:()=>h(!u),style:{border:0,userSelect:"none"},children:u?qE:Sa})]})]})});var Ms=[{icon:Hx,value:"selection",key:T.V,numericKey:T[1],fillable:!0},{icon:vd,value:"rectangle",key:T.R,numericKey:T[2],fillable:!0},{icon:wd,value:"diamond",key:T.D,numericKey:T[3],fillable:!0},{icon:Td,value:"ellipse",key:T.O,numericKey:T[4],fillable:!0},{icon:Ux,value:"arrow",key:T.A,numericKey:T[5],fillable:!0},{icon:Sd,value:"line",key:T.L,numericKey:T[6],fillable:!0},{icon:Tn,value:"freedraw",key:[T.P,T.X],numericKey:T[7],fillable:!1},{icon:Ea,value:"text",key:T.T,numericKey:T[8],fillable:!1},{icon:Vx,value:"image",key:null,numericKey:T[9],fillable:!1},{icon:Yx,value:"eraser",key:T.E,numericKey:T[0],fillable:!1}],iw=e=>Ms.find((o,r)=>o.numericKey!=null&&e===o.numericKey.toString()||o.key&&(typeof o.key=="string"?o.key===e:o.key.includes(e)))?.value||null;import Kg from"clsx";import{useState as pk}from"react";import{createIsolation as dk}from"jotai-scope";import Yg from"react";import Ir from"tunnel-rat";var Wg=Yg.createContext(null),je=()=>Yg.useContext(Wg),mk=dk(),aw=()=>Yg.useMemo(()=>({MainMenuTunnel:Ir(),WelcomeScreenMenuHintTunnel:Ir(),WelcomeScreenToolbarHintTunnel:Ir(),WelcomeScreenHelpHintTunnel:Ir(),WelcomeScreenCenterTunnel:Ir(),FooterCenterTunnel:Ir(),DefaultSidebarTriggerTunnel:Ir(),DefaultSidebarTabTriggersTunnel:Ir(),OverwriteConfirmDialogTunnel:Ir(),TTDDialogTriggerTunnel:Ir(),tunnelsJotai:mk}),[]);import{Fragment as jr,jsx as We,jsxs as Tt}from"react/jsx-runtime";var Zg=(e,t)=>{let o=t[0]?.type||null;for(let r of t)if(r.type!==o){o=null;break}return Hl(e.activeTool.type)&&o!=="image"&&o!=="frame"&&o!=="magicframe"||t.some(r=>Hl(r.type))},Xg=(e,t)=>yn(e.activeTool.type)||t.some(o=>yn(o.type)),Gm=({appState:e,elementsMap:t,renderAction:o,app:r})=>{let n=Pc(t,e),i=!1;n.length===2&&(it(n[0])||it(n[1]))&&(i=!0);let a=!!(e.editingTextElement||e.newElement),l=Te(),s=document.documentElement.getAttribute("dir")==="rtl",c=yn(e.activeTool.type)&&!ti(e.currentItemBackgroundColor)||n.some(h=>yn(h.type)&&!ti(h.backgroundColor)),m=n.length===1||i,d=!e.editingLinearElement&&n.length===1&&le(n[0])&&!ee(n[0]),p=!e.croppingElementId&&n.length===1&&xe(n[0]),u=!i&&po(e,r);return Tt("div",{className:"panelColumn",children:[We("div",{children:Zg(e,n)&&o("changeStrokeColor")}),Xg(e,n)&&We("div",{children:o("changeBackgroundColor")}),c&&o("changeFillStyle"),(wu(e.activeTool.type)||n.some(h=>wu(h.type)))&&o("changeStrokeWidth"),(e.activeTool.type==="freedraw"||n.some(h=>h.type==="freedraw"))&&o("changeStrokeShape"),(Tu(e.activeTool.type)||n.some(h=>Tu(h.type)))&&Tt(jr,{children:[o("changeStrokeStyle"),o("changeSloppiness")]}),(Su(e.activeTool.type)||n.some(h=>Su(h.type)))&&We(jr,{children:o("changeRoundness")}),(Cu(e.activeTool.type)||n.some(h=>Cu(h.type)))&&We(jr,{children:o("changeArrowType")}),(e.activeTool.type==="text"||n.some(K))&&Tt(jr,{children:[o("changeFontFamily"),o("changeFontSize"),(e.activeTool.type==="text"||Xb(n,t))&&o("changeTextAlign")]}),Zb(n,t)&&o("changeVerticalAlign"),(ra(e.activeTool.type)||n.some(h=>ra(h.type)))&&We(jr,{children:o("changeArrowhead")}),o("changeOpacity"),Tt("fieldset",{children:[We("legend",{children:f("labels.layers")}),Tt("div",{className:"buttonList",children:[o("sendToBack"),o("sendBackward"),o("bringForward"),o("bringToFront")]})]}),u&&!i&&Tt("fieldset",{children:[We("legend",{children:f("labels.align")}),Tt("div",{className:"buttonList",children:[s?Tt(jr,{children:[o("alignRight"),o("alignHorizontallyCentered"),o("alignLeft")]}):Tt(jr,{children:[o("alignLeft"),o("alignHorizontallyCentered"),o("alignRight")]}),n.length>2&&o("distributeHorizontally"),We("div",{style:{flexBasis:"100%",height:0}}),Tt("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[o("alignTop"),o("alignVerticallyCentered"),o("alignBottom"),n.length>2&&o("distributeVertically")]})]})]}),!a&&n.length>0&&Tt("fieldset",{children:[We("legend",{children:f("labels.actions")}),Tt("div",{className:"buttonList",children:[!l.editor.isMobile&&o("duplicateSelection"),!l.editor.isMobile&&o("deleteSelectedElements"),o("group"),o("ungroup"),m&&o("hyperlink"),p&&o("cropEditor"),d&&o("toggleLinearEditor")]})]})]})},Vm=({activeTool:e,appState:t,app:o,UIOptions:r})=>{let[n,i]=pk(!1),a=e.type==="frame",l=e.type==="laser",s=e.type==="lasso",c=e.type==="embeddable",{TTDDialogTriggerTunnel:m}=je();return Tt(jr,{children:[Ms.map(({value:d,icon:p,key:u,numericKey:h,fillable:x},b)=>{if(r.tools?.[d]===!1)return null;let E=f(`toolBar.${d}`),w=u&&dn(typeof u=="string"?u:u[0]),y=w?`${w} ${f("helpDialog.or")} ${h}`:`${h}`;return We(te,{className:Kg("Shape",{fillable:x}),type:"radio",icon:p,checked:e.type===d,name:"editor-current-shape",title:`${dn(E)} \u2014 ${y}`,keyBindingLabel:h||w,"aria-label":dn(E),"aria-keyshortcuts":y,"data-testid":`toolbar-${d}`,onPointerDown:({pointerType:v})=>{!t.penDetected&&v==="pen"&&o.togglePenMode(!0),d==="selection"&&(t.activeTool.type==="selection"?o.setActiveTool({type:"lasso"}):o.setActiveTool({type:"selection"}))},onChange:({pointerType:v})=>{t.activeTool.type!==d&&fe("toolbar",d,"ui"),d==="image"?o.setActiveTool({type:d,insertOnCanvasDirectly:v!=="mouse"}):o.setActiveTool({type:d})}},d)}),We("div",{className:"App-toolbar__divider"}),Tt(Pe,{open:n,children:[We(Pe.Trigger,{className:Kg("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":a||c||s||l&&!o.props.isCollaborating}),onToggle:()=>i(!n),title:f("toolBar.extraTools"),children:a?Ii:c?rh:l&&!o.props.isCollaborating?ns:s?Jl:$E}),Tt(Pe.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[We(Pe.Item,{onSelect:()=>o.setActiveTool({type:"frame"}),icon:Ii,shortcut:T.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:a,children:f("toolBar.frame")}),We(Pe.Item,{onSelect:()=>o.setActiveTool({type:"embeddable"}),icon:rh,"data-testid":"toolbar-embeddable",selected:c,children:f("toolBar.embeddable")}),We(Pe.Item,{onSelect:()=>o.setActiveTool({type:"laser"}),icon:ns,"data-testid":"toolbar-laser",selected:l,shortcut:T.K.toLocaleUpperCase(),children:f("toolBar.laser")}),We(Pe.Item,{onSelect:()=>o.setActiveTool({type:"lasso"}),icon:Jl,"data-testid":"toolbar-lasso",selected:s,children:f("toolBar.lasso")}),We("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),o.props.aiEnabled!==!1&&We(m.Out,{}),We(Pe.Item,{onSelect:()=>o.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:Pd,"data-testid":"toolbar-embeddable",children:f("toolBar.mermaidToExcalidraw")}),o.props.aiEnabled!==!1&&o.plugins.diagramToCode&&We(jr,{children:Tt(Pe.Item,{onSelect:()=>o.onMagicframeToolSelect(),icon:Rd,"data-testid":"toolbar-magicframe",children:[f("toolBar.magicframe"),We(Pe.Item.Badge,{children:"AI"})]})})]})]})]})},lw=({renderAction:e,zoom:t})=>We(Lt.Col,{gap:1,className:Wt.ZOOM_ACTIONS,children:Tt(Lt.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),sw=({renderAction:e,className:t})=>Tt("div",{className:`undo-redo-buttons ${t}`,children:[We("div",{className:"undo-button-container",children:We(So,{label:f("buttons.undo"),children:e("undo")})}),We("div",{className:"redo-button-container",children:Tt(So,{label:f("buttons.redo"),children:[" ",e("redo")]})})]}),cw=({actionManager:e,showExitZenModeBtn:t})=>We("button",{type:"button",className:Kg("disable-zen-mode",{"disable-zen-mode--visible":t}),onClick:()=>e.executeAction(Ua),children:f("buttons.exitZenMode")}),dw=({renderAction:e,className:t})=>We("div",{className:`finalize-button ${t}`,children:e("finalize",{size:"small"})});import{useRef as uk}from"react";var $g=e=>{let t=uk({userFn:e});return t.current.userFn=e,t.current.stableFn||(t.current.stableFn=(...o)=>t.current.userFn(...o)),t.current.stableFn};import{jsx as gk,jsxs as hk}from"react/jsx-runtime";var Bi=ke(null),mw=()=>{let[e,t]=ve(Bi),o=bt();return e&&e==="clearCanvas"?gk(Pm,{onConfirm:()=>{o.executeAction(Kr),t(null)},onCancel:()=>t(null),title:f("clearCanvasDialog.title"),children:hk("p",{className:"clear-canvas__content",children:[" ",f("alerts.clearReset")]})}):null};var jg={};b1(jg,{toggleTheme:()=>fk});var fk={...Ai,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(Ai,"commandPalette")}};import{jsx as Jt,jsxs as kr}from"react/jsx-runtime";var Ek=ke(null),tt={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links"},yk=e=>{switch(e){case tt.app:return 1;case tt.export:return 2;case tt.editor:return 3;case tt.tools:return 4;case tt.elements:return 5;case tt.links:return 6;default:return 10}},Km=({shortcut:e,className:t,children:o})=>{let r=e.replace("++","+$").split("+");return kr("div",{className:uw("shortcut",t),children:[r.map((n,i)=>Jt("div",{className:"shortcut-wrapper",children:Jt("div",{className:"shortcut-key",children:n==="$"?"+":n})},n)),Jt("div",{className:"shortcut-desc",children:o})]})},hw=e=>!e.altKey&&e[T.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===T.P||e.key===T.SLASH),oQ=Object.assign(e=>{let t=_e(),o=Se();return Wm(()=>{let r=n=>{hw(n)&&(n.preventDefault(),n.stopPropagation(),o(i=>{let a=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return a&&fe("command_palette","open","shortcut"),{openDialog:a}}))};return window.addEventListener("keydown",r,{capture:!0}),()=>window.removeEventListener("keydown",r,{capture:!0})},[o]),t.openDialog?.name!=="commandPalette"?null:Jt(vk,{...e})},{defaultItems:jg});function vk({customCommandPaletteItems:e}){let t=lt(),o=_e(),r=Se(),n=Tr(),i=bt(),[a,l]=ve(Ek),[s,c]=Ym(null),m=xk(null),d=Sn({uiAppState:o,customCommandPaletteItems:e,appProps:n});Wm(()=>{let{uiAppState:I,customCommandPaletteItems:L,appProps:A}=d,R=G=>{let j="";return G.label&&(typeof G.label=="function"?j=f(G.label(t.scene.getNonDeletedElements(),I,t)):j=f(G.label)),j},_=G=>typeof G.icon=="function"?G.icon(I,t.scene.getNonDeletedElements()):G.icon,z=[],W=(G,j,H)=>{let B={label:R(G),icon:_(G),category:j,shortcut:st(G.name),keywords:G.keywords,predicate:G.predicate,viewMode:G.viewMode,perform:()=>{i.executeAction(G,"commandPalette")}};return H?H(B,G):B};if(I&&t.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.duplicateSelection,i.actions.flipHorizontal,i.actions.flipVertical,i.actions.zoomToFitSelection,i.actions.zoomToFitSelectionInViewport,i.actions.increaseFontSize,i.actions.decreaseFontSize,i.actions.toggleLinearEditor,i.actions.cropEditor,vs,Im,dv].map(Z=>W(Z,tt.elements,(ce,ue)=>({...ce,predicate:ue.predicate?ue.predicate:(he,nt,to,pr)=>Q(he,nt).length>0}))),j=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool,i.actions.toggleLassoTool].map(Z=>W(Z,tt.tools)),H=[i.actions.undo,i.actions.redo,i.actions.zoomIn,i.actions.zoomOut,i.actions.resetZoom,i.actions.zoomToFit,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(Z=>W(Z,tt.editor)),B=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map(Z=>W(Z,tt.export));z=[...G,...H,{label:R(Kr),icon:_(Kr),shortcut:st(Kr.name),category:tt.editor,keywords:["delete","destroy"],viewMode:!1,perform:()=>{Fe.set(Bi,"clearCanvas")}},{label:f("buttons.exportImage"),category:tt.export,icon:Md,shortcut:st("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{r({openDialog:{name:"imageExport"}})}},...B];let U=[{label:f("toolBar.library"),category:tt.app,icon:ba,viewMode:!1,perform:()=>{I.openSidebar?r({openSidebar:null}):r({openSidebar:{name:zt.name,tab:zt.defaultTab}})}},{label:f("search.title"),category:tt.app,icon:wo,viewMode:!0,perform:()=>{i.executeAction(As)}},{label:f("labels.shapeSwitch"),category:tt.elements,icon:is,perform:()=>{i.executeAction(cv)}},{label:f("labels.changeStroke"),keywords:["color","outline"],category:tt.elements,icon:kd,viewMode:!1,predicate:(Z,ce)=>{let ue=Q(Z,ce);return ue.length>0&&Zg(ce,ue)},perform:()=>{r(Z=>({openMenu:Z.openMenu==="shape"?null:"shape",openPopup:"elementStroke"}))}},{label:f("labels.changeBackground"),keywords:["color","fill"],icon:kd,category:tt.elements,viewMode:!1,predicate:(Z,ce)=>{let ue=Q(Z,ce);return ue.length>0&&Xg(ce,ue)},perform:()=>{r(Z=>({openMenu:Z.openMenu==="shape"?null:"shape",openPopup:"elementBackground"}))}},{label:f("labels.canvasBackground"),keywords:["color"],icon:kd,category:tt.editor,viewMode:!1,perform:()=>{r(Z=>({openMenu:Z.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...Ms.reduce((Z,ce)=>{let{value:ue,icon:he,key:nt,numericKey:to}=ce;if(A.UIOptions.tools?.[ue]===!1)return Z;let Yo=nt&&dn(typeof nt=="string"?nt:nt[0])||to,tn={label:f(`toolBar.${ue}`),category:tt.tools,shortcut:Yo,icon:he,keywords:["toolbar"],viewMode:!1,perform:({event:oo})=>{ue==="image"?t.setActiveTool({type:ue,insertOnCanvasDirectly:oo.type==="keydown"}):t.setActiveTool({type:ue})}};return Z.push(tn),Z},[]),...j,{label:f("toolBar.lock"),category:tt.tools,icon:I.activeTool.locked?xa:Ti,shortcut:T.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{t.toggleLock()}},{label:`${f("labels.textToDiagram")}...`,category:tt.tools,icon:QE,viewMode:!1,predicate:A.aiEnabled,perform:()=>{r(Z=>({...Z,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${f("toolBar.mermaidToExcalidraw")}...`,category:tt.tools,icon:Pd,viewMode:!1,predicate:A.aiEnabled,perform:()=>{r(Z=>({...Z,openDialog:{name:"ttd",tab:"mermaid"}}))}}],oe=[...z,...U,...L||[]].map(Z=>({...Z,icon:Z.icon||is,order:Z.order??yk(Z.category),haystack:`${Lg(Z.label.toLocaleLowerCase())} ${Z.keywords?.join(" ")||""}`}));c(oe),l(oe.find(Z=>Z.label===a?.label)??null)}},[d,t,i,c,a?.label,l,r]);let[p,u]=Ym(""),[h,x]=Ym(null),[b,E]=Ym({}),w=I=>{r({openDialog:null},I),u("")},y=(I,L)=>{o.openDialog?.name==="commandPalette"&&(L.stopPropagation(),L.preventDefault(),document.body.classList.add("excalidraw-animations-disabled"),w(()=>{I.perform({actionManager:i,event:L}),l(I),requestAnimationFrame(()=>{document.body.classList.remove("excalidraw-animations-disabled")})}))},v=$g(I=>I.viewMode===!1&&o.viewModeEnabled?!1:typeof I.predicate=="function"?I.predicate(t.scene.getNonDeletedElements(),o,n,t):I.predicate===void 0||I.predicate),C=$g(I=>{let L=gr(I.target)||hw(I)||I.key===T.ESCAPE;if(L&&I.key!==T.ARROW_UP&&I.key!==T.ARROW_DOWN&&I.key!==T.ENTER)return;let A=Object.values(b).flat(),R=a&&!p&&v(a);if(I.key===T.ARROW_UP){I.preventDefault();let _=A.findIndex(G=>G.label===h?.label);if(R){if(_===0){x(a);return}if(h===a){let G=A[A.length-1];G&&x(G);return}}let z;_===-1?z=A.length-1:z=_===0?A.length-1:(_-1)%A.length;let W=A[z];W&&x(W);return}if(I.key===T.ARROW_DOWN){I.preventDefault();let _=A.findIndex(G=>G.label===h?.label);if(R){if(!h||_===A.length-1){x(a);return}if(h===a){let G=A[0];G&&x(G);return}}let z=(_+1)%A.length,W=A[z];W&&x(W);return}if(I.key===T.ENTER&&h&&setTimeout(()=>{y(h,I)}),!L){if(I.stopPropagation(),/^[a-zA-Z0-9]$/.test(I.key)){m?.current?.focus();return}I.preventDefault()}});return Wm(()=>(window.addEventListener("keydown",C,{capture:!0}),()=>window.removeEventListener("keydown",C,{capture:!0})),[C]),Wm(()=>{if(!s)return;let I=_=>{let z={};for(let W of _)z[W.category]?z[W.category].push(W):z[W.category]=[W];return z},L=s.filter(v).sort((_,z)=>_.order-z.order),A=!p&&a&&v(a);if(!p){E(I(A?L.filter(_=>_.label!==a?.label):L)),x(A?a:L[0]||null);return}let R=Lg(p.toLocaleLowerCase().replace(/[<>_| -]/g,""));L=bk.filter(R,L,{extract:_=>_.haystack}).sort((_,z)=>z.score-_.score).map(_=>_.original),E(I(L)),x(L[0]??null)},[p,s,v,a]),kr(ct,{onCloseRequest:()=>w(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[Jt(ol,{value:p,placeholder:f("commandPalette.search.placeholder"),onChange:I=>{u(I)},selectOnRender:!0,ref:m}),!t.device.viewport.isMobile&&kr("div",{className:"shortcuts-wrapper",children:[Jt(Km,{shortcut:"\u2191\u2193",children:f("commandPalette.shortcuts.select")}),Jt(Km,{shortcut:"\u21B5",children:f("commandPalette.shortcuts.confirm")}),Jt(Km,{shortcut:N("Esc"),children:f("commandPalette.shortcuts.close")})]}),kr("div",{className:"commands",children:[a&&!p&&kr("div",{className:"command-category",children:[kr("div",{className:"command-category-title",children:[f("commandPalette.recents"),Jt("div",{className:"icon",style:{marginLeft:"6px"},children:ey})]}),Jt(pw,{command:a,isSelected:a.label===h?.label,onClick:I=>y(a,I),disabled:!v(a),onMouseMove:()=>x(a),showShortcut:!t.device.viewport.isMobile,appState:o})]}),Object.keys(b).length>0?Object.keys(b).map((I,L)=>kr("div",{className:"command-category",children:[Jt("div",{className:"command-category-title",children:I}),b[I].map(A=>Jt(pw,{command:A,isSelected:A.label===h?.label,onClick:R=>y(A,R),onMouseMove:()=>x(A),showShortcut:!t.device.viewport.isMobile,appState:o},A.label))]},I)):s?kr("div",{className:"no-match",children:[Jt("div",{className:"icon",children:wo})," ",f("commandPalette.search.noMatch")]}):null]})]})}var pw=({command:e,isSelected:t,disabled:o,onMouseMove:r,onClick:n,showShortcut:i,appState:a})=>{let l=()=>{};return kr("div",{className:uw("command-item",{"item-selected":t,"item-disabled":o}),ref:s=>{t&&!o&&s?.scrollIntoView?.({block:"nearest"})},onClick:o?l:n,onMouseMove:o?l:r,title:o?f("commandPalette.itemNotAvailable"):"",children:[kr("div",{className:"name",children:[e.icon&&Jt(An,{icon:typeof e.icon=="function"?e.icon(a):e.icon}),e.label]}),i&&e.shortcut&&Jt(Km,{shortcut:e.shortcut})]})};import{jsx as wk}from"react/jsx-runtime";var qg=F({name:"toggleLinearEditor",category:tt.elements,label:(e,t,o)=>o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,t,o,r)=>{let n=r.scene.getSelectedElements(t);return!!(!t.editingLinearElement&&n.length===1&&le(n[0])&&!ee(n[0]))},perform(e,t,o,r){let n=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0})[0],i=t.editingLinearElement?.elementId===n.id?null:new $(n,q(e));return{appState:{...t,editingLinearElement:i},captureUpdate:D.IMMEDIATELY}},PanelComponent:({appState:e,updateData:t,app:o})=>{let r=o.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0],n=f(r.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return wk(te,{type:"button",icon:hy,title:n,"aria-label":n,onClick:()=>t(null)})}});var As=F({name:"searchMenu",icon:wo,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,t,o,r){if(t.openSidebar?.name===zt.name&&t.openSidebar.tab===Nr){let n=r.excalidrawContainerValue.container?.querySelector(`.${Wt.SEARCH_MENU_INPUT_WRAPPER} input`);return n?.focus(),n?.select(),!1}return{appState:{...t,openSidebar:{name:zt.name,tab:Nr},openDialog:null},captureUpdate:D.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,t,o)=>o.gridModeEnabled===void 0,keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.F});import{jsx as Tk}from"react/jsx-runtime";var Jg=F({name:"cropEditor",label:"helpDialog.cropStart",icon:wh,viewMode:!0,trackEvent:{category:"menu"},keywords:["image","crop"],perform(e,t,o,r){let n=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...t,isCropping:!1,croppingElementId:n.id},captureUpdate:D.IMMEDIATELY}},predicate:(e,t,o,r)=>{let n=r.scene.getSelectedElements(t);return!!(!t.croppingElementId&&n.length===1&&xe(n[0]))},PanelComponent:({appState:e,updateData:t,app:o})=>{let r=f("helpDialog.cropStart");return Tk(te,{type:"button",icon:wh,title:r,"aria-label":r,onClick:()=>t(null)})}});var gw=(e,t)=>{let o=t.scene.getSelectedElements(e);return o.length===1&&J(o[0])},fw=F({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,t,o,r)=>{let n=r.scene.getSelectedElements(t).at(0)||null;if(J(n)){let i=so(ye(e),n.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...t,selectedElementIds:i.reduce((a,l)=>(a[l.id]=!0,a),{})},captureUpdate:D.IMMEDIATELY}}return{elements:e,appState:t,captureUpdate:D.EVENTUALLY}},predicate:(e,t,o,r)=>gw(t,r)}),bw=F({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,t,o,r)=>{let n=r.scene.getSelectedElements(t).at(0)||null;return J(n)?{elements:b0(e,n),appState:{...t,selectedElementIds:{[n.id]:!0}},captureUpdate:D.IMMEDIATELY}:{elements:e,appState:t,captureUpdate:D.EVENTUALLY}},predicate:(e,t,o,r)=>gw(t,r)}),Tee=F({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t)=>({elements:e,appState:{...t,frameRendering:{...t.frameRendering,enabled:!t.frameRendering.enabled}},captureUpdate:D.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),See=F({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:Ii,viewMode:!1,perform:(e,t,o,r)=>{let n=Ne(t,{type:"frame"});return Io(r.interactiveCanvas,{...t,activeTool:n}),{elements:e,appState:{...t,activeTool:Ne(t,{type:"frame"})},captureUpdate:D.EVENTUALLY}},keyTest:e=>!e[T.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===T.F}),xw=F({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,t,o,r)=>{let n=Q(e,t);return n.length>0&&!n.some(i=>J(i))},perform:(e,t,o,r)=>{let n=Q(e,t),i=r.scene.getNonDeletedElementsMap(),[a,l,s,c]=Ee(n,i),m=16,d=ia({x:a-m,y:l-m,width:s-a+m*2,height:c-l+m*2});if(t.editingGroupId){let u=Be(n,t.editingGroupId);for(let h of u){let x=h.groupIds.indexOf(t.editingGroupId);kt(h,i,{groupIds:h.groupIds.slice(0,x)})}}return{elements:ta([...r.scene.getElementsIncludingDeleted(),d],n,d,t),appState:{selectedElementIds:{[d.id]:!0}},captureUpdate:D.IMMEDIATELY}}});var rl=class extends ha{},Fi=class{constructor(t=!0,o=!0){this.isUndoStackEmpty=t;this.isRedoStackEmpty=o}},Ls=class e{constructor(t){this.store=t;S(this,"onHistoryChangedEmitter",new Kt);S(this,"undoStack",[]);S(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(t){if(t.isEmpty()||t instanceof rl)return;let o=rl.inverse(t);this.undoStack.push(o),o.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new Fi(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(t,o){return this.perform(t,o,()=>e.pop(this.undoStack),r=>e.push(this.redoStack,r,t))}redo(t,o){return this.perform(t,o,()=>e.pop(this.redoStack),r=>e.push(this.undoStack,r,t))}perform(t,o,r,n){try{let i=r();if(i===null)return;let a=D.IMMEDIATELY,l=this.store.snapshot,s=t,c=o,m=!1;for(;i;){try{[s,c,m]=ha.applyTo(i,s,c,l);let d=l.maybeClone(a,s,c);this.store.scheduleMicroAction({action:a,change:wi.create(l,d),delta:i}),l=d}finally{n(i)}if(m)break;i=r()}return[s,c]}finally{this.onHistoryChangedEmitter.trigger(new Fi(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(t){if(!t.length)return null;let o=t.pop();return o!==void 0?o:null}static push(t,o,r){let n=rl.inverse(o),i=rl.applyLatestChanges(n,r,"inserted");return t.push(i)}};import{useEffect as Sk,useState as Ck}from"react";var Qg=(e,t)=>{let[o,r]=Ck(t);return Sk(()=>{let n=e.on(i=>{r(i)});return()=>{n()}},[e]),o};import{jsx as ww}from"react/jsx-runtime";var Ew=(e,t,o)=>{if(!t.multiElement&&!t.resizingElement&&!t.editingTextElement&&!t.newElement&&!t.selectedElementsAreBeingDragged&&!t.selectionElement&&!e.flowChartCreator.isCreatingChart){let r=o();if(!r)return{captureUpdate:D.EVENTUALLY};let[n,i]=r,a=la(Array.from(n.values()));return{appState:i,elements:a,captureUpdate:D.NEVER}}return{captureUpdate:D.EVENTUALLY}},yw=e=>({name:"undo",label:"buttons.undo",icon:ih,trackEvent:{category:"history"},viewMode:!1,perform:(t,o,r,n)=>Ew(n,o,()=>e.undo(q(t),o)),keyTest:t=>t[T.CTRL_OR_CMD]&&gc(t,T.Z)&&!t.shiftKey,PanelComponent:({updateData:t,data:o})=>{let{isUndoStackEmpty:r}=Qg(e.onHistoryChangedEmitter,new Fi(e.isUndoStackEmpty,e.isRedoStackEmpty));return ww(te,{type:"button",icon:ih,"aria-label":f("buttons.undo"),onClick:t,size:o?.size||"medium",disabled:r,"data-testid":"button-undo"})}}),vw=e=>({name:"redo",label:"buttons.redo",icon:ah,trackEvent:{category:"history"},viewMode:!1,perform:(t,o,r,n)=>Ew(n,o,()=>e.redo(q(t),o)),keyTest:t=>t[T.CTRL_OR_CMD]&&t.shiftKey&&gc(t,T.Z)||oc&&t.ctrlKey&&!t.shiftKey&&gc(t,T.Y),PanelComponent:({updateData:t,data:o})=>{let{isRedoStackEmpty:r}=Qg(e.onHistoryChangedEmitter,new Fi(e.isUndoStackEmpty,e.isRedoStackEmpty));return ww(te,{type:"button",icon:ah,"aria-label":f("buttons.redo"),onClick:t,size:o?.size||"medium",disabled:r,"data-testid":"button-redo"})}});var Tw=F({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,t,o,r)=>{let n=Q(e,t);return n.length===1&&K(n[0])&&!n[0].autoResize},perform:(e,t,o,r)=>{let n=Q(e,t);return{appState:t,elements:e.map(i=>{if(i.id===n[0].id&&K(i)){let a=ut(i.originalText,Ge(i),i.lineHeight);return re(i,{autoResize:!0,width:a.width,height:a.height,text:i.originalText})}return i}),captureUpdate:D.IMMEDIATELY}}});var ef=F({name:"viewMode",label:"labels.viewMode",icon:Sa,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,t){return{appState:{...t,viewModeEnabled:!this.checked(t)},captureUpdate:D.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,t,o)=>typeof o.viewModeEnabled>"u",keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===me.R});import{jsx as Ik}from"react/jsx-runtime";var tf=(e,t,o,r,n,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(o,r,i))&&fe(e.trackEvent.category,e.trackEvent.action||e.name,`${t} (${n.device.editor.isMobile?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},Zm=class{constructor(t,o,r,n){S(this,"actions",{});S(this,"updater");S(this,"getAppState");S(this,"getElementsIncludingDeleted");S(this,"app");S(this,"renderAction",(t,o)=>{let r=this.app.props.UIOptions.canvasActions;if(this.actions[t]&&"PanelComponent"in this.actions[t]&&(!(t in r)||r[t])){let n=this.actions[t],i=n.PanelComponent;i.displayName="PanelComponent";let a=this.getElementsIncludingDeleted(),l=this.getAppState(),s=c=>{tf(n,"ui",l,a,this.app,c),this.updater(n.perform(this.getElementsIncludingDeleted(),this.getAppState(),c,this.app))};return Ik(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:s,appProps:this.app.props,app:this.app,data:o})}return null});S(this,"isActionEnabled",t=>{let o=this.getElementsIncludingDeleted(),r=this.getAppState();return!t.predicate||t.predicate(o,r,this.app.props,this.app)});this.updater=i=>{if(pn(i))i.then(a=>t(a));else return t(i)},this.getAppState=o,this.getElementsIncludingDeleted=r,this.app=n}registerAction(t){this.actions[t.name]=t}registerAll(t){t.forEach(o=>this.registerAction(o))}handleKeyDown(t){let o=this.app.props.UIOptions.canvasActions,r=Object.values(this.actions).sort((s,c)=>(c.keyPriority||0)-(s.keyPriority||0)).filter(s=>(s.name in o?o[s.name]:!0)&&s.keyTest&&s.keyTest(t,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(r.length!==1)return r.length>1&&console.warn("Canceling as multiple actions match this shortcut",r),!1;let n=r[0];if(this.getAppState().viewModeEnabled&&n.viewMode!==!0)return!1;let i=this.getElementsIncludingDeleted(),a=this.getAppState(),l=null;return tf(n,"keyboard",a,i,this.app,null),t.preventDefault(),t.stopPropagation(),this.updater(r[0].perform(i,a,l,this.app)),!0}executeAction(t,o="api",r=null){let n=this.getElementsIncludingDeleted(),i=this.getAppState();tf(t,o,i,n,this.app,r),this.updater(t.perform(n,i,r,this.app))}};var Xm=class{constructor(){S(this,"targets",new WeakMap);S(this,"rafIds",new WeakMap)}register(t,o){this.targets.set(t,{callback:o,stopped:!0})}start(t){let o=this.targets.get(t);o&&(this.rafIds.has(t)||(this.targets.set(t,{...o,stopped:!1}),this.scheduleFrame(t)))}stop(t){let o=this.targets.get(t);o&&!o.stopped&&this.targets.set(t,{...o,stopped:!0}),this.cancelFrame(t)}constructFrame(t){return o=>{let r=this.targets.get(t);if(!r)return;let n=this.onFrame(r,o);!r.stopped&&!n?this.scheduleFrame(t):this.cancelFrame(t)}}scheduleFrame(t){let o=requestAnimationFrame(this.constructFrame(t));this.rafIds.set(t,o)}cancelFrame(t){if(this.rafIds.has(t)){let o=this.rafIds.get(t);cancelAnimationFrame(o)}this.rafIds.delete(t)}onFrame(t,o){return t.callback(o)??!1}};var of=e=>{let t=Array.from(e.values());return{x:Sw(t,o=>o.x)/t.length,y:Sw(t,o=>o.y)/t.length}},rf=([e,t])=>Math.hypot(e.x-t.x,e.y-t.y),Sw=(e,t)=>e.reduce((o,r)=>o+t(r),0);var kk=8,Cw=99999,$m=e=>kk/e,Qt=class Qt{};S(Qt,"referenceSnapPoints",null),S(Qt,"visibleGaps",null),S(Qt,"setReferenceSnapPoints",t=>{Qt.referenceSnapPoints=t}),S(Qt,"getReferenceSnapPoints",()=>Qt.referenceSnapPoints),S(Qt,"setVisibleGaps",t=>{Qt.visibleGaps=t}),S(Qt,"getVisibleGaps",()=>Qt.visibleGaps),S(Qt,"destroy",()=>{Qt.referenceSnapPoints=null,Qt.visibleGaps=null});var zo=Qt,Rn=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,qr=({event:e,app:t,selectedElements:o})=>e?t.state.objectsSnapModeEnabled&&!e[T.CTRL_OR_CMD]||!t.state.objectsSnapModeEnabled&&e[T.CTRL_OR_CMD]&&!Rn(t):o.length===1&&o[0].type==="arrow"?!1:t.state.objectsSnapModeEnabled,Mk=(e,t,o=.01)=>Math.abs(e-t)<=o,Ds=(e,t,{omitCenter:o,boundingBoxCorners:r,dragOffset:n}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[l,s,c,m,d,p]=Ve(a,t);n&&(l+=n.x,c+=n.x,d+=n.x,s+=n.y,m+=n.y,p+=n.y);let u=(c-l)/2,h=(m-s)/2;if((a.type==="diamond"||a.type==="ellipse")&&!r){let x=ie(M(l,s+h),M(d,p),a.angle),b=ie(M(l+u,s),M(d,p),a.angle),E=ie(M(c,s+h),M(d,p),a.angle),w=ie(M(l+u,m),M(d,p),a.angle),y=M(d,p);i=o?[x,b,E,w]:[x,b,E,w,y]}else{let x=ie(M(l,s),M(d,p),a.angle),b=ie(M(c,s),M(d,p),a.angle),E=ie(M(l,m),M(d,p),a.angle),w=ie(M(c,m),M(d,p),a.angle),y=M(d,p);i=o?[x,b,E,w]:[x,b,E,w,y]}}else if(e.length>1){let[a,l,s,c]=Kc(e,n??{x:0,y:0}),m=s-a,d=c-l,p=M(a,l),u=M(s,l),h=M(a,c),x=M(s,c),b=M(a+m/2,l+d/2);i=o?[p,u,h,x]:[p,u,h,x,b]}return i.map(a=>M(ot(a[0]),ot(a[1])))},Mw=(e,t,o,r)=>{let n=t.filter(i=>J(i)).map(i=>i.id);return fu(e,t,o,r).filter(i=>!(i.frameId&&n.includes(i.frameId)))},Aw=(e,t,o,r)=>{let n=Mw(e,t,o,r),i=ci(n,r).filter(d=>!(d.length===1&&He(d[0]))).map(d=>Ee(d).map(p=>ot(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>Cw)break e;let h=a[u],[,x,b,E]=p,[w,y,,v]=h;b<w&&kl(Eo(x,E),Eo(y,v))&&l.push({startBounds:p,endBounds:h,startSide:[M(b,x),M(b,E)],endSide:[M(w,y),M(w,v)],length:w-b,overlap:Ml(Eo(x,E),Eo(y,v))})}}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>Cw)break e;let h=c[u],[x,,b,E]=p,[w,y,v]=h;E<y&&kl(Eo(x,b),Eo(w,v))&&m.push({startBounds:p,endBounds:h,startSide:[M(x,E),M(b,E)],endSide:[M(w,y),M(v,y)],length:y-E,overlap:Ml(Eo(x,b),Eo(w,v))})}}return{horizontalGaps:l,verticalGaps:m}},Iw=(e,t,o,r,n,i,a)=>{if(!qr({app:o,event:r,selectedElements:e}))return[];if(e.length===0)return[];let l=zo.getVisibleGaps();if(l){let{horizontalGaps:s,verticalGaps:c}=l,[m,d,p,u]=Kc(e,t).map(b=>ot(b)),h=(m+p)/2,x=(d+u)/2;for(let b of s){if(!kl(Eo(d,u),b.overlap))continue;let E=b.startSide[0][0]+b.length/2,w=ot(E-h);if(b.length>p-m&&Math.abs(w)<=a.x){Math.abs(w)<a.x&&(n.length=0),a.x=Math.abs(w);let _={type:"gap",direction:"center_horizontal",gap:b,offset:w};n.push(_);continue}let[,,v]=b.endBounds,C=m-v,I=ot(b.length-C);if(Math.abs(I)<=a.x){Math.abs(I)<a.x&&(n.length=0),a.x=Math.abs(I);let _={type:"gap",direction:"side_right",gap:b,offset:I};n.push(_);continue}let[L,,,]=b.startBounds,A=L-p,R=ot(A-b.length);if(Math.abs(R)<=a.x){Math.abs(R)<a.x&&(n.length=0),a.x=Math.abs(R);let _={type:"gap",direction:"side_left",gap:b,offset:R};n.push(_);continue}}for(let b of c){if(!kl(Eo(m,p),b.overlap))continue;let E=b.startSide[0][1]+b.length/2,w=ot(E-x);if(b.length>u-d&&Math.abs(w)<=a.y){Math.abs(w)<a.y&&(i.length=0),a.y=Math.abs(w);let _={type:"gap",direction:"center_vertical",gap:b,offset:w};i.push(_);continue}let[,v,,]=b.startBounds,C=v-u,I=ot(C-b.length);if(Math.abs(I)<=a.y){Math.abs(I)<a.y&&(i.length=0),a.y=Math.abs(I);let _={type:"gap",direction:"side_top",gap:b,offset:I};i.push(_);continue}let[,,,L]=b.endBounds,A=ot(d-L),R=b.length-A;if(Math.abs(R)<=a.y){Math.abs(R)<a.y&&(i.length=0),a.y=Math.abs(R);let _={type:"gap",direction:"side_bottom",gap:b,offset:R};i.push(_);continue}}}},Lw=(e,t,o,r)=>{let n=Mw(e,t,o,r);return ci(n,r).filter(i=>!(i.length===1&&He(i[0]))).flatMap(i=>Ds(i,r))},nl=(e,t,o,r,n,i,a)=>{if(!qr({app:o,event:r,selectedElements:e})||e.length===0&&t.length===0)return[];let l=zo.getReferenceSnapPoints();if(l)for(let s of t)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))}},Dw=(e,t,o,r,n)=>{let i=o.state,a=Q(e,i);if(!qr({app:o,event:r,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};t.x=ot(t.x),t.y=ot(t.y);let l=[],s=[],c=$m(i.zoom.value),m={x:c,y:c},d=Ds(a,n,{dragOffset:t});nl(a,d,o,r,l,s,m),Iw(a,t,o,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:ot(t.x+p.x),y:ot(t.y+p.y)};nl(a,Ds(a,n,{dragOffset:u}),o,r,l,s,m),Iw(a,u,o,r,l,s,m);let h=nf(l,s),x=Lk(a,u,[...l,...s].filter(b=>b.type==="gap"));return{snapOffset:p,snapLines:[...h,...x]}},ot=e=>Math.round(e*10**6)/10**6,kw=e=>{let t=new Map;for(let o of e){let r=o.join(",");t.has(r)||t.set(r,o)}return Array.from(t.values())},nf=(e,t)=>{let o={},r={};if(e.length>0){for(let n of e)if(n.type==="point"){let i=ot(n.points[0][0]);o[i]||(o[i]=[]),o[i].push(...n.points.map(a=>M(ot(a[0]),ot(a[1]))))}}if(t.length>0){for(let n of t)if(n.type==="point"){let i=ot(n.points[0][1]);r[i]||(r[i]=[]),r[i].push(...n.points.map(a=>M(ot(a[0]),ot(a[1]))))}}return Object.entries(o).map(([n,i])=>({type:"points",points:kw(i.map(a=>M(Number(n),a[1])).sort((a,l)=>a[1]-l[1]))})).concat(Object.entries(r).map(([n,i])=>({type:"points",points:kw(i.map(a=>M(a[0],Number(n))).sort((a,l)=>a[0]-l[0]))})))},Ak=e=>{let t=new Map;for(let o of e){let r=o.points.flat().map(n=>[ot(n)]).join(",");t.has(r)||t.set(r,o)}return Array.from(t.values())},Lk=(e,t,o)=>{let[r,n,i,a]=Kc(e,t),l=[];for(let s of o){let[c,m,d,p]=s.gap.startBounds,[u,h,x,b]=s.gap.endBounds,E=Ml(Eo(n,a),s.gap.overlap),w=Ml(Eo(r,i),s.gap.overlap);switch(s.direction){case"center_horizontal":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"horizontal",points:[M(s.gap.startSide[0][0],y),M(r,y)]},{type:"gap",direction:"horizontal",points:[M(i,y),M(s.gap.endSide[0][0],y)]})}break}case"center_vertical":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"vertical",points:[M(y,s.gap.startSide[0][1]),M(y,n)]},{type:"gap",direction:"vertical",points:[M(y,a),M(y,s.gap.endSide[0][1])]})}break}case"side_right":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"horizontal",points:[M(d,y),M(u,y)]},{type:"gap",direction:"horizontal",points:[M(x,y),M(r,y)]})}break}case"side_left":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"horizontal",points:[M(i,y),M(c,y)]},{type:"gap",direction:"horizontal",points:[M(d,y),M(u,y)]})}break}case"side_top":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"vertical",points:[M(y,a),M(y,m)]},{type:"gap",direction:"vertical",points:[M(y,p),M(y,h)]})}break}case"side_bottom":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"vertical",points:[M(y,p),M(y,h)]},{type:"gap",direction:"vertical",points:[M(y,b),M(y,n)]})}break}}}return Ak(l.map(s=>({...s,points:s.points.map(c=>M(ot(c[0]),ot(c[1])))})))},af=(e,t,o,r,n,i)=>{if(!qr({event:r,selectedElements:e,app:o})||e.length===0||e.length===1&&!Mk(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,l,s,c]=Ee(t);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(M(s,l),M(s,c));break}case"w":{m.push(M(a,l),M(a,c));break}case"n":{m.push(M(a,l),M(s,l));break}case"s":{m.push(M(a,c),M(s,c));break}case"ne":{m.push(M(s,l));break}case"nw":{m.push(M(a,l));break}case"se":{m.push(M(s,c));break}case"sw":{m.push(M(a,c));break}}let d=$m(o.state.zoom.value),p={x:d,y:d},u=[],h=[];nl(t,m,o,r,u,h,p);let x={x:u[0]?.offset??0,y:h[0]?.offset??0};p.x=0,p.y=0,u.length=0,h.length=0;let[b,E,w,y]=Ee(e).map(I=>ot(I)),v=[M(b,E),M(b,y),M(w,E),M(w,y)];nl(e,v,o,r,u,h,p);let C=nf(u,h);return{snapOffset:x,snapLines:C}},_w=(e,t,o,r,n,i)=>{if(!qr({event:o,selectedElements:[e],app:t}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[M(r.x+n.x,r.y+n.y)],l=$m(t.state.zoom.value),s={x:l,y:l},c=[],m=[];nl([e],a,t,o,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=Ds([e],i,{boundingBoxCorners:!0,omitCenter:!0});nl([e],p,t,o,c,m,s);let u=nf(c,m);return{snapOffset:d,snapLines:u}},Pw=(e,t,o,r,n)=>{if(!qr({event:r,selectedElements:[],app:t}))return{originOffset:{x:0,y:0},snapLines:[]};let i=fu(e,[],t.state,n),a=$m(t.state.zoom.value),l={x:a,y:a},s=[],c=[];for(let m of i){let d=Ds([m],n);for(let p of d){let u=p[0]-o.x;Math.abs(u)<=Math.abs(l.x)&&(Math.abs(u)<Math.abs(l.x)&&(c.length=0),c.push({type:"pointer",points:[p,M(p[0],o.y)],direction:"vertical"}),l.x=u);let h=p[1]-o.y;Math.abs(h)<=Math.abs(l.y)&&(Math.abs(h)<Math.abs(l.y)&&(s.length=0),s.push({type:"pointer",points:[p,M(o.x,p[1])],direction:"horizontal"}),l.y=h)}}return{originOffset:{x:c.length>0?c[0].points[0][0]-o.x:0,y:s.length>0?s[0].points[0][1]-o.y:0},snapLines:[...c,...s]}},Rw=e=>e===at.rectangle||e===at.ellipse||e===at.diamond||e===at.frame||e===at.magicframe||e===at.image||e===at.text;var jm={width:100,height:0},Nn=100,Dk=(e,t,o)=>{let r=Xt({x:0,y:0,textAlign:Tl.CENTER,verticalAlign:io.MIDDLE,...t,containerId:e.id,strokeColor:t.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:r.id})}),Xe(r,e,o),[e,r]},Nw=(e,t,o,r,n)=>{let i,a;if(Object.assign(e,{startBinding:e?.startBinding||null,endBinding:e.endBinding||null}),t){let m=t?.width??Nn,d=t?.height??Nn,p;t.id&&(p=r.getElement(t.id),p||console.error(`No element for start binding with id ${t.id} found`));let u=t.x||e.x-m,h=t.y||e.y-d/2,x=p?p.type:t.type;if(x){if(x==="text"){let b="";p&&p.type==="text"?b=p.text:t.type==="text"&&(b=t.text),b||console.error(`No text found for start binding text element for ${e.id}`),i=Xt({x:u,y:h,type:"text",...p,...t,text:b}),Object.assign(i,{x:t.x||e.x-i.width,y:t.y||e.y-i.height/2})}else switch(x){case"rectangle":case"ellipse":case"diamond":{i=Rt({x:u,y:h,width:m,height:d,...p,...t,type:x});break}default:Xo(e,`Unhandled element start type "${t.type}"`,!0)}Qo(e,i,"start",n)}}if(o){let m=o?.height??Nn,d=o?.width??Nn,p;o.id&&(p=r.getElement(o.id),p||console.error(`No element for end binding with id ${o.id} found`));let u=o.x||e.x+e.width,h=o.y||e.y-m/2,x=p?p.type:o.type;if(x){if(x==="text"){let b="";p&&p.type==="text"?b=p.text:o.type==="text"&&(b=o.text),b||console.error(`No text found for end binding text element for ${e.id}`),a=Xt({x:u,y:h,type:"text",...p,...o,text:b}),Object.assign(a,{y:o.y||e.y-a.height/2})}else switch(x){case"rectangle":case"ellipse":case"diamond":{a=Rt({x:u,y:h,width:d,height:m,...p,...o,type:x});break}default:Xo(e,`Unhandled element end type "${x}"`,!0)}Qo(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=lo(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,$.getNormalizedPoints({...e,points:c})),{linearElement:e,startBoundElement:i,endBoundElement:a}},lf=class{constructor(){S(this,"excalidrawElements",new Map);S(this,"add",t=>{t&&this.excalidrawElements.set(t.id,t)});S(this,"getElements",()=>tr(Array.from(this.excalidrawElements.values())));S(this,"getElementsMap",()=>Br(q(this.getElements())));S(this,"getElement",t=>this.excalidrawElements.get(t))}},il=(e,t)=>{if(!e)return[];let o=lo(e),r=new lf,n=new Map,i=new Map;for(let s of o){let c,m=s.id;switch(t?.regenerateIds!==!1&&Object.assign(s,{id:Ht()}),s.type){case"rectangle":case"ellipse":case"diamond":{let p=s?.label?.text&&s.width===void 0?0:s?.width||Nn,u=s?.label?.text&&s.height===void 0?0:s?.height||Nn;c=Rt({...s,width:p,height:u});break}case"line":{let p=s.width||jm.width,u=s.height||jm.height;c=yo({width:p,height:u,points:[M(0,0),M(p,u)],...s});break}case"arrow":{let p=s.width||jm.width,u=s.height||jm.height;c=er({width:p,height:u,endArrowhead:"arrow",points:[M(0,0),M(p,u)],...s,type:"arrow"}),Object.assign(c,nb(c.points));break}case"text":{let p=s?.fontFamily||nn,u=s?.fontSize||Rr,h=s?.lineHeight||Ko(p),x=s.text??"",b=li(x),E=ut(b,Ge({fontFamily:p,fontSize:u}),h);c=Xt({width:E.width,height:E.height,fontFamily:p,fontSize:u,...s});break}case"image":{c=Xc({width:s?.width||Nn,height:s?.height||Nn,...s});break}case"frame":{c=ia({x:0,y:0,...s});break}case"magicframe":{c=Ul({x:0,y:0,...s});break}case"freedraw":case"iframe":case"embeddable":{c=s;break}default:c=s,Xo(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 Ei(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]=Dk(m,c?.label,l);if(r.add(d),r.add(p),Ie(d)){let u=c.type==="arrow"?c?.start:void 0,h=c.type==="arrow"?c?.end:void 0;if(u&&u.id){let w=i.get(u.id);w&&Object.assign(u,{id:w})}if(h&&h.id){let w=i.get(h.id);w&&Object.assign(h,{id:w})}let{linearElement:x,startBoundElement:b,endBoundElement:E}=Nw(d,u,h,r,l);d=x,r.add(x),r.add(b),r.add(E)}}else switch(c.type){case"arrow":{let{start:d,end:p}=c;if(d&&d.id){let b=i.get(d.id);Object.assign(d,{id:b})}if(p&&p.id){let b=i.get(p.id);Object.assign(p,{id:b})}let{linearElement:u,startBoundElement:h,endBoundElement:x}=Nw(m,d,p,r,l);r.add(u),r.add(h),r.add(x);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(C=>{let I=i.get(C);if(!I)throw new Error(`Element with ${C} wasn't mapped correctly`);let L=r.getElement(I);if(!L)throw new Error(`Frame element with id ${I} doesn't exist`);Object.assign(L,{frameId:m.id}),L?.boundElements?.forEach(A=>{let R=r.getElement(A.id);if(!R)throw new Error(`Bound element with id ${A.id} doesn't exist`);Object.assign(R,{frameId:m.id}),d.push(R)}),d.push(L)});let[p,u,h,x]=Ee(d),b=10;p=p-b,u=u-b,h=h+b,x=x+b;let E=m?.x||p,w=m?.y||u,y=m?.width||h-p,v=m?.height||x-u;Object.assign(m,{x:E,y:w,width:y,height:v}),Oe()&&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 qm from"open-color";var _k="#ff6b6b",Pk="#ff0000",Ow=1,Bw=2,Fw=(e,t)=>{if(!t.snapLines.length)return;let o=t.theme===se.LIGHT||t.zenModeEnabled?_k:Pk,r=(t.zenModeEnabled?Ow*1.5:Ow)/t.zoom.value;e.save(),e.translate(t.scrollX,t.scrollY);for(let n of t.snapLines)n.type==="pointer"?(e.lineWidth=r,e.strokeStyle=o,Nk(n,e,t)):n.type==="gap"?(e.lineWidth=r,e.strokeStyle=o,Ok(n.points[0],n.points[1],n.direction,t,e)):n.type==="points"&&(e.lineWidth=r,e.strokeStyle=o,Rk(n,e,t));e.restore()},Rk=(e,t,o)=>{if(!o.zenModeEnabled){let r=e.points[0],n=e.points[e.points.length-1];Ho(r,n,t)}for(let r of e.points)zw(r,o,t)},Nk=(e,t,o)=>{zw(e.points[0],o,t),o.zenModeEnabled||Ho(e.points[0],e.points[1],t)},zw=([e,t],o,r)=>{r.save();let n=(o.zenModeEnabled?Bw*1.5:Bw)/o.zoom.value;r.beginPath(),r.moveTo(e-n,t-n),r.lineTo(e+n,t+n),r.moveTo(e+n,t-n),r.lineTo(e-n,t+n),r.stroke(),r.restore()},Ho=(e,t,o)=>{o.beginPath(),o.lineTo(e[0],e[1]),o.lineTo(t[0],t[1]),o.stroke()},Ok=(e,t,o,r,n)=>{let i=8/r.zoom.value,a=i/2,l=i/4;if(o==="horizontal"){let s=[(e[0]+t[0])/2,e[1]];r.zenModeEnabled||Ho(M(e[0],e[1]-i),M(e[0],e[1]+i),n),Ho(M(s[0]-l,s[1]-a),M(s[0]-l,s[1]+a),n),Ho(M(s[0]+l,s[1]-a),M(s[0]+l,s[1]+a),n),r.zenModeEnabled||(Ho(M(t[0],t[1]-i),M(t[0],t[1]+i),n),Ho(e,t,n))}else{let s=[e[0],(e[1]+t[1])/2];r.zenModeEnabled||Ho(M(e[0]-i,e[1]),M(e[0]+i,e[1]),n),Ho(M(s[0]-a,s[1]-l),M(s[0]+a,s[1]-l),n),Ho(M(s[0]-a,s[1]+l),M(s[0]+a,s[1]+l),n),r.zenModeEnabled||(Ho(M(t[0]-i,t[1]),M(t[0]+i,t[1]),n),Ho(e,t,n))}};var cr=4,go=6,Hw="rgba(0,0,0,0.3)",Uw=(e,t,o,r)=>{if(!e.size)return{horizontal:null,vertical:null};let[n,i,a,l]=Ee(e),s=t/r.zoom.value,c=o/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=Yr().rtl,p=-r.scrollX+m.left,u=-r.scrollY+m.top,h=p+s-m.right,x=u+c-m.bottom,b=Math.min(n,p),E=Math.min(i,u),w=Math.max(a,h),y=Math.max(l,x),v=a-n,C=l-i,I=w-b,L=y-E,A=Math.max(cr*2,m.left+m.right)+go*2,R=t*(s/I)-A,_=Math.max(cr*2,m.top+m.bottom)+go*2,z=o*(c/L)-_,W=I>v?I*r.zoom.value/(R+A):t/(R+A),G=L>C?L*r.zoom.value/(z+_):o/(z+_);return{horizontal:p===b&&h===w?null:{x:Math.max(m.left,cr)+go+(p-b)/I*t,y:o-go-Math.max(cr,m.bottom),width:R,height:go,deltaMultiplier:W},vertical:u===E&&x===y?null:{x:d?Math.max(m.left,cr):t-go-Math.max(m.right,cr),y:Math.max(m.top,cr)+go+(u-E)/L*o,width:go,height:z,deltaMultiplier:G}}},sf=(e,t,o)=>{let[r,n]=[e.horizontal,e.vertical].map(a=>a!=null&&a.x<=t&&t<=a.x+a.width&&a.y<=o&&o<=a.y+a.height);return{isOverEither:r||n,isOverHorizontal:r,isOverVertical:n}};var Bk=(e,t)=>{hn(t.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:o}=t.selectedLinearElement;hn(o,"midPointCoords is null"),e.save(),e.translate(t.scrollX,t.scrollY),Vw(o,e,t),e.restore()},Fk=(e,t,o)=>{let{elementId:r,hoverPointIndex:n}=t.selectedLinearElement;if(t.editingLinearElement?.selectedPointsIndices?.includes(n))return;let i=$.getElement(r,o);if(!i)return;let a=$.getPointAtIndexGlobalCoordinates(i,n,o);e.save(),e.translate(t.scrollX,t.scrollY),Vw(a,e,t),e.restore()},Vw=(e,t,o)=>{t.fillStyle="rgba(105, 101, 219, 0.4)",Kl(t,e[0],e[1],$.POINT_HANDLE_SIZE/o.zoom.value,!1)},cf=(e,t,o,r,n,i=!1)=>{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)"),Kl(e,o[0],o[1],r/t.zoom.value,!i)},zk=(e,t,o,r)=>{let[n,i,a,l]=Ve(t,o),s=a-n,c=l-i;e.strokeStyle="rgba(0,0,0,.05)",e.fillStyle="rgba(0,0,0,.05)";let m=Yc(t,t.width,t.height,r);switch(t.type){case"rectangle":case"text":case"image":case"iframe":case"embeddable":case"frame":case"magicframe":Z0(e,t,m);break;case"diamond":$0(e,m,t);break;case"ellipse":e.lineWidth=Yc(t,t.width,t.height,r)-Hc,X0(e,s+m+Hc,c+m+Hc,n+s/2,i+c/2,t.angle);break}},Hk=(e,t,o,r)=>{let[n,i,a]=t,l=Yc(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,o);Kl(e,m,d,l)})},Yw=(e,t,o)=>{let{angle:r,x1:n,y1:i,x2:a,y2:l,selectionColors:s,cx:c,cy:m,dashed:d,activeEmbeddable:p}=o,u=a-n,h=l-i,b=(o.padding??an*2)/t.zoom.value,E=8/t.zoom.value,w=4/t.zoom.value;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=(p?4:1)/t.zoom.value;let y=s.length;for(let v=0;v<y;++v)e.strokeStyle=s[v],d&&e.setLineDash([E,w+(E+w)*(y-1)]),e.lineDashOffset=(E+w)*v,Zl(e,n-b,i-b,u+b*2,h+b*2,c,m,r);e.restore()},Uk=(e,t,o,r)=>{let n=Array.isArray(o)?Hk:zk;e.save(),e.translate(t.scrollX,t.scrollY),n(e,o,r,t.zoom),e.restore()},Gk=(e,t,o,r)=>{let[n,i,a,l]=Ve(o,r),s=a-n,c=l-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=Ft.strokeWidth/t.zoom.value,e.save(),e.translate(t.scrollX,t.scrollY),Zl(e,n,i,s,c,n+s/2,i+c/2,o.angle,!1,Ft.radius/t.zoom.value),e.restore()},Vk=(e,t,o)=>{let r=o.filter(l=>l.groupIds.length===0),n=o.filter(l=>l.groupIds.length>0),i=l=>{let[s,c,m,d]=Ee(l);return{angle:0,x1:s,x2:m,y1:c,y2:d,selectionColors:["rgb(0,118,255)"],dashed:!1,cx:s+(m-s)/2,cy:c+(d-c)/2,activeEmbeddable:!1}},a=l=>{let s=Be(o,l);return i(s)};Object.entries(Qb(n,t)).filter(([l,s])=>s).map(([l,s])=>l).map(l=>a(l)).concat(r.map(l=>i([l]))).forEach(l=>Yw(e,t,l))},df=(e,t,o,r)=>{if(!t.selectedLinearElement)return;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=1/t.zoom.value;let n=$.getPointsGlobalCoordinates(o,r),{POINT_HANDLE_SIZE:i}=$,a=t.editingLinearElement?i:i/2;if(n.forEach((l,s)=>{if(ee(o)&&s!==0&&s!==n.length-1)return;let c=!!t.editingLinearElement?.selectedPointsIndices?.includes(s);cf(e,t,l,a,c)}),ee(o)){let l=o.fixedSegments?.map(s=>s.index)||[];n.slice(0,-1).forEach((s,c)=>{$.isSegmentTooShort(o,n[c+1],n[c],c,t.zoom)||cf(e,t,M((s[0]+n[c+1][0])/2,(s[1]+n[c+1][1])/2),i/2,!1,!l.includes(c+1))})}else $.getEditorMidPoints(o,r,t).filter((s,c,m)=>s!==null&&!(ee(o)&&(c===0||c===m.length-1))).forEach(s=>{(t.editingLinearElement||n.length===2)&&cf(e,t,s,i/2,!1,!0)});e.restore()},Gw=(e,t,o,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/o.zoom.value,t.selectionColor&&(e.strokeStyle=t.selectionColor),i==="rotation"?Kl(e,l+c/2,s+m/2,c/2):e.roundRect?(e.beginPath(),e.roundRect(l,s,c,m,2/o.zoom.value),e.fill(),e.stroke()):Zl(e,l,s,c,m,l+c/2,s+m/2,n,!0),e.restore()}})},Yk=(e,t,o,r,n)=>{let[i,a,,,l,s]=Ve(r,n),c=3,m=20,d=c/o.zoom.value,p=d/2,u=l-i+d,h=s-a+d,x=Math.min(m/o.zoom.value,u),b=Math.min(m/o.zoom.value,h);e.save(),e.fillStyle=t.selectionColor,e.strokeStyle=t.selectionColor,e.lineWidth=d,[[[-u,-h],[0,p],[x,p],[p,0],[p,b]],[[u-p,-h],[p,p],[-x+p,p],[0,0],[0,b]],[[-u,h],[0,-p],[x,-p],[p,0],[p,-b]],[[u-p,h],[p,-p],[-x+p,-p],[0,0],[0,-b]]].forEach(w=>{let[[y,v],[C,I],[L,A],[R,_],[z,W]]=w;e.save(),e.translate(l,s),e.rotate(r.angle),e.beginPath(),e.moveTo(y+C,v+I),e.lineTo(y+L,v+A),e.stroke(),e.beginPath(),e.moveTo(y+R,v+_),e.lineTo(y+z,v+W),e.stroke(),e.restore()}),e.restore()},Wk=(e,t,o,r)=>{t.save();let n=an*2/o.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);t.translate(l+o.scrollX,s+o.scrollY),t.rotate(e.angle),t.lineWidth=1/o.zoom.value,t.strokeStyle=r,t.strokeRect(c,m,i,a),t.restore()},Ww=({canvas:e,elementsMap:t,visibleElements:o,selectedElements:r,allElementsMap:n,scale:i,appState:a,renderConfig:l,device:s})=>{if(e===null)return{atLeastOneVisibleElement:!1,elementsMap:t};let[c,m]=od(e,i),d=rd({canvas:e,scale:i,normalizedWidth:c,normalizedHeight:m});d.save(),d.scale(a.zoom.value,a.zoom.value);let p;if(o.forEach(x=>{a.editingLinearElement?.elementId===x.id&&x&&(p=x)}),p&&df(d,a,p,t),a.selectionElement&&!a.isCropping)try{y0(a.selectionElement,d,a,l.selectionColor)}catch(x){console.error(x)}if(a.editingTextElement&&K(a.editingTextElement)){let x=n.get(a.editingTextElement.id);x&&!x.autoResize&&Wk(x,d,a,l.selectionColor)}a.isBindingEnabled&&a.suggestedBindings.filter(x=>x!=null).forEach(x=>{Uk(d,a,x,t)}),a.frameToHighlight&&Gk(d,a,a.frameToHighlight,t),a.elementsToHighlight&&Vk(d,a,a.elementsToHighlight);let u=r.some(x=>J(x));if(r.length===1&&a.editingLinearElement?.elementId===r[0].id&&df(d,a,r[0],t),a.selectedLinearElement){let x=a.selectedLinearElement,b=r.find(E=>E.id===x.elementId);x.segmentMidPointHoveredCoords?Bk(d,a):(ee(b)?x.hoverPointIndex===0||x.hoverPointIndex===b.points.length-1:x.hoverPointIndex>=0)&&Fk(d,a,t)}if(!a.multiElement&&!a.editingLinearElement){let x=md(r,a),b=r.length===1&&le(r[0]);b&&a.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&df(d,a,r[0],t);let E=l.selectionColor||qm.black;if(x){let w=q(r),y=[];for(let C of t.values()){let I=[],L=l.remoteSelectedElementIds.get(C.id);if(b&&ee(C)&&(C.startBinding||C.endBinding)||(w.has(C.id)&&!_c(a,C)&&I.push(E),L&&I.push(...L.map(A=>Ni(A,a.collaborators.get(A))))),I.length){let[A,R,_,z,W,G]=Ve(C,t,!0);y.push({angle:C.angle,x1:A,y1:R,x2:_,y2:z,selectionColors:I,dashed:!!L,cx:W,cy:G,activeEmbeddable:a.activeEmbeddable?.element===C&&a.activeEmbeddable.state==="active",padding:C.id===a.croppingElementId||xe(C)?0:void 0})}}let v=C=>{let I=Be(t,C),[L,A,R,_]=Ee(I);y.push({angle:0,x1:L,x2:R,y1:A,y2:_,selectionColors:[qm.black],dashed:!0,cx:L+(R-L)/2,cy:A+(_-A)/2,activeEmbeddable:!1})};for(let C of qo(a))v(C);a.editingGroupId&&v(a.editingGroupId),y.forEach(C=>Yw(d,a,C))}if(d.save(),d.translate(a.scrollX,a.scrollY),r.length===1){d.fillStyle=qm.white;let w=dd(r[0],a.zoom,t,"mouse",fi(s));if(!a.viewModeEnabled&&x&&!K(a.editingTextElement)&&!a.croppingElementId&&Gw(d,l,a,w,r[0].angle),a.croppingElementId&&!a.isCropping){let y=t.get(a.croppingElementId);y&&xe(y)&&Yk(d,l,a,y,t)}}else if(r.length>1&&!a.isRotating){let w=an*2/a.zoom.value;d.fillStyle=qm.white;let[y,v,C,I]=Ee(r,t),L=d.getLineDash();d.setLineDash([2/a.zoom.value]);let A=d.lineWidth;d.lineWidth=1/a.zoom.value,d.strokeStyle=E,Zl(d,y-w,v-w,C-y+w*2,I-v+w*2,(y+C)/2,(v+I)/2,0),d.lineWidth=A,d.setLineDash(L);let R=jl([y,v,C,I,(y+C)/2,(v+I)/2],0,a.zoom,"mouse",u?{...fi(s),rotation:!0}:fi(s));r.some(_=>!_.locked)&&Gw(d,l,a,R,0)}d.restore()}a.searchMatches?.matches.forEach(({id:x,focus:b,matchedLines:E})=>{let w=t.get(x);if(w){let[y,v,,,C,I]=Ve(w,t,!0);d.save(),a.theme===se.LIGHT?b?d.fillStyle="rgba(255, 124, 0, 0.4)":d.fillStyle="rgba(255, 226, 0, 0.4)":b?d.fillStyle="rgba(229, 82, 0, 0.4)":d.fillStyle="rgba(99, 52, 0, 0.4)";let L=J(w)?a.zoom.value:1;d.translate(a.scrollX,a.scrollY),d.translate(C,I),d.rotate(w.angle),E.forEach(A=>{(A.showOnCanvas||b)&&d.fillRect(y+A.offsetX/L-C,v+A.offsetY/L-I,A.width/L,A.height/L)}),d.restore()}}),Fw(d,a),d.restore(),U2({context:d,renderConfig:l,appState:a,normalizedWidth:c,normalizedHeight:m});let h;return l.renderScrollbars&&(h=Uw(t,c,m,a),d.save(),d.fillStyle=Hw,d.strokeStyle="rgba(255,255,255,0.8)",[h.horizontal,h.vertical].forEach(x=>{x&&gm(d,x.x,x.y,x.width,x.height,go/2)}),d.restore()),{scrollBars:h,atLeastOneVisibleElement:o.length>0,elementsMap:t}},mf=Wi(e=>{let t=Ww(e);e.callback?.(t)},{trailing:!0}),Kw=(e,t)=>{if(t){mf(e);return}let o=Ww(e);return e.callback(o),o};var _s=class{constructor(t){S(this,"scene");S(this,"getRenderableElements",(()=>{let t=({elementsMap:r,zoom:n,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s,height:c,width:m})=>{let d=[];for(let p of r.values())Rl(p,m,c,{zoom:n,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s},r)&&d.push(p);return d},o=({elements:r,editingTextElement:n,newElementId:i,pendingImageElementId:a})=>{let l=Br(new Map);for(let s of r)xe(s)&&a===s.id||i!==s.id&&(!n||n.type!=="text"||s.id!==n.id)&&l.set(s.id,s);return l};return Eb(({zoom:r,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:l,height:s,width:c,editingTextElement:m,newElementId:d,pendingImageElementId:p,sceneNonce:u})=>{let h=this.scene.getNonDeletedElements(),x=o({elements:h,editingTextElement:m,newElementId:d,pendingImageElementId:p}),b=t({elementsMap:x,zoom:r,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:l,height:s,width:c});return{elementsMap:x,visibleElements:b}})})());this.scene=t}destroy(){mf.cancel(),j0.cancel(),this.getRenderableElements.clear()}};import{jsx as Xk}from"react/jsx-runtime";var Kk=5,Zk=(e,t,o)=>{let[r,n]=Ve(e,o),{x:i,y:a}=Pt({sceneX:r+e.width,sceneY:n},t),l=i-t.offsetLeft+10,s=a-t.offsetTop;return{x:l,y:s}},pf=({children:e,element:t,elementsMap:o})=>{let r=wr();if(r.contextMenu||r.newElement||r.resizingElement||r.isRotating||r.openMenu||r.viewModeEnabled)return null;let{x:n,y:i}=Zk(t,r,o);return Xk("div",{className:"excalidraw-canvas-buttons",style:{top:`${i}px`,left:`${n}px`,padding:Kk},children:e})};import{LaserPointer as $k}from"@excalidraw/laser-pointer";var Jr=class{constructor(t,o,r){this.animationFrameHandler=t;this.app=o;this.options=r;S(this,"currentTrail");S(this,"pastTrails",[]);S(this,"container");S(this,"trailElement");S(this,"trailAnimation");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.trailElement=document.createElementNS(Xp,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(Xp,"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(t,o){if(this.currentTrail){let r=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[r-1][0]===t&&this.currentTrail.originalPoints[r-1][1]===o}return!1}start(t){t&&(this.container=t),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),this.animationFrameHandler.start(this)}stop(){this.animationFrameHandler.stop(this),this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}startPath(t,o){this.currentTrail=new $k(this.options),this.currentTrail.addPoint([t,o,performance.now()]),this.update()}addPointToPath(t,o){this.currentTrail&&(this.currentTrail.addPoint([t,o,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 t=[];for(let r of this.pastTrails)t.push(this.drawTrail(r,this.app.state));if(this.currentTrail){let r=this.drawTrail(this.currentTrail,this.app.state);t.push(r)}this.pastTrails=this.pastTrails.filter(r=>r.getStrokeOutline().length!==0),t.length===0&&this.stop();let o=t.join(" ").trim();this.trailElement.setAttribute("d",o),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(t,o){let r=t.getStrokeOutline(t.options.size/o.zoom.value).map(([i,a])=>{let l=Pt({sceneX:i,sceneY:a},o);return[l.x,l.y]}),n=this.trailAnimation?r.slice(0,r.length/2):r;return yb(n,!0)}};var Jm=class{constructor(t,o){this.animationFrameHandler=t;this.app=o;S(this,"localTrail");S(this,"collabTrails",new Map);S(this,"container");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.localTrail=new Jr(t,o,{...this.getTrailOptions(),fill:()=>Up})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:t=>{let n=Math.max(0,1-(performance.now()-t.pressure)/1e3),i=(50-Math.min(50,t.totalLength-t.currentIndex))/50;return Math.min(Zo(i),Zo(n))}}}startPath(t,o){this.localTrail.startPath(t,o)}addPointToPath(t,o){this.localTrail.addPointToPath(t,o)}endPath(){this.localTrail.endPath()}start(t){this.container=t,this.animationFrameHandler.start(this),this.localTrail.start(t)}stop(){this.animationFrameHandler.stop(this),this.localTrail.stop()}onFrame(){this.updateCollabTrails()}updateCollabTrails(){if(!(!this.container||this.app.state.collaborators.size===0)){for(let[t,o]of this.app.state.collaborators.entries()){let r;this.collabTrails.has(t)?r=this.collabTrails.get(t):(r=new Jr(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>o.pointer?.laserColor||Ni(t,o)}),r.start(this.container),this.collabTrails.set(t,r)),o.pointer&&o.pointer.tool==="laser"&&(o.button==="down"&&!r.hasCurrentTrail&&r.startPath(o.pointer.x,o.pointer.y),o.button==="down"&&r.hasCurrentTrail&&!r.hasLastPoint(o.pointer.x,o.pointer.y)&&r.addPointToPath(o.pointer.x,o.pointer.y),o.button==="up"&&r.hasCurrentTrail&&(r.addPointToPath(o.pointer.x,o.pointer.y),r.endPath()))}for(let t of this.collabTrails.keys())this.app.state.collaborators.has(t)||(this.collabTrails.get(t).stop(),this.collabTrails.delete(t))}}};import{version as jk}from"react";import{unstable_batchedUpdates as Zw}from"react-dom";var rt=e=>t=>{Zw(e,t)},Qm=e=>Wi(t=>{Zw(e,t)}),al=(()=>{let e;try{let o=jk.split(".");e=Number(o[0])>17}catch{e=!1}let t=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(t||(t=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})();var qk=(e,t,o,r,n,i)=>{let{zoom:a}=r,l=180*o/Math.PI,s=e*(a.value-1)/2,c=t*(a.value-1)/2;return e>n&&a.value!==1&&(s=n*(a.value-1)/2),t>i&&a.value!==1&&(c=i*(a.value-1)/2),`translate(${s}px, ${c}px) scale(${a.value}) rotate(${l}deg)`},Xw=({id:e,onChange:t,onSubmit:o,getViewportCoords:r,element:n,canvas:i,excalidrawContainer:a,app:l,autoSelect:s=!0})=>{let c=(H,B)=>{if(!B.style.fontFamily||!B.style.fontSize)return!1;let U=B.style.fontFamily.replace(/"/g,"");return Jn({fontFamily:H.fontFamily})!==U||`${H.fontSize}px`!==B.style.fontSize},m=()=>{let H=l.state,B=l.scene.getElement(e);if(!B)return;let{textAlign:U,verticalAlign:oe}=B,Z=l.scene.getNonDeletedElementsMap();if(B&&K(B)){let ce=B.x,ue=B.y,he=Ut(B,l.scene.getNonDeletedElementsMap()),nt=B.width,to=B.height,pr=B.width,Yo=B.height;if(he&&B.containerId){if(Ie(he)){let rn=$.getBoundTextElementPosition(he,B,Z);ce=rn.x,ue=rn.y}let qs=c(B,d),fl;if(qs?fl=_l(he.id,he.height):(fl=Hb[he.id],fl||(fl=_l(he.id,he.height))),pr=bn(he,B),Yo=Dc(he,B),!Ie(he)&&to>Yo){let rn=qi(to,he.type);l.scene.mutateElement(he,{height:rn});return}else if(!Ie(he)&&he.height>fl.height&&to<Yo){let rn=qi(to,he.type);l.scene.mutateElement(he,{height:rn})}else{let{y:rn}=Ac(he,B,Z);ue=rn}}let[tn,oo]=r(ce,ue),ur=d.selectionStart,ro=d.selectionEnd,on=d.value.length;if(ur===ro&&ro!==on){let qs=on-ro;d.selectionStart=d.value.length-qs,d.selectionEnd=d.value.length-qs}he?nt+=.5:(pr=(H.width-8-tn)/H.zoom.value,nt=Math.min(nt,pr)),to*=1.05;let xo=Ge(B),js=(H.height-oo)/H.zoom.value;Object.assign(d.style,{font:xo,lineHeight:B.lineHeight,width:`${nt}px`,height:`${to}px`,left:`${tn}px`,top:`${oo}px`,transform:qk(nt,to,Kb(B,he),H,pr,js),textAlign:U,verticalAlign:oe,color:B.strokeColor,opacity:B.opacity/100,filter:"var(--theme-filter)",maxHeight:`${js}px`}),d.scrollTop=0,et()&&(d.style.fontFamily=Jn(B)),l.scene.mutateElement(B,{x:ce,y:ue})}},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";(He(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(),t&&(d.onpaste=async H=>{let B=await pm(H,!0);if(!B.text)return;let U=li(B.text);if(!U)return;let oe=Ut(n,l.scene.getNonDeletedElementsMap()),Z=Ge({fontSize:l.state.currentItemFontSize,fontFamily:l.state.currentItemFontFamily});if(oe){let ce=pe(oe,l.scene.getNonDeletedElementsMap()),ue=fn(`${d.value}${U}`,Z,bn(oe,ce)),he=Wb(ue,Z);d.style.width=`${he}px`}},d.oninput=()=>{let H=li(d.value);if(d.value!==H){let B=d.selectionStart;d.value=H,d.selectionStart=B,d.selectionEnd=B}t(d.value)}),d.onkeydown=H=>{if(!H.shiftKey&&im.keyTest(H))H.preventDefault(),l.actionManager.executeAction(im),m();else if(!H.shiftKey&&am.keyTest(H))H.preventDefault(),l.actionManager.executeAction(am),m();else if(!H.shiftKey&&lm.keyTest(H))H.preventDefault(),l.actionManager.executeAction(lm),m();else if(Qh.keyTest(H))l.actionManager.executeAction(Qh);else if(eg.keyTest(H))l.actionManager.executeAction(eg);else if(H.key===T.ESCAPE)H.preventDefault(),C=!0,I();else if(Pi.keyTest(H))H.preventDefault(),I(),l.actionManager.executeAction(Pi);else if(H.key===T.ENTER&&H[T.CTRL_OR_CMD]){if(H.preventDefault(),H.isComposing||H.keyCode===229)return;C=!0,I()}else if(H.key===T.TAB||H[T.CTRL_OR_CMD]&&(H.code===me.BRACKET_LEFT||H.code===me.BRACKET_RIGHT)){if(H.preventDefault(),H.isComposing)return;H.shiftKey||H.code===me.BRACKET_LEFT?w():E(),d.dispatchEvent(new Event("input"))}};let h=4,x=" ".repeat(h),b=new RegExp(`^ {1,${h}}`),E=()=>{let{selectionStart:H,selectionEnd:B}=d,U=y(),oe=d.value;U.forEach(Z=>{let ce=oe.slice(0,Z),ue=oe.slice(Z);oe=`${ce}${x}${ue}`}),d.value=oe,d.selectionStart=H+h,d.selectionEnd=B+h*U.length},w=()=>{let{selectionStart:H,selectionEnd:B}=d,U=y(),oe=[],Z=d.value;U.forEach(ce=>{let ue=Z.slice(ce,ce+h).match(b);if(ue){let he=Z.slice(0,ce),nt=Z.slice(ce+ue[0].length);Z=`${he}${nt}`,oe.push(ce)}}),d.value=Z,oe.length&&(H>oe[oe.length-1]?d.selectionStart=Math.max(H-h,oe[oe.length-1]):d.selectionStart=H,d.selectionEnd=Math.max(d.selectionStart,B-h*oe.length))},y=()=>{let{selectionStart:H,selectionEnd:B,value:U}=d,oe=U.slice(0,H).match(/[^\n]*$/)[0].length;return H=H-oe,U.slice(H,B).split(`
|
|
9
|
-
`).reduce((ce,ue,he,nt)=>ce.concat(he?ce[he-1]+nt[he-1].length+1:H),[]).reverse()},v=H=>{H.target instanceof HTMLCanvasElement&&(H.preventDefault(),H.stopPropagation())},C=!1,I=()=>{if(G)return;G=!0,L();let H=l.scene.getElement(n.id);if(!H)return;let B=Ut(H,l.scene.getNonDeletedElementsMap());if(B){if(d.value.trim()){let U=_o(B);!U||U!==n.id?l.scene.mutateElement(B,{boundElements:(B.boundElements||[]).concat({type:"text",id:n.id})}):Ie(B)&&Jo(B)}else l.scene.mutateElement(B,{boundElements:B.boundElements?.filter(U=>!K(U))});Xe(H,B,l.scene)}o({viaKeyboard:C,nextOriginalText:d.value})},L=()=>{d.onblur=null,d.oninput=null,d.onkeydown=null,j&&j.disconnect(),window.removeEventListener("resize",m),window.removeEventListener("wheel",v,!0),window.removeEventListener("pointerdown",_),window.removeEventListener("pointerup",A),window.removeEventListener("blur",I),window.removeEventListener("beforeunload",I),z(),W(),d.remove()},A=H=>{window.removeEventListener("pointerup",A);let B=H?.target,U=B instanceof HTMLElement&&B.classList.contains("properties-trigger");setTimeout(()=>{d.onblur=I,U||d.focus()})},R=()=>{d.onblur=null,window.addEventListener("pointerup",A),window.addEventListener("blur",I)},_=H=>{let B=H?.target;if(H.button===hr.WHEEL){B instanceof HTMLTextAreaElement&&(H.preventDefault(),l.handleCanvasPanUsingWheelOrSpaceDrag(H)),R();return}let U=B instanceof HTMLElement&&B.classList.contains("properties-trigger");(H.target instanceof HTMLElement||H.target instanceof SVGElement)&&H.target.closest(`.${Wt.SHAPE_ACTIONS_MENU}, .${Wt.ZOOM_ACTIONS}`)&&!gr(H.target)||U?R():H.target instanceof HTMLCanvasElement&&!et()&&requestAnimationFrame(()=>{I()})},z=l.scene.onUpdate(()=>{m(),!!document.activeElement?.closest(".properties-content")||d.focus()}),W=l.onScrollChangeEmitter.on(()=>{m()}),G=!1;s&&d.select(),A();let j=null;return i&&"ResizeObserver"in window?(j=new window.ResizeObserver(()=>{m()}),j.observe(i)):window.addEventListener("resize",m),d.onpointerdown=H=>H.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",_,{capture:!0})}),window.addEventListener("beforeunload",I),a?.querySelector(".excalidraw-textEditorContainer").appendChild(d),I};var $w=e=>{let t=["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(?:${t.map(r=>`\\s*${r}(-beta)?`).join("|")})\\b`).test(e.trim())};import{simplify as Jk}from"points-on-curve";var jw=e=>{let{lassoPath:t,elements:o,elementsSegments:r,intersectedElements:n,enclosedElements:i,simplifyDistance:a}=e,l=t;a&&(l=Jk(t,a)),i.clear();for(let c of o)!n.has(c.id)&&!i.has(c.id)&&(Qk(l,c,r)?i.add(c.id):eM(l,c,r)&&n.add(c.id));return{selectedElementIds:[...n,...i]}},Qk=(e,t,o)=>{let r=ob(e),n=o.get(t.id);return n?n.some(i=>i.some(a=>rb(a,r))):!1},eM=(e,t,o)=>{let r=o.get(t.id);return r?e.reduce((i,a,l)=>(l===0||i.push(xc(e[l-1],a)),i),[]).some(i=>r.some(a=>Ec(i,a,1)!==null)):!1};var ep=class extends Jr{constructor(o,r){super(o,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(Zo(s),Zo(l))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});S(this,"intersectedElements",new Set);S(this,"enclosedElements",new Set);S(this,"elementsSegments",null);S(this,"keepPreviousSelection",!1);S(this,"selectElementsFromIds",o=>{this.app.setState(r=>{let n=o.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&&K(c)){let m=Ut(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&&J(c)){let m=so(this.app.scene.getNonDeletedElementsMap(),c.id);for(let d of m)delete n[d.id]}}let i=ht({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&&le(this.app.scene.getNonDeletedElement(a[0]))?new $(this.app.scene.getNonDeletedElement(a[0]),this.app.scene.getNonDeletedElementsMap()):null}})});S(this,"addPointToPath",(o,r,n=!1)=>{super.addPointToPath(o,r),this.keepPreviousSelection=n,this.updateSelection()});S(this,"updateSelection",()=>{let o=super.getCurrentTrail()?.originalPoints?.map(r=>M(r[0],r[1]));if(!this.elementsSegments){this.elementsSegments=new Map;let r=q(this.app.visibleElements);for(let n of this.app.visibleElements){let i=Wc(n,r);this.elementsSegments.set(n.id,i)}}if(o){let{selectedElementIds:r}=jw({lassoPath:o,elements:this.app.visibleElements,elementsSegments:this.elementsSegments,intersectedElements:this.intersectedElements,enclosedElements:this.enclosedElements,simplifyDistance:5/this.app.state.zoom.value});this.selectElementsFromIds(r)}})}startPath(o,r,n=!1){this.endPath(),super.startPath(o,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}};var tM=2,tp=class extends Jr{constructor(o,r){super(o,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(Zo(s),Zo(l))},fill:()=>r.state.theme===se.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"});S(this,"elementsToErase",new Set);S(this,"groupsToErase",new Set);S(this,"segmentsCache",new Map);S(this,"geometricShapesCache",new Map)}startPath(o,r){this.endPath(),super.startPath(o,r),this.elementsToErase.clear()}addPointToPath(o,r,n=!1){return super.addPointToPath(o,r),this.updateElementsToBeErased(n)}updateElementsToBeErased(o){let r=super.getCurrentTrail()?.originalPoints?.map(l=>M(l[0],l[1]))||[];r=r?.slice(r.length-tM);let n=this.app.visibleElements.filter(l=>!l.locked),i=q(n),a=r.reduce((l,s,c)=>(c===0||l.push(xc(r[c-1],s)),l),[]);if(a.length===0)return[];for(let l of n)if(o&&this.elementsToErase.has(l.id)){if(qw(a,l,this.segmentsCache,this.geometricShapesCache,i,this.app)){let c=l.groupIds.at(-1);if(this.groupsToErase.has(c)){let m=Be(this.app.scene.getNonDeletedElementsMap(),c);for(let d of m)this.elementsToErase.delete(d.id);this.groupsToErase.delete(c)}if(He(l)&&this.elementsToErase.delete(l.containerId),it(l)){let m=_o(l);m&&this.elementsToErase.delete(m)}this.elementsToErase.delete(l.id)}}else if(!o&&!this.elementsToErase.has(l.id)&&qw(a,l,this.segmentsCache,this.geometricShapesCache,i,this.app)){let c=l.groupIds.at(-1);if(!this.groupsToErase.has(c)){let m=Be(this.app.scene.getNonDeletedElementsMap(),c);for(let d of m)this.elementsToErase.add(d.id);this.groupsToErase.add(c)}if(it(l)){let m=_o(l);m&&this.elementsToErase.add(m)}He(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(),this.segmentsCache.clear()}},qw=(e,t,o,r,n,i)=>{let a=r.get(t.id);a||(a=Ur(t,n),r.set(t.id,a));let l=e[e.length-1][1];if(Ab(t)&&Zc(l,a))return!0;let s=o.get(t.id);return s||(s=Wc(t,n),o.set(t.id,s)),e.some(c=>s?.some(m=>Ec(c,m,i.getElementHitThreshold())!==null))};import{jsx as Uo,jsxs as Jw}from"react/jsx-runtime";var oM=()=>Jw("div",{"data-testid":"brave-measure-text-error",children:[Uo("p",{children:Uo(qt,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>Uo("span",{style:{fontWeight:600},children:e})})}),Uo("p",{children:Uo(qt,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>Uo("span",{style:{fontWeight:600},children:e})})}),Uo("p",{children:Uo(qt,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>Uo("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),Uo("p",{children:Uo(qt,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>Uo("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>Jw("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),Qw=oM;import aM from"clsx";import lM from"react";import{useLayoutEffect as rM,useRef as e3,useEffect as t3}from"react";import{unstable_batchedUpdates as nM}from"react-dom";import{jsx as iM}from"react/jsx-runtime";var o3=({children:e,left:t,top:o,onCloseRequest:r,fitInViewport:n=!1,offsetLeft:i=0,offsetTop:a=0,viewportWidth:l=window.innerWidth,viewportHeight:s=window.innerHeight})=>{let c=e3(null);t3(()=>{let d=c.current;if(!d)return;d.contains(document.activeElement)||d.focus();let p=u=>{if(u.key===T.TAB){let h=Ll(d),{activeElement:x}=document,b=h.findIndex(E=>E===x);x===d?(u.shiftKey?h[h.length-1]?.focus():h[0].focus(),u.preventDefault(),u.stopImmediatePropagation()):b===0&&u.shiftKey?(h[h.length-1]?.focus(),u.preventDefault(),u.stopImmediatePropagation()):b===h.length-1&&!u.shiftKey&&(h[0]?.focus(),u.preventDefault(),u.stopImmediatePropagation())}};return d.addEventListener("keydown",p),()=>d.removeEventListener("keydown",p)},[]);let m=e3(null);return rM(()=>{if(n&&c.current&&o!=null&&t!=null){let d=c.current,{width:p,height:u}=d.getBoundingClientRect();if(m.current?.top===o&&m.current?.left===t)return;m.current={top:o,left:t},p>=l?(d.style.width=`${l}px`,d.style.left="0px",d.style.overflowX="scroll"):t+p-i>l?d.style.left=`${l-p-10}px`:d.style.left=`${t}px`,u>=s?(d.style.height=`${s-20}px`,d.style.top="10px",d.style.overflowY="scroll"):o+u-a>s?d.style.top=`${s-u}px`:d.style.top=`${o}px`}},[o,t,n,l,s,i,a]),t3(()=>{if(r){let d=p=>{c.current?.contains(p.target)||nM(()=>r(p))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[r]),iM("div",{className:"popover",ref:c,tabIndex:-1,children:e})};import{jsx as ll,jsxs as sM}from"react/jsx-runtime";var xt="separator",r3=lM.memo(({actionManager:e,items:t,top:o,left:r,onClose:n})=>{let i=wr(),a=In(),l=t.reduce((s,c)=>(c&&(c===xt||!c.predicate||c.predicate(a,i,e.app.props,e.app))&&s.push(c),s),[]);return ll(o3,{onCloseRequest:()=>{n()},top:o,left:r,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,children:ll("ul",{className:"context-menu",onContextMenu:s=>s.preventDefault(),children:l.map((s,c)=>{if(s===xt)return!l[c-1]||l[c-1]===xt?null:ll("hr",{className:"context-menu-item-separator"},c);let m=s.name,d="";return s.label&&(typeof s.label=="function"?d=f(s.label(a,i,e.app)):d=f(s.label)),ll("li",{"data-testid":m,onClick:()=>{n(()=>{e.executeAction(s,"contextMenu")})},children:sM("button",{type:"button",className:aM("context-menu-item",{dangerous:m==="deleteSelectedElements",checkmark:s.checked?.(i)}),children:[ll("div",{className:"context-menu-item__label",children:d}),ll("kbd",{className:"context-menu-item__shortcut",children:m?st(m):""})]})},c)})})})});import{jsx as uf,jsxs as n3}from"react/jsx-runtime";var cM=({height:e,width:t,userToFollow:o,onDisconnect:r})=>uf("div",{className:"follow-mode",style:{width:t,height:e},children:n3("div",{className:"follow-mode__badge",children:[n3("div",{className:"follow-mode__badge__label",children:["Following"," ",uf("span",{className:"follow-mode__badge__username",title:o.username,children:o.username})]}),uf("button",{type:"button",onClick:r,className:"follow-mode__disconnect-btn",children:Po})]})}),i3=cM;import Gs from"clsx";import h8 from"react";import dM from"clsx";import{useState as mM,useEffect as pM}from"react";import{jsx as hf,jsxs as uM}from"react/jsx-runtime";var op=({delay:e,theme:t})=>{let[o,r]=mM(!!e);return pM(()=>{if(!e)return;let n=setTimeout(()=>{r(!1)},e);return()=>clearTimeout(n)},[e]),o?null:uM("div",{className:dM("LoadingMessage",{"LoadingMessage--dark":t===se.DARK}),children:[hf("div",{children:hf(Ot,{})}),hf("div",{className:"LoadingMessage-text",children:f("labels.loadingScene")})]})};import hM from"clsx";import{jsx as l3,jsxs as fM}from"react/jsx-runtime";var gM="medium",a3={CHECKED:xa,UNCHECKED:Ti},rp=e=>fM("label",{className:hM("ToolIcon ToolIcon__lock",`ToolIcon_size_${gM}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[l3("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),l3("div",{className:"ToolIcon__icon",children:e.checked?a3.CHECKED:a3.UNCHECKED})]});import bM from"clsx";import{jsx as xM}from"react/jsx-runtime";var np=({children:e,side:t,className:o})=>xM("div",{className:bM("FixedSideContainer",`FixedSideContainer_side_${t}`,o),children:e});import EM from"clsx";import{jsx as yM}from"react/jsx-runtime";var ip=e=>yM(te,{className:EM("Shape",{fillable:!1}),type:"radio",icon:_d,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:T.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":T.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});import{jsx as s3}from"react/jsx-runtime";var vM=({appState:e,isMobile:t,device:o,app:r})=>{let{activeTool:n,isResizing:i,isRotating:a,lastPointerDownWith:l}=e,s=e.multiElement!==null;if(e.openSidebar?.name===zt.name&&e.openSidebar.tab===Nr&&e.searchMatches?.matches.length)return f("hints.dismissSearch");if(e.openSidebar&&!o.editor.canFitSidebar)return null;if(co(e))return f("hints.eraserRevert");if(n.type==="arrow"||n.type==="line")return s?f("hints.linearElementMulti"):n.type==="arrow"?f("hints.arrowTool",{arrowShortcut:N("A")}):f("hints.linearElement");if(n.type==="freedraw")return f("hints.freeDraw");if(n.type==="text")return f("hints.text");if(n.type==="embeddable")return f("hints.embeddable");if(e.activeTool.type==="image"&&e.pendingImageElementId)return f("hints.placeImage");let c=r.scene.getSelectedElements(e);if(i&&l==="mouse"&&c.length===1){let m=c[0];return le(m)&&m.points.length===2?f("hints.lockAngle"):xe(m)?f("hints.resizeImage"):f("hints.resize")}if(a&&l==="mouse")return f("hints.rotate");if(c.length===1&&K(c[0]))return f("hints.text_selected");if(e.editingTextElement)return f("hints.text_editing");if(e.croppingElementId)return f("hints.leaveCropEditor");if(c.length===1&&xe(c[0]))return f("hints.enterCropEditor");if(n.type==="selection"){if(e.selectionElement&&!c.length&&!e.editingTextElement&&!e.editingLinearElement)return[f("hints.deepBoxSelect")];if(Rn(r)&&e.selectedElementsAreBeingDragged)return f("hints.disableSnapping");if(!c.length&&!t)return[f("hints.canvasPanning")];if(c.length===1){if(le(c[0]))return e.editingLinearElement?e.editingLinearElement.selectedPointsIndices?f("hints.lineEditor_pointSelected"):f("hints.lineEditor_nothingSelected"):f("hints.lineEditor_info");if(!e.newElement&&!e.selectedElementsAreBeingDragged&&Hr(c[0]))return ii(c[0])?xx(c[0],r.scene.getNonDeletedElementsMap())?[f("hints.bindTextToElement"),f("hints.createFlowchart")]:[f("hints.bindTextToElement"),f("hints.createFlowchart")]:f("hints.bindTextToElement")}}return null},ap=({appState:e,isMobile:t,device:o,app:r})=>{let n=vM({appState:e,isMobile:t,device:o,app:r});if(!n)return null;let i=Array.isArray(n)?n.map(a=>N(a).replace(/\. ?$/,"")).join(". "):N(n);return s3("div",{className:"HintViewer",children:s3("span",{children:i})})};import wM from"clsx";import{jsx as c3,jsxs as SM}from"react/jsx-runtime";var TM="medium",lp=e=>e.penDetected?SM("label",{className:wM("ToolIcon ToolIcon__penMode",`ToolIcon_size_${TM}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[c3("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),c3("div",{className:"ToolIcon__icon",children:Gx})]}):null;import{Fragment as CM,jsx as d3,jsxs as IM}from"react/jsx-runtime";var On=({heading:e,children:t,...o})=>{let{id:r}=ft(),n=d3("h2",{className:"visually-hidden",id:`${r}-${e}-title`,children:f(`headings.${e}`)});return d3("section",{...o,"aria-labelledby":`${r}-${e}-title`,children:typeof t=="function"?t(n):IM(CM,{children:[n,t]})})};import{Fragment as kM,jsx as Bt,jsxs as Qr}from"react/jsx-runtime";var m3=({appState:e,elements:t,actionManager:o,setAppState:r,onLockToggle:n,onHandToolToggle:i,onPenModeToggle:a,renderTopRightUI:l,renderCustomStats:s,renderSidebars:c,device:m,renderWelcomeScreen:d,UIOptions:p,app:u})=>{let{WelcomeScreenCenterTunnel:h,MainMenuTunnel:x,DefaultSidebarTriggerTunnel:b}=je(),E=()=>Qr(np,{side:"top",className:"App-top-bar",children:[d&&Bt(h.Out,{}),Bt(On,{heading:"shapes",children:y=>Bt(Lt.Col,{gap:4,align:"center",children:Qr(Lt.Row,{gap:1,className:"App-toolbar-container",children:[Qr(wt,{padding:1,className:"App-toolbar App-toolbar--mobile",children:[y,Bt(Lt.Row,{gap:1,children:Bt(Vm,{appState:e,activeTool:e.activeTool,UIOptions:p,app:u})})]}),l&&l(!0,e),Qr("div",{className:"mobile-misc-tools-container",children:[!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&Bt(b.Out,{}),Bt(lp,{checked:e.penMode,onChange:()=>a(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),Bt(rp,{checked:e.activeTool.locked,onChange:n,title:f("toolBar.lock"),isMobile:!0}),Bt(ip,{checked:or(e),onChange:()=>i(),title:f("toolBar.hand"),isMobile:!0})]})]})})}),Bt(ap,{appState:e,isMobile:!0,device:m,app:u})]}),w=()=>e.viewModeEnabled||e.openDialog?.name==="elementLinkSelector"?Bt("div",{className:"App-toolbar-content",children:Bt(x.Out,{})}):Qr("div",{className:"App-toolbar-content",children:[Bt(x.Out,{}),o.renderAction("toggleEditMenu"),o.renderAction(e.multiElement?"finalize":"duplicateSelection"),o.renderAction("deleteSelectedElements"),Qr("div",{children:[o.renderAction("undo"),o.renderAction("redo")]})]});return Qr(kM,{children:[c(),!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&E(),Bt("div",{className:"App-bottom-bar",style:{marginBottom:go+cr*2,marginLeft:go+cr*2,marginRight:go+cr*2},children:Qr(wt,{padding:0,children:[e.openMenu==="shape"&&!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&Oa(e,t)?Bt(On,{className:"App-mobile-menu",heading:"selectedShapeActions",children:Bt(Gm,{appState:e,elementsMap:u.scene.getNonDeletedElementsMap(),renderAction:o.renderAction,app:u})}):null,Qr("footer",{className:"App-toolbar",children:[w(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&Bt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(y=>({...hi(t,y)}))},children:f("buttons.scrollBackToContent")})]})]})})]})};import MM from"open-color";import AM,{useLayoutEffect as LM,useRef as DM,useState as _M}from"react";import{jsx as Ps,jsxs as PM}from"react/jsx-runtime";var p3=e=>{let t=DM(null),[o,r]=_M(null);return LM(()=>{if(!e.spreadsheet)return;let n=L2(e.chartType,e.spreadsheet,0,0);r(n);let i,a=t.current;return(async()=>(i=await da(n,{exportBackground:!1,viewBackgroundColor:MM.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]),Ps("button",{type:"button",className:"ChartPreview",onClick:()=>{o&&e.onClick(e.chartType,o)},children:Ps("div",{ref:t})})},u3=({setAppState:e,appState:t,onClose:o})=>{let{onInsertElements:r}=lt(),n=AM.useCallback(()=>{o&&o()},[o]),i=(a,l)=>{r(l),fe("paste","chart",a),e({currentChartType:a,pasteDialog:{shown:!1,data:null}})};return Ps(ct,{size:"small",onCloseRequest:n,title:f("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:PM("div",{className:"container",children:[Ps(p3,{chartType:"bar",spreadsheet:t.pasteDialog.data,selected:t.currentChartType==="bar",onClick:i}),Ps(p3,{chartType:"line",spreadsheet:t.pasteDialog.data,selected:t.currentChartType==="line",onClick:i})]})})};import*as Bn from"@radix-ui/react-popover";import h3 from"clsx";import sp,{useLayoutEffect as RM}from"react";import{Fragment as zM,jsx as Mr,jsxs as cp}from"react/jsx-runtime";var NM=4,OM=8,BM=({shouldWrap:e,children:t,username:o})=>e?Mr(So,{label:o||"Unknown user",children:t}):Mr(zM,{children:t}),gf=({actionManager:e,collaborator:t,socketId:o,withName:r=!1,shouldWrapWithTooltip:n=!1,isBeingFollowed:i})=>{let a={socketId:o,collaborator:t,withName:r,isBeingFollowed:i},l=e.renderAction("goToCollaborator",a);return Mr(BM,{username:t.username,shouldWrap:n,children:l},o)},FM=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],dp=sp.memo(({className:e,mobile:t,collaborators:o,userToFollow:r})=>{let n=bt(),i=new Map;o.forEach((x,b)=>{let E=x.id||b;i.set(E,{...x,socketId:b})});let a=Array.from(i.values()).filter(x=>x.username?.trim()),[l,s]=sp.useState(""),c=a.filter(x=>x.username?.toLowerCase().includes(l)),m=sp.useRef(null);RM(()=>{if(m.current){let x=E=>{let w=Math.max(1,Math.min(8,Math.floor(E/38)));p(w)};if(x(m.current.clientWidth),!bl)return;let b=new ResizeObserver(E=>{for(let w of E){let{width:y}=w.contentRect;x(y)}});return b.observe(m.current),()=>{b.disconnect()}}},[]);let[d,p]=sp.useState(NM),h=a.slice(0,d-1).map(x=>gf({actionManager:n,collaborator:x,socketId:x.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:x.socketId===r}));return t?Mr("div",{className:h3("UserList UserList_mobile",e),children:a.map(x=>gf({actionManager:n,collaborator:x,socketId:x.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:x.socketId===r}))}):Mr("div",{className:"UserList__wrapper",ref:m,children:cp("div",{className:h3("UserList",e),style:{"--max-avatars":d},children:[h,a.length>d-1&&cp(Bn.Root,{children:[cp(Bn.Trigger,{className:"UserList__more",children:["+",a.length-d+1]}),Mr(Bn.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:cp(wt,{padding:2,children:[a.length>=OM&&Mr(jd,{placeholder:f("quickSearch.placeholder"),onChange:s}),Mr(qd,{className:"dropdown-menu UserList__collaborators",placeholder:f("userList.empty"),children:c.length>0?[Mr("div",{className:"hint",children:f("userList.hint.text")}),c.map(x=>gf({actionManager:n,collaborator:x,socketId:x.socketId,withName:!0,isBeingFollowed:x.socketId===r}))]:[]}),Mr(Bn.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})]})]})})},(e,t)=>{if(e.collaborators.size!==t.collaborators.size||e.mobile!==t.mobile||e.className!==t.className||e.userToFollow!==t.userToFollow)return!1;let o=t.collaborators.keys();for(let[r,n]of e.collaborators){let i=t.collaborators.get(r);if(!i||r!==o.next().value||!pt(n,i,FM))return!1}return!0});import mp from"clsx";import{jsx as HM}from"react/jsx-runtime";var g3=e=>HM("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${f("helpDialog.title")} \u2014 ?`,"aria-label":f("helpDialog.title"),children:ya});import{jsx as Ar,jsxs as ff}from"react/jsx-runtime";var f3=({appState:e,actionManager:t,showExitZenModeBtn:o,renderWelcomeScreen:r})=>{let{FooterCenterTunnel:n,WelcomeScreenHelpHintTunnel:i}=je(),a=Te(),l=!e.viewModeEnabled&&e.multiElement&&a.isTouchScreen;return ff("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[Ar("div",{className:mp("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:Ar(Lt.Col,{gap:2,children:ff(On,{heading:"canvasActions",children:[Ar(lw,{renderAction:t.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&Ar(sw,{renderAction:t.renderAction,className:mp("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})}),l&&Ar(dw,{renderAction:t.renderAction,className:mp("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled})})]})})}),Ar(n.Out,{}),Ar("div",{className:mp("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:ff("div",{style:{position:"relative"},children:[r&&Ar(i.Out,{}),Ar(g3,{onClick:()=>t.executeAction(Ri)})]})}),Ar(cw,{actionManager:t,showExitZenModeBtn:o})]})},b3=f3;f3.displayName="Footer";import XM from"clsx";import{useEffect as k3,useLayoutEffect as M3,useRef as Cf,useState as $M,forwardRef as A3,useImperativeHandle as jM,useCallback as C3}from"react";import GM from"clsx";import{useContext as VM}from"react";import UM from"react";var pp=UM.createContext({});import{jsx as bf,jsxs as x3}from"react/jsx-runtime";var xf=({children:e,className:t})=>{let o=Te(),r=VM(pp),n=!!(o.editor.canFitSidebar&&r.shouldRenderDockButton);return x3("div",{className:GM("sidebar__header",t),"data-testid":"sidebar-header",children:[e,x3("div",{className:"sidebar__header__buttons",children:[n&&bf(So,{label:f("labels.sidebarLock"),children:bf(Mo,{onSelect:()=>r.onDock?.(!r.docked),selected:!!r.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":f("labels.sidebarLock"),children:Ox})}),bf(Mo,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:r.onCloseRequest,"aria-label":f("buttons.close"),children:Po})]})]})};xf.displayName="SidebarHeader";import*as y3 from"@radix-ui/react-tabs";import{jsx as E3}from"react/jsx-runtime";var Ef=({children:e,tab:t,onSelect:o,...r})=>E3(y3.Trigger,{value:t,asChild:!0,onSelect:o,children:E3("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...r,children:e})});Ef.displayName="SidebarTabTrigger";import*as v3 from"@radix-ui/react-tabs";import{jsx as YM}from"react/jsx-runtime";var yf=({children:e,...t})=>YM(v3.List,{className:"sidebar-triggers",...t,children:e});yf.displayName="SidebarTabTriggers";import WM from"clsx";import{jsx as vf,jsxs as w3}from"react/jsx-runtime";var wf=({name:e,tab:t,icon:o,title:r,children:n,onToggle:i,className:a,style:l})=>{let s=Se(),c=_e();return w3("label",{title:r,className:"sidebar-trigger__label-element",children:[vf("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:t}:null}),i?.(d)},checked:c.openSidebar?.name===e,"aria-label":r,"aria-keyshortcuts":"0"}),w3("div",{className:WM("sidebar-trigger",a),style:l,children:[o&&vf("div",{children:o}),n&&vf("div",{className:"sidebar-trigger__label",children:n})]})]})};wf.displayName="SidebarTrigger";import*as T3 from"@radix-ui/react-tabs";import{jsx as KM}from"react/jsx-runtime";var Tf=({children:e,...t})=>{let o=_e(),r=Se();if(!o.openSidebar)return null;let{name:n}=o.openSidebar;return KM(T3.Root,{className:"sidebar-tabs-root",value:o.openSidebar.tab,onValueChange:i=>r(a=>({...a,openSidebar:{...a.openSidebar,name:n,tab:i}})),...t,children:e})};Tf.displayName="SidebarTabs";import*as S3 from"@radix-ui/react-tabs";import{jsx as ZM}from"react/jsx-runtime";var Sf=({tab:e,children:t,...o})=>ZM(S3.Content,{...o,value:e,"data-testid":e,children:t});Sf.displayName="SidebarTab";import{jsx as I3}from"react/jsx-runtime";import{createElement as qM}from"react";var Rs=ke(!1),L3=A3(({name:e,children:t,onDock:o,docked:r,className:n,...i},a)=>{Oe()&&o&&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=Se(),s=rr(Rs);M3(()=>(s(!!r),()=>{s(!1)}),[s,r]);let c=Cf({});c.current.onCloseRequest=()=>{l({openSidebar:null})},c.current.onDock=u=>o?.(u),c.current=Ki(c.current,{docked:r,shouldRenderDockButton:!!o&&r!=null});let m=Cf(null);jM(a,()=>m.current);let d=Te(),p=C3(()=>{document.querySelector(".Dialog")||l({openSidebar:null})},[l]);return Ca(m,C3(u=>{u.target.closest(".sidebar-trigger")||(!r||!d.editor.canFitSidebar)&&p()},[p,r,d.editor.canFitSidebar])),k3(()=>{let u=h=>{h.key===T.ESCAPE&&(!r||!d.editor.canFitSidebar)&&p()};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}},[p,r,d.editor.canFitSidebar]),I3(wt,{...i,className:XM("sidebar",{"sidebar--docked":r},n),ref:m,children:I3(pp.Provider,{value:c.current,children:t})})});L3.displayName="SidebarInner";var Go=Object.assign(A3((e,t)=>{let o=_e(),{onStateChange:r}=e,n=Cf(o.openSidebar);k3(()=>{(!o.openSidebar&&n?.current?.name===e.name||o.openSidebar?.name===e.name&&n?.current?.name!==e.name||n.current?.name===e.name)&&o.openSidebar!==n.current&&r?.(o.openSidebar?.name!==e.name?null:o.openSidebar),n.current=o.openSidebar},[o.openSidebar,r,e.name]);let[i,a]=$M(!1);return M3(()=>(a(!0),()=>a(!1)),[]),i&&o.openSidebar?.name===e.name?qM(L3,{...e,ref:t,key:e.name}):null}),{Header:xf,TabTriggers:yf,TabTrigger:Ef,Tabs:Tf,Tab:Sf,Trigger:wf});Go.displayName="Sidebar";import{useLayoutEffect as JM,useRef as QM}from"react";import{jsx as eA}from"react/jsx-runtime";var en=(e,t)=>{let o=ke(0),r=n=>{let{tunnelsJotai:{useAtom:i}}=je(),[,a]=i(o),l=QM({preferHost:!1,counter:0});return JM(()=>{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:eA(t,{...n})};return r.displayName=e,r};var Mf={};b1(Mf,{ChangeCanvasBackground:()=>Y3,ClearCanvas:()=>G3,CommandPalette:()=>z3,Export:()=>W3,Help:()=>U3,LiveCollaborationTrigger:()=>Z3,LoadScene:()=>O3,SaveAsImage:()=>F3,SaveToActiveFile:()=>B3,SearchMenu:()=>H3,Socials:()=>K3,ToggleTheme:()=>V3});import nA from"clsx";var If=ke({active:!1});async function D3({title:e,description:t,actionLabel:o,color:r}){return new Promise(n=>{Fe.set(If,{active:!0,onConfirm:()=>n(!0),onClose:()=>n(!1),onReject:()=>n(!1),title:e,description:t,actionLabel:o,color:r})})}import tA from"clsx";import{jsx as _3,jsxs as oA}from"react/jsx-runtime";var up=function({onChange:e,value:t,choices:o,name:r}){return _3("div",{className:"RadioGroup",children:o.map(n=>oA("div",{className:tA("RadioGroup__choice",{active:n.value===t}),title:n.ariaLabel,children:[_3("input",{name:r,type:"radio",checked:n.value===t,onChange:()=>e(n.value),"aria-label":n.ariaLabel}),n.label]},String(n.value)))})};import{Fragment as rA,jsx as kf,jsxs as P3}from"react/jsx-runtime";var R3=({value:e,shortcut:t,onChange:o,choices:r,children:n,name:i})=>{let a=Te();return P3(rA,{children:[P3("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[kf("label",{className:"dropdown-menu-item__text",htmlFor:i,children:n}),kf(up,{name:i,value:e,onChange:o,choices:r})]}),t&&!a.editor.isMobile&&kf("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:t})]})};R3.displayName="DropdownMenuItemContentRadio";var N3=R3;import{Fragment as iA,jsx as St,jsxs as X3}from"react/jsx-runtime";var O3=()=>{let{t:e}=dt(),t=bt(),o=In();return t.isActionEnabled(Na)?St($t,{icon:va,onSelect:async()=>{(!o.length||await D3({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:St(qt,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:n=>St("strong",{children:n}),br:()=>St("br",{})})}))&&t.executeAction(Na)},"data-testid":"load-button",shortcut:st("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};O3.displayName="LoadScene";var B3=()=>{let{t:e}=dt(),t=bt();return t.isActionEnabled(Pi)?St($t,{shortcut:st("saveScene"),"data-testid":"save-button",onSelect:()=>t.executeAction(Pi),icon:jx,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};B3.displayName="SaveToActiveFile";var F3=()=>{let e=Se(),{t}=dt();return St($t,{icon:Md,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:st("imageExport"),"aria-label":t("buttons.exportImage"),children:t("buttons.exportImage")})};F3.displayName="SaveAsImage";var z3=e=>{let t=Se(),{t:o}=dt();return St($t,{icon:is,"data-testid":"command-palette-button",onSelect:()=>{fe("command_palette","open","menu"),t({openDialog:{name:"commandPalette"}})},shortcut:st("commandPalette"),"aria-label":o("commandPalette.title"),className:e?.className,children:o("commandPalette.title")})};z3.displayName="CommandPalette";var H3=e=>{let{t}=dt(),o=bt();return St($t,{icon:wo,"data-testid":"search-menu-button",onSelect:()=>{o.executeAction(As)},shortcut:st("searchMenu"),"aria-label":t("search.title"),className:e?.className,children:t("search.title")})};H3.displayName="SearchMenu";var U3=()=>{let{t:e}=dt(),t=bt();return St($t,{"data-testid":"help-menu-item",icon:ya,onSelect:()=>t.executeAction(Ri),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};U3.displayName="Help";var G3=()=>{let{t:e}=dt(),t=rr(Bi);return bt().isActionEnabled(Kr)?St($t,{icon:vo,onSelect:()=>t("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};G3.displayName="ClearCanvas";var V3=e=>{let{t}=dt(),o=_e(),r=bt(),n=st("toggleTheme");return r.isActionEnabled(Ai)?e?.allowSystemTheme?St(N3,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:se.LIGHT,label:ts,ariaLabel:`${t("buttons.lightMode")} - ${n}`},{value:se.DARK,label:es,ariaLabel:`${t("buttons.darkMode")} - ${n}`},{value:"system",label:my,ariaLabel:t("buttons.systemMode")}],children:t("labels.theme")}):St($t,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(o.theme===se.DARK?se.LIGHT:se.DARK);else return r.executeAction(Ai)},icon:o.theme===se.DARK?ts:es,"data-testid":"toggle-dark-mode",shortcut:n,"aria-label":o.theme===se.DARK?t("buttons.lightMode"):t("buttons.darkMode"),children:o.theme===se.DARK?t("buttons.lightMode"):t("buttons.darkMode")}):null};V3.displayName="ToggleTheme";var Y3=()=>{let{t:e}=dt(),t=_e(),o=bt(),r=Tr();return t.viewModeEnabled||!r.UIOptions.canvasActions.changeViewBackgroundColor?null:X3("div",{style:{marginTop:"0.5rem"},children:[St("div",{"data-testid":"canvas-background-label",style:{fontSize:".75rem",marginBottom:".5rem"},children:e("labels.canvasBackground")}),St("div",{style:{padding:"0 0.625rem"},children:o.renderAction("changeViewBackgroundColor")})]})};Y3.displayName="ChangeCanvasBackground";var W3=()=>{let{t:e}=dt(),t=Se();return St($t,{icon:Si,onSelect:()=>{t({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};W3.displayName="Export";var K3=()=>{let{t:e}=dt();return X3(iA,{children:[St(Qa,{icon:Id,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),St(Qa,{icon:Xx,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),St(Qa,{icon:Zx,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};K3.displayName="Socials";var Z3=({onSelect:e,isCollaborating:t})=>{let{t:o}=dt();return St($t,{"data-testid":"collab-button",icon:Ad,className:nA({"active-collab":t}),onSelect:e,children:o("labels.liveCollaboration")})};Z3.displayName="LiveCollaborationTrigger";import{jsx as hp,jsxs as Af}from"react/jsx-runtime";var aA=Object.assign(en("MainMenu",({children:e,onSelect:t})=>{let{MainMenuTunnel:o}=je(),r=Te(),n=_e(),i=Se(),a=r.editor.isMobile?void 0:()=>i({openMenu:null});return hp(o.In,{children:Af(Pe,{open:n.openMenu==="canvas",children:[hp(Pe.Trigger,{onToggle:()=>{i({openMenu:n.openMenu==="canvas"?null:"canvas"})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:Cd}),Af(Pe.Content,{onClickOutside:a,onSelect:un(t,()=>{i({openMenu:null})}),children:[e,r.editor.isMobile&&n.collaborators.size>0&&Af("fieldset",{className:"UserList-Wrapper",children:[hp("legend",{children:f("labels.collaborators")}),hp(dp,{mobile:!0,collaborators:n.collaborators,userToFollow:n.userToFollow?.socketId||null})]})]})]})})}),{Trigger:Pe.Trigger,Item:Pe.Item,ItemLink:Pe.ItemLink,ItemCustom:Pe.ItemCustom,Group:Pe.Group,Separator:Pe.Separator,DefaultItems:Mf}),Yt=aA;import lA from"clsx";import{forwardRef as sA,useState as cA}from"react";import{jsx as gp,jsxs as dA}from"react/jsx-runtime";var Fn=sA(({children:e,icon:t,onClick:o,label:r,variant:n="filled",color:i="primary",size:a="medium",fullWidth:l,className:s,status:c},m)=>{let[d,p]=cA(!1),u=async x=>{let b=o?.(x);if(pn(b)){let E=window.setTimeout(()=>{p(!0)},50);try{await b}catch(w){if(w instanceof sa)console.warn(w);else throw w}finally{clearTimeout(E),p(!1)}}},h=d?"loading":c;return i=h==="success"?"success":i,gp("button",{className:lA("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${n}`,`ExcButton--size-${a}`,`ExcButton--status-${h}`,{"ExcButton--fullWidth":l},s),onClick:u,type:"button","aria-label":r,ref:m,disabled:h==="loading"||h==="success",children:dA("div",{className:"ExcButton__contents",children:[h==="loading"?gp(Ot,{className:"ExcButton__statusIcon"}):h==="success"&&gp("div",{className:"ExcButton__statusIcon",children:KE}),t&&gp("div",{className:"ExcButton__icon","aria-hidden":!0,children:t}),n!=="icon"&&(e??r)]})})});import{jsx as sl,jsxs as uA}from"react/jsx-runtime";var fp=({title:e,children:t,actionLabel:o,onClick:r})=>uA("div",{className:"OverwriteConfirm__Actions__Action",children:[sl("h4",{children:e}),sl("div",{className:"OverwriteConfirm__Actions__Action__content",children:t}),sl(Fn,{variant:"outlined",color:"muted",label:o,size:"large",fullWidth:!0,onClick:r})]}),mA=()=>{let{t:e}=dt(),t=bt(),o=Se();return sl(fp,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{t.executeAction(hm,"ui",!0),o({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},pA=()=>{let{t:e}=dt(),t=bt();return sl(fp,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{t.executeAction(Es,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},Lf=Object.assign(({children:e})=>sl("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:mA,SaveToDisk:pA});import{jsx as zn,jsxs as $3}from"react/jsx-runtime";var bp=Object.assign(en("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:t}=je(),[o,r]=ve(If);if(!o.active)return null;let n=()=>{o.onClose(),r(a=>({...a,active:!1}))},i=()=>{o.onConfirm(),r(a=>({...a,active:!1}))};return zn(t.In,{children:zn(ct,{onCloseRequest:n,title:!1,size:916,children:$3("div",{className:"OverwriteConfirm",children:[zn("h3",{children:o.title}),$3("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${o.color}`,children:[zn("div",{className:"OverwriteConfirm__Description__icon",children:ZE}),zn("div",{children:o.description}),zn("div",{className:"OverwriteConfirm__Description__spacer"}),zn(Fn,{color:o.color,size:"large",label:o.actionLabel,onClick:i})]}),zn(Lf,{children:e})]})})})}),{Actions:Lf,Action:fp});import MA from"clsx";import hA from"clsx";import gA from"lodash.debounce";import{Fragment as fA,memo as bA,useEffect as Ns,useMemo as j3,useRef as Df,useState as q3}from"react";import{Fragment as kA,jsx as Dt,jsxs as Lr}from"react/jsx-runtime";var xA=ke(""),_f=ke(null),EA=350,t5=()=>{let e=lt(),t=Se(),o=Df(null),[r,n]=ve(xA),i=r.trim(),[a,l]=q3(!1),[s,c]=q3({nonce:null,items:[]}),m=Df(null),d=Df(void 0),[p,u]=ve(_f),h=e.scene.getNonDeletedElementsMap();Ns(()=>{a||(i!==m.current||e.scene.getSceneNonce()!==d.current)&&(m.current=null,e5(i,e,(y,v)=>{c({nonce:$o(),items:y}),m.current=i,d.current=e.scene.getSceneNonce(),t({searchMatches:y.length?{focusedId:null,matches:y.map(C=>({id:C.element.id,focus:!1,matchedLines:C.matchedLines}))}:null})}))},[a,i,h,e,t,u,d]);let x=()=>{s.items.length>0&&u(y=>y===null?0:(y+1)%s.items.length)},b=()=>{s.items.length>0&&u(y=>y===null?0:y-1<0?s.items.length-1:y-1)};Ns(()=>{t(y=>y.searchMatches?{searchMatches:{focusedId:p!==null&&y.searchMatches?.matches[p]?.id||null,matches:y.searchMatches.matches.map((C,I)=>I===p?{...C,focus:!0}:{...C,focus:!1})}}:null)},[p,t]),Ns(()=>{if(s.items.length>0&&p!==null){let y=s.items[p];if(y){let v=e.state.zoom.value,C=Xt({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:J(y.element)?Ft.nameFontSize:y.element.fontSize,fontFamily:J(y.element)?yt.Assistant:y.element.fontFamily}),I=14,L=C.fontSize,A=L*v<I;if(!Ji([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())||A){let R;A?L>=I?R={fitToContent:!0}:R={fitToViewport:!0,maxZoom:Do(I/L,1)}:R={fitToContent:!0},e.scrollToContent(C,{animate:!0,duration:300,...R,canvasOffsets:e.getEditorUIOffsets()})}}}},[p,s,e]),Ns(()=>()=>{u(null),m.current=null,d.current=void 0,t({searchMatches:null}),l(!1)},[t,u]);let E=Sn({goToNextItem:x,goToPreviousItem:b,searchMatches:s});Ns(()=>{let y=v=>{if(v.key===T.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){v.preventDefault(),v.stopPropagation(),t({openSidebar:null});return}v[T.CTRL_OR_CMD]&&v.key===T.F&&(v.preventDefault(),v.stopPropagation(),o.current?.matches(":focus")||(e.state.openDialog&&t({openDialog:null}),o.current?.focus(),o.current?.select())),v.target instanceof HTMLElement&&v.target.closest(".layer-ui__search")&&E.searchMatches.items.length&&(v.key===T.ENTER&&(v.stopPropagation(),E.goToNextItem()),v.key===T.ARROW_UP?(v.stopPropagation(),E.goToPreviousItem()):v.key===T.ARROW_DOWN&&(v.stopPropagation(),E.goToNextItem()))};return Ze(window,"keydown",y,{capture:!0,passive:!1})},[t,E,e]);let w=`${s.items.length} ${s.items.length===1?f("search.singleResult"):f("search.multipleResults")}`;return Lr("div",{className:"layer-ui__search",children:[Dt("div",{className:"layer-ui__search-header",children:Dt(ol,{className:Wt.SEARCH_MENU_INPUT_WRAPPER,value:r,ref:o,placeholder:f("search.placeholder"),icon:wo,onChange:y=>{n(y),l(!0);let v=y.trim();e5(v,e,(C,I)=>{c({nonce:$o(),items:C}),u(I),m.current=v,d.current=e.scene.getSceneNonce(),t({searchMatches:C.length?{focusedId:null,matches:C.map(L=>({id:L.element.id,focus:!1,matchedLines:L.matchedLines}))}:null}),l(!1)})},selectOnRender:!0})}),Lr("div",{className:"layer-ui__search-count",children:[s.items.length>0&&Lr(kA,{children:[p!==null&&p>-1?Lr("div",{children:[p+1," / ",w]}):Dt("div",{children:w}),Lr("div",{className:"result-nav",children:[Dt(Mo,{onSelect:()=>{x()},className:"result-nav-btn",children:zd}),Dt(Mo,{onSelect:()=>{b()},className:"result-nav-btn",children:fy})]})]}),s.items.length===0&&i&&m.current&&Dt("div",{style:{margin:"1rem auto"},children:f("search.noMatch")})]}),Dt(wA,{matches:s,onItemClick:u,focusIndex:p,searchQuery:i})]})},J3=e=>{let t=[e.preview.moreBefore?"...":"",e.preview.previewText.slice(0,e.preview.indexInSearchQuery),e.preview.previewText.slice(e.preview.indexInSearchQuery,e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.previewText.slice(e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.moreAfter?"...":""];return Dt("div",{tabIndex:-1,className:hA("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:o=>{e.highlighted&&o?.scrollIntoView({behavior:"auto",block:"nearest"})},children:Dt("div",{className:"preview-text",children:t.flatMap((o,r)=>Dt(fA,{children:r===2?Dt("b",{children:o}):o},r))})})},yA=e=>{let t=j3(()=>e.matches.items.filter(r=>J(r.element)),[e.matches]),o=j3(()=>e.matches.items.filter(r=>K(r.element)),[e.matches]);return Lr("div",{children:[t.length>0&&Lr("div",{className:"layer-ui__search-result-container",children:[Lr("div",{className:"layer-ui__search-result-title",children:[Dt("div",{className:"title-icon",children:Ii}),Dt("div",{children:f("search.frames")})]}),t.map((r,n)=>Dt(J3,{searchQuery:e.searchQuery,preview:r.preview,highlighted:n===e.focusIndex,onClick:()=>e.onItemClick(n)},r.element.id+r.index)),o.length>0&&Dt("div",{className:"layer-ui__divider"})]}),o.length>0&&Lr("div",{className:"layer-ui__search-result-container",children:[Lr("div",{className:"layer-ui__search-result-title",children:[Dt("div",{className:"title-icon",children:Ea}),Dt("div",{children:f("search.texts")})]}),o.map((r,n)=>Dt(J3,{searchQuery:e.searchQuery,preview:r.preview,highlighted:n+t.length===e.focusIndex,onClick:()=>e.onItemClick(n+t.length)},r.element.id+r.index))]})]})},vA=(e,t)=>e.matches.nonce===t.matches.nonce&&e.focusIndex===t.focusIndex,wA=bA(yA,vA),Q3=(e,t,o)=>{let i=e.slice(0,t),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(t+o.length),p=d.split(/\s+/),u=!d.startsWith(" "),h=u?6:5,x=(u?"":" ")+p.slice(0,h).join(" ");return{indexInSearchQuery:c.length,previewText:c+o+x,moreBefore:s>0,moreAfter:p.length>h}},TA=(e,t)=>{let o=e.split(`
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
${g("hints.firefox_clipboard_write")}`):new Error(g("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var wE=async(e,o,t,n)=>{let{exportBackground:r,viewBackgroundColor:i,fileHandle:a}=o,l=P1(a);if(!a||!L1(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:m}=er(e,o,!1);return await tr(l,s,o,t,{exportBackground:r,viewBackgroundColor:i,name:n,fileHandle:a,exportingFrame:m}),{fileHandle:a}};import{Fragment as cM,jsx as zo,jsxs as dM}from"react/jsx-runtime";var su=N({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,o,t)=>({appState:{...o,name:t},captureUpdate:io.EVENTUALLY}),PanelComponent:({appState:e,updateData:o,appProps:t,data:n,app:r})=>zo(rE,{label:g("labels.fileTitle"),value:r.getName(),onChange:i=>o(i),ignoreFocus:n?.ignoreFocus??!1})}),vE=N({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,o,t)=>({appState:{...o,exportScale:t},captureUpdate:io.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let n=sM(e),i=we(n,o)?j(n,o):n;return zo(cM,{children:lM.map(a=>{let[l,s]=k1(i,aM,a),m=`${g("imageExportDialog.label.scale")} ${a}x (${l}x${s})`;return zo(Z,{size:"small",type:"radio",icon:`${a}x`,name:"export-canvas-scale",title:m,"aria-label":m,id:"export-canvas-scale",checked:a===o.exportScale,onChange:()=>t(a)},a)})})}}),cu=N({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,o,t)=>({appState:{...o,exportBackground:t},captureUpdate:io.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>zo(Da,{checked:e.exportBackground,onChange:t=>o(t),children:g("imageExportDialog.label.withBackground")})}),rc=N({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,o,t)=>({appState:{...o,exportEmbedScene:t},captureUpdate:io.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>dM(Da,{checked:e.exportEmbedScene,onChange:t=>o(t),children:[g("imageExportDialog.label.embedScene"),zo(At,{label:g("imageExportDialog.tooltip.embedScene"),long:!0,children:zo("div",{className:"excalidraw-tooltip-icon",children:h0})})]})}),or=N({name:"saveToActiveFile",label:"buttons.save",icon:Xn,trackEvent:{category:"export"},predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.saveToActiveFile&&!!o.fileHandle&&!o.viewModeEnabled,perform:async(e,o,t,n)=>{let r=!!o.fileHandle;try{let{fileHandle:i}=Zl(o.fileHandle)?await wE(e,o,n.files,n.getName()):await Yl(e,o,n.files,n.getName());return{captureUpdate:io.EVENTUALLY,appState:{...o,fileHandle:i,toast:r?{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:io.EVENTUALLY}}},keyTest:e=>e.key===ni.S&&e[ni.CTRL_OR_CMD]&&!e.shiftKey}),za=N({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:Xn,viewMode:!0,trackEvent:{category:"export"},perform:async(e,o,t,n)=>{try{let{fileHandle:r}=await Yl(e,{...o,fileHandle:null},n.files,n.getName());return{captureUpdate:io.EVENTUALLY,appState:{...o,openDialog:null,fileHandle:r,toast:{message:g("toast.fileSaved")}}}}catch(r){return r?.name!=="AbortError"?console.error(r):console.warn(r),{captureUpdate:io.EVENTUALLY}}},keyTest:e=>e.key===ni.S&&e.shiftKey&&e[ni.CTRL_OR_CMD],PanelComponent:({updateData:e})=>zo(Z,{type:"button",icon:c0,title:g("buttons.saveAs"),"aria-label":g("buttons.saveAs"),showAriaLabel:de().editor.isMobile,hidden:!Ir,onClick:()=>e(null),"data-testid":"save-as-button"})}),ri=N({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.loadScene&&!o.viewModeEnabled,perform:async(e,o,t,n)=>{try{let{elements:r,appState:i,files:a}=await Pm(o,e);return{elements:r,appState:i,files:a,captureUpdate:io.IMMEDIATELY}}catch(r){return r?.name==="AbortError"?(console.warn(r),!1):{elements:e,appState:{...o,errorMessage:r.message},files:n.files,captureUpdate:io.EVENTUALLY}}},keyTest:e=>e[ni.CTRL_OR_CMD]&&e.key===ni.O}),TE=N({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,o,t)=>({appState:{...o,exportWithDarkMode:t},captureUpdate:io.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>zo("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:zo(oE,{value:e.exportWithDarkMode?lu.DARK:lu.LIGHT,onChange:t=>{o(t===lu.DARK)},title:g("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as mM,DEFAULT_FONT_FAMILY as pM,DEFAULT_TEXT_ALIGN as uM,CODES as IE,KEYS as CE,getLineHeight as hM}from"@excalidraw/common";import{newElementWith as ic}from"@excalidraw/element";import{hasBoundTextElement as gM,canApplyRoundnessTypeToElement as fM,getDefaultRoundnessTypeForElement as bM,isFrameLikeElement as xM,isArrowElement as EM,isExcalidrawElement as yM,isTextElement as du}from"@excalidraw/element";import{getBoundTextElement as wM,redrawTextBoundingBox as vM}from"@excalidraw/element";import{CaptureUpdateAction as mu}from"@excalidraw/element";var SE="{}",pu=N({name:"copyStyles",label:"labels.copyStyles",icon:rp,trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=[],i=e.find(a=>o.selectedElementIds[a.id]);if(r.push(i),i&&gM(i)){let a=wM(i,n.scene.getNonDeletedElementsMap());r.push(a)}return i&&(SE=JSON.stringify(r)),{appState:{...o,toast:{message:g("toast.copyStyles")}},captureUpdate:mu.EVENTUALLY}},keyTest:e=>e[CE.CTRL_OR_CMD]&&e.altKey&&e.code===IE.C}),uu=N({name:"pasteStyles",label:"labels.pasteStyles",icon:rp,trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=JSON.parse(SE),i=r[0],a=r[1];if(!yM(i))return{elements:e,captureUpdate:mu.EVENTUALLY};let l=j(e,o,{includeBoundTextElement:!0}),s=l.map(m=>m.id);return{elements:e.map(m=>{if(s.includes(m.id)){let d=i;if(du(m)&&m.containerId&&(d=a),!d)return m;let c=ic(m,{backgroundColor:d?.backgroundColor,strokeWidth:d?.strokeWidth,strokeColor:d?.strokeColor,strokeStyle:d?.strokeStyle,fillStyle:d?.fillStyle,opacity:d?.opacity,roughness:d?.roughness,roundness:d.roundness?fM(d.roundness.type,m)?d.roundness:bM(m):null});if(du(c)){let p=d.fontSize||mM,u=d.fontFamily||pM;c=ic(c,{fontSize:p,fontFamily:u,textAlign:d.textAlign||uM,lineHeight:d.lineHeight||hM(u)});let f=null;c.containerId&&(f=l.find(b=>du(c)&&b.id===c.containerId)||null),vM(c,f,n.scene)}return c.type==="arrow"&&EM(d)&&(c=ic(c,{startArrowhead:d.startArrowhead,endArrowhead:d.endArrowhead})),xM(m)&&(c=ic(c,{roundness:null,backgroundColor:"transparent"})),c}return m}),captureUpdate:mu.IMMEDIATELY}},keyTest:e=>e[CE.CTRL_OR_CMD]&&e.altKey&&e.code===IE.V});import{KEYS as TM}from"@excalidraw/common";import{getNonDeletedElements as IM}from"@excalidraw/element";import{showSelectedShapeActions as CM}from"@excalidraw/element";import{CaptureUpdateAction as hu}from"@excalidraw/element";import{jsx as kE}from"react/jsx-runtime";var SM=N({name:"toggleCanvasMenu",label:"buttons.menu",trackEvent:{category:"menu"},perform:(e,o)=>({appState:{...o,openMenu:o.openMenu==="canvas"?null:"canvas"},captureUpdate:hu.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>kE(Z,{type:"button",icon:is,"aria-label":g("buttons.menu"),onClick:o,selected:e.openMenu==="canvas"})}),kM=N({name:"toggleEditMenu",label:"buttons.edit",trackEvent:{category:"menu"},perform:(e,o)=>({appState:{...o,openMenu:o.openMenu==="shape"?null:"shape"},captureUpdate:hu.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>kE(Z,{visible:CM(o,IM(e)),type:"button",icon:d0,"aria-label":g("buttons.edit"),onClick:t,selected:o.openMenu==="shape"})}),nr=N({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:r0,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,o,t,{focusContainer:n})=>(o.openDialog?.name==="help"&&n(),{appState:{...o,openDialog:o.openDialog?.name==="help"?null:{name:"help"}},captureUpdate:hu.EVENTUALLY}),keyTest:e=>e.key===TM.QUESTION_MARK});import{getNonDeletedElements as lc}from"@excalidraw/element";import{newElementWith as LE}from"@excalidraw/element";import{isBoundToContainer as MM}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as PM,getElementsInResizingFrame as LM,getFrameLikeElements as AM,getRootElements as DM,groupByFrameLikes as _M,removeElementsFromFrame as RM,replaceAllElementsInFrame as NM}from"@excalidraw/element";import{KEYS as sc,randomId as BM,arrayToMap as gu,getShortcutKey as AE}from"@excalidraw/common";import{getSelectedGroupIds as ac,selectGroup as FM,selectGroupsForSelectedElements as OM,getElementsInGroup as ME,addToGroup as zM,removeFromSelectedGroups as HM,isElementInGroup as DE}from"@excalidraw/element";import{syncMovedIndices as GM}from"@excalidraw/element";import{CaptureUpdateAction as Ha}from"@excalidraw/element";import{jsx as ii}from"react/jsx-runtime";var UM=e=>{if(e.length>=2){let o=e[0].groupIds;for(let t of o)if(e.reduce((n,r)=>n&&DE(r,t),!0))return!0}return!1},PE=(e,o,t)=>{let n=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});return n.length>=2&&!UM(n)&&!PM(n)},fu=N({name:"group",label:"labels.group",icon:e=>ii(ep,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=DM(n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}));if(r.length<2)return{appState:o,elements:e,captureUpdate:Ha.EVENTUALLY};let i=ac(o);if(i.length===1){let x=i[0],y=new Set(ME(e,x).map(v=>v.id)),E=new Set(r.map(v=>v.id));if(new Set([...Array.from(y),...Array.from(E)]).size===y.size)return{appState:o,elements:e,captureUpdate:Ha.EVENTUALLY}}let a=[...e];new Set(r.map(x=>x.frameId)).size>1&&_M(r).forEach((y,E)=>{RM(y,n.scene.getNonDeletedElementsMap())});let s=BM(),m=gu(r);a=a.map(x=>m.get(x.id)?LE(x,{groupIds:zM(x.groupIds,s,o.editingGroupId)}):x);let d=ME(a,s),c=d[d.length-1],p=a.lastIndexOf(c),u=a.slice(p+1),f=a.slice(0,p).filter(x=>!DE(x,s)),b=GM([...f,...d,...u],gu(d));return{appState:{...o,...FM(s,{...o,selectedGroupIds:{}},lc(a))},elements:b,captureUpdate:Ha.IMMEDIATELY}},predicate:(e,o,t,n)=>PE(e,o,n),keyTest:e=>!e.shiftKey&&e[sc.CTRL_OR_CMD]&&e.key===sc.G,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>ii(Z,{hidden:!PE(e,o,n),type:"button",icon:ii(ep,{theme:o.theme}),onClick:()=>t(null),title:`${g("labels.group")} \u2014 ${AE("CtrlOrCmd+G")}`,"aria-label":g("labels.group"),visible:we(lc(e),o)})}),bu=N({name:"ungroup",label:"labels.ungroup",icon:e=>ii(tp,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=ac(o),i=gu(e);if(r.length===0)return{appState:o,elements:e,captureUpdate:Ha.EVENTUALLY};let a=[...e],l=[];a=a.map(p=>{MM(p)&&l.push(p.id);let u=HM(p.groupIds,o.selectedGroupIds);return u.length===p.groupIds.length?p:LE(p,{groupIds:u})});let s=OM(o,lc(a),o,null),m=n.scene.getSelectedElements(o),d=new Set(m.filter(p=>p.frameId).map(p=>p.frameId));return AM(e).filter(p=>d.has(p.id)).forEach(p=>{p&&(a=NM(a,LM(a,p,o,i),p,n))}),s.selectedElementIds=Object.entries(s.selectedElementIds).reduce((p,[u,f])=>(f&&!l.includes(u)&&(p[u]=!0),p),{}),{appState:{...o,...s},elements:a,captureUpdate:Ha.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[sc.CTRL_OR_CMD]&&e.key===sc.G.toUpperCase(),predicate:(e,o)=>ac(o).length>0,PanelComponent:({elements:e,appState:o,updateData:t})=>ii(Z,{type:"button",hidden:ac(o).length===0,icon:ii(tp,{theme:o.theme}),onClick:()=>t(null),title:`${g("labels.ungroup")} \u2014 ${AE("CtrlOrCmd+Shift+G")}`,"aria-label":g("labels.ungroup"),visible:we(lc(e),o)})});import $M from"clsx";import{CaptureUpdateAction as FE}from"@excalidraw/element";import{COLOR_CHARCOAL_BLACK as YM,COLOR_VOICE_CALL as WM,COLOR_WHITE as dc,THEME as VM,UserIdleState as _E}from"@excalidraw/common";var cc=(e,o,t,n,r,i,a)=>{e.beginPath(),e.moveTo(o+i,t),e.lineTo(o+n-i,t),e.quadraticCurveTo(o+n,t,o+n,t+i),e.lineTo(o+n,t+r-i),e.quadraticCurveTo(o+n,t+r,o+n-i,t+r),e.lineTo(o+i,t+r),e.quadraticCurveTo(o,t+r,o,t+r-i),e.lineTo(o,t+i),e.quadraticCurveTo(o,t,o+i,t),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};function XM(e){let o=0;if(e.length===0)return o;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);o=(o<<5)-o+n}return o}var rr=(e,o)=>`hsl(${Math.abs(XM(o?.id||e))%37*10}, 100%, 83%)`,RE=e=>{let o=e?.trim()?.codePointAt(0);return(o?String.fromCodePoint(o):"?").toUpperCase()},NE=({context:e,renderConfig:o,appState:t,normalizedWidth:n,normalizedHeight:r})=>{for(let[i,a]of o.remotePointerViewportCoords){let{x:l,y:s}=a,m=t.collaborators.get(i);l-=t.offsetLeft,s-=t.offsetTop;let d=11,c=14,p=l<0||l>n-d||s<0||s>r-c;l=Math.max(l,0),l=Math.min(l,n-d),s=Math.max(s,0),s=Math.min(s,r-c);let u=rr(i,m);e.save(),e.strokeStyle=u,e.fillStyle=u;let f=o.remotePointerUserStates.get(i),b=p||f===_E.IDLE||f===_E.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===VM.DARK?"#2f6330":WM,y=m?.isSpeaking;y&&(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=dc,e.strokeStyle=dc,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 w=(y?l+0:l)+d/2,v=(y?s+0:s)+c+2,C=5,S=3,L=e.measureText(E),P=L.actualBoundingBoxDescent+L.actualBoundingBoxAscent,B=Math.max(P,12),k=w-1,A=v-1,F=L.width+2+C*2+2,Y=B+2+S*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(k,A,F,Y,8),e.fillStyle=u,e.fill(),e.strokeStyle=dc,e.stroke(),y&&(e.beginPath(),e.roundRect(k-2,A-2,F+4,Y+4,8),e.strokeStyle=x,e.stroke())):cc(e,k,A,F,Y,8,dc),e.fillStyle=YM,e.fillText(E,w+C+1,v+S+L.actualBoundingBoxAscent+Math.floor((B-P)/2)+2),y){e.fillStyle=x;let Q=8,_=8,R=5;e.fillRect(k+F+_,A+(Y/2-Q/2),2,Q),e.fillRect(k+F+_+R,A+(Y/2-Q*2/2),2,Q*2),e.fillRect(k+F+_+R*2,A+(Y/2-Q/2),2,Q)}}e.restore(),e.closePath()}};import KM from"clsx";import{useState as ZM}from"react";import{jsx as BE}from"react/jsx-runtime";var xu=({color:e,onClick:o,name:t,src:n,className:r})=>{let i=RE(t),[a,l]=ZM(!1),s=!a&&n,m=s?void 0:{background:e};return BE("div",{className:KM("Avatar",r),style:m,onClick:o,children:s?BE("img",{className:"Avatar-img",src:n,alt:i,referrerPolicy:"no-referrer",onError:()=>l(!0)}):i})};import{jsx as wo,jsxs as mc}from"react/jsx-runtime";var jM=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:FE.EVENTUALLY}:{appState:{...o,userToFollow:{socketId:t.socketId,username:t.username||""},openMenu:o.openMenu==="canvas"?null:o.openMenu},captureUpdate:FE.EVENTUALLY},PanelComponent:({updateData:e,data:o,appState:t})=>{let{socketId:n,collaborator:r,withName:i,isBeingFollowed:a}=o,l=rr(n,r),s=$M({"is-followed":a,"is-current-user":r.isCurrentUser===!0,"is-speaking":r.isSpeaking,"is-in-call":r.isInCall,"is-muted":r.isMuted}),m=r.isInCall?r.isSpeaking?mc("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:g("userList.hint.isSpeaking"),children:[wo("div",{}),wo("div",{}),wo("div",{})]}):r.isMuted?wo("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:g("userList.hint.micMuted"),children:gb}):wo("div",{title:g("userList.hint.inCall"),children:hb}):null;return i?mc("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(r),children:[wo(xu,{color:l,onClick:()=>{},name:r.username||"",src:r.avatarUrl,className:s}),wo("div",{className:"UserList__collaborator-name",children:r.username}),mc("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&wo("div",{className:"UserList__collaborator-status-icon-is-followed",title:g("userList.hint.followStatus"),children:Br}),m]})]}):mc("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[wo(xu,{color:l,onClick:()=>{e(r)},name:r.username||"",src:r.avatarUrl,className:s}),m&&wo("div",{className:"UserList__collaborator-status-icon",children:m})]})}});import{LIBRARY_DISABLED_TYPES as qM,randomId as JM}from"@excalidraw/common";import{deepCopyElement as QM}from"@excalidraw/element";import{CaptureUpdateAction as Eu}from"@excalidraw/element";var yu=N({name:"addToLibrary",trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let i of qM)if(r.some(a=>a.type===i))return{captureUpdate:Eu.EVENTUALLY,appState:{...o,errorMessage:g(`errors.libraryElementTypeError.${i}`)}};return n.library.getLatestLibrary().then(i=>n.library.setLibrary([{id:JM(),status:"unpublished",elements:r.map(QM),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 ai}from"@excalidraw/element";import{isFrameLikeElement as eP}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as tP}from"@excalidraw/element";import{KEYS as hn,arrayToMap as oP,getShortcutKey as pc}from"@excalidraw/common";import{alignElements as nP}from"@excalidraw/element";import{CaptureUpdateAction as li}from"@excalidraw/element";import{getSelectedElementsByGroup as rP}from"@excalidraw/element";import{jsx as ci}from"react/jsx-runtime";var gt=(e,o)=>{let t=o.scene.getSelectedElements(e);return rP(t,o.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(n=>eP(n))},si=(e,o,t,n)=>{let r=t.scene.getSelectedElements(o),i=nP(r,n,t.scene,o),a=oP(i);return tP(e.map(l=>a.get(l.id)||l),o,t)},iP=N({name:"alignTop",label:"labels.alignTop",icon:Zm,trackEvent:{category:"element"},predicate:(e,o,t,n)=>gt(o,n),perform:(e,o,t,n)=>({appState:o,elements:si(e,o,n,{position:"start",axis:"y"}),captureUpdate:li.IMMEDIATELY}),keyTest:e=>e[hn.CTRL_OR_CMD]&&e.shiftKey&&e.key===hn.ARROW_UP,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>ci(Z,{hidden:!gt(o,n),type:"button",icon:Zm,onClick:()=>t(null),title:`${g("labels.alignTop")} \u2014 ${pc("CtrlOrCmd+Shift+Up")}`,"aria-label":g("labels.alignTop"),visible:we(ai(e),o)})}),aP=N({name:"alignBottom",label:"labels.alignBottom",icon:$m,trackEvent:{category:"element"},predicate:(e,o,t,n)=>gt(o,n),perform:(e,o,t,n)=>({appState:o,elements:si(e,o,n,{position:"end",axis:"y"}),captureUpdate:li.IMMEDIATELY}),keyTest:e=>e[hn.CTRL_OR_CMD]&&e.shiftKey&&e.key===hn.ARROW_DOWN,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>ci(Z,{hidden:!gt(o,n),type:"button",icon:$m,onClick:()=>t(null),title:`${g("labels.alignBottom")} \u2014 ${pc("CtrlOrCmd+Shift+Down")}`,"aria-label":g("labels.alignBottom"),visible:we(ai(e),o)})}),lP=N({name:"alignLeft",label:"labels.alignLeft",icon:jm,trackEvent:{category:"element"},predicate:(e,o,t,n)=>gt(o,n),perform:(e,o,t,n)=>({appState:o,elements:si(e,o,n,{position:"start",axis:"x"}),captureUpdate:li.IMMEDIATELY}),keyTest:e=>e[hn.CTRL_OR_CMD]&&e.shiftKey&&e.key===hn.ARROW_LEFT,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>ci(Z,{hidden:!gt(o,n),type:"button",icon:jm,onClick:()=>t(null),title:`${g("labels.alignLeft")} \u2014 ${pc("CtrlOrCmd+Shift+Left")}`,"aria-label":g("labels.alignLeft"),visible:we(ai(e),o)})}),sP=N({name:"alignRight",label:"labels.alignRight",icon:qm,trackEvent:{category:"element"},predicate:(e,o,t,n)=>gt(o,n),perform:(e,o,t,n)=>({appState:o,elements:si(e,o,n,{position:"end",axis:"x"}),captureUpdate:li.IMMEDIATELY}),keyTest:e=>e[hn.CTRL_OR_CMD]&&e.shiftKey&&e.key===hn.ARROW_RIGHT,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>ci(Z,{hidden:!gt(o,n),type:"button",icon:qm,onClick:()=>t(null),title:`${g("labels.alignRight")} \u2014 ${pc("CtrlOrCmd+Shift+Right")}`,"aria-label":g("labels.alignRight"),visible:we(ai(e),o)})}),cP=N({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Jm,trackEvent:{category:"element"},predicate:(e,o,t,n)=>gt(o,n),perform:(e,o,t,n)=>({appState:o,elements:si(e,o,n,{position:"center",axis:"y"}),captureUpdate:li.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>ci(Z,{hidden:!gt(o,n),type:"button",icon:Jm,onClick:()=>t(null),title:g("labels.centerVertically"),"aria-label":g("labels.centerVertically"),visible:we(ai(e),o)})}),dP=N({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Qm,trackEvent:{category:"element"},predicate:(e,o,t,n)=>gt(o,n),perform:(e,o,t,n)=>({appState:o,elements:si(e,o,n,{position:"center",axis:"x"}),captureUpdate:li.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>ci(Z,{hidden:!gt(o,n),type:"button",icon:Qm,onClick:()=>t(null),title:g("labels.centerHorizontally"),"aria-label":g("labels.centerHorizontally"),visible:we(ai(e),o)})});import{getNonDeletedElements as OE}from"@excalidraw/element";import{isFrameLikeElement as mP}from"@excalidraw/element";import{CODES as zE,KEYS as HE,arrayToMap as pP,getShortcutKey as GE}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as uP}from"@excalidraw/element";import{distributeElements as hP}from"@excalidraw/element";import{CaptureUpdateAction as UE}from"@excalidraw/element";import{getSelectedElementsByGroup as gP}from"@excalidraw/element";import{jsx as VE}from"react/jsx-runtime";var YE=(e,o)=>{let t=o.scene.getSelectedElements(e);return gP(t,o.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(n=>mP(n))},WE=(e,o,t,n)=>{let r=t.scene.getSelectedElements(o),i=hP(r,t.scene.getNonDeletedElementsMap(),n,o),a=pP(i);return uP(e.map(l=>a.get(l.id)||l),o,t)},fP=N({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,o,t,n)=>({appState:o,elements:WE(e,o,n,{space:"between",axis:"x"}),captureUpdate:UE.IMMEDIATELY}),keyTest:e=>!e[HE.CTRL_OR_CMD]&&e.altKey&&e.code===zE.H,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>VE(Z,{hidden:!YE(o,n),type:"button",icon:x0,onClick:()=>t(null),title:`${g("labels.distributeHorizontally")} \u2014 ${GE("Alt+H")}`,"aria-label":g("labels.distributeHorizontally"),visible:we(OE(e),o)})}),bP=N({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,o,t,n)=>({appState:o,elements:WE(e,o,n,{space:"between",axis:"y"}),captureUpdate:UE.IMMEDIATELY}),keyTest:e=>!e[HE.CTRL_OR_CMD]&&e.altKey&&e.code===zE.V,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>VE(Z,{hidden:!YE(o,n),type:"button",icon:E0,onClick:()=>t(null),title:`${g("labels.distributeVertically")} \u2014 ${GE("Alt+V")}`,"aria-label":g("labels.distributeVertically"),visible:we(OE(e),o)})});import{getNonDeletedElements as xP}from"@excalidraw/element";import{bindOrUnbindLinearElements as EP,isBindingEnabled as yP}from"@excalidraw/element";import{getCommonBoundingBox as XE}from"@excalidraw/element";import{newElementWith as wP}from"@excalidraw/element";import{deepCopyElement as vP}from"@excalidraw/element";import{resizeMultipleElements as TP}from"@excalidraw/element";import{isArrowElement as IP,isElbowArrow as CP,isLinearElement as SP}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as KE}from"@excalidraw/element";import{CODES as ZE,KEYS as kP,arrayToMap as MP}from"@excalidraw/common";import{CaptureUpdateAction as $E}from"@excalidraw/element";var wu=N({name:"flipHorizontal",label:"labels.flipHorizontal",icon:Eb,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:KE(jE(e,n.scene.getNonDeletedElementsMap(),o,"horizontal",n),o,n),appState:o,captureUpdate:$E.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===ZE.H}),vu=N({name:"flipVertical",label:"labels.flipVertical",icon:xb,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:KE(jE(e,n.scene.getNonDeletedElementsMap(),o,"vertical",n),o,n),appState:o,captureUpdate:$E.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===ZE.V&&!e[kP.CTRL_OR_CMD]}),jE=(e,o,t,n,r)=>{let i=j(xP(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=PP(i,o,t,n,r),l=MP(a);return e.map(s=>l.get(s.id)||s)},PP=(e,o,t,n,r)=>{if(e.every(u=>IP(u)&&(u.startBinding||u.endBinding)))return e.map(u=>{let f=u;return wP(f,{startArrowhead:f.endArrowhead,endArrowhead:f.startArrowhead})});let{midX:i,midY:a}=XE(e);TP(e,o,"nw",r.scene,new Map(Array.from(o.values()).map(u=>[u.id,vP(u)])),{flipByX:n==="horizontal",flipByY:n==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),EP(e.filter(SP),yP(t),[],r.scene,t.zoom);let{elbowArrows:l,otherElements:s}=e.reduce((u,f)=>CP(f)?{...u,elbowArrows:u.elbowArrows.concat(f)}:{...u,otherElements:u.otherElements.concat(f)},{elbowArrows:[],otherElements:[]}),{midX:m,midY:d}=XE(e),[c,p]=[i-m,a-d];return s.forEach(u=>r.scene.mutateElement(u,{x:u.x+c,y:u.y+p})),l.forEach(u=>r.scene.mutateElement(u,{x:u.x+c,y:u.y+p})),e};import{isTextElement as LP}from"@excalidraw/element";import{getTextFromElements as AP}from"@excalidraw/element";import{CODES as DP,KEYS as qE,isFirefox as _P}from"@excalidraw/common";import{CaptureUpdateAction as Rt}from"@excalidraw/element";var di=N({name:"copy",label:"labels.copy",icon:la,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await oc(r,n.files,t)}catch(i){return{captureUpdate:Rt.EVENTUALLY,appState:{...o,errorMessage:i.message}}}return{captureUpdate:Rt.EVENTUALLY}},keyTest:void 0}),Tu=N({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r;try{r=await xE()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),_P?{captureUpdate:Rt.EVENTUALLY,appState:{...o,errorMessage:g("hints.firefox_clipboard_write")}}:{captureUpdate:Rt.EVENTUALLY,appState:{...o,errorMessage:g("errors.asyncPasteFailedOnRead")}})}try{n.pasteFromClipboard(fE({types:r}))}catch(i){return console.error(i),{captureUpdate:Rt.EVENTUALLY,appState:{...o,errorMessage:g("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:Rt.EVENTUALLY}},keyTest:void 0}),uc=N({name:"cut",label:"labels.cut",icon:nb,trackEvent:{category:"element"},perform:(e,o,t,n)=>(di.perform(e,o,t,n),fa.perform(e,o,null,n)),keyTest:e=>e[qE.CTRL_OR_CMD]&&e.key===qE.X}),hc=N({name:"copyAsSvg",label:"labels.copyAsSvg",icon:yb,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{if(!n.canvas)return{captureUpdate:Rt.EVENTUALLY};let{exportedElements:r,exportingFrame:i}=er(e,o,!0);try{await tr("clipboard-svg",r,o,n.files,{...o,exportingFrame:i,name:n.getName()});let a=n.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:Rt.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:Rt.EVENTUALLY}}},predicate:e=>tc&&e.length>0,keywords:["svg","clipboard","copy"]}),gc=N({name:"copyAsPng",label:"labels.copyAsPng",icon:wb,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{if(!n.canvas)return{captureUpdate:Rt.EVENTUALLY};let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=er(e,o,!0);try{return await tr("clipboard",i,o,n.files,{...o,exportingFrame:a,name:n.getName()}),{appState:{...o,toast:{message:g("toast.copyToClipboardAsPng",{exportSelection:r.length?g("toast.selection"):g("toast.canvas"),exportColorScheme:o.exportWithDarkMode?g("buttons.darkMode"):g("buttons.lightMode")})}},captureUpdate:Rt.EVENTUALLY}}catch(l){return console.error(l),{appState:{...o,errorMessage:l.message},captureUpdate:Rt.EVENTUALLY}}},predicate:e=>oi&&e.length>0,keyTest:e=>e.code===DP.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),fc=N({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});try{ro(AP(r))}catch{throw new Error(g("errors.copyToSystemClipboardFailed"))}return{captureUpdate:Rt.EVENTUALLY}},predicate:(e,o,t,n)=>tc&&n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}).some(LP),keywords:["text","clipboard","copy"]});import{CODES as RP,KEYS as NP}from"@excalidraw/common";import{CaptureUpdateAction as BP}from"@excalidraw/element";var bc=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:BP.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[NP.CTRL_OR_CMD]&&e.code===RP.QUOTE});import{CODES as FP,KEYS as OP}from"@excalidraw/common";import{CaptureUpdateAction as zP}from"@excalidraw/element";var mi=N({name:"zenMode",label:"buttons.zenMode",icon:Tb,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,o){return{appState:{...o,zenModeEnabled:!this.checked(o)},captureUpdate:zP.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,o,t)=>typeof t.zenModeEnabled>"u",keyTest:e=>!e[OP.CTRL_OR_CMD]&&e.altKey&&e.code===FP.Z});import{CODES as HP,KEYS as GP}from"@excalidraw/common";import{CaptureUpdateAction as UP}from"@excalidraw/element";var Iu=N({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:vb,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,o){return{appState:{...o,objectsSnapModeEnabled:!this.checked(o),gridModeEnabled:!1},captureUpdate:UP.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,o,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[GP.CTRL_OR_CMD]&&e.altKey&&e.code===HP.S});import{CODES as YP,KEYS as WP}from"@excalidraw/common";import{CaptureUpdateAction as VP}from"@excalidraw/element";var pi=N({name:"stats",label:"stats.fullTitle",icon:bb,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,o){return{appState:{...o,stats:{...o.stats,open:!this.checked(o)}},captureUpdate:VP.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[WP.CTRL_OR_CMD]&&e.altKey&&e.code===YP.SLASH});import{BOUND_TEXT_PADDING as JE,ROUNDNESS as QE,TEXT_ALIGN as ty,VERTICAL_ALIGN as oy,arrayToMap as ny,getFontString as XP}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as KP,resetOriginalContainerCache as ZP,updateOriginalContainerCache as $P}from"@excalidraw/element";import{computeBoundTextPosition as jP,computeContainerDimensionForBoundText as ey,getBoundTextElement as ry,redrawTextBoundingBox as iy}from"@excalidraw/element";import{hasBoundTextElement as qP,isArrowElement as JP,isTextBindableContainer as Cu,isTextElement as Ga,isUsingAdaptiveRadius as QP}from"@excalidraw/element";import{measureText as eL}from"@excalidraw/element";import{syncMovedIndices as ay}from"@excalidraw/element";import{newElement as tL}from"@excalidraw/element";import{CaptureUpdateAction as Su}from"@excalidraw/element";var ku=N({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,o,t,n)=>n.scene.getSelectedElements(o).some(i=>qP(i)),perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i=n.scene.getNonDeletedElementsMap();return r.forEach(a=>{let l=ry(a,i);if(l){let{width:s,height:m}=eL(l.originalText,XP(l),l.lineHeight),d=KP(a.id);ZP(a.id);let{x:c,y:p}=jP(a,l,i);n.scene.mutateElement(l,{containerId:null,width:s,height:m,text:l.originalText,x:c,y:p}),n.scene.mutateElement(a,{boundElements:a.boundElements?.filter(u=>u.id!==l.id),height:d||a.height})}}),{elements:e,appState:o,captureUpdate:Su.IMMEDIATELY}}}),Mu=N({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);if(r.length===2){let i=Ga(r[0])||Ga(r[1]),a;if(Cu(r[0])?a=r[0]:Cu(r[1])&&(a=r[1]),i&&a&&ry(a,n.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i,a;Ga(r[0])&&Cu(r[1])?(i=r[0],a=r[1]):(i=r[1],a=r[0]),n.scene.mutateElement(i,{containerId:a.id,verticalAlign:oy.MIDDLE,textAlign:ty.CENTER,autoResize:!0,angle:JP(a)?0:a?.angle??0}),n.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let l=a.height;return iy(i,a,n.scene),$P(a.id,l),{elements:oL(e,a,i),appState:{...o,selectedElementIds:{[a.id]:!0}},captureUpdate:Su.IMMEDIATELY}}}),oL=(e,o,t)=>{let n=e.slice(),r=n.findIndex(a=>a.id===t.id);n.splice(r,1);let i=n.findIndex(a=>a.id===o.id);return n.splice(i+1,0,t),ay(n,ny([o,t])),n},nL=(e,o,t)=>{let n=e.slice(),r=n.findIndex(a=>a.id===o.id);n.splice(r,1);let i=n.findIndex(a=>a.id===t.id);return n.splice(i,0,o),ay(n,ny([o,t])),n},ly=N({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i=r.some(a=>Ga(a));return r.length>0&&i},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i=e.slice(),a={};for(let l of r)if(Ga(l)){let s=tL({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:QP("rectangle")?QE.ADAPTIVE_RADIUS:QE.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:l.x-JE,y:l.y-JE,width:ey(l.width,"rectangle"),height:ey(l.height,"rectangle"),groupIds:l.groupIds,frameId:l.frameId});if(l.boundElements?.length){let m=l.boundElements.filter(c=>c.type==="arrow").map(c=>c.id);i.filter(c=>m.includes(c.id)).forEach(c=>{let p=c.startBinding,u=c.endBinding;p?.elementId===l.id&&(p={...p,elementId:s.id}),u?.elementId===l.id&&(u={...u,elementId:s.id}),(p||u)&&n.scene.mutateElement(c,{startBinding:p,endBinding:u})})}n.scene.mutateElement(l,{containerId:s.id,verticalAlign:oy.MIDDLE,boundElements:null,textAlign:ty.CENTER,autoResize:!0}),iy(l,s,n.scene),i=nL([...i,s],s,l),a[s.id]=!0}return{elements:i,appState:{...o,selectedElementIds:a},captureUpdate:Su.IMMEDIATELY}}});import{isEmbeddableElement as yL}from"@excalidraw/element";import{KEYS as by,getShortcutKey as wL}from"@excalidraw/common";import{CaptureUpdateAction as vL}from"@excalidraw/element";import{pointFrom as my}from"@excalidraw/math";import rL from"clsx";import{useCallback as sy,useEffect as cy,useLayoutEffect as iL,useRef as aL,useState as lL}from"react";import{EVENT as Pu,HYPERLINK_TOOLTIP_DELAY as sL,KEYS as xc}from"@excalidraw/common";import{getElementAbsoluteCoords as Ru}from"@excalidraw/element";import{hitElementBoundingBox as cL}from"@excalidraw/element";import{isElementLink as dL}from"@excalidraw/element";import{getEmbedLink as mL,embeddableURLValidator as pL}from"@excalidraw/element";import{sceneCoordsToViewportCoords as py,viewportCoordsToSceneCoords as uL,wrapEvent as hL,isLocalLink as gL,normalizeLink as Lu}from"@excalidraw/common";import{isEmbeddableElement as Au}from"@excalidraw/element";import{jsx as ui,jsxs as dy}from"react/jsx-runtime";var Nu=380,fL=42,Du=5,uy=85,bL=500,_u=!1,Ec=new Map,hy=({element:e,scene:o,setAppState:t,onLinkOpen:n,setToast:r,updateEmbedValidationStatus:i})=>{let a=o.getNonDeletedElementsMap(),l=bo(),s=xo(),m=de(),d=e.link||"",[c,p]=lL(d),u=aL(null),f=l.showHyperlinkPopup==="editor",b=sy(()=>{if(!u.current)return;let v=Lu(u.current.value)||null;if(!e.link&&v&&re("hyperlink","create"),Au(e)){if(l.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!v){o.mutateElement(e,{link:null}),i(e,!1);return}if(!pL(v,s.validateEmbeddable))v&&r({message:g("toast.unableToEmbed"),closable:!0}),e.link&&Ec.set(e.id,e.link),o.mutateElement(e,{link:v}),i(e,!1);else{let{width:C,height:S}=e,L=mL(v);L?.error instanceof URIError&&r({message:g("toast.unrecognizedLinkFormat"),closable:!0});let P=L?L.intrinsicSize.w/L.intrinsicSize.h:1,B=Ec.get(e.id)!==e.link;o.mutateElement(e,{...B?{width:L?.type==="video"?C>S?C:S*P:C,height:L?.type==="video"&&C>S?C/P:S}:{},link:v}),i(e,!0),Ec.has(e.id)&&Ec.delete(e.id)}}else o.mutateElement(e,{link:v})},[e,o,r,s.validateEmbeddable,l.activeEmbeddable,t,i]);iL(()=>()=>{b()},[b]),cy(()=>{f&&u?.current&&!(m.viewport.isMobile||m.isTouchScreen)&&u.current.select()},[f,m.viewport.isMobile,m.isTouchScreen]),cy(()=>{let v=null,C=S=>{if(f)return;v&&clearTimeout(v),EL(e,a,l,my(S.clientX,S.clientY))&&(v=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},bL))};return window.addEventListener(Pu.POINTER_MOVE,C,!1),()=>{window.removeEventListener(Pu.POINTER_MOVE,C,!1),v&&clearTimeout(v)}},[l,e,f,t,a]);let x=sy(()=>{re("hyperlink","delete"),o.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,o]),y=()=>{re("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:E,y:w}=gy(e,l,a);return l.contextMenu||l.selectedElementsAreBeingDragged||l.resizingElement||l.isRotating||l.openMenu||l.viewModeEnabled?null:dy("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${w}px`,left:`${E}px`,width:Nu,padding:Du},children:[f?ui("input",{className:rL("excalidraw-hyperlinkContainer-input"),placeholder:g("labels.link.hint"),ref:u,value:c,onChange:v=>p(v.target.value),autoFocus:!0,onKeyDown:v=>{v.stopPropagation(),v[xc.CTRL_OR_CMD]&&v.key===xc.K&&v.preventDefault(),(v.key===xc.ENTER||v.key===xc.ESCAPE)&&(b(),t({showHyperlinkPopup:"info"}))}}):e.link?ui("a",{href:Lu(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:gL(e.link)?"_self":"_blank",onClick:v=>{if(e.link&&n){let C=hL(Pu.EXCALIDRAW_LINK,v.nativeEvent);n({...e,link:Lu(e.link)},C),C.defaultPrevented&&v.preventDefault()}},rel:"noopener noreferrer",children:e.link}):ui("div",{className:"excalidraw-hyperlinkContainer-link",children:g("labels.link.empty")}),dy("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!f&&ui(Z,{type:"button",title:g("buttons.edit"),"aria-label":g("buttons.edit"),label:g("buttons.edit"),onClick:y,className:"excalidraw-hyperlinkContainer--edit",icon:tn}),ui(Z,{type:"button",title:g("labels.linkToElement"),"aria-label":g("labels.linkToElement"),label:g("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:bs}),d&&!Au(e)&&ui(Z,{type:"button",title:g("buttons.remove"),"aria-label":g("buttons.remove"),label:g("buttons.remove"),onClick:x,className:"excalidraw-hyperlinkContainer--remove",icon:Mt})]})]})},gy=(e,o,t)=>{let[n,r]=Ru(e,t),{x:i,y:a}=py({sceneX:n+e.width/2,sceneY:r},o),l=i-o.offsetLeft-Nu/2,s=a-o.offsetTop-uy;return{x:l,y:s}},Bu=(e,o)=>{let t=j(e,o);return Au(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},Ua=null,fy=(e,o,t)=>{Ua&&clearTimeout(Ua),Ua=window.setTimeout(()=>xL(e,o,t),sL)},xL=(e,o,t)=>{if(!e.link)return;let n=Qr();n.classList.add("excalidraw-tooltip--visible"),n.style.maxWidth="20rem",n.textContent=dL(e.link)?g("labels.link.goToElement"):e.link;let[r,i,a,l]=Ru(e,t),[s,m,d,c]=E1([r,i,a,l],e.angle,o),p=py({sceneX:s,sceneY:m},o);Zp(n,{left:p.x,top:p.y,width:d,height:c},"top"),re("hyperlink","tooltip","link-icon"),_u=!0},Fu=()=>{Ua&&clearTimeout(Ua),_u&&(_u=!1,Qr().classList.remove("excalidraw-tooltip--visible"))},EL=(e,o,t,[n,r])=>{let{x:i,y:a}=uL({clientX:n,clientY:r},t),l=15/t.zoom.value;if(cL(my(i,a),e,o))return!1;let[s,m,d]=Ru(e,o);if(i>=s&&i<=d&&a>=m-uy&&a<=m)return!1;let{x:c,y:p}=gy(e,t,o);return!(n>=c-l&&n<=c+Nu+Du*2+l&&r>=p-l&&r<=p+l+Du*2+fL)};import{jsx as TL}from"react/jsx-runtime";var Ya=N({name:"hyperlink",label:(e,o)=>Bu(e,o),icon:da,perform:(e,o)=>o.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...o,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:vL.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[by.CTRL_OR_CMD]&&e.key===by.K,predicate:(e,o)=>j(e,o).length===1,PanelComponent:({elements:e,appState:o,updateData:t})=>{let n=j(e,o);return TL(Z,{type:"button",icon:da,"aria-label":g(Bu(e,o)),title:`${yL(e[0])?g("labels.link.labelEmbed"):g("labels.link.label")} - ${wL("CtrlOrCmd+K")}`,onClick:()=>t(null),selected:n.length===1&&!!n[0].link})}});import{KEYS as xy,arrayToMap as zu,randomId as IL}from"@excalidraw/common";import{elementsAreInSameGroup as CL,newElementWith as Ey,selectGroupsFromGivenElements as yy}from"@excalidraw/element";import{CaptureUpdateAction as wy}from"@excalidraw/element";var Ou=e=>e.every(o=>!o.locked),Wa=N({name:"toggleElementLock",label:(e,o,t)=>{let n=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1});return Ou(n)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,o)=>{let t=j(o,e);return Ou(t)?Lr:Vn},trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return r.length>0&&!r.some(i=>i.locked&&i.frameId)},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!r.length)return!1;let i=Ou(r),a=zu(r),l=r.length>1&&CL(r),m=r.length===1||l?null:IL(),d={...o.lockedMultiSelections};if(i)d={...o.lockedMultiSelections,...m?{[m]:!0}:{}};else if(l){let y=r[0].groupIds.at(-1);delete d[y]}let c=e.map(y=>{if(!a.has(y.id))return y;let E=y.groupIds;return i?m&&(E=[...E,m]):E=E.filter(w=>!o.lockedMultiSelections[w]),Ey(y,{locked:i,groupIds:E.length!==y.groupIds.length?E:y.groupIds})}),p=zu(c),u=i?{}:Object.fromEntries(r.map(y=>[y.id,!0])),f=r.map(y=>p.get(y.id)||y),b=i?{}:yy(f,o),x=i?m||(l?r[0].groupIds.at(-1):r[0].id):null;return{elements:c,appState:{...o,selectedElementIds:u,selectedGroupIds:b,selectedLinearElement:i?null:o.selectedLinearElement,lockedMultiSelections:d,activeLockedId:x},captureUpdate:wy.IMMEDIATELY}},keyTest:(e,o,t,n)=>e.key.toLocaleLowerCase()===xy.L&&e[xy.CTRL_OR_CMD]&&e.shiftKey&&n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}).length>0}),vy=N({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:Vn,predicate:(e,o)=>j(e,o).length===0&&e.some(n=>n.locked),perform:(e,o)=>{let t=e.filter(a=>a.locked),n=e.map(a=>{if(a.locked){let l=a.groupIds.filter(s=>!o.lockedMultiSelections[s]);return Ey(a,{locked:!1,groupIds:a.groupIds.length!==l.length?l:a.groupIds})}return a}),r=zu(n),i=t.map(a=>r.get(a.id)||a);return{elements:n,appState:{...o,selectedElementIds:Object.fromEntries(t.map(a=>[a.id,!0])),selectedGroupIds:yy(i,o),lockedMultiSelections:{},activeLockedId:null},captureUpdate:wy.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as ND,isLinearElement as BD,isLineElement as Ai}from"@excalidraw/element";import{arrayToMap as FD,invariant as zh}from"@excalidraw/common";import{toggleLinePolygonState as OD,CaptureUpdateAction as kw}from"@excalidraw/element";import Q2 from"clsx";import M7 from"fuzzy";import{useEffect as qc,useRef as P7,useState as jc}from"react";import{DEFAULT_SIDEBAR as q2,EVENT as Qc,KEYS as lo,capitalizeString as L7,getShortcutKey as A7,isWritableElement as D7}from"@excalidraw/common";import{CaptureUpdateAction as lA}from"@excalidraw/element";import{useEffect as Ka,useMemo as Ty,useRef as Yu,useState as SL}from"react";import{getLinearElementSubType as fi,updateElbowArrowPoints as kL}from"@excalidraw/element";import{pointFrom as wc,pointRotateRads as ML}from"@excalidraw/math";import{hasBoundTextElement as PL,isArrowBoundToElement as LL,isArrowElement as AL,isElbowArrow as DL,isLinearElement as Ku,isUsingAdaptiveRadius as _L}from"@excalidraw/element";import{getCommonBoundingBox as RL,getElementAbsoluteCoords as NL}from"@excalidraw/element";import{getBoundTextElement as My,getBoundTextMaxHeight as BL,getBoundTextMaxWidth as FL,redrawTextBoundingBox as OL}from"@excalidraw/element";import{wrapText as zL}from"@excalidraw/element";import{assertNever as HL,CLASSES as GL,getFontString as Hu,isProdEnv as UL,mapFind as YL,reduceToCommonValue as WL,updateActiveTool as Iy}from"@excalidraw/common";import{measureText as Cy}from"@excalidraw/element";import{LinearElementEditor as VL}from"@excalidraw/element";import{newArrowElement as Gu,newElement as XL,newLinearElement as KL}from"@excalidraw/element";import{ShapeCache as ZL}from"@excalidraw/element";import{updateBindings as $L}from"@excalidraw/element";import{jsx as Xu}from"react/jsx-runtime";var jL=8,qL=10,Va=["rectangle","diamond","ellipse"],Xa=["line","sharpArrow","curvedArrow","elbowArrow"],JL=new Set(Va),QL=new Set(Xa),bi=e=>JL.has(e),Tc=e=>e==="arrow"||QL.has(e),ao=he(null),Za=new Map,$a=new Map,eA=({app:e})=>{let o=e.scene.getSelectedElements(e.state),t=Yu(null);return Ka(()=>{if(o.length===0){e.updateEditorAtom(ao,null);return}let n=xi(o);n&&!t.current?t.current=n:(t.current&&!n||t.current&&n!==t.current)&&(e.updateEditorAtom(ao,null),t.current=null)},[o,e]),Ka(()=>()=>{Za.clear(),$a.clear()},[]),Xu(tA,{app:e,elements:o})},tA=({app:e,elements:o})=>{let t=xi(o),n=Ty(()=>t==="generic"?Ly(o):[],[t,o]),r=Ty(()=>t==="linear"?Vu(o):[],[t,o]),i=t==="generic"?n.every(c=>c.type===n[0].type):t==="linear"?r.every(c=>fi(c)===fi(r[0])):!1,[a,l]=SL({x:0,y:0}),s=Yu(""),m=Yu(null);Ka(()=>{let c=[...n,...r].sort((x,y)=>x.id.localeCompare(y.id)),p=`
|
|
8
|
+
${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${c.map(x=>x.id).join(",")}`;if(p===s.current)return;s.current=p;let u;if(c.length===1){let[x,,,y,E,w]=NL(c[0],e.scene.getNonDeletedElementsMap());u=ML(wc(x,y),wc(E,w),c[0].angle)}else{let{minX:x,maxY:y}=RL(c);u=wc(x,y)}let{x:f,y:b}=Dy({sceneX:u[0],sceneY:u[1]},e.state);l({x:f,y:b})},[n,r,e.scene,e.state]),Ka(()=>{for(let c of r){let p=Wu(c.id,aA(c));$a.has(p)||$a.set(p,c)}},[r]),Ka(()=>{for(let c of n)if(!Za.has(c.id)){let p=My(c,e.scene.getNonDeletedElementsMap());p&&Za.set(c.id,{fontSize:p.fontSize})}},[n,e.scene]);let d=t==="linear"?[["line",rs],["sharpArrow",Fr],["curvedArrow",zr],["elbowArrow",Or]]:t==="generic"?[["rectangle",ts],["diamond",os],["ellipse",ns]]:[];return Xu("div",{ref:m,tabIndex:-1,style:{position:"absolute",top:`${a.y+(qL+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-jL}px`,zIndex:2},className:GL.CONVERT_ELEMENT_TYPE_POPUP,children:d.map(([c,p])=>{let u=i&&(t==="generic"&&n[0].type===c||t==="linear"&&fi(r[0])===c);return Xu(Z,{className:"Shape",type:"radio",icon:p,checked:u,name:"convertElementType-option",title:c,keyBindingLabel:"","aria-label":c,"data-testid":`toolbar-${c}`,onChange:()=>{e.state.activeTool.type!==c&&re("convertElementType",c,"ui"),Zu(e,{conversionType:t,nextType:c}),m.current?.focus()}},`${o[0].id}${o[0].version}_${c}`)})})},oA=(e,o,t)=>{let n=FL(e,o),r=BL(e,o),i=zL(o.text,Hu(o),n),a=Cy(i,Hu(o),o.lineHeight),l=o.fontSize;for(;(a.width>n||a.height>r)&&l>0;){l-=1;let s={...o,fontSize:l};a=Cy(o.text,Hu(s),o.lineHeight)}Ic(o,t.getNonDeletedElementsMap(),{fontSize:l,width:a.width,height:a.height}),OL(o,e,t)},Zu=(e,{conversionType:o,nextType:t,direction:n="right"})=>{if(!o)return!1;let r=e.scene.getSelectedElements(e.state),i=r.reduce((l,s)=>({...l,[s.id]:!0}),{}),a=n==="right"?1:-1;if(o==="generic"){let l=Ly(r),m=l.every(d=>d.type===l[0].type)?Va.indexOf(l[0].type):-1;if(t=t??Va[(m+Va.length+a)%Va.length],t&&bi(t)){let d={};for(let p of l){let u=ky(p,t,e);d[u.id]=u}let c=[];for(let p of e.scene.getElementsIncludingDeleted())d[p.id]?c.push(d[p.id]):c.push(p);e.scene.replaceAllElements(c);for(let p of Object.values(d)){let u=My(p,e.scene.getNonDeletedElementsMap());u&&(Za.get(p.id)&&Ic(u,e.scene.getNonDeletedElementsMap(),{fontSize:Za.get(p.id)?.fontSize??u.fontSize}),oA(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:Iy(p,{type:"selection"})}))}}if(o==="linear"){let l=Vu(r);if(!t){let m=WL(l,fi),d=m?Xa.indexOf(m):-1;t=Xa[(d+Xa.length+a)%Xa.length]}if(Tc(t)){let m=[],d=e.scene.getElementsMapIncludingDeleted();for(let c of l){let p=$a.get(Wu(c.id,t));if(p&&fi(p)===t)d.set(p.id,p),m.push(p);else{let u=ky(c,t,e);d.set(u.id,u),m.push(u)}}e.scene.replaceAllElements(d);for(let c of m)if(Ku(c))if(DL(c)){let p=nA(c);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=kL(c,e.scene.getNonDeletedElementsMap(),{points:p,fixedSegments:u});Ic(c,e.scene.getNonDeletedElementsMap(),{...f,endArrowhead:"arrow"})}else{let p=YL(["line","sharpArrow","curvedArrow"],u=>$a.get(Wu(c.id,u)));if(p){let u=p.points;e.scene.mutateElement(c,{points:u})}}}let s=Vu(e.scene.getSelectedElements(e.state));e.setState(m=>({selectedElementIds:i,selectedLinearElement:s.length===1?new VL(s[0],e.scene.getNonDeletedElementsMap()):null,activeTool:Iy(m,{type:"selection"})}))}return!0},xi=e=>{if(e.length===0)return null;let o=!1;for(let t of e){if(bi(t.type))return"generic";Py(t)&&(o=!0)}return o?"linear":null},Py=e=>Ku(e)&&(!AL(e)||!LL(e)&&!PL(e)),Wu=(e,o)=>`${e}:${o}`,Ly=e=>e.filter(o=>bi(o.type)),Vu=e=>e.filter(o=>Py(o)),yc=20,hi=(e,o)=>e[0]===o[0],Uu=(e,o)=>e[1]===o[1],Sy=(e,o)=>hi(e,o)?Math.abs(e[1]-o[1]):Math.abs(e[0]-o[0]),nA=e=>{let o=[e.points[0]],t=rA(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])<yc?l[0]=a[0]:Math.abs(l[1]-a[1])<yc&&(l[1]=a[1]),hi(a,l)||Uu(a,l)||o.push(wc(a[0],l[1])),o.push(l)}let n=[o[0]];for(let i=1;i<o.length-1;++i)hi(o[i-1],o[i])&&hi(o[i],o[i+1])||Uu(o[i-1],o[i])&&Uu(o[i],o[i+1])||n.push(o[i]);n.push(o[o.length-1]);let r=[n[0]];for(let i=1;i<n.length-1;++i){let a=r[r.length-1],l=n[i],s=n[i+1],m=hi(a,l),d=hi(l,s);if(m!==d){let c=Sy(a,l),p=Sy(l,s);if(c<yc||p<yc){if(p<c)m?s[0]=a[0]:s[1]=a[1];else if(d)for(let u=r.length-1;u>=0&&r[u][0]===a[0];--u)r[u][0]=l[0];else for(let u=r.length-1;u>=0&&r[u][1]===a[1];--u)r[u][1]=l[1];continue}}r.push(l)}return r.push(n[n.length-1]),r},rA=e=>{if(e.length===0)return[];let o=[e[0]];for(let t=1;t<e.length;t++){let[n,r]=o[o.length-1],[i,a]=e[t];(n!==i||r!==a)&&o.push(e[t])}return o},ky=(e,o,t)=>{if(!iA(e.type,o)){if(!UL())throw Error(`Invalid conversion from ${e.type} to ${o}.`);return e}if(e.type===o)return e;if(ZL.delete(e),bi(o)){let n=gi(XL({...e,type:o,roundness:o==="diamond"&&e.roundness?{type:_L(o)?vc.ADAPTIVE_RADIUS:vc.PROPORTIONAL_RADIUS}:e.roundness}));return $L(n,t.scene),n}if(Tc(o))switch(o){case"line":return gi(KL({...e,type:"line"}));case"sharpArrow":return gi(Gu({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return gi(Gu({...e,type:"arrow",elbowed:!1,roundness:{type:vc.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return gi(Gu({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return HL(o,`unhandled conversion type: ${o}`),e},iA=(e,o)=>!!(bi(e)&&bi(o)||Tc(e)&&Tc(o)),aA=e=>Ku(e)?fi(e):e.type,Ay=eA;var _y=N({name:"toggleShapeSwitch",label:"labels.shapeSwitch",icon:()=>null,viewMode:!0,trackEvent:{category:"shape_switch",action:"toggle"},keywords:["change","switch","swap"],perform(e,o,t,n){return Ue.set(ao,{type:"panel"}),{captureUpdate:lA.NEVER}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>xi(e)!==null});import{canCreateLinkFromElements as $u,defaultGetElementLinkFromSelection as sA,getLinkIdAndTypeFromSelection as cA}from"@excalidraw/element";import{CaptureUpdateAction as ja}from"@excalidraw/element";var Cc=N({name:"copyElementLink",label:"labels.copyElementLink",icon:Rr,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r=j(e,o);try{if(window.location){let i=cA(r,o);return i?(await ro(n.props.generateLinkForSelection?n.props.generateLinkForSelection(i.id,i.type):sA(i.id,i.type)),{appState:{toast:{message:g("toast.elementLinkCopied"),closable:!0}},captureUpdate:ja.EVENTUALLY}):{appState:o,elements:e,app:n,captureUpdate:ja.EVENTUALLY}}}catch(i){console.error(i)}return{appState:o,elements:e,app:n,captureUpdate:ja.EVENTUALLY}},predicate:(e,o)=>$u(j(e,o))}),Ry=N({name:"linkToElement",label:"labels.linkToElement",icon:bs,perform:(e,o,t,n)=>{let r=j(e,o);return r.length!==1||!$u(r)?{elements:e,appState:o,app:n,captureUpdate:ja.EVENTUALLY}:{appState:{...o,openDialog:{name:"elementLinkSelector",sourceElementId:j(e,o)[0].id}},captureUpdate:ja.IMMEDIATELY}},predicate:(e,o,t,n)=>{let r=j(e,o);return o.openDialog?.name!=="elementLinkSelector"&&r.length===1&&$u(r)},trackEvent:!1});import{isDarwin as Ny,getShortcutKey as ne}from"@excalidraw/common";var dA={toggleTheme:[ne("Shift+Alt+D")],saveScene:[ne("CtrlOrCmd+S")],loadScene:[ne("CtrlOrCmd+O")],clearCanvas:[ne("CtrlOrCmd+Delete")],imageExport:[ne("CtrlOrCmd+Shift+E")],commandPalette:[ne("CtrlOrCmd+/"),ne("CtrlOrCmd+Shift+P")],cut:[ne("CtrlOrCmd+X")],copy:[ne("CtrlOrCmd+C")],paste:[ne("CtrlOrCmd+V")],copyStyles:[ne("CtrlOrCmd+Alt+C")],pasteStyles:[ne("CtrlOrCmd+Alt+V")],selectAll:[ne("CtrlOrCmd+A")],deleteSelectedElements:[ne("Delete")],duplicateSelection:[ne("CtrlOrCmd+D"),ne(`Alt+${g("helpDialog.drag")}`)],sendBackward:[ne("CtrlOrCmd+[")],bringForward:[ne("CtrlOrCmd+]")],sendToBack:[Ny?ne("CtrlOrCmd+Alt+["):ne("CtrlOrCmd+Shift+[")],bringToFront:[Ny?ne("CtrlOrCmd+Alt+]"):ne("CtrlOrCmd+Shift+]")],copyAsPng:[ne("Shift+Alt+C")],group:[ne("CtrlOrCmd+G")],ungroup:[ne("CtrlOrCmd+Shift+G")],gridMode:[ne("CtrlOrCmd+'")],zenMode:[ne("Alt+Z")],objectsSnapMode:[ne("Alt+S")],stats:[ne("Alt+/")],addToLibrary:[],flipHorizontal:[ne("Shift+H")],flipVertical:[ne("Shift+V")],viewMode:[ne("Alt+R")],hyperlink:[ne("CtrlOrCmd+K")],toggleElementLock:[ne("CtrlOrCmd+Shift+L")],resetZoom:[ne("CtrlOrCmd+0")],zoomOut:[ne("CtrlOrCmd+-")],zoomIn:[ne("CtrlOrCmd++")],zoomToFitSelection:[ne("Shift+3")],zoomToFit:[ne("Shift+1")],zoomToFitSelectionInViewport:[ne("Shift+2")],toggleEraserTool:[ne("E")],toggleHandTool:[ne("H")],setFrameAsActiveTool:[ne("F")],saveFileToDisk:[ne("CtrlOrCmd+S")],saveToActiveFile:[ne("CtrlOrCmd+S")],toggleShortcuts:[ne("?")],searchMenu:[ne("CtrlOrCmd+F")],wrapSelectionInFrame:[]},Fe=(e,o=0)=>{let t=dA[e];return t&&t.length>0?t[o]||t[0]:""};var mA="\\u0300-\\u036f",pA="\\ufe20-\\ufe2f",uA="\\u20d0-\\u20ff",hA=mA+pA+uA,gA=`[${hA}]`,fA=RegExp(gA,"g"),bA=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,xA={\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"},ju=e=>e.replace(bA,o=>xA[o]||o).replace(fA,"");import l7 from"clsx";import{useEffect as s7,useState as c7}from"react";import{KEYS as d7,queryFocusableElements as _2}from"@excalidraw/common";import{useCallback as EA,useState as yA}from"react";var By=()=>{let[e,o]=yA(null),t=EA(n=>o(n),[]);return[e,t]};import{useState as k2,useCallback as ph,useMemo as M2,useEffect as I2,memo as P2,useRef as j8}from"react";import{LIBRARY_DISABLED_TYPES as q8,randomId as J8,isShallowEqual as Q8}from"@excalidraw/common";import{useEffect as Hy,useRef as Gy}from"react";import{URL_HASH_KEYS as Qu,URL_QUERY_KEYS as eh,APP_NAME as Uy,EVENT as kc,DEFAULT_SIDEBAR as CA,LIBRARY_SIDEBAR_TAB as SA,arrayToMap as th,cloneJSON as kA,preventUnload as MA,promiseTry as Yy,resolvablePromise as PA,toValidURL as LA,Queue as AA,Emitter as DA}from"@excalidraw/common";import{hashElementsVersion as _A,hashString as RA}from"@excalidraw/element";import{getCommonBoundingBox as Ju}from"@excalidraw/element";import{MIME_TYPES as ir}from"@excalidraw/common";var gn=({elements:e,appState:o,files:t,maxWidthOrHeight:n,getDimensions:r,exportPadding:i,exportingFrame:a})=>{let{elements:l,appState:s}=Sr({elements:e,appState:o},null,null,{deleteInvisibleElements:!0}),{exportBackground:m,viewBackgroundColor:d}=s;return Kl(l,{...s,offsetTop:0,offsetLeft:0,width:0,height:0},t||{},{exportBackground:m,exportPadding:i,viewBackgroundColor:d,exportingFrame:a},(c,p)=>{let u=document.createElement("canvas");if(n){typeof r=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let b=Math.max(c,p),x=n<b?n/b:o?.exportScale??1;return u.width=c*x,u.height=p*x,{canvas:u,scale:x}}let f=r?.(c,p)||{width:c,height:p};return u.width=f.width,u.height=f.height,{canvas:u,scale:f.scale??1}})},Fy=async e=>{let{mimeType:o=ir.png,quality:t}=e;o===ir.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${ir.png}" mimeType`),o==="image/jpg"&&(o=ir.jpg),o===ir.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${ir.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let n=await gn(e);return t=t||(/image\/jpe?g/.test(o)?.92:.8),new Promise((r,i)=>{n.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&o===ir.png&&e.appState?.exportEmbedScene&&(a=await M1({blob:a,metadata:ta(e.elements,e.appState,e.files||{},"local")})),r(a)},o,t)})},Ei=async({elements:e,appState:o=Qo(),files:t={},exportPadding:n,renderEmbeddables:r,exportingFrame:i,skipInliningFonts:a,reuseImages:l})=>{let{elements:s,appState:m}=Sr({elements:e,appState:o},null,null,{deleteInvisibleElements:!0}),d={...m,exportPadding:n};return Cr(s,d,t,{exportingFrame:i,renderEmbeddables:r,skipInliningFonts:a,reuseImages:l})},wA=async e=>{if(e.type==="svg"){let o=await Ei(e);await ro(o.outerHTML)}else if(e.type==="png")await nc(Fy(e));else if(e.type==="json")await oc(e.elements,e.files);else throw new Error("Invalid export type")};import{useEffect as vA,useState as TA}from"react";import{COLOR_PALETTE as IA}from"@excalidraw/common";var qu=he(new Map),Oy=async e=>await Ei({elements:e,appState:{exportBackground:!1,viewBackgroundColor:IA.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),zy=(e,o,t)=>{let[n,r]=TA();return vA(()=>{if(o)if(e){let i=t.get(e);i?r(i):(async()=>{let a=await Oy(o);a.querySelector(".style-fonts")?.remove(),a&&(t.set(e,a),r(a))})()}else(async()=>{let i=await Oy(o);r(i)})()},[e,o,t,r]),n},Sc=()=>{let[e]=le(qu);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:n=>{n.forEach(r=>e.delete(r))},svgCache:e}};var NA=["excalidraw.com","raw.githubusercontent.com/excalidraw/excalidraw-libraries"],Vy=new DA,ar=he({status:"loaded",isInitialized:!1,libraryItems:[]}),qa=e=>kA(e),BA=(e,o)=>!e.find(t=>t.elements.length!==o.elements.length?!1:t.elements.every((n,r)=>n.id===o.elements[r].id&&n.versionNonce===o.elements[r].versionNonce)),Xy=(e,o)=>{let t=[];for(let n of o)BA(e,n)&&t.push(n);return[...t,...e]},Ky=(e,o)=>{let t=th(o),n={deletedItems:new Map,addedItems:new Map};for(let i of e)t.has(i.id)||n.deletedItems.set(i.id,i);let r=th(e);for(let i of o)r.has(i.id)||n.addedItems.set(i.id,i);return n},oh=class{constructor(o){I(this,"currLibraryItems",[]);I(this,"prevLibraryItems",qa(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)Ue.set(ar,o=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:o.isInitialized}));else{Ue.set(ar,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let o=this.prevLibraryItems;this.prevLibraryItems=qa(this.currLibraryItems);let t=qa(this.currLibraryItems);this.app.props.onLibraryChange?.(t),Vy.trigger(Ky(o,t),t)}catch(o){console.error(o)}}});I(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],Ue.set(qu,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(qa(t))}catch{return o(this.currLibraryItems)}}));I(this,"updateLibrary",async({libraryItems:o,prompt:t=!1,merge:n=!1,openLibraryMenu:r=!1,defaultStatus:i="unpublished"})=>(r&&this.app.setState({openSidebar:{name:CA.name,tab:SA}}),this.setLibrary(()=>new Promise(async(a,l)=>{try{let s=await(typeof o=="function"&&!(o instanceof Blob)?o(this.currLibraryItems):o),m;s instanceof Blob?m=await _m(s,i):m=ra(s,i),!t||window.confirm(g("alerts.confirmAddLibrary",{numShapes:m.length}))?(t&&this.app.focusContainer(),a(n?Xy(this.currLibraryItems,m):m)):l(new Tr)}catch(s){l(s)}}))));I(this,"setLibrary",o=>{let t=new Promise(async(n,r)=>{try{await this.getLastUpdateTask(),typeof o=="function"&&(o=o(this.currLibraryItems)),this.currLibraryItems=qa(await o),n(this.currLibraryItems)}catch(i){r(i)}}).catch(n=>{if(n.name==="AbortError")return console.warn("Library update aborted by user"),this.currLibraryItems;throw n}).finally(()=>{this.updateQueue=this.updateQueue.filter(n=>n!==t),this.notifyListeners()});return this.updateQueue.push(t),this.notifyListeners(),t});this.app=o}},Zy=oh,Lc=e=>{let t=Math.ceil(Math.sqrt(e.length)),n=[],r=u=>e.slice(u*t,u*t+t).reduce((b,x)=>{let{height:y}=Ju(x.elements);return Math.max(b,y)},0),i=u=>{let f=0,b=0,x=0;for(let y of e){if(f%t===0&&(b=0),b===u){let{width:E}=Ju(y.elements);x=Math.max(x,E)}f++,b++}return x},a=0,l=0,s=0,m=0,d=0,c=0,p=0;for(let u of e){d&&d%t===0&&(l+=s+50,a=0,c=0,p++),c===0&&(s=r(p)),m=i(c);let{minX:f,minY:b,width:x,height:y}=Ju(u.elements),E=(m-x)/2,w=(s-y)/2;n.push(...u.elements.map(v=>({...v,x:v.x+a+E-f,y:v.y+l+w-b}))),a+=m+50,d++,c++}return n},FA=(e,o=NA)=>{if(typeof o=="function"?o(e):o.some(t=>{let n=new URL(`https://${t.replace(/^https?:\/\//,"")}`),{hostname:r,pathname:i}=new URL(e);return new RegExp(`(^|\\.)${n.hostname}$`).test(r)&&new RegExp(`^${n.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(Qu.addLibrary)||new URLSearchParams(window.location.search).get(eh.addLibrary),o=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:o}:null},fn=class fn{constructor(o){I(this,"adapter");this.adapter=o}static async getLibraryItems(o,t,n=!0){let r=()=>new Promise(async(i,a)=>{try{let l=await o.load({source:t});i(ra(l?.libraryItems||[],"published"))}catch(l){a(l)}});return n?fn.queue.push(r):r()}getLibraryItems(o){return fn.getLibraryItems(this.adapter,o,!1)}};I(fn,"queue",new AA),I(fn,"run",async(o,t)=>{let n=new fn(o);return fn.queue.push(()=>t(n))});var yi=fn,Ja=0,Mc=0,Pc=e=>RA(e.map(o=>`${o.id}:${_A(o.elements)}`).sort().join()),Wy=async(e,o)=>{try{return Mc++,await yi.run(e,async t=>{let n=th(await t.getLibraryItems("save"));for(let[l]of o.deletedItems)n.delete(l);let r=[];for(let[l,s]of o.addedItems)n.has(l)?n.set(l,s):r.push(s);let i=r.concat(Array.from(n.values())),a=Pc(i);return a!==Ja&&await e.save({libraryItems:i}),Ja=a,i})}finally{Mc--}},OA=e=>{let{excalidrawAPI:o}=e,t=Gy(e);t.current=e;let n=Gy(!1);Hy(()=>{if(!o)return;n.current=!1;let r=async({libraryUrl:l,idToken:s})=>{let m=new Promise(async(c,p)=>{try{l=decodeURIComponent(l),l=LA(l),FA(l,t.current.validateLibraryUrl);let f=await(await fetch(l)).blob();c(f)}catch(u){p(u)}}),d=s!==o.id;await(d&&document.hidden?new Promise(c=>{window.addEventListener("focus",()=>c(),{once:!0})}):null);try{await o.updateLibrary({libraryItems:m,prompt:d,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(c){throw o.updateScene({appState:{errorMessage:c.message}}),c}finally{if(window.location.hash.includes(Qu.addLibrary)){let c=new URLSearchParams(window.location.hash.slice(1));c.delete(Qu.addLibrary),window.history.replaceState({},Uy,`#${c.toString()}`)}else if(window.location.search.includes(eh.addLibrary)){let c=new URLSearchParams(window.location.search);c.delete(eh.addLibrary),window.history.replaceState({},Uy,`?${c.toString()}`)}}},i=l=>{l.preventDefault();let s=nh();s&&(l.stopImmediatePropagation(),window.history.replaceState({},"",l.oldURL),r(s))},a=nh();if(a&&r(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,m=PA();s?m.resolve(Yy(s.load).then(async d=>{let c=null;try{if(!d)return yi.getLibraryItems(l,"load");c=ra(d.libraryItems||[],"published");let p=await Wy(l,Ky([],c));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}`),c}}).catch(d=>(console.error(`error during library migration: ${d.message}`),yi.getLibraryItems(l,"load")))):m.resolve(Yy(yi.getLibraryItems,l,"load")),o.updateLibrary({libraryItems:m.then(d=>{let c=d||[];return Ja=Pc(c),c}),merge:!0}).finally(()=>{n.current=!0})}return window.addEventListener(kc.HASHCHANGE,i),()=>{window.removeEventListener(kc.HASHCHANGE,i)}},[o]),Hy(()=>{let r=Vy.on(async(a,l)=>{let s=n.current,m="adapter"in t.current&&t.current.adapter||null;try{m&&Ja!==Pc(l)&&await Wy(m,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=>{Mc&&MA(a)};return window.addEventListener(kc.BEFORE_UNLOAD,i),()=>{window.removeEventListener(kc.BEFORE_UNLOAD,i),r(),Ja=0,Mc=0}},[])};import UA from"clsx";import{VERSIONS as zA}from"@excalidraw/common";import{jsx as GA}from"react/jsx-runtime";var HA=({theme:e,id:o,libraryReturnUrl:t})=>{let n=t||window.location.origin+window.location.pathname;return GA("a",{className:"library-menu-browse-button",href:`${T.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${n}&useHash=true&token=${o}&theme=${e}&version=${zA.excalidrawLibrary}`,target:"_excalidraw_libraries",children:g("labels.libraries")})},$y=HA;import{jsx as YA,jsxs as WA}from"react/jsx-runtime";var Ac=({libraryReturnUrl:e,theme:o,id:t,style:n,children:r,className:i})=>WA("div",{className:UA("library-menu-control-buttons",i),style:n,children:[YA($y,{id:t,libraryReturnUrl:e,theme:o}),r]});import{useCallback as Ti,useEffect as U8,useMemo as v2,useRef as Y8,useState as W8}from"react";import{MIME_TYPES as V8,arrayToMap as X8}from"@excalidraw/common";import{duplicateElements as K8}from"@excalidraw/element";import VA from"lodash.throttle";import{useEffect as XA}from"react";var KA=he(0),jy=e=>{let[o,t]=le(KA);return XA(()=>{let{current:n}=e;if(!n)return;let r=VA(()=>{let{scrollTop:i}=n;t(i)},200);return n.addEventListener("scroll",r),()=>{r.cancel(),n.removeEventListener("scroll",r)}},[e,t]),o};import C8 from"clsx";import{useCallback as S8,useState as lh}from"react";import{muteFSAbortError as k8}from"@excalidraw/common";import{flushSync as qy}from"react-dom";import ZA from"clsx";import{jsx as Dc,jsxs as jA}from"react/jsx-runtime";var $A=({label:e,onClick:o,className:t,children:n,actionType:r,type:i="button",isLoading:a,...l})=>{let s=r?`Dialog__action-button--${r}`:"";return jA("button",{className:ZA("Dialog__action-button",s,t),type:i,"aria-label":e,onClick:o,...l,children:[n&&Dc("div",{style:a?{visibility:"hidden"}:{},children:n}),Dc("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&Dc("div",{style:{position:"absolute",inset:0},children:Dc(tt,{})})]})},Ho=$A;import{jsx as Jy,jsxs as Qy}from"react/jsx-runtime";var qA=e=>{let{onConfirm:o,onCancel:t,children:n,confirmText:r=g("buttons.confirm"),cancelText:i=g("buttons.cancel"),className:a="",...l}=e,s=ae(),m=en(wi),{container:d}=Ne();return Qy(Oe,{onCloseRequest:t,size:"small",...l,className:`confirm-dialog ${a}`,children:[n,Qy("div",{className:"confirm-dialog-buttons",children:[Jy(Ho,{label:i,onClick:()=>{s({openMenu:null}),m(!1),qy(()=>{t()}),d?.focus()}}),Jy(Ho,{label:r,onClick:()=>{s({openMenu:null}),m(!1),qy(()=>{o()}),d?.focus()},actionType:"danger"})]})]})},_c=qA;import Nc from"open-color";import{useCallback as r8,useEffect as ah,useRef as e2,useState as rh}from"react";import{EDITOR_LS_KEYS as ih,EXPORT_DATA_TYPES as i8,MIME_TYPES as t2,VERSIONS as a8,chunk as l8,getExportSource as s8}from"@excalidraw/common";var Wt=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(Wt,"set",(o,t)=>{try{return window.localStorage.setItem(o,JSON.stringify(t)),!0}catch(n){return console.warn(`localStorage.setItem error: ${n.message}`),!1}}),I(Wt,"delete",o=>{try{window.localStorage.removeItem(o)}catch(t){console.warn(`localStorage.removeItem error: ${t.message}`)}});import Rc from"react";var JA=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,QA=/{{([\w-]+)}}/,e8=/<([\w-]+)>/,t8=/<\/([\w-]+)>/,o8=(e,o)=>{let t=[{name:"",children:[]}];return e.split(JA).filter(Boolean).forEach(n=>{let r=n.match(e8),i=n.match(t8),a=n.match(QA);if(r!==null){let l=r[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(),m=Rc.createElement(Rc.Fragment,{},...s.children),d=o[s.name];typeof d=="function"&&t[t.length-1].children.push(d(m))}else console.warn(`Trans: unexpected end tag ${n} 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(n)}),t.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),t[0].children},n8=({i18nKey:e,children:o,...t})=>{let{t:n}=Ge();return Rc.createElement(Rc.Fragment,{},...o8(n(e),t))},ft=n8;import{jsx as se,jsxs as lt}from"react/jsx-runtime";var c8=async e=>{let n=Math.round(8),r=Math.max(Math.round(128/64),2),i=l8(e,6),a=document.createElement("canvas");a.width=i[0].length*128+(i[0].length+1)*(n*2)-n*2,a.height=i.length*128+(i.length+1)*(n*2)-n*2;let l=a.getContext("2d");l.fillStyle=Nc.white,l.fillRect(0,0,a.width,a.height);for(let[s,m]of e.entries()){let d=await gn({elements:m.elements,files:null,maxWidthOrHeight:128}),{width:c,height:p}=d,u=Math.floor(s/6)*(128+n*2),f=s%6*(128+n*2);l.drawImage(d,f+(128-c)/2+n,u+(128-p)/2+n),l.lineWidth=r,l.strokeStyle=Nc.gray[4],l.strokeRect(f+n/2,u+n/2,128+n,128+n)}return await jl(new File([await Ao(a)],"preview",{type:t2.png}),{outputType:t2.jpg,maxWidthOrHeight:5e3})},d8=({libItem:e,appState:o,index:t,onChange:n,onRemove:r})=>{let i=e2(null),a=e2(null);return ah(()=>{let l=i.current;l&&(async()=>{let s=await Ei({elements:e.elements,appState:{...o,viewBackgroundColor:Nc.white,exportBackground:!0},files:null,skipInliningFonts:!0});l.innerHTML=s.outerHTML})()},[e.elements,o]),lt("div",{className:"single-library-item",children:[e.status==="published"&&se("span",{className:"single-library-item-status",children:g("labels.statusPublished")}),se("div",{ref:i,className:"single-library-item__svg"}),se(Z,{"aria-label":g("buttons.remove"),type:"button",icon:zt,className:"single-library-item--remove",onClick:r.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:[se("span",{style:{fontWeight:500,color:Nc.gray[6]},children:g("publishDialog.itemName")}),se("span",{"aria-hidden":"true",className:"required",children:"*"})]}),se("input",{type:"text",ref:a,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:l=>{n(l.target.value,t)}})]}),se("span",{className:"error",children:e.error})]})]})},m8=({onClose:e,libraryItems:o,appState:t,onSuccess:n,onError:r,updateItemsInStorage:i,onRemove:a})=>{let[l,s]=rh({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[m,d]=rh(!1);ah(()=>{let w=Wt.get(ih.PUBLISH_LIBRARY);w&&s(w)},[]);let[c,p]=rh(o.slice());ah(()=>{p(o.slice())},[o]);let u=w=>{s({...l,[w.target.name]:w.target.value})},f=async w=>{w.preventDefault(),d(!0);let v=[],C=!1;if(c.forEach(A=>{let F="";A.name||(F=g("publishDialog.errors.required"),C=!0),v.push({...A,error:F})}),C){p(v),d(!1);return}let S=await c8(c),L={type:i8.excalidrawLibrary,version:a8.excalidrawLibrary,source:s8(),libraryItems:c},P=JSON.stringify(L,null,2),B=new Blob([P],{type:"application/json"}),k=new FormData;k.append("excalidrawLib",B),k.append("previewImage",S),k.append("previewImageType",S.type),k.append("title",l.name),k.append("authorName",l.authorName),k.append("githubHandle",l.githubHandle),k.append("name",l.name),k.append("description",l.description),k.append("twitterHandle",l.twitterHandle),k.append("website",l.website),fetch(`${T.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:k}).then(A=>A.ok?A.json().then(({url:F})=>{Wt.delete(ih.PUBLISH_LIBRARY),n({url:F,authorName:l.authorName,items:c})}):A.json().catch(()=>{throw new Error(A.statusText||"something went wrong")}).then(F=>{throw new Error(F.message||A.statusText||"something went wrong")}),A=>{console.error(A),r(A),d(!1)}).catch(A=>{console.error(A),r(A),d(!1)})},b=()=>{let w=[];return c.forEach((v,C)=>{w.push(se("div",{className:"single-library-item-wrapper",children:se(d8,{libItem:v,appState:t,index:C,onChange:(S,L)=>{let P=c.slice();P[L].name=S,p(P)},onRemove:a})},C))}),se("div",{className:"selected-library-items",children:w})},x=r8(()=>{i(c),Wt.set(ih.PUBLISH_LIBRARY,l),e()},[c,e,i,l]),y=!!o.length,E=o.some(w=>w.status==="published");return se(Oe,{onCloseRequest:x,title:g("publishDialog.title"),className:"publish-library",children:y?lt("form",{onSubmit:f,children:[se("div",{className:"publish-library-note",children:se(ft,{i18nKey:"publishDialog.noteDescription",link:w=>se("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener",children:w})})}),se("span",{className:"publish-library-note",children:se(ft,{i18nKey:"publishDialog.noteGuidelines",link:w=>se("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:w})})}),se("div",{className:"publish-library-note",children:g("publishDialog.noteItems")}),E&&se("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:[se("span",{children:g("publishDialog.libraryName")}),se("span",{"aria-hidden":"true",className:"required",children:"*"})]}),se("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:[se("span",{children:g("publishDialog.libraryDesc")}),se("span",{"aria-hidden":"true",className:"required",children:"*"})]}),se("textarea",{name:"description",rows:4,required:!0,value:l.description,onChange:u,placeholder:g("publishDialog.placeholder.libraryDesc")})]}),lt("label",{children:[lt("div",{children:[se("span",{children:g("publishDialog.authorName")}),se("span",{"aria-hidden":"true",className:"required",children:"*"})]}),se("input",{type:"text",name:"authorName",required:!0,value:l.authorName,onChange:u,placeholder:g("publishDialog.placeholder.authorName")})]}),lt("label",{children:[se("span",{children:g("publishDialog.githubUsername")}),se("input",{type:"text",name:"githubHandle",value:l.githubHandle,onChange:u,placeholder:g("publishDialog.placeholder.githubHandle")})]}),lt("label",{children:[se("span",{children:g("publishDialog.twitterUsername")}),se("input",{type:"text",name:"twitterHandle",value:l.twitterHandle,onChange:u,placeholder:g("publishDialog.placeholder.twitterHandle")})]}),lt("label",{children:[se("span",{children:g("publishDialog.website")}),se("input",{type:"text",name:"website",pattern:"https?://.+",title:g("publishDialog.errors.website"),value:l.website,onChange:u,placeholder:g("publishDialog.placeholder.website")})]}),se("span",{className:"publish-library-note",children:se(ft,{i18nKey:"publishDialog.noteLicense",link:w=>se("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:w})})})]}),lt("div",{className:"publish-library__buttons",children:[se(Ho,{label:g("buttons.cancel"),onClick:x,"data-testid":"cancel-clear-canvas-button"}),se(Ho,{type:"submit",label:g("buttons.submit"),actionType:"primary",isLoading:m})]})]}):se("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:g("publishDialog.atleastOneLibItem")})})},o2=m8;import h8 from"clsx";import{useEffect as g8,useRef as f8}from"react";import{EVENT as a2,KEYS as b8}from"@excalidraw/common";import{forwardRef as n2}from"react";import r2 from"clsx";import{jsx as i2}from"react/jsx-runtime";var p8=n2(({children:e,gap:o,align:t,justifyContent:n,className:r,style:i},a)=>i2("div",{className:r2("Stack Stack_horizontal",r),style:{"--gap":o,alignItems:t,justifyContent:n,...i},ref:a,children:e})),u8=n2(({children:e,gap:o,align:t,justifyContent:n,className:r,style:i},a)=>i2("div",{className:r2("Stack Stack_vertical",r),style:{"--gap":o,justifyItems:t,justifyContent:n,...i},ref:a,children:e})),qe={Row:p8,Col:u8};import{jsx as Bc}from"react/jsx-runtime";var l2=({children:e,onClickOutside:o,className:t="",onSelect:n,style:r})=>{let i=de(),a=f8(null),l=on({onClickOutside:o});Wr(a,()=>{l.onClickOutside?.()}),g8(()=>{let m=c=>{c.key===b8.ESCAPE&&(c.stopImmediatePropagation(),l.onClickOutside?.())},d={capture:!0};return document.addEventListener(a2.KEYDOWN,m,d),()=>{document.removeEventListener(a2.KEYDOWN,m,d)}},[l]);let s=h8(`dropdown-menu ${t}`,{"dropdown-menu--mobile":i.editor.isMobile}).trim();return Bc(Ap.Provider,{value:{onSelect:n},children:Bc("div",{ref:a,className:s,style:r,"data-testid":"dropdown-menu",children:i.editor.isMobile?Bc(qe.Col,{className:"dropdown-menu-container",children:e}):Bc(Ye,{className:"dropdown-menu-container",padding:2,style:{zIndex:2},children:e})})})};l2.displayName="DropdownMenuContent";var s2=l2;import{jsx as E8}from"react/jsx-runtime";var x8=({children:e,className:o="",selected:t,...n})=>E8("div",{...n,className:`dropdown-menu-item-base dropdown-menu-item-custom ${o} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),c2=x8;import{jsx as d2}from"react/jsx-runtime";var m2=({icon:e,shortcut:o,href:t,children:n,onSelect:r,className:i="",selected:a,rel:l="noopener",...s})=>{let m=zs(s.onClick,r);return d2("a",{...s,href:t,target:"_blank",rel:l||"noopener",className:Os(i,a),title:s.title??s["aria-label"],onClick:m,children:d2(Fs,{icon:e,shortcut:o,children:n})})},vi=m2;m2.displayName="DropdownMenuItemLink";import{jsx as y8}from"react/jsx-runtime";var p2=()=>y8("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0"}}),u2=p2;p2.displayName="DropdownMenuSeparator";import w8 from"clsx";import{jsx as v8}from"react/jsx-runtime";var h2=({className:e="",children:o,onToggle:t,title:n,...r})=>{let i=de(),a=w8(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.editor.isMobile}).trim();return v8("button",{"data-prevent-outside-click":!0,className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:n,...r,children:o})},g2=h2;h2.displayName="DropdownMenuTrigger";import Fc from"react";var f2=e=>{let o=Fc.Children.toArray(e).find(t=>Fc.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuTrigger");return o||null},b2=e=>{let o=Fc.Children.toArray(e).find(t=>Fc.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuContent");return o||null};import{Fragment as T8,jsxs as I8}from"react/jsx-runtime";var Go=({children:e,open:o})=>{let t=f2(e),n=b2(e);return I8(T8,{children:[t,o&&n]})};Go.Trigger=g2;Go.Content=s2;Go.Item=pt;Go.ItemLink=vi;Go.ItemCustom=c2;Go.Group=Ta;Go.Separator=u2;var xe=Go;Go.displayName="DropdownMenu";import{jsx as vt,jsxs as Oc}from"react/jsx-runtime";var M8=(e,o)=>e.filter(t=>o.includes(t.id)),P8=({setAppState:e,selectedItems:o,library:t,onRemoveFromLibrary:n,resetLibrary:r,onSelectItems:i,appState:a,className:l})=>{let[s]=le(ar),[m,d]=le(wi),c=()=>{let k=o.length?g("alerts.removeItemsFromsLibrary",{count:o.length}):g("alerts.resetLibrary"),A=o.length?g("confirmDialog.removeItemsFromLib"):g("confirmDialog.resetLibrary");return vt(_c,{onConfirm:()=>{o.length?n():r(),u(!1)},onCancel:()=>{u(!1)},title:A,children:vt("p",{children:k})})},[p,u]=lh(!1),f=!!o.length,b=f?s.libraryItems.filter(k=>o.includes(k.id)):s.libraryItems,x=f?g("buttons.remove"):g("buttons.resetLibrary"),[y,E]=lh(!1),[w,v]=lh(null),C=S8(()=>Oc(Oe,{onCloseRequest:()=>v(null),title:g("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[vt("p",{children:vt(ft,{i18nKey:"publishSuccessDialog.content",authorName:w.authorName,link:k=>vt("a",{href:w?.url,target:"_blank",rel:"noopener noreferrer",children:k})})}),vt(Z,{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,w]),S=(k,A)=>{E(!1),v({url:k.url,authorName:k.authorName});let F=A.slice();F.forEach(Y=>{o.includes(Y.id)&&(Y.status="published")}),t.setLibrary(F)},L=async()=>{try{await t.updateLibrary({libraryItems:Ul({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(k){if(k?.name==="AbortError"){console.warn(k);return}e({errorMessage:g("errors.importLibraryError")})}},P=async()=>{let k=f?b:await t.getLatestLibrary();x1(k).catch(k8).catch(A=>{e({errorMessage:A.message})})},B=()=>Oc(xe,{open:m,children:[vt(xe.Trigger,{onToggle:()=>d(!m),children:V1}),Oc(xe.Content,{onClickOutside:()=>d(!1),onSelect:()=>d(!1),className:"library-menu",children:[!f&&vt(xe.Item,{onSelect:L,icon:_r,"data-testid":"lib-dropdown--load",children:g("buttons.load")}),!!b.length&&vt(xe.Item,{onSelect:P,icon:Xn,"data-testid":"lib-dropdown--export",children:g("buttons.export")}),!!b.length&&vt(xe.Item,{onSelect:()=>u(!0),icon:Mt,children:x}),f&&vt(xe.Item,{icon:ob,onSelect:()=>E(!0),"data-testid":"lib-dropdown--remove",children:g("buttons.publishLibrary")})]})]});return Oc("div",{className:C8("library-menu-dropdown-container",l),children:[B(),o.length>0&&vt("div",{className:"library-actions-counter",children:o.length}),p&&c(),y&&vt(o2,{onClose:()=>E(!1),libraryItems:M8(s.libraryItems,o),appState:a,onSuccess:k=>S(k,s.libraryItems),onError:k=>window.alert(k),updateItemsInStorage:()=>t.setLibrary(s.libraryItems),onRemove:k=>i(o.filter(A=>A!==k))}),w&&C()]})},sh=({selectedItems:e,onSelectItems:o,className:t})=>{let{library:n}=Be(),{clearLibraryCache:r,deleteItemsFromLibraryCache:i}=Sc(),a=be(),l=ae(),[s]=le(ar),m=async c=>{let p=c.filter(u=>!e.includes(u.id));n.setLibrary(p).catch(()=>{l({errorMessage:g("alerts.errorRemovingFromLibrary")})}),i(e),o([])};return vt(P8,{appState:a,setAppState:l,selectedItems:e,onSelectItems:o,library:n,onRemoveFromLibrary:()=>m(s.libraryItems),resetLibrary:()=>{n.resetLibrary(),r()},className:t})};import{memo as O8,useEffect as z8,useState as H8}from"react";import L8,{useCallback as A8}from"react";function D8(){return[!1,A8(o=>o(),[])]}var x2=L8.useTransition||D8;import E2 from"clsx";import{memo as _8,useEffect as R8,useRef as N8,useState as B8}from"react";import{jsx as zc,jsxs as F8}from"react/jsx-runtime";var y2=_8(({id:e,elements:o,isPending:t,onClick:n,selected:r,onToggle:i,onDrag:a,svgCache:l})=>{let s=N8(null),m=zy(e,o,l);R8(()=>{let f=s.current;if(f)return m&&(f.innerHTML=m.outerHTML),()=>{f.innerHTML=""}},[m]);let[d,c]=B8(!1),p=de().editor.isMobile,u=t&&zc("div",{className:"library-unit__adder",children:W1});return F8("div",{className:E2("library-unit",{"library-unit__active":o,"library-unit--hover":o&&d,"library-unit--selected":r,"library-unit--skeleton":!m}),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[zc("div",{className:E2("library-unit__dragger",{"library-unit__pulse":!!t}),ref:s,draggable:!!o,onClick:o||t?f=>{e&&f.shiftKey?i(e,f):n(e)}:void 0,onDragStart:f=>{if(!e){f.preventDefault();return}c(!1),a(e,f)}}),u,e&&o&&(d||p||r)&&zc(Da,{checked:r,onChange:(f,b)=>i(e,b),className:"library-unit__checkbox"})]})}),w2=()=>zc("div",{className:"library-unit library-unit--skeleton"});import{Fragment as G8,jsx as Hc}from"react/jsx-runtime";var ch=({children:e})=>Hc("div",{className:"library-menu-items-container__grid",children:e}),Gc=O8(({items:e,onItemSelectToggle:o,onItemDrag:t,isItemSelected:n,onClick:r,svgCache:i,itemsRenderedPerBatch:a})=>{let[,l]=x2(),[s,m]=H8(0);return z8(()=>{s<e.length&&l(()=>{m(s+a)})},[s,e.length,l,a]),Hc(G8,{children:e.map((d,c)=>c<s?Hc(y2,{elements:d?.elements,isPending:!d?.id&&!!d?.elements,onClick:r,svgCache:i,id:d?.id,selected:n(d.id),onToggle:o,onDrag:t},d?.id??c):Hc(w2,{},c))})});import{Fragment as T2,jsx as Tt,jsxs as Ii}from"react/jsx-runtime";var Z8=17,$8=64;function dh({isLoading:e,libraryItems:o,onAddToLibrary:t,onInsertLibraryItems:n,pendingElements:r,theme:i,id:a,libraryReturnUrl:l,onSelectItems:s,selectedItems:m}){let d=Y8(null),c=jy(d);U8(()=>{c>0&&d.current?.scrollTo(0,c)},[]);let{svgCache:p}=Sc(),u=v2(()=>o.filter(k=>k.status!=="published"),[o]),f=v2(()=>o.filter(k=>k.status==="published"),[o]),b=!o.length&&!r.length,x=!r.length&&!u.length&&!f.length,[y,E]=W8(null),w=Ti((k,A)=>{let F=!m.includes(k),Y=[...u,...f];if(F){if(A.shiftKey&&y){let Q=Y.findIndex(X=>X.id===y),_=Y.findIndex(X=>X.id===k);if(Q===-1||_===-1){s([...m,k]);return}let R=X8(m),W=Y.reduce((X,G,me)=>((me>=Q&&me<=_||R.has(G.id))&&X.push(G.id),X),[]);s(W)}else s([...m,k]);E(k)}else E(null),s(m.filter(Q=>Q!==k))},[y,s,f,m,u]),v=Ti(k=>{let A;return m.includes(k)?A=o.filter(F=>m.includes(F.id)):A=o.filter(F=>F.id===k),A.map(F=>({...F,elements:K8({type:"everything",elements:F.elements,randomizeSeed:!0}).duplicatedElements}))},[o,m]),C=Ti((k,A)=>{let F={itemIds:m.includes(k)?m:[k]};A.dataTransfer.setData(V8.excalidrawlibIds,JSON.stringify(F))},[m]),S=Ti(k=>k?m.includes(k):!1,[m]),L=Ti(()=>{t(r)},[r,t]),P=Ti(k=>{k&&n(v(k))},[v,n]),B=p.size>=o.length?$8:Z8;return Ii("div",{className:"library-menu-items-container",style:r.length||u.length||f.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[!x&&Tt(sh,{selectedItems:m,onSelectItems:s,className:"library-menu-dropdown-container--in-heading"}),Ii(qe.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:[Ii(T2,{children:[!x&&Tt("div",{className:"library-menu-items-container__header",children:g("labels.personalLib")}),e&&Tt("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:Tt(tt,{})}),!r.length&&!u.length?Ii("div",{className:"library-menu-items__no-items",children:[Tt("div",{className:"library-menu-items__no-items__label",children:g("library.noItems")}),Tt("div",{className:"library-menu-items__no-items__hint",children:f.length>0?g("library.hint_emptyPrivateLibrary"):g("library.hint_emptyLibrary")})]}):Ii(ch,{children:[r.length>0&&Tt(Gc,{itemsRenderedPerBatch:B,items:[{id:null,elements:r}],onItemSelectToggle:w,onItemDrag:C,onClick:L,isItemSelected:S,svgCache:p}),Tt(Gc,{itemsRenderedPerBatch:B,items:u,onItemSelectToggle:w,onItemDrag:C,onClick:P,isItemSelected:S,svgCache:p})]})]}),Ii(T2,{children:[(f.length>0||r.length>0||u.length>0)&&Tt("div",{className:"library-menu-items-container__header library-menu-items-container__header--excal",children:g("labels.excalidrawLib")}),f.length>0?Tt(ch,{children:Tt(Gc,{itemsRenderedPerBatch:B,items:f,onItemSelectToggle:w,onItemDrag:C,onClick:P,isItemSelected:S,svgCache:p})}):u.length>0?Tt("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",fontSize:".9rem"},children:g("library.noItems")}):null]}),b&&Tt(Ac,{style:{padding:"16px 0",width:"100%"},id:a,libraryReturnUrl:l,theme:i,children:Tt(sh,{selectedItems:m,onSelectItems:s})})]})]})}import{jsx as bn,jsxs as S2}from"react/jsx-runtime";var wi=he(!1),C2=({children:e})=>bn("div",{className:"layer-ui__library",children:e}),e7=P2(({onInsertLibraryItems:e,pendingElements:o,onAddToLibrary:t,setAppState:n,libraryReturnUrl:r,library:i,id:a,theme:l,selectedItems:s,onSelectItems:m})=>{let[d]=le(ar),c=ph(f=>{(async(x,y)=>{re("element","addToLibrary","ui");for(let w of q8)if(x.some(v=>v.type===w))return n({errorMessage:g(`errors.libraryElementTypeError.${w}`)});let E=[{status:"unpublished",elements:x,id:J8(),created:Date.now()},...y];t(),i.setLibrary(E).catch(()=>{n({errorMessage:g("alerts.errorAddingToLibrary")})})})(f,d.libraryItems)},[t,i,n,d.libraryItems]),p=M2(()=>d.libraryItems,[d]);if(d.status==="loading"&&!d.isInitialized)return bn(C2,{children:bn("div",{className:"layer-ui__library-message",children:S2("div",{children:[bn(tt,{size:"2em"}),bn("span",{children:g("labels.libraryLoadingMessage")})]})})});let u=d.libraryItems.length>0||o.length>0;return S2(C2,{children:[bn(dh,{isLoading:d.status==="loading",libraryItems:p,onAddToLibrary:c,onInsertLibraryItems:e,pendingElements:o,id:a,libraryReturnUrl:r,theme:l,onSelectItems:m,selectedItems:s}),u&&bn(Ac,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:a,libraryReturnUrl:r,theme:l})]})}),mh=(e,o)=>({elements:e,pending:j(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:o}),t7=(e,o)=>{let t=an(),[n,r]=k2(()=>mh(t,e.selectedElementIds)),i=j8(new Map);return I2(()=>{for(let a of n.pending)i.current.set(a.id,a.version)},[n.pending]),I2(()=>{o.state.cursorButton==="up"&&o.state.activeTool.type==="selection"&&r(a=>{if(!Q8(a.selectedElementIds,e.selectedElementIds))return i.current.clear(),mh(t,e.selectedElementIds);let l=o.scene.getNonDeletedElementsMap();for(let s of Object.keys(e.selectedElementIds)){let m=l.get(s)?.version;if(m&&m!==i.current.get(s))return mh(t,e.selectedElementIds)}return a})},[o,o.state.cursorButton,o.state.activeTool.type,e.selectedElementIds,t]),n.pending},L2=P2(()=>{let e=Be(),{onInsertElements:o}=e,t=xo(),n=be(),r=ae(),[i,a]=k2([]),l=M2(()=>e.library,[e.library]),s=t7(n,e),m=ph(c=>{o(Lc(c))},[o]),d=ph(()=>{r({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[r]);return bn(e7,{pendingElements:s,onInsertLibraryItems:m,onAddToLibrary:d,setAppState:r,libraryReturnUrl:t.libraryReturnUrl,library:l,id:e.id,theme:n.theme,selectedItems:i,onSelectItems:a})});import o7 from"clsx";import{useRef as n7}from"react";import{createPortal as r7}from"react-dom";import{KEYS as i7}from"@excalidraw/common";import{jsx as A2,jsxs as a7}from"react/jsx-runtime";var D2=e=>{let{closeOnClickOutside:o=!0}=e,t=Ss({className:"excalidraw-modal-container"}),n=n7(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let r=i=>{i.key===i7.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return r7(a7("div",{className:o7("Modal",e.className,{"animations-disabled":n.current}),role:"dialog","aria-modal":"true",onKeyDown:r,"aria-labelledby":e.labelledBy,"data-prevent-outside-click":!0,children:[A2("div",{className:"Modal__background",onClick:o?e.onCloseRequest:void 0}),A2("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as Qa,jsxs as p7}from"react/jsx-runtime";function m7(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var Oe=e=>{let[o,t]=By(),[n]=c7(document.activeElement),{id:r}=Ne(),i=de().viewport.isMobile;s7(()=>{if(!o)return;let m=_2(o);setTimeout(()=>{m.length>0&&e.autofocus!==!1&&(m[1]||m[0]).focus()});let d=c=>{if(c.key===d7.TAB){let p=_2(o),{activeElement:u}=document,f=p.findIndex(b=>b===u);f===0&&c.shiftKey?(p[p.length-1].focus(),c.preventDefault()):f===p.length-1&&!c.shiftKey&&(p[0].focus(),c.preventDefault())}};return o.addEventListener("keydown",d),()=>o.removeEventListener("keydown",d)},[o,e.autofocus]);let a=ae(),l=en(wi),s=()=>{a({openMenu:null}),l(!1),n.focus(),e.onCloseRequest()};return Qa(D2,{className:l7("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:m7(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,children:p7(Ye,{ref:t,children:[e.title&&Qa("h2",{id:`${r}-dialog-title`,className:"Dialog__title",children:Qa("span",{className:"Dialog__titleContent",children:e.title})}),i&&Qa("button",{className:"Dialog__close",onClick:s,title:g("buttons.close"),"aria-label":g("buttons.close"),type:"button",children:zt}),Qa("div",{className:"Dialog__content",children:e.children})]})})};import uh from"clsx";import{forwardRef as f7,useRef as b7,useImperativeHandle as x7,useLayoutEffect as E7,useState as y7}from"react";import u7 from"clsx";import{composeEventHandlers as h7}from"@excalidraw/common";import{jsx as g7}from"react/jsx-runtime";var Nt=({type:e="button",onSelect:o,selected:t,children:n,className:r="",...i})=>g7("button",{onClick:h7(i.onClick,a=>{o()}),type:e,className:u7("excalidraw-button",r,{selected:t}),...i,children:n});import{jsx as hh,jsxs as R2}from"react/jsx-runtime";var Ci=f7(({onChange:e,label:o,fullWidth:t,placeholder:n,readonly:r,selectOnRender:i,onKeyDown:a,isRedacted:l=!1,icon:s,className:m,...d},c)=>{let p=b7(null);x7(c,()=>p.current),E7(()=>{i&&(p.current?.focus(),p.current?.select())},[i]);let[u,f]=y7(!1);return R2("div",{className:uh("ExcTextField",m,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!s}),onClick:()=>{p.current?.focus()},children:[s,o&&hh("div",{className:"ExcTextField__label",children:o}),R2("div",{className:uh("ExcTextField__input",{"ExcTextField__input--readonly":r}),children:[hh("input",{className:uh({"is-redacted":"value"in d&&d.value&&l&&!u}),readOnly:r,value:"value"in d?d.value:void 0,defaultValue:"defaultValue"in d?d.defaultValue:void 0,placeholder:n,ref:p,onChange:b=>e?.(b.target.value),onKeyDown:a}),l&&hh(Nt,{onSelect:()=>f(!u),style:{border:0,userSelect:"none"},children:u?db:Br})]})]})});import{KEYS as ze}from"@excalidraw/common";var Uc=[{icon:Fm,value:"selection",key:ze.V,numericKey:ze[1],fillable:!0},{icon:ts,value:"rectangle",key:ze.R,numericKey:ze[2],fillable:!0},{icon:os,value:"diamond",key:ze.D,numericKey:ze[3],fillable:!0},{icon:ns,value:"ellipse",key:ze.O,numericKey:ze[4],fillable:!0},{icon:J1,value:"arrow",key:ze.A,numericKey:ze[5],fillable:!0},{icon:rs,value:"line",key:ze.L,numericKey:ze[6],fillable:!0},{icon:tn,value:"freedraw",key:[ze.P,ze.X],numericKey:ze[7],fillable:!1},{icon:Ar,value:"text",key:ze.T,numericKey:ze[8],fillable:!1},{icon:t0,value:"image",key:null,numericKey:ze[9],fillable:!1},{icon:o0,value:"eraser",key:ze.E,numericKey:ze[0],fillable:!1}],gh=e=>e.defaultSelectionTool==="lasso"?[{value:"lasso",icon:Fm,key:ze.V,numericKey:ze[1],fillable:!0},...Uc.slice(1)]:Uc,N2=(e,o)=>gh(o).find((n,r)=>n.numericKey!=null&&e===n.numericKey.toString()||n.key&&(typeof n.key=="string"?n.key===e:n.key.includes(e)))?.value||null;import el from"clsx";import{useState as T7}from"react";import*as To from"@radix-ui/react-popover";import{CLASSES as H2,KEYS as F2,capitalizeString as xh,isTransparent as Yc}from"@excalidraw/common";import{shouldAllowVerticalAlign as G2,suppportsHorizontalAlign as U2}from"@excalidraw/element";import{hasBoundTextElement as Wc,isElbowArrow as Y2,isImageElement as W2,isLinearElement as V2,isTextElement as yh,isArrowElement as O2}from"@excalidraw/element";import{hasStrokeColor as z2,toolIsArrow as Vc}from"@excalidraw/element";import{createIsolation as w7}from"jotai-scope";import fh from"react";import vo from"tunnel-rat";var bh=fh.createContext(null),Ce=()=>fh.useContext(bh),v7=w7(),B2=()=>fh.useMemo(()=>({MainMenuTunnel:vo(),WelcomeScreenMenuHintTunnel:vo(),WelcomeScreenToolbarHintTunnel:vo(),WelcomeScreenHelpHintTunnel:vo(),WelcomeScreenCenterTunnel:vo(),FooterCenterTunnel:vo(),DefaultSidebarTriggerTunnel:vo(),DefaultSidebarTabTriggersTunnel:vo(),OverwriteConfirmDialogTunnel:vo(),TTDDialogTriggerTunnel:vo(),tunnelsJotai:v7}),[]);import{Fragment as Bt,jsx as J,jsxs as ce}from"react/jsx-runtime";var Eh=el([H2.SHAPE_ACTIONS_THEME_SCOPE,"properties-content"]),Xc=(e,o)=>{let t=o[0]?.type||null;for(let n of o)if(n.type!==t){t=null;break}return z2(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||o.some(n=>z2(n.type))},Kc=(e,o)=>go(e.activeTool.type)||o.some(t=>go(t.type)),Zc=({appState:e,elementsMap:o,renderAction:t,app:n})=>{let r=ea(o,e),i=!1;r.length===2&&(Wc(r[0])||Wc(r[1]))&&(i=!0);let a=!!(e.editingTextElement||e.newElement),l=de(),s=document.documentElement.getAttribute("dir")==="rtl",m=go(e.activeTool.type)&&!Yc(e.currentItemBackgroundColor)||r.some(f=>go(f.type)&&!Yc(f.backgroundColor)),d=r.length===1||i,c=!e.selectedLinearElement?.isEditing&&r.length===1&&V2(r[0])&&!Y2(r[0]),p=!e.croppingElementId&&r.length===1&&W2(r[0]),u=!i&>(e,n);return ce("div",{className:"selected-shape-actions",children:[J("div",{children:Xc(e,r)&&t("changeStrokeColor")}),Kc(e,r)&&J("div",{children:t("changeBackgroundColor")}),m&&t("changeFillStyle"),(Un(e.activeTool.type)||r.some(f=>Un(f.type)))&&t("changeStrokeWidth"),(e.activeTool.type==="freedraw"||r.some(f=>f.type==="freedraw"))&&t("changeStrokeShape"),(Yn(e.activeTool.type)||r.some(f=>Yn(f.type)))&&ce(Bt,{children:[t("changeStrokeStyle"),t("changeSloppiness")]}),(Wn(e.activeTool.type)||r.some(f=>Wn(f.type)))&&J(Bt,{children:t("changeRoundness")}),(Vc(e.activeTool.type)||r.some(f=>Vc(f.type)))&&J(Bt,{children:t("changeArrowType")}),(e.activeTool.type==="text"||r.some(yh))&&ce(Bt,{children:[t("changeFontFamily"),t("changeFontSize"),(e.activeTool.type==="text"||U2(r,o))&&t("changeTextAlign")]}),G2(r,o)&&t("changeVerticalAlign"),(vr(e.activeTool.type)||r.some(f=>vr(f.type)))&&J(Bt,{children:t("changeArrowhead")}),t("changeOpacity"),ce("fieldset",{children:[J("legend",{children:g("labels.layers")}),ce("div",{className:"buttonList",children:[t("sendToBack"),t("sendBackward"),t("bringForward"),t("bringToFront")]})]}),u&&!i&&ce("fieldset",{children:[J("legend",{children:g("labels.align")}),ce("div",{className:"buttonList",children:[s?ce(Bt,{children:[t("alignRight"),t("alignHorizontallyCentered"),t("alignLeft")]}):ce(Bt,{children:[t("alignLeft"),t("alignHorizontallyCentered"),t("alignRight")]}),r.length>2&&t("distributeHorizontally"),J("div",{style:{flexBasis:"100%",height:0}}),ce("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[t("alignTop"),t("alignVerticallyCentered"),t("alignBottom"),r.length>2&&t("distributeVertically")]})]})]}),!a&&r.length>0&&ce("fieldset",{children:[J("legend",{children:g("labels.actions")}),ce("div",{className:"buttonList",children:[!l.editor.isMobile&&t("duplicateSelection"),!l.editor.isMobile&&t("deleteSelectedElements"),t("group"),t("ungroup"),d&&t("hyperlink"),p&&t("cropEditor"),c&&t("toggleLinearEditor")]})]})]})},X2=({appState:e,elementsMap:o,renderAction:t,app:n,setAppState:r})=>{let i=ea(o,e),{saveCaretPosition:a,restoreCaretPosition:l}=Kb(),{container:s}=Ne(),m=!!(e.editingTextElement||e.newElement),d=go(e.activeTool.type)&&!Yc(e.currentItemBackgroundColor)||i.some(y=>go(y.type)&&!Yc(y.backgroundColor)),c=i.length===1,p=!e.selectedLinearElement?.isEditing&&i.length===1&&V2(i[0])&&!Y2(i[0]),u=!e.croppingElementId&&i.length===1&&W2(i[0]),f=gt(e,n),b=!1;i.length===2&&(Wc(i[0])||Wc(i[1]))&&(b=!0);let x=document.documentElement.getAttribute("dir")==="rtl";return ce("div",{className:"compact-shape-actions",children:[Xc(e,i)&&J("div",{className:el("compact-action-item"),children:t("changeStrokeColor")}),Kc(e,i)&&J("div",{className:"compact-action-item",children:t("changeBackgroundColor")}),(d||Un(e.activeTool.type)||i.some(y=>Un(y.type))||Yn(e.activeTool.type)||i.some(y=>Yn(y.type))||Wn(e.activeTool.type)||i.some(y=>Wn(y.type)))&&J("div",{className:"compact-action-item",children:ce(To.Root,{open:e.openPopup==="compactStrokeStyles",onOpenChange:y=>{r(y?{openPopup:"compactStrokeStyles"}:{openPopup:null})},children:[J(To.Trigger,{asChild:!0,children:J("button",{type:"button",className:"compact-action-button properties-trigger",title:g("labels.stroke"),onClick:y=>{y.preventDefault(),y.stopPropagation(),r({openPopup:e.openPopup==="compactStrokeStyles"?null:"compactStrokeStyles"})},children:Lb})}),e.openPopup==="compactStrokeStyles"&&J(_o,{className:Eh,container:s,style:{maxWidth:"13rem"},onClose:()=>{},children:ce("div",{className:"selected-shape-actions",children:[d&&t("changeFillStyle"),(Un(e.activeTool.type)||i.some(y=>Un(y.type)))&&t("changeStrokeWidth"),(Yn(e.activeTool.type)||i.some(y=>Yn(y.type)))&&ce(Bt,{children:[t("changeStrokeStyle"),t("changeSloppiness")]}),(Wn(e.activeTool.type)||i.some(y=>Wn(y.type)))&&t("changeRoundness"),t("changeOpacity")]})})]})}),(Vc(e.activeTool.type)||i.some(y=>Vc(y.type)))&&J("div",{className:"compact-action-item",children:ce(To.Root,{open:e.openPopup==="compactArrowProperties",onOpenChange:y=>{r(y?{openPopup:"compactArrowProperties"}:{openPopup:null})},children:[J(To.Trigger,{asChild:!0,children:J("button",{type:"button",className:"compact-action-button properties-trigger",title:g("labels.arrowtypes"),onClick:y=>{y.preventDefault(),y.stopPropagation(),r({openPopup:e.openPopup==="compactArrowProperties"?null:"compactArrowProperties"})},children:(()=>{let y=at(i,n,E=>O2(E)?E.elbowed?"elbow":E.roundness?"round":"sharp":null,E=>O2(E),E=>E?null:e.currentItemArrowType);return y==="elbow"?Or:y==="round"?zr:Fr})()})}),e.openPopup==="compactArrowProperties"&&J(_o,{container:s,className:"properties-content",style:{maxWidth:"13rem"},onClose:()=>{},children:t("changeArrowProperties")})]})}),p&&J("div",{className:"compact-action-item",children:t("toggleLinearEditor")}),(e.activeTool.type==="text"||i.some(yh))&&ce(Bt,{children:[J("div",{className:"compact-action-item",children:t("changeFontFamily")}),J("div",{className:"compact-action-item",children:ce(To.Root,{open:e.openPopup==="compactTextProperties",onOpenChange:y=>{y?(e.editingTextElement&&a(),r({openPopup:"compactTextProperties"})):(r({openPopup:null}),e.editingTextElement&&l())},children:[J(To.Trigger,{asChild:!0,children:J("button",{type:"button",className:"compact-action-button properties-trigger",title:g("labels.textAlign"),onClick:y=>{y.preventDefault(),y.stopPropagation(),e.openPopup==="compactTextProperties"?r({openPopup:null}):(e.editingTextElement&&a(),r({openPopup:"compactTextProperties"}))},children:e0})}),e.openPopup==="compactTextProperties"&&J(_o,{className:Eh,container:s,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&l()},children:ce("div",{className:"selected-shape-actions",children:[(e.activeTool.type==="text"||i.some(yh))&&t("changeFontSize"),(e.activeTool.type==="text"||U2(i,o))&&t("changeTextAlign"),G2(i,o)&&t("changeVerticalAlign")]})})]})})]}),!m&&i.length>0&&J("div",{className:"compact-action-item",children:t("duplicateSelection")}),!m&&i.length>0&&J("div",{className:"compact-action-item",children:t("deleteSelectedElements")}),!m&&i.length>0&&J("div",{className:"compact-action-item",children:ce(To.Root,{open:e.openPopup==="compactOtherProperties",onOpenChange:y=>{r(y?{openPopup:"compactOtherProperties"}:{openPopup:null})},children:[J(To.Trigger,{asChild:!0,children:J("button",{type:"button",className:"compact-action-button properties-trigger",title:g("labels.actions"),onClick:y=>{y.preventDefault(),y.stopPropagation(),r({openPopup:e.openPopup==="compactOtherProperties"?null:"compactOtherProperties"})},children:X1})}),e.openPopup==="compactOtherProperties"&&J(_o,{className:Eh,container:s,style:{maxWidth:"12rem",justifyContent:"center",alignItems:"center"},onClose:()=>{},children:ce("div",{className:"selected-shape-actions",children:[ce("fieldset",{children:[J("legend",{children:g("labels.layers")}),ce("div",{className:"buttonList",children:[t("sendToBack"),t("sendBackward"),t("bringForward"),t("bringToFront")]})]}),f&&!b&&ce("fieldset",{children:[J("legend",{children:g("labels.align")}),ce("div",{className:"buttonList",children:[x?ce(Bt,{children:[t("alignRight"),t("alignHorizontallyCentered"),t("alignLeft")]}):ce(Bt,{children:[t("alignLeft"),t("alignHorizontallyCentered"),t("alignRight")]}),i.length>2&&t("distributeHorizontally"),J("div",{style:{flexBasis:"100%",height:0}}),ce("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[t("alignTop"),t("alignVerticallyCentered"),t("alignBottom"),i.length>2&&t("distributeVertically")]})]})]}),ce("fieldset",{children:[J("legend",{children:g("labels.actions")}),ce("div",{className:"buttonList",children:[t("group"),t("ungroup"),c&&t("hyperlink"),u&&t("cropEditor")]})]})]})})]})})]})},$c=({activeTool:e,appState:o,app:t,UIOptions:n})=>{let[r,i]=T7(!1),a=e.type==="frame",l=e.type==="laser",s=e.type==="lasso"&&t.defaultSelectionTool!=="lasso",m=e.type==="embeddable",{TTDDialogTriggerTunnel:d}=Ce();return ce(Bt,{children:[gh(t).map(({value:c,icon:p,key:u,numericKey:f,fillable:b},x)=>{if(n.tools?.[c]===!1)return null;let y=g(`toolBar.${c}`),E=u&&xh(typeof u=="string"?u:u[0]),w=E?`${E} ${g("helpDialog.or")} ${f}`:`${f}`;return J(Z,{className:el("Shape",{fillable:b}),type:"radio",icon:p,checked:e.type===c,name:"editor-current-shape",title:`${xh(y)} \u2014 ${w}`,keyBindingLabel:f||E,"aria-label":xh(y),"aria-keyshortcuts":w,"data-testid":`toolbar-${c}`,onPointerDown:({pointerType:v})=>{!o.penDetected&&v==="pen"&&t.togglePenMode(!0),c==="selection"&&(o.activeTool.type==="selection"?t.setActiveTool({type:"lasso"}):t.setActiveTool({type:"selection"}))},onChange:({pointerType:v})=>{o.activeTool.type!==c&&re("toolbar",c,"ui"),c==="image"?t.setActiveTool({type:c}):t.setActiveTool({type:c})}},c)}),J("div",{className:"App-toolbar__divider"}),ce(xe,{open:r,children:[J(xe.Trigger,{className:el("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":a||m||s||l&&!t.props.isCollaborating}),onToggle:()=>i(!r),title:g("toolBar.extraTools"),children:a?Zn:m?Hm:l&&!t.props.isCollaborating?pa:s?aa:sb}),ce(xe.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[J(xe.Item,{onSelect:()=>t.setActiveTool({type:"frame"}),icon:Zn,shortcut:F2.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:a,children:g("toolBar.frame")}),J(xe.Item,{onSelect:()=>t.setActiveTool({type:"embeddable"}),icon:Hm,"data-testid":"toolbar-embeddable",selected:m,children:g("toolBar.embeddable")}),J(xe.Item,{onSelect:()=>t.setActiveTool({type:"laser"}),icon:pa,"data-testid":"toolbar-laser",selected:l,shortcut:F2.K.toLocaleUpperCase(),children:g("toolBar.laser")}),t.defaultSelectionTool!=="lasso"&&J(xe.Item,{onSelect:()=>t.setActiveTool({type:"lasso"}),icon:aa,"data-testid":"toolbar-lasso",selected:s,children:g("toolBar.lasso")}),J("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),t.props.aiEnabled!==!1&&J(d.Out,{}),J(xe.Item,{onSelect:()=>t.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:us,"data-testid":"toolbar-embeddable",children:g("toolBar.mermaidToExcalidraw")}),t.props.aiEnabled!==!1&&t.plugins.diagramToCode&&J(Bt,{children:ce(xe.Item,{onSelect:()=>t.onMagicframeToolSelect(),icon:hs,"data-testid":"toolbar-magicframe",children:[g("toolBar.magicframe"),J(xe.Item.Badge,{children:"AI"})]})})]})]})]})},K2=({renderAction:e,zoom:o})=>J(qe.Col,{gap:1,className:H2.ZOOM_ACTIONS,children:ce(qe.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),Z2=({renderAction:e,className:o})=>ce("div",{className:`undo-redo-buttons ${o}`,children:[J("div",{className:"undo-button-container",children:J(At,{label:g("buttons.undo"),children:e("undo")})}),J("div",{className:"redo-button-container",children:ce(At,{label:g("buttons.redo"),children:[" ",e("redo")]})})]}),$2=({actionManager:e,showExitZenModeBtn:o})=>J("button",{type:"button",className:el("disable-zen-mode",{"disable-zen-mode--visible":o}),onClick:()=>e.executeAction(mi),children:g("buttons.exitZenMode")});import{useRef as I7}from"react";var wh=e=>{let o=I7({userFn:e});return o.current.userFn=e,o.current.stableFn||(o.current.stableFn=(...t)=>o.current.userFn(...t)),o.current.stableFn};import{jsx as S7,jsxs as C7}from"react/jsx-runtime";var lr=he(null),j2=()=>{let[e,o]=le(lr),t=We();return e&&e==="clearCanvas"?S7(_c,{onConfirm:()=>{t.executeAction(Oo),o(null)},onCancel:()=>o(null),title:g("clearCanvasDialog.title"),children:C7("p",{className:"clear-canvas__content",children:[" ",g("alerts.clearReset")]})}):null};var vh={};p1(vh,{toggleTheme:()=>k7});var k7={...Jn,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(Jn,"commandPalette")}};import{jsx as st,jsxs as Io}from"react/jsx-runtime";var _7=he(null),Me={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links"},R7=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}},Jc=({shortcut:e,className:o,children:t})=>{let n=e.replace("++","+$").split("+");return Io("div",{className:Q2("shortcut",o),children:[n.map((r,i)=>st("div",{className:"shortcut-wrapper",children:st("div",{className:"shortcut-key",children:r==="$"?"+":r})},r)),st("div",{className:"shortcut-desc",children:t})]})},ew=e=>!e.altKey&&e[lo.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===lo.P||e.key===lo.SLASH),wde=Object.assign(e=>{let o=be(),t=ae();return qc(()=>{let n=r=>{ew(r)&&(r.preventDefault(),r.stopPropagation(),t(i=>{let a=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return a&&re("command_palette","open","shortcut"),{openDialog:a}}))};return window.addEventListener(Qc.KEYDOWN,n,{capture:!0}),()=>window.removeEventListener(Qc.KEYDOWN,n,{capture:!0})},[t]),o.openDialog?.name!=="commandPalette"?null:st(N7,{...e})},{defaultItems:vh});function N7({customCommandPaletteItems:e}){let o=Be(),t=be(),n=ae(),r=xo(),i=We(),[a,l]=le(_7),[s,m]=jc(null),d=P7(null),c=on({uiAppState:t,customCommandPaletteItems:e,appProps:r});qc(()=>{let{uiAppState:S,customCommandPaletteItems:L,appProps:P}=c,B=Y=>{let Q="";return Y.label&&(typeof Y.label=="function"?Q=g(Y.label(o.scene.getNonDeletedElements(),S,o)):Q=g(Y.label)),Q},k=Y=>typeof Y.icon=="function"?Y.icon(S,o.scene.getNonDeletedElements()):Y.icon,A=[],F=(Y,Q,_)=>{let R={label:B(Y),icon:k(Y),category:Q,shortcut:Fe(Y.name),keywords:Y.keywords,predicate:Y.predicate,viewMode:Y.viewMode,perform:()=>{i.executeAction(Y,"commandPalette")}};return _?_(R,Y):R};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.duplicateSelection,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,Ya,Cc,Ry].map(G=>F(G,Me.elements,(me,ue)=>({...me,predicate:ue.predicate?ue.predicate:(pe,it,uo,yr)=>j(pe,it).length>0}))),Q=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool,i.actions.toggleLassoTool].map(G=>F(G,Me.tools)),_=[i.actions.undo,i.actions.redo,i.actions.zoomIn,i.actions.zoomOut,i.actions.resetZoom,i.actions.zoomToFit,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(G=>F(G,Me.editor)),R=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map(G=>F(G,Me.export));A=[...Y,..._,{label:B(Oo),icon:k(Oo),shortcut:Fe(Oo.name),category:Me.editor,keywords:["delete","destroy"],viewMode:!1,perform:()=>{Ue.set(lr,"clearCanvas")}},{label:g("buttons.exportImage"),category:Me.export,icon:ss,shortcut:Fe("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{n({openDialog:{name:"imageExport"}})}},...R];let W=[{label:g("toolBar.library"),category:Me.app,icon:Pr,viewMode:!1,perform:()=>{S.openSidebar?n({openSidebar:null}):n({openSidebar:{name:q2.name,tab:q2.defaultTab}})}},{label:g("search.title"),category:Me.app,icon:Pt,viewMode:!0,perform:()=>{i.executeAction(tl)}},{label:g("labels.shapeSwitch"),category:Me.elements,icon:ua,perform:()=>{i.executeAction(_y)}},{label:g("labels.changeStroke"),keywords:["color","outline"],category:Me.elements,icon:ls,viewMode:!1,predicate:(G,me)=>{let ue=j(G,me);return ue.length>0&&Xc(me,ue)},perform:()=>{n(G=>({openMenu:G.openMenu==="shape"?null:"shape",openPopup:"elementStroke"}))}},{label:g("labels.changeBackground"),keywords:["color","fill"],icon:ls,category:Me.elements,viewMode:!1,predicate:(G,me)=>{let ue=j(G,me);return ue.length>0&&Kc(me,ue)},perform:()=>{n(G=>({openMenu:G.openMenu==="shape"?null:"shape",openPopup:"elementBackground"}))}},{label:g("labels.canvasBackground"),keywords:["color"],icon:ls,category:Me.editor,viewMode:!1,perform:()=>{n(G=>({openMenu:G.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...Uc.reduce((G,me)=>{let{value:ue,icon:pe,key:it,numericKey:uo}=me;if(P.UIOptions.tools?.[ue]===!1)return G;let wr=it&&L7(typeof it=="string"?it:it[0])||uo,Hl={label:g(`toolBar.${ue}`),category:Me.tools,shortcut:wr,icon:pe,keywords:["toolbar"],viewMode:!1,perform:({event:Im})=>{ue==="image"?o.setActiveTool({type:ue}):o.setActiveTool({type:ue})}};return G.push(Hl),G},[]),...Q,{label:g("toolBar.lock"),category:Me.tools,icon:S.activeTool.locked?Lr:Vn,shortcut:lo.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{o.toggleLock()}},{label:`${g("labels.textToDiagram")}...`,category:Me.tools,icon:pb,viewMode:!1,predicate:P.aiEnabled,perform:()=>{n(G=>({...G,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${g("toolBar.mermaidToExcalidraw")}...`,category:Me.tools,icon:us,viewMode:!1,predicate:P.aiEnabled,perform:()=>{n(G=>({...G,openDialog:{name:"ttd",tab:"mermaid"}}))}}],X=[...A,...W,...L||[]].map(G=>({...G,icon:G.icon||ua,order:G.order??R7(G.category),haystack:`${ju(G.label.toLocaleLowerCase())} ${G.keywords?.join(" ")||""}`}));m(X),l(X.find(G=>G.label===a?.label)??null)}},[c,o,i,m,a?.label,l,n]);let[p,u]=jc(""),[f,b]=jc(null),[x,y]=jc({}),E=S=>{n({openDialog:null},S),u("")},w=(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=wh(S=>S.viewMode===!1&&t.viewModeEnabled?!1:typeof S.predicate=="function"?S.predicate(o.scene.getNonDeletedElements(),t,r,o):S.predicate===void 0||S.predicate),C=wh(S=>{let L=D7(S.target)||ew(S)||S.key===lo.ESCAPE;if(L&&S.key!==lo.ARROW_UP&&S.key!==lo.ARROW_DOWN&&S.key!==lo.ENTER)return;let P=Object.values(x).flat(),B=a&&!p&&v(a);if(S.key===lo.ARROW_UP){S.preventDefault();let k=P.findIndex(Y=>Y.label===f?.label);if(B){if(k===0){b(a);return}if(f===a){let Y=P[P.length-1];Y&&b(Y);return}}let A;k===-1?A=P.length-1:A=k===0?P.length-1:(k-1)%P.length;let F=P[A];F&&b(F);return}if(S.key===lo.ARROW_DOWN){S.preventDefault();let k=P.findIndex(Y=>Y.label===f?.label);if(B){if(!f||k===P.length-1){b(a);return}if(f===a){let Y=P[0];Y&&b(Y);return}}let A=(k+1)%P.length,F=P[A];F&&b(F);return}if(S.key===lo.ENTER&&f&&setTimeout(()=>{w(f,S)}),!L){if(S.stopPropagation(),/^[a-zA-Z0-9]$/.test(S.key)){d?.current?.focus();return}S.preventDefault()}});return qc(()=>(window.addEventListener(Qc.KEYDOWN,C,{capture:!0}),()=>window.removeEventListener(Qc.KEYDOWN,C,{capture:!0})),[C]),qc(()=>{if(!s)return;let S=k=>{let A={};for(let F of k)A[F.category]?A[F.category].push(F):A[F.category]=[F];return A},L=s.filter(v).sort((k,A)=>k.order-A.order),P=!p&&a&&v(a);if(!p){y(S(P?L.filter(k=>k.label!==a?.label):L)),b(P?a:L[0]||null);return}let B=ju(p.toLocaleLowerCase().replace(/[<>_| -]/g,""));L=M7.filter(B,L,{extract:k=>k.haystack}).sort((k,A)=>A.score-k.score).map(k=>k.original),y(S(L)),b(L[0]??null)},[p,s,v,a]),Io(Oe,{onCloseRequest:()=>E(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[st(Ci,{value:p,placeholder:g("commandPalette.search.placeholder"),onChange:S=>{u(S)},selectOnRender:!0,ref:d}),!o.device.viewport.isMobile&&Io("div",{className:"shortcuts-wrapper",children:[st(Jc,{shortcut:"\u2191\u2193",children:g("commandPalette.shortcuts.select")}),st(Jc,{shortcut:"\u21B5",children:g("commandPalette.shortcuts.confirm")}),st(Jc,{shortcut:A7("Esc"),children:g("commandPalette.shortcuts.close")})]}),Io("div",{className:"commands",children:[a&&!p&&Io("div",{className:"command-category",children:[Io("div",{className:"command-category-title",children:[g("commandPalette.recents"),st("div",{className:"icon",style:{marginLeft:"6px"},children:ub})]}),st(J2,{command:a,isSelected:a.label===f?.label,onClick:S=>w(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)=>Io("div",{className:"command-category",children:[st("div",{className:"command-category-title",children:S}),x[S].map(P=>st(J2,{command:P,isSelected:P.label===f?.label,onClick:B=>w(P,B),onMouseMove:()=>b(P),showShortcut:!o.device.viewport.isMobile,appState:t},P.label))]},S)):s?Io("div",{className:"no-match",children:[st("div",{className:"icon",children:Pt})," ",g("commandPalette.search.noMatch")]}):null]})]})}var J2=({command:e,isSelected:o,disabled:t,onMouseMove:n,onClick:r,showShortcut:i,appState:a})=>{let l=()=>{};return Io("div",{className:Q2("command-item",{"item-selected":o,"item-disabled":t}),ref:s=>{o&&!t&&s?.scrollIntoView?.({block:"nearest"})},onClick:t?l:r,onMouseMove:t?l:n,title:t?g("commandPalette.itemNotAvailable"):"",children:[Io("div",{className:"name",children:[e.icon&&st(dn,{icon:typeof e.icon=="function"?e.icon(a):e.icon}),st(Ia,{children:e.label})]}),i&&e.shortcut&&st(Jc,{shortcut:e.shortcut})]})};import{getSizeFromPoints as f0e,randomInteger as _D,getUpdatedTimestamp as RD}from"@excalidraw/common";import{simplify as TD}from"points-on-curve";import{pointsOnBezierCurves as Sde}from"points-on-curve";import{invariant as Mde}from"@excalidraw/common";import{curve as Lde,lineSegment as Ade,pointFrom as Dde,pointDistance as _de,pointFromArray as Rde,pointFromVector as Nde,pointRotateRads as Bde,polygon as Fde,polygonFromPoints as Ode,PRECISION as zde,segmentsIntersectAt as Hde,vector as Gde,vectorAdd as Ude,vectorFromPoint as Yde,vectorScale as Wde}from"@excalidraw/math";import{getElementAbsoluteCoords as Xde}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 vw,pointRotateRads as e0e}from"@excalidraw/math";import{ROUGHNESS as CD,isTransparent as al,assertNever as SD,COLOR_PALETTE as kD,LINE_POLYGON_POINT_MERGE_DISTANCE as o0e}from"@excalidraw/common";import{RoughGenerator as MD}from"roughjs/bin/generator";import u1e from"roughjs/bin/rough";import{getStroke as gD}from"perfect-freehand";import{isRightAngleRads as f1e,lineSegment as b1e,pointFrom as x1e,pointRotateRads as E1e}from"@excalidraw/math";import{BOUND_TEXT_PADDING as w1e,DEFAULT_REDUCED_GLOBAL_ALPHA as v1e,ELEMENT_READY_TO_ERASE_OPACITY as T1e,FRAME_STYLE as I1e,MIME_TYPES as xw,THEME as C1e,distance as S1e,getFontString as k1e,isRTL as M1e,getVerticalOffset as P1e,invariant as L1e}from"@excalidraw/common";import Cge from"roughjs/bin/rough";import{arrayToMap as kge,invariant as dw,rescalePoints as Mge,sizeOf as Pge}from"@excalidraw/common";import{degreesToRadians as Rh,lineSegment as Age,pointDistance as Dge,pointFrom as ot,pointFromArray as Q7,pointRotateRads as Li}from"@excalidraw/math";import{pointsOnBezierCurves as Nge}from"points-on-curve";import{pointCenter as Yhe,pointFrom as Whe,pointRotateRads as Vhe,pointsEqual as Xhe,pointDistance as Khe,vectorFromPoint as Zhe,curveLength as $he,curvePointAtLength as jhe}from"@excalidraw/math";import{DRAGGING_THRESHOLD as Qhe,KEYS as ege,shouldRotateWithDiscreteAngle as tge,getGridPoint as oge,invariant as nge,tupleToCoors as rge,viewportCoordsToSceneCoords as ige}from"@excalidraw/common";import{deconstructLinearOrFreeDrawElement as lge,isPathALoop as sge}from"@excalidraw/element";import{KEYS as Yue,arrayToMap as Wue,isBindingFallthroughEnabled as Vue,tupleToCoors as Xue,invariant as Kue,isDevEnv as Zue,isTestEnv as $ue}from"@excalidraw/common";import{lineSegment as que,pointFrom as Jue,pointRotateRads as Que,vectorFromPoint as ehe,pointDistanceSq as the,clamp as ohe,pointDistance as nhe,pointFromVector as rhe,vectorScale as ihe,vectorNormalize as ahe,vectorCross as lhe,pointsEqual as she,lineSegmentIntersectionPoints as che,PRECISION as dhe}from"@excalidraw/math";import{isTransparent as Epe}from"@excalidraw/common";import{curveIntersectLineSegment as wpe,isPointWithinBounds as vpe,lineSegment as Tpe,lineSegmentIntersectionPoints as Ipe,pointFrom as Cpe,pointFromVector as Spe,pointRotateRads as kpe,pointsEqual as Mpe,vectorFromPoint as Ppe,vectorNormalize as Lpe,vectorScale as Ape}from"@excalidraw/math";import{ellipse as _pe,ellipseSegmentInterceptPoints as Rpe}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as B7,DEFAULT_PROPORTIONAL_RADIUS as Ih,LINE_CONFIRM_THRESHOLD as F7,ROUNDNESS as Ch}from"@excalidraw/common";import{curve as qde,curveCatmullRomCubicApproxPoints as Jde,curveOffsetPoints as Qde,lineSegment as eme,pointDistance as O7,pointFrom as tme,pointFromArray as ome,rectangle as nme}from"@excalidraw/math";var ed=(e,o=1)=>{if(e.length>=3){let[t,n]=[e[0],e[e.length-1]];return O7(t,n)<=F7/o}return!1},ol=(e,o)=>{if(o.roundness?.type===Ch.PROPORTIONAL_RADIUS||o.roundness?.type===Ch.LEGACY)return e*Ih;if(o.roundness?.type===Ch.ADAPTIVE_RADIUS){let t=o.roundness?.value??B7,n=t/Ih;return e<=n?e*Ih:t}return 0};import{ROUNDNESS as dme,assertNever as mme}from"@excalidraw/common";import{pointsEqual as ume}from"@excalidraw/math";var tw=e=>!!e&&e.type==="embeddable",ow=e=>!!e&&e.type==="iframe",kh=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),sr=e=>e!=null&&e.type==="text";var td=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var xn=e=>e!=null&&z7(e.type);var Si=e=>e!=null&&e.type==="arrow",nl=e=>Si(e)&&e.elbowed;var z7=e=>e==="arrow"||e==="line";var ki=e=>e!==null&&"containerId"in e&&e.containerId!==null&&sr(e);import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as Ume,ARROW_LABEL_WIDTH_FRACTION as Yme,BOUND_TEXT_PADDING as Wme,DEFAULT_FONT_SIZE as Vme,TEXT_ALIGN as Xme,VERTICAL_ALIGN as Kme,getFontString as Zme,isProdEnv as $me,invariant as jme}from"@excalidraw/common";import{pointFrom as Jme,pointRotateRads as Qme}from"@excalidraw/math";import{BOUND_TEXT_PADDING as Eme,DEFAULT_FONT_SIZE as yme,DEFAULT_FONT_FAMILY as wme,getFontString as vme,isTestEnv as Tme,normalizeEOL as Ime}from"@excalidraw/common";var Cme="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as Dme,isTestEnv as _me}from"@excalidraw/common";import{curvePointDistance as spe,distanceToLineSegment as cpe,pointRotateRads as dpe}from"@excalidraw/math";import{ellipse as ppe,ellipseDistanceFromPoint as upe}from"@excalidraw/math/ellipse";import{invariant as Xpe,isDevEnv as Kpe,isTestEnv as Zpe}from"@excalidraw/common";import{pointFrom as jpe,pointFromVector as qpe,pointRotateRads as Jpe,pointScaleFromOrigin as Qpe,pointsEqual as eue,triangleIncludesPoint as tue,vectorCross as oue,vectorFromPoint as W7,vectorScale as nue}from"@excalidraw/math";var Dh=[1,0],aw=[0,1],_h=[-1,0],lw=[0,-1],nd=e=>{let[o,t]=e,n=Math.abs(o),r=Math.abs(t);return o>r?Dh:o<=-r?_h:t>n?aw:lw},sw=(e,o)=>nd(W7(e,o)),rd=(e,o)=>id(sw(e,o)),Ah=(e,o)=>e[0]===o[0]&&e[1]===o[1],id=e=>Ah(e,Dh)||Ah(e,_h);import{clamp as cue,pointDistance as due,pointFrom as mue,pointScaleFromOrigin as pue,pointsEqual as uue,pointTranslate as hue,vector as gue,vectorCross as fue,vectorFromPoint as bue,vectorScale as xue}from"@excalidraw/math";import{BinaryHeap as yue,invariant as wue,isAnyTrue as vue,tupleToCoors as Tue,getSizeFromPoints as Iue,isDevEnv as Cue,arrayToMap as Sue}from"@excalidraw/common";import{SHIFT_LOCKING_ANGLE as Che,viewportCoordsToSceneCoords as She}from"@excalidraw/common";import{normalizeRadians as Mhe,radiansBetweenAngles as Phe,radiansDifference as Lhe}from"@excalidraw/math";import{pointsEqual as Dhe}from"@excalidraw/math";var Sh=e=>{let o=Math.floor(e.width/2)+1,t=0,n=e.width,r=Math.floor(e.height/2)+1,i=o,a=e.height;return[o,t,n,r,i,a,0,r]};var eD=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}},tD=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},Nh=(e,o,t,n)=>{if(o.length<1)return null;let r=Th(o[0]);if(r.length<1)return null;let i=t==="start"?1:r.length-1,a=r[i].data;dw(a.length===6,"Op data length is not 6");let l=ot(a[4],a[5]),s=ot(a[2],a[3]),m=ot(a[0],a[1]),d=r[i-1],c=ot(0,0);if(d.op==="move"){let _=Q7(d.data);dw(_!=null,"Op data is not a point"),c=_}else d.op==="bcurveTo"&&(c=ot(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-_)*m[R]+c[R]*Math.pow(_,3),[u,f]=t==="start"?c:l,[b,x]=[p(.3,0),p(.3,1)],y=Math.hypot(u-b,f-x),E=(u-b)/y,w=(f-x)/y,v=eD(n),C=0;{let[_,R]=t==="end"?e.points[e.points.length-1]:e.points[0],[W,X]=e.points.length>1?t==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];C=Math.hypot(_-W,R-X)}let L=Math.min(v,C*(n==="diamond"||n==="diamond_outline"?.25:.5)),P=u-E*L,B=f-w*L;if(n==="dot"||n==="circle"||n==="circle_outline"){let _=Math.hypot(B-f,P-u)+e.strokeWidth-2;return[u,f,_]}let k=tD(n);if(n==="crowfoot_many"||n==="crowfoot_one_or_many"){let[_,R]=Li(ot(u,f),ot(P,B),Rh(-k)),[W,X]=Li(ot(u,f),ot(P,B),Rh(k));return[P,B,_,R,W,X]}let[A,F]=Li(ot(P,B),ot(u,f),-k*Math.PI/180),[Y,Q]=Li(ot(P,B),ot(u,f),Rh(k));if(n==="diamond"||n==="diamond_outline"){let _,R;if(t==="start"){let[W,X]=e.points.length>1?e.points[1]:[0,0];[_,R]=Li(ot(u+L*2,f),ot(u,f),Math.atan2(X-f,W-u))}else{let[W,X]=e.points.length>1?e.points[e.points.length-2]:[0,0];[_,R]=Li(ot(u-L*2,f),ot(u,f),Math.atan2(f-X,u-W))}return[u,f,A,F,_,R,Y,Q]}return[u,f,A,F,Y,Q]};import{pointFrom as $ge,pointCenter as jge,pointRotateRads as qge,vectorFromPoint as Jge,vectorNormalize as Qge,vectorSubtract as efe,vectorAdd as tfe,vectorScale as ofe,pointFromVector as nfe,clamp as rfe,isCloseTo as ife}from"@excalidraw/math";import{arrayToMap as Vfe}from"@excalidraw/common";import{isPointWithinBounds as Kfe,pointFrom as Zfe}from"@excalidraw/math";import{vectorCross as dfe,vectorFromPoint as mfe}from"@excalidraw/math";import{arrayToMap as oD}from"@excalidraw/common";import{getElementBounds as nD}from"@excalidraw/element";import{isArrowElement as rD,isExcalidrawElement as iD,isFreeDrawElement as aD,isLinearElement as lD,isTextElement as sD}from"@excalidraw/element";import{rangeIncludesValue as ad,pointFrom as Yo,pointRotateRads as cD,rangeInclusive as ld}from"@excalidraw/math";var dD=e=>e.type==="diamond"?[Yo(e.width/2,0),Yo(e.width,e.height/2),Yo(e.width/2,e.height),Yo(0,e.height/2)]:[Yo(0,0),Yo(0+e.width,0),Yo(0+e.width,e.height),Yo(0,e.height)],mD=e=>lD(e)||aD(e)?e.points:dD(e),pw=e=>{let o=e.reduce((t,[n,r])=>(t.minY=Math.min(t.minY,r),t.minX=Math.min(t.minX,n),t.maxX=Math.max(t.maxX,n),t.maxY=Math.max(t.maxY,r),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},uw=e=>{let o=mD(e),{cx:t,cy:n}=pw(o),r=Yo(t,n),i=o.map(d=>cD(d,r,e.angle)),{minX:a,minY:l,maxX:s,maxY:m}=pw(i);return[a+e.x,l+e.y,s+e.x,m+e.y]},Bh=(e,o,t=!1)=>{let n=uw(e),r=o[0]<=n[0]&&o[2]>=n[2]&&o[1]<=n[1]&&o[3]>=n[3];return t?r?!0:n[0]<=o[0]&&n[2]>=o[2]&&n[1]<=o[1]&&n[3]>=o[3]:r},hw=(e,o)=>{let t=uw(e);return(ad(t[0],ld(o[0],o[2]))||ad(o[0],ld(t[0],t[2])))&&(ad(t[1],ld(o[1],o[3]))||ad(o[1],ld(t[1],t[3])))},gw=({elements:e,bounds:o,type:t,errorMargin:n=0})=>{iD(o)&&(o=nD(o,oD(e)));let r=[o[0]-n,o[1]-n,o[2]+n,o[3]+n],i=new Set;for(let a of e){if(i.has(a.id))continue;if(t==="overlap"?hw(a,r):t==="inside"?Bh(a,r):Bh(a,r,!0)){if(i.add(a.id),a.boundElements)for(let s of a.boundElements)i.add(s.id);sD(a)&&a.containerId&&i.add(a.containerId),rD(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 kfe,isShallowEqual as uD}from"@excalidraw/common";var pD=function(){let e=null,o=null,t=null,n=(i,a,l,s)=>{if(t!==void 0&&a===o&&i===e&&l.editingGroupId===t?.editingGroupId)return t;let m={};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];m[f]=!0}}let d={},c=a.reduce((p,u)=>{if(u.isDeleted)return p;let f=u.groupIds.find(b=>m[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&&m[p]&&(m[p]=!1);return o=a,e=i,t={editingGroupId:l.editingGroupId,selectedGroupIds:m,selectedElementIds:Fh({...l.selectedElementIds,...c},s)},t},r=(i,a,l,s)=>{let m=s?s.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):Oh(a,i);return m.length?n(m,a,i,l):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:Fh(i.selectedElementIds,l)}};return r.clearCache=()=>{o=null,e=null,t=null},r}();var Rfe=function(){let e=null,o=null,t=null,n=(r,i)=>(t!=null&&r===e&&i.selectedElementIds===o||(t=r.some(a=>i.selectedElementIds[a.id]),e=r,o=i.selectedElementIds),t);return n.clearCache=()=>{e=null,o=null,t=null},n}(),Oh=(e,o,t)=>{let n=new Set,r=[];for(let i of e.values()){if(o.selectedElementIds[i.id]){r.push(i),n.add(i.id);continue}if(t?.includeBoundTextElement&&ki(i)&&o.selectedElementIds[i?.containerId]){r.push(i),n.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return r.forEach(a=>{td(a)&&fw(e,a.id).forEach(l=>!n.has(l.id)&&i.push(l)),i.push(a)}),i}return r};var Fh=(e,o)=>uD(o.selectedElementIds,e)?o.selectedElementIds:e;var fw=(e,o)=>{let t=[];for(let n of e.values())n.frameId===o&&t.push(n);return t};var fD=typeof document<"u"?document.createElement("img"):{src:""};fD.src=`data:${xw.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 bD=typeof document<"u"?document.createElement("img"):{src:""};bD.src=`data:${xw.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 Ew=new WeakMap;var xD=new WeakMap([]);function yw(e){let o=ED(e),t=new Path2D(o);return xD.set(e,t),t}function ED(e){return vD(yD(e))}function yD(e){let o=e.simulatePressure?e.points:e.points.length?e.points.map(([n,r],i)=>[n,r,e.pressures[i]]):[[0,0,.5]],t={simulatePressure:e.simulatePressure,size:e.strokeWidth*4.25,thinning:.6,smoothing:.5,streamline:.5,easing:n=>Math.sin(n*Math.PI/2),last:!!e.lastCommittedPoint};return gD(o,t)}function bw(e,o){return[(e[0]+o[0])/2,(e[1]+o[1])/2]}var wD=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g;function vD(e){if(!e.length)return"";let o=e.length-1;return e.reduce((t,n,r,i)=>(r===o?t.push(n,bw(n,i[0]),"L",i[0],"Z"):t.push(n,bw(n,i[r+1])),t),["M",e[0],"Q"]).join(" ").replace(wD,"$1")}var ww=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";var ct=class ct{};I(ct,"rg",new MD),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 n=t?.isExporting?void 0:ct.get(o);if(n!==void 0)return n;Ew.delete(o);let r=AD(o,ct.rg,t||{isExporting:!1,canvasBackgroundColor:kD.white,embedsValidationStatus:null});return ct.cache.set(o,r),r});var Pi=ct,PD=e=>[8,8+e],Cw=e=>[1.5,6+e];function LD(e){let o=e.roughness,t=Math.max(e.width,e.height),n=Math.min(e.width,e.height);return n>=20&&t>=50||n>=15&&e.roundness&&ww(e.type)||xn(e)&&t>=50?o:Math.min(o/(t<10?3:2),2.5)}var Uo=(e,o=!1)=>{let t={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?PD(e.strokeWidth):e.strokeStyle==="dotted"?Cw(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:LD(e),stroke:e.strokeColor,preserveVertices:o||e.roughness<CD.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return t.fillStyle=e.fillStyle,t.fill=al(e.backgroundColor)?void 0:e.backgroundColor,e.type==="ellipse"&&(t.curveFitting=1),t;case"line":case"freedraw":return ed(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}`)}},Tw=(e,o,t)=>kh(e)&&(o||tw(e)&&t?.get(e.id)!==!0)&&al(e.backgroundColor)&&al(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:ow(e)?{...e,strokeColor:al(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:al(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,Iw=(e,o,t,n,r,i,a)=>{let l=Nh(e,o,t,n);if(l===null)return[];let s=(m,d)=>{if(m===null)return[];let[,,c,p,u,f]=m;return[r.line(c,p,u,f,d)]};switch(n){case"dot":case"circle":case"circle_outline":{let[m,d,c]=l;return delete i.strokeLineDash,[r.circle(m,d,c,{...i,fill:n==="circle_outline"?a:e.strokeColor,fillStyle:"solid",stroke:e.strokeColor,roughness:Math.min(.5,i.roughness||0)})]}case"triangle":case"triangle_outline":{let[m,d,c,p,u,f]=l;return delete i.strokeLineDash,[r.polygon([[m,d],[c,p],[u,f],[m,d]],{...i,fill:n==="triangle_outline"?a:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"diamond":case"diamond_outline":{let[m,d,c,p,u,f,b,x]=l;return delete i.strokeLineDash,[r.polygon([[m,d],[c,p],[u,f],[b,x],[m,d]],{...i,fill:n==="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[m,d,c,p,u,f]=l;if(e.strokeStyle==="dotted"){let b=Cw(e.strokeWidth-1);i.strokeLineDash=[b[0],b[1]-1]}else delete i.strokeLineDash;return i.roughness=Math.min(1,i.roughness||0),[r.line(c,p,m,d,i),r.line(u,f,m,d,i),...n==="crowfoot_one_or_many"?s(Nh(e,o,t,"crowfoot_one"),i):[]]}}};var AD=(e,o,{isExporting:t,canvasBackgroundColor:n,embedsValidationStatus:r})=>{switch(e.type){case"rectangle":case"iframe":case"embeddable":{let i;if(e.roundness){let a=e.width,l=e.height,s=ol(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`,Uo(Tw(e,t,r),!0))}else i=o.rectangle(0,0,e.width,e.height,Uo(Tw(e,t,r),!1));return i}case"diamond":{let i,[a,l,s,m,d,c,p,u]=Sh(e);if(e.roundness){let f=ol(Math.abs(a-p),e),b=ol(Math.abs(m-l),e);i=o.path(`M ${a+f} ${l+b} L ${s-f} ${m-b}
|
|
9
|
+
C ${s} ${m}, ${s} ${m}, ${s-f} ${m+b}
|
|
10
|
+
L ${d+f} ${c-b}
|
|
11
|
+
C ${d} ${c}, ${d} ${c}, ${d-f} ${c-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}`,Uo(e,!0))}else i=o.polygon([[a,l],[s,m],[d,c],[p,u]],Uo(e));return i}case"ellipse":return o.ellipse(e.width/2,e.height/2,e.width,e.height,Uo(e));case"line":case"arrow":{let i,a=Uo(e),l=e.points.length?e.points:[ID(0,0)];if(nl(e)?l.every(s=>Math.abs(s[0])<=1e6&&Math.abs(s[1])<=1e6)?i=[o.path(DD(l,16),Uo(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:m="arrow"}=e;if(s!==null){let d=Iw(e,i,"start",s,o,a,n);i.push(...d)}if(m!==null){let d=Iw(e,i,"end",m,o,a,n);i.push(...d)}}return i}case"freedraw":{let i;if(yw(e),ed(e.points)){let a=TD(e.points,.75);i=o.curve(a,{...Uo(e),stroke:"none"})}else i=null;return i}case"frame":case"magicframe":case"text":case"image":return null;default:return SD(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},DD=(e,o)=>{let t=[];for(let r=1;r<e.length-1;r+=1){let i=e[r-1],a=e[r+1],l=e[r],s=rd(l,i),m=rd(a,l),d=Math.min(o,vw(e[r],a)/2,vw(e[r],i)/2);s?i[0]<l[0]?t.push([e[r][0]-d,e[r][1]]):t.push([e[r][0]+d,e[r][1]]):i[1]<l[1]?t.push([e[r][0],e[r][1]-d]):t.push([e[r][0],e[r][1]+d]),t.push(e[r]),m?a[0]<l[0]?t.push([e[r][0]-d,e[r][1]]):t.push([e[r][0]+d,e[r][1]]):a[1]<l[1]?t.push([e[r][0],e[r][1]-d]):t.push([e[r][0],e[r][1]+d])}let n=[`M ${e[0][0]} ${e[0][1]}`];for(let r=0;r<t.length;r+=3)n.push(`L ${t[r][0]} ${t[r][1]}`),n.push(`Q ${t[r+1][0]} ${t[r+1][1]}, ${t[r+2][0]} ${t[r+2][1]}`);return n.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),n.join(" ")};var Sw=(e,o,t=!1)=>{let n=!1;for(let r in o){let i=o[r];if(typeof i<"u"){if(e[r]===i&&(typeof i!="object"||i===null))continue;n=!0}}return!n&&!t?e:{...e,...o,version:o.version??e.version+1,versionNonce:o.versionNonce??_D(),updated:RD()}};import{jsx as Mw}from"react/jsx-runtime";var Di=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,n)=>{let r=n.scene.getSelectedElements(o);return!!(!o.selectedLinearElement?.isEditing&&r.length===1&&BD(r[0])&&!ND(r[0]))},perform(e,o,t,n){let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];zh(r,"No selected element found"),zh(o.selectedLinearElement,"No selected linear element found"),zh(r.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:kw.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let n=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0];if(!n)return null;let r=g(n.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return Mw(Z,{type:"button",icon:kb,title:r,"aria-label":r,onClick:()=>o(null)})}}),D0e=N({name:"togglePolygon",category:Me.elements,icon:Bm,keywords:["loop"],label:(e,o,t)=>!t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds}).some(i=>!Ai(i)||!i.polygon)?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds});return r.length>0&&r.every(i=>Ai(i)&&i.points.length>=4)},perform(e,o,t,n){let r=n.scene.getSelectedElements(o);if(r.some(s=>!Ai(s)))return!1;let i=r,a=i.some(s=>!s.polygon),l=FD(i);return{elements:e.map(s=>!l.has(s.id)||!Ai(s)?s:Sw(s,{backgroundColor:a?s.backgroundColor:"transparent",...OD(s,a)})),appState:o,captureUpdate:kw.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let n=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(n.length===0||n.some(a=>!Ai(a)||!a.polygon||a.points.length<3))return null;let r=n.every(a=>Ai(a)&&a.polygon),i=g(r?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return Mw(Yr,{icon:Bm,title:i,"aria-label":i,active:r,onClick:()=>o(null),style:{marginLeft:"auto"}})}});import{KEYS as Pw,CANVAS_SEARCH_TAB as Lw,CLASSES as zD,DEFAULT_SIDEBAR as Aw}from"@excalidraw/common";import{CaptureUpdateAction as HD}from"@excalidraw/element";var tl=N({name:"searchMenu",icon:Pt,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,o,t,n){if(o.openDialog)return!1;if(o.openSidebar?.name===Aw.name&&o.openSidebar.tab===Lw){let r=n.excalidrawContainerValue.container?.querySelector(`.${zD.SEARCH_MENU_INPUT_WRAPPER} input`);return r?.focus(),r?.select(),!1}return{appState:{...o,openSidebar:{name:Aw.name,tab:Lw},openDialog:null},captureUpdate:HD.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[Pw.CTRL_OR_CMD]&&e.key===Pw.F});import{isImageElement as GD}from"@excalidraw/element";import{CaptureUpdateAction as UD}from"@excalidraw/element";import{jsx as YD}from"react/jsx-runtime";var Hh=N({name:"cropEditor",label:"helpDialog.cropStart",icon:ip,viewMode:!0,trackEvent:{category:"menu"},keywords:["image","crop"],perform(e,o,t,n){let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...o,isCropping:!1,croppingElementId:r.id},captureUpdate:UD.IMMEDIATELY}},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return!!(!o.croppingElementId&&r.length===1&&GD(r[0]))},PanelComponent:({appState:e,updateData:o,app:t})=>{let n=g("helpDialog.cropStart");return YD(Z,{type:"button",icon:ip,title:n,"aria-label":n,onClick:()=>o(null)})}});import{getNonDeletedElements as WD}from"@excalidraw/element";import{mutateElement as VD}from"@excalidraw/element";import{newFrameElement as XD}from"@excalidraw/element";import{isFrameLikeElement as sd}from"@excalidraw/element";import{addElementsToFrame as KD,removeAllElementsFromFrame as ZD}from"@excalidraw/element";import{getFrameChildren as $D}from"@excalidraw/element";import{KEYS as Dw,updateActiveTool as _w}from"@excalidraw/common";import{getElementsInGroup as jD}from"@excalidraw/element";import{getCommonBounds as qD}from"@excalidraw/element";import{CaptureUpdateAction as cr}from"@excalidraw/element";var Rw=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length===1&&sd(t[0])},Nw=N({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o).at(0)||null;if(sd(r)){let i=$D(WD(e),r.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...o,selectedElementIds:i.reduce((a,l)=>(a[l.id]=!0,a),{})},captureUpdate:cr.IMMEDIATELY}}return{elements:e,appState:o,captureUpdate:cr.EVENTUALLY}},predicate:(e,o,t,n)=>Rw(o,n)}),Bw=N({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o).at(0)||null;return sd(r)?{elements:ZD(e,r),appState:{...o,selectedElementIds:{[r.id]:!0}},captureUpdate:cr.IMMEDIATELY}:{elements:e,appState:o,captureUpdate:cr.EVENTUALLY}},predicate:(e,o,t,n)=>Rw(o,n)}),Gbe=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:cr.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),Ube=N({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:Zn,viewMode:!1,perform:(e,o,t,n)=>{let r=_w(o,{type:"frame"});return Dt(n.interactiveCanvas,{...o,activeTool:r}),{elements:e,appState:{...o,activeTool:_w(o,{type:"frame"})},captureUpdate:cr.EVENTUALLY}},keyTest:e=>!e[Dw.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===Dw.F}),Fw=N({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=j(e,o);return r.length>0&&!r.some(i=>sd(i))},perform:(e,o,t,n)=>{let r=j(e,o),i=n.scene.getNonDeletedElementsMap(),[a,l,s,m]=qD(r,i),d=16,c=XD({x:a-d,y:l-d,width:s-a+d*2,height:m-l+d*2});if(o.editingGroupId){let u=jD(r,o.editingGroupId);for(let f of u){let b=f.groupIds.indexOf(o.editingGroupId);VD(f,i,{groupIds:f.groupIds.slice(0,b)})}}return{elements:KD([...n.scene.getElementsIncludingDeleted(),c],r,c,o),appState:{selectedElementIds:{[c.id]:!0}},captureUpdate:cr.IMMEDIATELY}}});import{isWindows as r_,KEYS as sl,matchKey as Yh,arrayToMap as Ow}from"@excalidraw/common";import{CaptureUpdateAction as Uh}from"@excalidraw/element";import{orderByFractionalIndex as i_}from"@excalidraw/element";import{Emitter as JD}from"@excalidraw/common";import{CaptureUpdateAction as QD,StoreChange as e_,StoreDelta as t_}from"@excalidraw/element";var _i=class extends t_{applyTo(o,t,n){let[r,i]=this.elements.applyTo(o,n.elements,{excludedProperties:new Set(["version","versionNonce"])}),[a,l]=this.appState.applyTo(t,r);return[r,a,i||l]}static calculate(o,t){return super.calculate(o,t)}static inverse(o){return super.inverse(o)}static applyLatestChanges(o,t,n,r){return super.applyLatestChanges(o,t,n,r)}},dr=class{constructor(o=!0,t=!0){this.isUndoStackEmpty=o;this.isRedoStackEmpty=t}},ll=class e{constructor(o){this.store=o;I(this,"onHistoryChangedEmitter",new JD);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 _i)return;let t=_i.inverse(o);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new dr(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(o,t){return this.perform(o,t,()=>e.pop(this.undoStack),n=>e.push(this.redoStack,n))}redo(o,t){return this.perform(o,t,()=>e.pop(this.redoStack),n=>e.push(this.undoStack,n))}perform(o,t,n,r){try{let i=n();if(i===null)return;let a=QD.IMMEDIATELY,l=this.store.snapshot,s=o,m=t,d=!1;for(;i;){try{[s,m,d]=i.applyTo(s,m,l);let c=l.elements,p=l.maybeClone(a,s,m),u=e_.create(l,p),f=_i.applyLatestChanges(i,c,s);f.isEmpty()||(this.store.scheduleMicroAction({action:a,change:u,delta:f}),i=f),l=p}finally{r(i)}if(d)break;i=n()}return[s,m]}finally{this.onHistoryChangedEmitter.trigger(new dr(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 n=_i.inverse(t);return o.push(n)}};import{useEffect as o_,useState as n_}from"react";var Gh=(e,o)=>{let[t,n]=n_(o);return o_(()=>{let r=e.on(i=>{n(i)});return()=>{r()}},[e]),t};import{jsx as Uw}from"react/jsx-runtime";var zw=(e,o,t)=>{if(!o.multiElement&&!o.resizingElement&&!o.editingTextElement&&!o.newElement&&!o.selectedElementsAreBeingDragged&&!o.selectionElement&&!e.flowChartCreator.isCreatingChart){let n=t();if(!n)return{captureUpdate:Uh.EVENTUALLY};let[r,i]=n,a=i_(Array.from(r.values()));return{appState:i,elements:a,captureUpdate:Uh.NEVER}}return{captureUpdate:Uh.EVENTUALLY}},Hw=e=>({name:"undo",label:"buttons.undo",icon:Um,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,n,r)=>zw(r,t,()=>e.undo(Ow(o),t)),keyTest:o=>o[sl.CTRL_OR_CMD]&&Yh(o,sl.Z)&&!o.shiftKey,PanelComponent:({updateData:o,data:t})=>{let{isUndoStackEmpty:n}=Gh(e.onHistoryChangedEmitter,new dr(e.isUndoStackEmpty,e.isRedoStackEmpty));return Uw(Z,{type:"button",icon:Um,"aria-label":g("buttons.undo"),onClick:o,size:t?.size||"medium",disabled:n,"data-testid":"button-undo"})}}),Gw=e=>({name:"redo",label:"buttons.redo",icon:Ym,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,n,r)=>zw(r,t,()=>e.redo(Ow(o),t)),keyTest:o=>o[sl.CTRL_OR_CMD]&&o.shiftKey&&Yh(o,sl.Z)||r_&&o.ctrlKey&&!o.shiftKey&&Yh(o,sl.Y),PanelComponent:({updateData:o,data:t})=>{let{isRedoStackEmpty:n}=Gh(e.onHistoryChangedEmitter,new dr(e.isUndoStackEmpty,e.isRedoStackEmpty));return Uw(Z,{type:"button",icon:Ym,"aria-label":g("buttons.redo"),onClick:o,size:t?.size||"medium",disabled:n,"data-testid":"button-redo"})}});import{getFontString as a_}from"@excalidraw/common";import{newElementWith as l_}from"@excalidraw/element";import{measureText as s_}from"@excalidraw/element";import{isTextElement as Yw}from"@excalidraw/element";import{CaptureUpdateAction as c_}from"@excalidraw/element";var Ww=N({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=j(e,o);return r.length===1&&Yw(r[0])&&!r[0].autoResize},perform:(e,o,t,n)=>{let r=j(e,o);return{appState:o,elements:e.map(i=>{if(i.id===r[0].id&&Yw(i)){let a=s_(i.originalText,a_(i),i.lineHeight);return l_(i,{autoResize:!0,width:a.width,height:a.height,text:i.originalText})}return i}),captureUpdate:c_.IMMEDIATELY}}});import{CODES as d_,KEYS as m_}from"@excalidraw/common";import{CaptureUpdateAction as p_}from"@excalidraw/element";var Wh=N({name:"viewMode",label:"labels.viewMode",icon:Br,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,o){return{appState:{...o,viewModeEnabled:!this.checked(o)},captureUpdate:p_.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,o,t)=>typeof t.viewModeEnabled>"u",keyTest:e=>!e[m_.CTRL_OR_CMD]&&e.altKey&&e.code===d_.R});import{isPromiseLike as u_}from"@excalidraw/common";import{jsx as h_}from"react/jsx-runtime";var Vh=(e,o,t,n,r,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,n,i))&&re(e.trackEvent.category,e.trackEvent.action||e.name,`${o} (${r.device.editor.isMobile?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},cd=class{constructor(o,t,n,r){I(this,"actions",{});I(this,"updater");I(this,"getAppState");I(this,"getElementsIncludingDeleted");I(this,"app");I(this,"renderAction",(o,t)=>{let n=this.app.props.UIOptions.canvasActions;if(this.actions[o]&&"PanelComponent"in this.actions[o]&&(!(o in n)||n[o])){let r=this.actions[o],i=r.PanelComponent;i.displayName="PanelComponent";let a=this.getElementsIncludingDeleted(),l=this.getAppState(),s=m=>{Vh(r,"ui",l,a,this.app,m),this.updater(r.perform(this.getElementsIncludingDeleted(),this.getAppState(),m,this.app))};return h_(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(),n=this.getAppState();return!o.predicate||o.predicate(t,n,this.app.props,this.app)});this.updater=i=>{if(u_(i))i.then(a=>o(a));else return o(i)},this.getAppState=t,this.getElementsIncludingDeleted=n,this.app=r}registerAction(o){this.actions[o.name]=o}registerAll(o){o.forEach(t=>this.registerAction(t))}handleKeyDown(o){let t=this.app.props.UIOptions.canvasActions,n=Object.values(this.actions).sort((s,m)=>(m.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(n.length!==1)return n.length>1&&console.warn("Canceling as multiple actions match this shortcut",n),!1;let r=n[0];if(this.getAppState().viewModeEnabled&&r.viewMode!==!0)return!1;let i=this.getElementsIncludingDeleted(),a=this.getAppState(),l=null;return Vh(r,"keyboard",a,i,this.app,null),o.preventDefault(),o.stopPropagation(),this.updater(n[0].perform(i,a,l,this.app)),!0}executeAction(o,t="api",n=null){let r=this.getElementsIncludingDeleted(),i=this.getAppState();Vh(o,t,i,r,this.app,n),this.updater(o.perform(r,i,n,this.app))}};var dd=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 n=this.targets.get(o);if(!n)return;let r=this.onFrame(n,t);!n.stopped&&!r?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 Xh=e=>{let o=Array.from(e.values());return{x:Vw(o,t=>t.x)/o.length,y:Vw(o,t=>t.y)/o.length}},Kh=([e,o])=>Math.hypot(e.x-o.x,e.y-o.y),Vw=(e,o)=>e.reduce((t,n)=>t+o(n),0);import{pointFrom as H,pointRotateRads as En,rangeInclusive as Vt,rangeIntersection as md,rangesOverlap as pd}from"@excalidraw/math";import{TOOL_TYPE as mr,KEYS as Xw}from"@excalidraw/common";import{getCommonBounds as Zh,getDraggedElementsBounds as $h,getElementAbsoluteCoords as g_}from"@excalidraw/element";import{isBoundToContainer as jw}from"@excalidraw/element";import{getMaximumGroups as qw}from"@excalidraw/element";import{getSelectedElements as f_,getVisibleAndNonSelectedElements as Jw}from"@excalidraw/element";var b_=8,Kw=99999,ud=e=>b_/e,bt=class bt{};I(bt,"referenceSnapPoints",null),I(bt,"visibleGaps",null),I(bt,"setReferenceSnapPoints",o=>{bt.referenceSnapPoints=o}),I(bt,"getReferenceSnapPoints",()=>bt.referenceSnapPoints),I(bt,"setVisibleGaps",o=>{bt.visibleGaps=o}),I(bt,"getVisibleGaps",()=>bt.visibleGaps),I(bt,"destroy",()=>{bt.referenceSnapPoints=null,bt.visibleGaps=null});var Xt=bt,yn=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,Wo=({event:e,app:o,selectedElements:t})=>{if(e){let n=o.state.activeTool.type==="lasso"&&o.state.selectedElementsAreBeingDragged;return(o.state.activeTool.type!=="lasso"||n)&&(o.state.objectsSnapModeEnabled&&!e[Xw.CTRL_OR_CMD]||!o.state.objectsSnapModeEnabled&&e[Xw.CTRL_OR_CMD]&&!yn(o))}return t.length===1&&t[0].type==="arrow"?!1:o.state.objectsSnapModeEnabled},x_=(e,o,t=.01)=>Math.abs(e-o)<=t,cl=(e,o,{omitCenter:t,boundingBoxCorners:n,dragOffset:r}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[l,s,m,d,c,p]=g_(a,o);r&&(l+=r.x,m+=r.x,c+=r.x,s+=r.y,d+=r.y,p+=r.y);let u=(m-l)/2,f=(d-s)/2;if((a.type==="diamond"||a.type==="ellipse")&&!n){let b=En(H(l,s+f),H(c,p),a.angle),x=En(H(l+u,s),H(c,p),a.angle),y=En(H(m,s+f),H(c,p),a.angle),E=En(H(l+u,d),H(c,p),a.angle),w=H(c,p);i=t?[b,x,y,E]:[b,x,y,E,w]}else{let b=En(H(l,s),H(c,p),a.angle),x=En(H(m,s),H(c,p),a.angle),y=En(H(l,d),H(c,p),a.angle),E=En(H(m,d),H(c,p),a.angle),w=H(c,p);i=t?[b,x,y,E]:[b,x,y,E,w]}}else if(e.length>1){let[a,l,s,m]=$h(e,r??{x:0,y:0}),d=s-a,c=m-l,p=H(a,l),u=H(s,l),f=H(a,m),b=H(s,m),x=H(a+d/2,l+c/2);i=t?[p,u,f,b]:[p,u,f,b,x]}return i.map(a=>H(Le(a[0]),Le(a[1])))},Qw=(e,o,t,n)=>Jw(e,o,t,n),ev=(e,o,t,n)=>{let r=Qw(e,o,t,n),i=qw(r,n).filter(c=>!(c.length===1&&jw(c[0]))).map(c=>Zh(c).map(p=>Le(p))),a=i.sort((c,p)=>c[0]-p[0]),l=[],s=0;e:for(let c=0;c<a.length;c++){let p=a[c];for(let u=c+1;u<a.length;u++){if(++s>Kw)break e;let f=a[u],[,b,x,y]=p,[E,w,,v]=f;x<E&&pd(Vt(b,y),Vt(w,v))&&l.push({startBounds:p,endBounds:f,startSide:[H(x,b),H(x,y)],endSide:[H(E,w),H(E,v)],length:E-x,overlap:md(Vt(b,y),Vt(w,v))})}}let m=i.sort((c,p)=>c[1]-p[1]),d=[];s=0;e:for(let c=0;c<m.length;c++){let p=m[c];for(let u=c+1;u<m.length;u++){if(++s>Kw)break e;let f=m[u],[b,,x,y]=p,[E,w,v]=f;y<w&&pd(Vt(b,x),Vt(E,v))&&d.push({startBounds:p,endBounds:f,startSide:[H(b,y),H(x,y)],endSide:[H(E,w),H(v,w)],length:w-y,overlap:md(Vt(b,x),Vt(E,v))})}}return{horizontalGaps:l,verticalGaps:d}},Zw=(e,o,t,n,r,i,a)=>{if(!Wo({app:t,event:n,selectedElements:e}))return[];if(e.length===0)return[];let l=Xt.getVisibleGaps();if(l){let{horizontalGaps:s,verticalGaps:m}=l,[d,c,p,u]=$h(e,o).map(x=>Le(x)),f=(d+p)/2,b=(c+u)/2;for(let x of s){if(!pd(Vt(c,u),x.overlap))continue;let y=x.startSide[0][0]+x.length/2,E=Le(y-f);if(x.length>p-d&&Math.abs(E)<=a.x){Math.abs(E)<a.x&&(r.length=0),a.x=Math.abs(E);let k={type:"gap",direction:"center_horizontal",gap:x,offset:E};r.push(k);continue}let[,,v]=x.endBounds,C=d-v,S=Le(x.length-C);if(Math.abs(S)<=a.x){Math.abs(S)<a.x&&(r.length=0),a.x=Math.abs(S);let k={type:"gap",direction:"side_right",gap:x,offset:S};r.push(k);continue}let[L,,,]=x.startBounds,P=L-p,B=Le(P-x.length);if(Math.abs(B)<=a.x){Math.abs(B)<a.x&&(r.length=0),a.x=Math.abs(B);let k={type:"gap",direction:"side_left",gap:x,offset:B};r.push(k);continue}}for(let x of m){if(!pd(Vt(d,p),x.overlap))continue;let y=x.startSide[0][1]+x.length/2,E=Le(y-b);if(x.length>u-c&&Math.abs(E)<=a.y){Math.abs(E)<a.y&&(i.length=0),a.y=Math.abs(E);let k={type:"gap",direction:"center_vertical",gap:x,offset:E};i.push(k);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 k={type:"gap",direction:"side_top",gap:x,offset:S};i.push(k);continue}let[,,,L]=x.endBounds,P=Le(c-L),B=x.length-P;if(Math.abs(B)<=a.y){Math.abs(B)<a.y&&(i.length=0),a.y=Math.abs(B);let k={type:"gap",direction:"side_bottom",gap:x,offset:B};i.push(k);continue}}}},tv=(e,o,t,n)=>{let r=Qw(e,o,t,n);return qw(r,n).filter(i=>!(i.length===1&&jw(i[0]))).flatMap(i=>cl(i,n))},Ri=(e,o,t,n,r,i,a)=>{if(!Wo({app:t,event:n,selectedElements:e})||e.length===0&&o.length===0)return[];let l=Xt.getReferenceSnapPoints();if(l)for(let s of o)for(let m of l){let d=m[0]-s[0],c=m[1]-s[1];Math.abs(d)<=a.x&&(Math.abs(d)<a.x&&(r.length=0),r.push({type:"point",points:[s,m],offset:d}),a.x=Math.abs(d)),Math.abs(c)<=a.y&&(Math.abs(c)<a.y&&(i.length=0),i.push({type:"point",points:[s,m],offset:c}),a.y=Math.abs(c))}},ov=(e,o,t,n,r)=>{let i=t.state,a=f_(e,i);if(!Wo({app:t,event:n,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=[],m=ud(i.zoom.value),d={x:m,y:m},c=cl(a,r,{dragOffset:o});Ri(a,c,t,n,l,s,d),Zw(a,o,t,n,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)};Ri(a,cl(a,r,{dragOffset:u}),t,n,l,s,d),Zw(a,u,t,n,l,s,d);let f=jh(l,s),b=y_(a,u,[...l,...s].filter(x=>x.type==="gap"));return{snapOffset:p,snapLines:[...f,...b]}},Le=e=>Math.round(e*10**6)/10**6,$w=e=>{let o=new Map;for(let t of e){let n=t.join(",");o.has(n)||o.set(n,t)}return Array.from(o.values())},jh=(e,o)=>{let t={},n={};if(e.length>0){for(let r of e)if(r.type==="point"){let i=Le(r.points[0][0]);t[i]||(t[i]=[]),t[i].push(...r.points.map(a=>H(Le(a[0]),Le(a[1]))))}}if(o.length>0){for(let r of o)if(r.type==="point"){let i=Le(r.points[0][1]);n[i]||(n[i]=[]),n[i].push(...r.points.map(a=>H(Le(a[0]),Le(a[1]))))}}return Object.entries(t).map(([r,i])=>({type:"points",points:$w(i.map(a=>H(Number(r),a[1])).sort((a,l)=>a[1]-l[1]))})).concat(Object.entries(n).map(([r,i])=>({type:"points",points:$w(i.map(a=>H(a[0],Number(r))).sort((a,l)=>a[0]-l[0]))})))},E_=e=>{let o=new Map;for(let t of e){let n=t.points.flat().map(r=>[Le(r)]).join(",");o.has(n)||o.set(n,t)}return Array.from(o.values())},y_=(e,o,t)=>{let[n,r,i,a]=$h(e,o),l=[];for(let s of t){let[m,d,c,p]=s.gap.startBounds,[u,f,b,x]=s.gap.endBounds,y=md(Vt(r,a),s.gap.overlap),E=md(Vt(n,i),s.gap.overlap);switch(s.direction){case"center_horizontal":{if(y){let w=(y[0]+y[1])/2;l.push({type:"gap",direction:"horizontal",points:[H(s.gap.startSide[0][0],w),H(n,w)]},{type:"gap",direction:"horizontal",points:[H(i,w),H(s.gap.endSide[0][0],w)]})}break}case"center_vertical":{if(E){let w=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[H(w,s.gap.startSide[0][1]),H(w,r)]},{type:"gap",direction:"vertical",points:[H(w,a),H(w,s.gap.endSide[0][1])]})}break}case"side_right":{if(y){let w=(y[0]+y[1])/2;l.push({type:"gap",direction:"horizontal",points:[H(c,w),H(u,w)]},{type:"gap",direction:"horizontal",points:[H(b,w),H(n,w)]})}break}case"side_left":{if(y){let w=(y[0]+y[1])/2;l.push({type:"gap",direction:"horizontal",points:[H(i,w),H(m,w)]},{type:"gap",direction:"horizontal",points:[H(c,w),H(u,w)]})}break}case"side_top":{if(E){let w=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[H(w,a),H(w,d)]},{type:"gap",direction:"vertical",points:[H(w,p),H(w,f)]})}break}case"side_bottom":{if(E){let w=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[H(w,p),H(w,f)]},{type:"gap",direction:"vertical",points:[H(w,x),H(w,r)]})}break}}}return E_(l.map(s=>({...s,points:s.points.map(m=>H(Le(m[0]),Le(m[1])))})))},qh=(e,o,t,n,r,i)=>{if(!Wo({event:n,selectedElements:e,app:t})||e.length===0||e.length===1&&!x_(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,l,s,m]=Zh(o);i&&(i.includes("e")?s+=r.x:i.includes("w")&&(a+=r.x),i.includes("n")?l+=r.y:i.includes("s")&&(m+=r.y));let d=[];if(i)switch(i){case"e":{d.push(H(s,l),H(s,m));break}case"w":{d.push(H(a,l),H(a,m));break}case"n":{d.push(H(a,l),H(s,l));break}case"s":{d.push(H(a,m),H(s,m));break}case"ne":{d.push(H(s,l));break}case"nw":{d.push(H(a,l));break}case"se":{d.push(H(s,m));break}case"sw":{d.push(H(a,m));break}}let c=ud(t.state.zoom.value),p={x:c,y:c},u=[],f=[];Ri(o,d,t,n,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,y,E,w]=Zh(e).map(S=>Le(S)),v=[H(x,y),H(x,w),H(E,y),H(E,w)];Ri(e,v,t,n,u,f,p);let C=jh(u,f);return{snapOffset:b,snapLines:C}},nv=(e,o,t,n,r,i)=>{if(!Wo({event:t,selectedElements:[e],app:o}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[H(n.x+r.x,n.y+r.y)],l=ud(o.state.zoom.value),s={x:l,y:l},m=[],d=[];Ri([e],a,o,t,m,d,s);let c={x:m[0]?.offset??0,y:d[0]?.offset??0};s.x=0,s.y=0,m.length=0,d.length=0;let p=cl([e],i,{boundingBoxCorners:!0,omitCenter:!0});Ri([e],p,o,t,m,d,s);let u=jh(m,d);return{snapOffset:c,snapLines:u}},rv=(e,o,t,n,r)=>{if(!Wo({event:n,selectedElements:[],app:o}))return{originOffset:{x:0,y:0},snapLines:[]};let i=Jw(e,[],o.state,r),a=ud(o.state.zoom.value),l={x:a,y:a},s=[],m=[];for(let d of i){let c=cl([d],r);for(let p of c){let u=p[0]-t.x;Math.abs(u)<=Math.abs(l.x)&&(Math.abs(u)<Math.abs(l.x)&&(m.length=0),m.push({type:"pointer",points:[p,H(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,H(t.x,p[1])],direction:"horizontal"}),l.y=f)}}return{originOffset:{x:m.length>0?m[0].points[0][0]-t.x:0,y:s.length>0?s[0].points[0][1]-t.y:0},snapLines:[...m,...s]}},iv=e=>e===mr.rectangle||e===mr.ellipse||e===mr.diamond||e===mr.frame||e===mr.magicframe||e===mr.image||e===mr.text;import{pointFrom as hd}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as w_,DEFAULT_FONT_SIZE as v_,TEXT_ALIGN as T_,VERTICAL_ALIGN as I_,getSizeFromPoints as C_,randomId as S_,arrayToMap as k_,assertNever as Jh,cloneJSON as sv,getFontString as M_,isDevEnv as P_,toBrandedType as L_,getLineHeight as A_}from"@excalidraw/common";import{bindLinearElement as av}from"@excalidraw/element";import{newArrowElement as D_,newElement as Qh,newFrameElement as __,newImageElement as R_,newLinearElement as N_,newMagicFrameElement as B_,newTextElement as fd}from"@excalidraw/element";import{measureText as F_,normalizeText as O_}from"@excalidraw/element";import{isArrowElement as z_}from"@excalidraw/element";import{syncInvalidIndices as H_}from"@excalidraw/element";import{redrawTextBoundingBox as G_}from"@excalidraw/element";import{LinearElementEditor as U_}from"@excalidraw/element";import{getCommonBounds as Y_}from"@excalidraw/element";import{Scene as W_}from"@excalidraw/element";var gd={width:100,height:0},wn=100,V_=(e,o,t)=>{let n=fd({x:0,y:0,textAlign:T_.CENTER,verticalAlign:I_.MIDDLE,...o,containerId:e.id,strokeColor:o.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:n.id})}),G_(n,e,t),[e,n]},lv=(e,o,t,n,r)=>{let i,a;if(Object.assign(e,{startBinding:e?.startBinding||null,endBinding:e.endBinding||null}),o){let d=o?.width??wn,c=o?.height??wn,p;o.id&&(p=n.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-c/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=fd({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=Qh({x:u,y:f,width:d,height:c,...p,...o,type:b});break}default:Jh(e,`Unhandled element start type "${o.type}"`,!0)}av(e,i,"start",r)}}if(t){let d=t?.height??wn,c=t?.width??wn,p;t.id&&(p=n.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=fd({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=Qh({x:u,y:f,width:c,height:d,...p,...t,type:b});break}default:Jh(e,`Unhandled element end type "${b}"`,!0)}av(e,a,"end",r)}}if(e.points.length<2)return{linearElement:e,startBoundElement:i,endBoundElement:a};let l=e.points.length-1,s=.5,m=sv(e.points);return e.points[l][0]>e.points[l-1][0]&&(m[0][0]=s,m[l][0]-=s),e.points[l][0]<e.points[l-1][0]&&(m[0][0]=-s,m[l][0]+=s),e.points[l][1]>e.points[l-1][1]&&(m[0][1]=s,m[l][1]-=s),e.points[l][1]<e.points[l-1][1]&&(m[0][1]=-s,m[l][1]+=s),Object.assign(e,U_.getNormalizeElementPointsAndCoords({...e,points:m})),{linearElement:e,startBoundElement:i,endBoundElement:a}},eg=class{constructor(){I(this,"excalidrawElements",new Map);I(this,"add",o=>{o&&this.excalidrawElements.set(o.id,o)});I(this,"getElements",()=>H_(Array.from(this.excalidrawElements.values())));I(this,"getElementsMap",()=>L_(k_(this.getElements())));I(this,"getElement",o=>this.excalidrawElements.get(o))}},Ni=(e,o)=>{if(!e)return[];let t=sv(e),n=new eg,r=new Map,i=new Map;for(let s of t){let m,d=s.id;switch(o?.regenerateIds!==!1&&Object.assign(s,{id:S_()}),s.type){case"rectangle":case"ellipse":case"diamond":{let p=s?.label?.text&&s.width===void 0?0:s?.width||wn,u=s?.label?.text&&s.height===void 0?0:s?.height||wn;m=Qh({...s,width:p,height:u});break}case"line":{let p=s.width||gd.width,u=s.height||gd.height;m=N_({width:p,height:u,points:[hd(0,0),hd(p,u)],...s});break}case"arrow":{let p=s.width||gd.width,u=s.height||gd.height;m=D_({width:p,height:u,endArrowhead:"arrow",points:[hd(0,0),hd(p,u)],...s,type:"arrow"}),Object.assign(m,C_(m.points));break}case"text":{let p=s?.fontFamily||w_,u=s?.fontSize||v_,f=s?.lineHeight||A_(p),b=s.text??"",x=O_(b),y=F_(x,M_({fontFamily:p,fontSize:u}),f);m=fd({width:y.width,height:y.height,fontFamily:p,fontSize:u,...s});break}case"image":{m=R_({width:s?.width||wn,height:s?.height||wn,...s});break}case"frame":{m=__({x:0,y:0,...s});break}case"magicframe":{m=B_({x:0,y:0,...s});break}case"freedraw":case"iframe":case"embeddable":{m=s;break}default:m=s,Jh(s,`Unhandled element type "${s.type}"`,!0)}n.getElement(m.id)?console.error(`Duplicate id found for ${m.id}`):(n.add(m),r.set(m.id,s),d&&i.set(d,m.id))}let a=n.getElementsMap(),l=new W_(a);for(let[s,m]of r){let d=n.getElement(s);switch(m.type){case"rectangle":case"ellipse":case"diamond":case"arrow":{if(m.label?.text){let[c,p]=V_(d,m?.label,l);if(n.add(c),n.add(p),z_(c)){let u=m.type==="arrow"?m?.start:void 0,f=m.type==="arrow"?m?.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:y}=lv(c,u,f,n,l);c=b,n.add(b),n.add(x),n.add(y)}}else switch(m.type){case"arrow":{let{start:c,end:p}=m;if(c&&c.id){let x=i.get(c.id);Object.assign(c,{id:x})}if(p&&p.id){let x=i.get(p.id);Object.assign(p,{id:x})}let{linearElement:u,startBoundElement:f,endBoundElement:b}=lv(d,c,p,n,l);n.add(u),n.add(f),n.add(b);break}}break}}}for(let[s,m]of r){if(m.type!=="frame"&&m.type!=="magicframe")continue;let d=n.getElement(s);if(!d)throw new Error(`Excalidraw element with id ${s} doesn't exist`);let c=[];m.children.forEach(C=>{let S=i.get(C);if(!S)throw new Error(`Element with ${C} wasn't mapped correctly`);let L=n.getElement(S);if(!L)throw new Error(`Frame element with id ${S} doesn't exist`);Object.assign(L,{frameId:d.id}),L?.boundElements?.forEach(P=>{let B=n.getElement(P.id);if(!B)throw new Error(`Bound element with id ${P.id} doesn't exist`);Object.assign(B,{frameId:d.id}),c.push(B)}),c.push(L)});let[p,u,f,b]=Y_(c),x=10;p=p-x,u=u-x,f=f+x,b=b+x;let y=d?.x||p,E=d?.y||u,w=d?.width||f-p,v=d?.height||b-u;Object.assign(d,{x:y,y:E,width:w,height:v}),P_()&&m.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 n.getElements()};import{isElementInViewport as wR}from"@excalidraw/element";import{memoize as vR,toBrandedType as TR}from"@excalidraw/common";import{pointFrom as Q_,pointsEqual as eR}from"@excalidraw/math";import xd from"open-color";import{arrayToMap as tR,DEFAULT_TRANSFORM_HANDLE_SPACING as sg,FRAME_STYLE as gv,invariant as fv,THEME as oR,throttleRAF as nR}from"@excalidraw/common";import{FIXED_BINDING_DISTANCE as og,maxBindingGap as vv}from"@excalidraw/element";import{LinearElementEditor as vn}from"@excalidraw/element";import{getOmitSidesForDevice as ng,getTransformHandles as rR,getTransformHandlesFromCoords as iR,shouldShowBoundingBox as aR}from"@excalidraw/element";import{isElbowArrow as dl,isFrameLikeElement as bv,isImageElement as xv,isLinearElement as lR,isLineElement as sR,isTextElement as Ev}from"@excalidraw/element";import{renderSelectionElement as cR}from"@excalidraw/element";import{getElementsInGroup as ag,getSelectedGroupIds as dR,isSelectedViaGroup as mR,selectGroupsFromGivenElements as pR}from"@excalidraw/element";import{getCommonBounds as lg,getElementAbsoluteCoords as ml}from"@excalidraw/element";import{pointFrom as dt}from"@excalidraw/math";import{THEME as X_}from"@excalidraw/common";var K_="#ff6b6b",Z_="#ff0000",cv=1,dv=2,mv=(e,o)=>{if(!o.snapLines.length)return;let t=o.theme===X_.LIGHT||o.zenModeEnabled?K_:Z_,n=(o.zenModeEnabled?cv*1.5:cv)/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY);for(let r of o.snapLines)r.type==="pointer"?(e.lineWidth=n,e.strokeStyle=t,j_(r,e,o)):r.type==="gap"?(e.lineWidth=n,e.strokeStyle=t,q_(r.points[0],r.points[1],r.direction,o,e)):r.type==="points"&&(e.lineWidth=n,e.strokeStyle=t,$_(r,e,o));e.restore()},$_=(e,o,t)=>{if(!t.zenModeEnabled){let n=e.points[0],r=e.points[e.points.length-1];Kt(n,r,o)}for(let n of e.points)pv(n,t,o)},j_=(e,o,t)=>{pv(e.points[0],t,o),t.zenModeEnabled||Kt(e.points[0],e.points[1],o)},pv=([e,o],t,n)=>{n.save();let r=(t.zenModeEnabled?dv*1.5:dv)/t.zoom.value;n.beginPath(),n.moveTo(e-r,o-r),n.lineTo(e+r,o+r),n.moveTo(e+r,o-r),n.lineTo(e-r,o+r),n.stroke(),n.restore()},Kt=(e,o,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(o[0],o[1]),t.stroke()},q_=(e,o,t,n,r)=>{let i=8/n.zoom.value,a=i/2,l=i/4;if(t==="horizontal"){let s=[(e[0]+o[0])/2,e[1]];n.zenModeEnabled||Kt(dt(e[0],e[1]-i),dt(e[0],e[1]+i),r),Kt(dt(s[0]-l,s[1]-a),dt(s[0]-l,s[1]+a),r),Kt(dt(s[0]+l,s[1]-a),dt(s[0]+l,s[1]+a),r),n.zenModeEnabled||(Kt(dt(o[0],o[1]-i),dt(o[0],o[1]+i),r),Kt(e,o,r))}else{let s=[e[0],(e[1]+o[1])/2];n.zenModeEnabled||Kt(dt(e[0]-i,e[1]),dt(e[0]+i,e[1]),r),Kt(dt(s[0]-a,s[1]-l),dt(s[0]+a,s[1]-l),r),Kt(dt(s[0]-a,s[1]+l),dt(s[0]+a,s[1]+l),r),n.zenModeEnabled||(Kt(dt(o[0]-i,o[1]),dt(o[0]+i,o[1]),r),Kt(e,o,r))}};import{getGlobalCSSVariable as bd}from"@excalidraw/common";import{getCommonBounds as J_}from"@excalidraw/element";var so=4,It=6,uv="rgba(0,0,0,0.3)",hv=(e,o,t,n)=>{if(!e.size)return{horizontal:null,vertical:null};let[r,i,a,l]=J_(e),s=o/n.zoom.value,m=t/n.zoom.value,d={top:parseInt(bd("sat"))||0,bottom:parseInt(bd("sab"))||0,left:parseInt(bd("sal"))||0,right:parseInt(bd("sar"))||0},c=Do().rtl,p=-n.scrollX+d.left,u=-n.scrollY+d.top,f=p+s-d.right,b=u+m-d.bottom,x=Math.min(r,p),y=Math.min(i,u),E=Math.max(a,f),w=Math.max(l,b),v=a-r,C=l-i,S=E-x,L=w-y,P=Math.max(so*2,d.left+d.right)+It*2,B=o*(s/S)-P,k=Math.max(so*2,d.top+d.bottom)+It*2,A=t*(m/L)-k,F=S>v?S*n.zoom.value/(B+P):o/(B+P),Y=L>C?L*n.zoom.value/(A+k):t/(A+k);return{horizontal:p===x&&f===E?null:{x:Math.max(d.left,so)+It+(p-x)/S*o,y:t-It-Math.max(so,d.bottom),width:B,height:It,deltaMultiplier:F},vertical:u===y&&b===w?null:{x:c?Math.max(d.left,so):o-It-Math.max(d.right,so),y:Math.max(d.top,so)+It+(u-y)/L*t,width:It,height:A,deltaMultiplier:Y}}},tg=(e,o,t)=>{let[n,r]=[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:n||r,isOverHorizontal:n,isOverVertical:r}};var uR=(e,o)=>{fv(o.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=o.selectedLinearElement;fv(t,"midPointCoords is null"),e.save(),e.translate(o.scrollX,o.scrollY),Tv(t,e,o),e.restore()},hR=(e,o,t)=>{let{elementId:n,hoverPointIndex:r}=o.selectedLinearElement;if(o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(r))return;let i=vn.getElement(n,t);if(!i)return;let a=vn.getPointAtIndexGlobalCoordinates(i,r,t);e.save(),e.translate(o.scrollX,o.scrollY),Tv(a,e,o),e.restore()},Tv=(e,o,t)=>{o.fillStyle="rgba(105, 101, 219, 0.4)",oa(o,e[0],e[1],vn.POINT_HANDLE_SIZE/t.zoom.value,!1)},rg=(e,o,t,n,r,i,a)=>{e.strokeStyle="#5e5ad8",e.setLineDash([]),e.fillStyle="rgba(255, 255, 255, 0.9)",r?e.fillStyle="rgba(134, 131, 226, 0.9)":i&&(e.fillStyle="rgba(177, 151, 252, 0.7)"),oa(e,t[0],t[1],(a?n*(o.selectedLinearElement?.isEditing?1.5:2):n)/o.zoom.value,!i,!a||r)},gR=(e,o,t,n)=>{let r=vv(o,o.width,o.height,n);switch(e.fillStyle="rgba(0,0,0,.05)",o.type){case"rectangle":case"text":case"image":case"iframe":case"embeddable":case"frame":case"magicframe":w1(e,o,t,r);break;case"diamond":T1(e,r,o,t);break;case"ellipse":{let[i,a,l,s]=ml(o,t),m=l-i,d=s-a;e.strokeStyle="rgba(0,0,0,.05)",e.lineWidth=r-og,v1(e,m+r+og,d+r+og,i+m/2,a+d/2,o.angle);break}}},fR=(e,o,t,n)=>{let[r,i,a]=o,l=vv(a,a.width,a.height,n);e.strokeStyle="rgba(0,0,0,0)",e.fillStyle="rgba(0,0,0,.05)",(i==="both"?[0,-1]:i==="start"?[0]:[-1]).forEach(m=>{let[d,c]=vn.getPointAtIndexGlobalCoordinates(r,m,t);oa(e,d,c,l,!0)})},Iv=(e,o,t)=>{let{angle:n,x1:r,y1:i,x2:a,y2:l,selectionColors:s,cx:m,cy:d,dashed:c,activeEmbeddable:p}=t,u=a-r,f=l-i,x=(t.padding??sg*2)/o.zoom.value,y=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 w=s.length;for(let v=0;v<w;++v)e.strokeStyle=s[v],c&&e.setLineDash([y,E+(y+E)*(w-1)]),e.lineDashOffset=(y+E)*v,na(e,r-x,i-x,u+x*2,f+x*2,m,d,n);e.restore()},bR=(e,o,t,n)=>{let r=Array.isArray(t)?fR:gR;e.save(),e.translate(o.scrollX,o.scrollY),r(e,t,n,o.zoom),e.restore()},xR=(e,o,t,n)=>{let[r,i,a,l]=ml(t,n),s=a-r,m=l-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=gv.strokeWidth/o.zoom.value,e.save(),e.translate(o.scrollX,o.scrollY),na(e,r,i,s,m,r+s/2,i+m/2,t.angle,!1,gv.radius/o.zoom.value),e.restore()},yv=(e,o,t,n)=>{let{colors:r=["rgb(0,118,255)"],dashed:i=!1}=n||{},a=t.filter(d=>d.groupIds.length===0),l=t.filter(d=>d.groupIds.length>0),s=d=>{let[c,p,u,f]=lg(d);return{angle:0,x1:c,x2:u,y1:p,y2:f,selectionColors:r,dashed:i,cx:c+(u-c)/2,cy:p+(f-p)/2,activeEmbeddable:!1}},m=d=>{let c=ag(t,d);return s(c)};Object.entries(pR(l,o)).filter(([d,c])=>c).map(([d,c])=>d).map(d=>m(d)).concat(a.map(d=>s([d]))).forEach(d=>Iv(e,o,d))},ig=(e,o,t,n)=>{if(!o.selectedLinearElement)return;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=1/o.zoom.value;let r=vn.getPointsGlobalCoordinates(t,n),{POINT_HANDLE_SIZE:i}=vn,a=o.selectedLinearElement?.isEditing?i:i/2,l=dl(t),s=sR(t);if(r.forEach((m,d)=>{if(l&&d!==0&&d!==r.length-1)return;let c=d>0&&(d!==r.length-1||!s||!t.polygon)&&eR(m,d===r.length-1?r[0]:r[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),rg(e,o,m,a,p,!1,c)}),dl(t)){let m=t.fixedSegments?.map(d=>d.index)||[];r.slice(0,-1).forEach((d,c)=>{vn.isSegmentTooShort(t,r[c+1],r[c],c,o.zoom)||rg(e,o,Q_((d[0]+r[c+1][0])/2,(d[1]+r[c+1][1])/2),i/2,!1,!m.includes(c+1),!1)})}else vn.getEditorMidPoints(t,n,o).filter((d,c,p)=>d!==null&&!(dl(t)&&(c===0||c===p.length-1))).forEach(d=>{(o.selectedLinearElement?.isEditing||r.length===2)&&rg(e,o,d,i/2,!1,!0,!1)});e.restore()},wv=(e,o,t,n,r)=>{Object.keys(n).forEach(i=>{let a=n[i];if(a!==void 0){let[l,s,m,d]=a;e.save(),e.lineWidth=1/t.zoom.value,o.selectionColor&&(e.strokeStyle=o.selectionColor),i==="rotation"?oa(e,l+m/2,s+d/2,m/2,!0):e.roundRect?(e.beginPath(),e.roundRect(l,s,m,d,2/t.zoom.value),e.fill(),e.stroke()):na(e,l,s,m,d,l+m/2,s+d/2,r,!0),e.restore()}})},ER=(e,o,t,n,r)=>{let[i,a,,,l,s]=ml(n,r),m=3,d=20,c=m/t.zoom.value,p=c/2,u=l-i+c,f=s-a+c,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=c,[[[-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[[w,v],[C,S],[L,P],[B,k],[A,F]]=E;e.save(),e.translate(l,s),e.rotate(n.angle),e.beginPath(),e.moveTo(w+C,v+S),e.lineTo(w+L,v+P),e.stroke(),e.beginPath(),e.moveTo(w+B,v+k),e.lineTo(w+A,v+F),e.stroke(),e.restore()}),e.restore()},yR=(e,o,t,n)=>{o.save();let r=sg*2/t.zoom.value,i=e.width+r*2,a=e.height+r*2,l=e.x+i/2,s=e.y+a/2,m=-(i/2+r),d=-(a/2+r);o.translate(l+t.scrollX,s+t.scrollY),o.rotate(e.angle),o.lineWidth=1/t.zoom.value,o.strokeStyle=n,o.strokeRect(m,d,i,a),o.restore()},Cv=({canvas:e,elementsMap:o,visibleElements:t,selectedElements:n,allElementsMap:r,scale:i,appState:a,renderConfig:l,device:s})=>{if(e===null)return{atLeastOneVisibleElement:!1,elementsMap:o};let[m,d]=Vl(e,i),c=Xl({canvas:e,scale:i,normalizedWidth:m,normalizedHeight:d});c.save(),c.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&&ig(c,a,p,o),a.selectionElement&&!a.isCropping)try{cR(a.selectionElement,c,a,l.selectionColor)}catch(b){console.error(b)}if(a.editingTextElement&&Ev(a.editingTextElement)){let b=r.get(a.editingTextElement.id);b&&!b.autoResize&&yR(b,c,a,l.selectionColor)}if(a.isBindingEnabled&&a.suggestedBindings.filter(b=>b!=null).forEach(b=>{bR(c,a,b,o)}),a.frameToHighlight&&xR(c,a,a.frameToHighlight,o),a.elementsToHighlight&&yv(c,a,a.elementsToHighlight),a.activeLockedId){let b=r.get(a.activeLockedId),x=b?[b]:ag(r,a.activeLockedId);yv(c,a,x,{colors:["#ced4da"],dashed:!0})}let u=n.some(b=>bv(b));if(n.length===1&&a.selectedLinearElement?.isEditing&&a.selectedLinearElement.elementId===n[0].id&&ig(c,a,n[0],o),a.selectedLinearElement){let b=a.selectedLinearElement,x=n.find(y=>y.id===b.elementId);b.segmentMidPointHoveredCoords?uR(c,a):(dl(x)?b.hoverPointIndex===0||b.hoverPointIndex===x.points.length-1:b.hoverPointIndex>=0)&&hR(c,a,o)}if(!a.multiElement&&!a.selectedLinearElement?.isEditing){let b=aR(n,a),x=n.length===1&&lR(n[0]);x&&a.selectedLinearElement?.elementId===n[0].id&&!n[0].locked&&ig(c,a,n[0],o);let y=l.selectionColor||xd.black;if(b){let E=tR(n),w=[];for(let C of o.values()){let S=[],L=l.remoteSelectedElementIds.get(C.id);if(x&&dl(C)&&(C.startBinding||C.endBinding)||(E.has(C.id)&&!mR(a,C)&&S.push(y),L&&S.push(...L.map(P=>rr(P,a.collaborators.get(P))))),S.length){let[P,B,k,A,F,Y]=ml(C,o,!0);w.push({angle:C.angle,x1:P,y1:B,x2:k,y2:A,selectionColors:C.locked?["#ced4da"]:S,dashed:!!L||C.locked,cx:F,cy:Y,activeEmbeddable:a.activeEmbeddable?.element===C&&a.activeEmbeddable.state==="active",padding:C.id===a.croppingElementId||xv(C)?0:void 0})}}let v=C=>{let S=ag(o,C),[L,P,B,k]=lg(S);w.push({angle:0,x1:L,x2:B,y1:P,y2:k,selectionColors:S.some(A=>A.locked)?["#ced4da"]:[xd.black],dashed:!0,cx:L+(B-L)/2,cy:P+(k-P)/2,activeEmbeddable:!1})};for(let C of dR(a))v(C);a.editingGroupId&&v(a.editingGroupId),w.forEach(C=>Iv(c,a,C))}if(c.save(),c.translate(a.scrollX,a.scrollY),n.length===1){c.fillStyle=xd.white;let E=rR(n[0],a.zoom,o,"mouse",ng(s));if(!a.viewModeEnabled&&b&&!Ev(a.editingTextElement)&&!a.croppingElementId&&wv(c,l,a,E,n[0].angle),a.croppingElementId&&!a.isCropping){let w=o.get(a.croppingElementId);w&&xv(w)&&ER(c,l,a,w,o)}}else if(n.length>1&&!a.isRotating&&!n.some(E=>E.locked)){let E=sg*2/a.zoom.value;c.fillStyle=xd.white;let[w,v,C,S]=lg(n,o),L=c.getLineDash();c.setLineDash([2/a.zoom.value]);let P=c.lineWidth;c.lineWidth=1/a.zoom.value,c.strokeStyle=y,na(c,w-E,v-E,C-w+E*2,S-v+E*2,(w+C)/2,(v+S)/2,0),c.lineWidth=P,c.setLineDash(L);let B=iR([w,v,C,S,(w+C)/2,(v+S)/2],0,a.zoom,"mouse",u?{...ng(s),rotation:!0}:ng(s));n.some(k=>!k.locked)&&wv(c,l,a,B,0)}c.restore()}a.searchMatches?.matches.forEach(({id:b,focus:x,matchedLines:y})=>{let E=o.get(b);if(E){let[w,v,,,C,S]=ml(E,o,!0);c.save(),a.theme===oR.LIGHT?x?c.fillStyle="rgba(255, 124, 0, 0.4)":c.fillStyle="rgba(255, 226, 0, 0.4)":x?c.fillStyle="rgba(229, 82, 0, 0.4)":c.fillStyle="rgba(99, 52, 0, 0.4)";let L=bv(E)?a.zoom.value:1;c.translate(a.scrollX,a.scrollY),c.translate(C,S),c.rotate(E.angle),y.forEach(P=>{(P.showOnCanvas||x)&&c.fillRect(w+P.offsetX/L-C,v+P.offsetY/L-S,P.width/L,P.height/L)}),c.restore()}}),mv(c,a),c.restore(),NE({context:c,renderConfig:l,appState:a,normalizedWidth:m,normalizedHeight:d});let f;return l.renderScrollbars&&(f=hv(o,m,d,a),c.save(),c.fillStyle=uv,c.strokeStyle="rgba(255,255,255,0.8)",[f.horizontal,f.vertical].forEach(b=>{b&&cc(c,b.x,b.y,b.width,b.height,It/2)}),c.restore()),{scrollBars:f,atLeastOneVisibleElement:t.length>0,elementsMap:o}},cg=nR(e=>{let o=Cv(e);e.callback?.(o)},{trailing:!0}),Sv=(e,o)=>{if(o){cg(e);return}let t=Cv(e);return e.callback(t),t};var pl=class{constructor(o){I(this,"scene");I(this,"getRenderableElements",(()=>{let o=({elementsMap:n,zoom:r,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s,height:m,width:d})=>{let c=[];for(let p of n.values())wR(p,d,m,{zoom:r,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s},n)&&c.push(p);return c},t=({elements:n,editingTextElement:r,newElementId:i})=>{let a=TR(new Map);for(let l of n)i!==l.id&&(!r||r.type!=="text"||l.id!==r.id)&&a.set(l.id,l);return a};return vR(({zoom:n,offsetLeft:r,offsetTop:i,scrollX:a,scrollY:l,height:s,width:m,editingTextElement:d,newElementId:c,sceneNonce:p})=>{let u=this.scene.getNonDeletedElements(),f=t({elements:u,editingTextElement:d,newElementId:c}),b=o({elementsMap:f,zoom:n,offsetLeft:r,offsetTop:i,scrollX:a,scrollY:l,height:s,width:m});return{elementsMap:f,visibleElements:b}})})());this.scene=o}destroy(){cg.cancel(),C1.cancel(),this.getRenderableElements.clear()}};import{sceneCoordsToViewportCoords as IR}from"@excalidraw/common";import{getElementAbsoluteCoords as CR}from"@excalidraw/element";import{jsx as MR}from"react/jsx-runtime";var SR=5,kR=(e,o,t)=>{let[n,r]=CR(e,t),{x:i,y:a}=IR({sceneX:n+e.width,sceneY:r},o),l=i-o.offsetLeft+10,s=a-o.offsetTop;return{x:l,y:s}},dg=({children:e,element:o,elementsMap:t})=>{let n=bo();if(n.contextMenu||n.newElement||n.resizingElement||n.isRotating||n.openMenu||n.viewModeEnabled)return null;let{x:r,y:i}=kR(o,n,t);return MR("div",{className:"excalidraw-canvas-buttons",style:{top:`${i}px`,left:`${r}px`,padding:SR},children:e})};import{DEFAULT_LASER_COLOR as DR,easeOut as Mv}from"@excalidraw/common";import{LaserPointer as PR}from"@excalidraw/laser-pointer";import{SVG_NS as kv,getSvgPathFromStroke as LR,sceneCoordsToViewportCoords as AR}from"@excalidraw/common";var Vo=class{constructor(o,t,n){this.animationFrameHandler=o;this.app=t;this.options=n;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(kv,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(kv,"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 n=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[n-1][0]===o&&this.currentTrail.originalPoints[n-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 n of this.pastTrails)o.push(this.drawTrail(n,this.app.state));if(this.currentTrail){let n=this.drawTrail(this.currentTrail,this.app.state);o.push(n)}this.pastTrails=this.pastTrails.filter(n=>n.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 n=o.getStrokeOutline(o.options.size/t.zoom.value).map(([i,a])=>{let l=AR({sceneX:i,sceneY:a},t);return[l.x,l.y]}),r=this.trailAnimation?n.slice(0,n.length/2):n;return LR(r,!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 Vo(o,t,{...this.getTrailOptions(),fill:()=>DR})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:o=>{let r=Math.max(0,1-(performance.now()-o.pressure)/1e3),i=(50-Math.min(50,o.totalLength-o.currentIndex))/50;return Math.min(Mv(i),Mv(r))}}}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 n;this.collabTrails.has(o)?n=this.collabTrails.get(o):(n=new Vo(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>t.pointer?.laserColor||rr(o,t)}),n.start(this.container),this.collabTrails.set(o,n)),t.pointer&&t.pointer.tool==="laser"&&(t.button==="down"&&!n.hasCurrentTrail&&n.startPath(t.pointer.x,t.pointer.y),t.button==="down"&&n.hasCurrentTrail&&!n.hasLastPoint(t.pointer.x,t.pointer.y)&&n.addPointToPath(t.pointer.x,t.pointer.y),t.button==="up"&&n.hasCurrentTrail&&(n.addPointToPath(t.pointer.x,t.pointer.y),n.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 _R}from"react";import{unstable_batchedUpdates as Pv}from"react-dom";import{throttleRAF as RR}from"@excalidraw/common";var Ae=e=>o=>{Pv(e,o)},yd=e=>RR(o=>{Pv(e,o)}),Bi=(()=>{let e;try{let t=_R.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 mg,KEYS as ul,CLASSES as pg,POINTER_BUTTON as NR,isWritableElement as BR,getFontString as Lv,getFontFamilyString as Av,isTestEnv as Dv,MIME_TYPES as FR}from"@excalidraw/common";import{originalContainerCache as OR,updateOriginalContainerCache as _v}from"@excalidraw/element";import{LinearElementEditor as zR}from"@excalidraw/element";import{bumpVersion as HR}from"@excalidraw/element";import{getBoundTextElementId as GR,getContainerElement as ug,getTextElementAngle as UR,redrawTextBoundingBox as YR,getBoundTextMaxHeight as WR,getBoundTextMaxWidth as Rv,computeContainerDimensionForBoundText as Nv,computeBoundTextPosition as VR,getBoundTextElement as XR}from"@excalidraw/element";import{getTextWidth as KR}from"@excalidraw/element";import{normalizeText as Bv}from"@excalidraw/element";import{wrapText as ZR}from"@excalidraw/element";import{isArrowElement as wd,isBoundToContainer as $R,isTextElement as Fv}from"@excalidraw/element";var jR=(e,o,t,n,r,i)=>{let{zoom:a}=n,l=180*t/Math.PI,s=e*(a.value-1)/2,m=o*(a.value-1)/2;return e>r&&a.value!==1&&(s=r*(a.value-1)/2),o>i&&a.value!==1&&(m=i*(a.value-1)/2),`translate(${s}px, ${m}px) scale(${a.value}) rotate(${l}deg)`},Ov=({id:e,onChange:o,onSubmit:t,getViewportCoords:n,element:r,canvas:i,excalidrawContainer:a,app:l,autoSelect:s=!0})=>{let m=(_,R)=>{if(!R.style.fontFamily||!R.style.fontSize)return!1;let W=R.style.fontFamily.replace(/"/g,"");return Av({fontFamily:_.fontFamily})!==W||`${_.fontSize}px`!==R.style.fontSize},d=()=>{let _=l.state,R=l.scene.getElement(e);if(!R)return;let{textAlign:W,verticalAlign:X}=R,G=l.scene.getNonDeletedElementsMap();if(R&&Fv(R)){let me=R.x,ue=R.y,pe=ug(R,l.scene.getNonDeletedElementsMap()),it=R.width,uo=R.height,yr=R.width,wr=R.height;if(pe&&R.containerId){if(wd(pe)){let qo=zR.getBoundTextElementPosition(pe,R,G);me=qo.x,ue=qo.y}let Gl=m(R,c),Qi;if(Gl?Qi=_v(pe.id,pe.height):(Qi=OR[pe.id],Qi||(Qi=_v(pe.id,pe.height))),yr=Rv(pe,R),wr=WR(pe,R),!wd(pe)&&uo>wr){let qo=Nv(uo,pe.type);l.scene.mutateElement(pe,{height:qo});return}else if(!wd(pe)&&pe.height>Qi.height&&uo<wr){let qo=Nv(uo,pe.type);l.scene.mutateElement(pe,{height:qo})}else{let{x:qo,y:kC}=VR(pe,R,G);me=qo,ue=kC}}let[Hl,Im]=n(me,ue),CC=c.selectionStart,Cm=c.selectionEnd,c1=c.value.length;if(CC===Cm&&Cm!==c1){let Gl=c1-Cm;c.selectionStart=c.value.length-Gl,c.selectionEnd=c.value.length-Gl}pe?it+=.5:(yr=(_.width-8-Hl)/_.zoom.value,it=Math.min(it,yr)),uo*=1.05;let SC=Lv(R),d1=(_.height-Im)/_.zoom.value;Object.assign(c.style,{font:SC,lineHeight:R.lineHeight,width:`${it}px`,height:`${uo}px`,left:`${Hl}px`,top:`${Im}px`,transform:jR(it,uo,UR(R,pe),_,yr,d1),textAlign:W,verticalAlign:X,color:R.strokeColor,opacity:R.opacity/100,filter:"var(--theme-filter)",maxHeight:`${d1}px`}),c.scrollTop=0,Dv()&&(c.style.fontFamily=Av(R)),l.scene.mutateElement(R,{x:me,y:ue})}},c=document.createElement("textarea");c.dir="auto",c.tabIndex=0,c.dataset.type="wysiwyg",c.wrap="off",c.classList.add("excalidraw-wysiwyg");let p="pre",u="normal";($R(r)||!r.autoResize)&&(p="pre-wrap",u="break-word"),Object.assign(c.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"}),c.value=r.originalText,d(),o&&(c.onpaste=async _=>{let R=(await Oa(_)).findByType(FR.text);if(!R)return;let W=Bv(R.value);if(!W)return;let X=ug(r,l.scene.getNonDeletedElementsMap()),G=Lv({fontSize:l.state.currentItemFontSize,fontFamily:l.state.currentItemFontFamily});if(X){let me=XR(X,l.scene.getNonDeletedElementsMap()),ue=ZR(`${c.value}${W}`,G,Rv(X,me)),pe=KR(ue,G);c.style.width=`${pe}px`}},c.oninput=()=>{let _=Bv(c.value);if(c.value!==_){let R=c.selectionStart;c.value=_,c.selectionStart=R,c.selectionEnd=R}o(c.value)}),c.onkeydown=_=>{if(!_.shiftKey&&Xs.keyTest(_))_.preventDefault(),l.actionManager.executeAction(Xs),d();else if(!_.shiftKey&&Ks.keyTest(_))_.preventDefault(),l.actionManager.executeAction(Ks),d();else if(!_.shiftKey&&Zs.keyTest(_))_.preventDefault(),l.actionManager.executeAction(Zs),d();else if(Xp.keyTest(_))l.actionManager.executeAction(Xp);else if(Kp.keyTest(_))l.actionManager.executeAction(Kp);else if(_.key===ul.ESCAPE)_.preventDefault(),C=!0,S();else if(or.keyTest(_))_.preventDefault(),S(),l.actionManager.executeAction(or);else if(_.key===ul.ENTER&&_[ul.CTRL_OR_CMD]){if(_.preventDefault(),_.isComposing||_.keyCode===229)return;C=!0,S()}else if(_.key===ul.TAB||_[ul.CTRL_OR_CMD]&&(_.code===mg.BRACKET_LEFT||_.code===mg.BRACKET_RIGHT)){if(_.preventDefault(),_.isComposing)return;_.shiftKey||_.code===mg.BRACKET_LEFT?E():y(),c.dispatchEvent(new Event("input"))}};let f=4,b=" ".repeat(f),x=new RegExp(`^ {1,${f}}`),y=()=>{let{selectionStart:_,selectionEnd:R}=c,W=w(),X=c.value;W.forEach(G=>{let me=X.slice(0,G),ue=X.slice(G);X=`${me}${b}${ue}`}),c.value=X,c.selectionStart=_+f,c.selectionEnd=R+f*W.length},E=()=>{let{selectionStart:_,selectionEnd:R}=c,W=w(),X=[],G=c.value;W.forEach(me=>{let ue=G.slice(me,me+f).match(x);if(ue){let pe=G.slice(0,me),it=G.slice(me+ue[0].length);G=`${pe}${it}`,X.push(me)}}),c.value=G,X.length&&(_>X[X.length-1]?c.selectionStart=Math.max(_-f,X[X.length-1]):c.selectionStart=_,c.selectionEnd=Math.max(c.selectionStart,R-f*X.length))},w=()=>{let{selectionStart:_,selectionEnd:R,value:W}=c,X=W.slice(0,_).match(/[^\n]*$/)[0].length;return _=_-X,W.slice(_,R).split(`
|
|
16
|
+
`).reduce((me,ue,pe,it)=>me.concat(pe?me[pe-1]+it[pe-1].length+1:_),[]).reverse()},v=_=>{_.target instanceof HTMLCanvasElement&&(_.preventDefault(),_.stopPropagation())},C=!1,S=()=>{if(Y)return;Y=!0,L();let _=l.scene.getElement(r.id);if(!_)return;let R=ug(_,l.scene.getNonDeletedElementsMap());if(R){if(c.value.trim()){let W=GR(R);!W||W!==r.id?l.scene.mutateElement(R,{boundElements:(R.boundElements||[]).concat({type:"text",id:r.id})}):wd(R)&&HR(R)}else l.scene.mutateElement(R,{boundElements:R.boundElements?.filter(W=>!Fv(W))});YR(_,R,l.scene)}t({viaKeyboard:C,nextOriginalText:c.value})},L=()=>{c.onblur=null,c.oninput=null,c.onkeydown=null,Q&&Q.disconnect(),window.removeEventListener("resize",d),window.removeEventListener("wheel",v,!0),window.removeEventListener("pointerdown",k),window.removeEventListener("pointerup",P),window.removeEventListener("blur",S),window.removeEventListener("beforeunload",S),A(),F(),c.remove()},P=_=>{window.removeEventListener("pointerup",P);let R=_?.target,W=R instanceof HTMLElement&&R.classList.contains("properties-trigger"),X=(R instanceof HTMLElement||R instanceof SVGElement)&&!!R.closest(".properties-content"),G=(R instanceof HTMLElement||R instanceof SVGElement)&&(!!R.closest(`.${pg.SHAPE_ACTIONS_MENU}`)||!!R.closest(".compact-shape-actions-island"));setTimeout(()=>{G||W||X||(c.onblur=S,c.focus())})},B=()=>{c.onblur=null,window.addEventListener("pointerup",P),window.addEventListener("blur",S)},k=_=>{let R=_?.target;if(_.button===NR.WHEEL){R instanceof HTMLTextAreaElement&&(_.preventDefault(),l.handleCanvasPanUsingWheelOrSpaceDrag(_)),B();return}let W=R instanceof HTMLElement&&R.classList.contains("properties-trigger"),X=(R instanceof HTMLElement||R instanceof SVGElement)&&!!R.closest(".properties-content");(_.target instanceof HTMLElement||_.target instanceof SVGElement)&&(_.target.closest(`.${pg.SHAPE_ACTIONS_MENU}, .${pg.ZOOM_ACTIONS}`)||_.target.closest(".compact-shape-actions-island"))&&!BR(_.target)||W||X?B():_.target instanceof HTMLCanvasElement&&!Dv()&&requestAnimationFrame(()=>{S()})},A=l.scene.onUpdate(()=>{d(),!!document.activeElement?.closest(".properties-content")||c.focus()}),F=l.onScrollChangeEmitter.on(()=>{d()}),Y=!1;s&&c.select(),P();let Q=null;return i&&"ResizeObserver"in window?(Q=new window.ResizeObserver(()=>{d()}),Q.observe(i)):window.addEventListener("resize",d),c.onpointerdown=_=>_.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",k,{capture:!0})}),window.addEventListener("beforeunload",S),a?.querySelector(".excalidraw-textEditorContainer").appendChild(c),S};var zv=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(n=>`\\s*${n}(-beta)?`).join("|")})\\b`).test(e.trim())};import{pointFrom as a9}from"@excalidraw/math";import{getElementLineSegments as l9}from"@excalidraw/element";import{LinearElementEditor as s9}from"@excalidraw/element";import{isFrameLikeElement as c9,isLinearElement as d9,isTextElement as m9}from"@excalidraw/element";import{getFrameChildren as p9}from"@excalidraw/element";import{selectGroupsForSelectedElements as u9}from"@excalidraw/element";import{getContainerElement as h9}from"@excalidraw/element";import{arrayToMap as g9,easeOut as Yv,isShallowEqual as f9}from"@excalidraw/common";import{simplify as qR}from"points-on-curve";import{polygonFromPoints as JR,lineSegment as Hv,polygonIncludesPointNonZero as QR}from"@excalidraw/math";import{computeBoundTextPosition as e9,doBoundsIntersect as t9,getBoundTextElement as o9,getElementBounds as n9,intersectElementWithLineSegment as Gv}from"@excalidraw/element";var Uv=e=>{let{lassoPath:o,elements:t,elementsMap:n,elementsSegments:r,intersectedElements:i,enclosedElements:a,simplifyDistance:l}=e,s=o;l&&(s=qR(o,l));let m=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 m){let u=n9(p,n);t9(d,u)&&!i.has(p.id)&&!a.has(p.id)&&(r9(s,p,r)?a.add(p.id):i9(s,p,n)&&i.add(p.id))}return{selectedElementIds:[...i,...a]}},r9=(e,o,t)=>{let n=JR(e),r=t.get(o.id);return r?r.some(i=>i.some(a=>QR(a,n))):!1},i9=(e,o,t)=>{let n=e.slice(1).map((i,a)=>Hv(e[a],i)).concat([Hv(e[e.length-1],e[0])]),r=o9(o,t);return n.some(i=>Gv(o,t,i,0,!0).length>0||!!r&&Gv({...r,...e9(o,r,t)},t,i,0,!0).length>0)};var vd=class extends Vo{constructor(t,n){super(t,n,{animateTrail:!0,streamline:.4,sizeMapping:r=>{let l=Math.max(0,1-(performance.now()-r.pressure)/(1/0)),s=(5e3-Math.min(5e3,r.totalLength-r.currentIndex))/5e3;return Math.min(Yv(s),Yv(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(n=>{let r=t.reduce((s,m)=>(s[m]=!0,s),{});if(this.keepPreviousSelection)for(let s of Object.keys(n.selectedElementIds))r[s]=!0;for(let[s]of Object.entries(r)){let m=this.app.scene.getNonDeletedElement(s);if(m&&m9(m)){let d=h9(m,this.app.scene.getNonDeletedElementsMap());d&&(r[d.id]=!0,delete r[m.id])}}for(let[s]of Object.entries(r)){let m=this.app.scene.getNonDeletedElement(s);if(m&&c9(m)){let d=p9(this.app.scene.getNonDeletedElementsMap(),m.id);for(let c of d)delete r[c.id]}}let i=u9({editingGroupId:n.editingGroupId,selectedElementIds:r},this.app.scene.getNonDeletedElements(),n,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&&d9(this.app.scene.getNonDeletedElement(a[0]))?new s9(this.app.scene.getNonDeletedElement(a[0]),this.app.scene.getNonDeletedElementsMap()):null}})});I(this,"addPointToPath",(t,n,r=!1)=>{super.addPointToPath(t,n),this.keepPreviousSelection=r,this.updateSelection()});I(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(r=>a9(r[0],r[1])),n={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!f9(n,this.canvasTranslate??{})){this.canvasTranslate=n,this.elementsSegments=new Map;let r=g9(this.app.visibleElements);for(let i of this.app.visibleElements){let a=l9(i,r);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:r}=Uv({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(r)}})}startPath(t,n,r=!1){this.endPath(),super.startPath(t,n),this.intersectedElements.clear(),this.enclosedElements.clear(),this.keepPreviousSelection=r,this.keepPreviousSelection||this.app.setState({selectedElementIds:{},selectedGroupIds:{},selectedLinearElement:null})}endPath(){super.endPath(),super.clearTrails(),this.intersectedElements.clear(),this.enclosedElements.clear(),this.elementsSegments=null}};import{arrayToMap as b9,easeOut as Wv,THEME as x9}from"@excalidraw/common";import{computeBoundTextPosition as E9,doBoundsIntersect as y9,getBoundTextElement as w9,getElementBounds as v9,getElementLineSegments as T9,getFreedrawOutlineAsSegments as I9,getFreedrawOutlinePoints as C9,intersectElementWithLineSegment as Vv,isArrowElement as S9,isFreeDrawElement as Xv,isLineElement as k9,isPointInElement as M9}from"@excalidraw/element";import{lineSegment as P9,lineSegmentsDistance as Kv,pointFrom as Qv,polygon as L9,polygonIncludesPointNonZero as A9}from"@excalidraw/math";import{getElementsInGroup as Zv}from"@excalidraw/element";import{shouldTestInside as D9}from"@excalidraw/element";import{hasBoundTextElement as $v,isBoundToContainer as jv}from"@excalidraw/element";import{getBoundTextElementId as qv}from"@excalidraw/element";var Td=class extends Vo{constructor(t,n){super(t,n,{streamline:.2,size:5,keepHead:!0,sizeMapping:r=>{let l=Math.max(0,1-(performance.now()-r.pressure)/200),s=(10-Math.min(10,r.totalLength-r.currentIndex))/10;return Math.min(Wv(s),Wv(l))},fill:()=>n.state.theme===x9.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,n){this.endPath(),super.startPath(t,n),this.elementsToErase.clear()}addPointToPath(t,n,r=!1){return super.addPointToPath(t,n),this.updateElementsToBeErased(r)}updateElementsToBeErased(t){let n=super.getCurrentTrail()?.originalPoints?.map(l=>Qv(l[0],l[1]))||[];if(n.length<2)return[];let r=P9(n[n.length-1],n[n.length-2]),i=this.app.visibleElements.filter(l=>!l.locked),a=b9(i);for(let l of i)if(t&&this.elementsToErase.has(l.id)){if(Jv(r,l,a,this.app.state.zoom.value)){let m=l.groupIds.at(-1);if(this.groupsToErase.has(m)){let d=Zv(this.app.scene.getNonDeletedElementsMap(),m);for(let c of d)this.elementsToErase.delete(c.id);this.groupsToErase.delete(m)}if(jv(l)&&this.elementsToErase.delete(l.containerId),$v(l)){let d=qv(l);d&&this.elementsToErase.delete(d)}this.elementsToErase.delete(l.id)}}else if(!t&&!this.elementsToErase.has(l.id)&&Jv(r,l,a,this.app.state.zoom.value)){let m=l.groupIds.at(-1);if(!this.groupsToErase.has(m)){let d=Zv(this.app.scene.getNonDeletedElementsMap(),m);for(let c of d)this.elementsToErase.add(c.id);this.groupsToErase.add(m)}if($v(l)){let d=qv(l);d&&this.elementsToErase.add(d)}jv(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()}},Jv=(e,o,t,n)=>{let r=e[1],i=Xv(o)?15:o.strokeWidth/2,a=[Math.min(e[0][0],e[1][0])-i,Math.min(e[0][1],e[1][1])-i,Math.max(e[0][0],e[1][0])+i,Math.max(e[0][1],e[1][1])+i],l=v9(o,t),s=[l[0]-i,l[1]-i,l[2]+i,l[3]+i];if(!y9(a,s))return!1;if(D9(o)&&M9(r,o,t))return!0;if(Xv(o)){let d=C9(o),c=I9(o,d,t),p=Math.max(2.25,5/n);for(let f of c)if(Kv(f,e)<=p)return!0;let u=L9(...d.map(([f,b])=>Qv(o.x+f,o.y+b)));return!!A9(e[0],u)}let m=w9(o,t);if(S9(o)||k9(o)&&!o.polygon){let d=Math.max(o.strokeWidth,o.strokeWidth*2/n),c=T9(o,t);for(let p of c)if(Kv(p,e)<=d)return!0;return!1}return Vv(o,t,e,0,!0).length>0||!!m&&Vv({...m,...E9(o,m,t)},t,e,0,!0).length>0};import{jsx as Zt,jsxs as e3}from"react/jsx-runtime";var _9=()=>e3("div",{"data-testid":"brave-measure-text-error",children:[Zt("p",{children:Zt(ft,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>Zt("span",{style:{fontWeight:600},children:e})})}),Zt("p",{children:Zt(ft,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>Zt("span",{style:{fontWeight:600},children:e})})}),Zt("p",{children:Zt(ft,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>Zt("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),Zt("p",{children:Zt(ft,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>Zt("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>e3("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),t3=_9;import z9 from"clsx";import H9 from"react";import{useLayoutEffect as R9,useRef as o3,useEffect as n3}from"react";import{unstable_batchedUpdates as N9}from"react-dom";import{KEYS as B9,queryFocusableElements as F9}from"@excalidraw/common";import{jsx as O9}from"react/jsx-runtime";var r3=({children:e,left:o,top:t,onCloseRequest:n,fitInViewport:r=!1,offsetLeft:i=0,offsetTop:a=0,viewportWidth:l=window.innerWidth,viewportHeight:s=window.innerHeight})=>{let m=o3(null);n3(()=>{let c=m.current;if(!c)return;c.contains(document.activeElement)||c.focus();let p=u=>{if(u.key===B9.TAB){let f=F9(c),{activeElement:b}=document,x=f.findIndex(y=>y===b);b===c?(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 c.addEventListener("keydown",p),()=>c.removeEventListener("keydown",p)},[]);let d=o3(null);return R9(()=>{if(r&&m.current&&t!=null&&o!=null){let c=m.current,{width:p,height:u}=c.getBoundingClientRect();if(d.current?.top===t&&d.current?.left===o)return;d.current={top:t,left:o},p>=l?(c.style.width=`${l}px`,c.style.left="0px",c.style.overflowX="scroll"):o+p-i>l?c.style.left=`${l-p-10}px`:c.style.left=`${o}px`,u>=s?(c.style.height=`${s-20}px`,c.style.top="10px",c.style.overflowY="scroll"):t+u-a>s?c.style.top=`${s-u}px`:c.style.top=`${t}px`}},[t,o,r,l,s,i,a]),n3(()=>{if(n){let c=p=>{m.current?.contains(p.target)||N9(()=>n(p))};return document.addEventListener("pointerdown",c,!1),()=>document.removeEventListener("pointerdown",c,!1)}},[n]),O9("div",{className:"popover",ref:m,tabIndex:-1,children:e})};import{jsx as Fi,jsxs as G9}from"react/jsx-runtime";var Ve="separator",i3=H9.memo(({actionManager:e,items:o,top:t,left:n,onClose:r})=>{let i=bo(),a=an(),l=o.reduce((s,m)=>(m&&(m===Ve||!m.predicate||m.predicate(a,i,e.app.props,e.app))&&s.push(m),s),[]);return Fi(r3,{onCloseRequest:()=>{r()},top:t,left:n,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,children:Fi("ul",{className:"context-menu",onContextMenu:s=>s.preventDefault(),children:l.map((s,m)=>{if(s===Ve)return!l[m-1]||l[m-1]===Ve?null:Fi("hr",{className:"context-menu-item-separator"},m);let d=s.name,c="";return s.label&&(typeof s.label=="function"?c=g(s.label(a,i,e.app)):c=g(s.label)),Fi("li",{"data-testid":d,onClick:()=>{r(()=>{e.executeAction(s,"contextMenu")})},children:G9("button",{type:"button",className:z9("context-menu-item",{dangerous:d==="deleteSelectedElements",checkmark:s.checked?.(i)}),children:[Fi("div",{className:"context-menu-item__label",children:c}),Fi("kbd",{className:"context-menu-item__shortcut",children:d?Fe(d):""})]})},m)})})})});import{jsx as hg,jsxs as a3}from"react/jsx-runtime";var U9=({height:e,width:o,userToFollow:t,onDisconnect:n})=>hg("div",{className:"follow-mode",style:{width:o,height:e},children:a3("div",{className:"follow-mode__badge",children:[a3("div",{className:"follow-mode__badge__label",children:["Following"," ",hg("span",{className:"follow-mode__badge__username",title:t.username,children:t.username})]}),hg("button",{type:"button",onClick:n,className:"follow-mode__disconnect-btn",children:zt})]})}),l3=U9;import ur from"clsx";import lz from"react";import{CLASSES as sz,DEFAULT_SIDEBAR as uf,MQ_MIN_WIDTH_DESKTOP as cz,TOOL_TYPE as z5,arrayToMap as dz,capitalizeString as mz,isShallowEqual as cm}from"@excalidraw/common";import{mutateElement as pz}from"@excalidraw/element";import{showSelectedShapeActions as uz}from"@excalidraw/element";import{ShapeCache as hz}from"@excalidraw/element";import Y9 from"clsx";import{useState as W9,useEffect as V9}from"react";import{THEME as X9}from"@excalidraw/common";import{jsx as gg,jsxs as K9}from"react/jsx-runtime";var Id=({delay:e,theme:o})=>{let[t,n]=W9(!!e);return V9(()=>{if(!e)return;let r=setTimeout(()=>{n(!1)},e);return()=>clearTimeout(r)},[e]),t?null:K9("div",{className:Y9("LoadingMessage",{"LoadingMessage--dark":o===X9.DARK}),children:[gg("div",{children:gg(tt,{})}),gg("div",{className:"LoadingMessage-text",children:g("labels.loadingScene")})]})};import Z9 from"clsx";import{jsx as c3,jsxs as j9}from"react/jsx-runtime";var $9="medium",s3={CHECKED:Lr,UNCHECKED:Vn},Cd=e=>j9("label",{className:Z9("ToolIcon ToolIcon__lock",`ToolIcon_size_${$9}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[c3("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),c3("div",{className:"ToolIcon__icon",children:e.checked?s3.CHECKED:s3.UNCHECKED})]});import{showSelectedShapeActions as hN}from"@excalidraw/element";import q9 from"clsx";import{jsx as J9}from"react/jsx-runtime";var Sd=({children:e,side:o,className:t})=>J9("div",{className:q9("FixedSideContainer",`FixedSideContainer_side_${o}`,t),children:e});import Q9 from"clsx";import{KEYS as d3}from"@excalidraw/common";import{jsx as eN}from"react/jsx-runtime";var kd=e=>eN(Z,{className:Q9("Shape",{fillable:!1}),type:"radio",icon:ps,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:d3.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":d3.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});import{CANVAS_SEARCH_TAB as tN,DEFAULT_SIDEBAR as oN}from"@excalidraw/common";import{isFlowchartNodeElement as nN,isImageElement as m3,isLinearElement as p3,isLineElement as rN,isTextBindableContainer as iN,isTextElement as aN}from"@excalidraw/element";import{getShortcutKey as fg}from"@excalidraw/common";import{isNodeInFlowchart as lN}from"@excalidraw/element";import{jsx as u3}from"react/jsx-runtime";var sN=({appState:e,isMobile:o,device:t,app:n})=>{let{activeTool:r,isResizing:i,isRotating:a,lastPointerDownWith:l}=e,s=e.multiElement!==null;if(e.openSidebar?.name===oN.name&&e.openSidebar.tab===tN&&e.searchMatches?.matches.length)return g("hints.dismissSearch");if(e.openSidebar&&!t.editor.canFitSidebar)return null;if(yt(e))return g("hints.eraserRevert");if(r.type==="arrow"||r.type==="line")return s?g("hints.linearElementMulti"):r.type==="arrow"?g("hints.arrowTool",{arrowShortcut:fg("A")}):g("hints.linearElement");if(r.type==="freedraw")return g("hints.freeDraw");if(r.type==="text")return g("hints.text");if(r.type==="embeddable")return g("hints.embeddable");let m=n.scene.getSelectedElements(e);if(i&&l==="mouse"&&m.length===1){let d=m[0];return p3(d)&&d.points.length===2?g("hints.lockAngle"):m3(d)?g("hints.resizeImage"):g("hints.resize")}if(a&&l==="mouse")return g("hints.rotate");if(m.length===1&&aN(m[0]))return g("hints.text_selected");if(e.editingTextElement)return g("hints.text_editing");if(e.croppingElementId)return g("hints.leaveCropEditor");if(m.length===1&&m3(m[0]))return g("hints.enterCropEditor");if(r.type==="selection"){if(e.selectionElement&&!m.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return[g("hints.deepBoxSelect")];if(yn(n)&&e.selectedElementsAreBeingDragged)return g("hints.disableSnapping");if(!m.length&&!o)return[g("hints.canvasPanning")];if(m.length===1){if(p3(m[0]))return e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?g("hints.lineEditor_pointSelected"):g("hints.lineEditor_nothingSelected"):rN(m[0])?g("hints.lineEditor_line_info"):g("hints.lineEditor_info");if(!e.newElement&&!e.selectedElementsAreBeingDragged&&iN(m[0]))return nN(m[0])?lN(m[0],n.scene.getNonDeletedElementsMap())?[g("hints.bindTextToElement"),g("hints.createFlowchart")]:[g("hints.bindTextToElement"),g("hints.createFlowchart")]:g("hints.bindTextToElement")}}return null},Md=({appState:e,isMobile:o,device:t,app:n})=>{let r=sN({appState:e,isMobile:o,device:t,app:n});if(!r)return null;let i=Array.isArray(r)?r.map(a=>fg(a).replace(/\. ?$/,"")).join(". "):fg(r);return u3("div",{className:"HintViewer",children:u3("span",{children:i})})};import cN from"clsx";import{jsx as h3,jsxs as mN}from"react/jsx-runtime";var dN="medium",Pd=e=>e.penDetected?mN("label",{className:cN("ToolIcon ToolIcon__penMode",`ToolIcon_size_${dN}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[h3("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),h3("div",{className:"ToolIcon__icon",children:Q1})]}):null;import{Fragment as pN,jsx as g3,jsxs as uN}from"react/jsx-runtime";var Tn=({heading:e,children:o,...t})=>{let{id:n}=Ne(),r=g3("h2",{className:"visually-hidden",id:`${n}-${e}-title`,children:g(`headings.${e}`)});return g3("section",{...t,"aria-labelledby":`${n}-${e}-title`,children:typeof o=="function"?o(r):uN(pN,{children:[r,o]})})};import{Fragment as gN,jsx as nt,jsxs as Xo}from"react/jsx-runtime";var f3=({appState:e,elements:o,actionManager:t,setAppState:n,onLockToggle:r,onHandToolToggle:i,onPenModeToggle:a,renderTopRightUI:l,renderCustomStats:s,renderSidebars:m,device:d,renderWelcomeScreen:c,UIOptions:p,app:u})=>{let{WelcomeScreenCenterTunnel:f,MainMenuTunnel:b,DefaultSidebarTriggerTunnel:x}=Ce(),y=()=>Xo(Sd,{side:"top",className:"App-top-bar",children:[c&&nt(f.Out,{}),nt(Tn,{heading:"shapes",children:w=>nt(qe.Col,{gap:4,align:"center",children:Xo(qe.Row,{gap:1,className:"App-toolbar-container",children:[Xo(Ye,{padding:1,className:"App-toolbar App-toolbar--mobile",children:[w,nt(qe.Row,{gap:1,children:nt($c,{appState:e,activeTool:e.activeTool,UIOptions:p,app:u})})]}),l&&l(!0,e),Xo("div",{className:"mobile-misc-tools-container",children:[!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&nt(x.Out,{}),nt(Pd,{checked:e.penMode,onChange:()=>a(null),title:g("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),nt(Cd,{checked:e.activeTool.locked,onChange:r,title:g("toolBar.lock"),isMobile:!0}),nt(kd,{checked:Qt(e),onChange:()=>i(),title:g("toolBar.hand"),isMobile:!0})]})]})})}),nt(Md,{appState:e,isMobile:!0,device:d,app:u})]}),E=()=>e.viewModeEnabled||e.openDialog?.name==="elementLinkSelector"?nt("div",{className:"App-toolbar-content",children:nt(b.Out,{})}):Xo("div",{className:"App-toolbar-content",children:[nt(b.Out,{}),t.renderAction("toggleEditMenu"),t.renderAction(e.multiElement?"finalize":"duplicateSelection"),t.renderAction("deleteSelectedElements"),Xo("div",{children:[t.renderAction("undo"),t.renderAction("redo")]})]});return Xo(gN,{children:[m(),!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&y(),nt("div",{className:"App-bottom-bar",style:{marginBottom:It+so*2,marginLeft:It+so*2,marginRight:It+so*2},children:Xo(Ye,{padding:0,children:[e.openMenu==="shape"&&!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&hN(e,o)?nt(Tn,{className:"App-mobile-menu",heading:"selectedShapeActions",children:nt(Zc,{appState:e,elementsMap:u.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:u})}):null,Xo("footer",{className:"App-toolbar",children:[E(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&nt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{n(w=>({...Gn(o,w)}))},children:g("buttons.scrollBackToContent")})]})]})})]})};import fN from"open-color";import bN,{useLayoutEffect as xN,useRef as EN,useState as yN}from"react";import{jsx as hl,jsxs as wN}from"react/jsx-runtime";var b3=e=>{let o=EN(null),[t,n]=yN(null);return xN(()=>{if(!e.spreadsheet)return;let r=hE(e.chartType,e.spreadsheet,0,0);n(r);let i,a=o.current;return(async()=>(i=await Cr(r,{exportBackground:!1,viewBackgroundColor:fN.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]),hl("button",{type:"button",className:"ChartPreview",onClick:()=>{t&&e.onClick(e.chartType,t)},children:hl("div",{ref:o})})},x3=({setAppState:e,appState:o,onClose:t})=>{let{onInsertElements:n}=Be(),r=bN.useCallback(()=>{t&&t()},[t]),i=(a,l)=>{n(l),re("paste","chart",a),e({currentChartType:a,pasteDialog:{shown:!1,data:null}})};return hl(Oe,{size:"small",onCloseRequest:r,title:g("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:wN("div",{className:"container",children:[hl(b3,{chartType:"bar",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="bar",onClick:i}),hl(b3,{chartType:"line",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="line",onClick:i})]})})};import*as In from"@radix-ui/react-popover";import E3 from"clsx";import Ld,{useLayoutEffect as vN}from"react";import{supportsResizeObserver as TN,isShallowEqual as IN}from"@excalidraw/common";import{Fragment as PN,jsx as Co,jsxs as Ad}from"react/jsx-runtime";var CN=4,SN=8,kN=({shouldWrap:e,children:o,username:t})=>e?Co(At,{label:t||"Unknown user",children:o}):Co(PN,{children:o}),bg=({actionManager:e,collaborator:o,socketId:t,withName:n=!1,shouldWrapWithTooltip:r=!1,isBeingFollowed:i})=>{let a={socketId:t,collaborator:o,withName:n,isBeingFollowed:i},l=e.renderAction("goToCollaborator",a);return Co(kN,{username:o.username,shouldWrap:r,children:l},t)},MN=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],Dd=Ld.memo(({className:e,mobile:o,collaborators:t,userToFollow:n})=>{let r=We(),i=new Map;t.forEach((b,x)=>{let y=b.id||x;i.set(y,{...b,socketId:x})});let a=Array.from(i.values()).filter(b=>b.username?.trim()),[l,s]=Ld.useState(""),m=a.filter(b=>b.username?.toLowerCase().includes(l)),d=Ld.useRef(null);vN(()=>{if(d.current){let b=y=>{let E=Math.max(1,Math.min(8,Math.floor(y/38)));p(E)};if(b(d.current.clientWidth),!TN)return;let x=new ResizeObserver(y=>{for(let E of y){let{width:w}=E.contentRect;b(w)}});return x.observe(d.current),()=>{x.disconnect()}}},[]);let[c,p]=Ld.useState(CN),f=a.slice(0,c-1).map(b=>bg({actionManager:r,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===n}));return o?Co("div",{className:E3("UserList UserList_mobile",e),children:a.map(b=>bg({actionManager:r,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===n}))}):Co("div",{className:"UserList__wrapper",ref:d,children:Ad("div",{className:E3("UserList",e),style:{"--max-avatars":c},children:[f,a.length>c-1&&Ad(In.Root,{children:[Ad(In.Trigger,{className:"UserList__more",children:["+",a.length-c+1]}),Co(In.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:Ad(Ye,{padding:2,children:[a.length>=SN&&Co(Rs,{placeholder:g("quickSearch.placeholder"),onChange:s}),Co(Ns,{className:"dropdown-menu UserList__collaborators",placeholder:g("userList.empty"),children:m.length>0?[Co("div",{className:"hint",children:g("userList.hint.text")}),m.map(b=>bg({actionManager:r,collaborator:b,socketId:b.socketId,withName:!0,isBeingFollowed:b.socketId===n}))]:[]}),Co(In.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[n,r]of e.collaborators){let i=o.collaborators.get(n);if(!i||n!==t.next().value||!IN(r,i,MN))return!1}return!0});import xg from"clsx";import{jsx as LN}from"react/jsx-runtime";var y3=e=>LN("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${g("helpDialog.title")} \u2014 ?`,"aria-label":g("helpDialog.title"),children:Dr});import{jsx as Ko,jsxs as Eg}from"react/jsx-runtime";var w3=({appState:e,actionManager:o,showExitZenModeBtn:t,renderWelcomeScreen:n})=>{let{FooterCenterTunnel:r,WelcomeScreenHelpHintTunnel:i}=Ce();return Eg("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[Ko("div",{className:xg("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:Ko(qe.Col,{gap:2,children:Eg(Tn,{heading:"canvasActions",children:[Ko(K2,{renderAction:o.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&Ko(Z2,{renderAction:o.renderAction,className:xg("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),Ko(r.Out,{}),Ko("div",{className:xg("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:Eg("div",{style:{position:"relative"},children:[n&&Ko(i.Out,{}),Ko(y3,{onClick:()=>o.executeAction(nr)})]})}),Ko($2,{actionManager:o,showExitZenModeBtn:t})]})},v3=w3;w3.displayName="Footer";import ON from"clsx";import{useEffect as _3,useLayoutEffect as R3,useRef as Mg,useState as zN,forwardRef as N3,useImperativeHandle as HN,useCallback as L3}from"react";import{EVENT as A3,isDevEnv as GN,KEYS as UN,updateObject as YN}from"@excalidraw/common";import DN from"clsx";import{useContext as _N}from"react";import AN from"react";var _d=AN.createContext({});import{jsx as yg,jsxs as T3}from"react/jsx-runtime";var wg=({children:e,className:o})=>{let t=de(),n=_N(_d),r=!!(t.editor.canFitSidebar&&n.shouldRenderDockButton);return T3("div",{className:DN("sidebar__header",o),"data-testid":"sidebar-header",children:[e,T3("div",{className:"sidebar__header__buttons",children:[r&&yg(At,{label:g("labels.sidebarLock"),children:yg(Nt,{onSelect:()=>n.onDock?.(!n.docked),selected:!!n.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":g("labels.sidebarLock"),children:K1})}),yg(Nt,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:n.onCloseRequest,"aria-label":g("buttons.close"),children:zt})]})]})};wg.displayName="SidebarHeader";import*as C3 from"@radix-ui/react-tabs";import{jsx as I3}from"react/jsx-runtime";var vg=({children:e,tab:o,onSelect:t,...n})=>I3(C3.Trigger,{value:o,asChild:!0,onSelect:t,children:I3("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...n,children:e})});vg.displayName="SidebarTabTrigger";import*as S3 from"@radix-ui/react-tabs";import{jsx as RN}from"react/jsx-runtime";var Tg=({children:e,...o})=>RN(S3.List,{className:"sidebar-triggers",...o,children:e});Tg.displayName="SidebarTabTriggers";import NN from"clsx";import{jsx as Ig,jsxs as k3}from"react/jsx-runtime";var Cg=({name:e,tab:o,icon:t,title:n,children:r,onToggle:i,className:a,style:l})=>{let s=ae(),m=be();return k3("label",{title:n,className:"sidebar-trigger__label-element",children:[Ig("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:d=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let c=d.target.checked;s({openSidebar:c?{name:e,tab:o}:null}),i?.(c)},checked:m.openSidebar?.name===e,"aria-label":n,"aria-keyshortcuts":"0"}),k3("div",{className:NN("sidebar-trigger",a),style:l,children:[t&&Ig("div",{children:t}),r&&Ig("div",{className:"sidebar-trigger__label",children:r})]})]})};Cg.displayName="SidebarTrigger";import*as M3 from"@radix-ui/react-tabs";import{jsx as BN}from"react/jsx-runtime";var Sg=({children:e,...o})=>{let t=be(),n=ae();if(!t.openSidebar)return null;let{name:r}=t.openSidebar;return BN(M3.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>n(a=>({...a,openSidebar:{...a.openSidebar,name:r,tab:i}})),...o,children:e})};Sg.displayName="SidebarTabs";import*as P3 from"@radix-ui/react-tabs";import{jsx as FN}from"react/jsx-runtime";var kg=({tab:e,children:o,...t})=>FN(P3.Content,{...t,value:e,"data-testid":e,children:o});kg.displayName="SidebarTab";import{jsx as D3}from"react/jsx-runtime";import{createElement as WN}from"react";var gl=he(!1),B3=N3(({name:e,children:o,onDock:t,docked:n,className:r,...i},a)=>{GN()&&t&&n==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=ae(),s=en(gl);R3(()=>(s(!!n),()=>{s(!1)}),[s,n]);let m=Mg({});m.current.onCloseRequest=()=>{l({openSidebar:null})},m.current.onDock=u=>t?.(u),m.current=YN(m.current,{docked:n,shouldRenderDockButton:!!t&&n!=null});let d=Mg(null);HN(a,()=>d.current);let c=de(),p=L3(()=>{document.querySelector(".Dialog")||l({openSidebar:null})},[l]);return Wr(d,L3(u=>{u.target.closest(".sidebar-trigger")||(!n||!c.editor.canFitSidebar)&&p()},[p,n,c.editor.canFitSidebar])),_3(()=>{let u=f=>{f.key===UN.ESCAPE&&(!n||!c.editor.canFitSidebar)&&p()};return document.addEventListener(A3.KEYDOWN,u),()=>{document.removeEventListener(A3.KEYDOWN,u)}},[p,n,c.editor.canFitSidebar]),D3(Ye,{...i,className:ON("sidebar",{"sidebar--docked":n},r),ref:d,children:D3(_d.Provider,{value:m.current,children:o})})});B3.displayName="SidebarInner";var $t=Object.assign(N3((e,o)=>{let t=be(),{onStateChange:n}=e,r=Mg(t.openSidebar);_3(()=>{(!t.openSidebar&&r?.current?.name===e.name||t.openSidebar?.name===e.name&&r?.current?.name!==e.name||r.current?.name===e.name)&&t.openSidebar!==r.current&&n?.(t.openSidebar?.name!==e.name?null:t.openSidebar),r.current=t.openSidebar},[t.openSidebar,n,e.name]);let[i,a]=zN(!1);return R3(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?WN(B3,{...e,ref:o,key:e.name}):null}),{Header:wg,TabTriggers:Tg,TabTrigger:vg,Tabs:Sg,Tab:kg,Trigger:Cg});$t.displayName="Sidebar";import{composeEventHandlers as QN}from"@excalidraw/common";import{useLayoutEffect as VN,useRef as XN}from"react";import{jsx as KN}from"react/jsx-runtime";var Zo=(e,o)=>{let t=he(0),n=r=>{let{tunnelsJotai:{useAtom:i}}=Ce(),[,a]=i(t),l=XN({preferHost:!1,counter:0});return VN(()=>{let s=l.current;return a(m=>{let d=m+1;return s.counter=d,d}),()=>{a(m=>{let d=m-1;return s.counter=d,d||(s.preferHost=!1),d})}},[a]),r.__fallback||(l.current.preferHost=!0),!l.current.counter&&r.__fallback&&l.current.preferHost||l.current.counter>1&&r.__fallback?null:KN(o,{...r})};return n.displayName=e,n};var Ag={};p1(Ag,{ChangeCanvasBackground:()=>j3,ClearCanvas:()=>Z3,CommandPalette:()=>V3,Export:()=>q3,Help:()=>K3,LiveCollaborationTrigger:()=>Q3,LoadScene:()=>U3,SaveAsImage:()=>W3,SaveToActiveFile:()=>Y3,SearchMenu:()=>X3,Socials:()=>J3,ToggleTheme:()=>$3});import qN from"clsx";import{THEME as Cn}from"@excalidraw/common";var Pg=he({active:!1});async function F3({title:e,description:o,actionLabel:t,color:n}){return new Promise(r=>{Ue.set(Pg,{active:!0,onConfirm:()=>r(!0),onClose:()=>r(!1),onReject:()=>r(!1),title:e,description:o,actionLabel:t,color:n})})}import ZN from"clsx";import{jsx as O3,jsxs as $N}from"react/jsx-runtime";var Rd=function({onChange:e,value:o,choices:t,name:n}){return O3("div",{className:"RadioGroup",children:t.map(r=>$N("div",{className:ZN("RadioGroup__choice",{active:r.value===o}),title:r.ariaLabel,children:[O3("input",{name:n,type:"radio",checked:r.value===o,onChange:()=>e(r.value),"aria-label":r.ariaLabel}),r.label]},String(r.value)))})};import{Fragment as jN,jsx as Lg,jsxs as z3}from"react/jsx-runtime";var H3=({value:e,shortcut:o,onChange:t,choices:n,children:r,name:i})=>{let a=de();return z3(jN,{children:[z3("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[Lg("label",{className:"dropdown-menu-item__text",htmlFor:i,children:r}),Lg(Rd,{name:i,value:e,onChange:t,choices:n})]}),o&&!a.editor.isMobile&&Lg("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:o})]})};H3.displayName="DropdownMenuItemContentRadio";var G3=H3;import{Fragment as JN,jsx as je,jsxs as eT}from"react/jsx-runtime";var U3=()=>{let{t:e}=Ge(),o=We(),t=an();return o.isActionEnabled(ri)?je(pt,{icon:_r,onSelect:async()=>{(!t.length||await F3({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:je(ft,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:r=>je("strong",{children:r}),br:()=>je("br",{})})}))&&o.executeAction(ri)},"data-testid":"load-button",shortcut:Fe("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};U3.displayName="LoadScene";var Y3=()=>{let{t:e}=Ge(),o=We();return o.isActionEnabled(or)?je(pt,{shortcut:Fe("saveScene"),"data-testid":"save-button",onSelect:()=>o.executeAction(or),icon:s0,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};Y3.displayName="SaveToActiveFile";var W3=()=>{let e=ae(),{t:o}=Ge();return je(pt,{icon:ss,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:Fe("imageExport"),"aria-label":o("buttons.exportImage"),children:o("buttons.exportImage")})};W3.displayName="SaveAsImage";var V3=e=>{let o=ae(),{t}=Ge();return je(pt,{icon:ua,"data-testid":"command-palette-button",onSelect:()=>{re("command_palette","open","menu"),o({openDialog:{name:"commandPalette"}})},shortcut:Fe("commandPalette"),"aria-label":t("commandPalette.title"),className:e?.className,children:t("commandPalette.title")})};V3.displayName="CommandPalette";var X3=e=>{let{t:o}=Ge(),t=We();return je(pt,{icon:Pt,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(tl)},shortcut:Fe("searchMenu"),"aria-label":o("search.title"),className:e?.className,children:o("search.title")})};X3.displayName="SearchMenu";var K3=()=>{let{t:e}=Ge(),o=We();return je(pt,{"data-testid":"help-menu-item",icon:Dr,onSelect:()=>o.executeAction(nr),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};K3.displayName="Help";var Z3=()=>{let{t:e}=Ge(),o=en(lr);return We().isActionEnabled(Oo)?je(pt,{icon:Mt,onSelect:()=>o("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};Z3.displayName="ClearCanvas";var $3=e=>{let{t:o}=Ge(),t=be(),n=We(),r=Fe("toggleTheme");return n.isActionEnabled(Jn)?e?.allowSystemTheme?je(G3,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:Cn.LIGHT,label:ca,ariaLabel:`${o("buttons.lightMode")} - ${r}`},{value:Cn.DARK,label:sa,ariaLabel:`${o("buttons.darkMode")} - ${r}`},{value:"system",label:Ib,ariaLabel:o("buttons.systemMode")}],children:o("labels.theme")}):je(pt,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(t.theme===Cn.DARK?Cn.LIGHT:Cn.DARK);else return n.executeAction(Jn)},icon:t.theme===Cn.DARK?ca:sa,"data-testid":"toggle-dark-mode",shortcut:r,"aria-label":t.theme===Cn.DARK?o("buttons.lightMode"):o("buttons.darkMode"),children:t.theme===Cn.DARK?o("buttons.lightMode"):o("buttons.darkMode")}):null};$3.displayName="ToggleTheme";var j3=()=>{let{t:e}=Ge(),o=be(),t=We(),n=xo();return o.viewModeEnabled||!n.UIOptions.canvasActions.changeViewBackgroundColor?null:eT("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")})]})};j3.displayName="ChangeCanvasBackground";var q3=()=>{let{t:e}=Ge(),o=ae();return je(pt,{icon:Xn,onSelect:()=>{o({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};q3.displayName="Export";var J3=()=>{let{t:e}=Ge();return eT(JN,{children:[je(vi,{icon:as,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),je(vi,{icon:a0,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),je(vi,{icon:i0,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};J3.displayName="Socials";var Q3=({onSelect:e,isCollaborating:o})=>{let{t}=Ge();return je(pt,{"data-testid":"collab-button",icon:cs,className:qN({"active-collab":o}),onSelect:e,children:t("labels.liveCollaboration")})};Q3.displayName="LiveCollaborationTrigger";import{jsx as Nd,jsxs as Dg}from"react/jsx-runtime";var eB=Object.assign(Zo("MainMenu",({children:e,onSelect:o})=>{let{MainMenuTunnel:t}=Ce(),n=de(),r=be(),i=ae(),a=n.editor.isMobile?void 0:()=>i({openMenu:null});return Nd(t.In,{children:Dg(xe,{open:r.openMenu==="canvas",children:[Nd(xe.Trigger,{onToggle:()=>{i({openMenu:r.openMenu==="canvas"?null:"canvas"})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:is}),Dg(xe.Content,{onClickOutside:a,onSelect:QN(o,()=>{i({openMenu:null})}),children:[e,n.editor.isMobile&&r.collaborators.size>0&&Dg("fieldset",{className:"UserList-Wrapper",children:[Nd("legend",{children:g("labels.collaborators")}),Nd(Dd,{mobile:!0,collaborators:r.collaborators,userToFollow:r.userToFollow?.socketId||null})]})]})]})})}),{Trigger:xe.Trigger,Item:xe.Item,ItemLink:xe.ItemLink,ItemCustom:xe.ItemCustom,Group:xe.Group,Separator:xe.Separator,DefaultItems:Ag}),mt=eB;import tB from"clsx";import{forwardRef as oB,useState as nB}from"react";import{isPromiseLike as rB}from"@excalidraw/common";import{jsx as Bd,jsxs as iB}from"react/jsx-runtime";var Sn=oB(({children:e,icon:o,onClick:t,label:n,variant:r="filled",color:i="primary",size:a="medium",fullWidth:l,className:s,status:m},d)=>{let[c,p]=nB(!1),u=async b=>{let x=t?.(b);if(rB(x)){let y=window.setTimeout(()=>{p(!0)},50);try{await x}catch(E){if(E instanceof Tr)console.warn(E);else throw E}finally{clearTimeout(y),p(!1)}}},f=c?"loading":m;return i=f==="success"?"success":i,Bd("button",{className:tB("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${r}`,`ExcButton--size-${a}`,`ExcButton--status-${f}`,{"ExcButton--fullWidth":l},s),onClick:u,type:"button","aria-label":n,ref:d,disabled:f==="loading"||f==="success",children:iB("div",{className:"ExcButton__contents",children:[f==="loading"?Bd(tt,{className:"ExcButton__statusIcon"}):f==="success"&&Bd("div",{className:"ExcButton__statusIcon",children:ib}),o&&Bd("div",{className:"ExcButton__icon","aria-hidden":!0,children:o}),r!=="icon"&&(e??n)]})})});import{jsx as Oi,jsxs as sB}from"react/jsx-runtime";var Fd=({title:e,children:o,actionLabel:t,onClick:n})=>sB("div",{className:"OverwriteConfirm__Actions__Action",children:[Oi("h4",{children:e}),Oi("div",{className:"OverwriteConfirm__Actions__Action__content",children:o}),Oi(Sn,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:n})]}),aB=()=>{let{t:e}=Ge(),o=We(),t=ae();return Oi(Fd,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{o.executeAction(rc,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},lB=()=>{let{t:e}=Ge(),o=We();return Oi(Fd,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{o.executeAction(za,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},_g=Object.assign(({children:e})=>Oi("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:aB,SaveToDisk:lB});import{jsx as kn,jsxs as tT}from"react/jsx-runtime";var Od=Object.assign(Zo("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:o}=Ce(),[t,n]=le(Pg);if(!t.active)return null;let r=()=>{t.onClose(),n(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),n(a=>({...a,active:!1}))};return kn(o.In,{children:kn(Oe,{onCloseRequest:r,title:!1,size:916,children:tT("div",{className:"OverwriteConfirm",children:[kn("h3",{children:t.title}),tT("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[kn("div",{className:"OverwriteConfirm__Description__icon",children:ab}),kn("div",{children:t.description}),kn("div",{className:"OverwriteConfirm__Description__spacer"}),kn(Sn,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),kn(_g,{children:e})]})})})}),{Actions:_g,Action:Fd});import LB from"clsx";import{CANVAS_SEARCH_TAB as Og,DEFAULT_SIDEBAR as AB,LIBRARY_SIDEBAR_TAB as mT,composeEventHandlers as DB}from"@excalidraw/common";import{round as cB}from"@excalidraw/math";import dB from"clsx";import mB from"lodash.debounce";import{Fragment as pB,memo as uB,useEffect as fl,useMemo as oT,useRef as Rg,useState as nT}from"react";import{CLASSES as hB,EVENT as gB,FONT_FAMILY as Ng,FRAME_STYLE as Bg,getLineHeight as fB}from"@excalidraw/common";import{isElementCompletelyInViewport as bB}from"@excalidraw/element";import{measureText as bl}from"@excalidraw/element";import{KEYS as zi,randomInteger as rT,addEventListener as xB,getFontString as zd}from"@excalidraw/common";import{newTextElement as EB}from"@excalidraw/element";import{isTextElement as sT,isFrameLikeElement as Hd}from"@excalidraw/element";import{getDefaultFrameName as cT}from"@excalidraw/element/frame";import{Fragment as PB,jsx as Je,jsxs as So}from"react/jsx-runtime";var yB=he(""),Fg=he(null),wB=350,dT=()=>{let e=Be(),o=ae(),t=Rg(null),[n,r]=le(yB),i=n.trim(),[a,l]=nT(!1),[s,m]=nT({nonce:null,items:[]}),d=Rg(null),c=Rg(void 0),[p,u]=le(Fg),f=e.scene.getNonDeletedElementsMap();fl(()=>{a||(i!==d.current||e.scene.getSceneNonce()!==c.current)&&(d.current=null,lT(i,e,(w,v)=>{m({nonce:rT(),items:w}),d.current=i,c.current=e.scene.getSceneNonce(),o({searchMatches:w.length?{focusedId:null,matches:w.map(C=>({id:C.element.id,focus:!1,matchedLines:C.matchedLines}))}:null})}))},[a,i,f,e,o,u,c]);let b=()=>{s.items.length>0&&u(w=>w===null?0:(w+1)%s.items.length)},x=()=>{s.items.length>0&&u(w=>w===null?0:w-1<0?s.items.length-1:w-1)};fl(()=>{o(w=>w.searchMatches?{searchMatches:{focusedId:p!==null&&w.searchMatches?.matches[p]?.id||null,matches:w.searchMatches.matches.map((C,S)=>S===p?{...C,focus:!0}:{...C,focus:!1})}}:null)},[p,o]),fl(()=>{if(s.items.length>0&&p!==null){let w=s.items[p];if(w){let v=e.state.zoom.value,C=EB({text:w.searchQuery,x:w.element.x+(w.matchedLines[0]?.offsetX??0),y:w.element.y+(w.matchedLines[0]?.offsetY??0),width:w.matchedLines[0]?.width,height:w.matchedLines[0]?.height,fontSize:Hd(w.element)?Bg.nameFontSize:w.element.fontSize,fontFamily:Hd(w.element)?Ng.Assistant:w.element.fontFamily}),S=14,L=C.fontSize,P=L*v<S;if(!bB([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())||P){let B;P?L>=S?B={fitToContent:!0}:B={fitToViewport:!0,maxZoom:cB(S/L,1)}:B={fitToContent:!0},e.scrollToContent(C,{animate:!0,duration:300,...B,canvasOffsets:e.getEditorUIOffsets()})}}}},[p,s,e]),fl(()=>()=>{u(null),d.current=null,c.current=void 0,o({searchMatches:null}),l(!1)},[o,u]);let y=on({goToNextItem:b,goToPreviousItem:x,searchMatches:s});fl(()=>{let w=v=>{if(v.key===zi.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){v.preventDefault(),v.stopPropagation(),o({openSidebar:null});return}if(v[zi.CTRL_OR_CMD]&&v.key===zi.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")&&y.searchMatches.items.length&&(v.key===zi.ENTER&&(v.stopPropagation(),y.goToNextItem()),v.key===zi.ARROW_UP?(v.stopPropagation(),y.goToPreviousItem()):v.key===zi.ARROW_DOWN&&(v.stopPropagation(),y.goToNextItem()))};return xB(window,gB.KEYDOWN,w,{capture:!0,passive:!1})},[o,y,e]);let E=`${s.items.length} ${s.items.length===1?g("search.singleResult"):g("search.multipleResults")}`;return So("div",{className:"layer-ui__search",children:[Je("div",{className:"layer-ui__search-header",children:Je(Ci,{className:hB.SEARCH_MENU_INPUT_WRAPPER,value:n,ref:t,placeholder:g("search.placeholder"),icon:Pt,onChange:w=>{r(w),l(!0);let v=w.trim();lT(v,e,(C,S)=>{m({nonce:rT(),items:C}),u(S),d.current=v,c.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})}),So("div",{className:"layer-ui__search-count",children:[s.items.length>0&&So(PB,{children:[p!==null&&p>-1?So("div",{children:[p+1," / ",E]}):Je("div",{children:E}),So("div",{className:"result-nav",children:[Je(Nt,{onSelect:()=>{b()},className:"result-nav-btn",children:fs}),Je(Nt,{onSelect:()=>{x()},className:"result-nav-btn",children:Pb})]})]}),s.items.length===0&&i&&d.current&&Je("div",{style:{margin:"1rem auto"},children:g("search.noMatch")})]}),Je(IB,{matches:s,onItemClick:u,focusIndex:p,searchQuery:i})]})},iT=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 Je("div",{tabIndex:-1,className:dB("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:Je("div",{className:"preview-text",children:o.flatMap((t,n)=>Je(pB,{children:n===2?Je("b",{children:t}):t},n))})})},vB=e=>{let o=oT(()=>e.matches.items.filter(n=>Hd(n.element)),[e.matches]),t=oT(()=>e.matches.items.filter(n=>sT(n.element)),[e.matches]);return So("div",{children:[o.length>0&&So("div",{className:"layer-ui__search-result-container",children:[So("div",{className:"layer-ui__search-result-title",children:[Je("div",{className:"title-icon",children:Zn}),Je("div",{children:g("search.frames")})]}),o.map((n,r)=>Je(iT,{searchQuery:e.searchQuery,preview:n.preview,highlighted:r===e.focusIndex,onClick:()=>e.onItemClick(r)},n.element.id+n.index)),t.length>0&&Je("div",{className:"layer-ui__divider"})]}),t.length>0&&So("div",{className:"layer-ui__search-result-container",children:[So("div",{className:"layer-ui__search-result-title",children:[Je("div",{className:"title-icon",children:Ar}),Je("div",{children:g("search.texts")})]}),t.map((n,r)=>Je(iT,{searchQuery:e.searchQuery,preview:n.preview,highlighted:r+o.length===e.focusIndex,onClick:()=>e.onItemClick(r+o.length)},n.element.id+n.index))]})]})},TB=(e,o)=>e.matches.nonce===o.matches.nonce&&e.focusIndex===o.focusIndex,IB=uB(vB,TB),aT=(e,o,t)=>{let i=e.slice(0,o),a=i.split(/\s+/),l=i.endsWith(" "),s=a.length-2-1-(l?0:1),m=a.slice(s<=0?0:s).join(" ")+(l?" ":""),d=20;m=m.length>d?m.slice(-d):m;let c=e.slice(o+t.length),p=c.split(/\s+/),u=!c.startsWith(" "),f=u?6:5,b=(u?"":" ")+p.slice(0,f).join(" ");return{indexInSearchQuery:m.length,previewText:m+t+b,moreBefore:s>0,moreAfter:p.length>f}},CB=(e,o)=>{let t=e.split(`
|
|
17
|
+
`),n=[],r=0;for(let i=0;i<t.length;i++){let a=t[i],l=t[i+1];if(l){let s=o.indexOf(l,r);if(s>a.length+r){let m=s-(a.length+r);for(;m>0;)a+=" ",m--}}n.push(a),r=r+a.length}return n.join(`
|
|
18
|
+
`)},SB=(e,o,t)=>{let r=CB(e.text,e.originalText).split(`
|
|
19
|
+
`),i=[],a=0,l=0;for(let c of r){let p=a,u=p+c.length-1;i.push({line:c,startIndex:p,endIndex:u,lineNumber:l}),a=u+1,l++}let s=t,m=e.originalText.slice(t,t+o.length),d=[];for(let c of i){if(m==="")break;if(s>=c.startIndex&&s<=c.endIndex){let p=c.endIndex+1-s,u=c.line.slice(0,s-c.startIndex),f=m.slice(0,p);m=m.slice(p);let b=bl(u,zd(e),e.lineHeight);if(u===""&&(b.width=0),e.textAlign!=="left"&&c.line.length>0){let v=bl(c.line,zd(e),e.lineHeight),C=e.textAlign==="center"?(e.width-v.width)/2:e.width-v.width;b.width+=C}let{width:x,height:y}=bl(f,zd(e),e.lineHeight),E=b.width,w=c.lineNumber*b.height;d.push({offsetX:E,offsetY:w,width:x,height:y,showOnCanvas:!0}),s+=p}}return d},kB=(e,o,t,n)=>{let r=e.name??cT(e),i=r.slice(t,t+o.length),a=r.slice(0,t),l=zd({fontSize:Bg.nameFontSize,fontFamily:Ng.Assistant}),s=fB(Ng.Assistant),m=bl(a,l,s);a===""&&(m.width=0);let d=bl(i,l,s),c=m.width,p=-m.height-Bg.strokeWidth,u=d.width;return[{offsetX:c,offsetY:p,width:u,height:d.height,showOnCanvas:c+u<=e.width*n}]},MB=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),lT=mB((e,o,t)=>{if(!e||e===""){t([],null);return}let n=o.scene.getNonDeletedElements(),r=n.filter(p=>sT(p)),i=n.filter(p=>Hd(p));r.sort((p,u)=>p.y-u.y),i.sort((p,u)=>p.y-u.y);let a=[],l=new RegExp(MB(e),"gi");for(let p of r){let u=null,f=p.originalText;for(;(u=l.exec(f))!==null;){let b=aT(f,u.index,e),x=SB(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??cT(p);for(;(u=l.exec(f))!==null;){let b=aT(f,u.index,e),x=kB(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 m=new Set(o.visibleElements.map(p=>p.id)),d=[...s,...a],c=d.findIndex(p=>m.has(p.element.id))??null;t(d,c)},wB);import{jsx as co,jsxs as pT}from"react/jsx-runtime";import{createElement as _B}from"react";var uT=Zo("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:o}=Ce();return co(o.In,{children:co($t.Trigger,{...e,className:"default-sidebar-trigger",name:AB.name})})});uT.displayName="DefaultSidebarTrigger";var hT=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:o}=Ce();return co(o.In,{children:e})};hT.displayName="DefaultTabTriggers";var Gd=Object.assign(Zo("DefaultSidebar",({children:e,className:o,onDock:t,docked:n,...r})=>{let i=be(),a=ae(),{DefaultSidebarTabTriggersTunnel:l}=Ce(),s=i.openSidebar?.tab===Og;return _B($t,{...r,name:"default",key:"default",className:LB("default-sidebar",o),docked:s||(n??i.defaultSidebarDockedPreference),onDock:s||t===!1||!t&&n!=null?void 0:DB(t,m=>{a({defaultSidebarDockedPreference:m})})},pT($t.Tabs,{children:[co($t.Header,{children:pT($t.TabTriggers,{children:[co($t.TabTrigger,{tab:Og,children:Pt}),co($t.TabTrigger,{tab:mT,children:Pr}),co(l.Out,{})]})}),co($t.Tab,{tab:mT,children:co(L2,{})}),co($t.Tab,{tab:Og,children:co(dT,{})}),e]}))}),{Trigger:uT,TabTriggers:hT});import{useEffect as QB,useRef as Gg,useState as qd}from"react";import{isFiniteNumber as BT}from"@excalidraw/math";import{useState as vT,useRef as TT,useEffect as IT,useDeferredValue as UB}from"react";import{EDITOR_LS_KEYS as YB,debounce as WB,isDevEnv as VB}from"@excalidraw/common";import{useEffect as RB,useRef as gT}from"react";import{EVENT as fT,KEYS as bT}from"@excalidraw/common";import{jsx as NB}from"react/jsx-runtime";var Ud=({input:e,placeholder:o,onChange:t,onKeyboardSubmit:n})=>{let r=gT(null),i=gT(n);return i.current=n,RB(()=>{if(!i.current)return;let a=r.current;if(a){let l=s=>{s[bT.CTRL_OR_CMD]&&s.key===bT.ENTER&&(s.preventDefault(),i.current?.())};return a.focus(),a.addEventListener(fT.KEYDOWN,l),()=>{a.removeEventListener(fT.KEYDOWN,l)}}},[]),NB("textarea",{className:"ttd-dialog-input",onChange:t,value:e,placeholder:o,ref:r})};import{jsx as Yd,jsxs as xT}from"react/jsx-runtime";var BB=({error:e})=>xT("div",{"data-testid":"ttd-dialog-output-error",className:"ttd-dialog-output-error",children:["Error! ",Yd("p",{children:e})]}),Wd=({error:e,canvasRef:o,loaded:t})=>xT("div",{className:"ttd-dialog-output-wrapper",children:[e&&Yd(BB,{error:e.message}),t?Yd("div",{ref:o,style:{opacity:e?"0.15":1},className:"ttd-dialog-output-canvas-container"}):Yd(tt,{size:"2rem"})]});import ET from"clsx";import{jsx as zg,jsxs as xl}from"react/jsx-runtime";var Hi=({label:e,children:o,panelAction:t,panelActionDisabled:n=!1,onTextSubmitInProgess:r,renderTopRight:i,renderSubmitShortcut:a,renderBottomRight:l})=>xl("div",{className:"ttd-dialog-panel",children:[xl("div",{className:"ttd-dialog-panel__header",children:[zg("label",{children:e}),i?.()]}),o,xl("div",{className:ET("ttd-dialog-panel-button-container",{invisible:!t}),style:{display:"flex",alignItems:"center"},children:[xl(Nt,{className:"ttd-dialog-panel-button",onSelect:t?t.action:()=>{},disabled:n||r,children:[xl("div",{className:ET({invisible:r}),children:[t?.label,t?.icon&&zg("span",{children:t.icon})]}),r&&zg(tt,{})]}),!n&&!r&&a?.(),l?.()]})]});import{jsx as FB}from"react/jsx-runtime";var Vd=({children:e})=>FB("div",{className:"ttd-dialog-panels",children:e});import{getShortcutKey as yT}from"@excalidraw/common";import{jsx as wT,jsxs as OB}from"react/jsx-runtime";var Xd=()=>OB("div",{className:"ttd-dialog-submit-shortcut",children:[wT("div",{className:"ttd-dialog-submit-shortcut__key",children:yT("CtrlOrCmd")}),wT("div",{className:"ttd-dialog-submit-shortcut__key",children:yT("Enter")})]});import{DEFAULT_EXPORT_PADDING as zB,EDITOR_LS_KEYS as HB}from"@excalidraw/common";var GB=({canvasRef:e,setError:o})=>{let t=e.current;if(!t)return;let n=t.parentElement;n&&(n.style.background="",o(null),t.replaceChildren())},Kd=async({canvasRef:e,mermaidToExcalidrawLib:o,mermaidDefinition:t,setError:n,data:r})=>{let i=e.current,a=i?.parentElement;if(!(!i||!a)){if(!t){GB({canvasRef:e,setError:n});return}try{let l=await o.api,s;try{s=await l.parseMermaidToExcalidraw(t)}catch{s=await l.parseMermaidToExcalidraw(t.replace(/"/g,"'"))}let{elements:m,files:d}=s;n(null),r.current={elements:Ni(m,{regenerateIds:!0}),files:d};let c=await gn({elements:r.current.elements,files:r.current.files,exportPadding:zB,maxWidthOrHeight:Math.max(a.offsetWidth,a.offsetHeight)*window.devicePixelRatio});try{await Ao(c)}catch(p){throw p.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):p}a.style.background="var(--default-bg-color)",i.replaceChildren(c)}catch(l){throw a.style.background="var(--default-bg-color)",t&&n(l),l}}},El=e=>{Wt.set(HB.MERMAID_TO_EXCALIDRAW,e)},Zd=({app:e,data:o,text:t,shouldSaveMermaidDataToStorage:n})=>{let{elements:r,files:i}=o.current;r.length&&(e.addElementsFromPasteOrLibrary({elements:r,files:i,position:"center",fitToContent:!0}),e.setOpenDialog(null),n&&t&&El(t))};import{Fragment as ZB,jsx as ko,jsxs as ST}from"react/jsx-runtime";var XB=`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]`,
|
|
18
|
-
TTD mermaid definition render errror: ${_.message}`,"color: yellow"),fe("ai","mermaid parse failed","ttd"),C(new Error("Generated an invalid diagram :(. You may also try a different prompt."))}}catch(I){let L=I.message;(!L||L==="Failed to fetch")&&(L="Request failed"),C(new Error(L))}finally{p(!1)}},b=Nf(x);b.current=x;let[E,w]=Mp({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw")});VA(()=>{(async()=>{await E.api,w(L=>({...L,loaded:!0}))})()},[E.api]);let y=Nf({elements:[],files:null}),[v,C]=Mp(null);return eo(ct,{className:"ttd-dialog",onCloseRequest:()=>{o.setOpenDialog(null)},size:1200,title:!1,...t,autofocus:!1,children:Hn(x5,{dialog:"ttd",tab:e,children:["__fallback"in t&&t.__fallback?eo("p",{className:"dialog-mermaid-title",children:f("mermaid.title")}):Hn(Rf,{children:[eo(Ip,{tab:"text-to-diagram",children:Hn("div",{style:{display:"flex",alignItems:"center"},children:[f("labels.textToDiagram"),eo("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"})]})}),eo(Ip,{tab:"mermaid",children:"Mermaid"})]}),eo(kp,{className:"ttd-dialog-content",tab:"mermaid",children:eo(h5,{mermaidToExcalidrawLib:E})}),!("__fallback"in t)&&Hn(kp,{className:"ttd-dialog-content",tab:"text-to-diagram",children:[eo("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."}),Hn(wp,{children:[eo(cl,{label:f("labels.prompt"),panelAction:{action:x,label:"Generate",icon:Ta},onTextSubmitInProgess:d,panelActionDisabled:c.length>dl||u?.rateLimitRemaining===0,renderTopRight:()=>u?Hn("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:()=>eo(Tp,{}),renderBottomRight:()=>{if(typeof i?.generatedResponse=="string")return Hn("div",{className:"excalidraw-link",style:{marginLeft:"auto",fontSize:14},onClick:()=>{typeof i?.generatedResponse=="string"&&(Bs(i.generatedResponse),r({openDialog:{name:"ttd",tab:"mermaid"}}))},children:["View as Mermaid",eo(An,{icon:Ta})]});let I=c.length/dl;return I>.8?Hn("div",{style:{marginLeft:"auto",fontSize:12,fontFamily:"monospace",color:I>1?"var(--color-danger)":void 0},children:["Length: ",c.length,"/",dl]}):null},children:eo(Ep,{onChange:m,input:l,placeholder:"Describe what you want to see...",onKeyboardSubmit:()=>{b.current()}})}),eo(cl,{label:"Preview",panelAction:{action:()=>{console.info("Panel action clicked"),Cp({app:o,data:y})},label:"Insert",icon:Ta},children:eo(vp,{canvasRef:n,error:v,loaded:E.loaded})})]})]})]})})});import NL from"clsx";import OL from"lodash.throttle";import{useEffect as N5,useMemo as Vf,useState as BL,memo as FL}from"react";import ZA from"clsx";import{useEffect as S5,useRef as Ap,useState as XA}from"react";var T5=.01,Fs=10,fo=(e,t)=>!(t==="height"&&K(e)||t==="width"&&K(e)||t==="angle"&&J(e)),Qe=(e,t)=>{let o=e+t/2;return o-o%t},ml=(e,t,o)=>Object.keys(e).map(r=>({original:(o??t).get(r),latest:t.get(r)})).filter(r=>r.original!==void 0&&r.latest!==void 0);var zi=(e,t,o,r,n,i=!0)=>{let a=r.getNonDeletedElementsMap(),l=a.get(o.id);if(!l)return;let[s,c]=[o.x+o.width/2,o.y+o.height/2],[m,d]=ie(M(o.x,o.y),M(s,c),o.angle),p=e-m,u=t-d,[h,x]=ie(M(e,t),M(s+p,c+u),-o.angle);r.mutateElement(l,{x:h,y:x},{informMutation:i,isDragging:!1}),En(l,r);let b=pe(o,n);if(b){let E=a.get(b.id);E&&r.mutateElement(E,{x:b.x+p,y:b.y+u},{informMutation:i,isDragging:!1})}if(J(o)){let E=so(n,o.id);E.forEach(w=>{let y=a.get(w.id);if(!y)return;let[v,C]=[w.x+w.width/2,w.y+w.height/2],[I,L]=ie(M(w.x,w.y),M(v,C),w.angle),A=Math.round(I+p),R=Math.round(L+u),[_,z]=ie(M(A,R),M(v+p,C+u),-w.angle);r.mutateElement(y,{x:_,y:z},{informMutation:i,isDragging:!1}),En(y,r,{simultaneouslyUpdated:E})})}},pl=(e,t)=>{let r=qo(t).map(n=>Be(e,n).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(n=>!br(n)).forEach(n=>{r.push({[n.id]:!0})}),r};import{jsx as Ff,jsxs as jA}from"react/jsx-runtime";var $A=({label:e,icon:t,dragInputCallback:o,value:r,elements:n,editable:i=!0,shouldKeepAspectRatio:a,property:l,scene:s,appState:c,sensitivity:m=1})=>{let d=lt(),p=Ap(null),u=Ap(null),[h,x]=XA(r.toString()),b=Ap(null);b.current||(b.current={originalAppState:lo(c),originalElements:n,lastUpdatedValue:h,updatePending:!1}),S5(()=>{let y=r.toString();x(y),b.current.lastUpdatedValue=y},[r]);let E=(y,v,C)=>{if(!b.current.updatePending)return!1;b.current.updatePending=!1;let I=Number(y);if(isNaN(I)){x(r.toString());return}let L=Number(I.toFixed(2)),A=Number(r);(isNaN(A)||Math.abs(L-A)>=T5)&&(b.current.lastUpdatedValue=y,o({accumulatedChange:0,instantChange:0,originalElements:v,originalElementsMap:d.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:s,nextValue:L,property:l,originalAppState:C,setInputValue:R=>x(String(R))}),d.syncActionResult({captureUpdate:D.IMMEDIATELY}))},w=Ap({});return w.current.handleInputValue=E,S5(()=>{let y=p.current,v=w.current;return()=>{let C=y?.value;C&&v.handleInputValue?.(C,b.current.originalElements,b.current.originalAppState),window.removeEventListener("pointermove",v.onPointerMove,!1),window.removeEventListener("pointerup",v.onPointerUp,!1)}},[i]),i?jA("div",{className:ZA("drag-input-container",!i&&"disabled"),"data-testid":e,children:[Ff("div",{className:"drag-input-label",ref:u,onPointerDown:y=>{if(p.current&&i){document.body.classList.add("excalidraw-cursor-resize");let v=Number(p.current.value);isNaN(v)&&(v=0);let C=null,I=d.scene.getNonDeletedElements().reduce((G,j)=>(G.set(j.id,mo(j)),G),new Map),L=n.map(G=>I.get(G.id)),A=lo(c),R=0,_=0,z=G=>{if(C&&I!==null&&L!==null){let j=G.clientX-C.x;j!==0&&(_+=j,Math.abs(_)>=m&&(_=Math.sign(_)*Math.floor(Math.abs(_)/m),R+=_,o({accumulatedChange:R,instantChange:_,originalElements:L,originalElementsMap:I,shouldKeepAspectRatio:a,shouldChangeByStepSize:G.shiftKey,property:l,scene:s,originalAppState:A,setInputValue:H=>x(String(H))}),_=0))}C={x:G.clientX,y:G.clientY}},W=()=>{window.removeEventListener("pointermove",z,!1),d.syncActionResult({captureUpdate:D.IMMEDIATELY}),C=null,R=0,_=0,L=null,I=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener("pointerup",W,!1)};w.current.onPointerMove=z,w.current.onPointerUp=W,window.addEventListener("pointermove",z,!1),window.addEventListener("pointerup",W,!1)}},onPointerEnter:()=>{u.current&&(u.current.style.cursor="ew-resize")},children:t?Ff(An,{icon:t}):e}),Ff("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:y=>{if(i){let v=y.target;v instanceof HTMLInputElement&&y.key===T.ENTER&&(E(v.value,n,c),d.focusContainer())}},ref:p,value:h,onChange:y=>{b.current.updatePending=!0,x(y.target.value)},onFocus:y=>{y.target.select(),b.current.originalElements=n,b.current.originalAppState=lo(c)},onBlur:y=>{h?i&&E(y.target.value,b.current.originalElements,b.current.originalAppState):x(r.toString())},disabled:!i})]}):null},_t=$A;import{jsx as eL}from"react/jsx-runtime";var qA=15,JA=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:o,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=t[0];if(a&&!ee(a)){let l=i.get(a.id);if(!l)return;if(r!==void 0){let u=Vi(r);n.mutateElement(l,{angle:u}),En(l,n);let h=pe(l,i);h&&!Ie(l)&&n.mutateElement(h,{angle:u});return}let s=Math.round(Yi(a.angle)*100)/100,c=Math.round(e),m=(s+c)%360;o&&(m=Qe(m,qA)),m=m<0?m+360:m;let d=Vi(m);n.mutateElement(l,{angle:d}),En(l,n);let p=pe(l,i);p&&!Ie(l)&&n.mutateElement(p,{angle:d})}},QA=({element:e,scene:t,appState:o,property:r})=>eL(_t,{label:"A",icon:Dd,value:Math.round(Yi(e.angle)%360*100)/100,elements:[e],dragInputCallback:JA,editable:fo(e,"angle"),scene:t,appState:o,property:r}),C5=QA;import{jsx as oL}from"react/jsx-runtime";var I5=5,tL=({property:e,scene:t,appState:o,setAppState:r})=>oL(_t,{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?Qe(s.gridStep+I5*Math.sign(i),I5):s.gridStep+i),c?(c=G0(c),l(c),{gridStep:c}):(l(s.gridStep),null)})},scene:t,value:o.gridStep,property:e,appState:o}),k5=tL;import{jsx as aL}from"react/jsx-runtime";var M5=10,rL=e=>e.type==="image",nL=({accumulatedChange:e,originalElements:t,originalElementsMap:o,shouldKeepAspectRatio:r,shouldChangeByStepSize:n,nextValue:i,property:a,originalAppState:l,instantChange:s,scene:c})=>{let m=c.getNonDeletedElementsMap(),d=t[0],p=m.get(d.id);if(d&&p){let u=r||rL(d),h=d.width/d.height;if(l.croppingElementId===d.id){let y=m.get(d.id);if(!y||!xe(y)||!y.crop)return;let v=y.crop,C={...v},I=y.scale[0]===-1,L=y.scale[1]===-1,{width:A,height:R}=ai(y),_=v.naturalWidth/A,z=v.naturalHeight/R,W=I?v.width+v.x:v.naturalWidth-v.x,G=L?v.height+v.y:v.naturalHeight-v.y,j=pu*_,H=pu*z;if(i!==void 0){if(a==="width"){let ce=i*_,ue=It(ce,j,W);C={...C,width:ue,x:I?v.x+v.width-ue:v.x}}else if(a==="height"){let ce=i*z,ue=It(ce,H,G);C={...C,height:ue,y:L?v.y+v.height-ue:v.y}}c.mutateElement(y,{crop:C,width:C.width/(v.naturalWidth/A),height:C.height/(v.naturalHeight/R)});return}let B=a==="width"?s:0,U=a==="height"?s:0,oe=It(v.width+B,j,W),Z=It(v.height+U,j,G);C={...v,x:I?v.x+v.width-oe:v.x,y:L?v.y+v.height-Z:v.y,width:oe,height:Z},c.mutateElement(y,{crop:C,width:C.width/(v.naturalWidth/A),height:C.height/(v.naturalHeight/R)});return}if(i!==void 0){let y=Math.max(a==="width"?i:u?i*h:d.width,ao),v=Math.max(a==="height"?i:u?i/h:d.height,ao);xi(y,v,p,d,o,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:u});return}let x=a==="width"?e:0,b=a==="height"?e:0,E=Math.max(0,d.width+x);a==="width"&&(n?E=Qe(E,M5):E=Math.round(E));let w=Math.max(0,d.height+b);a==="height"&&(n?w=Qe(w,M5):w=Math.round(w)),u&&(a==="width"?w=Math.round(E/h*100)/100:E=Math.round(w*h*100)/100),w=Math.max(ao,w),E=Math.max(ao,E),xi(E,w,p,d,o,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:u})}},iL=({property:e,element:t,scene:o,appState:r})=>{let n=Do(e==="width"?t.width:t.height,2);if(r.croppingElementId&&r.croppingElementId===t.id&&xe(t)&&t.crop){let{width:i,height:a}=ai(t);if(e==="width"){let l=i/t.crop.naturalWidth;n=Do(t.crop.width*l,2)}if(e==="height"){let l=a/t.crop.naturalHeight;n=Do(t.crop.height*l,2)}}return aL(_t,{label:e==="width"?"W":"H",elements:[t],dragInputCallback:nL,value:n,editable:fo(t,e),scene:o,appState:r,property:e})},zf=iL;import{jsx as dL}from"react/jsx-runtime";var A5=4,lL=4,sL=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:o,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=t[0];if(a){let l=i.get(a.id);if(!l||!K(l))return;let s;if(r!==void 0)s=Math.max(Math.round(r),A5);else if(a.type==="text"){let c=Math.round(a.fontSize),m=Math.round(e);s=Math.max(c+m,A5),o&&(s=Qe(s,lL))}s&&(n.mutateElement(l,{fontSize:s}),Xe(l,n.getContainerElement(l),n))}},cL=({element:e,scene:t,appState:o,property:r})=>{let n=K(e)?e:it(e)?pe(e,t.getNonDeletedElementsMap()):null;return n?dL(_t,{label:"F",value:Math.round(n.fontSize*10)/10,elements:[n],dragInputCallback:sL,icon:Ci,appState:o,scene:t,property:r}):null},L5=cL;import{jsx as hL}from"react/jsx-runtime";var mL=15,pL=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:o,nextValue:r,property:n,scene:i})=>{let a=i.getNonDeletedElementsMap(),l=t.map(c=>a.get(c.id)).filter(c=>c&&!br(c)&&fo(c,n)),s=t.filter(c=>!br(c)&&fo(c,n));if(r!==void 0){let c=Vi(r);for(let m of l){if(!m)continue;i.mutateElement(m,{angle:c});let d=pe(m,a);d&&!Ie(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(Yi(d.angle)*100)/100,u=Math.round(e),h=(p+u)%360;o&&(h=Qe(h,mL)),h=h<0?h+360:h;let x=Vi(h);i.mutateElement(m,{angle:x});let b=pe(m,a);b&&!Ie(m)&&i.mutateElement(b,{angle:x})}i.triggerUpdate()},uL=({elements:e,scene:t,appState:o,property:r})=>{let n=e.filter(s=>!br(s)&&fo(s,"angle")),i=n.map(s=>Math.round(Yi(s.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",l=n.some(s=>fo(s,"angle"));return hL(_t,{label:"A",icon:Dd,value:a,elements:e,dragInputCallback:pL,editable:l,appState:o,scene:t,property:r})},D5=uL;import{useMemo as gL}from"react";import{jsx as yL}from"react/jsx-runtime";var ul=10,fL=(e,t,o,r)=>{let n=r.x-e,i=r.y-t,a=r.width*o,l=r.height*o,s=e+n*o,c=t+i*o;return{width:a,height:l,x:s,y:c,...hd(r,a,l,!1),...K(r)?{fontSize:r.fontSize*o}:{}}},bL=(e,t,o,r,n,i,a,l)=>{let s=l.getNonDeletedElementsMap(),c=fL(e,t,r,i);l.mutateElement(n,c);let m=pe(i,a);if(m){let d=m.fontSize*r;gt(n,l,{newSize:{width:c.width,height:c.height}});let p=s.get(m.id);p&&K(p)&&(l.mutateElement(p,{fontSize:d}),Pl(n,l,o==="width"?"e":"s",!0))}},_5=(e,t,o,r,n,i,a,l,s,c)=>{i==="width"?t=Math.round(e/r*100)/100:e=Math.round(t*r*100)/100;let m=t/o;for(let d=0;d<l.length;d++){let p=l[d],u=a[d];bL(n[0],n[1],i,m,u,p,s,c)}},xL=({accumulatedChange:e,originalElements:t,originalElementsMap:o,originalAppState:r,shouldChangeByStepSize:n,nextValue:i,scene:a,property:l})=>{let s=a.getNonDeletedElementsMap(),c=pl(t,r);if(i!==void 0){for(let p of c){let u=ml(p,s,o);if(u.length>1){let h=u.map(R=>R.latest),x=u.map(R=>R.original),[b,E,w,y]=Ee(x),v=w-b,C=y-E,I=v/C,L=Math.max(ao,l==="width"?Math.max(0,i):v),A=Math.max(ao,l==="height"?Math.max(0,i):C);_5(L,A,C,I,M(b,E),l,h,x,o,a)}else{let[h]=u,x=h?.latest,b=h?.original;if(x&&b&&fo(x,l)){let E=l==="width"?Math.max(0,i):x.width;l==="width"&&(n?E=Qe(E,ul):E=Math.round(E));let w=l==="height"?Math.max(0,i):x.height;l==="height"&&(n?w=Qe(w,ul):w=Math.round(w)),E=Math.max(ao,E),w=Math.max(ao,w),xi(E,w,x,b,o,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=ml(p,s,o);if(u.length>1){let h=u.map(R=>R.latest),x=u.map(R=>R.original),[b,E,w,y]=Ee(x),v=w-b,C=y-E,I=v/C,L=Math.max(0,v+m);l==="width"&&(n?L=Qe(L,ul):L=Math.round(L));let A=Math.max(0,C+d);l==="height"&&(n?A=Qe(A,ul):A=Math.round(A)),L=Math.max(ao,L),A=Math.max(ao,A),_5(L,A,C,I,M(b,E),l,h,x,o,a)}else{let[h]=u,x=h?.latest,b=h?.original;if(x&&b&&fo(x,l)){let E=Math.max(0,b.width+m);l==="width"&&(n?E=Qe(E,ul):E=Math.round(E));let w=Math.max(0,b.height+d);l==="height"&&(n?w=Qe(w,ul):w=Math.round(w)),E=Math.max(ao,E),w=Math.max(ao,w),xi(E,w,x,b,o,a,l==="width"?"e":"s",{shouldInformMutation:!1})}}}a.triggerUpdate()},EL=({property:e,elements:t,elementsMap:o,atomicUnits:r,scene:n,appState:i})=>{let a=gL(()=>r.map(c=>{let m=ml(c,o);if(m.length>1){let[p,u,h,x]=Ee(m.map(b=>b.latest));return Math.round((e==="width"?h-p:x-u)*100)/100}let[d]=m;return Math.round((e==="width"?d.latest.width:d.latest.height)*100)/100}),[o,r,e]),l=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",s=a.length>0;return yL(_t,{label:e==="width"?"W":"H",elements:t,dragInputCallback:xL,value:l,editable:s,appState:i,property:e,scene:n})},Hf=EL;import{jsx as CL}from"react/jsx-runtime";var P5=4,vL=4,wL=(e,t)=>e.reduce((o,r)=>{if(!r||br(r))return o;if(K(r))return o.push(r),o;if(it(r)){let n=pe(r,t);if(n)return o.push(n),o}return o},[]),TL=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:o,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=t.map(s=>i.get(s.id)),l;if(r){l=Math.max(Math.round(r),P5);for(let s of a)n.mutateElement(s,{fontSize:l}),Xe(s,n.getContainerElement(s),n);n.triggerUpdate()}else{let s=t;for(let c=0;c<a.length;c++){let m=a[c],d=s[c],p=Math.round(d.fontSize),u=Math.round(e),h=Math.max(p+u,P5);o&&(h=Qe(h,vL)),n.mutateElement(m,{fontSize:h}),Xe(m,n.getContainerElement(m),n)}n.triggerUpdate()}},SL=({elements:e,scene:t,appState:o,property:r,elementsMap:n})=>{let i=wL(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 CL(_t,{label:"F",icon:Ci,elements:i,dragInputCallback:TL,value:l,editable:s,scene:t,property:r,appState:o})},R5=SL;import{useMemo as IL}from"react";import{jsx as DL}from"react/jsx-runtime";var kL=(e,t,o,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]=ie(M(l.x,l.y),M(s,c),l.angle),p=e==="x"?Math.round(m+t):m,u=e==="y"?Math.round(d+o):d;zi(p,u,l,i,n,!1)}},ML=(e,t,o,r,n)=>{let i=n.getNonDeletedElementsMap(),[a,l,,]=Ee(o),s=e-a,c=t-l;for(let m=0;m<o.length;m++){let d=o[m],p=i.get(d.id);if(p&&(!K(p)||!p.containerId)){let[u,h]=[p.x+p.width/2,p.y+p.height/2],[x,b]=ie(M(p.x,p.y),M(u,h),p.angle);zi(x+s,b+c,d,n,r,!1)}}},AL=({accumulatedChange:e,originalElements:t,originalElementsMap:o,shouldChangeByStepSize:r,nextValue:n,property:i,scene:a,originalAppState:l})=>{let s=a.getNonDeletedElementsMap();if(n!==void 0){for(let p of pl(t,l)){let u=ml(p,s,o);if(u.length>1){let[h,x,,]=Ee(u.map(w=>w.latest));ML(i==="x"?n:h,i==="y"?n:x,u.map(w=>w.original),o,a)}else{let h=u[0]?.original,x=u[0]?.latest;if(h&&x&&fo(x,i)){let[b,E]=[h.x+h.width/2,h.y+h.height/2],[w,y]=ie(M(h.x,h.y),M(b,E),h.angle);zi(i==="x"?n:w,i==="y"?n:y,h,a,o,!1)}}}a.triggerUpdate();return}let c=r?Qe(e,Fs):e;kL(i,i==="x"?c:0,i==="y"?c:0,t,o,a),a.triggerUpdate()},LL=({property:e,elements:t,elementsMap:o,atomicUnits:r,scene:n,appState:i})=>{let a=IL(()=>r.map(s=>{let c=Object.keys(s).map(x=>o.get(x)).filter(x=>x!==void 0);if(c.length>1){let[x,b]=Ee(c);return Math.round((e==="x"?x:b)*100)/100}let[m]=c,[d,p]=[m.x+m.width/2,m.y+m.height/2],[u,h]=ie(M(m.x,m.y),M(d,p),m.angle);return Math.round((e==="x"?u:h)*100)/100}),[r,o,e]),l=new Set(a).size===1?a[0]:"Mixed";return DL(_t,{label:e==="x"?"X":"Y",elements:t,dragInputCallback:AL,value:l,property:e,scene:n,appState:i})},Uf=LL;import{jsx as RL}from"react/jsx-runtime";var _L=({accumulatedChange:e,instantChange:t,originalElements:o,originalElementsMap:r,shouldChangeByStepSize:n,nextValue:i,property:a,scene:l,originalAppState:s})=>{let c=l.getNonDeletedElementsMap(),m=o[0],[d,p]=[m.x+m.width/2,m.y+m.height/2],[u,h]=ie(M(m.x,m.y),M(d,p),m.angle);if(s.croppingElementId===m.id){let y=c.get(m.id);if(!y||!xe(y)||!y.crop)return;let v=y.crop,C=v,I=y.scale[0]===-1,L=y.scale[1]===-1,{width:A,height:R}=ai(y);if(i!==void 0){if(a==="x"){let W=i*(v.naturalWidth/A);I?C={...v,x:It(v.naturalWidth-W-v.width,0,v.naturalWidth-v.width)}:C={...v,x:It(i*(v.naturalWidth/A),0,v.naturalWidth-v.width)}}a==="y"&&(C={...v,y:It(i*(v.naturalHeight/R),0,v.naturalHeight-v.height)}),l.mutateElement(y,{crop:C});return}let _=(a==="x"?t:0)*(I?-1:1),z=(a==="y"?t:0)*(L?-1:1);C={...v,x:It(v.x+_,0,v.naturalWidth-v.width),y:It(v.y+z,0,v.naturalHeight-v.height)},l.mutateElement(y,{crop:C});return}if(i!==void 0){zi(a==="x"?i:u,a==="y"?i:h,m,l,r);return}let x=a==="x"?e:0,b=a==="y"?e:0,E=a==="x"?Math.round(n?Qe(m.x+x,Fs):u+x):u,w=a==="y"?Math.round(n?Qe(m.y+b,Fs):h+b):h;zi(E,w,m,l,r)},PL=({property:e,element:t,elementsMap:o,scene:r,appState:n})=>{let[i,a]=ie(M(t.x,t.y),M(t.x+t.width/2,t.y+t.height/2),t.angle),l=Do(e==="x"?i:a,2);if(n.croppingElementId===t.id&&xe(t)&&t.crop){let s=zb(t);s&&(l=Do(e==="x"?s.x:s.y,2))}return RL(_t,{label:e==="x"?"X":"Y",elements:[t],dragInputCallback:_L,scene:r,value:l,property:e,appState:n})},Gf=PL;import{Fragment as Yf,jsx as ae,jsxs as bo}from"react/jsx-runtime";var zL=50,zs=e=>{let t=wr(),o=e.app.scene.getSceneNonce()||1,r=e.app.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}),n=Rn(e.app);return ae(HL,{...e,appState:t,sceneNonce:o,selectedElements:r,gridModeEnabled:n})},qe=({children:e,columns:t=1,heading:o,style:r,...n})=>ae("div",{className:NL("exc-stats__row",{"exc-stats__row--heading":o}),style:{gridTemplateColumns:`repeat(${t}, 1fr)`,...r},...n,children:e});qe.displayName="StatsRow";var Lp=({children:e,order:t,style:o,...r})=>ae("div",{className:"exc-stats__rows",style:{order:t,...o},...r,children:e});Lp.displayName="StatsRows";zs.StatsRow=qe;zs.StatsRows=Lp;var HL=FL(({app:e,onClose:t,renderCustomStats:o,selectedElements:r,appState:n,sceneNonce:i,gridModeEnabled:a})=>{let l=e.scene,s=l.getNonDeletedElements(),c=l.getNonDeletedElementsMap(),m=Se(),d=r.length===1?r[0]:null,p=r.length>1?r:null,u=n.croppingElementId&&xe(d),h=u?ai(d):null,[x,b]=BL({width:0,height:0}),E=Vf(()=>OL(v=>{let C=Ee(v);b({width:Math.round(C[2])-Math.round(C[0]),height:Math.round(C[3])-Math.round(C[1])})},zL),[]);N5(()=>{E(s)},[i,s,E]),N5(()=>()=>E.cancel(),[E]);let w=Vf(()=>pl(r,n),[r,n]),y=Vf(()=>zc(r),[r]);return ae("div",{className:"exc-stats",children:bo(wt,{padding:3,children:[bo("div",{className:"title",children:[ae("h2",{children:f("stats.title")}),ae("div",{className:"close",onClick:t,children:Po})]}),bo(hs,{label:ae("h3",{children:f("stats.generalStats")}),open:!!(n.stats.panels&Cl.generalStats),openTrigger:()=>m(v=>({stats:{open:!0,panels:v.stats.panels^Cl.generalStats}})),children:[bo(Lp,{children:[ae(qe,{heading:!0,children:f("stats.scene")}),bo(qe,{columns:2,children:[ae("div",{children:f("stats.shapes")}),ae("div",{children:s.length})]}),bo(qe,{columns:2,children:[ae("div",{children:f("stats.width")}),ae("div",{children:x.width})]}),bo(qe,{columns:2,children:[ae("div",{children:f("stats.height")}),ae("div",{children:x.height})]}),a&&bo(Yf,{children:[ae(qe,{heading:!0,children:"Canvas"}),ae(qe,{children:ae(k5,{property:"gridStep",scene:l,appState:n,setAppState:m})})]})]}),o?.(s,n)]}),!y&&r.length>0&&ae("div",{id:"elementStats",style:{marginTop:12},children:ae(hs,{label:ae("h3",{children:f("stats.elementProperties")}),open:!!(n.stats.panels&Cl.elementProperties),openTrigger:()=>m(v=>({stats:{open:!0,panels:v.stats.panels^Cl.elementProperties}})),children:bo(Lp,{children:[d&&bo(Yf,{children:[u&&ae(qe,{heading:!0,children:f("labels.unCroppedDimension")}),n.croppingElementId&&xe(d)&&h&&bo(qe,{columns:2,children:[ae("div",{children:f("stats.width")}),ae("div",{children:Do(h.width,2)})]}),n.croppingElementId&&xe(d)&&h&&bo(qe,{columns:2,children:[ae("div",{children:f("stats.height")}),ae("div",{children:Do(h.height,2)})]}),ae(qe,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:n.croppingElementId?f("labels.imageCropping"):f(`element.${d.type}`)}),ae(qe,{children:ae(Gf,{element:d,property:"x",elementsMap:c,scene:l,appState:n})}),ae(qe,{children:ae(Gf,{element:d,property:"y",elementsMap:c,scene:l,appState:n})}),ae(qe,{children:ae(zf,{property:"width",element:d,scene:l,appState:n})}),ae(qe,{children:ae(zf,{property:"height",element:d,scene:l,appState:n})}),!ee(d)&&ae(qe,{children:ae(C5,{property:"angle",element:d,scene:l,appState:n})}),ae(qe,{children:ae(L5,{property:"fontSize",element:d,scene:l,appState:n})})]}),p&&bo(Yf,{children:[i0(p)&&ae(qe,{heading:!0,children:f("element.group")}),bo(qe,{columns:2,style:{margin:"0.3125rem 0"},children:[ae("div",{children:f("stats.shapes")}),ae("div",{children:r.length})]}),ae(qe,{children:ae(Uf,{property:"x",elements:p,elementsMap:c,atomicUnits:w,scene:l,appState:n})}),ae(qe,{children:ae(Uf,{property:"y",elements:p,elementsMap:c,atomicUnits:w,scene:l,appState:n})}),ae(qe,{children:ae(Hf,{property:"width",elements:p,elementsMap:c,atomicUnits:w,scene:l,appState:n})}),ae(qe,{children:ae(Hf,{property:"height",elements:p,elementsMap:c,atomicUnits:w,scene:l,appState:n})}),ae(qe,{children:ae(D5,{property:"angle",elements:p,scene:l,appState:n})}),ae(qe,{children:ae(R5,{property:"fontSize",elements:p,scene:l,appState:n,elementsMap:c})})]})]})})})]})})},(e,t)=>e.sceneNonce===t.sceneNonce&&e.selectedElements===t.selectedElements&&e.appState.stats.panels===t.appState.stats.panels&&e.gridModeEnabled===t.gridModeEnabled&&e.appState.gridStep===t.appState.gridStep&&e.appState.croppingElementId===t.appState.croppingElementId);import{useCallback as UL,useEffect as O5,useState as B5}from"react";import{jsx as hl,jsxs as Dp}from"react/jsx-runtime";var GL=({sourceElementId:e,onClose:t,appState:o,scene:r,generateLinkForSelection:n=$c})=>{let i=r.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[l,s]=B5(a),[c,m]=B5(!1);O5(()=>{let p=Q(i,o),u=a;if(p.length>0&&n){let h=jc(p,o);h&&(u=jo(n(h.id,h.type)))}s(u)},[i,o,o.selectedElementIds,a,n]);let d=UL(()=>{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})}t?.()},[e,l,i,c,r,t]);return O5(()=>{let p=u=>{o.openDialog?.name==="elementLinkSelector"&&u.key===T.ENTER&&d(),o.openDialog?.name==="elementLinkSelector"&&u.key===T.ESCAPE&&t?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[o,t,d]),Dp("div",{className:"ElementLinkDialog",children:[Dp("div",{className:"ElementLinkDialog__header",children:[hl("h2",{children:f("elementLink.title")}),hl("p",{children:f("elementLink.desc")})]}),Dp("div",{className:"ElementLinkDialog__input",children:[hl(ol,{value:l??"",onChange:p=>{c||m(!0),s(p)},onKeyDown:p=>{p.key===T.ENTER&&d()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&l&&hl(te,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:()=>{s(null),m(!0)},className:"ElementLinkDialog__remove",icon:vo})]}),Dp("div",{className:"ElementLinkDialog__actions",children:[hl(Xr,{label:f("buttons.cancel"),onClick:()=>{t?.()},style:{marginRight:10}}),hl(Xr,{label:f("buttons.confirm"),onClick:d,actionType:"primary"})]})]})},F5=GL;import VL,{useState as YL}from"react";import{Fragment as WL,jsx as Wf}from"react/jsx-runtime";var z5=({children:e,onClose:t})=>{let[o,r]=YL(!!e),{container:n}=ft(),i=VL.useCallback(()=>{r(!1),t&&t(),n?.focus()},[t,n]);return Wf(WL,{children:o&&Wf(ct,{size:"small",onCloseRequest:i,title:f("errorDialog.title"),children:Wf("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import KL from"react";import{Fragment as U5,jsx as V,jsxs as Ao}from"react/jsx-runtime";var ZL=()=>Ao("div",{className:"HelpDialog__header",children:[Ao("a",{className:"HelpDialog__btn",href:"https://docs.excalidraw.com",target:"_blank",rel:"noopener",children:[V("div",{className:"HelpDialog__link-icon",children:nh}),f("helpDialog.documentation")]}),Ao("a",{className:"HelpDialog__btn",href:"https://plus.excalidraw.com/blog",target:"_blank",rel:"noopener",children:[V("div",{className:"HelpDialog__link-icon",children:nh}),f("helpDialog.blog")]}),Ao("a",{className:"HelpDialog__btn",href:"https://github.com/excalidraw/excalidraw/issues",target:"_blank",rel:"noopener noreferrer",children:[V("div",{className:"HelpDialog__link-icon",children:Id}),f("helpDialog.github")]}),Ao("a",{className:"HelpDialog__btn",href:"https://youtube.com/@excalidraw",target:"_blank",rel:"noopener noreferrer",children:[V("div",{className:"HelpDialog__link-icon",children:py}),"YouTube"]})]}),XL=e=>Ao(U5,{children:[V("h3",{children:e.title}),V("div",{className:"HelpDialog__islands-container",children:e.children})]}),Kf=e=>Ao("div",{className:`HelpDialog__island ${e.className}`,children:[V("h4",{className:"HelpDialog__island-title",children:e.caption}),V("div",{className:"HelpDialog__island-content",children:e.children})]});function*$L(e,t){let o=!0;for(let r of e)o||(yield t),o=!1,yield r}var jL=e=>e.replace(/\b[a-z]\b/,t=>t.toUpperCase()),X=({label:e,shortcuts:t,isOr:o=!0})=>{let r=t.map(n=>(n.endsWith("++")?[...n.slice(0,-2).split("+"),"+"]:n.split("+")).map(a=>V(qL,{children:jL(a)},a)));return Ao("div",{className:"HelpDialog__shortcut",children:[V("div",{children:e}),V("div",{className:"HelpDialog__key-container",children:[...$L(r,o?f("helpDialog.or"):null)]})]})},qL=e=>V("kbd",{className:"HelpDialog__key",...e}),H5=({onClose:e})=>{let t=KL.useCallback(()=>{e&&e()},[e]);return V(U5,{children:Ao(ct,{onCloseRequest:t,title:f("helpDialog.title"),className:"HelpDialog",children:[V(ZL,{}),Ao(XL,{title:f("helpDialog.shortcuts"),children:[Ao(Kf,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[V(X,{label:f("toolBar.hand"),shortcuts:[T.H]}),V(X,{label:f("toolBar.selection"),shortcuts:[T.V,T[1]]}),V(X,{label:f("toolBar.rectangle"),shortcuts:[T.R,T[2]]}),V(X,{label:f("toolBar.diamond"),shortcuts:[T.D,T[3]]}),V(X,{label:f("toolBar.ellipse"),shortcuts:[T.O,T[4]]}),V(X,{label:f("toolBar.arrow"),shortcuts:[T.A,T[5]]}),V(X,{label:f("toolBar.line"),shortcuts:[T.L,T[6]]}),V(X,{label:f("toolBar.freedraw"),shortcuts:[T.P,T[7]]}),V(X,{label:f("toolBar.text"),shortcuts:[T.T,T[8]]}),V(X,{label:f("toolBar.image"),shortcuts:[T[9]]}),V(X,{label:f("toolBar.eraser"),shortcuts:[T.E,T[0]]}),V(X,{label:f("toolBar.frame"),shortcuts:[T.F]}),V(X,{label:f("toolBar.laser"),shortcuts:[T.K]}),V(X,{label:f("labels.eyeDropper"),shortcuts:[T.I,"Shift+S","Shift+G"]}),V(X,{label:f("helpDialog.editLineArrowPoints"),shortcuts:[N("CtrlOrCmd+Enter")]}),V(X,{label:f("helpDialog.editText"),shortcuts:[N("Enter")]}),V(X,{label:f("helpDialog.textNewLine"),shortcuts:[N("Enter"),N("Shift+Enter")]}),V(X,{label:f("helpDialog.textFinish"),shortcuts:[N("Esc"),N("CtrlOrCmd+Enter")]}),V(X,{label:f("helpDialog.curvedArrow"),shortcuts:["A",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),V(X,{label:f("helpDialog.curvedLine"),shortcuts:["L",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),V(X,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),V(X,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0}),V(X,{label:f("toolBar.lock"),shortcuts:[T.Q]}),V(X,{label:f("helpDialog.preventBinding"),shortcuts:[N("CtrlOrCmd")]}),V(X,{label:f("toolBar.link"),shortcuts:[N("CtrlOrCmd+K")]}),V(X,{label:f("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),Ao(Kf,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[V(X,{label:f("buttons.zoomIn"),shortcuts:[N("CtrlOrCmd++")]}),V(X,{label:f("buttons.zoomOut"),shortcuts:[N("CtrlOrCmd+-")]}),V(X,{label:f("buttons.resetZoom"),shortcuts:[N("CtrlOrCmd+0")]}),V(X,{label:f("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),V(X,{label:f("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),V(X,{label:f("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),V(X,{label:f("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),V(X,{label:f("buttons.zenMode"),shortcuts:[N("Alt+Z")]}),V(X,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]}),V(X,{label:f("labels.toggleGrid"),shortcuts:[N("CtrlOrCmd+'")]}),V(X,{label:f("labels.viewMode"),shortcuts:[N("Alt+R")]}),V(X,{label:f("labels.toggleTheme"),shortcuts:[N("Alt+Shift+D")]}),V(X,{label:f("stats.fullTitle"),shortcuts:[N("Alt+/")]}),V(X,{label:f("search.title"),shortcuts:[st("searchMenu")]}),V(X,{label:f("commandPalette.title"),shortcuts:Pr?[st("commandPalette")]:[st("commandPalette"),st("commandPalette",1)]})]}),Ao(Kf,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[V(X,{label:f("helpDialog.createFlowchart"),shortcuts:[N("CtrlOrCmd+Arrow Key")],isOr:!0}),V(X,{label:f("helpDialog.navigateFlowchart"),shortcuts:[N("Alt+Arrow Key")],isOr:!0}),V(X,{label:f("labels.moveCanvas"),shortcuts:[N(`Space+${f("helpDialog.drag")}`),N(`Wheel+${f("helpDialog.drag")}`)],isOr:!0}),V(X,{label:f("buttons.clearReset"),shortcuts:[N("CtrlOrCmd+Delete")]}),V(X,{label:f("labels.delete"),shortcuts:[N("Delete")]}),V(X,{label:f("labels.cut"),shortcuts:[N("CtrlOrCmd+X")]}),V(X,{label:f("labels.copy"),shortcuts:[N("CtrlOrCmd+C")]}),V(X,{label:f("labels.paste"),shortcuts:[N("CtrlOrCmd+V")]}),V(X,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),V(X,{label:f("labels.selectAll"),shortcuts:[N("CtrlOrCmd+A")]}),V(X,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),V(X,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),V(X,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(Ra||Pr)&&V(X,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),V(X,{label:f("labels.copyStyles"),shortcuts:[N("CtrlOrCmd+Alt+C")]}),V(X,{label:f("labels.pasteStyles"),shortcuts:[N("CtrlOrCmd+Alt+V")]}),V(X,{label:f("labels.sendToBack"),shortcuts:[Wo?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")]}),V(X,{label:f("labels.bringToFront"),shortcuts:[Wo?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")]}),V(X,{label:f("labels.sendBackward"),shortcuts:[N("CtrlOrCmd+[")]}),V(X,{label:f("labels.bringForward"),shortcuts:[N("CtrlOrCmd+]")]}),V(X,{label:f("labels.alignTop"),shortcuts:[N("CtrlOrCmd+Shift+Up")]}),V(X,{label:f("labels.alignBottom"),shortcuts:[N("CtrlOrCmd+Shift+Down")]}),V(X,{label:f("labels.alignLeft"),shortcuts:[N("CtrlOrCmd+Shift+Left")]}),V(X,{label:f("labels.alignRight"),shortcuts:[N("CtrlOrCmd+Shift+Right")]}),V(X,{label:f("labels.duplicateSelection"),shortcuts:[N("CtrlOrCmd+D"),N(`Alt+${f("helpDialog.drag")}`)]}),V(X,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),V(X,{label:f("buttons.undo"),shortcuts:[N("CtrlOrCmd+Z")]}),V(X,{label:f("buttons.redo"),shortcuts:oc?[N("CtrlOrCmd+Y"),N("CtrlOrCmd+Shift+Z")]:[N("CtrlOrCmd+Shift+Z")]}),V(X,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),V(X,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),V(X,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),V(X,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]}),V(X,{label:f("labels.showStroke"),shortcuts:[N("S")]}),V(X,{label:f("labels.showBackground"),shortcuts:[N("G")]}),V(X,{label:f("labels.showFonts"),shortcuts:[N("Shift+F")]}),V(X,{label:f("labels.decreaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+<")]}),V(X,{label:f("labels.increaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+>")]})]})]})]})})};import{useEffect as Y5,useRef as r8,useState as Un}from"react";import{useCallback as JL,useRef as QL,useState as e8}from"react";var t8=2e3,G5=()=>{let[e,t]=e8(null),o=QL(0),r=()=>{clearTimeout(o.current),t("success"),o.current=window.setTimeout(()=>{t(null)},t8)},n=JL(()=>{t(null)},[]);return{copyStatus:e,resetCopyStatus:n,onCopy:r}};import o8 from"clsx";import{jsx as V5}from"react/jsx-runtime";var Hs=({title:e,name:t,checked:o,onChange:r,disabled:n=!1})=>V5("div",{className:o8("Switch",{toggled:o,disabled:n}),children:V5("input",{name:t,id:t,title:e,type:"checkbox",checked:o,disabled:n,onChange:()=>r(!o),onKeyDown:i=>{i.key===" "&&r(!o)}})});import{jsx as Je,jsxs as Gn}from"react/jsx-runtime";var n8="filter"in document.createElement("canvas").getContext("2d"),i8=()=>Gn("div",{children:[Je("h3",{children:f("canvasError.cannotShowPreview")}),Je("p",{children:Je("span",{children:f("canvasError.canvasTooBig")})}),Gn("em",{children:["(",f("canvasError.canvasTooBigTip"),")"]})]}),a8=({appStateSnapshot:e,elementsSnapshot:t,files:o,actionManager:r,onExportImage:n,name:i})=>{let a=Ue(t,e),[l,s]=Un(i),[c,m]=Un(a),[d,p]=Un(e.exportBackground),[u,h]=Un(e.exportWithDarkMode),[x,b]=Un(e.exportEmbedScene),[E,w]=Un(e.exportScale),y=r8(null),[v,C]=Un(null),{onCopy:I,copyStatus:L,resetCopyStatus:A}=G5();Y5(()=>{A()},[l,d,u,E,x,A]);let{exportedElements:R,exportingFrame:_}=Di(t,e,c);return Y5(()=>{let z=y.current;if(!z)return;let W=z.offsetWidth,G=z.offsetHeight;W&&Dn({elements:R,appState:{...e,name:l,exportBackground:d,exportWithDarkMode:u,exportScale:E,exportEmbedScene:x},files:o,exportPadding:sn,maxWidthOrHeight:Math.max(W,G),exportingFrame:_}).then(j=>(C(null),Gr(j).then(()=>{z.replaceChildren(j)}).catch(H=>{throw H.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):H}))).catch(j=>{console.error(j),C(j)})},[e,o,R,_,l,d,u,E,x]),Gn("div",{className:"ImageExportModal",children:[Je("h3",{children:f("imageExportDialog.header")}),Gn("div",{className:"ImageExportModal__preview",children:[Je("div",{className:"ImageExportModal__preview__canvas",ref:y,children:v&&Je(i8,{})}),Je("div",{className:"ImageExportModal__preview__filename",children:!ca&&Je("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:z=>{s(z.target.value),r.executeAction(ng,"ui",z.target.value)}})})]}),Gn("div",{className:"ImageExportModal__settings",children:[Je("h3",{children:f("imageExportDialog.header")}),a&&Je(Us,{label:f("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Je(Hs,{name:"exportOnlySelected",checked:c,onChange:z=>{m(z)}})}),Je(Us,{label:f("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Je(Hs,{name:"exportBackgroundSwitch",checked:d,onChange:z=>{p(z),r.executeAction(ig,"ui",z)}})}),n8&&Je(Us,{label:f("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Je(Hs,{name:"exportDarkModeSwitch",checked:u,onChange:z=>{h(z),r.executeAction(O2,"ui",z)}})}),Je(Us,{label:f("imageExportDialog.label.embedScene"),tooltip:f("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Je(Hs,{name:"exportEmbedSwitch",checked:x,onChange:z=>{b(z),r.executeAction(hm,"ui",z)}})}),Je(Us,{label:f("imageExportDialog.label.scale"),name:"exportScale",children:Je(up,{name:"exportScale",value:E,onChange:z=>{w(z),r.executeAction(N2,"ui",z)},choices:mc.map(z=>({value:z,label:`${z}\xD7`}))})}),Gn("div",{className:"ImageExportModal__settings__buttons",children:[Je(Fn,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToPng"),onClick:()=>n(sc.png,R,{exportingFrame:_}),icon:yh,children:f("imageExportDialog.button.exportToPng")}),Je(Fn,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToSvg"),onClick:()=>n(sc.svg,R,{exportingFrame:_}),icon:yh,children:f("imageExportDialog.button.exportToSvg")}),(Ra||Pr)&&Je(Fn,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.copyPngToClipboard"),status:L,onClick:async()=>{await n(sc.clipboard,R,{exportingFrame:_}),I()},icon:wa,children:f("imageExportDialog.button.copyPngToClipboard")})]})]})]})},Us=({label:e,children:t,tooltip:o,name:r})=>Gn("div",{className:"ImageExportModal__settings__setting",title:e,children:[Gn("label",{htmlFor:r,className:"ImageExportModal__settings__setting__label",children:[e,o&&Je(So,{label:o,long:!0,children:WE})]}),Je("div",{className:"ImageExportModal__settings__setting__content",children:t})]}),W5=({elements:e,appState:t,files:o,actionManager:r,onExportImage:n,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:l,elementsSnapshot:s}]=Un(()=>({appStateSnapshot:lo(t),elementsSnapshot:lo(e)}));return Je(ct,{onCloseRequest:i,size:"wide",title:!1,children:Je(a8,{elementsSnapshot:s,appStateSnapshot:l,files:o,actionManager:r,onExportImage:n,name:a})})};import s8 from"react";import Zf from"open-color";import{jsx as l8}from"react/jsx-runtime";var Xf=({children:e,color:t})=>l8("div",{className:"Card",style:{"--card-color":t==="primary"?"var(--color-primary)":Zf[t][7],"--card-color-darker":t==="primary"?"var(--color-primary-darker)":Zf[t][8],"--card-color-darkest":t==="primary"?"var(--color-primary-darkest)":Zf[t][9]},children:e});import{Fragment as d8,jsx as mr,jsxs as _p}from"react/jsx-runtime";var c8=({elements:e,appState:t,setAppState:o,files:r,actionManager:n,exportOpts:i,canvas:a,onCloseRequest:l})=>{let{onExportToBackend:s}=i;return mr("div",{className:"ExportDialog ExportDialog--json",children:_p("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&_p(Xf,{color:"lime",children:[mr("div",{className:"Card-icon",children:Qx}),mr("h2",{children:f("exportDialog.disk_title")}),_p("div",{className:"Card-details",children:[f("exportDialog.disk_details"),!ca&&n.renderAction("changeProjectName")]}),mr(te,{className:"Card-button",type:"button",title:f("exportDialog.disk_button"),"aria-label":f("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{n.executeAction(Es,"ui")}})]}),s&&_p(Xf,{color:"pink",children:[mr("div",{className:"Card-icon",children:os}),mr("h2",{children:f("exportDialog.link_title")}),mr("div",{className:"Card-details",children:f("exportDialog.link_details")}),mr(te,{className:"Card-button",type:"button",title:f("exportDialog.link_button"),"aria-label":f("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{fe("export","link",`ui (${xb()})`),await s(e,t,r),l()}catch(c){o({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,t,r,a)]})})},K5=({elements:e,appState:t,files:o,actionManager:r,exportOpts:n,canvas:i,setAppState:a})=>{let l=s8.useCallback(()=>{a({openDialog:null})},[a]);return mr(d8,{children:t.openDialog?.name==="jsonExport"&&mr(ct,{onCloseRequest:l,title:f("buttons.export"),children:mr(c8,{elements:e,appState:t,setAppState:a,files:o,actionManager:r,onCloseRequest:l,exportOpts:n,canvas:i})})})};import m8 from"clsx";import{jsx as Z5,jsxs as u8}from"react/jsx-runtime";var p8="small",X5=e=>u8("label",{className:m8("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${p8}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[Z5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),Z5("div",{className:"ToolIcon__icon",children:ns})]});import{Fragment as j5,jsx as ne,jsxs as Lo}from"react/jsx-runtime";var g8=({UIOptions:e})=>Lo(Yt,{__fallback:!0,children:[ne(Yt.DefaultItems.LoadScene,{}),ne(Yt.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&ne(Yt.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&ne(Yt.DefaultItems.SaveAsImage,{}),ne(Yt.DefaultItems.SearchMenu,{}),ne(Yt.DefaultItems.Help,{}),ne(Yt.DefaultItems.ClearCanvas,{}),ne(Yt.Separator,{}),ne(Yt.Group,{title:"Excalidraw links",children:ne(Yt.DefaultItems.Socials,{})}),ne(Yt.Separator,{}),ne(Yt.DefaultItems.ToggleTheme,{}),ne(Yt.DefaultItems.ChangeCanvasBackground,{})]}),f8=()=>Lo(bp,{__fallback:!0,children:[ne(bp.Actions.SaveToDisk,{}),ne(bp.Actions.ExportToImage,{})]}),b8=({actionManager:e,appState:t,files:o,setAppState:r,elements:n,canvas:i,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,showExitZenModeBtn:c,renderTopRightUI:m,renderCustomStats:d,UIOptions:p,onExportImage:u,renderWelcomeScreen:h,children:x,app:b,isCollaborating:E,generateLinkForSelection:w})=>{let y=Te(),v=aw(),C=v.tunnelsJotai.Provider,[I,L]=ve(Cn),A=()=>p.canvasActions.export?ne(K5,{elements:n,appState:t,files:o,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:r}):null,R=()=>!p.canvasActions.saveAsImage||t.openDialog?.name!=="imageExport"?null:ne(W5,{elements:n,appState:t,files:o,actionManager:e,onExportImage:u,onCloseRequest:()=>r({openDialog:null}),name:b.getName()}),_=()=>Lo("div",{style:{position:"relative"},children:[ne(v.MainMenuTunnel.Out,{}),h&&ne(v.WelcomeScreenMenuHintTunnel.Out,{})]}),z=()=>ne(On,{heading:"selectedShapeActions",className:Gs("selected-shape-actions zen-mode-transition",{"transition-left":t.zenModeEnabled}),children:ne(wt,{className:Wt.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${t.height-166}px`},children:ne(Gm,{appState:t,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b})})}),W=()=>{let B=Oa(t,n),U=t.stats.open&&!t.zenModeEnabled&&!t.viewModeEnabled&&t.openDialog?.name!=="elementLinkSelector";return ne(np,{side:"top",children:Lo("div",{className:"App-menu App-menu_top",children:[Lo(Lt.Col,{gap:6,className:Gs("App-menu_top__left"),children:[_(),B&&z()]}),!t.viewModeEnabled&&t.openDialog?.name!=="elementLinkSelector"&&ne(On,{heading:"shapes",className:"shapes-section",children:oe=>Lo("div",{style:{position:"relative"},children:[h&&ne(v.WelcomeScreenToolbarHintTunnel.Out,{}),ne(Lt.Col,{gap:4,align:"start",children:Lo(Lt.Row,{gap:1,className:Gs("App-toolbar-container",{"zen-mode":t.zenModeEnabled}),children:[Lo(wt,{padding:1,className:Gs("App-toolbar",{"zen-mode":t.zenModeEnabled}),children:[ne(ap,{appState:t,isMobile:y.editor.isMobile,device:y,app:b}),oe,Lo(Lt.Row,{gap:1,children:[ne(lp,{zenModeEnabled:t.zenModeEnabled,checked:t.penMode,onChange:()=>s(null),title:f("toolBar.penMode"),penDetected:t.penDetected}),ne(rp,{checked:t.activeTool.locked,onChange:a,title:f("toolBar.lock")}),ne("div",{className:"App-toolbar__divider"}),ne(ip,{checked:or(t),onChange:()=>l(),title:f("toolBar.hand"),isMobile:!0}),ne(Vm,{appState:t,activeTool:t.activeTool,UIOptions:p,app:b})]})]}),E&&ne(wt,{style:{marginLeft:8,alignSelf:"center",height:"fit-content"},children:ne(X5,{title:f("toolBar.laser"),checked:t.activeTool.type===at.laser,onChange:()=>b.setActiveTool({type:at.laser}),isMobile:!0})})]})})]})}),Lo("div",{className:Gs("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":t.zenModeEnabled}),children:[t.collaborators.size>0&&ne(dp,{collaborators:t.collaborators,userToFollow:t.userToFollow?.socketId||null}),m?.(y.editor.isMobile,t),!t.viewModeEnabled&&t.openDialog?.name!=="elementLinkSelector"&&(!j||t.openSidebar?.name!==zt.name)&&ne(v.DefaultSidebarTriggerTunnel.Out,{}),U&&ne(zs,{app:b,onClose:()=>{e.executeAction(Ga)},renderCustomStats:d})]})]})})},G=()=>ne(xp,{__fallback:!0,onDock:B=>{fe("sidebar",`toggleDock (${B?"dock":"undock"})`,`(${y.editor.isMobile?"mobile":"desktop"})`)}}),j=bd(Rs),H=Lo(j5,{children:[x,ne(g8,{UIOptions:p}),ne(xp.Trigger,{__fallback:!0,icon:ba,title:dn(f("toolBar.library")),onToggle:B=>{B&&fe("sidebar",`${zt.name} (open)`,`button (${y.editor.isMobile?"mobile":"desktop"})`)},tab:zt.defaultTab,children:f("toolBar.library")}),ne(f8,{}),t.openDialog?.name==="ttd"&&ne(Bf,{__fallback:!0}),t.isLoading&&ne(op,{delay:250}),t.errorMessage&&ne(z5,{onClose:()=>r({errorMessage:null}),children:t.errorMessage}),I&&!y.editor.isMobile&&ne(_y,{colorPickerType:I.colorPickerType,onCancel:()=>{L(null)},onChange:(B,U,oe,{altKey:Z})=>{if(!(B!=="elementBackground"&&B!=="elementStroke"))if(oe.length){for(let ce of oe)kt(ce,q(n),{[Z&&I.swapPreviewOnAlt?B==="elementBackground"?"strokeColor":"backgroundColor":B==="elementBackground"?"backgroundColor":"strokeColor"]:U}),Er.delete(ce);b.scene.triggerUpdate()}else r(B==="elementBackground"?{currentItemBackgroundColor:U}:{currentItemStrokeColor:U})},onSelect:(B,U)=>{L(oe=>oe?.keepOpenOnAlt&&U.altKey?oe:null),I?.onSelect?.(B,U)}}),t.openDialog?.name==="help"&&ne(H5,{onClose:()=>{r({openDialog:null})}}),ne(mw,{}),t.openDialog?.name==="elementLinkSelector"&&ne(F5,{sourceElementId:t.openDialog.sourceElementId,onClose:()=>{r({openDialog:null})},scene:b.scene,appState:t,generateLinkForSelection:w}),ne(v.OverwriteConfirmDialogTunnel.Out,{}),R(),A(),t.pasteDialog.shown&&ne(u3,{setAppState:r,appState:t,onClose:()=>r({pasteDialog:{shown:!1,data:null}})}),y.editor.isMobile&&ne(m3,{app:b,appState:t,elements:n,actionManager:e,renderJSONExportDialog:A,renderImageExportDialog:R,setAppState:r,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,renderTopRightUI:m,renderCustomStats:d,renderSidebars:G,device:y,renderWelcomeScreen:h,UIOptions:p}),!y.editor.isMobile&&Lo(j5,{children:[Lo("div",{className:"layer-ui__wrapper",style:t.openSidebar&&j&&y.editor.canFitSidebar?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[h&&ne(v.WelcomeScreenCenterTunnel.Out,{}),W(),ne(b3,{appState:t,actionManager:e,showExitZenModeBtn:c,renderWelcomeScreen:h}),t.scrolledOutside&&ne("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(B=>({...hi(n,B)}))},children:f("buttons.scrollBackToContent")})]}),G()]})]});return ne(Ph.Provider,{value:t,children:ne(C,{children:ne(Wg.Provider,{value:v,children:H})})})},$5=e=>{let{suggestedBindings:t,startBoundElement:o,cursorButton:r,scrollX:n,scrollY:i,...a}=e;return a},x8=(e,t)=>{if(e.children!==t.children)return!1;let{canvas:o,appState:r,...n}=e,{canvas:i,appState:a,...l}=t;return pt($5(r),$5(a),{selectedElementIds:pt,selectedGroupIds:pt})&&pt(n,l)},q5=h8.memo(b8,x8);import E8 from"clsx";import{jsx as J5,jsxs as v8}from"react/jsx-runtime";var y8="small",Pp=e=>v8("label",{className:E8("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${y8}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[J5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),J5("div",{className:"ToolIcon__icon",children:e.icon})]});import{useEffect as w8,useRef as T8}from"react";import{jsx as Q5}from"react/jsx-runtime";var eT=({trails:e})=>{let t=T8(null);return w8(()=>{if(t.current)for(let o of e)o.start(t.current);return()=>{for(let o of e)o.stop()}},e),Q5("div",{className:"SVGLayer",children:Q5("svg",{ref:t})})};import S8,{useEffect as C8,useRef as I8}from"react";import{jsx as A8}from"react/jsx-runtime";var k8=e=>{let t=I8(!1);return C8(()=>{if(!t.current){t.current=!0;return}let o=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,Pt({sceneX:s.pointer.x,sceneY:s.pointer.y},e.appState)),o.set(c,s.button))});let l=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";Kw({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:o,remoteSelectedElementIds:n,remotePointerUsernames:i,remotePointerUserStates:a,selectionColor:l,renderScrollbars:e.renderScrollbars},device:e.device,callback:e.renderInteractiveSceneCallback},al())}),A8("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?Ce.GRAB:Ce.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:f("labels.drawingCanvas")})},tT=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,pendingImageElementId:e.pendingImageElementId,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,isBindingEnabled:e.isBindingEnabled,suggestedBindings:e.suggestedBindings,isRotating:e.isRotating,elementsToHighlight:e.elementsToHighlight,collaborators:e.collaborators,activeEmbeddable:e.activeEmbeddable,snapLines:e.snapLines,zenModeEnabled:e.zenModeEnabled,editingTextElement:e.editingTextElement,isCropping:e.isCropping,croppingElementId:e.croppingElementId,searchMatches:e.searchMatches}),M8=(e,t)=>e.selectionNonce!==t.selectionNonce||e.sceneNonce!==t.sceneNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements||e.selectedElements!==t.selectedElements||e.renderScrollbars!==t.renderScrollbars?!1:pt(tT(e.appState),tT(t.appState)),$f=S8.memo(k8,M8);import L8,{useEffect as D8,useRef as oT}from"react";import{jsx as R8}from"react/jsx-runtime";var _8=e=>{let t=oT(null),o=oT(!1);return D8(()=>{let r=t.current;if(!r)return;let n=e.canvas;o.current||(o.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),q0({canvas:n,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},al())}),R8("div",{className:"excalidraw__canvas-wrapper",ref:t})},rT=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,pendingImageElementId:e.pendingImageElementId,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}),P8=(e,t)=>e.sceneNonce!==t.sceneNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements?!1:pt(rT(e.appState),rT(t.appState))&&pt(e.renderConfig,t.renderConfig),jf=L8.memo(_8,P8);import{useEffect as O8,useRef as B8}from"react";var nT=({canvas:e,rc:t,newElement:o,elementsMap:r,allElementsMap:n,scale:i,appState:a,renderConfig:l})=>{if(e){let[s,c]=od(e,i),m=rd({canvas:e,scale:i,normalizedWidth:s,normalizedHeight:c});m.save(),m.scale(a.zoom.value,a.zoom.value),o&&o.type!=="selection"?v0(o,r,n,t,m,l,a):m.clearRect(0,0,s,c)}},N8=Wi(e=>{nT(e)},{trailing:!0}),iT=(e,t)=>{if(t){N8(e);return}nT(e)};import{jsx as z8}from"react/jsx-runtime";var F8=e=>{let t=B8(null);return O8(()=>{t.current&&iT({canvas:t.current,scale:e.scale,newElement:e.appState.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},al())}),z8("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:t})},aT=F8;import{useCallback as H8,useEffect as U8,useRef as G8}from"react";import{jsx as lT,jsxs as Y8}from"react/jsx-runtime";var V8=5e3,sT=({message:e,onClose:t,closable:o=!1,duration:r=V8,style:n})=>{let i=G8(0),a=r!==1/0,l=H8(()=>{a&&(i.current=window.setTimeout(()=>t(),r))},[t,r,a]);return U8(()=>{if(a)return l(),()=>clearTimeout(i.current)},[l,e,r,a]),Y8("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}),o&&lT(te,{icon:Po,"aria-label":"close",type:"icon",onClick:t,className:"close"})]})};import{Fragment as $8,jsx as Re,jsxs as Np}from"react/jsx-runtime";var pT=_r.createContext(null),uT=_r.createContext(null),hT={viewport:{isMobile:!1,isLandscape:!1},editor:{isMobile:!1,canFitSidebar:!1},isTouchScreen:!1},t1=_r.createContext(hT);t1.displayName="DeviceContext";var o1=_r.createContext({container:null,id:null});o1.displayName="ExcalidrawContainerContext";var r1=_r.createContext([]);r1.displayName="ExcalidrawElementsContext";var n1=_r.createContext({...wn(),width:0,height:0,offsetLeft:0,offsetTop:0});n1.displayName="ExcalidrawAppStateContext";var i1=_r.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});i1.displayName="ExcalidrawSetAppStateContext";var a1=_r.createContext(null);a1.displayName="ExcalidrawActionManagerContext";var lt=()=>Wn(pT),Tr=()=>Wn(uT),Te=()=>Wn(t1),ft=()=>Wn(o1),In=()=>Wn(r1),wr=()=>Wn(n1),Se=()=>Wn(i1),bt=()=>Wn(a1),Vs=!1,qf=0,Hi=!1,Ys=!1,Jf=!1,Ws={horizontal:null,vertical:null},Yn=0,Ks=!1,Qf=new Map,Rp=!1,dT=0,mT=!1,Zs=null,De={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},e1=class e extends _r.Component{constructor(o){super(o);S(this,"canvas");S(this,"interactiveCanvas",null);S(this,"rc");S(this,"unmounted",!1);S(this,"actionManager");S(this,"device",hT);S(this,"excalidrawContainerRef",_r.createRef());S(this,"scene");S(this,"fonts");S(this,"renderer");S(this,"visibleElements");S(this,"resizeObserver");S(this,"nearestScrollableContainer");S(this,"library");S(this,"libraryItemsFromStorage");S(this,"id");S(this,"store");S(this,"history");S(this,"excalidrawContainerValue");S(this,"files",{});S(this,"imageCache",new Map);S(this,"iFrameRefs",new Map);S(this,"embedsValidationStatus",new Map);S(this,"initializedEmbeds",new Set);S(this,"elementsPendingErasure",new Set);S(this,"flowChartCreator",new ud);S(this,"flowChartNavigator",new pd);S(this,"hitLinkElement");S(this,"lastPointerDownEvent",null);S(this,"lastPointerUpEvent",null);S(this,"lastPointerMoveEvent",null);S(this,"lastPointerMoveCoords",null);S(this,"lastViewportPosition",{x:0,y:0});S(this,"animationFrameHandler",new Xm);S(this,"laserTrails",new Jm(this.animationFrameHandler,this));S(this,"eraserTrail",new tp(this.animationFrameHandler,this));S(this,"lassoTrail",new ep(this.animationFrameHandler,this));S(this,"onChangeEmitter",new Kt);S(this,"onPointerDownEmitter",new Kt);S(this,"onPointerUpEmitter",new Kt);S(this,"onUserFollowEmitter",new Kt);S(this,"onScrollChangeEmitter",new Kt);S(this,"missingPointerEventCleanupEmitter",new Kt);S(this,"onRemoveEventListenersEmitter",new Kt);S(this,"updateEditorAtom",(o,...r)=>{let n=Fe.set(o,...r);return this.triggerRender(),n});S(this,"getEffectiveGridSize",()=>Rn(this)?this.state.gridSize:null);S(this,"updateEmbedValidationStatus",(o,r)=>{this.embedsValidationStatus.set(o.id,r),Er.delete(o)});S(this,"updateEmbeddables",()=>{let o=new Set,r=!1;this.scene.getNonDeletedElements().filter(n=>{if(Zt(n)){if(o.add(n.id),!this.embedsValidationStatus.has(n.id)){r=!0;let i=aa(n.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(n,i)}}else ri(n)&&o.add(n.id);return!1}),r&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((n,i)=>{o.has(i)||this.iFrameRefs.delete(i)})});S(this,"getFrameNameDOMId",o=>`${this.id}-frame-name-${o.id}`);S(this,"frameNameBoundsCache",{get:o=>{let r=this.frameNameBoundsCache._cache.get(o.id);if(!r||r.zoom!==this.state.zoom.value||r.versionNonce!==o.versionNonce){let n=document.getElementById(this.getFrameNameDOMId(o));if(n){let i=n.getBoundingClientRect(),a=Ke({clientX:i.x,clientY:i.y},this.state),l=Ke({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:o.versionNonce},this.frameNameBoundsCache._cache.set(o.id,r),r}return null}return r},_cache:new Map});S(this,"resetEditingFrame",o=>{o&&this.scene.mutateElement(o,{name:o.name?.trim()||null}),this.setState({editingFrame:null})});S(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let o=this.state.theme===se.DARK,r=this.scene.getNonDeletedFramesLikes(),n=r.length>0&&this.state.searchMatches?.focusedId&&J(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return r.map(i=>{if(!Rl(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}=Pt({sceneX:i.x,sceneY:i.y},this.state),s=6,c,m=x0(i);if(i.id===this.state.editingFrame){let d=m;c=Re("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===T.ESCAPE||p.key===T.ENTER)&&this.resetEditingFrame(i)},style:{background:this.state.viewBackgroundColor,filter:o?G1:"none",zIndex:2,border:"none",display:"block",padding:`${s}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${Ft.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 Re("div",{id:this.getFrameNameDOMId(i),style:{position:"absolute",bottom:`${this.state.height+Ft.nameOffsetY-l+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:Ft.nameFontSize,color:o?Ft.nameColorDarkTheme:Ft.nameColorLightTheme,lineHeight:Ft.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:Ce.MOVE,pointerEvents:this.state.viewModeEnabled?$n.disabled:$n.enabled},onPointerDown:d=>this.handleCanvasPointerDown(d),onWheel:d=>this.handleWheel(d),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:c},i.id)})});S(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});S(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());S(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());S(this,"getSceneElements",()=>this.scene.getNonDeletedElements());S(this,"onInsertElements",o=>{this.addElementsFromPasteOrLibrary({elements:o,position:"center",files:null})});S(this,"onExportImage",async(o,r,n)=>{fe("export",o,"ui");let i=await _i(o,r,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:n.exportingFrame}).catch(yc).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&id(i)&&this.setState({fileHandle:i})});S(this,"magicGenerations",new Map);S(this,"updateMagicGeneration",({frameElement:o,data:r})=>{r.status==="pending"?this.scene.mutateElement(o,{customData:{generationData:void 0}},{informMutation:!1,isDragging:!1}):this.scene.mutateElement(o,{customData:{generationData:r}},{informMutation:!1,isDragging:!1}),this.magicGenerations.set(o.id,r),this.triggerRender()});S(this,"plugins",{});S(this,"onMagicframeToolSelect",()=>{let o=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(o.length===0)this.setActiveTool({type:at.magicframe}),fe("ai","tool-select (empty-selection)","d2c");else{let r=o.length===1&&Ic(o[0])&&o[0];if(!r&&o.some(i=>J(i)||i.frameId)){this.setActiveTool({type:at.magicframe});return}fe("ai","tool-select (existing selection)","d2c");let n;if(r)n=r;else{let[i,a,l,s]=Ee(o),c=50;n=Ul({...Ft,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 o)this.scene.mutateElement(m,{frameId:n.id});this.setState({selectedElementIds:{[n.id]:!0}})}this.onMagicFrameGenerate(n,"upstream")}});S(this,"openEyeDropper",({type:o})=>{this.updateEditorAtom(Cn,{swapPreviewOnAlt:!0,colorPickerType:o==="stroke"?"elementStroke":"elementBackground",onSelect:(r,n)=>{let i=o==="background"&&n.altKey||o==="stroke"&&!n.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?i?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:r},captureUpdate:D.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},captureUpdate:D.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?re(l,{[i?"strokeColor":"backgroundColor"]:r}):l),captureUpdate:D.IMMEDIATELY})},keepOpenOnAlt:!1})});S(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.setState({editingLinearElement:null})})});S(this,"syncActionResult",rt(o=>{if(this.unmounted||o===!1)return;this.store.scheduleAction(o.captureUpdate);let r=!1,n=null;if(o.elements&&(this.scene.replaceAllElements(o.elements),r=!0),o.files&&(this.addMissingFiles(o.files,o.replaceFiles),this.addNewImagesToImageCache()),o.appState||n||this.state.contextMenu){let i=o?.appState?.viewModeEnabled||!1,a=o?.appState?.zenModeEnabled||!1,l=o?.appState?.theme||this.props.theme||se.LIGHT,s=o?.appState?.name??this.state.name,c=o?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(a=this.props.zenModeEnabled),n=o.appState?.editingTextElement||null,o.elements&&n&&o.elements.forEach(m=>{n?.id===m.id&&n!==m&&Yl(m)&&K(m)&&(n=m)}),n?.isDeleted&&(n=null),this.setState(m=>{let d=o.appState||{};return{...m,...d,contextMenu:null,editingTextElement:n,viewModeEnabled:i,zenModeEnabled:a,theme:l,name:s,errorMessage:c}}),r=!0}r||this.scene.triggerUpdate()}));S(this,"onBlur",rt(()=>{Hi=!1,this.setState({isBindingEnabled:!0})}));S(this,"onUnload",()=>{this.onBlur()});S(this,"disableEvent",o=>{o.preventDefault()});S(this,"resetHistory",()=>{this.history.clear()});S(this,"resetStore",()=>{this.store.clear()});S(this,"resetScene",rt(o=>{this.scene.replaceAllElements([]),this.setState(r=>({...wn(),isLoading:o?.resetLoadingState?!1:r.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));S(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 o=null;try{typeof this.props.initialData=="function"?o=await this.props.initialData()||null:o=await this.props.initialData||null,o?.libraryItems&&this.library.updateLibrary({libraryItems:o.libraryItems,merge:!0}).catch(n=>{console.error(n)})}catch(n){console.error(n),o={appState:{errorMessage:n.message||"Encountered an error during importing or restoring scene data"}}}let r=ma(o,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},o?.scrollToContent&&(r.appState={...r.appState,...hi(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:D.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(n=>{this.fonts.onLoaded(n)}),ui(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})});S(this,"isMobileBreakpoint",(o,r)=>o<V1||r<W1&&o<Y1);S(this,"refreshViewportBreakpoints",()=>{if(!this.excalidrawContainerRef.current)return;let{clientWidth:r,clientHeight:n}=document.body,i=this.device.viewport,a=Ki(i,{isLandscape:r>n,isMobile:this.isMobileBreakpoint(r,n)});return i!==a?(this.device={...this.device,viewport:a},!0):!1});S(this,"refreshEditorBreakpoints",()=>{let o=this.excalidrawContainerRef.current;if(!o)return;let{width:r,height:n}=o.getBoundingClientRect(),i=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:K1,a=this.device.editor,l=Ki(a,{isMobile:this.isMobileBreakpoint(r,n),canFitSidebar:r>i});return a!==l?(this.device={...this.device,editor:l},!0):!1});S(this,"onResize",rt(()=>{this.scene.getElementsIncludingDeleted().forEach(o=>Er.delete(o)),this.refreshViewportBreakpoints(),this.updateDOMRect(),bl||this.refreshEditorBreakpoints(),this.setState({})}));S(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});S(this,"renderInteractiveSceneCallback",({atLeastOneVisibleElement:o,scrollBars:r,elementsMap:n})=>{r&&(Ws=r);let i=this.state.editingTextElement?!1:!o&&n.size>0;this.state.scrolledOutside!==i&&this.setState({scrolledOutside:i}),this.scheduleImageRefresh()});S(this,"onScroll",Qn(()=>{let{offsetTop:o,offsetLeft:r}=this.getCanvasOffsets();this.setState(n=>n.offsetLeft===r&&n.offsetTop===o?null:{offsetTop:o,offsetLeft:r})},H1));S(this,"onCut",rt(o=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||gr(o.target)||(this.actionManager.executeAction(bm,"keyboard",o),o.preventDefault(),o.stopPropagation())}));S(this,"onCopy",rt(o=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||gr(o.target)||(this.actionManager.executeAction(Ha,"keyboard",o),o.preventDefault(),o.stopPropagation())}));S(this,"onTouchStart",o=>{if(rc&&o.preventDefault(),!Vs){Vs=!0,clearTimeout(qf),qf=window.setTimeout(e.resetTapTwice,F1);return}if(Vs&&o.touches.length===1){let r=o.touches[0];this.handleCanvasDoubleClick({clientX:r.clientX,clientY:r.clientY}),Vs=!1,clearTimeout(qf)}o.touches.length===2&&this.setState({selectedElementIds:Me({},this.state),activeEmbeddable:null})});S(this,"onTouchEnd",o=>{this.resetContextMenuTimer(),o.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:Me(this.state.previousSelectedElementIds,this.state)}):De.pointers.clear()});S(this,"pasteFromClipboard",rt(async o=>{let r=!!Rp,n=document.activeElement,i=this.excalidrawContainerRef.current?.contains(n);if(o&&!i)return;let a=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(o&&(!(a instanceof HTMLCanvasElement)||gr(n)))return;let{x:l,y:s}=Ke({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),c=o?.clipboardData?.files[0],m=await pm(o,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=Fu(d))}}if(ad(c)&&!m.spreadsheet){if(!this.isToolSupported("image")){this.setState({errorMessage:f("errors.imageToolNotSupported")});return}let d=this.createImageElement({sceneX:l,sceneY:s});this.insertImageElement(d,c),this.initializeImageDimensions(d),this.setState({selectedElementIds:Me({[d.id]:!0},this.state)});return}if(this.props.onPaste)try{if(await this.props.onPaste(m,o)===!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?il(m.elements):m.elements;this.addElementsFromPasteOrLibrary({elements:d,files:m.files||null,position:"cursor",retainSeed:r})}else if(m.text){if(m.text&&$w(m.text)){let u=await import("@excalidraw/mermaid-to-excalidraw");try{let{elements:h,files:x}=await u.parseMermaidToExcalidraw(m.text),b=il(h,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:b,files:x,position:"cursor"});return}catch(h){console.warn(`parsing pasted text as mermaid definition failed: ${h.message}`)}}let d=vb(m.text).split(/\n+/).map(u=>u.trim()).filter(Boolean),p=d.map(u=>N0(u)).filter(u=>aa(u,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(u)||pi(u)?.type==="video"));if(!Rp&&p.length>0&&p.length===d.length){let u=[];for(let h of p){let x=u[u.length-1],b=this.insertEmbeddableElement({sceneX:x?x.x+x.width+20:l,sceneY:s,link:jo(h)});b&&u.push(b)}u.length&&this.setState({selectedElementIds:Object.fromEntries(u.map(h=>[h.id,!0]))});return}this.addTextFromPaste(m.text,r)}this.setActiveTool({type:"selection"}),o?.preventDefault()}));S(this,"addElementsFromPasteOrLibrary",o=>{let r=Nu(o.elements,null,void 0),[n,i,a,l]=Ee(r),s=ei(n,a)/2,c=ei(i,l)/2,m=typeof o.position=="object"?o.position.clientX:o.position==="cursor"?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,d=typeof o.position=="object"?o.position.clientY:o.position==="cursor"?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop,{x:p,y:u}=Ke({clientX:m,clientY:d},this.state),h=p-s,x=u-c,[b,E]=mt(h,x,this.getEffectiveGridSize()),{duplicatedElements:w}=gi({type:"everything",elements:r.map(A=>re(A,{x:A.x+b-n,y:A.y+E-i})),randomizeSeed:!o.retainSeed}),y=this.scene.getElementsIncludingDeleted(),v=[...y,...w];v=this.props.onDuplicate?.(v,y)||v,At(v,q(w));let I=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(I){let A=f0(w,I);ta(v,A,I,this.state)}this.scene.replaceAllElements(v),w.forEach(A=>{if(K(A)&&He(A)){let R=Ut(A,this.scene.getElementsMapIncludingDeleted());Xe(A,R,this.scene)}}),k1&&vn.loadElementsFonts(w).then(A=>{this.fonts.onLoaded(A)}),o.files&&this.addMissingFiles(o.files),this.store.scheduleCapture();let L=l0(w);this.setState({...this.state,openSidebar:this.state.openSidebar&&this.device.editor.canFitSidebar&&Fe.get(Rs)?this.state.openSidebar:null,...ht({editingGroupId:null,selectedElementIds:L.reduce((A,R)=>(He(R)||(A[R.id]=!0),A),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{o.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:"selection"}),o.fitToContent&&this.scrollToContent(w,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})});S(this,"setAppState",(o,r)=>{this.setState(o,r)});S(this,"removePointer",o=>{Yn&&this.resetContextMenuTimer(),De.pointers.delete(o.pointerId)});S(this,"toggleLock",(o="ui")=>{this.state.activeTool.locked||fe("toolbar","toggleLock",`${o} (${this.device.editor.isMobile?"mobile":"desktop"})`),this.setState(r=>({activeTool:{...r.activeTool,...Ne(this.state,r.activeTool.locked?{type:"selection"}:r.activeTool),locked:!r.activeTool.locked}}))});S(this,"updateFrameRendering",o=>{this.setState(r=>{let n=typeof o=="function"?o(r.frameRendering):o;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}}})});S(this,"togglePenMode",o=>{this.setState(r=>({penMode:o??!r.penMode,penDetected:!0}))});S(this,"onHandToolToggle",()=>{this.actionManager.executeAction(E2)});S(this,"zoomCanvas",o=>{this.setState({...Wr({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:yr(o)},this.state)})});S(this,"cancelInProgressAnimation",null);S(this,"scrollToContent",(o=this.scene.getNonDeletedElements(),r)=>{if(typeof o=="string"){let s;if(ui(o)?s=z0(o):s=o,s){let c=this.scene.getElementsFromId(s);c?.length?this.scrollToContent(c,{fitToContent:r?.fitToContent??!0,animate:r?.animate??!0}):ui(o)&&this.setState({toast:{message:f("elementLink.notFound"),duration:3e3,closable:!0}})}return}this.cancelInProgressAnimation?.();let n=Array.isArray(o)?o:[o],i=this.state.zoom,a=this.state.scrollX,l=this.state.scrollY;if(r?.fitToContent||r?.fitToViewport){let{appState:s}=gs({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=hi(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=lb({fromValues:{scrollX:s,scrollY:c,zoom:m},toValues:{scrollX:a,scrollY:l,zoom:i.value},interpolateValue:(p,u,h,x)=>{if(x==="zoom")return p*Math.pow(u/p,Zo(h))},onStep:({scrollX:p,scrollY:u,zoom:h})=>{this.setState({scrollX:p,scrollY:u,zoom:{value:h}})},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})});S(this,"maybeUnfollowRemoteUser",()=>{this.state.userToFollow&&this.setState({userToFollow:null})});S(this,"translateCanvas",o=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(o)});S(this,"setToast",o=>{this.setState({toast:o})});S(this,"restoreFileFromShare",async()=>{try{let o=await caches.open("web-share-target"),r=await o.match("shared-file");if(r){let n=await r.blob(),i=new File([n],n.name||"",{type:n.type});this.loadFileToCanvas(i,null),await o.delete("shared-file"),window.history.replaceState(null,xl,window.location.pathname)}}catch(o){this.setState({errorMessage:o.message})}});S(this,"addFiles",rt(o=>{let{addedFiles:r}=this.addMissingFiles(o);this.clearImageShapeCache(r),this.scene.triggerUpdate(),this.addNewImagesToImageCache()}));S(this,"addMissingFiles",(o,r=!1)=>{let n=r?{}:{...this.files},i={},a=Array.isArray(o)?o:Object.values(o);for(let l of a)if(!n[l.id]&&(i[l.id]=l,n[l.id]=l,l.mimeType===ge.svg))try{let s=ix(Au(lx(l.dataURL)),ge.svg);l.dataURL!==s&&(l.version=(l.version??1)+1,l.dataURL=s)}catch(s){console.error(s)}return this.files=n,{addedFiles:i}});S(this,"updateScene",rt(o=>{let{elements:r,appState:n,collaborators:i,captureUpdate:a}=o,l=r?tr(r):void 0;if(a){let s=r?q(l??[]):void 0,c=n?Object.assign({},this.store.snapshot.appState,n):void 0;this.store.scheduleMicroAction({action:a,elements:s,appState:c})}n&&this.setState(n),l&&this.scene.replaceAllElements(l),i&&this.setState({collaborators:i})}));S(this,"mutateElement",(o,r,n=!0)=>this.scene.mutateElement(o,r,{informMutation:n,isDragging:!1}));S(this,"triggerRender",o=>{o===!0?this.scene.triggerUpdate():this.setState({})});S(this,"toggleSidebar",({name:o,tab:r,force:n})=>{let i;n===void 0?i=this.state.openSidebar?.name===o&&this.state.openSidebar?.tab===r?null:o:i=n?o:null;let a=i?{name:i}:null;return a&&r&&(a.tab=r),this.setState({openSidebar:a}),!!i});S(this,"updateCurrentCursorPosition",rt(o=>{this.lastViewportPosition.x=o.clientX,this.lastViewportPosition.y=o.clientY}));S(this,"getEditorUIOffsets",()=>{let o=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 Yr().rtl?{top:o+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:o+i,right:Math.max(this.state.width-(r?.left??this.state.width)+i,0),bottom:i,left:Math.max(n?.right??0,0)+i}});S(this,"onKeyDown",rt(o=>{if("Proxy"in window&&(!o.shiftKey&&/^[A-Z]$/.test(o.key)||o.shiftKey&&/^[a-z]$/.test(o.key))&&(o=new Proxy(o,{get(a,l){let s=a[l];return typeof s=="function"?s.bind(a):l==="key"?o.shiftKey?a.key.toUpperCase():a.key.toLowerCase():s}})),!au(o.target)){if((o.key===T.ESCAPE||o.key===T.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let a=Q(this.scene.getNonDeletedElementsMap(),this.state);if(a.length===1&&xe(a[0])&&o.key===T.ENTER){this.startImageCropping(a[0]);return}if(o.key===T.ESCAPE)this.updateEditorAtom(sr,null);else if(o.key===T.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(Wt.CONVERT_ELEMENT_TYPE_POPUP))){o.preventDefault();let s=$a(a);Fe.get(sr)?.type==="panel"&&Ag(this,{conversionType:s,direction:o.shiftKey?"left":"right"})&&this.store.scheduleCapture(),s&&this.updateEditorAtom(sr,{type:"panel"})}if(o.key===T.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let l=jn(o.key);if(o[T.CTRL_OR_CMD]&&l&&!o.shiftKey){o.preventDefault();let s=Q(this.scene.getNonDeletedElementsMap(),this.state);s.length===1&&ii(s[0])&&this.flowChartCreator.createNodes(s[0],this.state,Vu(o.key),this.scene),this.flowChartCreator.pendingNodes?.length&&!Ji(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(o.altKey){let s=Q(this.scene.getNonDeletedElementsMap(),this.state);if(s.length===1&&l){o.preventDefault();let c=this.flowChartNavigator.exploreByDirection(s[0],this.scene.getNonDeletedElementsMap(),Vu(o.key));if(c){this.setState(d=>({selectedElementIds:Me({[c]:!0},d)}));let m=this.scene.getNonDeletedElementsMap().get(c);m&&!Ji([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(o[T.CTRL_OR_CMD]&&o.key===T.P&&!o.shiftKey&&!o.altKey){this.setToast({message:f("commandPalette.shortcutHint",{shortcut:st("commandPalette")})}),o.preventDefault();return}if(o[T.CTRL_OR_CMD]&&o.key.toLowerCase()===T.V&&(Rp=o.shiftKey,clearTimeout(dT),dT=window.setTimeout(()=>{Rp=!1},100)),o[T.CTRL_OR_CMD]&&gr(o.target)&&(o.code===me.MINUS||o.code===me.EQUAL)){o.preventDefault();return}if(gr(o.target)&&o.key!==T.ESCAPE||jn(o.key)&&au(o.target))return;if(o.key===T.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(o.key.toLowerCase()===T.E&&o.shiftKey&&o[T.CTRL_OR_CMD]){o.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(o.key===T.PAGE_UP||o.key===T.PAGE_DOWN){let a=(o.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;o.key===T.PAGE_DOWN&&(a=-a),o.shiftKey?this.translateCanvas(l=>({scrollX:l.scrollX+a})):this.translateCanvas(l=>({scrollY:l.scrollY+a}))}if(this.state.openDialog?.name==="elementLinkSelector"||this.actionManager.handleKeyDown(o)||this.state.viewModeEnabled)return;if(o[T.CTRL_OR_CMD]&&this.state.isBindingEnabled&&this.setState({isBindingEnabled:!1}),jn(o.key)){let a=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),l=a.find(ee),s=new Set;a.filter(ee).filter(p=>{let u=p.startBinding&&!a.some(x=>x.id===p.startBinding?.elementId),h=p.endBinding&&!a.some(x=>x.id===p.endBinding?.elementId);return u||h}).forEach(p=>s.add(p.id)),a=a.filter(p=>!s.has(p.id));let c=this.getEffectiveGridSize()&&(o.shiftKey?Hp:this.getEffectiveGridSize())||(o.shiftKey?L1:Hp),m=0,d=0;o.key===T.ARROW_LEFT?m=-c:o.key===T.ARROW_RIGHT?m=c:o.key===T.ARROW_UP?d=-c:o.key===T.ARROW_DOWN&&(d=c),a.forEach(p=>{this.scene.mutateElement(p,{x:p.x+m,y:p.y+d},{informMutation:!1,isDragging:!1}),gt(p,this.scene,{simultaneouslyUpdated:a})}),this.setState({suggestedBindings:Gc(a.filter(p=>p.id!==l?.id||c!==0),this.scene.getNonDeletedElementsMap(),this.state.zoom)}),this.scene.triggerUpdate(),o.preventDefault()}else if(o.key===T.ENTER){let a=this.scene.getSelectedElements(this.state);if(a.length===1){let l=a[0];if(o[T.CTRL_OR_CMD])le(l)&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==a[0].id)&&(this.store.scheduleCapture(),ee(l)||this.setState({editingLinearElement:new $(l,this.scene.getNonDeletedElementsMap())}));else if(K(l)||$b(l)){let s;K(l)||(s=l);let c=Lc(l,this.state,this.scene.getNonDeletedElementsMap()),m=c.x,d=c.y;this.startTextEditing({sceneX:m,sceneY:d,container:s}),o.preventDefault();return}else J(l)&&this.setState({editingFrame:l.id})}}else if(!o.ctrlKey&&!o.altKey&&!o.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let a=iw(o.key);a?(this.state.activeTool.type!==a&&fe("toolbar",a,`keyboard (${this.device.editor.isMobile?"mobile":"desktop"})`),a==="arrow"&&this.state.activeTool.type==="arrow"&&this.setState(l=>({currentItemArrowType:l.currentItemArrowType===vt.sharp?vt.round:l.currentItemArrowType===vt.round?vt.elbow:vt.sharp})),this.setActiveTool({type:a}),o.stopPropagation()):o.key===T.Q&&(this.toggleLock("keyboard"),o.stopPropagation())}if(o.key===T.SPACE&&De.pointers.size===0&&(Hi=!0,Le(this.interactiveCanvas,Ce.GRAB),o.preventDefault()),(o.key===T.G||o.key===T.S)&&!o.altKey&&!o[T.CTRL_OR_CMD]){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;o.key===T.G&&(yn(this.state.activeTool.type)||a.some(l=>yn(l.type)))&&(this.setState({openPopup:"elementBackground"}),o.stopPropagation()),o.key===T.S&&(this.setState({openPopup:"elementStroke"}),o.stopPropagation())}if(!o[T.CTRL_OR_CMD]&&o.shiftKey&&o.key.toLowerCase()===T.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=>K(l)||pe(l,this.scene.getNonDeletedElementsMap())))&&(o.preventDefault(),this.setState({openPopup:"fontFamily"}))}if(o.key===T.K&&!o.altKey&&!o[T.CTRL_OR_CMD]){this.state.activeTool.type==="laser"?this.setActiveTool({type:"selection"}):this.setActiveTool({type:"laser"});return}o[T.CTRL_OR_CMD]&&(o.key===T.BACKSPACE||o.key===T.DELETE)&&this.updateEditorAtom(Bi,"clearCanvas");let r=o.key.toLocaleLowerCase(),n=r===T.S&&o.shiftKey,i=o.key===T.I||r===T.G&&o.shiftKey;(n||i)&&this.openEyeDropper({type:n?"stroke":"background"})}));S(this,"onKeyUp",rt(o=>{if(o.key===T.SPACE&&(this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector"?Le(this.interactiveCanvas,Ce.GRAB):this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"?Co(this.interactiveCanvas):(Io(this.interactiveCanvas,this.state),this.setState({selectedElementIds:Me({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Hi=!1),!o[T.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),jn(o.key)&&(Nl(this.scene.getSelectedElements(this.state).filter(le),mi(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.scene,this.state.zoom),this.setState({suggestedBindings:[]})),o.altKey||this.flowChartNavigator.isExploring&&(this.flowChartNavigator.clear(),this.syncActionResult({captureUpdate:D.IMMEDIATELY})),!o[T.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:Me({[r.id]:!0},n)})),Ji([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:D.IMMEDIATELY})}}));S(this,"isToolSupported",o=>this.props.UIOptions.tools?.[o]!==!1);S(this,"setActiveTool",(o,r=!1)=>{if(!this.isToolSupported(o.type)){console.warn(`"${o.type}" tool is disabled via "UIOptions.canvasActions.tools.${o.type}"`);return}let n=Ne(this.state,o);n.type==="hand"?Le(this.interactiveCanvas,Ce.GRAB):Hi||Io(this.interactiveCanvas,{...this.state,activeTool:n}),ib(document.activeElement)&&this.focusContainer(),Tb(n.type)||this.setState({suggestedBindings:[]}),n.type==="image"&&this.onImageAction({insertOnCanvasDirectly:(o.type==="image"&&o.insertOnCanvasDirectly)??!1}),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:Me({},i),selectedGroupIds:Me({},i),editingGroupId:null,multiElement:null},...a}:n.type!=="selection"?{...i,activeTool:n,selectedElementIds:Me({},i),selectedGroupIds:Me({},i),editingGroupId:null,multiElement:null,...a}:{...i,activeTool:n,...a}})});S(this,"setOpenDialog",o=>{this.setState({openDialog:o})});S(this,"setCursor",o=>{Le(this.interactiveCanvas,o)});S(this,"resetCursor",()=>{Co(this.interactiveCanvas)});S(this,"isTouchScreenMultiTouchGesture",()=>De.pointers.size>=2);S(this,"getName",()=>this.state.name||this.props.name||`${f("labels.untitled")}-${iu()}`);S(this,"onGestureStart",rt(o=>{o.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:Me({},this.state),activeEmbeddable:null}),De.initialScale=this.state.zoom.value}));S(this,"onGestureChange",rt(o=>{if(o.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let r=De.initialScale;r&&this.setState(n=>({...Wr({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:yr(r*o.scale)},n)}))}));S(this,"onGestureEnd",rt(o=>{o.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:Me(this.state.previousSelectedElementIds,this.state)}),De.initialScale=null}));S(this,"startTextEditing",({sceneX:o,sceneY:r,insertAtParentCenter:n=!0,container:i,autoEdit:a=!0})=>{let l=!1,s=n&&this.getTextWysiwygSnappedToCenterPosition(o,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?K(m[0])?c=m[0]:i?c=pe(m[0],this.scene.getNonDeletedElementsMap()):c=this.getTextElementAtPosition(o,r):c=this.getTextElementAtPosition(o,r);let d=c?.fontFamily||this.state.currentItemFontFamily,p=c?.lineHeight||Ko(d),u=this.state.currentItemFontSize;if(!c&&l&&i&&!Ie(i)){let E=kc(Ge({fontSize:u,fontFamily:d}),p),w=Mc(u,p),y=Math.max(i.height,w),v=Math.max(i.width,E);this.scene.mutateElement(i,{height:y,width:v}),o=i.x+v/2,r=i.y+y/2,s&&(s=this.getTextWysiwygSnappedToCenterPosition(o,r,this.state,i))}let h=this.getTopLayerFrameAtSceneCoords({x:o,y:r}),x=c||Xt({x:s?s.elementCenterX:o,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?io.MIDDLE:Gp,containerId:l?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:p,angle:i?Ie(i)?0:i.angle:0,frameId:h?h.id:null});if(!c&&l&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:x.id})}),this.setState({editingTextElement:x}),!c)if(i&&l){let b=this.scene.getElementIndex(i.id);this.scene.insertElementAtIndex(x,b+1)}else this.scene.insertElement(x);a||c||i?this.handleTextWysiwyg(x,{isExistingElement:!!c}):this.setState({newElement:x,multiElement:null})});S(this,"startImageCropping",o=>{this.store.scheduleCapture(),this.setState({croppingElementId:o.id})});S(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});S(this,"handleCanvasDoubleClick",o=>{if(this.state.multiElement||this.state.activeTool.type!=="selection")return;let r=this.scene.getSelectedElements(this.state),{x:n,y:i}=Ke(o,this.state);if(r.length===1&&le(r[0])){if(o[T.CTRL_OR_CMD]&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==r[0].id)&&!ee(r[0])){this.store.scheduleCapture(),this.setState({editingLinearElement:new $(r[0],this.scene.getNonDeletedElementsMap())});return}else if(this.state.selectedLinearElement&&ee(r[0])){let l=$.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:n,y:i},this.state,this.scene.getNonDeletedElementsMap()),s=l?$.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,l,this.scene.getNonDeletedElementsMap()):-1;if(s&&s>-1){this.store.scheduleCapture(),$.deleteFixedSegment(r[0],this.scene,s);let c=$.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:n,y:i},this.state,this.scene.getNonDeletedElementsMap()),m=c?$.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,c,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:{...this.state.selectedLinearElement.pointerDownState,segmentMidpoint:{index:m,value:l,added:!1}},segmentMidPointHoveredCoords:c}});return}}}if(r.length===1&&xe(r[0])){this.startImageCropping(r[0]);return}if(Co(this.interactiveCanvas),qo(this.state).length>0){let l=this.getElementAtPosition(n,i),s=l&&t0(l,this.state.selectedGroupIds);if(s){this.store.scheduleCapture(),this.setState(c=>({...c,...ht({editingGroupId:s,selectedElementIds:{[l.id]:!0}},this.scene.getNonDeletedElements(),c,this)}));return}}if(Co(this.interactiveCanvas),!o[T.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let l=this.getElementAtPosition(n,i);if(Xi(l)){this.setState({activeEmbeddable:{element:l,state:"active"}});return}let s=this.getTextBindableContainerAtPosition(n,i);if(s&&(it(s)||!ti(s.backgroundColor)||$i({x:n,y:i,element:s,shape:Ur(s,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()}))){let c=Lc(s,this.state,this.scene.getNonDeletedElementsMap());n=c.x,i=c.y}this.startTextEditing({sceneX:n,sceneY:i,insertAtParentCenter:!o.altKey,container:s})}});S(this,"getElementLinkAtPosition",(o,r)=>{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&&td(l,this.scene.getNonDeletedElementsMap(),this.state,M(o.x,o.y),this.device.editor.isMobile))return l}});S(this,"redirectToLink",(o,r)=>{let n=qn(M(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),M(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||n>Xn)return;let i=Ke(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),l=td(this.hitLinkElement,a,this.state,M(i.x,i.y),this.device.editor.isMobile),s=Ke(this.lastPointerUpEvent,this.state),c=td(this.hitLinkElement,a,this.state,M(s.x,s.y),this.device.editor.isMobile);if(l&&c){wg();let m=this.hitLinkElement.link;if(m){m=jo(m);let d;if(this.props.onLinkOpen&&(d=vc("excalidraw-link",o.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:m},d)),!d?.defaultPrevented){let p=Sc(m)?"_self":"_blank",u=window.open(void 0,p);u&&(u.opener=null,u.location=m)}}}});S(this,"getTopLayerFrameAtSceneCoords",o=>{let r=this.scene.getNonDeletedElementsMap(),n=this.scene.getNonDeletedFramesLikes().filter(i=>bu(o,i,r));return n.length?n[n.length-1]:null});S(this,"handleCanvasPointerMove",o=>{this.savePointer(o.clientX,o.clientY,this.state.cursorButton),this.lastPointerMoveEvent=o.nativeEvent,De.pointers.has(o.pointerId)&&De.pointers.set(o.pointerId,{x:o.clientX,y:o.clientY});let r=De.initialScale;if(De.pointers.size===2&&De.lastCenter&&r&&De.initialDistance){let u=of(De.pointers),h=u.x-De.lastCenter.x,x=u.y-De.lastCenter.y;De.lastCenter=u;let b=rf(Array.from(De.pointers.values())),E=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:b/De.initialDistance,w=E?yr(r*E):this.state.zoom.value;this.setState(y=>{let v=Wr({viewportX:u.x,viewportY:u.y,nextZoom:w},y);this.translateCanvas({zoom:v.zoom,scrollX:v.scrollX+2*(h/w),scrollY:v.scrollY+2*(x/w),shouldCacheIgnoreZoom:!0})}),this.resetShouldCacheIgnoreZoomDebounced()}else De.lastCenter=De.initialDistance=De.initialScale=null;if(Hi||Ys||Jf||or(this.state))return;let i=sf(Ws,o.clientX-this.state.offsetLeft,o.clientY-this.state.offsetTop).isOverEither;!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(i?Co(this.interactiveCanvas):Io(this.interactiveCanvas,this.state));let a=Ke(o,this.state),{x:l,y:s}=a;if(!this.state.newElement&&Rw(this.state.activeTool.type)){let{originOffset:u,snapLines:h}=Pw(this.scene.getNonDeletedElements(),this,{x:l,y:s},o,this.scene.getNonDeletedElementsMap());this.setState(x=>{let b=Zi(x.snapLines,h),E=x.originSnapOffset?Zi(x.originSnapOffset,u):u;return x.snapLines===b&&x.originSnapOffset===E?null:{snapLines:b,originSnapOffset:E}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(u=>u.snapLines.length?{snapLines:[]}:null);if(this.state.editingLinearElement&&!this.state.editingLinearElement.isDragging){let u=$.handlePointerMove(o,l,s,this);u&&u!==this.state.editingLinearElement&&Vn(()=>{this.setState({editingLinearElement:u})}),u?.lastUncommittedPoint!=null?this.maybeSuggestBindingAtCursor(a,u.elbowed):Vn(()=>{this.setState({suggestedBindings:[]})})}if(Sb(this.state.activeTool.type)){let{newElement:u}=this.state;zr(u,!1)?this.maybeSuggestBindingsForLinearElementAtCoords(u,[a],this.state.startBoundElement):this.maybeSuggestBindingAtCursor(a,!1)}if(this.state.multiElement){let{multiElement:u}=this.state,{x:h,y:x}=u,{points:b,lastCommittedPoint:E}=u,w=b[b.length-1];if(Io(this.interactiveCanvas,this.state),w===E)qn(M(l-h,s-x),w)>=nc?this.scene.mutateElement(u,{points:[...b,M(l-h,s-x)]},{informMutation:!1,isDragging:!1}):Le(this.interactiveCanvas,Ce.POINTER);else if(b.length>2&&E&&qn(M(l-h,s-x),E)<nc)Le(this.interactiveCanvas,Ce.POINTER),this.scene.mutateElement(u,{points:b.slice(0,-1)},{informMutation:!1,isDragging:!1});else{let[y,v]=mt(l,s,o[T.CTRL_OR_CMD]||ee(u)?null:this.getEffectiveGridSize()),[C,I]=u?.lastCommittedPoint??[0,0],L=y-h-C,A=v-x-I;fc(o)&&({width:L,height:A}=gu(C+h,I+x,y,v)),zl(b,this.state.zoom.value)&&Le(this.interactiveCanvas,Ce.POINTER),this.scene.mutateElement(u,{points:[...b.slice(0,-1),M(C+L,I+A)]},{isDragging:!0,informMutation:!1}),this.triggerRender(!1)}return}if(!!o.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&&ee(d[0]))){let u=Xu(m,this.state,l,s,this.state.zoom,o.pointerType,this.scene.getNonDeletedElementsMap(),this.device);if(u&&u.transformHandleType){Le(this.interactiveCanvas,ju(u));return}}}else if(d.length>1&&!i&&this.state.openDialog?.name!=="elementLinkSelector"){let u=$u(Ee(d),l,s,this.state.zoom,o.pointerType,this.device);if(u){Le(this.interactiveCanvas,ju({transformHandleType:u}));return}}let p=this.getElementAtPosition(a.x,a.y);this.hitLinkElement=this.getElementLinkAtPosition(a,p),!co(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(Le(this.interactiveCanvas,Ce.POINTER),ov(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):(wg(),p&&(p.link||Zt(p))&&this.state.selectedElementIds[p.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?Le(this.interactiveCanvas,K(p)?Ce.TEXT:Ce.CROSSHAIR):this.state.viewModeEnabled?Le(this.interactiveCanvas,Ce.GRAB):this.state.openDialog?.name==="elementLinkSelector"?Le(this.interactiveCanvas,Ce.AUTO):i?Le(this.interactiveCanvas,Ce.AUTO):this.state.selectedLinearElement?this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,l,s):o[T.CTRL_OR_CMD]?Le(this.interactiveCanvas,Ce.AUTO):(p||this.isHittingCommonBoundingBoxOfSelectedElements(a,d))&&!p?.locked&&(p&&Xi(p)&&this.isIframeLikeElementCenter(p,o,l,s)?(Le(this.interactiveCanvas,Ce.POINTER),this.setState({activeEmbeddable:{element:p,state:"hover"}})):(!p||!ee(p)||!(p.startBinding||p.endBinding))&&(Le(this.interactiveCanvas,Ce.MOVE),this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null})))),this.state.openDialog?.name==="elementLinkSelector"&&p?this.setState(u=>({hoveredElementIds:Zi(u.hoveredElementIds,ht({editingGroupId:u.editingGroupId,selectedElementIds:{[p.id]:!0}},this.scene.getNonDeletedElements(),u,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!p&&this.setState(u=>({hoveredElementIds:Zi(u.hoveredElementIds,{})})))});S(this,"handleEraser",(o,r)=>{let n=this.eraserTrail.addPointToPath(r.x,r.y,o.altKey);this.elementsPendingErasure=new Set(n),this.triggerRender()});S(this,"handleTouchMove",o=>{Ks=!0});S(this,"handleCanvasPointerDown",o=>{let r=o.target;if(r.setPointerCapture&&r.setPointerCapture(o.pointerId),this.maybeCleanupAfterMissingPointerUp(o.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(_f,null)),Fe.get(sr)&&this.updateEditorAtom(sr,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.updateGestureOnPointerDown(o),o.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:Me(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"?D.EVENTUALLY:D.NEVER});return}let n=document.getSelection();if(n?.anchorNode&&n.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(o),!this.state.penDetected&&o.pointerType==="pen"&&this.setState(d=>({penMode:!0,penDetected:!0})),!this.device.isTouchScreen&&["pen","touch"].includes(o.pointerType)&&(this.device=Ki(this.device,{isTouchScreen:!0})),Ys||(this.lastPointerDownEvent=o,this.handleCanvasPanUsingWheelOrSpaceDrag(o)))return;if(this.setState({lastPointerDownWith:o.pointerType,cursorButton:"down"}),this.savePointer(o.clientX,o.clientY,"down"),o.button===hr.ERASER&&this.state.activeTool.type!==at.eraser){this.setState({activeTool:Ne(this.state,{type:at.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(o);let d=()=>{p(),u?.(),co(this.state)&&this.setState({activeTool:Ne(this.state,{...this.state.activeTool.lastActiveTool||{type:at.selection},lastActiveToolBeforeEraser:null})})},p=Ze(window,"pointerup",d,{once:!0}),u;requestAnimationFrame(()=>{u=this.missingPointerEventCleanupEmitter.once(d)})});return}if(o.button!==hr.MAIN&&o.button!==hr.TOUCH&&o.button!==hr.ERASER||De.pointers.size>1)return;let i=this.initialPointerDownState(o);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleDraggingScrollBar(o,i)||(this.clearSelectionIfNotUsingSelection(),this.updateBindingEnabledOnPointerMove(o),this.handleSelectionOnPointerDown(o,i))||!(!this.state.penMode||o.pointerType!=="touch"||this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"||this.state.activeTool.type==="text"||this.state.activeTool.type==="image"))return;if(this.state.activeTool.type==="lasso")this.lassoTrail.startPath(i.origin.x,i.origin.y,o.shiftKey);else if(this.state.activeTool.type==="text")this.handleTextOnPointerDown(o,i);else if(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")this.handleLinearElementOnPointerDown(o,this.state.activeTool.type,i);else if(this.state.activeTool.type==="image"){Le(this.interactiveCanvas,Ce.CROSSHAIR);let d=this.state.pendingImageElementId&&this.scene.getElement(this.state.pendingImageElementId);if(!d)return;this.setState({newElement:d,pendingImageElementId:null,multiElement:null});let{x:p,y:u}=Ke(o,this.state),h=this.getTopLayerFrameAtSceneCoords({x:p,y:u});this.scene.mutateElement(d,{x:p,y:u,frameId:h?h.id:null})}else this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(o,this.state.activeTool.type,i):this.state.activeTool.type==="custom"?Io(this.interactiveCanvas,this.state):this.state.activeTool.type===at.frame||this.state.activeTool.type===at.magicframe?this.createFrameElementOnPointerDown(i,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(i.lastCoords.x,i.lastCoords.y):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,i);this.props?.onPointerDown?.(this.state.activeTool,i),this.onPointerDownEmitter.trigger(this.state.activeTool,i,o),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||o.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)});S(this,"handleCanvasPointerUp",o=>{this.removePointer(o),this.lastPointerUpEvent=o;let r=Ke({clientX:o.clientX,clientY:o.clientY},this.state),n=o.timeStamp-(this.lastPointerDownEvent?.timeStamp??0);if(this.device.editor.isMobile&&n<300){let i=this.getElementAtPosition(r.x,r.y);if(Xi(i)&&this.isIframeLikeElementCenter(i,o,r.x,r.y)){this.handleEmbeddableCenterClick(i);return}}if(this.device.isTouchScreen){let i=this.getElementAtPosition(r.x,r.y);this.hitLinkElement=this.getElementLinkAtPosition(r,i)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?n<300&&Xi(this.hitLinkElement)&&!K0(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,M(r.x,r.y))?this.handleEmbeddableCenterClick(this.hitLinkElement):this.redirectToLink(o,this.device.isTouchScreen):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})});S(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",o=>{o.pointerType==="touch"&&(Ks=!1,Yn?Ks=!0:Yn=window.setTimeout(()=>{Yn=0,Ks||this.handleCanvasContextMenu(o)},z1))});S(this,"resetContextMenuTimer",()=>{clearTimeout(Yn),Yn=0,Ks=!1});S(this,"maybeCleanupAfterMissingPointerUp",o=>{Zs?.(),this.missingPointerEventCleanupEmitter.trigger(o).clear()});S(this,"handleCanvasPanUsingWheelOrSpaceDrag",o=>{if(!(De.pointers.size<=1&&(o.button===hr.WHEEL||o.button===hr.MAIN&&Hi||or(this.state)||this.state.viewModeEnabled)))return!1;Ys=!0,this.focusContainer(),this.state.editingTextElement||o.preventDefault();let r=!1,n=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);Le(this.interactiveCanvas,Ce.GRABBING);let{clientX:i,clientY:a}=o,l=Qm(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=h=>{document.body.removeEventListener("paste",p),h.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=rt(Zs=()=>{Zs=null,Ys=!1,Hi||(this.state.viewModeEnabled?Le(this.interactiveCanvas,Ce.GRAB):Io(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(o.clientX,o.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});S(this,"clearSelectionIfNotUsingSelection",()=>{this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.setState({selectedElementIds:Me({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});S(this,"handleSelectionOnPointerDown",(o,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&&!ee(a[0])&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let l=Xu(n,this.state,r.origin.x,r.origin.y,this.state.zoom,o.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=$u(Ee(a),r.origin.x,r.origin.y,this.state.zoom,o.pointerType,this.device));if(r.resize.handleType)r.resize.isResizing=!0,r.resize.offset=mn(yx(r.resize.handleType,a,i,r.origin.x,r.origin.y)),a.length===1&&le(a[0])&&a[0].points.length===2&&(r.resize.arrowDirection=vx(r.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let c=this.state.editingLinearElement||this.state.selectedLinearElement,m=$.handlePointerDown(o,this,this.store,r.origin,c,this.scene);if(m.hitElement&&(r.hit.element=m.hitElement),m.linearElementEditor&&(this.setState({selectedLinearElement:m.linearElementEditor}),this.state.editingLinearElement&&this.setState({editingLinearElement:m.linearElementEditor})),m.didAddPoint)return!0}if(r.hit.element=r.hit.element??this.getElementAtPosition(r.origin.x,r.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(r.origin,r.hit.element),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=this.getElementsAtPosition(r.origin.x,r.origin.y);let l=r.hit.element,s=r.hit.allHitElements.some(c=>this.isASelectedElement(c));if((l===null||!s)&&!o.shiftKey&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&this.clearSelection(l),this.state.editingLinearElement)this.setState({selectedElementIds:Me({[this.state.editingLinearElement.elementId]:!0},this.state)});else if(l!=null){if(o[T.CTRL_OR_CMD])return this.state.selectedElementIds[l.id]||(r.hit.wasAddedToSelection=!0),this.setState(c=>({...e0(c,l),previousSelectedElementIds:this.state.selectedElementIds})),!1;this.state.selectedElementIds[l.id]||(this.state.editingGroupId&&!Qi(l,this.state.editingGroupId)&&this.setState({selectedElementIds:Me({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!s&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(c=>{let m={...c.selectedElementIds,[l.id]:!0},d=[];if(Object.keys(c.selectedElementIds).forEach(p=>{let u=this.scene.getElement(p);u&&d.push(u)}),J(l))so(d,l.id).forEach(p=>{delete m[p.id]});else if(l.frameId)m[l.frameId]&&delete m[l.id];else{let p=l.groupIds,u=new Set(p.flatMap(h=>Be(this.scene.getNonDeletedElements(),h)).filter(h=>J(h)).map(h=>h.id));u.size>0&&d.forEach(h=>{h.frameId&&u.has(h.frameId)&&(delete m[h.id],h.groupIds.flatMap(x=>Be(this.scene.getNonDeletedElements(),x)).forEach(x=>{delete m[x.id]}))})}return c.openDialog?.name==="elementLinkSelector"&&(l.groupIds.some(p=>c.selectedGroupIds[p])||(m={[l.id]:!0})),{...ht({editingGroupId:c.editingGroupId,selectedElementIds:m},this.scene.getNonDeletedElements(),c,this),showHyperlinkPopup:l.link||Zt(l)?"info":!1}}),r.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});S(this,"handleTextOnPointerDown",(o,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);it(a)&&(l=a,n=a.x+a.width/2,i=a.y+a.height/2),this.startTextEditing({sceneX:n,sceneY:i,insertAtParentCenter:!o.altKey,container:l,autoEdit:!1}),Co(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:Ne(this.state,{type:"selection"})})});S(this,"handleFreeDrawElementOnPointerDown",(o,r,n)=>{let[i,a]=mt(n.origin.x,n.origin.y,null),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),s=o.pressure===.5,c=R0({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:[M(0,0)],pressures:s?[]:[o.pressure]});this.scene.insertElement(c),this.setState(d=>{let p={...d.selectedElementIds};return delete p[c.id],{selectedElementIds:Me(p,d)}});let m=xn(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom);this.setState({newElement:c,startBoundElement:m,suggestedBindings:[]})});S(this,"insertIframeElement",({sceneX:o,sceneY:r,width:n,height:i})=>{let[a,l]=mt(o,r,this.lastPointerDownEvent?.[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=_0({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});S(this,"insertEmbeddableElement",({sceneX:o,sceneY:r,link:n})=>{let[i,a]=mt(o,r,this.lastPointerDownEvent?.[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=pi(n);if(!l)return;l.error instanceof URIError&&this.setToast({message:f("toast.unrecognizedLinkFormat"),closable:!0});let s=ku({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});S(this,"createImageElement",({sceneX:o,sceneY:r,addToFrameUnderCursor:n=!0})=>{let[i,a]=mt(o,r,this.lastPointerDownEvent?.[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=n?this.getTopLayerFrameAtSceneCoords({x:i,y:a}):null;return Xc({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})});S(this,"handleLinearElementOnPointerDown",(o,r,n)=>{if(this.state.multiElement){let{multiElement:i}=this.state;if(i.type==="line"&&zl(i.points,this.state.zoom.value)){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(ko);return}if(ee(i)&&i.points.length>1){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(ko);return}let{x:a,y:l,lastCommittedPoint:s}=i;if(i.points.length>1&&s&&qn(M(n.origin.x-a,n.origin.y-l),s)<nc){this.actionManager.executeAction(ko);return}this.setState(c=>({selectedElementIds:Me({...c.selectedElementIds,[i.id]:!0},c)})),this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),Le(this.interactiveCanvas,Ce.POINTER)}else{let[i,a]=mt(n.origin.x,n.origin.y,o[T.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"?er({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===vt.round?{type:Ct.PROPORTIONAL_RADIUS}:null,startArrowhead:m,endArrowhead:d,locked:!1,frameId:l?l.id:null,elbowed:this.state.currentItemArrowType===vt.elbow,fixedSegments:this.state.currentItemArrowType===vt.elbow?[]:null}):yo({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:Ct.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:l?l.id:null});this.setState(h=>{let x={...h.selectedElementIds};return delete x[p.id],{selectedElementIds:Me(x,h)}}),this.scene.mutateElement(p,{points:[...p.points,M(0,0)]});let u=xn(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,ee(p),ee(p));this.scene.insertElement(p),this.setState({newElement:p,startBoundElement:u,suggestedBindings:[]})}});S(this,"createGenericElementOnPointerDown",(o,r)=>{let[n,i]=mt(r.origin.x,r.origin.y,this.lastPointerDownEvent?.[T.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(o),locked:!1,frameId:a?a.id:null},s;o==="embeddable"?s=ku({type:"embeddable",...l}):s=Rt({type:o,...l}),s.type==="selection"?this.setState({selectionElement:s}):(this.scene.insertElement(s),this.setState({multiElement:null,newElement:s}))});S(this,"createFrameElementOnPointerDown",(o,r)=>{let[n,i]=mt(o.origin.x,o.origin.y,this.lastPointerDownEvent?.[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:n,y:i,opacity:this.state.currentItemOpacity,locked:!1,...Ft},l=r===at.magicframe?Ul(a):ia(a);this.scene.insertElement(l),this.setState({multiElement:null,newElement:l})});S(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});S(this,"eraseElements",()=>{let o=!1,r=this.scene.getElementsIncludingDeleted().map(n=>this.elementsPendingErasure.has(n.id)||n.frameId&&this.elementsPendingErasure.has(n.frameId)||He(n)&&this.elementsPendingErasure.has(n.containerId)?(o=!0,re(n,{isDeleted:!0})):n);this.elementsPendingErasure=new Set,o&&(this.store.scheduleCapture(),this.scene.replaceAllElements(r))});S(this,"initializeImage",async({imageFile:o,imageElement:r,showCursorImagePreview:n=!1})=>{if(!ad(o))throw new Error(f("errors.unsupportedFileType"));let i=o.type;if(Le(this.interactiveCanvas,"wait"),i===ge.svg)try{o=Fu(Au(await o.text()),o.name)}catch(m){throw console.warn(m),new Error(f("errors.svgImageInsertError"))}let a=await(this.props.generateIdForFile?.(o)||nx(o));if(!a)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(f("errors.imageInsertError"));if(!this.files[a]?.dataURL){try{o=await $l(o,{maxWidthOrHeight:Z1})}catch(m){console.error("Error trying to resizing image file on insertion",m)}if(o.size>Zp)throw new Error(f("errors.fileTooBig",{maxSize:`${Math.trunc(Zp/1024/1024)}MB`}))}if(n){let m=this.files[a]?.dataURL,d=m&&ax(m);this.setImagePreviewCursor(d||o)}let s=this.files[a]?.dataURL||await sd(o),c=this.scene.mutateElement(r,{fileId:a},{informMutation:!1,isDragging:!1});return new Promise(async(m,d)=>{try{this.addMissingFiles([{mimeType:i,id:a,dataURL:s,created:Date.now(),lastRetrieved:Date.now()}]);let p=this.imageCache.get(a);p||(this.addNewImagesToImageCache(),await this.updateImageCache([c])),p?.image instanceof Promise&&await p.image,this.state.pendingImageElementId!==c.id&&this.state.newElement?.id!==c.id&&this.initializeImageDimensions(c,!0),m(c)}catch(p){console.error(p),d(new Error(f("errors.imageInsertError")))}finally{n||Co(this.interactiveCanvas)}})});S(this,"insertImageElement",async(o,r,n)=>{if(!this.isToolSupported("image")){this.setState({errorMessage:f("errors.imageToolNotSupported")});return}this.scene.insertElement(o);try{return await this.initializeImage({imageFile:r,imageElement:o,showCursorImagePreview:n})}catch(i){return this.scene.mutateElement(o,{isDeleted:!0}),this.actionManager.executeAction(ko),this.setState({errorMessage:i.message||f("errors.imageInsertError")}),null}});S(this,"setImagePreviewCursor",async o=>{let n;try{n=await $l(o,{maxWidthOrHeight:96})}catch(a){throw a.cause==="UNSUPPORTED"?new Error(f("errors.unsupportedFileType")):a}let i=await sd(n);if(o.type===ge.svg){let a=await O0(i),l=Math.min(a.height,96),s=l*(a.width/a.height);s>96&&(s=96,l=s*(a.height/a.width));let c=document.createElement("canvas");c.height=l,c.width=s,c.getContext("2d").drawImage(a,0,0,s,l),i=c.toDataURL(ge.svg)}this.state.pendingImageElementId&&Le(this.interactiveCanvas,`url(${i}) 4 4, auto`)});S(this,"onImageAction",async({insertOnCanvasDirectly:o})=>{try{let r=this.state.width/2+this.state.offsetLeft,n=this.state.height/2+this.state.offsetTop,{x:i,y:a}=Ke({clientX:r,clientY:n},this.state),l=await Qc({description:"Image",extensions:Object.keys(wl)}),s=this.createImageElement({sceneX:i,sceneY:a,addToFrameUnderCursor:!1});o?(this.insertImageElement(s,l),this.initializeImageDimensions(s),this.setState({selectedElementIds:Me({[s.id]:!0},this.state)},()=>{this.actionManager.executeAction(ko)})):this.setState({pendingImageElementId:s.id},()=>{this.insertImageElement(s,l,!0)})}catch(r){r.name!=="AbortError"?console.error(r):console.warn(r),this.setState({pendingImageElementId:null,newElement:null,activeTool:Ne(this.state,{type:"selection"})},()=>{this.actionManager.executeAction(ko)})}});S(this,"initializeImageDimensions",(o,r=!1)=>{let n=Fr(o)&&this.imageCache.get(o.fileId)?.image;if(!n||n instanceof Promise){if(o.width<Xn/this.state.zoom.value&&o.height<Xn/this.state.zoom.value){let i=100/this.state.zoom.value;this.scene.mutateElement(o,{x:o.x-i/2,y:o.y-i/2,width:i,height:i})}return}if(r||o.width<Xn/this.state.zoom.value&&o.height<Xn/this.state.zoom.value){let i=Math.max(this.state.height-120,160),a=Math.min(i,Math.floor(this.state.height*.5)/this.state.zoom.value),l=Math.min(n.naturalHeight,a),s=l*(n.naturalWidth/n.naturalHeight),c=o.x+o.width/2-s/2,m=o.y+o.height/2-l/2;this.scene.mutateElement(o,{x:c,y:m,width:s,height:l,crop:null})}});S(this,"updateImageCache",async(o,r=this.files)=>{let{updatedFiles:n,erroredFiles:i}=await B0({imageCache:this.imageCache,fileIds:o.map(a=>a.fileId),files:r});if(n.size||i.size)for(let a of o)n.has(a.fileId)&&Er.delete(a);return i.size&&this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(a=>Fr(a)&&i.has(a.fileId)?re(a,{status:"error"}):a)),{updatedFiles:n,erroredFiles:i}});S(this,"addNewImagesToImageCache",async(o=F0(this.scene.getNonDeletedElements()),r=this.files)=>{let n=o.filter(i=>!i.isDeleted&&!this.imageCache.has(i.fileId));if(n.length){let{updatedFiles:i}=await this.updateImageCache(n,r);i.size&&this.scene.triggerUpdate()}});S(this,"scheduleImageRefresh",W8(()=>{this.addNewImagesToImageCache()},B1));S(this,"updateBindingEnabledOnPointerMove",o=>{let r=w0(o);this.state.isBindingEnabled!==r&&this.setState({isBindingEnabled:r})});S(this,"maybeSuggestBindingAtCursor",(o,r)=>{let n=xn(o,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,!1,r);this.setState({suggestedBindings:n!=null?[n]:[]})});S(this,"maybeSuggestBindingsForLinearElementAtCoords",(o,r,n)=>{if(!r.length)return;let i=r.reduce((a,l)=>{let s=xn(l,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,ee(o),ee(o));return s!=null&&!T0(o,n?.id,s)&&a.push(s),a},[]);this.setState({suggestedBindings:i})});S(this,"handleInteractiveCanvasRef",o=>{o!==null?(this.interactiveCanvas=o,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))});S(this,"handleAppOnDrop",async o=>{let{file:r,fileHandle:n}=await cx(o),{x:i,y:a}=Ke(o,this.state);try{if(ad(r)&&this.isToolSupported("image")){if(r?.type===ge.png||r?.type===ge.svg)try{let c=await ld(r,this.state,this.scene.getElementsIncludingDeleted(),n);this.syncActionResult({...c,appState:{...c.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:D.IMMEDIATELY});return}catch(c){if(c.name!=="EncodingError")throw new Error(f("alerts.couldNotLoadInvalidFile"))}let s=this.createImageElement({sceneX:i,sceneY:a});this.insertImageElement(s,r),this.initializeImageDimensions(s),this.setState({selectedElementIds:Me({[s.id]:!0},this.state)});return}}catch(s){return this.setState({isLoading:!1,errorMessage:s.message})}let l=o.dataTransfer.getData(ge.excalidrawlib);if(l&&typeof l=="string"){try{let s=rx(l);this.addElementsFromPasteOrLibrary({elements:Lm(s),position:o,files:null})}catch(s){this.setState({errorMessage:s.message})}return}if(r&&await this.loadFileToCanvas(r,n),o.dataTransfer?.types?.includes("text/plain")){let s=o.dataTransfer?.getData("text");if(s&&aa(s,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(s)||pi(s)?.type==="video")){let c=this.insertEmbeddableElement({sceneX:i,sceneY:a,link:jo(s)});c&&this.setState({selectedElementIds:{[c.id]:!0}})}}});S(this,"loadFileToCanvas",async(o,r)=>{o=await mx(o);try{let n=this.scene.getElementsIncludingDeleted(),i;try{i=await Ou(o,this.state,n,r)}catch(a){let l=a instanceof V0;if(l&&a.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:f("errors.imageToolNotSupported")});return}let s=l?f("alerts.cannotRestoreFromImage"):f("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:s})}if(!i)return;i.type===ge.excalidraw?(tr(n.concat(i.data.elements)),this.store.scheduleMicroAction({action:D.NEVER,elements:q(n),appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({...i.data,appState:{...i.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:D.IMMEDIATELY})):i.type===ge.excalidrawlib&&await this.library.updateLibrary({libraryItems:o,merge:!0,openLibraryMenu:!0}).catch(a=>{console.error(a),this.setState({errorMessage:f("errors.importLibraryError")})})}catch(n){this.setState({isLoading:!1,errorMessage:n.message})}});S(this,"handleCanvasContextMenu",o=>{if(o.preventDefault(),("pointerType"in o.nativeEvent&&o.nativeEvent.pointerType==="touch"||"pointerType"in o.nativeEvent&&o.nativeEvent.pointerType==="pen"&&o.button!==hr.SECONDARY)&&this.state.activeTool.type!=="selection")return;let{x:r,y:n}=Ke(o,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=o.clientX-d,u=o.clientY-m;fe("contextMenu","openContextMenu",s),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,...ht({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:le(i)?new $(i,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:p,items:this.getContextMenuItems(s)}})})});S(this,"maybeDragNewGenericElement",(o,r,n=!0)=>{let i=this.state.selectionElement,a=o.lastCoords;if(i&&this.state.activeTool.type!=="eraser"){qu({newElement:i,elementType:this.state.activeTool.type,originX:o.origin.x,originY:o.origin.y,x:a.x,y:a.y,width:ei(o.origin.x,a.x),height:ei(o.origin.y,a.y),shouldMaintainAspectRatio:Gi(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]=mt(a.x,a.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=Fr(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}=_w(l,this,r,{x:o.originInGrid.x+(this.state.originSnapOffset?.x??0),y:o.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:s-o.originInGrid.x,y:c-o.originInGrid.y},this.scene.getNonDeletedElementsMap());s+=p.x,c+=p.y,this.setState({snapLines:u}),qu({newElement:l,elementType:this.state.activeTool.type,originX:o.originInGrid.x,originY:o.originInGrid.y,x:s,y:c,width:ei(o.originInGrid.x,s),height:ei(o.originInGrid.y,c),shouldMaintainAspectRatio:xe(l)?!Gi(r):Gi(r),shouldResizeFromCenter:jp(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===at.frame||this.state.activeTool.type===at.magicframe)&&this.setState({elementsToHighlight:ea(this.scene.getNonDeletedElements(),l,this.state,this.scene.getNonDeletedElementsMap())})});S(this,"maybeHandleCrop",(o,r)=>{if(!this.state.croppingElementId)return!1;let n=o.resize.handleType,i=o.lastCoords,[a,l]=mt(i.x-o.resize.offset.x,i.y-o.resize.offset.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(n&&s&&xe(s)){let c=o.originalElements.get(s.id),m=Fr(s)&&this.imageCache.get(s.fileId)?.image;if(c&&xe(c)&&m&&!(m instanceof Promise)){let[d,p]=mt(i.x,i.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:d-o.originInGrid.x,y:p-o.originInGrid.y};this.maybeCacheReferenceSnapPoints(r,[s]);let{snapOffset:h,snapLines:x}=af([s],[c],this,r,u,n);this.scene.mutateElement(s,Fb(s,n,m.naturalWidth,m.naturalHeight,a+h.x,l+h.y,r.shiftKey?c.width/c.height:void 0)),gt(s,this.scene,{newSize:{width:s.width,height:s.height}}),this.setState({isCropping:n&&n!=="rotation",snapLines:x})}return!0}return!1});S(this,"maybeHandleResize",(o,r)=>{let n=this.scene.getSelectedElements(this.state),i=n.filter(d=>J(d)),a=o.resize.handleType;if(i.length>0&&a==="rotation"||n.length===1&&ee(n[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let l=o.lastCoords,[s,c]=mt(l.x-o.resize.offset.x,l.y-o.resize.offset.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=new Map;if(i.forEach(d=>{so(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]=mt(l.x,l.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:d-o.originInGrid.x,y:p-o.originInGrid.y},h=[...o.originalElements.values()];this.maybeCacheReferenceSnapPoints(r,n);let{snapOffset:x,snapLines:b}=af(n,Q(h,this.state),this,r,u,a);s+=x.x,c+=x.y,this.setState({snapLines:b})}if(Ex(o.originalElements,a,n,this.scene,fc(r),jp(r),n.some(d=>xe(d))?!Gi(r):Gi(r),s,c,o.resize.center.x,o.resize.center.y)){let d=Gc(n,this.scene.getNonDeletedElementsMap(),this.state.zoom),p=new Set;return i.forEach(u=>{ea(this.scene.getNonDeletedElements(),u,this.state,this.scene.getNonDeletedElementsMap()).forEach(h=>p.add(h))}),this.setState({elementsToHighlight:[...p],suggestedBindings:d}),!0}return!1});S(this,"getContextMenuItems",o=>{let r=[];return r.push(Em,xm),o==="canvas"?this.state.viewModeEnabled?[...r,vm,Ua,ef,Ga]:[hg,xt,Em,xm,ym,xt,Lh,rv,xt,vm,gg,Ua,ef,Ga]:(r.push(ym),this.state.viewModeEnabled?[Ha,...r]:[xt,bm,Ha,hg,xt,fw,bw,xw,xt,Jg,xt,...r,xt,ag,lg,xt,sg,Tw,fg,bg,$2,cg,xt,mg,xt,Ih,kh,Mh,Ah,xt,pg,ug,xt,qg,xt,vs,Im,xt,Dh,Sg,xt,ss])});S(this,"handleWheel",rt(o=>{if(!(o.target instanceof HTMLCanvasElement||o.target instanceof HTMLTextAreaElement||o.target instanceof HTMLIFrameElement)){o[T.CTRL_OR_CMD]&&o.preventDefault();return}if(o.preventDefault(),Ys)return;let{deltaX:r,deltaY:n}=o;if(o.metaKey||o.ctrlKey){let i=Math.sign(n),a=Ui*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=>({...Wr({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:yr(c)},m),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(o.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}))}));S(this,"savePointer",(o,r,n)=>{if(!o||!r)return;let{x:i,y:a}=Ke({clientX:o,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:De.pointers})});S(this,"resetShouldCacheIgnoreZoomDebounced",Qn(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));S(this,"updateDOMRect",o=>{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){o&&o();return}this.setState({width:n,height:i,offsetLeft:a,offsetTop:l},()=>{o&&o()})}});S(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});let r=wn(),{excalidrawAPI:n,viewModeEnabled:i=!1,zenModeEnabled:a=!1,gridModeEnabled:l=!1,objectsSnapModeEnabled:s=!1,theme:c=r.theme,name:m=`${f("labels.untitled")}-${iu()}`}=o;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},this.id=Z8(),this.library=new vv(this),this.actionManager=new Zm(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new Ei,this.canvas=document.createElement("canvas"),this.rc=K8.canvas(this.canvas),this.renderer=new _s(this.scene),this.visibleElements=[],this.store=new gd(this),this.history=new Ls(this.store),n){let d={updateScene:this.updateScene,mutateElement:this.mutateElement,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,history:{clear:this.resetHistory},scrollToContent:this.scrollToContent,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:p=>{this.actionManager.registerAction(p)},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:p=>this.onChangeEmitter.on(p),onIncrement:p=>this.store.onStoreIncrementEmitter.on(p),onPointerDown:p=>this.onPointerDownEmitter.on(p),onPointerUp:p=>this.onPointerUpEmitter.on(p),onScrollChange:p=>this.onScrollChangeEmitter.on(p),onUserFollow:p=>this.onUserFollowEmitter.on(p)};typeof n=="function"?n(d):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new vn(this.scene),this.history=new Ls(this.store),this.actionManager.registerAll(Ud),this.actionManager.registerAction(yw(this.history)),this.actionManager.registerAction(vw(this.history))}onWindowMessage(o){if(o.origin!=="https://player.vimeo.com"&&o.origin!=="https://www.youtube.com")return;let r=null;try{r=JSON.parse(o.data)}catch{}if(r)switch(o.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===o.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(yl).includes(i)&&Qf.set(n,i)}break}}cacheEmbeddableRef(o,r){r&&this.iFrameRefs.set(o.id,r)}getHTMLIFrameElement(o){return this.iFrameRefs.get(o.id)}handleEmbeddableCenterClick(o){if(this.state.activeEmbeddable?.element===o&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:o,state:"active"},selectedElementIds:{[o.id]:!0},newElement:null,selectionElement:null})},100),ri(o)))return;let r=this.getHTMLIFrameElement(o);if(r?.contentWindow){if(r.src.includes("youtube")){let n=Qf.get(o.id);switch(n||(Qf.set(o.id,yl.UNSTARTED),r.contentWindow.postMessage(JSON.stringify({event:"listening",id:o.id}),"*")),n){case yl.PLAYING:case yl.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(o,r,n,i){return o&&!r.altKey&&!r.shiftKey&&!r.metaKey&&!r.ctrlKey&&(this.state.activeEmbeddable?.element!==o||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&n>=o.x+o.width/3&&n<=o.x+2*o.width/3&&i>=o.y+o.height/3&&i<=o.y+2*o.height/3}renderEmbeddables(){let o=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||ri(a));return Re($8,{children:i.map(a=>{let{x:l,y:s}=Pt({sceneX:a.x,sceneY:a.y},this.state),c=Rl(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(ri(a)){p=null;let x=(a.customData?.generationData??this.magicGenerations.get(a.id))||{status:"error",message:"No generation data",code:"ERR_NO_GENERATION_DATA"};if(x.status==="done"){let b=x.html;p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>b}}else if(x.status==="pending")p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>Mu(`
|
|
24
|
+
C -->|Three| F[Car]`,CT=WB(El,300),KB=({mermaidToExcalidrawLib:e})=>{let[o,t]=vT(()=>Wt.get(YB.MERMAID_TO_EXCALIDRAW)||XB),n=UB(o.trim()),[r,i]=vT(null),a=TT(null),l=TT({elements:[],files:null}),s=Be();IT(()=>{Kd({canvasRef:a,data:l,mermaidToExcalidrawLib:e,setError:i,mermaidDefinition:n}).catch(d=>{VB()&&console.error("Failed to parse mermaid definition",d)}),CT(n)},[n,e]),IT(()=>()=>{CT.flush()},[]);let m=()=>{Zd({app:s,data:l,text:o,shouldSaveMermaidDataToStorage:!0})};return ST(ZB,{children:[ko("div",{className:"ttd-dialog-desc",children:ko(ft,{i18nKey:"mermaid.description",flowchartLink:d=>ko("a",{href:"https://mermaid.js.org/syntax/flowchart.html",children:d}),sequenceLink:d=>ko("a",{href:"https://mermaid.js.org/syntax/sequenceDiagram.html",children:d}),classLink:d=>ko("a",{href:"https://mermaid.js.org/syntax/classDiagram.html",children:d})})}),ST(Vd,{children:[ko(Hi,{label:g("mermaid.syntax"),children:ko(Ud,{input:o,placeholder:"Write Mermaid diagram defintion here...",onChange:d=>t(d.target.value),onKeyboardSubmit:()=>{m()}})}),ko(Hi,{label:g("mermaid.preview"),panelAction:{action:()=>{m()},label:g("mermaid.button"),icon:Nr},renderSubmitShortcut:()=>ko(Xd,{}),children:ko(Wd,{canvasRef:a,loaded:e.loaded,error:r})})]})]})},kT=KB;import*as PT from"@radix-ui/react-tabs";import{useRef as MT}from"react";import{isMemberOf as $B}from"@excalidraw/common";import{jsx as jB}from"react/jsx-runtime";var LT=e=>{let o=ae(),t=MT(null),n=MT(0);return jB(PT.Root,{ref:t,className:"ttd-dialog-tabs-root",value:e.tab,onValueChange:r=>{if(!r)return;let i=t.current?.closest(".Modal__content");if(i){let a=i.offsetHeight||0;a>n.current&&(n.current=a,i.style.minHeight=`min(${n.current}px, 100%)`)}e.dialog==="ttd"&&$B(["text-to-diagram","mermaid"],r)&&o({openDialog:{name:e.dialog,tab:r}})},children:e.children})};LT.displayName="TTDDialogTabs";var AT=LT;import*as DT from"@radix-ui/react-tabs";import{jsx as qB}from"react/jsx-runtime";var Hg=({children:e,...o})=>qB(DT.List,{className:"ttd-dialog-triggers",...o,children:e});Hg.displayName="TTDDialogTabTriggers";import*as RT from"@radix-ui/react-tabs";import{jsx as _T}from"react/jsx-runtime";var $d=({children:e,tab:o,onSelect:t,...n})=>_T(RT.Trigger,{value:o,asChild:!0,onSelect:t,children:_T("button",{type:"button",className:"ttd-dialog-tab-trigger",...n,children:e})});$d.displayName="TTDDialogTabTrigger";import*as NT from"@radix-ui/react-tabs";import{jsx as JB}from"react/jsx-runtime";var jd=({tab:e,children:o,...t})=>JB(NT.Content,{...t,value:e,children:o});jd.displayName="TTDDialogTab";import{jsx as xt,jsxs as Mn}from"react/jsx-runtime";var Ug=3,Gi=1e3,eF=he(null),tF=he(null),Yg=e=>{let o=be();return o.openDialog?.name!=="ttd"?null:xt(oF,{...e,tab:o.openDialog.tab})},oF=Zo("TTDDialogBase",({tab:e,...o})=>{let t=Be(),n=ae(),r=Gg(null),[i,a]=le(tF),[l,s]=qd(i?.prompt??""),m=l.trim(),d=S=>{s(S.target.value),a(L=>({generatedResponse:L?.generatedResponse??null,prompt:S.target.value}))},[c,p]=qd(!1),[u,f]=le(eF),b=async()=>{if(m.length>Gi||m.length<Ug||c||u?.rateLimitRemaining===0||"__fallback"in o){m.length<Ug&&C(new Error(`Prompt is too short (min ${Ug} characters)`)),m.length>Gi&&C(new Error(`Prompt is too long (max ${Gi} characters)`));return}try{p(!0),re("ai","generate","ttd");let{generatedResponse:S,error:L,rateLimit:P,rateLimitRemaining:B}=await o.onTextSubmit(m);if(typeof S=="string"&&a(k=>({generatedResponse:S,prompt:k?.prompt??null})),BT(P)&&BT(B)&&f({rateLimit:P,rateLimitRemaining:B}),L){C(L);return}if(!S){C(new Error("Generation failed"));return}try{await Kd({canvasRef:r,data:w,mermaidToExcalidrawLib:y,setError:C,mermaidDefinition:S}),re("ai","mermaid parse success","ttd")}catch(k){console.info(`%cTTD mermaid render errror: ${k.message}`,"color: red"),console.info(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
25
|
+
TTD mermaid definition render errror: ${k.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=Gg(b);x.current=b;let[y,E]=qd({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw")});QB(()=>{(async()=>{await y.api,E(L=>({...L,loaded:!0}))})()},[y.api]);let w=Gg({elements:[],files:null}),[v,C]=qd(null);return xt(Oe,{className:"ttd-dialog",onCloseRequest:()=>{t.setOpenDialog(null)},size:1200,title:!1,...o,autofocus:!1,children:Mn(AT,{dialog:"ttd",tab:e,children:["__fallback"in o&&o.__fallback?xt("p",{className:"dialog-mermaid-title",children:g("mermaid.title")}):Mn(Hg,{children:[xt($d,{tab:"text-to-diagram",children:Mn("div",{style:{display:"flex",alignItems:"center"},children:[g("labels.textToDiagram"),xt("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"})]})}),xt($d,{tab:"mermaid",children:"Mermaid"})]}),xt(jd,{className:"ttd-dialog-content",tab:"mermaid",children:xt(kT,{mermaidToExcalidrawLib:y})}),!("__fallback"in o)&&Mn(jd,{className:"ttd-dialog-content",tab:"text-to-diagram",children:[xt("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."}),Mn(Vd,{children:[xt(Hi,{label:g("labels.prompt"),panelAction:{action:b,label:"Generate",icon:Nr},onTextSubmitInProgess:c,panelActionDisabled:m.length>Gi||u?.rateLimitRemaining===0,renderTopRight:()=>u?Mn("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:()=>xt(Xd,{}),renderBottomRight:()=>{if(typeof i?.generatedResponse=="string")return Mn("div",{className:"excalidraw-link",style:{marginLeft:"auto",fontSize:14},onClick:()=>{typeof i?.generatedResponse=="string"&&(El(i.generatedResponse),n({openDialog:{name:"ttd",tab:"mermaid"}}))},children:["View as Mermaid",xt(dn,{icon:Nr})]});let S=m.length/Gi;return S>.8?Mn("div",{style:{marginLeft:"auto",fontSize:12,fontFamily:"monospace",color:S>1?"var(--color-danger)":void 0},children:["Length: ",m.length,"/",Gi]}):null},children:xt(Ud,{onChange:d,input:l,placeholder:"Describe what you want to see...",onKeyboardSubmit:()=>{x.current()}})}),xt(Hi,{label:"Preview",panelAction:{action:()=>{console.info("Panel action clicked"),Zd({app:t,data:w})},label:"Insert",icon:Nr},children:xt(Wd,{canvasRef:r,error:v,loaded:y.loaded})})]})]})]})})});import{round as w5}from"@excalidraw/math";import gO from"clsx";import fO from"lodash.throttle";import{useEffect as v5,useMemo as nf,useState as bO,memo as xO}from"react";import{STATS_PANELS as im}from"@excalidraw/common";import{getCommonBounds as EO}from"@excalidraw/element";import{getUncroppedWidthAndHeight as yO}from"@excalidraw/element";import{isElbowArrow as wO,isImageElement as rf}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as vO}from"@excalidraw/element";import{elementsAreInSameGroup as TO}from"@excalidraw/element";import{degreesToRadians as UT,radiansToDegrees as XT}from"@excalidraw/math";import{getBoundTextElement as YT}from"@excalidraw/element";import{isArrowElement as WT,isElbowArrow as hF}from"@excalidraw/element";import{updateBindings as VT}from"@excalidraw/element";import sF from"clsx";import{useEffect as HT,useRef as Qd,useState as cF}from"react";import{EVENT as Wi,KEYS as dF,cloneJSON as Wg}from"@excalidraw/common";import{deepCopyElement as mF}from"@excalidraw/element";import{CaptureUpdateAction as GT}from"@excalidraw/element";import{pointFrom as Pn,pointRotateRads as Jd}from"@excalidraw/math";import{getBoundTextElement as nF}from"@excalidraw/element";import{isFrameLikeElement as OT}from"@excalidraw/element";import{getSelectedGroupIds as rF,getElementsInGroup as iF,isInGroup as aF}from"@excalidraw/element";import{getFrameChildren as lF}from"@excalidraw/element";import{updateBindings as FT}from"@excalidraw/element";var zT=.01,yl=10,Ct=(e,o)=>!(o==="angle"&&OT(e)),Pe=(e,o)=>{let t=e+o/2;return t-t%o},Ui=(e,o,t)=>Object.keys(e).map(n=>({original:(t??o).get(n),latest:o.get(n)})).filter(n=>n.original!==void 0&&n.latest!==void 0);var pr=(e,o,t,n,r,i=!0)=>{let a=n.getNonDeletedElementsMap(),l=a.get(t.id);if(!l)return;let[s,m]=[t.x+t.width/2,t.y+t.height/2],[d,c]=Jd(Pn(t.x,t.y),Pn(s,m),t.angle),p=e-d,u=o-c,[f,b]=Jd(Pn(e,o),Pn(s+p,m+u),-t.angle);n.mutateElement(l,{x:f,y:b},{informMutation:i,isDragging:!1}),FT(l,n);let x=nF(t,r);if(x){let y=a.get(x.id);y&&n.mutateElement(y,{x:x.x+p,y:x.y+u},{informMutation:i,isDragging:!1})}if(OT(t)){let y=lF(r,t.id);y.forEach(E=>{let w=a.get(E.id);if(!w)return;let[v,C]=[E.x+E.width/2,E.y+E.height/2],[S,L]=Jd(Pn(E.x,E.y),Pn(v,C),E.angle),P=Math.round(S+p),B=Math.round(L+u),[k,A]=Jd(Pn(P,B),Pn(v+p,C+u),-E.angle);n.mutateElement(w,{x:k,y:A},{informMutation:i,isDragging:!1}),FT(w,n,{simultaneouslyUpdated:y})})}},Yi=(e,o)=>{let n=rF(o).map(r=>iF(e,r).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(r=>!aF(r)).forEach(r=>{n.push({[r.id]:!0})}),n};import{jsx as Vg,jsxs as uF}from"react/jsx-runtime";var pF=({label:e,icon:o,dragInputCallback:t,value:n,elements:r,editable:i=!0,shouldKeepAspectRatio:a,property:l,scene:s,appState:m,sensitivity:d=1,dragFinishedCallback:c})=>{let p=Be(),u=ae(),f=Qd(null),b=Qd(null),[x,y]=cF(n.toString()),E=Qd(null);E.current||(E.current={originalAppState:Wg(m),originalElements:r,lastUpdatedValue:x,updatePending:!1}),HT(()=>{let C=n.toString();y(C),E.current.lastUpdatedValue=C},[n]);let w=(C,S,L)=>{if(!E.current.updatePending)return!1;E.current.updatePending=!1;let P=Number(C);if(isNaN(P)){y(n.toString());return}let B=Number(P.toFixed(2)),k=Number(n);(isNaN(k)||Math.abs(B-k)>=zT)&&(E.current.lastUpdatedValue=C,t({accumulatedChange:0,instantChange:0,originalElements:S,originalElementsMap:p.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:s,nextValue:B,property:l,originalAppState:L,setInputValue:A=>y(String(A)),app:p,setAppState:u}),p.syncActionResult({captureUpdate:GT.IMMEDIATELY}))},v=Qd({});return v.current.handleInputValue=w,HT(()=>{let C=f.current,S=v.current;return()=>{let L=C?.value;L&&S.handleInputValue?.(L,E.current.originalElements,E.current.originalAppState),window.removeEventListener(Wi.POINTER_MOVE,S.onPointerMove,!1),window.removeEventListener(Wi.POINTER_UP,S.onPointerUp,!1)}},[i]),i?uF("div",{className:sF("drag-input-container",!i&&"disabled"),"data-testid":e,children:[Vg("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,P=p.scene.getNonDeletedElements().reduce((_,R)=>(_.set(R.id,mF(R)),_),new Map),B=r.map(_=>P.get(_.id)),k=Wg(m),A=0,F=0,Y=_=>{if(L&&P!==null&&B!==null){let R=_.clientX-L.x;R!==0&&(F+=R,Math.abs(F)>=d&&(F=Math.sign(F)*Math.floor(Math.abs(F)/d),A+=F,t({accumulatedChange:A,instantChange:F,originalElements:B,originalElementsMap:P,shouldKeepAspectRatio:a,shouldChangeByStepSize:_.shiftKey,property:l,scene:s,originalAppState:k,setInputValue:W=>y(String(W)),app:p,setAppState:u}),F=0))}L={x:_.clientX,y:_.clientY}},Q=()=>{window.removeEventListener(Wi.POINTER_MOVE,Y,!1),p.syncActionResult({captureUpdate:GT.IMMEDIATELY}),c?.({app:p,setAppState:u,originalElements:B,originalAppState:k}),L=null,A=0,F=0,B=null,P=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(Wi.POINTER_UP,Q,!1)};v.current.onPointerMove=Y,v.current.onPointerUp=Q,window.addEventListener(Wi.POINTER_MOVE,Y,!1),window.addEventListener(Wi.POINTER_UP,Q,!1)}},onPointerEnter:()=>{b.current&&(b.current.style.cursor="ew-resize")},children:o?Vg(dn,{icon:o}):e}),Vg("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:C=>{if(i){let S=C.target;S instanceof HTMLInputElement&&C.key===dF.ENTER&&(w(S.value,r,m),p.focusContainer())}},ref:f,value:x,onChange:C=>{E.current.updatePending=!0,y(C.target.value)},onFocus:C=>{C.target.select(),E.current.originalElements=r,E.current.originalAppState=Wg(m)},onBlur:C=>{x?i&&w(C.target.value,E.current.originalElements,E.current.originalAppState):y(n.toString())},disabled:!i})]}):null},Qe=pF;import{jsx as xF}from"react/jsx-runtime";var gF=15,fF=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=o[0];if(a&&!hF(a)){let l=i.get(a.id);if(!l)return;if(n!==void 0){let u=UT(n);r.mutateElement(l,{angle:u}),VT(l,r);let f=YT(l,i);f&&!WT(l)&&r.mutateElement(f,{angle:u});return}let s=Math.round(XT(a.angle)*100)/100,m=Math.round(e),d=(s+m)%360;t&&(d=Pe(d,gF)),d=d<0?d+360:d;let c=UT(d);r.mutateElement(l,{angle:c}),VT(l,r);let p=YT(l,i);p&&!WT(l)&&r.mutateElement(p,{angle:c})}},bF=({element:e,scene:o,appState:t,property:n})=>xF(Qe,{label:"A",icon:ms,value:Math.round(XT(e.angle)%360*100)/100,elements:[e],dragInputCallback:fF,editable:Ct(e,"angle"),scene:o,appState:t,property:n}),KT=bF;import{jsx as yF}from"react/jsx-runtime";var ZT=5,EF=({property:e,scene:o,appState:t,setAppState:n})=>yF(Qe,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:r,instantChange:i,shouldChangeByStepSize:a,setInputValue:l})=>{n(s=>{let m;return r?m=r:i&&(m=a?Pe(s.gridStep+ZT*Math.sign(i),ZT):s.gridStep+i),m?(m=g1(m),l(m),{gridStep:m}):(l(s.gridStep),null)})},scene:o,value:t.gridStep,property:e,appState:t}),$T=EF;import{clamp as em,round as Xg}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as tm}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as jT,getUncroppedWidthAndHeight as QT}from"@excalidraw/element";import{resizeSingleElement as qT}from"@excalidraw/element";import{isImageElement as e5}from"@excalidraw/element";import{isFrameLikeElement as Kg}from"@excalidraw/element";import{getElementsInResizingFrame as Zg}from"@excalidraw/element";import{replaceAllElementsInFrame as t5}from"@excalidraw/element";import{jsx as CF}from"react/jsx-runtime";var JT=10,wF=e=>e.type==="image",vF=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldKeepAspectRatio:n,shouldChangeByStepSize:r,nextValue:i,property:a,originalAppState:l,instantChange:s,scene:m,app:d,setAppState:c})=>{let p=m.getNonDeletedElementsMap(),u=o[0],f=p.get(u.id);if(u&&f){let b=n||wF(u),x=u.width/u.height;if(l.croppingElementId===u.id){let y=p.get(u.id);if(!y||!e5(y)||!y.crop)return;let E=y.crop,w={...E},v=y.scale[0]===-1,C=y.scale[1]===-1,{width:S,height:L}=QT(y),P=E.naturalWidth/S,B=E.naturalHeight/L,k=v?E.width+E.x:E.naturalWidth-E.x,A=C?E.height+E.y:E.naturalHeight-E.y,F=jT*P,Y=jT*B;if(i!==void 0){if(a==="width"){let X=i*P,G=em(X,F,k);w={...w,width:G,x:v?E.x+E.width-G:E.x}}else if(a==="height"){let X=i*B,G=em(X,Y,A);w={...w,height:G,y:C?E.y+E.height-G:E.y}}m.mutateElement(y,{crop:w,width:w.width/(E.naturalWidth/S),height:w.height/(E.naturalHeight/L)});return}let Q=a==="width"?s:0,_=a==="height"?s:0,R=em(E.width+Q,F,k),W=em(E.height+_,F,A);w={...E,x:v?E.x+E.width-R:E.x,y:C?E.y+E.height-W:E.y,width:R,height:W},m.mutateElement(y,{crop:w,width:w.width/(E.naturalWidth/S),height:w.height/(E.naturalHeight/L)});return}if(i!==void 0){let y=Math.max(a==="width"?i:b?i*x:u.width,tm),E=Math.max(a==="height"?i:b?i/x:u.height,tm);if(qT(y,E,f,u,t,m,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),Kg(f)){let w=Zg(m.getElementsIncludingDeleted(),f,l,m.getNonDeletedElementsMap()),v=t5(m.getElementsIncludingDeleted(),w,f,d);m.replaceAllElements(v)}return}{let y=a==="width"?e:0,E=a==="height"?e:0,w=Math.max(0,u.width+y);a==="width"&&(r?w=Pe(w,JT):w=Math.round(w));let v=Math.max(0,u.height+E);if(a==="height"&&(r?v=Pe(v,JT):v=Math.round(v)),b&&(a==="width"?v=Math.round(w/x*100)/100:w=Math.round(v*x*100)/100),v=Math.max(tm,v),w=Math.max(tm,w),qT(w,v,f,u,t,m,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),Kg(f)){let C=Zg(m.getElementsIncludingDeleted(),f,l,m.getNonDeletedElementsMap());c({elementsToHighlight:C})}}}},TF=({setAppState:e,app:o,originalElements:t,originalAppState:n})=>{let r=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&Kg(a)){let l=Zg(o.scene.getElementsIncludingDeleted(),a,n,o.scene.getNonDeletedElementsMap()),s=t5(o.scene.getElementsIncludingDeleted(),l,a,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},IF=({property:e,element:o,scene:t,appState:n})=>{let r=Xg(e==="width"?o.width:o.height,2);if(n.croppingElementId&&n.croppingElementId===o.id&&e5(o)&&o.crop){let{width:i,height:a}=QT(o);if(e==="width"){let l=i/o.crop.naturalWidth;r=Xg(o.crop.width*l,2)}if(e==="height"){let l=a/o.crop.naturalHeight;r=Xg(o.crop.height*l,2)}}return CF(Qe,{label:e==="width"?"W":"H",elements:[o],dragInputCallback:vF,value:r,editable:Ct(o,e),scene:t,appState:n,property:e,dragFinishedCallback:TF})},$g=IF;import{getBoundTextElement as SF,redrawTextBoundingBox as kF}from"@excalidraw/element";import{hasBoundTextElement as MF,isTextElement as n5}from"@excalidraw/element";import{jsx as DF}from"react/jsx-runtime";var o5=4,PF=4,LF=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=o[0];if(a){let l=i.get(a.id);if(!l||!n5(l))return;let s;if(n!==void 0)s=Math.max(Math.round(n),o5);else if(a.type==="text"){let m=Math.round(a.fontSize),d=Math.round(e);s=Math.max(m+d,o5),t&&(s=Pe(s,PF))}s&&(r.mutateElement(l,{fontSize:s}),kF(l,r.getContainerElement(l),r))}},AF=({element:e,scene:o,appState:t,property:n})=>{let r=n5(e)?e:MF(e)?SF(e,o.getNonDeletedElementsMap()):null;return r?DF(Qe,{label:"F",value:Math.round(r.fontSize*10)/10,elements:[r],dragInputCallback:LF,icon:Kn,appState:t,scene:o,property:n}):null},r5=AF;import{degreesToRadians as i5,radiansToDegrees as s5}from"@excalidraw/math";import{getBoundTextElement as a5}from"@excalidraw/element";import{isArrowElement as l5}from"@excalidraw/element";import{isInGroup as jg}from"@excalidraw/element";import{jsx as BF}from"react/jsx-runtime";var _F=15,RF=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,property:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),l=o.map(m=>a.get(m.id)).filter(m=>m&&!jg(m)&&Ct(m,r)),s=o.filter(m=>!jg(m)&&Ct(m,r));if(n!==void 0){let m=i5(n);for(let d of l){if(!d)continue;i.mutateElement(d,{angle:m});let c=a5(d,a);c&&!l5(d)&&i.mutateElement(c,{angle:m})}i.triggerUpdate();return}for(let m=0;m<l.length;m++){let d=l[m];if(!d)continue;let c=s[m],p=Math.round(s5(c.angle)*100)/100,u=Math.round(e),f=(p+u)%360;t&&(f=Pe(f,_F)),f=f<0?f+360:f;let b=i5(f);i.mutateElement(d,{angle:b});let x=a5(d,a);x&&!l5(d)&&i.mutateElement(x,{angle:b})}i.triggerUpdate()},NF=({elements:e,scene:o,appState:t,property:n})=>{let r=e.filter(s=>!jg(s)&&Ct(s,"angle")),i=r.map(s=>Math.round(s5(s.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",l=r.some(s=>Ct(s,"angle"));return BF(Qe,{label:"A",icon:ms,value:a,elements:e,dragInputCallback:RF,editable:l,appState:t,scene:o,property:n})},c5=NF;import{pointFrom as d5}from"@excalidraw/math";import{useMemo as FF}from"react";import{MIN_WIDTH_OR_HEIGHT as Ln}from"@excalidraw/common";import{getElementsInResizingFrame as qg,isFrameLikeElement as Jg,replaceAllElementsInFrame as u5,updateBoundElements as OF}from"@excalidraw/element";import{rescalePointsInElement as zF,resizeSingleElement as m5}from"@excalidraw/element";import{getBoundTextElement as HF,handleBindTextResize as GF}from"@excalidraw/element";import{isTextElement as h5}from"@excalidraw/element";import{getCommonBounds as om}from"@excalidraw/element";import{jsx as KF}from"react/jsx-runtime";var Vi=10,UF=(e,o,t,n)=>{let r=n.x-e,i=n.y-o,a=n.width*t,l=n.height*t,s=e+r*t,m=o+i*t;return{width:a,height:l,x:s,y:m,...zF(n,a,l,!1),...h5(n)?{fontSize:n.fontSize*t}:{}}},YF=(e,o,t,n,r,i,a,l)=>{let s=l.getNonDeletedElementsMap(),m=UF(e,o,n,i);l.mutateElement(r,m);let d=HF(i,a);if(d){let c=d.fontSize*n;OF(r,l,{newSize:{width:m.width,height:m.height}});let p=s.get(d.id);p&&h5(p)&&(l.mutateElement(p,{fontSize:c}),GF(r,l,t==="width"?"e":"s",!0))}},p5=(e,o,t,n,r,i,a,l,s,m)=>{i==="width"?o=Math.round(e/n*100)/100:e=Math.round(o*n*100)/100;let d=o/t;for(let c=0;c<l.length;c++){let p=l[c],u=a[c];YF(r[0],r[1],i,d,u,p,s,m)}},WF=({accumulatedChange:e,originalElements:o,originalElementsMap:t,originalAppState:n,shouldChangeByStepSize:r,nextValue:i,scene:a,property:l,setAppState:s,app:m})=>{let d=a.getNonDeletedElementsMap(),c=Yi(o,n);if(i!==void 0){for(let b of c){let x=Ui(b,d,t);if(x.length>1){let y=x.map(F=>F.latest),E=x.map(F=>F.original),[w,v,C,S]=om(E),L=C-w,P=S-v,B=L/P,k=Math.max(Ln,l==="width"?Math.max(0,i):L),A=Math.max(Ln,l==="height"?Math.max(0,i):P);p5(k,A,P,B,d5(w,v),l,y,E,t,a)}else{let[y]=x,E=y?.latest,w=y?.original;if(E&&w&&Ct(E,l)){let v=l==="width"?Math.max(0,i):E.width;l==="width"&&(r?v=Pe(v,Vi):v=Math.round(v));let C=l==="height"?Math.max(0,i):E.height;if(l==="height"&&(r?C=Pe(C,Vi):C=Math.round(C)),v=Math.max(Ln,v),C=Math.max(Ln,C),m5(v,C,E,w,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),Jg(E)){let S=qg(a.getElementsIncludingDeleted(),E,n,a.getNonDeletedElementsMap()),L=u5(a.getElementsIncludingDeleted(),S,E,m);a.replaceAllElements(L)}}}}a.triggerUpdate();return}let p=l==="width"?e:0,u=l==="height"?e:0,f=[];for(let b of c){let x=Ui(b,d,t);if(x.length>1){let y=x.map(F=>F.latest),E=x.map(F=>F.original),[w,v,C,S]=om(E),L=C-w,P=S-v,B=L/P,k=Math.max(0,L+p);l==="width"&&(r?k=Pe(k,Vi):k=Math.round(k));let A=Math.max(0,P+u);l==="height"&&(r?A=Pe(A,Vi):A=Math.round(A)),k=Math.max(Ln,k),A=Math.max(Ln,A),p5(k,A,P,B,d5(w,v),l,y,E,t,a)}else{let[y]=x,E=y?.latest,w=y?.original;if(E&&w&&Ct(E,l)){let v=Math.max(0,w.width+p);l==="width"&&(r?v=Pe(v,Vi):v=Math.round(v));let C=Math.max(0,w.height+u);if(l==="height"&&(r?C=Pe(C,Vi):C=Math.round(C)),v=Math.max(Ln,v),C=Math.max(Ln,C),m5(v,C,E,w,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),Jg(E)){let S=qg(a.getElementsIncludingDeleted(),E,n,a.getNonDeletedElementsMap());f.push(...S)}}}}s({elementsToHighlight:f}),a.triggerUpdate()},VF=({setAppState:e,app:o,originalElements:t,originalAppState:n})=>{let r=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&Jg(a)){let l=qg(o.scene.getElementsIncludingDeleted(),a,n,o.scene.getNonDeletedElementsMap()),s=u5(o.scene.getElementsIncludingDeleted(),l,a,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},XF=({property:e,elements:o,elementsMap:t,atomicUnits:n,scene:r,appState:i})=>{let a=FF(()=>n.map(m=>{let d=Ui(m,t);if(d.length>1){let[p,u,f,b]=om(d.map(x=>x.latest));return Math.round((e==="width"?f-p:b-u)*100)/100}let[c]=d;return Math.round((e==="width"?c.latest.width:c.latest.height)*100)/100}),[t,n,e]),l=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",s=a.length>0;return KF(Qe,{label:e==="width"?"W":"H",elements:o,dragInputCallback:WF,value:l,editable:s,appState:i,property:e,scene:r,dragFinishedCallback:VF})},Qg=XF;import{getBoundTextElement as ZF,redrawTextBoundingBox as g5}from"@excalidraw/element";import{hasBoundTextElement as $F,isTextElement as jF}from"@excalidraw/element";import{isInGroup as qF}from"@excalidraw/element";import{jsx as oO}from"react/jsx-runtime";var f5=4,JF=4,QF=(e,o)=>e.reduce((t,n)=>{if(!n||qF(n))return t;if(jF(n))return t.push(n),t;if($F(n)){let r=ZF(n,o);if(r)return t.push(r),t}return t},[]),eO=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=o.map(s=>i.get(s.id)),l;if(n){l=Math.max(Math.round(n),f5);for(let s of a)r.mutateElement(s,{fontSize:l}),g5(s,r.getContainerElement(s),r);r.triggerUpdate()}else{let s=o;for(let m=0;m<a.length;m++){let d=a[m],c=s[m],p=Math.round(c.fontSize),u=Math.round(e),f=Math.max(p+u,f5);t&&(f=Pe(f,JF)),r.mutateElement(d,{fontSize:f}),g5(d,r.getContainerElement(d),r)}r.triggerUpdate()}},tO=({elements:e,scene:o,appState:t,property:n,elementsMap:r})=>{let i=QF(e,r);if(!i.length)return null;let a=i.map(m=>Math.round(m.fontSize*10)/10),l=new Set(a).size===1?a[0]:"Mixed",s=a.length>0;return oO(Qe,{label:"F",icon:Kn,elements:i,dragInputCallback:eO,value:l,editable:s,scene:o,property:n,appState:t})},b5=tO;import{pointFrom as An,pointRotateRads as nm}from"@excalidraw/math";import{useMemo as nO}from"react";import{isTextElement as rO}from"@excalidraw/element";import{getCommonBounds as ef}from"@excalidraw/element";import{jsx as cO}from"react/jsx-runtime";var iO=(e,o,t,n,r,i)=>{for(let a=0;a<n.length;a++){let l=n[a],[s,m]=[l.x+l.width/2,l.y+l.height/2],[d,c]=nm(An(l.x,l.y),An(s,m),l.angle),p=e==="x"?Math.round(d+o):d,u=e==="y"?Math.round(c+t):c;pr(p,u,l,i,r,!1)}},aO=(e,o,t,n,r)=>{let i=r.getNonDeletedElementsMap(),[a,l,,]=ef(t),s=e-a,m=o-l;for(let d=0;d<t.length;d++){let c=t[d],p=i.get(c.id);if(p&&(!rO(p)||!p.containerId)){let[u,f]=[p.x+p.width/2,p.y+p.height/2],[b,x]=nm(An(p.x,p.y),An(u,f),p.angle);pr(b+s,x+m,c,r,n,!1)}}},lO=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldChangeByStepSize:n,nextValue:r,property:i,scene:a,originalAppState:l})=>{let s=a.getNonDeletedElementsMap();if(r!==void 0){for(let p of Yi(o,l)){let u=Ui(p,s,t);if(u.length>1){let[f,b,,]=ef(u.map(E=>E.latest));aO(i==="x"?r:f,i==="y"?r:b,u.map(E=>E.original),t,a)}else{let f=u[0]?.original,b=u[0]?.latest;if(f&&b&&Ct(b,i)){let[x,y]=[f.x+f.width/2,f.y+f.height/2],[E,w]=nm(An(f.x,f.y),An(x,y),f.angle);pr(i==="x"?r:E,i==="y"?r:w,f,a,t,!1)}}}a.triggerUpdate();return}let m=n?Pe(e,yl):e;iO(i,i==="x"?m:0,i==="y"?m:0,o,t,a),a.triggerUpdate()},sO=({property:e,elements:o,elementsMap:t,atomicUnits:n,scene:r,appState:i})=>{let a=nO(()=>n.map(s=>{let m=Object.keys(s).map(b=>t.get(b)).filter(b=>b!==void 0);if(m.length>1){let[b,x]=ef(m);return Math.round((e==="x"?b:x)*100)/100}let[d]=m,[c,p]=[d.x+d.width/2,d.y+d.height/2],[u,f]=nm(An(d.x,d.y),An(c,p),d.angle);return Math.round((e==="x"?u:f)*100)/100}),[n,t,e]),l=new Set(a).size===1?a[0]:"Mixed";return cO(Qe,{label:e==="x"?"X":"Y",elements:o,dragInputCallback:lO,value:l,property:e,scene:r,appState:i})},tf=sO;import{clamp as wl,pointFrom as rm,pointRotateRads as E5,round as x5}from"@excalidraw/math";import{getFlipAdjustedCropPosition as dO,getUncroppedWidthAndHeight as mO}from"@excalidraw/element";import{isImageElement as y5}from"@excalidraw/element";import{jsx as hO}from"react/jsx-runtime";var pO=({accumulatedChange:e,instantChange:o,originalElements:t,originalElementsMap:n,shouldChangeByStepSize:r,nextValue:i,property:a,scene:l,originalAppState:s})=>{let m=l.getNonDeletedElementsMap(),d=t[0],[c,p]=[d.x+d.width/2,d.y+d.height/2],[u,f]=E5(rm(d.x,d.y),rm(c,p),d.angle);if(s.croppingElementId===d.id){let w=m.get(d.id);if(!w||!y5(w)||!w.crop)return;let v=w.crop,C=v,S=w.scale[0]===-1,L=w.scale[1]===-1,{width:P,height:B}=mO(w);if(i!==void 0){if(a==="x"){let F=i*(v.naturalWidth/P);S?C={...v,x:wl(v.naturalWidth-F-v.width,0,v.naturalWidth-v.width)}:C={...v,x:wl(i*(v.naturalWidth/P),0,v.naturalWidth-v.width)}}a==="y"&&(C={...v,y:wl(i*(v.naturalHeight/B),0,v.naturalHeight-v.height)}),l.mutateElement(w,{crop:C});return}let k=(a==="x"?o:0)*(S?-1:1),A=(a==="y"?o:0)*(L?-1:1);C={...v,x:wl(v.x+k,0,v.naturalWidth-v.width),y:wl(v.y+A,0,v.naturalHeight-v.height)},l.mutateElement(w,{crop:C});return}if(i!==void 0){pr(a==="x"?i:u,a==="y"?i:f,d,l,n);return}let b=a==="x"?e:0,x=a==="y"?e:0,y=a==="x"?Math.round(r?Pe(d.x+b,yl):u+b):u,E=a==="y"?Math.round(r?Pe(d.y+x,yl):f+x):f;pr(y,E,d,l,n)},uO=({property:e,element:o,elementsMap:t,scene:n,appState:r})=>{let[i,a]=E5(rm(o.x,o.y),rm(o.x+o.width/2,o.y+o.height/2),o.angle),l=x5(e==="x"?i:a,2);if(r.croppingElementId===o.id&&y5(o)&&o.crop){let s=dO(o);s&&(l=x5(e==="x"?s.x:s.y,2))}return hO(Qe,{label:e==="x"?"X":"Y",elements:[o],dragInputCallback:pO,scene:n,value:l,property:e,appState:r})},of=uO;import{Fragment as af,jsx as q,jsxs as St}from"react/jsx-runtime";var IO=50,vl=e=>{let o=bo(),t=e.app.scene.getSceneNonce()||1,n=e.app.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}),r=yn(e.app);return q(CO,{...e,appState:o,sceneNonce:t,selectedElements:n,gridModeEnabled:r})},Se=({children:e,columns:o=1,heading:t,style:n,...r})=>q("div",{className:gO("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${o}, 1fr)`,...n},...r,children:e});Se.displayName="StatsRow";var am=({children:e,order:o,style:t,...n})=>q("div",{className:"exc-stats__rows",style:{order:o,...t},...n,children:e});am.displayName="StatsRows";vl.StatsRow=Se;vl.StatsRows=am;var CO=xO(({app:e,onClose:o,renderCustomStats:t,selectedElements:n,appState:r,sceneNonce:i,gridModeEnabled:a})=>{let l=e.scene,s=l.getNonDeletedElements(),m=l.getNonDeletedElementsMap(),d=ae(),c=n.length===1?n[0]:null,p=n.length>1?n:null,u=r.croppingElementId&&rf(c),f=u?yO(c):null,[b,x]=bO({width:0,height:0}),y=nf(()=>fO(v=>{let C=EO(v);x({width:Math.round(C[2])-Math.round(C[0]),height:Math.round(C[3])-Math.round(C[1])})},IO),[]);v5(()=>{y(s)},[i,s,y]),v5(()=>()=>y.cancel(),[y]);let E=nf(()=>Yi(n,r),[n,r]),w=nf(()=>vO(n),[n]);return q("div",{className:"exc-stats",children:St(Ye,{padding:3,children:[St("div",{className:"title",children:[q("h2",{children:g("stats.title")}),q("div",{className:"close",onClick:o,children:zt})]}),St(ka,{label:q("h3",{children:g("stats.generalStats")}),open:!!(r.stats.panels&im.generalStats),openTrigger:()=>d(v=>({stats:{open:!0,panels:v.stats.panels^im.generalStats}})),children:[St(am,{children:[q(Se,{heading:!0,children:g("stats.scene")}),St(Se,{columns:2,children:[q("div",{children:g("stats.shapes")}),q("div",{children:s.length})]}),St(Se,{columns:2,children:[q("div",{children:g("stats.width")}),q("div",{children:b.width})]}),St(Se,{columns:2,children:[q("div",{children:g("stats.height")}),q("div",{children:b.height})]}),a&&St(af,{children:[q(Se,{heading:!0,children:"Canvas"}),q(Se,{children:q($T,{property:"gridStep",scene:l,appState:r,setAppState:d})})]})]}),t?.(s,r)]}),!w&&n.length>0&&q("div",{id:"elementStats",style:{marginTop:12},children:q(ka,{label:q("h3",{children:g("stats.elementProperties")}),open:!!(r.stats.panels&im.elementProperties),openTrigger:()=>d(v=>({stats:{open:!0,panels:v.stats.panels^im.elementProperties}})),children:St(am,{children:[c&&St(af,{children:[u&&q(Se,{heading:!0,children:g("labels.unCroppedDimension")}),r.croppingElementId&&rf(c)&&f&&St(Se,{columns:2,children:[q("div",{children:g("stats.width")}),q("div",{children:w5(f.width,2)})]}),r.croppingElementId&&rf(c)&&f&&St(Se,{columns:2,children:[q("div",{children:g("stats.height")}),q("div",{children:w5(f.height,2)})]}),q(Se,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:r.croppingElementId?g("labels.imageCropping"):g(`element.${c.type}`)}),q(Se,{children:q(of,{element:c,property:"x",elementsMap:m,scene:l,appState:r})}),q(Se,{children:q(of,{element:c,property:"y",elementsMap:m,scene:l,appState:r})}),q(Se,{children:q($g,{property:"width",element:c,scene:l,appState:r})}),q(Se,{children:q($g,{property:"height",element:c,scene:l,appState:r})}),!wO(c)&&q(Se,{children:q(KT,{property:"angle",element:c,scene:l,appState:r})}),q(Se,{children:q(r5,{property:"fontSize",element:c,scene:l,appState:r})})]}),p&&St(af,{children:[TO(p)&&q(Se,{heading:!0,children:g("element.group")}),St(Se,{columns:2,style:{margin:"0.3125rem 0"},children:[q("div",{children:g("stats.shapes")}),q("div",{children:n.length})]}),q(Se,{children:q(tf,{property:"x",elements:p,elementsMap:m,atomicUnits:E,scene:l,appState:r})}),q(Se,{children:q(tf,{property:"y",elements:p,elementsMap:m,atomicUnits:E,scene:l,appState:r})}),q(Se,{children:q(Qg,{property:"width",elements:p,elementsMap:m,atomicUnits:E,scene:l,appState:r})}),q(Se,{children:q(Qg,{property:"height",elements:p,elementsMap:m,atomicUnits:E,scene:l,appState:r})}),q(Se,{children:q(c5,{property:"angle",elements:p,scene:l,appState:r})}),q(Se,{children:q(b5,{property:"fontSize",elements:p,scene:l,appState:r,elementsMap:m})})]})]})})})]})})},(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 SO,useEffect as T5,useState as I5}from"react";import{normalizeLink as kO,KEYS as lf}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as MO,getLinkIdAndTypeFromSelection as PO}from"@excalidraw/element";import{jsx as Xi,jsxs as lm}from"react/jsx-runtime";var LO=({sourceElementId:e,onClose:o,appState:t,scene:n,generateLinkForSelection:r=MO})=>{let i=n.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[l,s]=I5(a),[m,d]=I5(!1);T5(()=>{let p=j(i,t),u=a;if(p.length>0&&r){let f=PO(p,t);f&&(u=kO(r(f.id,f.type)))}s(u)},[i,t,t.selectedElementIds,a,r]);let c=SO(()=>{if(l&&l!==i.get(e)?.link){let p=i.get(e);p&&n.mutateElement(p,{link:l})}if(!l&&m&&e){let p=i.get(e);p&&n.mutateElement(p,{link:null})}o?.()},[e,l,i,m,n,o]);return T5(()=>{let p=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===lf.ENTER&&c(),t.openDialog?.name==="elementLinkSelector"&&u.key===lf.ESCAPE&&o?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[t,o,c]),lm("div",{className:"ElementLinkDialog",children:[lm("div",{className:"ElementLinkDialog__header",children:[Xi("h2",{children:g("elementLink.title")}),Xi("p",{children:g("elementLink.desc")})]}),lm("div",{className:"ElementLinkDialog__input",children:[Xi(Ci,{value:l??"",onChange:p=>{m||d(!0),s(p)},onKeyDown:p=>{p.key===lf.ENTER&&c()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&l&&Xi(Z,{type:"button",title:g("buttons.remove"),"aria-label":g("buttons.remove"),label:g("buttons.remove"),onClick:()=>{s(null),d(!0)},className:"ElementLinkDialog__remove",icon:Mt})]}),lm("div",{className:"ElementLinkDialog__actions",children:[Xi(Ho,{label:g("buttons.cancel"),onClick:()=>{o?.()},style:{marginRight:10}}),Xi(Ho,{label:g("buttons.confirm"),onClick:c,actionType:"primary"})]})]})},C5=LO;import AO,{useState as DO}from"react";import{Fragment as _O,jsx as sf}from"react/jsx-runtime";var S5=({children:e,onClose:o})=>{let[t,n]=DO(!!e),{container:r}=Ne(),i=AO.useCallback(()=>{n(!1),o&&o(),r?.focus()},[o,r]);return sf(_O,{children:t&&sf(Oe,{size:"small",onCloseRequest:i,title:g("errorDialog.title"),children:sf("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import RO from"react";import{isDarwin as k5,isFirefox as M5,isWindows as NO}from"@excalidraw/common";import{KEYS as De,getShortcutKey as K}from"@excalidraw/common";import{Fragment as L5,jsx as z,jsxs as Ft}from"react/jsx-runtime";var BO=()=>Ft("div",{className:"HelpDialog__header",children:[Ft("a",{className:"HelpDialog__btn",href:"https://docs.excalidraw.com",target:"_blank",rel:"noopener",children:[z("div",{className:"HelpDialog__link-icon",children:Gm}),g("helpDialog.documentation")]}),Ft("a",{className:"HelpDialog__btn",href:"https://plus.excalidraw.com/blog",target:"_blank",rel:"noopener",children:[z("div",{className:"HelpDialog__link-icon",children:Gm}),g("helpDialog.blog")]}),Ft("a",{className:"HelpDialog__btn",href:"https://github.com/excalidraw/excalidraw/issues",target:"_blank",rel:"noopener noreferrer",children:[z("div",{className:"HelpDialog__link-icon",children:as}),g("helpDialog.github")]}),Ft("a",{className:"HelpDialog__btn",href:"https://youtube.com/@excalidraw",target:"_blank",rel:"noopener noreferrer",children:[z("div",{className:"HelpDialog__link-icon",children:Cb}),"YouTube"]})]}),FO=e=>Ft(L5,{children:[z("h3",{children:e.title}),z("div",{className:"HelpDialog__islands-container",children:e.children})]}),cf=e=>Ft("div",{className:`HelpDialog__island ${e.className}`,children:[z("h4",{className:"HelpDialog__island-title",children:e.caption}),z("div",{className:"HelpDialog__island-content",children:e.children})]});function*OO(e,o){let t=!0;for(let n of e)t||(yield o),t=!1,yield n}var zO=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),U=({label:e,shortcuts:o,isOr:t=!0})=>{let n=o.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>z(HO,{children:zO(a)},a)));return Ft("div",{className:"HelpDialog__shortcut",children:[z("div",{children:e}),z("div",{className:"HelpDialog__key-container",children:[...OO(n,t?g("helpDialog.or"):null)]})]})},HO=e=>z("kbd",{className:"HelpDialog__key",...e}),P5=({onClose:e})=>{let o=RO.useCallback(()=>{e&&e()},[e]);return z(L5,{children:Ft(Oe,{onCloseRequest:o,title:g("helpDialog.title"),className:"HelpDialog",children:[z(BO,{}),Ft(FO,{title:g("helpDialog.shortcuts"),children:[Ft(cf,{className:"HelpDialog__island--tools",caption:g("helpDialog.tools"),children:[z(U,{label:g("toolBar.hand"),shortcuts:[De.H]}),z(U,{label:g("toolBar.selection"),shortcuts:[De.V,De[1]]}),z(U,{label:g("toolBar.rectangle"),shortcuts:[De.R,De[2]]}),z(U,{label:g("toolBar.diamond"),shortcuts:[De.D,De[3]]}),z(U,{label:g("toolBar.ellipse"),shortcuts:[De.O,De[4]]}),z(U,{label:g("toolBar.arrow"),shortcuts:[De.A,De[5]]}),z(U,{label:g("toolBar.line"),shortcuts:[De.L,De[6]]}),z(U,{label:g("toolBar.freedraw"),shortcuts:[De.P,De[7]]}),z(U,{label:g("toolBar.text"),shortcuts:[De.T,De[8]]}),z(U,{label:g("toolBar.image"),shortcuts:[De[9]]}),z(U,{label:g("toolBar.eraser"),shortcuts:[De.E,De[0]]}),z(U,{label:g("toolBar.frame"),shortcuts:[De.F]}),z(U,{label:g("toolBar.laser"),shortcuts:[De.K]}),z(U,{label:g("labels.eyeDropper"),shortcuts:[De.I,"Shift+S","Shift+G"]}),z(U,{label:g("helpDialog.editLineArrowPoints"),shortcuts:[K("CtrlOrCmd+Enter")]}),z(U,{label:g("helpDialog.editText"),shortcuts:[K("Enter")]}),z(U,{label:g("helpDialog.textNewLine"),shortcuts:[K("Enter"),K("Shift+Enter")]}),z(U,{label:g("helpDialog.textFinish"),shortcuts:[K("Esc"),K("CtrlOrCmd+Enter")]}),z(U,{label:g("helpDialog.curvedArrow"),shortcuts:["A",g("helpDialog.click"),g("helpDialog.click"),g("helpDialog.click")],isOr:!1}),z(U,{label:g("helpDialog.curvedLine"),shortcuts:["L",g("helpDialog.click"),g("helpDialog.click"),g("helpDialog.click")],isOr:!1}),z(U,{label:g("helpDialog.cropStart"),shortcuts:[g("helpDialog.doubleClick"),K("Enter")],isOr:!0}),z(U,{label:g("helpDialog.cropFinish"),shortcuts:[K("Enter"),K("Escape")],isOr:!0}),z(U,{label:g("toolBar.lock"),shortcuts:[De.Q]}),z(U,{label:g("helpDialog.preventBinding"),shortcuts:[K("CtrlOrCmd")]}),z(U,{label:g("toolBar.link"),shortcuts:[K("CtrlOrCmd+K")]}),z(U,{label:g("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),Ft(cf,{className:"HelpDialog__island--view",caption:g("helpDialog.view"),children:[z(U,{label:g("buttons.zoomIn"),shortcuts:[K("CtrlOrCmd++")]}),z(U,{label:g("buttons.zoomOut"),shortcuts:[K("CtrlOrCmd+-")]}),z(U,{label:g("buttons.resetZoom"),shortcuts:[K("CtrlOrCmd+0")]}),z(U,{label:g("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),z(U,{label:g("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),z(U,{label:g("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),z(U,{label:g("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),z(U,{label:g("buttons.zenMode"),shortcuts:[K("Alt+Z")]}),z(U,{label:g("buttons.objectsSnapMode"),shortcuts:[K("Alt+S")]}),z(U,{label:g("labels.toggleGrid"),shortcuts:[K("CtrlOrCmd+'")]}),z(U,{label:g("labels.viewMode"),shortcuts:[K("Alt+R")]}),z(U,{label:g("labels.toggleTheme"),shortcuts:[K("Alt+Shift+D")]}),z(U,{label:g("stats.fullTitle"),shortcuts:[K("Alt+/")]}),z(U,{label:g("search.title"),shortcuts:[Fe("searchMenu")]}),z(U,{label:g("commandPalette.title"),shortcuts:M5?[Fe("commandPalette")]:[Fe("commandPalette"),Fe("commandPalette",1)]})]}),Ft(cf,{className:"HelpDialog__island--editor",caption:g("helpDialog.editor"),children:[z(U,{label:g("helpDialog.createFlowchart"),shortcuts:[K("CtrlOrCmd+Arrow Key")],isOr:!0}),z(U,{label:g("helpDialog.navigateFlowchart"),shortcuts:[K("Alt+Arrow Key")],isOr:!0}),z(U,{label:g("labels.moveCanvas"),shortcuts:[K(`Space+${g("helpDialog.drag")}`),K(`Wheel+${g("helpDialog.drag")}`)],isOr:!0}),z(U,{label:g("buttons.clearReset"),shortcuts:[K("CtrlOrCmd+Delete")]}),z(U,{label:g("labels.delete"),shortcuts:[K("Delete")]}),z(U,{label:g("labels.cut"),shortcuts:[K("CtrlOrCmd+X")]}),z(U,{label:g("labels.copy"),shortcuts:[K("CtrlOrCmd+C")]}),z(U,{label:g("labels.paste"),shortcuts:[K("CtrlOrCmd+V")]}),z(U,{label:g("labels.pasteAsPlaintext"),shortcuts:[K("CtrlOrCmd+Shift+V")]}),z(U,{label:g("labels.selectAll"),shortcuts:[K("CtrlOrCmd+A")]}),z(U,{label:g("labels.multiSelect"),shortcuts:[K(`Shift+${g("helpDialog.click")}`)]}),z(U,{label:g("helpDialog.deepSelect"),shortcuts:[K(`CtrlOrCmd+${g("helpDialog.click")}`)]}),z(U,{label:g("helpDialog.deepBoxSelect"),shortcuts:[K(`CtrlOrCmd+${g("helpDialog.drag")}`)]}),(oi||M5)&&z(U,{label:g("labels.copyAsPng"),shortcuts:[K("Shift+Alt+C")]}),z(U,{label:g("labels.copyStyles"),shortcuts:[K("CtrlOrCmd+Alt+C")]}),z(U,{label:g("labels.pasteStyles"),shortcuts:[K("CtrlOrCmd+Alt+V")]}),z(U,{label:g("labels.sendToBack"),shortcuts:[k5?K("CtrlOrCmd+Alt+["):K("CtrlOrCmd+Shift+[")]}),z(U,{label:g("labels.bringToFront"),shortcuts:[k5?K("CtrlOrCmd+Alt+]"):K("CtrlOrCmd+Shift+]")]}),z(U,{label:g("labels.sendBackward"),shortcuts:[K("CtrlOrCmd+[")]}),z(U,{label:g("labels.bringForward"),shortcuts:[K("CtrlOrCmd+]")]}),z(U,{label:g("labels.alignTop"),shortcuts:[K("CtrlOrCmd+Shift+Up")]}),z(U,{label:g("labels.alignBottom"),shortcuts:[K("CtrlOrCmd+Shift+Down")]}),z(U,{label:g("labels.alignLeft"),shortcuts:[K("CtrlOrCmd+Shift+Left")]}),z(U,{label:g("labels.alignRight"),shortcuts:[K("CtrlOrCmd+Shift+Right")]}),z(U,{label:g("labels.duplicateSelection"),shortcuts:[K("CtrlOrCmd+D"),K(`Alt+${g("helpDialog.drag")}`)]}),z(U,{label:g("helpDialog.toggleElementLock"),shortcuts:[K("CtrlOrCmd+Shift+L")]}),z(U,{label:g("buttons.undo"),shortcuts:[K("CtrlOrCmd+Z")]}),z(U,{label:g("buttons.redo"),shortcuts:NO?[K("CtrlOrCmd+Y"),K("CtrlOrCmd+Shift+Z")]:[K("CtrlOrCmd+Shift+Z")]}),z(U,{label:g("labels.group"),shortcuts:[K("CtrlOrCmd+G")]}),z(U,{label:g("labels.ungroup"),shortcuts:[K("CtrlOrCmd+Shift+G")]}),z(U,{label:g("labels.flipHorizontal"),shortcuts:[K("Shift+H")]}),z(U,{label:g("labels.flipVertical"),shortcuts:[K("Shift+V")]}),z(U,{label:g("labels.showStroke"),shortcuts:[K("S")]}),z(U,{label:g("labels.showBackground"),shortcuts:[K("G")]}),z(U,{label:g("labels.showFonts"),shortcuts:[K("Shift+F")]}),z(U,{label:g("labels.decreaseFontSize"),shortcuts:[K("CtrlOrCmd+Shift+<")]}),z(U,{label:g("labels.increaseFontSize"),shortcuts:[K("CtrlOrCmd+Shift+>")]})]})]})]})})};import{useEffect as _5,useRef as XO,useState as Dn}from"react";import{DEFAULT_EXPORT_PADDING as KO,EXPORT_IMAGE_TYPES as df,isFirefox as ZO,EXPORT_SCALES as $O,cloneJSON as R5}from"@excalidraw/common";import{useCallback as GO,useRef as UO,useState as YO}from"react";var WO=2e3,A5=()=>{let[e,o]=YO(null),t=UO(0),n=()=>{clearTimeout(t.current),o("success"),t.current=window.setTimeout(()=>{o(null)},WO)},r=GO(()=>{o(null)},[]);return{copyStatus:e,resetCopyStatus:r,onCopy:n}};import VO from"clsx";import{jsx as D5}from"react/jsx-runtime";var Tl=({title:e,name:o,checked:t,onChange:n,disabled:r=!1})=>D5("div",{className:VO("Switch",{toggled:t,disabled:r}),children:D5("input",{name:o,id:o,title:e,type:"checkbox",checked:t,disabled:r,onChange:()=>n(!t),onKeyDown:i=>{i.key===" "&&n(!t)}})});import{jsx as ke,jsxs as _n}from"react/jsx-runtime";var jO="filter"in document.createElement("canvas").getContext("2d"),qO=()=>_n("div",{children:[ke("h3",{children:g("canvasError.cannotShowPreview")}),ke("p",{children:ke("span",{children:g("canvasError.canvasTooBig")})}),_n("em",{children:["(",g("canvasError.canvasTooBigTip"),")"]})]}),JO=({appStateSnapshot:e,elementsSnapshot:o,files:t,actionManager:n,onExportImage:r,name:i})=>{let a=we(o,e),[l,s]=Dn(i),[m,d]=Dn(a),[c,p]=Dn(e.exportBackground),[u,f]=Dn(e.exportWithDarkMode),[b,x]=Dn(e.exportEmbedScene),[y,E]=Dn(e.exportScale),w=XO(null),[v,C]=Dn(null),{onCopy:S,copyStatus:L,resetCopyStatus:P}=A5();_5(()=>{P()},[l,c,u,y,b,P]);let{exportedElements:B,exportingFrame:k}=er(o,e,m);return _5(()=>{let A=w.current;if(!A)return;let F=A.offsetWidth,Y=A.offsetHeight;F&&gn({elements:B,appState:{...e,name:l,exportBackground:c,exportWithDarkMode:u,exportScale:y,exportEmbedScene:b},files:t,exportPadding:KO,maxWidthOrHeight:Math.max(F,Y),exportingFrame:k}).then(Q=>(C(null),Ao(Q).then(()=>{A.replaceChildren(Q)}).catch(_=>{throw _.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):_}))).catch(Q=>{console.error(Q),C(Q)})},[e,t,B,k,l,c,u,y,b]),_n("div",{className:"ImageExportModal",children:[ke("h3",{children:g("imageExportDialog.header")}),_n("div",{className:"ImageExportModal__preview",children:[ke("div",{className:"ImageExportModal__preview__canvas",ref:w,children:v&&ke(qO,{})}),ke("div",{className:"ImageExportModal__preview__filename",children:!Ir&&ke("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:A=>{s(A.target.value),n.executeAction(su,"ui",A.target.value)}})})]}),_n("div",{className:"ImageExportModal__settings",children:[ke("h3",{children:g("imageExportDialog.header")}),a&&ke(Il,{label:g("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:ke(Tl,{name:"exportOnlySelected",checked:m,onChange:A=>{d(A)}})}),ke(Il,{label:g("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:ke(Tl,{name:"exportBackgroundSwitch",checked:c,onChange:A=>{p(A),n.executeAction(cu,"ui",A)}})}),jO&&ke(Il,{label:g("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:ke(Tl,{name:"exportDarkModeSwitch",checked:u,onChange:A=>{f(A),n.executeAction(TE,"ui",A)}})}),ke(Il,{label:g("imageExportDialog.label.embedScene"),tooltip:g("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:ke(Tl,{name:"exportEmbedSwitch",checked:b,onChange:A=>{x(A),n.executeAction(rc,"ui",A)}})}),ke(Il,{label:g("imageExportDialog.label.scale"),name:"exportScale",children:ke(Rd,{name:"exportScale",value:y,onChange:A=>{E(A),n.executeAction(vE,"ui",A)},choices:$O.map(A=>({value:A,label:`${A}\xD7`}))})}),_n("div",{className:"ImageExportModal__settings__buttons",children:[ke(Sn,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToPng"),onClick:()=>r(df.png,B,{exportingFrame:k}),icon:np,children:g("imageExportDialog.button.exportToPng")}),ke(Sn,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToSvg"),onClick:()=>r(df.svg,B,{exportingFrame:k}),icon:np,children:g("imageExportDialog.button.exportToSvg")}),(oi||ZO)&&ke(Sn,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.copyPngToClipboard"),status:L,onClick:async()=>{await r(df.clipboard,B,{exportingFrame:k}),S()},icon:Rr,children:g("imageExportDialog.button.copyPngToClipboard")})]})]})]})},Il=({label:e,children:o,tooltip:t,name:n})=>_n("div",{className:"ImageExportModal__settings__setting",title:e,children:[_n("label",{htmlFor:n,className:"ImageExportModal__settings__setting__label",children:[e,t&&ke(At,{label:t,long:!0,children:rb})]}),ke("div",{className:"ImageExportModal__settings__setting__content",children:o})]}),N5=({elements:e,appState:o,files:t,actionManager:n,onExportImage:r,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:l,elementsSnapshot:s}]=Dn(()=>({appStateSnapshot:R5(o),elementsSnapshot:R5(e)}));return ke(Oe,{onCloseRequest:i,size:"wide",title:!1,children:ke(JO,{elementsSnapshot:s,appStateSnapshot:l,files:t,actionManager:n,onExportImage:r,name:a})})};import ez from"react";import{getFrame as tz}from"@excalidraw/common";import mf from"open-color";import{jsx as QO}from"react/jsx-runtime";var pf=({children:e,color:o})=>QO("div",{className:"Card",style:{"--card-color":o==="primary"?"var(--color-primary)":mf[o][7],"--card-color-darker":o==="primary"?"var(--color-primary-darker)":mf[o][8],"--card-color-darkest":o==="primary"?"var(--color-primary-darkest)":mf[o][9]},children:e});import{Fragment as nz,jsx as mo,jsxs as sm}from"react/jsx-runtime";var oz=({elements:e,appState:o,setAppState:t,files:n,actionManager:r,exportOpts:i,canvas:a,onCloseRequest:l})=>{let{onExportToBackend:s}=i;return mo("div",{className:"ExportDialog ExportDialog--json",children:sm("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&sm(pf,{color:"lime",children:[mo("div",{className:"Card-icon",children:p0}),mo("h2",{children:g("exportDialog.disk_title")}),sm("div",{className:"Card-details",children:[g("exportDialog.disk_details"),!Ir&&r.renderAction("changeProjectName")]}),mo(Z,{className:"Card-button",type:"button",title:g("exportDialog.disk_button"),"aria-label":g("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{r.executeAction(za,"ui")}})]}),s&&sm(pf,{color:"pink",children:[mo("div",{className:"Card-icon",children:da}),mo("h2",{children:g("exportDialog.link_title")}),mo("div",{className:"Card-details",children:g("exportDialog.link_details")}),mo(Z,{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 (${tz()})`),await s(e,o,n),l()}catch(m){t({errorMessage:m.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,o,n,a)]})})},B5=({elements:e,appState:o,files:t,actionManager:n,exportOpts:r,canvas:i,setAppState:a})=>{let l=ez.useCallback(()=>{a({openDialog:null})},[a]);return mo(nz,{children:o.openDialog?.name==="jsonExport"&&mo(Oe,{onCloseRequest:l,title:g("buttons.export"),children:mo(oz,{elements:e,appState:o,setAppState:a,files:t,actionManager:n,onCloseRequest:l,exportOpts:r,canvas:i})})})};import rz from"clsx";import{jsx as F5,jsxs as az}from"react/jsx-runtime";var iz="small",O5=e=>az("label",{className:rz("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${iz}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[F5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),F5("div",{className:"ToolIcon__icon",children:pa})]});import{Fragment as G5,jsx as $,jsxs as Ot}from"react/jsx-runtime";var gz=({UIOptions:e})=>Ot(mt,{__fallback:!0,children:[$(mt.DefaultItems.LoadScene,{}),$(mt.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&$(mt.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&$(mt.DefaultItems.SaveAsImage,{}),$(mt.DefaultItems.SearchMenu,{}),$(mt.DefaultItems.Help,{}),$(mt.DefaultItems.ClearCanvas,{}),$(mt.Separator,{}),$(mt.Group,{title:"Excalidraw links",children:$(mt.DefaultItems.Socials,{})}),$(mt.Separator,{}),$(mt.DefaultItems.ToggleTheme,{}),$(mt.DefaultItems.ChangeCanvasBackground,{})]}),fz=()=>Ot(Od,{__fallback:!0,children:[$(Od.Actions.SaveToDisk,{}),$(Od.Actions.ExportToImage,{})]}),bz=({actionManager:e,appState:o,files:t,setAppState:n,elements:r,canvas:i,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,showExitZenModeBtn:m,renderTopRightUI:d,renderCustomStats:c,UIOptions:p,onExportImage:u,renderWelcomeScreen:f,children:b,app:x,isCollaborating:y,generateLinkForSelection:E})=>{let w=de(),v=B2(),C=o.stylesPanelMode==="compact"?{menuTopGap:4,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:.5,islandPadding:1,collabMarginLeft:8}:{menuTopGap:6,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:1,islandPadding:1,collabMarginLeft:8},S=v.tunnelsJotai.Provider,[L,P]=le(rn),B=()=>p.canvasActions.export?$(B5,{elements:r,appState:o,files:t,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:n}):null,k=()=>!p.canvasActions.saveAsImage||o.openDialog?.name!=="imageExport"?null:$(N5,{elements:r,appState:o,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>n({openDialog:null}),name:x.getName()}),A=()=>Ot("div",{style:{position:"relative"},children:[$(v.MainMenuTunnel.Out,{}),f&&$(v.WelcomeScreenMenuHintTunnel.Out,{})]}),F=()=>{let W=o.stylesPanelMode==="compact";return $(Tn,{heading:"selectedShapeActions",className:ur("selected-shape-actions zen-mode-transition",{"transition-left":o.zenModeEnabled}),children:W?$(Ye,{className:ur("compact-shape-actions-island"),padding:0,style:{maxHeight:`${o.height-166}px`},children:$(X2,{appState:o,elementsMap:x.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:x,setAppState:n})}):$(Ye,{className:sz.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${o.height-166}px`},children:$(Zc,{appState:o,elementsMap:x.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:x})})})},Y=()=>{let W=uz(o,r),X=o.stats.open&&!o.zenModeEnabled&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector";return $(Sd,{side:"top",children:Ot("div",{className:"App-menu App-menu_top",children:[Ot(qe.Col,{gap:C.menuTopGap,className:ur("App-menu_top__left"),children:[A(),$("div",{className:ur("selected-shape-actions-container",{"selected-shape-actions-container--compact":o.stylesPanelMode==="compact"}),children:W&&F()})]}),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&$(Tn,{heading:"shapes",className:"shapes-section",children:G=>Ot("div",{style:{position:"relative"},children:[f&&$(v.WelcomeScreenToolbarHintTunnel.Out,{}),$(qe.Col,{gap:C.toolbarColGap,align:"start",children:Ot(qe.Row,{gap:C.toolbarRowGap,className:ur("App-toolbar-container",{"zen-mode":o.zenModeEnabled}),children:[Ot(Ye,{padding:C.islandPadding,className:ur("App-toolbar",{"zen-mode":o.zenModeEnabled,"App-toolbar--compact":o.stylesPanelMode==="compact"}),children:[$(Md,{appState:o,isMobile:w.editor.isMobile,device:w,app:x}),G,Ot(qe.Row,{gap:C.toolbarInnerRowGap,children:[$(Pd,{zenModeEnabled:o.zenModeEnabled,checked:o.penMode,onChange:()=>s(null),title:g("toolBar.penMode"),penDetected:o.penDetected}),$(Cd,{checked:o.activeTool.locked,onChange:a,title:g("toolBar.lock")}),$("div",{className:"App-toolbar__divider"}),$(kd,{checked:Qt(o),onChange:()=>l(),title:g("toolBar.hand"),isMobile:!0}),$($c,{appState:o,activeTool:o.activeTool,UIOptions:p,app:x})]})]}),y&&$(Ye,{style:{marginLeft:C.collabMarginLeft,alignSelf:"center",height:"fit-content"},children:$(O5,{title:g("toolBar.laser"),checked:o.activeTool.type===z5.laser,onChange:()=>x.setActiveTool({type:z5.laser}),isMobile:!0})})]})})]})}),Ot("div",{className:ur("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":o.zenModeEnabled,"layer-ui__wrapper__top-right--compact":o.stylesPanelMode==="compact"}),children:[o.collaborators.size>0&&$(Dd,{collaborators:o.collaborators,userToFollow:o.userToFollow?.socketId||null}),d?.(w.editor.isMobile,o),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&(!_||o.openSidebar?.name!==uf.name)&&$(v.DefaultSidebarTriggerTunnel.Out,{}),X&&$(vl,{app:x,onClose:()=>{e.executeAction(pi)},renderCustomStats:c})]})]})})},Q=()=>$(Gd,{__fallback:!0,onDock:W=>{re("sidebar",`toggleDock (${W?"dock":"undock"})`,`(${w.editor.isMobile?"mobile":"desktop"})`)}}),_=ql(gl),R=Ot(G5,{children:[b,$(gz,{UIOptions:p}),$(Gd.Trigger,{__fallback:!0,icon:Pr,title:mz(g("toolBar.library")),onToggle:W=>{W&&re("sidebar",`${uf.name} (open)`,`button (${w.editor.isMobile?"mobile":"desktop"})`)},tab:uf.defaultTab,children:o.stylesPanelMode==="full"&&o.width>=cz&&g("toolBar.library")}),$(fz,{}),o.openDialog?.name==="ttd"&&$(Yg,{__fallback:!0}),o.isLoading&&$(Id,{delay:250}),o.errorMessage&&$(S5,{onClose:()=>n({errorMessage:null}),children:o.errorMessage}),L&&!w.editor.isMobile&&$(Xb,{colorPickerType:L.colorPickerType,onCancel:()=>{P(null)},onChange:(W,X,G,{altKey:me})=>{if(!(W!=="elementBackground"&&W!=="elementStroke"))if(G.length){for(let ue of G)pz(ue,dz(r),{[me&&L.swapPreviewOnAlt?W==="elementBackground"?"strokeColor":"backgroundColor":W==="elementBackground"?"backgroundColor":"strokeColor"]:X}),hz.delete(ue);x.scene.triggerUpdate()}else n(W==="elementBackground"?{currentItemBackgroundColor:X}:{currentItemStrokeColor:X})},onSelect:(W,X)=>{P(G=>G?.keepOpenOnAlt&&X.altKey?G:null),L?.onSelect?.(W,X)}}),o.openDialog?.name==="help"&&$(P5,{onClose:()=>{n({openDialog:null})}}),$(j2,{}),o.openDialog?.name==="elementLinkSelector"&&$(C5,{sourceElementId:o.openDialog.sourceElementId,onClose:()=>{n({openDialog:null})},scene:x.scene,appState:o,generateLinkForSelection:E}),$(v.OverwriteConfirmDialogTunnel.Out,{}),k(),B(),o.pasteDialog.shown&&$(x3,{setAppState:n,appState:o,onClose:()=>n({pasteDialog:{shown:!1,data:null}})}),w.editor.isMobile&&$(f3,{app:x,appState:o,elements:r,actionManager:e,renderJSONExportDialog:B,renderImageExportDialog:k,setAppState:n,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,renderTopRightUI:d,renderCustomStats:c,renderSidebars:Q,device:w,renderWelcomeScreen:f,UIOptions:p}),!w.editor.isMobile&&Ot(G5,{children:[Ot("div",{className:"layer-ui__wrapper",style:o.openSidebar&&_&&w.editor.canFitSidebar?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[f&&$(v.WelcomeScreenCenterTunnel.Out,{}),Y(),$(v3,{appState:o,actionManager:e,showExitZenModeBtn:m,renderWelcomeScreen:f}),o.scrolledOutside&&$("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{n(W=>({...Gn(r,W)}))},children:g("buttons.scrollBackToContent")})]}),Q()]})]});return $(xp.Provider,{value:o,children:$(S,{children:$(bh.Provider,{value:v,children:R})})})},H5=e=>{let{suggestedBindings:o,startBoundElement:t,cursorButton:n,scrollX:r,scrollY:i,...a}=e;return a},xz=(e,o)=>{if(e.children!==o.children)return!1;let{canvas:t,appState:n,...r}=e,{canvas:i,appState:a,...l}=o;return cm(H5(n),H5(a),{selectedElementIds:cm,selectedGroupIds:cm})&&cm(r,l)},U5=lz.memo(bz,xz);import Ez from"clsx";import{jsx as Y5,jsxs as wz}from"react/jsx-runtime";var yz="small",dm=e=>wz("label",{className:Ez("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${yz}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[Y5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),Y5("div",{className:"ToolIcon__icon",children:e.icon})]});import{useEffect as vz,useRef as Tz}from"react";import{jsx as W5}from"react/jsx-runtime";var V5=({trails:e})=>{let o=Tz(null);return vz(()=>{if(o.current)for(let t of e)t.start(o.current);return()=>{for(let t of e)t.stop()}},e),W5("div",{className:"SVGLayer",children:W5("svg",{ref:o})})};import Iz,{useEffect as Cz,useRef as Sz}from"react";import{CURSOR_TYPE as X5,isShallowEqual as kz,sceneCoordsToViewportCoords as Mz}from"@excalidraw/common";import{jsx as Az}from"react/jsx-runtime";var Pz=e=>{let o=Sz(!1);return Cz(()=>{if(!o.current){o.current=!0;return}let t=new Map,n=new Map,r=new Map,i=new Map,a=new Map;e.appState.collaborators.forEach((s,m)=>{if(s.selectedElementIds)for(let d of Object.keys(s.selectedElementIds))r.has(d)||r.set(d,[]),r.get(d).push(m);!s.pointer||s.pointer.renderCursor===!1||(s.username&&i.set(m,s.username),s.userState&&a.set(m,s.userState),n.set(m,Mz({sceneX:s.pointer.x,sceneY:s.pointer.y},e.appState)),t.set(m,s.button))});let l=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";Sv({canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:n,remotePointerButton:t,remoteSelectedElementIds:r,remotePointerUsernames:i,remotePointerUserStates:a,selectionColor:l,renderScrollbars:e.renderScrollbars},device:e.device,callback:e.renderInteractiveSceneCallback},Bi())}),Az("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?X5.GRAB:X5.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")})},K5=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}),Lz=(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:kz(K5(e.appState),K5(o.appState)),hf=Iz.memo(Pz,Lz);import Dz,{useEffect as Z5,useRef as $5}from"react";import{isShallowEqual as j5}from"@excalidraw/common";import{jsx as Nz}from"react/jsx-runtime";var _z=e=>{let o=$5(null),t=$5(!1);return Z5(()=>{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]),Z5(()=>{let n=o.current;if(!n)return;let r=e.canvas;t.current||(t.current=!0,n.replaceChildren(r),r.classList.add("excalidraw__canvas","static")),S1({canvas:r,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},Bi())}),Nz("div",{className:"excalidraw__canvas-wrapper",ref:o})},q5=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}),Rz=(e,o)=>e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements?!1:j5(q5(e.appState),q5(o.appState))&&j5(e.renderConfig,o.renderConfig),gf=Dz.memo(_z,Rz);import{useEffect as Uz,useRef as Yz}from"react";import{throttleRAF as Bz}from"@excalidraw/common";import{getTargetFrame as Fz,isInvisiblySmallElement as Oz,renderElement as zz,shouldApplyFrameClip as Hz}from"@excalidraw/element";var J5=({canvas:e,rc:o,newElement:t,elementsMap:n,allElementsMap:r,scale:i,appState:a,renderConfig:l})=>{if(e){let[s,m]=Vl(e,i),d=Xl({canvas:e,scale:i,normalizedWidth:s,normalizedHeight:m});if(d.save(),d.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"){if(Oz(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let p=Fz(t,n,a);p&&Hz(t,p,a,n)&&I1(p,d,l,a)}zz(t,n,r,o,d,l,a)}else d.clearRect(0,0,s,m);d.restore()}},Gz=Bz(e=>{J5(e)},{trailing:!0}),Q5=(e,o)=>{if(o){Gz(e);return}J5(e)};import{jsx as Vz}from"react/jsx-runtime";var Wz=e=>{let o=Yz(null);return Uz(()=>{o.current&&Q5({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},Bi())}),Vz("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})},eI=Wz;import{useCallback as Xz,useEffect as Kz,useRef as Zz}from"react";import{jsx as tI,jsxs as jz}from"react/jsx-runtime";var $z=5e3,oI=({message:e,onClose:o,closable:t=!1,duration:n=$z,style:r})=>{let i=Zz(0),a=n!==1/0,l=Xz(()=>{a&&(i.current=window.setTimeout(()=>o(),n))},[o,n,a]);return Kz(()=>{if(a)return l(),()=>clearTimeout(i.current)},[l,e,n,a]),jz("div",{className:"Toast",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?l:void 0,style:r,children:[tI("p",{className:"Toast__message",children:e}),t&&tI(Z,{icon:zt,"aria-label":"close",type:"icon",onClick:o,className:"close"})]})};import{getCommonBounds as qz,getElementsInGroup as Jz,selectGroupsFromGivenElements as Qz}from"@excalidraw/element";import{sceneCoordsToViewportCoords as eH}from"@excalidraw/common";import{flushSync as tH}from"react-dom";import{jsx as nH}from"react/jsx-runtime";var oH=({app:e,activeLockedId:o})=>{let t=e.scene.getElement(o),n=t?[t]:Jz(e.scene.getNonDeletedElementsMap(),o);if(n.length===0)return null;let[r,i]=qz(n),{x:a,y:l}=eH({sceneX:r,sceneY:i},e.state);return nH("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${a-e.state.offsetLeft}px`},onClick:()=>{tH(()=>{let s=Qz(n,e.state);e.setState({selectedElementIds:n.reduce((m,d)=>({...m,[d.id]:!0}),{}),selectedGroupIds:s,activeLockedId:null})}),e.actionManager.executeAction(Wa)},title:g("labels.elementLock.unlock"),children:Z1})},nI=oH;import{Fragment as eU,jsx as fe,jsxs as Em}from"react/jsx-runtime";var rC=Lo.createContext(null),iC=Lo.createContext(null),aC={viewport:{isMobile:!1,isLandscape:!1},editor:{isMobile:!1,canFitSidebar:!1},isTouchScreen:!1},Zf=Lo.createContext(aC);Zf.displayName="DeviceContext";var $f=Lo.createContext({container:null,id:null});$f.displayName="ExcalidrawContainerContext";var jf=Lo.createContext([]);jf.displayName="ExcalidrawElementsContext";var qf=Lo.createContext({...Qo(),width:0,height:0,offsetLeft:0,offsetTop:0});qf.displayName="ExcalidrawAppStateContext";var Jf=Lo.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});Jf.displayName="ExcalidrawSetAppStateContext";var Qf=Lo.createContext(null);Qf.displayName="ExcalidrawActionManagerContext";var Be=()=>zn(rC),xo=()=>zn(iC),de=()=>zn(Zf),Ne=()=>zn($f),an=()=>zn(jf),bo=()=>zn(qf),ae=()=>zn(Jf),We=()=>zn(Qf),Dl=!1,Uf=0,_l=null,Er=!1,Rl=!1,Yf=!1,Nl={horizontal:null,vertical:null},On=0,Bl=!1,Wf=new Map,Vf=!1,eC=0,tC=!1,Fl=null,ge={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},Kf=class e extends Lo.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",aC);I(this,"excalidrawContainerRef",Lo.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 kG);I(this,"flowChartNavigator",new MG);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 dd);I(this,"laserTrails",new Ed(this.animationFrameHandler,this));I(this,"eraserTrail",new Td(this.animationFrameHandler,this));I(this,"lassoTrail",new vd(this.animationFrameHandler,this));I(this,"onChangeEmitter",new gr);I(this,"onPointerDownEmitter",new gr);I(this,"onPointerUpEmitter",new gr);I(this,"onUserFollowEmitter",new gr);I(this,"onScrollChangeEmitter",new gr);I(this,"missingPointerEventCleanupEmitter",new gr);I(this,"onRemoveEventListenersEmitter",new gr);I(this,"defaultSelectionTool","selection");I(this,"updateEditorAtom",(t,...n)=>{let r=Ue.set(t,...n);return this.triggerRender(),r});I(this,"getEffectiveGridSize",()=>yn(this)?this.state.gridSize:null);I(this,"updateEmbedValidationStatus",(t,n)=>{this.embedsValidationStatus.set(t.id,n),Al.delete(t)});I(this,"updateEmbeddables",()=>{let t=new Set,n=!1;this.scene.getNonDeletedElements().filter(r=>{if(jo(r)){if(t.add(r.id),!this.embedsValidationStatus.has(r.id)){n=!0;let i=Rf(r.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(r,i)}}else qi(r)&&t.add(r.id);return!1}),n&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((r,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});I(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);I(this,"frameNameBoundsCache",{get:t=>{let n=this.frameNameBoundsCache._cache.get(t.id);if(!n||n.zoom!==this.state.zoom.value||n.versionNonce!==t.versionNonce){let r=document.getElementById(this.getFrameNameDOMId(t));if(r){let i=r.getBoundingClientRect(),a=He({clientX:i.x,clientY:i.y},this.state),l=He({clientX:i.right,clientY:i.bottom},this.state);return n={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,n),n}return null}return n},_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===um.DARK,n=this.scene.getNonDeletedFramesLikes(),r=n.length>0&&this.state.searchMatches?.focusedId&&kt(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return n.map(i=>{if(!_I(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}=gm({sceneX:i.x,sceneY:i.y},this.state),s=6,m,d=wG(i);if(i.id===this.state.editingFrame){let c=d;m=fe("input",{autoFocus:!0,value:c,onChange:p=>{this.scene.mutateElement(i,{name:p.target.value})},onFocus:p=>p.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:p=>{(p.key===V.ESCAPE||p.key===V.ENTER)&&this.resetEditingFrame(i)},style:{background:this.state.viewBackgroundColor,filter:t?yH:"none",zIndex:2,border:"none",display:"block",padding:`${s}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${Nn.nameFontSize}px`,transform:`translate(-${s}px, ${s}px)`,color:"var(--color-gray-80)",overflow:"hidden",maxWidth:`${document.body.clientWidth-a-s}px`},size:c.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else m=d;return fe("div",{id:this.getFrameNameDOMId(i),style:{position:"absolute",bottom:`${this.state.height+Nn.nameOffsetY-l+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:Nn.nameFontSize,color:t?Nn.nameColorDarkTheme:Nn.nameColorLightTheme,lineHeight:Nn.nameLineHeight,width:"max-content",maxWidth:r?.id===i.id&&r?.focus?"none":`${i.width*this.state.zoom.value}px`,overflow:i.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:_e.MOVE,pointerEvents:this.state.viewModeEnabled?Zi.disabled:Zi.enabled},onPointerDown:c=>this.handleCanvasPointerDown(c),onWheel:c=>this.handleWheel(c),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:m},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,n,r)=>{re("export",t,"ui");let i=await tr(t,n,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:r.exportingFrame}).catch(BH).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&Zl(i)&&this.setState({fileHandle:i})});I(this,"magicGenerations",new Map);I(this,"updateMagicGeneration",({frameElement:t,data:n})=>{n.status==="pending"?this.scene.mutateElement(t,{customData:{generationData:void 0}},{informMutation:!1,isDragging:!1}):this.scene.mutateElement(t,{customData:{generationData:n}},{informMutation:!1,isDragging:!1}),this.magicGenerations.set(t.id,n),this.triggerRender()});I(this,"plugins",{});I(this,"onMagicframeToolSelect",()=>{let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(t.length===0)this.setActiveTool({type:Po.magicframe}),re("ai","tool-select (empty-selection)","d2c");else{let n=t.length===1&&Df(t[0])&&t[0];if(!n&&t.some(i=>kt(i)||i.frameId)){this.setActiveTool({type:Po.magicframe});return}re("ai","tool-select (existing selection)","d2c");let r;if(n)r=n;else{let[i,a,l,s]=ji(t),m=50;r=SI({...Nn,x:i-m,y:a-m,width:l-i+m*2,height:s-a+m*2,opacity:100,locked:!1}),this.scene.insertElement(r);for(let d of t)this.scene.mutateElement(d,{frameId:r.id});this.setState({selectedElementIds:{[r.id]:!0}})}this.onMagicFrameGenerate(r,"upstream")}});I(this,"openEyeDropper",({type:t})=>{this.updateEditorAtom(rn,{swapPreviewOnAlt:!0,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(n,r)=>{let i=t==="background"&&r.altKey||t==="stroke"&&!r.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?i?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:n},captureUpdate:Et.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:n},captureUpdate:Et.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?Fn(l,{[i?"strokeColor":"backgroundColor"]:n}):l),captureUpdate:Et.IMMEDIATELY})},keepOpenOnAlt:!1})});I(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});I(this,"syncActionResult",Ae(t=>{if(this.unmounted||t===!1)return;this.store.scheduleAction(t.captureUpdate);let n=!1,r=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),n=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||r||this.state.contextMenu){let i=t?.appState?.viewModeEnabled||!1,a=t?.appState?.zenModeEnabled||!1,l=t?.appState?.theme||this.props.theme||um.LIGHT,s=t?.appState?.name??this.state.name,m=t?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(a=this.props.zenModeEnabled),r=t.appState?.editingTextElement||null,t.elements&&r&&t.elements.forEach(d=>{r?.id===d.id&&r!==d&&jI(d)&&po(d)&&(r=d)}),r?.isDeleted&&(r=null),this.setState(d=>{let c=t.appState||{};return{...d,...c,contextMenu:null,editingTextElement:r,viewModeEnabled:i,zenModeEnabled:a,theme:l,name:s,errorMessage:m}}),n=!0}n||this.scene.triggerUpdate()}));I(this,"onBlur",Ae(()=>{Er=!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",Ae(t=>{this.scene.replaceAllElements([]),this.setState(n=>({...Qo(),isLoading:t?.resetLoadingState?!1:n.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));I(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async i=>{if(!i.files.length)return;let a=i.files[0],l=await a.getFile();this.loadFileToCanvas(new File([l],l.name||"",{type:l.type}),a)}),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(i=>{console.error(i)})}catch(i){console.error(i),t={appState:{errorMessage:i.message||"Encountered an error during importing or restoring scene data"}}}let n=Sr(t,null,null,{repairBindings:!0,deleteInvisibleElements:!0}),r=n.appState.activeTool;n.appState={...n.appState,theme:this.props.theme||n.appState.theme,openSidebar:n.appState?.openSidebar||this.state.openSidebar,activeTool:r.type==="image"||r.type==="lasso"||r.type==="selection"?{...r,type:this.defaultSelectionTool}:n.appState.activeTool,isLoading:!1,toast:this.state.toast},t?.scrollToContent&&(n.appState={...n.appState,...Gn(n.elements,{...n.appState,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})}),this.resetStore(),this.resetHistory(),this.syncActionResult({...n,captureUpdate:Et.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(i=>{this.fonts.onLoaded(i)}),Gf(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})});I(this,"isMobileBreakpoint",(t,n)=>t<=YH||n<XH&&t<KH);I(this,"isTabletBreakpoint",(t,n)=>{let r=Math.min(t,n),i=Math.max(t,n);return r>=WH&&i<=VH});I(this,"refreshViewportBreakpoints",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:n,height:r}=t.getBoundingClientRect(),i=this.device.viewport,a=Tf(i,{isLandscape:n>r,isMobile:this.isMobileBreakpoint(n,r)});return i!==a?(this.device={...this.device,viewport:a},!0):!1});I(this,"refreshEditorBreakpoints",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:n,height:r}=t.getBoundingClientRect(),i=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:fH,a=this.device.editor,l=Tf(a,{isMobile:this.isMobileBreakpoint(n,r),canFitSidebar:n>i});return this.setState({stylesPanelMode:this.isTabletBreakpoint(n,r)&&fr()?"compact":"full"}),a!==l?(this.device={...this.device,editor:l},!0):!1});I(this,"onResize",Ae(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>Al.delete(t)),this.refreshViewportBreakpoints(),this.updateDOMRect(),gI||this.refreshEditorBreakpoints(),this.setState({})}));I(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});I(this,"renderInteractiveSceneCallback",({atLeastOneVisibleElement:t,scrollBars:n,elementsMap:r})=>{n&&(Nl=n);let i=this.state.editingTextElement?!1:!t&&r.size>0;this.state.scrolledOutside!==i&&this.setState({scrolledOutside:i}),this.scheduleImageRefresh()});I(this,"onScroll",xI(()=>{let{offsetTop:t,offsetLeft:n}=this.getCanvasOffsets();this.setState(r=>r.offsetLeft===n&&r.offsetTop===t?null:{offsetTop:t,offsetLeft:n})},bH));I(this,"onCut",Ae(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||Sl(t.target)||(this.actionManager.executeAction(uc,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onCopy",Ae(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||Sl(t.target)||(this.actionManager.executeAction(di,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onTouchStart",t=>{if(IH&&t.preventDefault(),!Dl){Dl=!0,t.touches.length===1&&(_l={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(Uf),Uf=window.setTimeout(e.resetTapTwice,xH);return}if(Dl&&t.touches.length===1&&_l){let n=t.touches[0];Rn(ie(n.clientX,n.clientY),ie(_l.x,_l.y))<=UH&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:n.clientX,clientY:n.clientY})),Dl=!1,clearTimeout(Uf)}t.touches.length===2&&this.setState({selectedElementIds:ve({},this.state),activeEmbeddable:null})});I(this,"onTouchEnd",t=>{this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:ve(this.state.previousSelectedElementIds,this.state)}):ge.pointers.clear()});I(this,"pasteFromClipboard",Ae(async t=>{let n=!!Vf,r=document.activeElement,i=this.excalidrawContainerRef.current?.contains(r);if(t&&!i)return;let a=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(t&&(!(a instanceof HTMLCanvasElement)||Sl(r)))return;let l=await Oa(t),s=l.getFiles(),m=await EE(l,n);if(this.props.onPaste)try{if(await this.props.onPaste(m,t)===!1)return}catch(d){console.error(d)}await this.insertClipboardContent(m,s,n),this.setActiveTool({type:this.defaultSelectionTool},!0),t?.preventDefault()}));I(this,"addElementsFromPasteOrLibrary",t=>{let n=Lm(t.elements,null,{deleteInvisibleElements:!0}),[r,i,a,l]=ji(n),s=$i(r,a)/2,m=$i(i,l)/2,d=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,c=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop,{x:p,y:u}=He({clientX:d,clientY:c},this.state),f=p-s,b=u-m,[x,y]=rt(f,b,this.getEffectiveGridSize()),{duplicatedElements:E}=Mf({type:"everything",elements:n.map(P=>Fn(P,{x:P.x+x-r,y:P.y+y-i})),randomizeSeed:!t.retainSeed}),w=this.scene.getElementsIncludingDeleted(),v=[...w,...E];v=this.props.onDuplicate?.(v,w)||v,VI(v,fm(E));let S=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(S){let P=TG(E,S);Of(v,P,S,this.state)}this.scene.replaceAllElements(v),E.forEach(P=>{if(po(P)&&Af(P)){let B=OI(P,this.scene.getElementsMapIncludingDeleted());gG(P,B,this.scene)}}),kH&&Jo.loadElementsFonts(E).then(P=>{this.fonts.onLoaded(P)}),t.files&&this.addMissingFiles(t.files);let L=YG(E);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.device.editor.canFitSidebar&&Ue.get(gl)?this.state.openSidebar:null,...qt({editingGroupId:null,selectedElementIds:L.reduce((P,B)=>(Af(B)||(P[B.id]=!0),P),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:this.defaultSelectionTool},!0),t.fitToContent&&this.scrollToContent(E,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})});I(this,"setAppState",(t,n)=>{this.setState(t,n)});I(this,"removePointer",t=>{On&&this.resetContextMenuTimer(),ge.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(n=>({activeTool:{...n.activeTool,...$o(this.state,n.activeTool.locked?{type:this.defaultSelectionTool}:n.activeTool),locked:!n.activeTool.locked}}))});I(this,"updateFrameRendering",t=>{this.setState(n=>{let r=typeof t=="function"?t(n.frameRendering):t;return{frameRendering:{enabled:r?.enabled??n.frameRendering.enabled,clip:r?.clip??n.frameRendering.clip,name:r?.name??n.frameRendering.name,outline:r?.outline??n.frameRendering.outline}}})});I(this,"togglePenMode",t=>{this.setState(n=>({penMode:t??!n.penMode,penDetected:!0}))});I(this,"onHandToolToggle",()=>{this.actionManager.executeAction(Kx)});I(this,"zoomCanvas",t=>{this.setState({...Bo({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:ho(t)},this.state)})});I(this,"cancelInProgressAnimation",null);I(this,"scrollToContent",(t=this.scene.getNonDeletedElements(),n)=>{if(typeof t=="string"){let s;if(Gf(t)?s=AG(t):s=t,s){let m=this.scene.getElementsFromId(s);m?.length?this.scrollToContent(m,{fitToContent:n?.fitToContent??!0,animate:n?.animate??!0}):Gf(t)&&this.setState({toast:{message:g("elementLink.notFound"),duration:3e3,closable:!0}})}return}this.cancelInProgressAnimation?.();let r=Array.isArray(t)?t:[t],i=this.state.zoom,a=this.state.scrollX,l=this.state.scrollY;if(n?.fitToContent||n?.fitToViewport){let{appState:s}=La({canvasOffsets:n.canvasOffsets,targetElements:r,appState:this.state,fitToViewport:!!n?.fitToViewport,viewportZoomFactor:n?.viewportZoomFactor,minZoom:n?.minZoom,maxZoom:n?.maxZoom});i=s.zoom,a=s.scrollX,l=s.scrollY}else{let s=Gn(r,this.state);a=s.scrollX,l=s.scrollY}if(n?.animate){let s=this.state.scrollX,m=this.state.scrollY,d=this.state.zoom.value,c=NH({fromValues:{scrollX:s,scrollY:m,zoom:d},toValues:{scrollX:a,scrollY:l,zoom:i.value},interpolateValue:(p,u,f,b)=>{if(b==="zoom")return p*Math.pow(u/p,FH(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:n?.duration??500});this.cancelInProgressAnimation=()=>{c(),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"),n=await t.match("shared-file");if(n){let r=await n.blob(),i=new File([r],r.name||"",{type:r.type});this.loadFileToCanvas(i,null),await t.delete("shared-file"),window.history.replaceState(null,cH,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});I(this,"addFiles",Ae(t=>{let{addedFiles:n}=this.addMissingFiles(t);this.clearImageShapeCache(n),this.scene.triggerUpdate(),this.addNewImagesToImageCache()}));I(this,"addMissingFiles",(t,n=!1)=>{let r=n?{}:{...this.files},i={},a=Array.isArray(t)?t:Object.values(t);for(let l of a)if(!r[l.id]&&(i[l.id]=l,r[l.id]=l,l.mimeType===Mo.svg))try{let s=R1(FI(N1(l.dataURL)),Mo.svg);l.dataURL!==s&&(l.version=(l.version??1)+1,l.dataURL=s)}catch(s){console.error(s)}return this.files=r,{addedFiles:i}});I(this,"updateScene",Ae(t=>{let{elements:n,appState:r,collaborators:i,captureUpdate:a}=t;if(a){let l=n||void 0,s=r?ZH({...this.store.snapshot.appState,...r}):void 0;this.store.scheduleMicroAction({action:a,elements:l,appState:s})}r&&this.setState(r),n&&this.scene.replaceAllElements(n),i&&this.setState({collaborators:i})}));I(this,"applyDeltas",(t,n)=>{let r=JI.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return JI.applyTo(r,a,i,n)});I(this,"mutateElement",(t,n,r=!0)=>this.scene.mutateElement(t,n,{informMutation:r,isDragging:!1}));I(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});I(this,"toggleSidebar",({name:t,tab:n,force:r})=>{let i;r===void 0?i=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===n?null:t:i=r?t:null;let a=i?{name:i}:null;return a&&n&&(a.tab=n),this.setState({openSidebar:a}),!!i});I(this,"updateCurrentCursorPosition",Ae(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,n=this.excalidrawContainerRef?.current?.querySelector(".sidebar")?.getBoundingClientRect(),r=this.excalidrawContainerRef?.current?.querySelector(".App-menu__left")?.getBoundingClientRect(),i=16;return Do().rtl?{top:t+i,right:Math.max(this.state.width-(r?.left??this.state.width),0)+i,bottom:i,left:Math.max(n?.right??0,0)+i}:{top:t+i,right:Math.max(this.state.width-(n?.left??this.state.width)+i,0),bottom:i,left:Math.max(r?.right??0,0)+i}});I(this,"onKeyDown",Ae(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}})),!EI(t.target)){if((t.key===V.ESCAPE||t.key===V.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let a=j(this.scene.getNonDeletedElementsMap(),this.state);if(a.length===1&&br(a[0])&&t.key===V.ENTER){this.startImageCropping(a[0]);return}if(t.key===V.ESCAPE)this.updateEditorAtom(ao,null);else if(t.key===V.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(GH.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let s=xi(a);Ue.get(ao)?.type==="panel"&&Zu(this,{conversionType:s,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),s&&this.updateEditorAtom(ao,{type:"panel"})}if(t.key===V.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let l=mm(t.key);if(t[V.CTRL_OR_CMD]&&l&&!t.shiftKey){t.preventDefault();let s=j(this.scene.getNonDeletedElementsMap(),this.state);s.length===1&&lG(s[0])&&this.flowChartCreator.createNodes(s[0],this.state,UI(t.key),this.scene),this.flowChartCreator.pendingNodes?.length&&!_f(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=j(this.scene.getNonDeletedElementsMap(),this.state);if(s.length===1&&l){t.preventDefault();let m=this.flowChartNavigator.exploreByDirection(s[0],this.scene.getNonDeletedElementsMap(),UI(t.key));if(m){this.setState(c=>({selectedElementIds:ve({[m]:!0},c)}));let d=this.scene.getNonDeletedElementsMap().get(m);d&&!_f([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[V.CTRL_OR_CMD]&&t.key===V.P&&!t.shiftKey&&!t.altKey){this.setToast({message:g("commandPalette.shortcutHint",{shortcut:Fe("commandPalette")})}),t.preventDefault();return}if(t[V.CTRL_OR_CMD]&&t.key.toLowerCase()===V.V&&(Vf=t.shiftKey,clearTimeout(eC),eC=window.setTimeout(()=>{Vf=!1},100)),t[V.CTRL_OR_CMD]&&Sl(t.target)&&(t.code===dI.MINUS||t.code===dI.EQUAL)){t.preventDefault();return}if(Sl(t.target)&&t.key!==V.ESCAPE||mm(t.key)&&EI(t.target))return;if(t.key===V.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===V.E&&t.shiftKey&&t[V.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(t.key===V.PAGE_UP||t.key===V.PAGE_DOWN){let a=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;t.key===V.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[V.CTRL_OR_CMD]&&this.state.isBindingEnabled&&this.setState({isBindingEnabled:!1}),mm(t.key)){let a=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),l=a.find(Xe),s=new Set;a.filter(Xe).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 m=this.getEffectiveGridSize()&&(t.shiftKey?uI:this.getEffectiveGridSize())||(t.shiftKey?pH:uI),d=0,c=0;t.key===V.ARROW_LEFT?d=-m:t.key===V.ARROW_RIGHT?d=m:t.key===V.ARROW_UP?c=-m:t.key===V.ARROW_DOWN&&(c=m),a.forEach(p=>{this.scene.mutateElement(p,{x:p.x+d,y:p.y+c},{informMutation:!1,isDragging:!1}),Sf(p,this.scene,{simultaneouslyUpdated:a})}),this.setState({suggestedBindings:kf(a.filter(p=>p.id!==l?.id||m!==0),this.scene.getNonDeletedElementsMap(),this.state.zoom)}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===V.ENTER){let a=this.scene.getSelectedElements(this.state);if(a.length===1){let l=a[0];if(t[V.CTRL_OR_CMD]||xm(l))jt(l)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)&&(this.store.scheduleCapture(),Xe(l)||this.actionManager.executeAction(Di));else if(po(l)||hG(l)){let s;po(l)||(s=l);let m=Bf(l,this.state,this.scene.getNonDeletedElementsMap()),d=m.x,c=m.y;this.startTextEditing({sceneX:d,sceneY:c,container:s}),t.preventDefault();return}else kt(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=N2(t.key,this);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===Bn.sharp?Bn.round:l.currentItemArrowType===Bn.round?Bn.elbow:Bn.sharp})),this.setActiveTool({type:a}),t.stopPropagation()):t.key===V.Q&&(this.toggleLock("keyboard"),t.stopPropagation())}if(t.key===V.SPACE&&ge.pointers.size===0&&(Er=!0,ye(this.interactiveCanvas,_e.GRAB),t.preventDefault()),(t.key===V.G||t.key===V.S)&&!t.altKey&&!t[V.CTRL_OR_CMD]){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;t.key===V.G&&(go(this.state.activeTool.type)||a.some(l=>go(l.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===V.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[V.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===V.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=>po(l)||Nf(l,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}if(t.key===V.K&&!t.altKey&&!t[V.CTRL_OR_CMD]){this.state.activeTool.type==="laser"?this.setActiveTool({type:this.defaultSelectionTool}):this.setActiveTool({type:"laser"});return}t[V.CTRL_OR_CMD]&&(t.key===V.BACKSPACE||t.key===V.DELETE)&&this.updateEditorAtom(lr,"clearCanvas");let n=t.key.toLocaleLowerCase(),r=n===V.S&&t.shiftKey,i=t.key===V.I||n===V.G&&t.shiftKey;(r||i)&&this.openEyeDropper({type:r?"stroke":"background"})}));I(this,"onKeyUp",Ae(t=>{if(t.key===V.SPACE&&(this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector"?ye(this.interactiveCanvas,_e.GRAB):this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"?Ut(this.interactiveCanvas):(Dt(this.interactiveCanvas,this.state),this.setState({selectedElementIds:ve({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Er=!1),!t[V.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),mm(t.key)&&(II(this.scene.getSelectedElements(this.state).filter(jt),Cf(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:Et.IMMEDIATELY})),!t[V.CTRL_OR_CMD]&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.pendingNodes?.length&&this.scene.insertElements(this.flowChartCreator.pendingNodes);let n=this.flowChartCreator.pendingNodes?.[0];n&&(this.setState(r=>({selectedElementIds:ve({[n.id]:!0},r)})),_f([n],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(n,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})),this.flowChartCreator.clear(),this.syncActionResult({captureUpdate:Et.IMMEDIATELY})}}));I(this,"isToolSupported",t=>this.props.UIOptions.tools?.[t]!==!1);I(this,"setActiveTool",(t,n=!1)=>{if(!this.isToolSupported(t.type)){console.warn(`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`);return}let r=$o(this.state,t);r.type==="hand"?ye(this.interactiveCanvas,_e.GRAB):Er||Dt(this.interactiveCanvas,{...this.state,activeTool:r}),AH(document.activeElement)&&this.focusContainer(),iG(r.type)||this.setState({suggestedBindings:[]}),r.type==="image"&&this.onImageToolbarButtonClick(),this.setState(i=>{let a={snapLines:i.snapLines.length?[]:i.snapLines,originSnapOffset:null,activeEmbeddable:null};return r.type==="freedraw"&&this.store.scheduleCapture(),r.type==="lasso"?{...i,activeTool:r,...n?{}:{selectedElementIds:ve({},i),selectedGroupIds:ve({},i),editingGroupId:null,multiElement:null},...a}:r.type!=="selection"?{...i,activeTool:r,selectedElementIds:ve({},i),selectedGroupIds:ve({},i),editingGroupId:null,multiElement:null,...a}:{...i,activeTool:r,...a}})});I(this,"setOpenDialog",t=>{this.setState({openDialog:t})});I(this,"setCursor",t=>{ye(this.interactiveCanvas,t)});I(this,"resetCursor",()=>{Ut(this.interactiveCanvas)});I(this,"isTouchScreenMultiTouchGesture",()=>ge.pointers.size>=2);I(this,"getName",()=>this.state.name||this.props.name||`${g("labels.untitled")}-${yI()}`);I(this,"onGestureStart",Ae(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:ve({},this.state),activeEmbeddable:null}),ge.initialScale=this.state.zoom.value}));I(this,"onGestureChange",Ae(t=>{if(t.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let n=ge.initialScale;n&&this.setState(r=>({...Bo({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:ho(n*t.scale)},r)}))}));I(this,"onGestureEnd",Ae(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:ve(this.state.previousSelectedElementIds,this.state)}),ge.initialScale=null}));I(this,"startTextEditing",({sceneX:t,sceneY:n,insertAtParentCenter:r=!0,container:i,autoEdit:a=!0})=>{let l=!1,s=r&&this.getTextWysiwygSnappedToCenterPosition(t,n,this.state,i);i&&s&&(Nf(i,this.scene.getNonDeletedElementsMap())||(l=!0));let m=null,d=this.scene.getSelectedElements(this.state);d.length===1?po(d[0])?m=d[0]:i?m=Nf(d[0],this.scene.getNonDeletedElementsMap()):m=this.getTextElementAtPosition(t,n):m=this.getTextElementAtPosition(t,n);let c=m?.fontFamily||this.state.currentItemFontFamily,p=m?.lineHeight||bI(c),u=this.state.currentItemFontSize;if(!m&&l&&i&&!Pf(i)){let y=NG(wf({fontSize:u,fontFamily:c}),p),E=BG(u,p),w=Math.max(i.height,E),v=Math.max(i.width,y);this.scene.mutateElement(i,{height:w,width:v}),t=i.x+v/2,n=i.y+w/2,s&&(s=this.getTextWysiwygSnappedToCenterPosition(t,n,this.state,i))}let f=this.getTopLayerFrameAtSceneCoords({x:t,y:n}),b=m||kI({x:s?s.elementCenterX:t,y:s?s.elementCenterY:n,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:c,textAlign:s?"center":this.state.currentItemTextAlign,verticalAlign:s?vH.MIDDLE:pI,containerId:l?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:p,angle:i?Pf(i)?0:i.angle:0,frameId:f?f.id:null});if(!m&&l&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:b.id})}),this.setState({editingTextElement:b}),!m)if(i&&l){let x=this.scene.getElementIndex(i.id);this.scene.insertElementAtIndex(b,x+1)}else this.scene.insertElement(b);a||m||i?this.handleTextWysiwyg(b,{isExistingElement:!!m}):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!==this.defaultSelectionTool)return;let n=this.scene.getSelectedElements(this.state),{x:r,y:i}=He(t,this.state);if(n.length===1&&jt(n[0])){let l=n[0];if((t[V.CTRL_OR_CMD]&&JG(l)||xm(l))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)){this.actionManager.executeAction(Di);return}else if(this.state.selectedLinearElement&&Xe(n[0])){let s=Ie.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),m=s?Ie.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,s,this.scene.getNonDeletedElementsMap()):-1;if(m&&m>-1){this.store.scheduleCapture(),Ie.deleteFixedSegment(n[0],this.scene,m);let d=Ie.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),c=d?Ie.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,d,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:{...this.state.selectedLinearElement.pointerDownState,segmentMidpoint:{index:c,value:s,added:!1}},segmentMidPointHoveredCoords:d}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===l.id&&xm(l))return}if(n.length===1&&br(n[0])){this.startImageCropping(n[0]);return}if(Ut(this.interactiveCanvas),GG(this.state).length>0){let l=this.getElementAtPosition(r,i),s=l&&HG(l,this.state.selectedGroupIds);if(s){this.store.scheduleCapture(),this.setState(m=>({...m,...qt({editingGroupId:s,selectedElementIds:{[l.id]:!0}},this.scene.getNonDeletedElements(),m,this)}));return}}if(Ut(this.interactiveCanvas),!t[V.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let l=this.getElementAtPosition(r,i);if(Pl(l)){this.setState({activeEmbeddable:{element:l,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){let s=this.getTextBindableContainerAtPosition(r,i);if(s&&(PI(s)||!RH(s.backgroundColor)||Ll({point:ie(r,i),element:s,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(s)}))){let m=Bf(s,this.state,this.scene.getNonDeletedElementsMap());r=m.x,i=m.y}this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:s})}}});I(this,"getElementLinkAtPosition",(t,n)=>{if(n&&n.locked)return;let r=this.scene.getNonDeletedElements(),i=-1;for(let a=r.length-1;a>=0;a--){let l=r[a];if(n&&l.id===n.id&&(i=a),l.link&&a>=i&&Wl(l,this.scene.getNonDeletedElementsMap(),this.state,ie(t.x,t.y),this.device.editor.isMobile))return l}});I(this,"redirectToLink",(t,n)=>{let r=Rn(ie(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),ie(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||r>mH)return;let i=He(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),l=Wl(this.hitLinkElement,a,this.state,ie(i.x,i.y),this.device.editor.isMobile),s=He(this.lastPointerUpEvent,this.state),m=Wl(this.hitLinkElement,a,this.state,ie(s.x,s.y),this.device.editor.isMobile);if(l&&m){Fu();let d=this.hitLinkElement.link;if(d){d=yf(d);let c;if(this.props.onLinkOpen&&(c=DH(te.EXCALIDRAW_LINK,t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:d},c)),!c?.defaultPrevented){let p=MH(d)?"_self":"_blank",u=window.open(void 0,p);u&&(u.opener=null,u.location=d)}}}});I(this,"getTopLayerFrameAtSceneCoords",t=>{let n=this.scene.getNonDeletedElementsMap(),r=this.scene.getNonDeletedFramesLikes().filter(i=>!i.locked&&zI(t,i,n));return r.length?r[r.length-1]:null});I(this,"handleCanvasPointerMove",t=>{this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent,ge.pointers.has(t.pointerId)&&ge.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let n=ge.initialScale;if(ge.pointers.size===2&&ge.lastCenter&&n&&ge.initialDistance){let f=Xh(ge.pointers),b=f.x-ge.lastCenter.x,x=f.y-ge.lastCenter.y;ge.lastCenter=f;let y=Kh(Array.from(ge.pointers.values())),E=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:y/ge.initialDistance,w=E?ho(n*E):this.state.zoom.value;this.setState(v=>{let C=Bo({viewportX:f.x,viewportY:f.y,nextZoom:w},v);this.translateCanvas({zoom:C.zoom,scrollX:C.scrollX+2*(b/w),scrollY:C.scrollY+2*(x/w),shouldCacheIgnoreZoom:!0})}),this.resetShouldCacheIgnoreZoomDebounced()}else ge.lastCenter=ge.initialDistance=ge.initialScale=null;if(Er||Rl||Yf||Qt(this.state))return;let i=tg(Nl,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(i?Ut(this.interactiveCanvas):Dt(this.interactiveCanvas,this.state));let a=He(t,this.state),{x:l,y:s}=a;if(!this.state.newElement&&iv(this.state.activeTool.type)){let{originOffset:f,snapLines:b}=rv(this.scene.getNonDeletedElements(),this,{x:l,y:s},t,this.scene.getNonDeletedElementsMap());this.setState(x=>{let y=kl(x.snapLines,b),E=x.originSnapOffset?kl(x.originSnapOffset,f):f;return x.snapLines===y&&x.originSnapOffset===E?null:{snapLines:y,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=Ie.handlePointerMove(t,l,s,this),b=f?this.scene.getElement(f.elementId):null;f&&f!==this.state.selectedLinearElement&&Ki(()=>{this.setState({selectedLinearElement:f})}),f?.lastUncommittedPoint!=null&&b&&LI(b.type)?this.maybeSuggestBindingAtCursor(a,f.elbowed):this.state.suggestedBindings.length&&this.setState({suggestedBindings:[]})}if(LI(this.state.activeTool.type)){let{newElement:f}=this.state;Lf(f,!1)?this.setState({suggestedBindings:vI(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:y,lastCommittedPoint:E}=f,w=y[y.length-1];if(Dt(this.interactiveCanvas,this.state),w===E)Rn(ie(l-b,s-x),w)>=Ef?this.scene.mutateElement(f,{points:[...y,ie(l-b,s-x)]},{informMutation:!1,isDragging:!1}):ye(this.interactiveCanvas,_e.POINTER);else if(y.length>2&&E&&Rn(ie(l-b,s-x),E)<Ef)ye(this.interactiveCanvas,_e.POINTER),this.scene.mutateElement(f,{points:y.slice(0,-1)},{informMutation:!1,isDragging:!1});else{let[v,C]=rt(l,s,t[V.CTRL_OR_CMD]||Xe(f)?null:this.getEffectiveGridSize()),[S,L]=f?.lastCommittedPoint??[0,0],P=v-b-S,B=C-x-L;xf(t)&&({width:P,height:B}=DI(S+b,L+x,v,C)),NI(y,this.state.zoom.value)&&ye(this.interactiveCanvas,_e.POINTER),this.scene.mutateElement(f,{points:[...y.slice(0,-1),ie(S+P,L+B)]},{isDragging:!0,informMutation:!1}),this.triggerRender(!1)}return}if(!!t.buttons||this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let d=this.scene.getNonDeletedElements(),c=this.scene.getSelectedElements(this.state);if(c.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"&&!(c.length===1&&Xe(c[0]))){let f=KI(d,this.state,l,s,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);if(f&&f.transformHandleType){ye(this.interactiveCanvas,XI(f));return}}}else if(c.length>1&&!i&&this.state.openDialog?.name!=="elementLinkSelector"){let f=ZI(ji(c),l,s,this.state.zoom,t.pointerType,this.device);if(f){ye(this.interactiveCanvas,XI({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),!yt(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(ye(this.interactiveCanvas,_e.POINTER),fy(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):(Fu(),u&&(u.link||jo(u))&&this.state.selectedElementIds[u.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?ye(this.interactiveCanvas,po(u)?_e.TEXT:_e.CROSSHAIR):this.state.viewModeEnabled?ye(this.interactiveCanvas,_e.GRAB):this.state.openDialog?.name==="elementLinkSelector"?ye(this.interactiveCanvas,_e.AUTO):i?ye(this.interactiveCanvas,_e.AUTO):t[V.CTRL_OR_CMD]?ye(this.interactiveCanvas,_e.AUTO):(u||this.isHittingCommonBoundingBoxOfSelectedElements(a,c))&&!u?.locked&&(u&&Pl(u)&&this.isIframeLikeElementCenter(u,t,l,s)?(ye(this.interactiveCanvas,_e.POINTER),this.setState({activeEmbeddable:{element:u,state:"hover"}})):(!u||!Xe(u)||!(u.startBinding||u.endBinding))&&((this.state.activeTool.type!=="lasso"||c.length>0)&&ye(this.interactiveCanvas,_e.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:kl(f.hoveredElementIds,qt({editingGroupId:f.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),f,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!u&&this.setState(f=>({hoveredElementIds:kl(f.hoveredElementIds,{})})))});I(this,"handleEraser",(t,n)=>{let r=this.eraserTrail.addPointToPath(n.x,n.y,t.altKey);this.elementsPendingErasure=new Set(r),this.triggerRender()});I(this,"handleTouchMove",t=>{Bl=!0});I(this,"handleCanvasPointerDown",t=>{let n=t.target;if(n.setPointerCapture&&n.setPointerCapture(t.pointerId),this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.searchMatches&&(this.setState(c=>({searchMatches:c.searchMatches&&{focusedId:null,matches:c.searchMatches.matches.map(p=>({...p,focus:!1}))}})),this.updateEditorAtom(Fg,null)),Ue.get(ao)&&this.updateEditorAtom(ao,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 c=this.state.newElement;this.updateScene({...c.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(p=>p.id!==c.id)}:{},appState:{newElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:ve(Object.keys(this.state.selectedElementIds).filter(p=>p!==c.id).reduce((p,u)=>(p[u]=this.state.selectedElementIds[u],p),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?Et.EVENTUALLY:Et.NEVER});return}let r=document.getSelection();if(r?.anchorNode&&r.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(c=>({penMode:!0,penDetected:!0})),!this.device.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.device=Tf(this.device,{isTouchScreen:!0})),Rl||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===hr.ERASER&&this.state.activeTool.type!==Po.eraser){this.setState({activeTool:$o(this.state,{type:Po.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let c=()=>{p(),u?.(),yt(this.state)&&this.setState({activeTool:$o(this.state,{...this.state.activeTool.lastActiveTool||{type:Po.selection},lastActiveToolBeforeEraser:null})})},p=Re(window,te.POINTER_UP,c,{once:!0}),u;requestAnimationFrame(()=>{u=this.missingPointerEventCleanupEmitter.once(c)})});return}if(t.button!==hr.MAIN&&t.button!==hr.TOUCH&&t.button!==hr.ERASER||ge.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;if(this.state.activeTool.type==="lasso"){let c=i.hit.element&&this.isASelectedElement(i.hit.element);!i.hit.hasHitCommonBoundingBoxOfSelectedElements&&!i.resize.handleType&&!c&&(this.lassoTrail.startPath(i.origin.x,i.origin.y,t.shiftKey),i.drag.blockDragging=!fr()),fr()&&i.hit.element&&!c&&(this.setState(p=>{let u={...p.selectedElementIds,[i.hit.element.id]:!0},f=[];Object.keys(p.selectedElementIds).forEach(x=>{let y=this.scene.getElement(x);y&&f.push(y)});let b=i.hit.element;if(kt(b))Ff(f,b.id).forEach(x=>{delete u[x.id]});else if(b.frameId)u[b.frameId]&&delete u[b.id];else{let x=b.groupIds,y=new Set(x.flatMap(E=>xr(this.scene.getNonDeletedElements(),E)).filter(E=>kt(E)).map(E=>E.id));y.size>0&&f.forEach(E=>{E.frameId&&y.has(E.frameId)&&(delete u[E.id],E.groupIds.flatMap(w=>xr(this.scene.getNonDeletedElements(),w)).forEach(w=>{delete u[w.id]}))})}return{...qt({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:b.link||jo(b)?"info":!1}}),i.hit.wasAddedToSelection=!0)}else 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===Po.frame||this.state.activeTool.type===Po.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),m=this.onKeyDownFromPointerDownHandler(i),d=this.onKeyUpFromPointerDownHandler(i);this.missingPointerEventCleanupEmitter.once(c=>s(c||t.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener(te.POINTER_MOVE,l),window.addEventListener(te.POINTER_UP,s),window.addEventListener(te.KEYDOWN,m),window.addEventListener(te.KEYUP,d),i.eventListeners.onMove=l,i.eventListeners.onUp=s,i.eventListeners.onKeyUp=d,i.eventListeners.onKeyDown=m)});I(this,"handleCanvasPointerUp",t=>{this.removePointer(t),this.lastPointerUpEvent=t;let n=He({clientX:t.clientX,clientY:t.clientY},this.state),r=t.timeStamp-(this.lastPointerDownEvent?.timeStamp??0);if(this.device.editor.isMobile&&r<300){let i=this.getElementAtPosition(n.x,n.y);if(Pl(i)&&this.isIframeLikeElementCenter(i,t,n.x,n.y)){this.handleEmbeddableCenterClick(i);return}}if(this.device.isTouchScreen){let i=this.getElementAtPosition(n.x,n.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(n,i)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?r<300&&Pl(this.hitLinkElement)&&!y1(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,ie(n.x,n.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"&&(Bl=!1,On?Bl=!0:On=window.setTimeout(()=>{On=0,Bl||this.handleCanvasContextMenu(t)},wH))});I(this,"resetContextMenuTimer",()=>{clearTimeout(On),On=0,Bl=!1});I(this,"maybeCleanupAfterMissingPointerUp",t=>{Fl?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});I(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(ge.pointers.size<=1&&(t.button===hr.WHEEL||t.button===hr.MAIN&&Er||Qt(this.state)||this.state.viewModeEnabled)))return!1;Rl=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let n=!1,r=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);ye(this.interactiveCanvas,_e.GRABBING);let{clientX:i,clientY:a}=t,l=yd(m=>{let d=i-m.clientX,c=a-m.clientY;if(i=m.clientX,a=m.clientY,r&&!n&&(Math.abs(d)>1||Math.abs(c)>1)){n=!0;let p=f=>{document.body.removeEventListener(te.PASTE,p),f.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener(te.PASTE,p),window.removeEventListener(te.POINTER_UP,u)},100)};document.body.addEventListener(te.PASTE,p),window.addEventListener(te.POINTER_UP,u)}this.translateCanvas({scrollX:this.state.scrollX-d/this.state.zoom.value,scrollY:this.state.scrollY-c/this.state.zoom.value})}),s=Ae(Fl=()=>{Fl=null,Rl=!1,Er||(this.state.viewModeEnabled?ye(this.interactiveCanvas,_e.GRAB):Dt(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(te.POINTER_MOVE,l),window.removeEventListener(te.POINTER_UP,s),window.removeEventListener(te.BLUR,s),l.flush()});return window.addEventListener(te.BLUR,s),window.addEventListener(te.POINTER_MOVE,l,{passive:!0}),window.addEventListener(te.POINTER_UP,s),!0});I(this,"clearSelectionIfNotUsingSelection",()=>{this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.setState({selectedElementIds:ve({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});I(this,"handleSelectionOnPointerDown",(t,n)=>{if(this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"){let r=this.scene.getNonDeletedElements(),i=this.scene.getNonDeletedElementsMap(),a=this.scene.getSelectedElements(this.state);if(a.length===1&&!this.state.selectedLinearElement?.isEditing&&!Xe(a[0])&&!(xm(a[0])&&Ie.getPointIndexUnderCursor(a[0],i,this.state.zoom,n.origin.x,n.origin.y)!==-1)&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let l=KI(r,this.state,n.origin.x,n.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);l!=null&&(l.transformHandleType==="rotation"?(this.setState({resizingElement:l.element}),n.resize.handleType=l.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:l.element}),n.resize.handleType=l.transformHandleType))}else a.length>1&&(n.resize.handleType=ZI(ji(a),n.origin.x,n.origin.y,this.state.zoom,t.pointerType,this.device));if(n.resize.handleType)n.resize.isResizing=!0,n.resize.offset=vf(VG(n.resize.handleType,a,i,n.origin.x,n.origin.y)),a.length===1&&jt(a[0])&&a[0].points.length===2&&(n.resize.arrowDirection=XG(n.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement,u=Ie.handlePointerDown(t,this,this.store,n.origin,p,this.scene);if(u.hitElement&&(n.hit.element=u.hitElement),u.linearElementEditor&&this.setState({selectedLinearElement:u.linearElementEditor}),u.didAddPoint)return!0}let l=this.getElementsAtPosition(n.origin.x,n.origin.y,{includeLockedElements:!0}),s=l.filter(p=>!p.locked),m=this.getElementAtPosition(n.origin.x,n.origin.y,{allHitElements:l});if((!m||m.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),m&&m.locked&&!s.some(p=>this.state.selectedElementIds[p.id])?n.hit.element=null:n.hit.element=n.hit.element??this.getElementAtPosition(n.origin.x,n.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(n.origin,m),this.hitLinkElement)return!0;if(this.state.croppingElementId&&n.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),n.hit.element&&this.getElementLinkAtPosition({x:n.origin.x,y:n.origin.y},n.hit.element))return!1;n.hit.allHitElements=s;let d=n.hit.element,c=n.hit.allHitElements.some(p=>this.isASelectedElement(p));if((d===null||!c)&&!t.shiftKey&&!n.hit.hasHitCommonBoundingBoxOfSelectedElements&&this.clearSelection(d),this.state.selectedLinearElement?.isEditing)this.setState({selectedElementIds:ve({[this.state.selectedLinearElement.elementId]:!0},this.state)});else if(d!=null){if(t[V.CTRL_OR_CMD])return t.altKey?(this.state.openDialog?.name==="elementLinkSelector"&&this.setOpenDialog(null),this.lassoTrail.startPath(n.origin.x,n.origin.y,t.shiftKey),this.setActiveTool({type:"lasso",fromSelection:!0}),!1):(this.state.selectedElementIds[d.id]||(n.hit.wasAddedToSelection=!0),this.setState(p=>({...zG(p,d),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[d.id]||(this.state.editingGroupId&&!WI(d,this.state.editingGroupId)&&this.setState({selectedElementIds:ve({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!c&&!n.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)}),kt(d))Ff(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(y=>xr(this.scene.getNonDeletedElements(),y)).filter(y=>kt(y)).map(y=>y.id));x.size>0&&f.forEach(y=>{y.frameId&&x.has(y.frameId)&&(delete u[y.id],y.groupIds.flatMap(E=>xr(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})),{...qt({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:d.link||jo(d)?"info":!1}}),n.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});I(this,"handleTextOnPointerDown",(t,n)=>{if(this.state.editingTextElement)return;let r=n.origin.x,i=n.origin.y,a=this.getElementAtPosition(r,i,{includeBoundTextElement:!0}),l=this.getTextBindableContainerAtPosition(r,i);PI(a)&&(l=a,r=a.x+a.width/2,i=a.y+a.height/2),this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:l,autoEdit:!1}),Ut(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:$o(this.state,{type:this.defaultSelectionTool})})});I(this,"handleFreeDrawElementOnPointerDown",(t,n,r)=>{let[i,a]=rt(r.origin.x,r.origin.y,null),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),s=t.pressure===.5,m=JH({type:n,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:[ie(0,0)],pressures:s?[]:[t.pressure]});this.scene.insertElement(m),this.setState(c=>{let p={...c.selectedElementIds};return delete p[m.id],{selectedElementIds:ve(p,c)}});let d=If(r.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom);this.setState({newElement:m,startBoundElement:d,suggestedBindings:[]})});I(this,"insertIframeElement",({sceneX:t,sceneY:n,width:r,height:i})=>{let[a,l]=rt(t,n,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=QH({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:r,height:i});return this.scene.insertElement(s),s});I(this,"insertEmbeddableElement",({sceneX:t,sceneY:n,link:r})=>{let[i,a]=rt(t,n,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=bm(r);if(!l)return;l.error instanceof URIError&&this.setToast({message:g("toast.unrecognizedLinkFormat"),closable:!0});let s=CI({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:r});return this.scene.insertElement(s),s});I(this,"newImagePlaceholder",({sceneX:t,sceneY:n,addToFrameUnderCursor:r=!0})=>{let[i,a]=rt(t,n,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=r?this.getTopLayerFrameAtSceneCoords({x:i,y:a}):null,s=100/this.state.zoom.value;return oG({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:l?l.id:null,x:i-s/2,y:a-s/2,width:s,height:s})});I(this,"handleLinearElementOnPointerDown",(t,n,r)=>{if(this.state.multiElement){let{multiElement:i}=this.state;if(i.type==="line"&&NI(i.points,this.state.zoom.value)){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(_t);return}if(Xe(i)&&i.points.length>1){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(_t);return}let{x:a,y:l,lastCommittedPoint:s}=i;if(i.points.length>1&&s&&Rn(ie(r.origin.x-a,r.origin.y-l),s)<Ef){this.actionManager.executeAction(_t);return}this.setState(m=>({selectedElementIds:ve({...m.selectedElementIds,[i.id]:!0},m)})),this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),ye(this.interactiveCanvas,_e.POINTER)}else{let[i,a]=rt(r.origin.x,r.origin.y,t[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:s,currentItemEndArrowhead:m}=this.state,[d,c]=n==="arrow"?[s,m]:[null,null],p=n==="arrow"?eG({type:n,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===Bn.round?{type:pm.PROPORTIONAL_RADIUS}:null,startArrowhead:d,endArrowhead:c,locked:!1,frameId:l?l.id:null,elbowed:this.state.currentItemArrowType===Bn.elbow,fixedSegments:this.state.currentItemArrowType===Bn.elbow?[]:null}):nG({type:n,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:pm.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:l?l.id:null});this.setState(f=>{let b={...f.selectedElementIds};return delete b[p.id],{selectedElementIds:ve(b,f)}}),this.scene.mutateElement(p,{points:[...p.points,ie(0,0)]});let u=If(r.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,Xe(p),Xe(p));this.scene.insertElement(p),this.setState({newElement:p,startBoundElement:u,suggestedBindings:[]})}});I(this,"createGenericElementOnPointerDown",(t,n)=>{let[r,i]=rt(n.origin.x,n.origin.y,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:r,y:i}),l={x:r,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=CI({type:"embeddable",...l}):s=tG({type:t,...l}),s.type==="selection"?this.setState({selectionElement:s}):(this.scene.insertElement(s),this.setState({multiElement:null,newElement:s}))});I(this,"createFrameElementOnPointerDown",(t,n)=>{let[r,i]=rt(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:r,y:i,opacity:this.state.currentItemOpacity,locked:!1,...Nn},l=n===Po.magicframe?SI(a):qH(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,n=this.scene.getElementsIncludingDeleted().map(r=>this.elementsPendingErasure.has(r.id)||r.frameId&&this.elementsPendingErasure.has(r.frameId)||Af(r)&&this.elementsPendingErasure.has(r.containerId)?(t=!0,Fn(r,{isDeleted:!0})):r);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(n))});I(this,"initializeImage",async(t,n)=>{if(!Am(n))throw new Error(g("errors.unsupportedFileType"));let r=n.type;if(ye(this.interactiveCanvas,"wait"),r===Mo.svg)try{n=Nm(FI(await n.text()),n.name)}catch(s){throw console.warn(s),new Error(g("errors.svgImageInsertError"))}let i=await(this.props.generateIdForFile?.(n)||_1(n));if(!i)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(g("errors.imageInsertError"));if(!this.files[i]?.dataURL){try{n=await jl(n,{maxWidthOrHeight:dH})}catch(s){console.error("Error trying to resizing image file on insertion",s)}if(n.size>hI)throw new Error(g("errors.fileTooBig",{maxSize:`${Math.trunc(hI/1024/1024)}MB`}))}let l=this.files[i]?.dataURL||await Rm(n);return new Promise(async(s,m)=>{try{let d=this.getLatestInitializedImageElement(t,i);if(this.addMissingFiles([{mimeType:r,id:i,dataURL:l,created:Date.now(),lastRetrieved:Date.now()}]),!this.imageCache.get(i)){this.addNewImagesToImageCache();let{erroredFiles:p}=await this.updateImageCache([d]);if(p.size)throw new Error("Image cache update resulted with an error.")}let c=await this.imageCache.get(i)?.image;if(c&&this.state.newElement?.id!==d.id){d=this.getLatestInitializedImageElement(t,i);let p=this.getImageNaturalDimensions(d,c);Object.assign(d,p)}s(d)}catch(d){console.error(d),m(new Error(g("errors.imageInsertError")))}})});I(this,"getLatestInitializedImageElement",(t,n)=>{let r=this.scene.getElement(t.id)??t;return Fn(r,{fileId:n})});I(this,"onImageToolbarButtonClick",async()=>{try{let t=this.state.width/2+this.state.offsetLeft,n=this.state.height/2+this.state.offsetTop,{x:r,y:i}=He({clientX:t,clientY:n},this.state),a=await Ul({description:"Image",extensions:Object.keys(uH),multiple:!0});this.insertImages(a,r,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:$o(this.state,{type:this.defaultSelectionTool})},()=>{this.actionManager.executeAction(_t)})}});I(this,"getImageNaturalDimensions",(t,n)=>{let r=Math.max(this.state.height-120,160),i=Math.min(r,Math.floor(this.state.height*.5)/this.state.zoom.value),a=Math.min(n.naturalHeight,i),l=a*(n.naturalWidth/n.naturalHeight),s=t.x+t.width/2-l/2,m=t.y+t.height/2-a/2;return{x:s,y:m,width:l,height:a,crop:null}});I(this,"updateImageCache",async(t,n=this.files)=>{let{updatedFiles:r,erroredFiles:i}=await uG({imageCache:this.imageCache,fileIds:t.map(a=>a.fileId),files:n});return i.size&&(this.store.scheduleAction(Et.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(a=>Ml(a)&&i.has(a.fileId)?Fn(a,{status:"error"}):a))),{updatedFiles:r,erroredFiles:i}});I(this,"addNewImagesToImageCache",async(t=pG(this.scene.getNonDeletedElements()),n=this.files)=>{let r=t.filter(i=>!i.isDeleted&&!this.imageCache.has(i.fileId));if(r.length){let{updatedFiles:i}=await this.updateImageCache(r,n);if(i.size)for(let a of r)i.has(a.fileId)&&Al.delete(a);i.size&&this.scene.triggerUpdate()}});I(this,"scheduleImageRefresh",rH(()=>{this.addNewImagesToImageCache()},hH));I(this,"updateBindingEnabledOnPointerMove",t=>{let n=jH(t);this.state.isBindingEnabled!==n&&this.setState({isBindingEnabled:n})});I(this,"maybeSuggestBindingAtCursor",(t,n)=>{let r=If(t,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,!1,n);this.setState({suggestedBindings:r!=null?[r]:[]})});I(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.interactiveCanvas.addEventListener(te.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(te.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener(te.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(te.TOUCH_END,this.onTouchEnd))});I(this,"insertImages",async(t,n,r)=>{let i=50/this.state.zoom.value,a=QI(t.map(()=>this.newImagePlaceholder({sceneX:n,sceneY:r})),n,r,i);a.forEach(p=>this.scene.insertElement(p));let l=await Promise.all(a.map(async(p,u)=>{try{return await this.initializeImage(p,await ia(t[u]))}catch(f){return this.setState({errorMessage:f.message||g("errors.imageInsertError")}),Fn(p,{isDeleted:!0})}})),s=fm(l),m=QI(l.filter(p=>!p.isDeleted),n,r,i),d=fm(m),c=this.scene.getElementsIncludingDeleted().map(p=>d.get(p.id)??s.get(p.id)??p);this.updateScene({appState:{selectedElementIds:ve(Object.fromEntries(m.map(p=>[p.id,!0])),this.state)},elements:c,captureUpdate:Et.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(_t)})});I(this,"handleAppOnDrop",async t=>{let{x:n,y:r}=He(t,this.state),i=await Oa(t),a=i.getFiles();if(a.length===1){let{file:c,fileHandle:p}=a[0];if(c&&(c.type===Mo.png||c.type===Mo.svg))try{let u=await $l(c,this.state,this.scene.getElementsIncludingDeleted(),p);this.syncActionResult({...u,appState:{...u.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:Et.IMMEDIATELY});return}catch(u){if(u.name!=="EncodingError")throw new Error(g("alerts.couldNotLoadInvalidFile"))}}let l=a.map(c=>c.file).filter(c=>Am(c));if(l.length>0&&this.isToolSupported("image"))return this.insertImages(l,n,r);let s=i.getData(Mo.excalidrawlibIds),m=i.getData(Mo.excalidrawlib);if(s||m){try{let c=null;if(s){let{itemIds:p}=JSON.parse(s);c=(await this.library.getLatestLibrary()).filter(f=>p.includes(f.id))}else m&&(c=D1(m));c?.length&&(c=c.map(p=>({...p,elements:Mf({type:"everything",elements:p.elements,randomizeSeed:!0}).duplicatedElements})),this.addElementsFromPasteOrLibrary({elements:Lc(c),position:t,files:null}))}catch(c){this.setState({errorMessage:c.message})}return}if(a.length>0){let{file:c,fileHandle:p}=a[0];c&&await this.loadFileToCanvas(c,p)}let d=i.findByType(Mo.text);if(d){let c=d.value;if(c&&Rf(c,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(c)||bm(c)?.type==="video")){let p=this.insertEmbeddableElement({sceneX:n,sceneY:r,link:yf(c)});p&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[p.id]:!0}}))}}});I(this,"loadFileToCanvas",async(t,n)=>{t=await ia(t);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await Dm(t,this.state,r,n)}catch(a){let l=a instanceof b1;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===Mo.excalidraw?(nC(r.concat(i.data.elements)),this.store.scheduleMicroAction({action:Et.NEVER,elements:r,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({...i.data,appState:{...i.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:Et.IMMEDIATELY})):i.type===Mo.excalidrawlib&&await this.library.updateLibrary({libraryItems:t,merge:!0,openLibraryMenu:!0}).catch(a=>{console.error(a),this.setState({errorMessage:g("errors.importLibraryError")})})}catch(r){this.setState({isLoading:!1,errorMessage:r.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!==hr.SECONDARY)&&this.state.activeTool.type!==this.defaultSelectionTool)return;let{x:n,y:r}=He(t,this.state),i=this.getElementAtPosition(n,r,{preferSelected:!0,includeLockedElements:!0}),a=this.scene.getSelectedElements(this.state),l=this.isHittingCommonBoundingBoxOfSelectedElements({x:n,y:r},a),s=i||l?"element":"canvas",m=this.excalidrawContainerRef.current,{top:d,left:c}=m.getBoundingClientRect(),p=t.clientX-c,u=t.clientY-d;re("contextMenu","openContextMenu",s),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,...qt({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:jt(i)?new Ie(i,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:p,items:this.getContextMenuItems(s)}})})});I(this,"maybeDragNewGenericElement",(t,n,r=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&this.state.activeTool.type!=="eraser"){$I({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:$i(t.origin.x,a.x),height:$i(t.origin.y,a.y),shouldMaintainAspectRatio:Cl(n),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let l=this.state.newElement;if(!l)return;let[s,m]=rt(a.x,a.y,n[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=Ml(l)&&this.imageCache.get(l.fileId)?.image,c=d&&!(d instanceof Promise)?d.width/d.height:null;this.maybeCacheReferenceSnapPoints(n,[l]);let{snapOffset:p,snapLines:u}=nv(l,this,n,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:s-t.originInGrid.x,y:m-t.originInGrid.y},this.scene.getNonDeletedElementsMap());s+=p.x,m+=p.y,this.setState({snapLines:u}),$I({newElement:l,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:s,y:m,width:$i(t.originInGrid.x,s),height:$i(t.originInGrid.y,m),shouldMaintainAspectRatio:br(l)?!Cl(n):Cl(n),shouldResizeFromCenter:mI(n),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:c,originOffset:this.state.originSnapOffset,informMutation:r}),this.setState({newElement:l}),(this.state.activeTool.type===Po.frame||this.state.activeTool.type===Po.magicframe)&&this.setState({elementsToHighlight:zf(this.scene.getNonDeletedElements(),l,this.state,this.scene.getNonDeletedElementsMap())})});I(this,"maybeHandleCrop",(t,n)=>{if(!this.state.croppingElementId)return!1;let r=t.resize.handleType,i=t.lastCoords,[a,l]=rt(i.x-t.resize.offset.x,i.y-t.resize.offset.y,n[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(r&&s&&br(s)){let m=t.originalElements.get(s.id),d=Ml(s)&&this.imageCache.get(s.fileId)?.image;if(m&&br(m)&&d&&!(d instanceof Promise)){let[c,p]=rt(i.x,i.y,n[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:c-t.originInGrid.x,y:p-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(n,[s]);let{snapOffset:f,snapLines:b}=qh([s],[m],this,n,u,r);this.scene.mutateElement(s,PG(s,this.scene.getNonDeletedElementsMap(),r,d.naturalWidth,d.naturalHeight,a+f.x,l+f.y,n.shiftKey?m.width/m.height:void 0)),Sf(s,this.scene,{newSize:{width:s.width,height:s.height}}),this.setState({isCropping:r&&r!=="rotation",snapLines:b})}return!0}return!1});I(this,"maybeHandleResize",(t,n)=>{let r=this.scene.getSelectedElements(this.state),i=r.filter(c=>kt(c)),a=t.resize.handleType;if(i.length>0&&a==="rotation"||r.length===1&&Xe(r[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let l=t.lastCoords,[s,m]=rt(l.x-t.resize.offset.x,l.y-t.resize.offset.y,n[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=new Map;if(i.forEach(c=>{Ff(this.scene.getNonDeletedElements(),c.id).forEach(u=>{d.set(c.id+u.id,{x:u.x-c.x,y:u.y-c.y})})}),!this.state.selectedElementsAreBeingDragged){let[c,p]=rt(l.x,l.y,n[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:c-t.originInGrid.x,y:p-t.originInGrid.y},f=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(n,r);let{snapOffset:b,snapLines:x}=qh(r,j(f,this.state),this,n,u,a);s+=b.x,m+=b.y,this.setState({snapLines:x})}if(KG(t.originalElements,a,r,this.scene,xf(n),mI(n),r.some(c=>br(c))?!Cl(n):Cl(n),s,m,t.resize.center.x,t.resize.center.y)){let c=kf(r,this.scene.getNonDeletedElementsMap(),this.state.zoom),p=new Set;return i.forEach(u=>{zf(this.scene.getNonDeletedElements(),u,this.state,this.scene.getNonDeletedElementsMap()).forEach(f=>p.add(f))}),this.setState({elementsToHighlight:[...p],suggestedBindings:c}),!0}return!1});I(this,"getContextMenuItems",t=>{let n=[];return n.push(gc,hc),t==="canvas"?this.state.viewModeEnabled?[...n,bc,mi,Wh,pi]:[Tu,Ve,gc,hc,fc,Ve,gp,vy,Ve,bc,Iu,mi,Wh,pi]:(n.push(fc),this.state.viewModeEnabled?[di,...n]:[Ve,uc,di,Tu,Ve,Nw,Bw,Fw,Ve,Hh,Ve,...n,Ve,pu,uu,Ve,fu,Ww,ku,Mu,ly,bu,Ve,yu,Ve,mp,pp,up,hp,Ve,wu,vu,Ve,Di,Ve,Ya,Cc,Ve,fp,Wa,Ve,fa])});I(this,"handleWheel",Ae(t=>{if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement)){t[V.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),Rl)return;let{deltaX:n,deltaY:r}=t;if(t.metaKey||t.ctrlKey){let i=Math.sign(r),a=TH*100,l=Math.abs(r),s=r;l>a&&(s=a*i);let m=this.state.zoom.value-s/100;m+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,l/20),this.translateCanvas(d=>({...Bo({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:ho(m)},d),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.translateCanvas(({zoom:i,scrollX:a})=>({scrollX:a-(r||n)/i.value}));return}this.translateCanvas(({zoom:i,scrollX:a,scrollY:l})=>({scrollX:a-n/i.value,scrollY:l-r/i.value}))}));I(this,"savePointer",(t,n,r)=>{if(!t||!n)return;let{x:i,y:a}=He({clientX:t,clientY:n},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:r,pointersMap:ge.pointers})});I(this,"resetShouldCacheIgnoreZoomDebounced",xI(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));I(this,"updateDOMRect",t=>{if(this.excalidrawContainerRef?.current){let n=this.excalidrawContainerRef.current,{width:r,height:i,left:a,top:l}=n.getBoundingClientRect(),{width:s,height:m,offsetTop:d,offsetLeft:c}=this.state;if(r===s&&i===m&&a===c&&l===d){t&&t();return}this.setState({width:r,height:i,offsetLeft:a,offsetTop:l},()=>{t&&t()})}});I(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});let n=Qo();this.defaultSelectionTool=fr()?"lasso":"selection";let{excalidrawAPI:r,viewModeEnabled:i=!1,zenModeEnabled:a=!1,gridModeEnabled:l=!1,objectsSnapModeEnabled:s=!1,theme:m=n.theme,name:d=`${g("labels.untitled")}-${yI()}`}=t;if(this.state={...n,theme:m,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:i,zenModeEnabled:a,objectsSnapModeEnabled:s,gridModeEnabled:l??n.gridModeEnabled,name:d,width:window.innerWidth,height:window.innerHeight},this.id=aH(),this.library=new Zy(this),this.actionManager=new cd(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new qI,this.canvas=document.createElement("canvas"),this.rc=iH.canvas(this.canvas),this.renderer=new pl(this.scene),this.visibleElements=[],this.store=new jG(this),this.history=new ll(this.store),r){let c={updateScene:this.updateScene,applyDeltas:this.applyDeltas,mutateElement:this.mutateElement,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},scrollToContent:this.scrollToContent,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:p=>{this.actionManager.registerAction(p)},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:p=>this.onChangeEmitter.on(p),onIncrement:p=>this.store.onStoreIncrementEmitter.on(p),onPointerDown:p=>this.onPointerDownEmitter.on(p),onPointerUp:p=>this.onPointerUpEmitter.on(p),onScrollChange:p=>this.onScrollChangeEmitter.on(p),onUserFollow:p=>this.onUserFollowEmitter.on(p)};typeof r=="function"?r(c):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new Jo(this.scene),this.history=new ll(this.store),this.actionManager.registerAll(xs),this.actionManager.registerAction(Hw(this.history)),this.actionManager.registerAction(Gw(this.history))}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let n=null;try{n=JSON.parse(t.data)}catch{}if(n)switch(t.origin){case"https://player.vimeo.com":if(n.method==="paused"){let r=null,i=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!i)break;for(let a of i)a.contentWindow===t.source&&(r=a.contentWindow);r?.postMessage(JSON.stringify({method:n.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(n.event==="infoDelivery"&&n.info&&n.id&&typeof n.info.playerState=="number"){let r=n.id,i=n.info.playerState;Object.values(hm).includes(i)&&Wf.set(r,i)}break}}cacheEmbeddableRef(t,n){n&&this.iFrameRefs.set(t.id,n)}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),qi(t)))return;let n=this.getHTMLIFrameElement(t);if(n?.contentWindow){if(n.src.includes("youtube")){let r=Wf.get(t.id);switch(r||(Wf.set(t.id,hm.UNSTARTED),n.contentWindow.postMessage(JSON.stringify({event:"listening",id:t.id}),"*")),r){case hm.PLAYING:case hm.BUFFERING:n.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:n.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}n.src.includes("player.vimeo.com")&&n.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*")}}isIframeLikeElementCenter(t,n,r,i){return t&&!n.altKey&&!n.shiftKey&&!n.metaKey&&!n.ctrlKey&&(this.state.activeEmbeddable?.element!==t||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&r>=t.x+t.width/3&&r<=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,n=this.state.width,r=this.state.height,i=this.scene.getNonDeletedElements().filter(a=>jo(a)&&this.embedsValidationStatus.get(a.id)===!0||qi(a));return fe(eU,{children:i.map(a=>{let{x:l,y:s}=gm({sceneX:a.x,sceneY:a.y},this.state),m=_I(a,n,r,this.state,this.scene.getNonDeletedElementsMap()),d=this.initializedEmbeds.has(a.id);if(m&&!d&&this.initializedEmbeds.add(a.id),!(m||d))return null;let p;if(qi(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:()=>BI(`
|
|
19
26
|
<style>
|
|
20
27
|
html, body {
|
|
21
28
|
width: 100%;
|
|
22
29
|
height: 100%;
|
|
23
|
-
color: ${this.state.theme===
|
|
30
|
+
color: ${this.state.theme===um.DARK?"white":"black"};
|
|
24
31
|
}
|
|
25
32
|
body {
|
|
26
33
|
display: flex;
|
|
@@ -87,7 +94,7 @@ TTD mermaid definition render errror: ${_.message}`,"color: yellow"),fe("ai","me
|
|
|
87
94
|
</svg>
|
|
88
95
|
</div>
|
|
89
96
|
<div>Generating...</div>
|
|
90
|
-
`)};else{let b
|
|
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:()=>BI(`
|
|
91
98
|
<style>
|
|
92
99
|
html, body {
|
|
93
100
|
height: 100%;
|
|
@@ -97,7 +104,7 @@ TTD mermaid definition render errror: ${_.message}`,"color: yellow"),fe("ai","me
|
|
|
97
104
|
flex-direction: column;
|
|
98
105
|
align-items: center;
|
|
99
106
|
justify-content: center;
|
|
100
|
-
color: ${
|
|
107
|
+
color: ${sH.red[3]};
|
|
101
108
|
}
|
|
102
109
|
h1, h3 {
|
|
103
110
|
margin-top: 0;
|
|
@@ -105,8 +112,8 @@ TTD mermaid definition render errror: ${_.message}`,"color: yellow"),fe("ai","me
|
|
|
105
112
|
}
|
|
106
113
|
</style>
|
|
107
114
|
<h1>Error!</h1>
|
|
108
|
-
<h3>${
|
|
109
|
-
`)}}}else p=pi(Cc(a.link||""));let u=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="active",h=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="hover";return Re("div",{className:cT("excalidraw__embeddable-container",{"is-hovered":h}),style:{transform:c?`translate(${l-this.state.offsetLeft}px, ${s-this.state.offsetTop}px) scale(${o})`:"none",display:c?"block":"none",opacity:E0(a,di(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?j1:1),"--embeddable-radius":`${A0(Math.min(a.width,a.height),a)}px`},children:Np("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?$n.enabled:$n.disabled},children:[h&&Re("div",{className:"excalidraw__embeddable-hint",children:f("buttons.embeddableInteractionButton")}),Re("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:(Zt(a)?this.props.renderEmbeddable?.(a,this.state):null)??Re("iframe",{ref:x=>this.cacheEmbeddableRef(a,x),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(o){document.documentElement.style.overscrollBehaviorX=o.type==="pointerenter"?"none":"auto"}render(){let o=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,pendingImageElementId:this.state.pendingImageElementId});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=o[0],d=Fe.get(sr)?.type==="panel";return Re("div",{className:cT("excalidraw excalidraw-container",{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.device.editor.isMobile}),style:{"--ui-pointerEvents":c?$n.disabled:$n.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:Re(pT.Provider,{value:this,children:Re(uT.Provider,{value:this.props,children:Re(o1.Provider,{value:this.excalidrawContainerValue,children:Re(t1.Provider,{value:this.device,children:Re(i1.Provider,{value:this.setAppState,children:Re(n1.Provider,{value:this.state,children:Np(r1.Provider,{value:this.scene.getNonDeletedElements(),children:[Np(a1.Provider,{value:this.actionManager,children:[Re(q5,{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:Yr().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}),Re("div",{className:"excalidraw-textEditorContainer"}),Re("div",{className:"excalidraw-contextMenuContainer"}),Re("div",{className:"excalidraw-eye-dropper-container"}),Re(eT,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail]}),o.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&Re(ev,{element:m,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},m.id),this.props.aiEnabled!==!1&&o.length===1&&Ic(m)&&Re(pf,{element:m,elementsMap:a,children:Re(Pp,{title:f("labels.convertToCode"),icon:Rd,checked:!1,onChange:()=>this.onMagicFrameGenerate(m,"button")})}),o.length===1&&ri(m)&&m.customData?.generationData?.status==="done"&&Np(pf,{element:m,elementsMap:a,children:[Re(Pp,{title:f("labels.copySource"),icon:wa,checked:!1,onChange:()=>this.onIframeSrcCopy(m)}),Re(Pp,{title:"Enter fullscreen",icon:jE,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&&Re(sT,{message:this.state.toast.message,onClose:()=>this.setToast(null),duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&Re(r3,{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?.()})}}),Re(jf,{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:Rn(this),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowChartCreator.pendingNodes}}),this.state.newElement&&Re(aT,{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}}),Re($f,{containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:a,visibleElements:l,allElementsMap:s,selectedElements:o,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&&Re(i3,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames(),d&&Re(sv,{app:this})]}),this.renderEmbeddables()]})})})})})})})})}setPlugins(o){Object.assign(this.plugins,o)}async onMagicFrameGenerate(o,r){let n=this.plugins.diagramToCode?.generate;if(!n){this.setState({errorMessage:"No diagram to code plugin found"});return}let i=Fc(this.scene.getNonDeletedElements(),o).filter(l=>!Ic(l));if(!i.length){r==="button"?(this.setState({errorMessage:"Cannot generate from an empty frame"}),fe("ai","generate (no-children)","d2c")):this.setActiveTool({type:"magicframe"});return}let a=this.insertIframeElement({sceneX:o.x+o.width+30,sceneY:o.y,width:o.width,height:o.height});if(a){this.updateMagicGeneration({frameElement:a,data:{status:"pending"}}),this.setState({selectedElementIds:{[a.id]:!0}}),fe("ai","generate (start)","d2c");try{let{html:l}=await n({frame:o,children:i});if(fe("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){fe("ai","generate (failed)","d2c"),this.updateMagicGeneration({frameElement:a,data:{status:"error",code:"ERR_OAI",message:l.message||"Unknown error during generation"}})}}}onIframeSrcCopy(o){o.customData?.generationData?.status==="done"&&(lr(o.customData.generationData.html),this.setToast({message:"copied to clipboard",closable:!1,duration:1500}))}clearImageShapeCache(o){let r=o??this.files;this.scene.getNonDeletedElements().forEach(n=>{Fr(n)&&r[n.fileId]&&(this.imageCache.delete(n.fileId),Er.delete(n))})}async componentDidMount(){if(this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,et()||Oe()){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:o}=this.props;o&&this.store.onStoreIncrementEmitter.on(n=>{o(n)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),et()||(this.refreshViewportBreakpoints(),this.refreshEditorBreakpoints()),bl&&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),M1()&&!Vb()&&this.setState({errorMessage:Re(Qw,{})})}componentWillUnmount(){window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new Ei,this.fonts=new vn(this.scene),this.renderer=new _s(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(),Er.destroy(),zo.destroy(),clearTimeout(Yn),Ue.clearCache(),ht.clearCache(),Yn=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(Ze(document,"keydown",this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(Ze(this.excalidrawContainerRef.current,"wheel",this.handleWheel,{passive:!1}),Ze(window,"message",this.onWindowMessage,!1),Ze(document,"pointerup",this.removePointer,{passive:!1}),Ze(document,"copy",this.onCopy,{passive:!1}),Ze(document,"keyup",this.onKeyUp,{passive:!0}),Ze(document,"pointermove",this.updateCurrentCursorPosition,{passive:!1}),Ze(document.fonts,"loadingdone",o=>{let r=o.fontfaces;this.fonts.onLoaded(r)},{passive:!1}),Ze(document,"gesturestart",this.onGestureStart,!1),Ze(document,"gesturechange",this.onGestureChange,!1),Ze(document,"gestureend",this.onGestureEnd,!1),Ze(window,"focus",()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(Ze(document,"fullscreenchange",this.onFullscreenChange,{passive:!1}),Ze(document,"paste",this.pasteFromClipboard,{passive:!1}),Ze(document,"cut",this.onCut,{passive:!1}),Ze(window,"resize",this.onResize,!1),Ze(window,"unload",this.onUnload,!1),Ze(window,"blur",this.onBlur,!1),Ze(this.excalidrawContainerRef.current,"wheel",this.handleWheel,{passive:!1}),Ze(this.excalidrawContainerRef.current,"dragover",this.disableEvent,!1),Ze(this.excalidrawContainerRef.current,"drop",this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(Ze(db(this.excalidrawContainerRef.current),"scroll",this.onScroll,{passive:!1})))}componentDidUpdate(o,r){this.updateEmbeddables();let n=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted(),a=this.scene.getNonDeletedElementsMap();!this.state.showWelcomeScreen&&!n.length&&this.setState({showWelcomeScreen:!0}),o.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&&co(this.state)&&this.setState({activeTool:Ne(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&r.theme!==this.state.theme&&og(this.interactiveCanvas,this.state.theme),r.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),o.langCode!==this.props.langCode&&this.updateLanguage(),co(r)&&!co(this.state)&&this.eraserTrail.endPath(),o.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:{}})),o.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),o.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===se.DARK),this.state.editingLinearElement&&!this.state.selectedElementIds[this.state.editingLinearElement.elementId]&&setTimeout(()=>{this.state.editingLinearElement&&this.actionManager.executeAction(ko)}),this.state.editingTextElement?.isDeleted&&this.setState({editingTextElement:null}),this.state.selectedLinearElement&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&this.setState({selectedLinearElement:null});let{multiElement:s}=r;r.activeTool!==this.state.activeTool&&s!=null&&mi(this.state)&&zr(s,!1)&&Ol(s,this.state,mn($.getPointAtIndexGlobalCoordinates(s,-1,a)),this.scene),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(){Vs=!1}async addElementsFromMixedContentPaste(o,{isPlainPaste:r,sceneX:n,sceneY:i}){if(!r&&o.some(a=>a.type==="imageUrl")&&this.isToolSupported("image")){let a=o.filter(p=>p.type==="imageUrl").map(p=>p.value),l=await Promise.all(a.map(async p=>{try{return{file:await sx(p)}}catch(u){let h=u.message;return u.cause==="FETCH_ERROR"?h=f("errors.failedToFetchImage"):u.cause==="UNSUPPORTED"&&(h=f("errors.unsupportedFileType")),{errorMessage:h}}})),s=i,c=!1,m={};for(let p of l)if(p.file){let u=this.createImageElement({sceneX:n,sceneY:s}),h=await this.insertImageElement(u,p.file);h&&(c||(c=!0,s-=h.height/2),this.scene.mutateElement(h,{y:s},{informMutation:!1,isDragging:!1}),s=u.y+u.height+25,m[u.id]=!0)}this.setState({selectedElementIds:Me(m,this.state)});let d=l.find(p=>!!p.errorMessage);d&&d.errorMessage&&this.setState({errorMessage:d.errorMessage})}else{let a=o.filter(l=>l.type==="text");a.length&&this.addTextFromPaste(a.map(l=>l.value).join(`
|
|
115
|
+
<h3>${x}</h3>
|
|
116
|
+
`)}}}else p=bm(PH(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 fe("div",{className:rI("excalidraw__embeddable-container",{"is-hovered":f}),style:{transform:m?`translate(${l-this.state.offsetLeft}px, ${s-this.state.offsetTop}px) scale(${t})`:"none",display:m?"block":"none",opacity:OG(a,Hf(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?SH:1),"--embeddable-radius":`${dG(Math.min(a.width,a.height),a)}px`},children:Em("div",{className:"excalidraw__embeddable-container__inner",style:{width:m?`${a.width}px`:0,height:m?`${a.height}px`:0,transform:m?`rotate(${a.angle}rad)`:"none",pointerEvents:u?Zi.enabled:Zi.disabled},children:[f&&fe("div",{className:"excalidraw__embeddable-hint",children:g("buttons.embeddableInteractionButton")}),fe("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:(jo(a)?this.props.renderEmbeddable?.(a,this.state):null)??fe("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:n,renderCustomStats:r}=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(),m="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],c=Ue.get(ao)?.type==="panel";return fe("div",{className:rI("excalidraw excalidraw-container",{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.device.editor.isMobile}),style:{"--ui-pointerEvents":m?Zi.disabled:Zi.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:fe(rC.Provider,{value:this,children:fe(iC.Provider,{value:this.props,children:fe($f.Provider,{value:this.excalidrawContainerValue,children:fe(Zf.Provider,{value:this.device,children:fe(Jf.Provider,{value:this.setAppState,children:fe(qf.Provider,{value:this.state,children:Em(jf.Provider,{value:this.scene.getNonDeletedElements(),children:[Em(Qf.Provider,{value:this.actionManager,children:[fe(U5,{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:Do().code,renderTopRightUI:n,renderCustomStats:r,showExitZenModeBtn:typeof this.props?.zenModeEnabled>"u"&&this.state.zenModeEnabled,UIOptions:this.props.UIOptions,onExportImage:this.onExportImage,renderWelcomeScreen:!this.state.isLoading&&this.state.showWelcomeScreen&&this.state.activeTool.type===this.defaultSelectionTool&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,children:this.props.children}),fe("div",{className:"excalidraw-textEditorContainer"}),fe("div",{className:"excalidraw-contextMenuContainer"}),fe("div",{className:"excalidraw-eye-dropper-container"}),fe(V5,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail]}),t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&fe(hy,{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&&Df(d)&&fe(dg,{element:d,elementsMap:a,children:fe(dm,{title:g("labels.convertToCode"),icon:hs,checked:!1,onChange:()=>this.onMagicFrameGenerate(d,"button")})}),t.length===1&&qi(d)&&d.customData?.generationData?.status==="done"&&Em(dg,{element:d,elementsMap:a,children:[fe(dm,{title:g("labels.copySource"),icon:Rr,checked:!1,onChange:()=>this.onIframeSrcCopy(d)}),fe(dm,{title:"Enter fullscreen",icon:cb,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&&fe(oI,{message:this.state.toast.message,onClose:this.handleToastClose,duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&fe(i3,{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?.()})}}),fe(gf,{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:yn(this),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowChartCreator.pendingNodes}}),this.state.newElement&&fe(eI,{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}}),fe(hf,{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&&fe(l3,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames(),this.state.activeLockedId&&fe(nI,{app:this,activeLockedId:this.state.activeLockedId}),c&&fe(Ay,{app:this})]}),this.renderEmbeddables()]})})})})})})})})}setPlugins(t){Object.assign(this.plugins,t)}async onMagicFrameGenerate(t,n){let r=this.plugins.diagramToCode?.generate;if(!r){this.setState({errorMessage:"No diagram to code plugin found"});return}let i=vG(this.scene.getNonDeletedElements(),t).filter(l=>!Df(l));if(!i.length){n==="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 r({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"&&(ro(t.customData.generationData.html),this.setToast({message:"copied to clipboard",closable:!1,duration:1500}))}clearImageShapeCache(t){let n=t??this.files;this.scene.getNonDeletedElements().forEach(r=>{Ml(r)&&n[r.fileId]&&(this.imageCache.delete(r.fileId),Al.delete(r))})}async componentDidMount(){if(this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,Xf()||oC()){let r=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(r=>{this.history.record(r.delta)});let{onIncrement:t}=this.props;t&&this.store.onStoreIncrementEmitter.on(r=>{t(r)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),Xf()||(this.refreshViewportBreakpoints(),this.refreshEditorBreakpoints()),gI&&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),gH()&&!DG()&&this.setState({errorMessage:fe(t3,{})})}componentWillUnmount(){window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new qI,this.fonts=new Jo(this.scene),this.renderer=new pl(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(),Al.destroy(),Xt.destroy(),clearTimeout(On),we.clearCache(),qt.clearCache(),On=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(Re(document,te.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(Re(this.excalidrawContainerRef.current,te.WHEEL,this.handleWheel,{passive:!1}),Re(window,te.MESSAGE,this.onWindowMessage,!1),Re(document,te.POINTER_UP,this.removePointer,{passive:!1}),Re(document,te.COPY,this.onCopy,{passive:!1}),Re(document,te.KEYUP,this.onKeyUp,{passive:!0}),Re(document,te.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),Re(document.fonts,"loadingdone",t=>{let n=t.fontfaces;this.fonts.onLoaded(n)},{passive:!1}),Re(document,te.GESTURE_START,this.onGestureStart,!1),Re(document,te.GESTURE_CHANGE,this.onGestureChange,!1),Re(document,te.GESTURE_END,this.onGestureEnd,!1),Re(window,te.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(Re(document,te.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),Re(document,te.PASTE,this.pasteFromClipboard,{passive:!1}),Re(document,te.CUT,this.onCut,{passive:!1}),Re(window,te.RESIZE,this.onResize,!1),Re(window,te.UNLOAD,this.onUnload,!1),Re(window,te.BLUR,this.onBlur,!1),Re(this.excalidrawContainerRef.current,te.WHEEL,this.handleWheel,{passive:!1}),Re(this.excalidrawContainerRef.current,te.DRAG_OVER,this.disableEvent,!1),Re(this.excalidrawContainerRef.current,te.DROP,this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(Re(LH(this.excalidrawContainerRef.current),te.SCROLL,this.onScroll,{passive:!1})))}componentDidUpdate(t,n){this.updateEmbeddables();let r=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted();!this.state.showWelcomeScreen&&!r.length&&this.setState({showWelcomeScreen:!0}),t.UIOptions.dockedSidebarBreakpoint!==this.props.UIOptions.dockedSidebarBreakpoint&&this.refreshEditorBreakpoints(),n.userToFollow&&!this.state.collaborators.has(n.userToFollow.socketId)&&this.maybeUnfollowRemoteUser(),(n.zoom.value!==this.state.zoom.value||n.scrollX!==this.state.scrollX||n.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)),n.userToFollow!==this.state.userToFollow&&(n.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:n.userToFollow,action:"UNFOLLOW"}),this.state.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:this.state.userToFollow,action:"FOLLOW"})),Object.keys(this.state.selectedElementIds).length&&yt(this.state)&&this.setState({activeTool:$o(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&n.theme!==this.state.theme&&qp(this.interactiveCanvas,this.state.theme),n.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),t.langCode!==this.props.langCode&&this.updateLanguage(),yt(n)&&!yt(this.state)&&this.eraserTrail.endPath(),t.viewModeEnabled!==this.props.viewModeEnabled&&this.setState({viewModeEnabled:!!this.props.viewModeEnabled}),n.viewModeEnabled!==this.state.viewModeEnabled&&(this.addEventListeners(),this.deselectElements()),(n.openDialog?.name==="elementLinkSelector"||this.state.openDialog?.name==="elementLinkSelector")&&n.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===um.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(_t)}),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?.(r,this.state,this.files),this.onChangeEmitter.trigger(r,this.state,this.files))}static resetTapTwice(){Dl=!1,_l=null}async insertClipboardContent(t,n,r){let{x:i,y:a}=He({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state);if(t.errorMessage){this.setState({errorMessage:t.errorMessage});return}if(n.length===0&&!r&&t.mixedContent){await this.addElementsFromMixedContentPaste(t.mixedContent,{isPlainPaste:r,sceneX:i,sceneY:a});return}if(t.spreadsheet&&!r){this.setState({pasteDialog:{data:t.spreadsheet,shown:!0}});return}let l=n.map(d=>d.file);if(l.length===0&&t.text&&!r){let d=t.text.trim();d.startsWith("<svg")&&d.endsWith("</svg>")&&l.push(Nm(d))}if(l.length>0){this.isToolSupported("image")?await this.insertImages(l,i,a):this.setState({errorMessage:g("errors.imageToolNotSupported")});return}if(t.elements){let d=t.programmaticAPI?Ni(t.elements):t.elements;this.addElementsFromPasteOrLibrary({elements:d,files:t.files||null,position:fr()?"center":"cursor",retainSeed:r});return}if(!t.text)return;if(!r&&zv(t.text)){let d=await import("@excalidraw/mermaid-to-excalidraw");try{let{elements:c,files:p}=await d.parseMermaidToExcalidraw(t.text),u=Ni(c,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:u,files:p,position:fr()?"center":"cursor"});return}catch(c){console.warn(`parsing pasted text as mermaid definition failed: ${c.message}`)}}let s=OH(t.text).split(/\n+/).map(d=>d.trim()).filter(Boolean),m=s.map(d=>mG(d)).filter(d=>Rf(d,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(d)||bm(d)?.type==="video"));if(!r&&m.length>0&&m.length===s.length){let d=[];for(let c of m){let p=d[d.length-1],u=this.insertEmbeddableElement({sceneX:p?p.x+p.width+20:i,sceneY:a,link:yf(c)});u&&d.push(u)}d.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(d.map(c=>[c.id,!0]))}));return}this.addTextFromPaste(t.text,r)}async addElementsFromMixedContentPaste(t,{isPlainPaste:n,sceneX:r,sceneY:i}){if(!n&&t.some(a=>a.type==="imageUrl")&&this.isToolSupported("image")){let a=t.filter(d=>d.type==="imageUrl").map(d=>d.value),l=await Promise.all(a.map(async d=>{try{return{file:await B1(d)}}catch(c){let p=c.message;return c.cause==="FETCH_ERROR"?p=g("errors.failedToFetchImage"):c.cause==="UNSUPPORTED"&&(p=g("errors.unsupportedFileType")),{errorMessage:p}}})),s=l.filter(d=>!!d.file).map(d=>d.file);await this.insertImages(s,r,i);let m=l.find(d=>!!d.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
|
-
`),
|
|
112
|
-
`),x=h.reduce((b,E,w)=>{let y=li(E).trim();if(y.length){let v=this.getTopLayerFrameAtSceneCoords({x:n,y:u}),C=ut(y,l,s),I=C.width>d,L=I?fn(y,l,d):y;C=I?ut(L,l,s):C;let A=n-C.width/2,R=u-C.height/2,_=Xt({...a,x:A,y:R,text:L,originalText:y,lineHeight:s,autoResize:!I,frameId:v?v.id:null});b.push(_),u+=_.height+p}else h[w-1]?.trim()&&(u+=Yb(a.fontSize,s)+p);return b},[]);x.length!==0&&(this.scene.insertElements(x),this.setState({selectedElementIds:Me(Object.fromEntries(x.map(b=>[b.id,!0])),this.state)}),!r&&x.length>1&&mT===!1&&!this.device.editor.isMobile&&(this.setToast({message:f("toast.pasteAsSingleElement",{shortcut:N("CtrlOrCmd+Shift+V")}),duration:5e3}),mT=!0),this.store.scheduleCapture())}handleTextWysiwyg(o,{isExistingElement:r=!1}){let n=this.scene.getElementsMapIncludingDeleted(),i=(a,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(s=>s.id===o.id&&K(s)?re(s,{originalText:a,isDeleted:l??s.isDeleted,...P0(s,Ut(s,n),n,a)}):s)])};Xw({id:o.id,canvas:this.canvas,getViewportCoords:(a,l)=>{let{x:s,y:c}=Pt({sceneX:a,sceneY:l},this.state);return[s-this.state.offsetLeft,c-this.state.offsetTop]},onChange:rt(a=>{i(a,!1),Yl(o)&>(o,this.scene)}),onSubmit:rt(({viaKeyboard:a,nextOriginalText:l})=>{let s=!l.trim();if(i(l,s),!s&&a){let c=o.containerId?o.containerId:o.id;Vn(()=>{this.setState(m=>({selectedElementIds:Me({...m.selectedElementIds,[c]:!0},m)}))})}s&&Vc(this.scene.getNonDeletedElements(),[o]),(!s||r)&&this.store.scheduleCapture(),Vn(()=>{this.setState({newElement:null,editingTextElement:null})}),this.state.activeTool.locked&&Io(this.interactiveCanvas,this.state),this.focusContainer()}),element:o,excalidrawContainer:this.excalidrawContainerRef.current,app:this,autoSelect:!this.device.isTouchScreen}),this.deselectElements(),i(o.originalText,!1)}deselectElements(){this.setState({selectedElementIds:Me({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(o,r){let n=this.getElementAtPosition(o,r,{includeBoundTextElement:!0});return n&&K(n)&&!n.isDeleted?n:null}getElementAtPosition(o,r,n){let i=this.getElementsAtPosition(o,r,n?.includeBoundTextElement,n?.includeLockedElements);if(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 $i({x:o,y:r,element:a,shape:Ur(a,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()/2,frameNameBound:J(a)?this.frameNameBoundsCache.get(a):null})?a:i[i.length-2]}return i.length===1?i[0]:null}getElementsAtPosition(o,r,n=!1,i=!1){let a=[],l=this.scene.getNonDeletedElementsMap();return(n&&i?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(c=>(i||!c.locked)&&(n||!(K(c)&&c.containerId)))).filter(c=>this.hitElement(o,r,c)).filter(c=>{let m=di(c,l);return m&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?bu({x:o,y:r},m,l):!0}).filter(c=>ri(c)?(a.push(c),!1):!0).concat(a)}getElementHitThreshold(){return _1/this.state.zoom.value}hitElement(o,r,n,i=!0){if(i&&this.state.selectedElementIds[n.id]&&md([n],this.state)){let l=D0(n,this.scene.getNonDeletedElementsMap(),xe(n)?0:this.getElementHitThreshold());if(Zc(M(o,r),l))return!0}return _b(o,r,k0(n,this.scene.getNonDeletedElementsMap()))?!0:$i({x:o,y:r,element:n,shape:Ur(n,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold(),frameNameBound:J(n)?this.frameNameBoundsCache.get(n):null})}getTextBindableContainerAtPosition(o,r){let n=this.scene.getNonDeletedElements(),i=this.scene.getSelectedElements(this.state);if(i.length===1)return Hr(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]=Ve(n[l],this.scene.getNonDeletedElementsMap());if(Ie(n[l])&&$i({x:o,y:r,element:n[l],shape:Ur(n[l],this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()})){a=n[l];break}else if(s<o&&o<m&&c<r&&r<d){a=n[l];break}}return Hr(a,!1)?a:null}handleHoverSelectedLinearElement(o,r,n){let i=this.scene.getNonDeletedElementsMap(),a=$.getElement(o.elementId,i);if(a)if(this.state.selectedLinearElement){let l=-1,s=null;$i({x:r,y:n,element:a,shape:Ur(a,this.scene.getNonDeletedElementsMap())})?(l=$.getPointIndexUnderCursor(a,i,this.state.zoom,r,n),s=$.getSegmentMidpointHitCoords(o,{x:r,y:n},this.state,this.scene.getNonDeletedElementsMap()),(ee(a)?l===0||l===a.points.length-1:l>=0)||s?Le(this.interactiveCanvas,Ce.POINTER):this.hitElement(r,n,a)&&(!ee(a)||!(a.startBinding||a.endBinding))&&Le(this.interactiveCanvas,Ce.MOVE)):this.hitElement(r,n,a)&&(!ee(a)||!(a.startBinding||a.endBinding))&&Le(this.interactiveCanvas,Ce.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 Le(this.interactiveCanvas,Ce.AUTO)}updateGestureOnPointerDown(o){De.pointers.set(o.pointerId,{x:o.clientX,y:o.clientY}),De.pointers.size===2&&(De.lastCenter=of(De.pointers),De.initialScale=this.state.zoom.value,De.initialDistance=rf(Array.from(De.pointers.values())))}initialPointerDownState(o){let r=Ke(o,this.state),n=this.scene.getSelectedElements(this.state),[i,a,l,s]=Ee(n),c=n.findIndex(ee)===0;return{origin:r,withCmdOrCtrl:o[T.CTRL_OR_CMD],originInGrid:mn(mt(r.x,r.y,o[T.CTRL_OR_CMD]||c?null:this.getEffectiveGridSize())),scrollbars:sf(Ws,o.clientX-this.state.offsetLeft,o.clientY-this.state.offsetTop),lastCoords:{...r},originalElements:this.scene.getNonDeletedElements().reduce((m,d)=>(m.set(d.id,mo(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(o,r){if(!(r.scrollbars.isOverEither&&!this.state.multiElement))return!1;Jf=!0,r.lastCoords.x=o.clientX,r.lastCoords.y=o.clientY;let n=Qm(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,r)}),i=rt(()=>{Zs=null,Jf=!1,Io(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(o.clientX,o.clientY,"up"),window.removeEventListener("pointermove",n),window.removeEventListener("pointerup",i),n.flush()});return Zs=i,window.addEventListener("pointermove",n),window.addEventListener("pointerup",i),!0}isASelectedElement(o){return o!=null&&this.state.selectedElementIds[o.id]}isHittingCommonBoundingBoxOfSelectedElements(o,r){if(r.length<2)return!1;let n=this.getElementHitThreshold(),[i,a,l,s]=Ee(r);return o.x>i-n&&o.x<l+n&&o.y>a-n&&o.y<s+n}getCurrentItemRoundness(o){return this.state.currentItemRoundness==="round"?{type:gn(o)?Ct.ADAPTIVE_RADIUS:Ct.PROPORTIONAL_RADIUS}:null}maybeCacheReferenceSnapPoints(o,r,n=!1){qr({event:o,app:this,selectedElements:r})&&(n||!zo.getReferenceSnapPoints())&&zo.setReferenceSnapPoints(Lw(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(o,r,n=!1){qr({event:o,app:this,selectedElements:r})&&(n||!zo.getVisibleGaps())&&zo.setVisibleGaps(Aw(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(o){return rt(r=>{this.maybeHandleResize(o,r)||this.maybeDragNewGenericElement(o,r)})}onKeyUpFromPointerDownHandler(o){return rt(r=>{r.key===T.ALT&&r.preventDefault(),!this.maybeHandleResize(o,r)&&this.maybeDragNewGenericElement(o,r)})}onPointerMoveFromPointerDownHandler(o){return Qm(r=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let n=Ke(r,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index){let[p,u]=mt(n.x,n.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),h=this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index;if(h<0){let b=$.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:p,y:u},this.state,this.scene.getNonDeletedElementsMap());h=b?$.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,b,this.scene.getNonDeletedElementsMap()):-1}let x=$.moveFixedSegment(this.state.selectedLinearElement,h,p,u,this.scene);Vn(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:x.segmentMidPointHoveredCoords,pointerDownState:x.pointerDownState}})});return}let i=this.lastPointerMoveCoords??o.origin;if(this.lastPointerMoveCoords=n,o.drag.offset===null&&(o.drag.offset=mn(Cx(this.scene.getSelectedElements(this.state),o.origin.x,o.origin.y))),!(r.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(r,o))return;if(co(this.state)){this.handleEraser(r,n);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(n.x,n.y);let[l,s]=mt(n.x,n.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(!o.drag.hasOccurred&&(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")&&qn(M(n.x,n.y),M(o.origin.x,o.origin.y))<Xn)return;if(o.resize.isResizing&&(o.lastCoords.x=n.x,o.lastCoords.y=n.y,this.maybeHandleCrop(o,r)||this.maybeHandleResize(o,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 h=$.addMidpoint(this.state.selectedLinearElement,n,this,!r[T.CTRL_OR_CMD],this.scene);if(!h)return;Vn(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:h.pointerDownState,selectedPointsIndices:h.selectedPointsIndices,segmentMidPointHoveredCoords:null}}),this.state.editingLinearElement&&this.setState({editingLinearElement:{...this.state.editingLinearElement,pointerDownState:h.pointerDownState,selectedPointsIndices:h.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,(h,x)=>{this.maybeSuggestBindingsForLinearElementAtCoords(h,x)},p,this.scene);if(u){o.lastCoords.x=n.x,o.lastCoords.y=n.y,o.drag.hasOccurred=!0,this.setState({editingLinearElement:this.state.editingLinearElement?u:null,selectedLinearElement:u});return}}let m=o.hit.allHitElements.some(p=>this.isASelectedElement(p)),d=this.state.editingLinearElement&&r.shiftKey&&this.state.editingLinearElement.elementId===o.hit.element?.id;if((m||o.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!d&&this.state.activeTool.type!=="lasso"){let p=this.scene.getSelectedElements(this.state);if(p.every(b=>b.locked))return;let u=p.find(b=>J(b)),h=this.getTopLayerFrameAtSceneCoords(n),x=h&&!u?h:null;if(this.state.frameToHighlight!==x&&Vn(()=>{this.setState({frameToHighlight:x})}),o.drag.hasOccurred=!0,p.length>0&&!o.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!=="active"){let b={x:n.x-o.drag.origin.x,y:n.y-o.drag.origin.y},E=[...o.originalElements.values()],w=r.shiftKey;if(w){let C=Math.abs(b.x),I=Math.abs(b.y),L=w&&C<I,A=w&&C>I;L&&(b.x=0),A&&(b.y=0)}if(this.state.croppingElementId){let C=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(C&&xe(C)&&C.crop!==null&&o.hit.element===C){let I=C.crop,L=Fr(C)&&this.imageCache.get(C.fileId)?.image;if(L&&!(L instanceof Promise)){let A=tb(Jp(n.x-i.x,n.y-i.y),Math.max(this.state.zoom.value,2)),[R,_,z,W,G,j]=Ve(C,c),H=bc(ie(M(R,_),M(G,j),C.angle)),B=bc(ie(M(z,_),M(G,j),C.angle)),U=bc(ie(M(R,W),M(G,j),C.angle)),oe=tu(eu(B,H)),Z=tu(eu(U,H)),ce=Jp(Qp(A,oe),Qp(A,Z)),ue={...I,x:It(I.x-ce[0]*Math.sign(C.scale[0]),0,L.naturalWidth-I.width),y:It(I.y-ce[1]*Math.sign(C.scale[1]),0,L.naturalHeight-I.height)};this.scene.mutateElement(C,{crop:ue});return}}}this.maybeCacheVisibleGaps(r,p),this.maybeCacheReferenceSnapPoints(r,p);let{snapOffset:y,snapLines:v}=Dw(E,b,this,r,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:v}),this.state.editingFrame||Sx(o,p,b,this.scene,y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),(p.length!==1||!ee(p[0]))&&this.setState({suggestedBindings:Gc(p,this.scene.getNonDeletedElementsMap(),this.state.zoom)}),r.altKey&&!o.hit.hasBeenDuplicated){o.hit.hasBeenDuplicated=!0;let C=this.scene.getElementsIncludingDeleted(),I=o.hit.element,L=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});I&&o.hit.wasAddedToSelection&&!L.find(B=>B.id===I.id)&&L.push(I);let A=new Map(L.map(B=>[B.id,B])),{duplicatedElements:R,duplicateElementsMap:_,elementsWithDuplicates:z,origIdToDuplicateId:W}=gi({type:"in-place",elements:C,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:A,overrides:({duplicateElement:B,origElement:U})=>({frameId:B.frameId??U.frameId,seed:$o()})});R.forEach(B=>{o.originalElements.set(B.id,mo(B))});let G=z.map(B=>{if(A.has(B.id)){let U=o.originalElements.get(B.id);if(U)return re(B,{x:U.x,y:U.y})}return B}),j=this.props.onDuplicate?.(G,C),H=At(j||G,q(R));Vn(()=>{if(o.hit.element){let B=W.get(o.hit.element.id),U=B&&_.get(B);o.hit.element=U||null}o.hit.allHitElements=o.hit.allHitElements.reduce((B,U)=>{let oe=W.get(U.id),Z=oe&&_.get(oe);return Z&&B.push(Z),B},[]),o.drag.origin=Ke(r,this.state),this.setState(B=>({...Rc(R,this.scene.getNonDeletedElements(),B)})),this.scene.replaceAllElements(H),this.maybeCacheVisibleGaps(r,L,!0),this.maybeCacheReferenceSnapPoints(r,L,!0)})}return}}if(this.state.selectionElement)o.lastCoords.x=n.x,o.lastCoords.y=n.y,r.altKey?(this.setActiveTool({type:"lasso",fromSelection:!0},r.shiftKey),this.lassoTrail.startPath(o.origin.x,o.origin.y,r.shiftKey),this.setAppState({selectionElement:null})):this.maybeDragNewGenericElement(o,r);else if(this.state.activeTool.type==="lasso")!r.altKey&&this.state.activeTool.fromSelection?(this.setActiveTool({type:"selection"}),this.createGenericElementOnPointerDown("selection",o),o.lastCoords.x=n.x,o.lastCoords.y=n.y,this.maybeDragNewGenericElement(o,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,h=n.x-p.x,x=n.y-p.y,b=u.length>0&&u[u.length-1];if(!(b&&b[0]===h&&b[1]===x)){let w=p.simulatePressure?p.pressures:[...p.pressures,r.pressure];this.scene.mutateElement(p,{points:[...u,M(h,x)],pressures:w},{informMutation:!1,isDragging:!1}),this.setState({newElement:p})}}else if(le(p)){o.drag.hasOccurred=!0;let u=p.points,h=l-p.x,x=s-p.y;fc(r)&&u.length===2&&({width:h,height:x}=gu(p.x,p.y,n.x,n.y)),u.length===1?this.scene.mutateElement(p,{points:[...u,M(h,x)]},{informMutation:!1,isDragging:!1}):(u.length===2||u.length>1&&ee(p))&&this.scene.mutateElement(p,{points:[...u.slice(0,-1),M(h,x)]},{isDragging:!0,informMutation:!1}),this.setState({newElement:p}),zr(p,!1)&&this.maybeSuggestBindingsForLinearElementAtCoords(p,[n],this.state.startBoundElement)}else o.lastCoords.x=n.x,o.lastCoords.y=n.y,this.maybeDragNewGenericElement(o,r,!1)}if(this.state.activeTool.type==="selection"){o.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&&Ue(p,this.state)&&(o.withCmdOrCtrl&&o.hit.element?this.setState(x=>ht({...x,selectedElementIds:{[o.hit.element.id]:!0}},this.scene.getNonDeletedElements(),x,this)):u=!1);let h=this.state.selectionElement?s0(p,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1):[];this.setState(x=>{let b={...u&&x.selectedElementIds,...h.reduce((E,w)=>(E[w.id]=!0,E),{})};return o.hit.element&&(h.length?delete b[o.hit.element.id]:b[o.hit.element.id]=!0),x=u?x:{...x,selectedGroupIds:{},editingGroupId:null},{...ht({editingGroupId:x.editingGroupId,selectedElementIds:b},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:h.length===1&&le(h[0])?new $(h[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:h.length===1&&(h[0].link||Zt(h[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(o,r){if(r.scrollbars.isOverHorizontal){let n=o.clientX,i=n-r.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-i*(Ws.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),r.lastCoords.x=n,!0}if(r.scrollbars.isOverVertical){let n=o.clientY,i=n-r.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-i*(Ws.vertical?.deltaMultiplier||1)/this.state.zoom.value}),r.lastCoords.y=n,!0}return!1}onPointerUpFromPointerDownHandler(o){return rt(r=>{this.removePointer(r),o.eventListeners.onMove&&o.eventListeners.onMove.flush();let{newElement:n,resizingElement:i,croppingElementId:a,multiElement:l,activeTool:s,isResizing:c,isRotating:m,isCropping:d}=this.state;this.setState(b=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:Zi(b.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.lastPointerMoveCoords=null,zo.setReferenceSnapPoints(null),zo.setVisibleGaps(null),this.savePointer(r.clientX,r.clientY,"up"),this.setState({selectedElementsAreBeingDragged:!1});let p=this.scene.getNonDeletedElementsMap();if(o.drag.hasOccurred&&o.hit?.element?.id){let b=p.get(o.hit.element.id);ni(b)&&b.boundElements?.filter(E=>E.type==="arrow").map(E=>p.get(E.id)).filter(E=>ee(E)).forEach(E=>{E&&this.scene.mutateElement(E,{})})}if(this.state.editingLinearElement)if(!o.boxSelection.hasOccurred&&o.hit?.element?.id!==this.state.editingLinearElement.elementId)this.actionManager.executeAction(ko);else{let b=$.handlePointerUp(r,this.state.editingLinearElement,this.state,this.scene);b!==this.state.editingLinearElement&&this.setState({editingLinearElement:b,suggestedBindings:[]})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let b=$.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());b&&this.scene.mutateElement(b,{})}if(o.hit?.element?.id!==this.state.selectedLinearElement.elementId)this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null});else{let b=$.handlePointerUp(r,this.state.selectedLinearElement,this.state,this.scene),{startBindingElement:E,endBindingElement:w}=b,y=this.scene.getElement(b.elementId);zr(y)&&Uc(y,E,w,this.scene),b!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...b,selectedPointsIndices:null},suggestedBindings:[]})}}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener("pointermove",o.eventListeners.onMove),window.removeEventListener("pointerup",o.eventListeners.onUp),window.removeEventListener("keydown",o.eventListeners.onKeyDown),window.removeEventListener("keyup",o.eventListeners.onKeyUp),this.state.pendingImageElementId&&this.setState({pendingImageElementId:null}),this.props?.onPointerUp?.(s,o),this.onPointerUpEmitter.trigger(this.state.activeTool,o,r),n?.type==="freedraw"){let b=Ke(r,this.state),E=n.points,w=b.x-n.x,y=b.y-n.y;w===E[0][0]&&y===E[0][1]&&(y+=1e-4,w+=1e-4);let v=n.simulatePressure?[]:[...n.pressures,r.pressure];this.scene.mutateElement(n,{points:[...E,M(w,y)],pressures:v,lastCommittedPoint:M(w,y)}),this.actionManager.executeAction(ko);return}if(xe(n)){let b=n;try{this.initializeImageDimensions(b),this.setState({selectedElementIds:Me({[b.id]:!0},this.state)},()=>{this.actionManager.executeAction(ko)})}catch(E){console.error(E),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().filter(w=>w.id!==b.id)),this.actionManager.executeAction(ko)}return}if(le(n)){n.points.length>1&&this.store.scheduleCapture();let b=Ke(r,this.state);!o.drag.hasOccurred&&n&&!l?(this.scene.mutateElement(n,{points:[...n.points,M(b.x-n.x,b.y-n.y)]},{informMutation:!1,isDragging:!1}),this.setState({multiElement:n,newElement:n})):o.drag.hasOccurred&&!l&&(mi(this.state)&&zr(n,!1)&&Ol(n,this.state,b,this.scene),this.setState({suggestedBindings:[],startBoundElement:null}),s.locked?this.setState(E=>({newElement:null})):(Co(this.interactiveCanvas),this.setState(E=>({newElement:null,activeTool:Ne(this.state,{type:"selection"}),selectedElementIds:Me({...E.selectedElementIds,[n.id]:!0},E),selectedLinearElement:new $(n,this.scene.getNonDeletedElementsMap())}))),this.scene.triggerUpdate());return}if(K(n)){let b=ji(Ge({fontSize:n.fontSize,fontFamily:n.fontFamily}),n.lineHeight);n.width<b&&this.scene.mutateElement(n,{autoResize:!0}),this.resetCursor(),this.handleTextWysiwyg(n,{isExistingElement:!0})}if(s.type!=="selection"&&n&&si(n)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(b=>b.id!==n.id),appState:{newElement:null},captureUpdate:D.NEVER});return}if(J(n)){let b=g0(this.scene.getElementsIncludingDeleted(),n,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(ta(this.scene.getElementsMapIncludingDeleted(),b,n,this.state))}if(n&&(this.scene.mutateElement(n,jb(n),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),o.drag.hasOccurred){let b=Ke(r,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let E=this.scene.getElement(this.state.selectedLinearElement.elementId);if(E?.frameId){let w=di(E,p);w&&E&&(Nc(E,w,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(E,{groupIds:[]}),Oc([E],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let E=this.getTopLayerFrameAtSceneCoords(b),w=this.scene.getSelectedElements(this.state),y=this.scene.getElementsMapIncludingDeleted(),v=C=>{if(C.length>0){for(let I of C){let L=I.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(I,{groupIds:I.groupIds.slice(0,L)},{informMutation:!1,isDragging:!1})}y.forEach(I=>{I.groupIds.length&&Be(y,I.groupIds[I.groupIds.length-1]).length<2&&this.scene.mutateElement(I,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(E&&!this.state.selectedElementIds[E.id]){let C=w.filter(I=>I.frameId!==E.id&&xu(I,y,this.state));this.state.editingGroupId&&v(C),y=ta(y,C,E,this.state)}else if(!E&&this.state.editingGroupId){let C=w.filter(I=>I.frameId&&!xu(I,y,this.state));v(C)}y=xr(y,this.state,this),this.scene.replaceAllElements(y)}}if(i&&this.store.scheduleCapture(),i&&si(i)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(b=>b.id!==i.id),captureUpdate:D.NEVER}),o.resize.isResizing){let b=xr(this.scene.getElementsIncludingDeleted(),this.state,this),E=this.scene.getSelectedElements(this.state).filter(w=>J(w));for(let w of E)b=Bc(b,ea(this.scene.getElementsIncludingDeleted(),w,this.state,p),w,this);this.scene.replaceAllElements(b)}let u=o.hit.element;this.state.selectedLinearElement?.elementId!==u?.id&&le(u)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new $(u,this.scene.getNonDeletedElementsMap())}),(!a||a&&(!u&&!d||u&&u.id!==a))&&this.finishImageCropping();let h=this.lastPointerDownEvent,x=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(co(this.state)&&h&&x){if(this.eraserTrail.endPath(),qn(M(h.clientX,h.clientY),M(x.clientX,x.clientY))===0){let E=Ke({clientX:x.clientX,clientY:x.clientY},this.state);this.getElementsAtPosition(E.x,E.y).forEach(y=>this.elementsPendingErasure.add(y.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(u&&!o.drag.hasOccurred&&!o.hit.wasAddedToSelection&&(!this.state.editingLinearElement||!o.boxSelection.hasOccurred)&&(r.shiftKey&&!this.state.editingLinearElement?this.state.selectedElementIds[u.id]?_c(this.state,u)?this.setState(b=>{let E={...b.selectedElementIds};for(let w of u.groupIds.flatMap(y=>Be(this.scene.getNonDeletedElements(),y)))delete E[w.id];return{selectedGroupIds:{...b.selectedElementIds,...u.groupIds.map(w=>({[w]:!1})).reduce((w,y)=>({...w,...y}),{})},selectedElementIds:Me(E,b)}}):this.state.selectedLinearElement?.isDragging||this.setState(b=>{let E={...b.selectedElementIds};delete E[u.id];let w=Q(this.scene.getNonDeletedElements(),{selectedElementIds:E});return{...ht({editingGroupId:b.editingGroupId,selectedElementIds:E},this.scene.getNonDeletedElements(),b,this),selectedLinearElement:w.length===1&&le(w[0])?new $(w[0],this.scene.getNonDeletedElementsMap()):b.selectedLinearElement}}):u.frameId&&this.state.selectedElementIds[u.frameId]?this.setState(b=>{let E={...b.selectedElementIds,[u.id]:!0};return delete E[u.frameId],(this.scene.getElement(u.frameId)?.groupIds??[]).flatMap(w=>Be(this.scene.getNonDeletedElements(),w)).forEach(w=>{delete E[w.id]}),{...ht({editingGroupId:b.editingGroupId,selectedElementIds:E},this.scene.getNonDeletedElements(),b,this),showHyperlinkPopup:u.link||Zt(u)?"info":!1}}):this.setState(b=>({selectedElementIds:Me({...b.selectedElementIds,[u.id]:!0},b)})):this.setState(b=>({...ht({editingGroupId:b.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),b,this),selectedLinearElement:le(u)&&b.selectedLinearElement?.elementId!==u.id?new $(u,this.scene.getNonDeletedElementsMap()):b.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(u&&ee(u))&&!o.drag.hasOccurred&&!this.state.isResizing&&(u&&Db({x:o.origin.x,y:o.origin.y,element:u,shape:Ur(u,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold(),frameNameBound:J(u)?this.frameNameBoundsCache.get(u):null},p)||!u&&o.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.editingLinearElement?this.setState({editingLinearElement:null}):this.setState({selectedElementIds:Me({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),Le(this.interactiveCanvas,Ce.AUTO);return}if(!s.locked&&s.type!=="freedraw"&&n&&this.setState(b=>({selectedElementIds:Me({...b.selectedElementIds,[n.id]:!0},b),showHyperlinkPopup:Zt(n)&&!n.link?"editor":b.showHyperlinkPopup})),(s.type!=="selection"||Ue(this.scene.getNonDeletedElements(),this.state)||!pt(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),o.drag.hasOccurred||c||m||d){let b=this.scene.getSelectedElements(this.state).filter(le);Nl(b,mi(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)?(Co(this.interactiveCanvas),this.setState({newElement:null,suggestedBindings:[],activeTool:Ne(this.state,{type:"selection"})})):this.setState({newElement:null,suggestedBindings:[]}),u&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&De.pointers.size<=1&&Xi(u)&&this.isIframeLikeElementCenter(u,this.lastPointerUpEvent,o.origin.x,o.origin.y)&&this.handleEmbeddableCenterClick(u)})}clearSelection(o){this.setState(r=>({selectedElementIds:Me({},r),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:r.editingGroupId&&o!=null&&Qi(o,r.editingGroupId)?r.editingGroupId:null})),this.setState({selectedElementIds:Me({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds})}getTextWysiwygSnappedToCenterPosition(o,r,n,i){if(i){let a=i.x+i.width/2,l=i.y+i.height/2,s=Lc(i,n,this.scene.getNonDeletedElementsMap());if(s&&(a=s.x,l=s.y),Math.hypot(o-a,r-l)<D1){let{x:d,y:p}=Pt({sceneX:a,sceneY:l},n);return{viewportX:d,viewportY:p,elementCenterX:a,elementCenterY:l}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let o=this.excalidrawContainerRef.current,{left:r,top:n}=o.getBoundingClientRect();return{offsetLeft:r,offsetTop:n}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let o=fa.find(r=>r.code===this.props.langCode)||vr;await yd(o),this.setAppState({})}},X8=()=>{(et()||Oe())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(tr(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};X8();var gT=e1;import{useEffect as j8,useState as q8}from"react";import{jsx as J8}from"react/jsx-runtime";var fT=e=>{let[t,o]=q8(!0);return j8(()=>{let r=async()=>{await yd(n),o(!1)},n=fa.find(i=>i.code===e.langCode)||vr;r()},[e.langCode]),t?J8(op,{theme:e.theme}):e.children};import Q8 from"clsx";import{jsx as bT}from"react/jsx-runtime";var xT=({children:e})=>{let{FooterCenterTunnel:t}=je(),o=_e();return bT(t.In,{children:bT("div",{className:Q8("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":o.zenModeEnabled}),children:e})})},e7=xT;xT.displayName="FooterCenter";import t7 from"clsx";import{jsx as r7,jsxs as n7}from"react/jsx-runtime";var ET=({isCollaborating:e,onSelect:t,...o})=>{let r=_e(),n=r.width<830;return n7(Mo,{...o,className:t7("collab-button",{active:e}),type:"button",onSelect:t,style:{position:"relative",width:n?void 0:"auto"},title:f("labels.liveCollaboration"),children:[n?oE:f("labels.share"),r.collaborators.size>0&&r7("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},o7=ET;ET.displayName="LiveCollaborationTrigger";import{jsx as Kn,jsxs as vT}from"react/jsx-runtime";var i7=()=>Kn("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Kn("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"})}),a7=()=>vT("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Kn("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)"}),Kn("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)"}),Kn("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)"}),Kn("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)"})]}),yT=({style:e,size:t="small",withText:o})=>vT("div",{className:`ExcalidrawLogo is-${t}`,style:e,children:[Kn(i7,{}),o&&Kn(a7,{})]});import{Fragment as ST,jsx as Et,jsxs as l1}from"react/jsx-runtime";var s1=({icon:e,shortcut:t,children:o})=>{let r=Te();return l1(ST,{children:[Et("div",{className:"welcome-screen-menu-item__icon",children:e}),Et("div",{className:"welcome-screen-menu-item__text",children:o}),t&&!r.editor.isMobile&&Et("div",{className:"welcome-screen-menu-item__shortcut",children:t})]})};s1.displayName="WelcomeScreenMenuItemContent";var Xs=({onSelect:e,children:t,icon:o,shortcut:r,className:n="",...i})=>Et("button",{...i,type:"button",className:`welcome-screen-menu-item ${n}`,onClick:e,children:Et(s1,{icon:o,shortcut:r,children:t})});Xs.displayName="WelcomeScreenMenuItem";var wT=({children:e,href:t,icon:o,shortcut:r,className:n="",...i})=>Et("a",{...i,className:`welcome-screen-menu-item ${n}`,href:t,target:"_blank",rel:"noopener",children:Et(s1,{icon:o,shortcut:r,children:e})});wT.displayName="WelcomeScreenMenuItemLink";var Vo=({children:e})=>{let{WelcomeScreenCenterTunnel:t}=je();return Et(t.In,{children:Et("div",{className:"welcome-screen-center",children:e||l1(ST,{children:[Et(c1,{}),Et(d1,{children:f("welcomeScreen.defaults.center_heading")}),l1(m1,{children:[Et(u1,{}),Et(p1,{})]})]})})})};Vo.displayName="Center";var c1=({children:e})=>Et("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||Et(yT,{withText:!0})});c1.displayName="Logo";var d1=({children:e})=>Et("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});d1.displayName="Heading";var m1=({children:e})=>Et("div",{className:"welcome-screen-menu",children:e});m1.displayName="Menu";var p1=()=>{let e=bt();return Et(Xs,{onSelect:()=>e.executeAction(Ri),shortcut:"?",icon:ya,children:f("helpDialog.title")})};p1.displayName="MenuItemHelp";var u1=()=>{let e=_e(),t=bt();return e.viewModeEnabled?null:Et(Xs,{onSelect:()=>t.executeAction(Na),shortcut:st("loadScene"),icon:va,children:f("buttons.load")})};u1.displayName="MenuItemLoadScene";var TT=({onSelect:e})=>{let{t}=dt();return Et(Xs,{shortcut:null,onSelect:e,icon:Ad,children:t("labels.liveCollaboration")})};TT.displayName="MenuItemLiveCollaborationTrigger";Vo.Logo=c1;Vo.Heading=d1;Vo.Menu=m1;Vo.MenuItem=Xs;Vo.MenuItemLink=wT;Vo.MenuItemHelp=p1;Vo.MenuItemLoadScene=u1;Vo.MenuItemLiveCollaborationTrigger=TT;import{jsx as gl,jsxs as h1}from"react/jsx-runtime";var Op=({children:e})=>{let{WelcomeScreenMenuHintTunnel:t}=je();return gl(t.In,{children:h1("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[Bx,gl("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.menuHint")})]})})};Op.displayName="MenuHint";var Bp=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:t}=je();return gl(t.In,{children:h1("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[gl("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.toolbarHint")}),zx]})})};Bp.displayName="ToolbarHint";var Fp=({children:e})=>{let{WelcomeScreenHelpHintTunnel:t}=je();return gl(t.In,{children:h1("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[gl("div",{children:e||f("welcomeScreen.defaults.helpHint")}),Fx]})})};Fp.displayName="HelpHint";import{Fragment as CT,jsx as $s,jsxs as s7}from"react/jsx-runtime";var zp=e=>$s(CT,{children:e.children||s7(CT,{children:[$s(Vo,{}),$s(Op,{}),$s(Bp,{}),$s(Fp,{})]})});zp.displayName="WelcomeScreen";zp.Center=Vo;zp.Hints={MenuHint:Op,ToolbarHint:Bp,HelpHint:Fp};var l7=zp;var c7=()=>{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)})},IT=c7;import d7 from"lodash.throttle";var m7=(e,t,o)=>!!(t&&(t.id===e.editingTextElement?.id||t.id===e.resizingElement?.id||t.id===e.newElement?.id||t.version>o.version||t.version===o.version&&t.versionNonce<o.versionNonce)),p7=d7((e,t,o)=>{if(Oe()||et()||window?.DEBUG_FRACTIONAL_INDICES){let r=tr(e.map(n=>({...n})));Jc(r,{shouldThrow:et()||Oe(),includeBoundTextValidation:!0,reconciliationContext:{localElements:t,remoteElements:o}})}},1e3*60,{leading:!0,trailing:!1}),u7=(e,t,o)=>{let r=q(e),n=[],i=new Set;for(let l of t)if(!i.has(l.id)){let s=r.get(l.id),c=m7(o,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=la(n);return p7(a,e,t),tr(a),a};import{jsx as kT,jsxs as h7}from"react/jsx-runtime";var MT=({children:e,icon:t})=>{let{TTDDialogTriggerTunnel:o}=je(),r=Se();return kT(o.In,{children:h7(Pe.Item,{onSelect:()=>{fe("ai","dialog open","ttd"),r({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:t??JE,children:[e??f("labels.textToDiagram"),kT(Pe.Item.Badge,{children:"AI"})]})})};MT.displayName="TTDDialogTrigger";import{useLayoutEffect as g7}from"react";var f7=e=>{let t=lt();return g7(()=>{t.setPlugins({diagramToCode:{generate:e.generate}})},[t,e.generate]),null};import{jsx as g1}from"react/jsx-runtime";IT();var E7=e=>{let{onChange:t,onIncrement:o,initialData:r,excalidrawAPI:n,isCollaborating:i=!1,onPointerUpdate:a,renderTopRightUI:l,langCode:s=vr.code,viewModeEnabled:c,zenModeEnabled:m,gridModeEnabled:d,libraryReturnUrl:p,theme:u,name:h,renderCustomStats:x,onPaste:b,detectScroll:E=!0,handleKeyboardGlobally:w=!1,onLibraryChange:y,autoFocus:v=!1,generateIdForFile:C,onLinkOpen:I,generateLinkForSelection:L,onPointerDown:A,onPointerUp:R,onScrollChange:_,onDuplicate:z,children:W,validateEmbeddable:G,renderEmbeddable:j,aiEnabled:H,showDeprecatedFonts:B,renderScrollbars:U}=e,oe=e.UIOptions?.canvasActions,Z={...e.UIOptions,canvasActions:{...Kp.canvasActions,...oe},tools:{image:e.UIOptions?.tools?.image??!0}};return oe?.export&&(Z.canvasActions.export.saveFileToDisk=oe.export?.saveFileToDisk??Kp.canvasActions.export.saveFileToDisk),Z.canvasActions.toggleTheme===null&&typeof u>"u"&&(Z.canvasActions.toggleTheme=!0),x7(()=>{(async()=>{await import("canvas-roundrect-polyfill")})();let ue=he=>{typeof he.scale=="number"&&he.scale!==1&&he.preventDefault()};return document.addEventListener("touchmove",ue,{passive:!1}),()=>{document.removeEventListener("touchmove",ue)}},[]),g1(Lx,{store:Fe,children:g1(fT,{langCode:s,theme:u,children:g1(gT,{onChange:t,onIncrement:o,initialData:r,excalidrawAPI:n,isCollaborating:i,onPointerUpdate:a,renderTopRightUI:l,langCode:s,viewModeEnabled:c,zenModeEnabled:m,gridModeEnabled:d,libraryReturnUrl:p,theme:u,name:h,renderCustomStats:x,UIOptions:Z,onPaste:b,detectScroll:E,handleKeyboardGlobally:w,onLibraryChange:y,autoFocus:v,generateIdForFile:C,onLinkOpen:I,generateLinkForSelection:L,onPointerDown:A,onPointerUp:R,onScrollChange:_,onDuplicate:z,validateEmbeddable:G,renderEmbeddable:j,aiEnabled:H!==!1,showDeprecatedFonts:B,renderScrollbars:U,children:W})})})},y7=(e,t)=>{if(e.children!==t.children)return!1;let{initialData:o,UIOptions:r={},...n}=e,{initialData:i,UIOptions:a={},...l}=t,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])&&pt(n,l)},v7=b7.memo(E7,y7);v7.displayName="Excalidraw";export{Mo as Button,D as CaptureUpdateAction,Up as DEFAULT_LASER_COLOR,xp as DefaultSidebar,f7 as DiagramToCodePlugin,v7 as Excalidraw,yt as FONT_FAMILY,e7 as Footer,o7 as LiveCollaborationTrigger,ge as MIME_TYPES,Yt as MainMenu,Ct as ROUNDNESS,Go as Sidebar,zs as Stats,se as THEME,Bf as TTDDialog,MT as TTDDialogTrigger,J1 as UserIdleState,l7 as WelcomeScreen,Jo as bumpVersion,il as convertToExcalidrawElements,vr as defaultLang,DT as elementPartiallyOverlapsWithOrContainsBBox,_T as elementsOverlappingBBox,pv as exportToBlob,Dn as exportToCanvas,B4 as exportToClipboard,ja as exportToSvg,Ee as getCommonBounds,sd as getDataURL,PT as getFreeDrawSvgPath,Am as getLibraryItemsHash,ye as getNonDeletedElements,RT as getSceneVersion,uu as getTextFromElements,Iu as getVisibleSceneBounds,Gl as hashElementsVersion,Vl as hashString,LT as isElementInsideBBox,ui as isElementLink,si as isInvisiblySmallElement,le as isLinearElement,fa as languages,ld as loadFromBlob,Bu as loadLibraryFromBlob,Ou as loadSceneOrLibraryFromBlob,Ev as mergeLibraryItems,kt as mutateElement,re as newElementWith,jo as normalizeLink,Pg as parseLibraryTokensFromUrl,u7 as reconcileElements,ma as restore,NT as restoreAppState,Nu as restoreElements,Xl as restoreLibraryItems,Pt as sceneCoordsToViewportCoords,Wl as serializeAsJSON,Ru as serializeLibraryAsJSON,AT as setCustomTextMetricsProvider,Te as useDevice,V4 as useHandleLibrary,dt as useI18n,Ke as viewportCoordsToSceneCoords,x2 as zoomToFitBounds};
|
|
118
|
+
`),n)}}addTextFromPaste(t,n=!1){let{x:r,y:i}=He({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),a={x:r,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:pI,locked:!1},l=wf({fontSize:a.fontSize,fontFamily:a.fontFamily}),s=bI(a.fontFamily),[m,,d]=SG(this.state),c=Math.max(Math.min((d-m)*.5,800),200),p=10,u=i,f=n?[t]:t.split(`
|
|
119
|
+
`),b=f.reduce((x,y,E)=>{let w=_G(y).trim();if(w.length){let v=this.getTopLayerFrameAtSceneCoords({x:r,y:u}),C=YI(w,l,s),S=C.width>c,L=S?LG(w,l,c):w;C=S?YI(L,l,s):C;let P=r-C.width/2,B=u-C.height/2,k=kI({...a,x:P,y:B,text:L,originalText:w,lineHeight:s,autoResize:!S,frameId:v?v.id:null});x.push(k),u+=k.height+p}else f[E-1]?.trim()&&(u+=RG(a.fontSize,s)+p);return x},[]);b.length!==0&&(this.scene.insertElements(b),this.store.scheduleCapture(),this.setState({selectedElementIds:ve(Object.fromEntries(b.map(x=>[x.id,!0])),this.state)}),!n&&b.length>1&&tC===!1&&!this.device.editor.isMobile&&(this.setToast({message:g("toast.pasteAsSingleElement",{shortcut:_H("CtrlOrCmd+Shift+V")}),duration:5e3}),tC=!0))}handleTextWysiwyg(t,{isExistingElement:n=!1}){let r=this.scene.getElementsMapIncludingDeleted(),i=(a,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(s=>s.id===t.id&&po(s)?Fn(s,{originalText:a,isDeleted:l??s.isDeleted,...rG(s,OI(s,r),r,a)}):s)])};Ov({id:t.id,canvas:this.canvas,getViewportCoords:(a,l)=>{let{x:s,y:m}=gm({sceneX:a,sceneY:l},this.state);return[s-this.state.offsetLeft,m-this.state.offsetTop]},onChange:Ae(a=>{i(a,!1),jI(t)&&Sf(t,this.scene)}),onSubmit:Ae(({viaKeyboard:a,nextOriginalText:l})=>{let s=!l.trim();if(i(l,s),!s&&a){let m=t.containerId?t.containerId:t.id;Ki(()=>{this.setState(d=>({selectedElementIds:ve({...d.selectedElementIds,[m]:!0},d)}))})}s&&$H(this.scene.getNonDeletedElements(),[t]),(!s||n)&&this.store.scheduleCapture(),Ki(()=>{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:ve({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(t,n){let r=this.getElementAtPosition(t,n,{includeBoundTextElement:!0});return r&&po(r)&&!r.isDeleted?r:null}getElementAtPosition(t,n,r){let i=[];if(r&&"allHitElements"in r?i=r?.allHitElements||[]:i=this.getElementsAtPosition(t,n,{includeBoundTextElement:r?.includeBoundTextElement,includeLockedElements:r?.includeLockedElements}),i.length>1){if(r?.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 Ll({point:ie(t,n),element:a,threshold:this.getElementHitThreshold(a)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:kt(a)?this.frameNameBoundsCache.get(a):null})?a:i[i.length-2]}return i.length===1?i[0]:null}getElementsAtPosition(t,n,r){let i=[],a=this.scene.getNonDeletedElementsMap();return(r?.includeBoundTextElement&&r?.includeLockedElements?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(s=>(r?.includeLockedElements||!s.locked)&&(r?.includeBoundTextElement||!(po(s)&&s.containerId)))).filter(s=>this.hitElement(t,n,s)).filter(s=>{let m=Hf(s,a);return m&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?zI({x:t,y:n},m,a):!0}).filter(s=>qi(s)?(i.push(s),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(fI/this.state.zoom.value))}hitElement(t,n,r,i=!0){return i&&this.state.selectedElementIds[r.id]&&fG([r],this.state)&&qG(ie(t,n),r,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(r))||IG(ie(t,n),r,this.scene.getNonDeletedElementsMap())?!0:Ll({point:ie(t,n),element:r,threshold:this.getElementHitThreshold(r),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:kt(r)?this.frameNameBoundsCache.get(r):null})}getTextBindableContainerAtPosition(t,n){let r=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=r.length-1;l>=0;--l){if(r[l].isDeleted)continue;let[s,m,d,c]=TI(r[l],this.scene.getNonDeletedElementsMap());if(Pf(r[l])&&Ll({point:ie(t,n),element:r[l],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(r[l])})){a=r[l];break}else if(s<t&&t<d&&m<n&&n<c){a=r[l];break}}return AI(a,!1)?a:null}handleHoverSelectedLinearElement(t,n,r){let i=this.scene.getNonDeletedElementsMap(),a=Ie.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let l=-1,s=null;Ll({point:ie(n,r),element:a,elementsMap:i,threshold:this.getElementHitThreshold(a)})?(l=Ie.getPointIndexUnderCursor(a,i,this.state.zoom,n,r),s=Ie.getSegmentMidpointHitCoords(t,{x:n,y:r},this.state,this.scene.getNonDeletedElementsMap()),(Xe(a)?l===0||l===a.points.length-1:l>=0)||s?ye(this.interactiveCanvas,_e.POINTER):this.hitElement(n,r,a)&&(!Xe(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&ye(this.interactiveCanvas,_e.MOVE)):this.hitElement(n,r,a)&&(!Xe(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&ye(this.interactiveCanvas,_e.MOVE),this.state.selectedLinearElement.hoverPointIndex!==l&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:l}}),Ie.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,s)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:s}})}else ye(this.interactiveCanvas,_e.AUTO)}updateGestureOnPointerDown(t){ge.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),ge.pointers.size===2&&(ge.lastCenter=Xh(ge.pointers),ge.initialScale=this.state.zoom.value,ge.initialDistance=Kh(Array.from(ge.pointers.values())))}initialPointerDownState(t){let n=He(t,this.state),r=this.scene.getSelectedElements(this.state),[i,a,l,s]=ji(r),m=r.findIndex(Xe)===0;return{origin:n,withCmdOrCtrl:t[V.CTRL_OR_CMD],originInGrid:vf(rt(n.x,n.y,t[V.CTRL_OR_CMD]||m?null:this.getEffectiveGridSize())),scrollbars:tg(Nl,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...n},originalElements:this.scene.getNonDeletedElements().reduce((d,c)=>(d.set(c.id,MI(c)),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(n,r)},drag:{hasOccurred:!1,offset:null,origin:{...n},blockDragging:!1},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,n){if(!(n.scrollbars.isOverEither&&!this.state.multiElement))return!1;Yf=!0,n.lastCoords.x=t.clientX,n.lastCoords.y=t.clientY;let r=yd(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,n)}),i=Ae(()=>{Fl=null,Yf=!1,Dt(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(te.POINTER_MOVE,r),window.removeEventListener(te.POINTER_UP,i),r.flush()});return Fl=i,window.addEventListener(te.POINTER_MOVE,r),window.addEventListener(te.POINTER_UP,i),!0}isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,n){if(n.length<2)return!1;let r=Math.max(fI/this.state.zoom.value,1),[i,a,l,s]=ji(n);return t.x>i-r&&t.x<l+r&&t.y>a-r&&t.y<s+r}getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:aG(t)?pm.ADAPTIVE_RADIUS:pm.PROPORTIONAL_RADIUS}:null}maybeCacheReferenceSnapPoints(t,n,r=!1){Wo({event:t,app:this,selectedElements:n})&&(r||!Xt.getReferenceSnapPoints())&&Xt.setReferenceSnapPoints(tv(this.scene.getNonDeletedElements(),n,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,n,r=!1){Wo({event:t,app:this,selectedElements:n})&&(r||!Xt.getVisibleGaps())&&Xt.setVisibleGaps(ev(this.scene.getNonDeletedElements(),n,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return Ae(n=>{this.maybeHandleResize(t,n)||this.maybeDragNewGenericElement(t,n)})}onKeyUpFromPointerDownHandler(t){return Ae(n=>{n.key===V.ALT&&n.preventDefault(),!this.maybeHandleResize(t,n)&&this.maybeDragNewGenericElement(t,n)})}onPointerMoveFromPointerDownHandler(t){return yd(n=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let r=He(n,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]=rt(r.x,r.y,n[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),f=this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index;if(f<0){let x=Ie.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:p,y:u},this.state,this.scene.getNonDeletedElementsMap());f=x?Ie.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,x,this.scene.getNonDeletedElementsMap()):-1}let b=Ie.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=r,t.drag.offset===null&&(t.drag.offset=vf($G(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(n.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(n,t))return;if(yt(this.state)){this.handleEraser(n,r);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(r.x,r.y);let[l,s]=rt(r.x,r.y,n[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(!t.drag.hasOccurred&&(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")&&Rn(ie(r.x,r.y),ie(t.origin.x,t.origin.y))*this.state.zoom.value<wI)return;if(t.resize.isResizing&&(t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeHandleCrop(t,n)||this.maybeHandleResize(t,n)))return!0;let m=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement;if(Ie.shouldAddMidpoint(this.state.selectedLinearElement,r,this.state,m)){let f=Ie.addMidpoint(this.state.selectedLinearElement,r,this,!n[V.CTRL_OR_CMD],this.scene);if(!f)return;Ki(()=>{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=Ie.handlePointDragging(n,this,r.x,r.y,p);if(u){t.lastCoords.x=r.x,t.lastCoords.y=r.y,t.drag.hasOccurred=!0,this.setState(u);return}}let d=t.hit.allHitElements.some(p=>this.isASelectedElement(p)),c=this.state.selectedLinearElement?.isEditing&&n.shiftKey&&this.state.selectedLinearElement.elementId===t.hit.element?.id;if((d||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!c&&!t.drag.blockDragging){let p=this.scene.getSelectedElements(this.state);if(p.length>0&&p.every(x=>x.locked))return;let u=p.find(x=>kt(x)),f=this.getTopLayerFrameAtSceneCoords(r),b=f&&!u?f:null;if(this.state.frameToHighlight!==b&&Ki(()=>{this.setState({frameToHighlight:b})}),t.drag.hasOccurred=!0,this.state.activeTool.type==="lasso"&&this.lassoTrail.hasCurrentTrail&&!(fr()&&t.hit.element)&&!this.state.activeTool.fromSelection)return;if(this.state.activeTool.type==="lasso"&&p.length>0&&t.drag.hasOccurred&&!this.state.activeTool.fromSelection&&this.lassoTrail.endPath(),p.length>0&&!t.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!=="active"){let x={x:r.x-t.drag.origin.x,y:r.y-t.drag.origin.y},y=[...t.originalElements.values()],E=n.shiftKey;if(E){let C=Math.abs(x.x),S=Math.abs(x.y),L=E&&C<S,P=E&&C>S;L&&(x.x=0),P&&(x.y=0)}if(this.state.croppingElementId){let C=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(C&&br(C)&&C.crop!==null&&t.hit.element===C){let S=C.crop,L=Ml(C)&&this.imageCache.get(C.fileId)?.image;if(L&&!(L instanceof Promise)){let P=lH(aI(r.x-i.x,r.y-i.y),Math.max(this.state.zoom.value,2)),[B,k,A,F,Y,Q]=TI(C,m),_=bf(ff(ie(B,k),ie(Y,Q),C.angle)),R=bf(ff(ie(A,k),ie(Y,Q),C.angle)),W=bf(ff(ie(B,F),ie(Y,Q),C.angle)),X=cI(lI(R,_)),G=cI(lI(W,_)),me=aI(sI(P,X),sI(P,G)),ue={...S,x:iI(S.x-me[0]*Math.sign(C.scale[0]),0,L.naturalWidth-S.width),y:iI(S.y-me[1]*Math.sign(C.scale[1]),0,L.naturalHeight-S.height)};this.scene.mutateElement(C,{crop:ue});return}}}this.maybeCacheVisibleGaps(n,p),this.maybeCacheReferenceSnapPoints(n,p);let{snapOffset:w,snapLines:v}=ov(y,x,this,n,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:v}),this.state.editingFrame||ZG(t,p,x,this.scene,w,n[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),(p.length!==1||!Xe(p[0]))&&this.setState({suggestedBindings:kf(p,this.scene.getNonDeletedElementsMap(),this.state.zoom)}),n.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 P=new Map(L.map(R=>[R.id,R])),{duplicatedElements:B,duplicateElementsMap:k,elementsWithDuplicates:A,origIdToDuplicateId:F}=Mf({type:"in-place",elements:C,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:P,overrides:({duplicateElement:R,origElement:W})=>({frameId:R.frameId??W.frameId,seed:HH()})});B.forEach(R=>{t.originalElements.set(R.id,MI(R))});let Y=A.map(R=>{if(P.has(R.id)){let W=t.originalElements.get(R.id);if(W)return Fn(R,{x:W.x,y:W.y})}return R}),Q=this.props.onDuplicate?.(Y,C),_=VI(Q||Y,fm(B));Ki(()=>{if(t.hit.element){let R=F.get(t.hit.element.id),W=R&&k.get(R);t.hit.element=W||null}t.hit.allHitElements=t.hit.allHitElements.reduce((R,W)=>{let X=F.get(W.id),G=X&&k.get(X);return G&&R.push(G),R},[]),t.drag.origin=He(n,this.state),this.setState(R=>({...WG(B,this.scene.getNonDeletedElements(),R)})),this.scene.replaceAllElements(_),this.maybeCacheVisibleGaps(n,L,!0),this.maybeCacheReferenceSnapPoints(n,L,!0)})}return}}if(this.state.selectionElement){if(t.lastCoords.x=r.x,t.lastCoords.y=r.y,n.altKey){this.setActiveTool({type:"lasso",fromSelection:!0},n.shiftKey),this.lassoTrail.startPath(t.origin.x,t.origin.y,n.shiftKey),this.setAppState({selectionElement:null});return}this.maybeDragNewGenericElement(t,n)}else if(this.state.activeTool.type==="lasso")!n.altKey&&this.state.activeTool.fromSelection?(this.setActiveTool({type:"selection"}),this.createGenericElementOnPointerDown("selection",t),t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeDragNewGenericElement(t,n),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(r.x,r.y,n.shiftKey);else{let p=this.state.newElement;if(!p)return;if(p.type==="freedraw"){let u=p.points,f=r.x-p.x,b=r.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,n.pressure];this.scene.mutateElement(p,{points:[...u,ie(f,b)],pressures:E},{informMutation:!1,isDragging:!1}),this.setState({newElement:p})}}else if(jt(p)){t.drag.hasOccurred=!0;let u=p.points,f=l-p.x,b=s-p.y;xf(n)&&u.length===2&&({width:f,height:b}=DI(p.x,p.y,r.x,r.y)),u.length===1?this.scene.mutateElement(p,{points:[...u,ie(f,b)]},{informMutation:!1,isDragging:!1}):(u.length===2||u.length>1&&Xe(p))&&this.scene.mutateElement(p,{points:[...u.slice(0,-1),ie(f,b)]},{isDragging:!0,informMutation:!1}),this.setState({newElement:p}),Lf(p,!1)&&this.setState({suggestedBindings:vI(p,[r],this.scene,this.state.zoom,this.state.startBoundElement)})}else t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeDragNewGenericElement(t,n,!1)}if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let p=this.scene.getNonDeletedElements();if(this.state.selectedLinearElement?.isEditing)Ie.handleBoxSelection(n,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!n.shiftKey&&we(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(b=>qt({...b,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),b,this)):u=!1);let f=this.state.selectionElement?f1(p,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1):[];this.setState(b=>{let x={...u&&b.selectedElementIds,...f.reduce((y,E)=>(y[E.id]=!0,y),{})};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},{...qt({editingGroupId:b.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),b,this),selectedLinearElement:f.length===1&&jt(f[0])?new Ie(f[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:f.length===1&&(f[0].link||jo(f[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(t,n){if(n.scrollbars.isOverHorizontal){let r=t.clientX,i=r-n.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-i*(Nl.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),n.lastCoords.x=r,!0}if(n.scrollbars.isOverVertical){let r=t.clientY,i=r-n.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-i*(Nl.vertical?.deltaMultiplier||1)/this.state.zoom.value}),n.lastCoords.y=r,!0}return!1}onPointerUpFromPointerDownHandler(t){return Ae(n=>{this.removePointer(n),t.drag.blockDragging=!1,t.eventListeners.onMove&&t.eventListeners.onMove.flush();let{newElement:r,resizingElement:i,croppingElementId:a,multiElement:l,activeTool:s,isResizing:m,isRotating:d,isCropping:c}=this.state;this.setState(E=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:kl(E.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.lastPointerMoveCoords=null,Xt.setReferenceSnapPoints(null),Xt.setVisibleGaps(null),this.savePointer(n.clientX,n.clientY,"up");let p=t.hit.allHitElements,u=He({clientX:n.clientX,clientY:n.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);sG(E)&&E.boundElements?.filter(w=>w.type==="arrow").map(w=>f.get(w.id)).filter(w=>Xe(w)).forEach(w=>{w&&this.scene.mutateElement(w,{})})}if(this.state.selectedLinearElement?.isEditing)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.selectedLinearElement.elementId)this.actionManager.executeAction(_t);else{let E=Ie.handlePointerUp(n,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=Ie.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(_t,"ui",{event:n,sceneCoords:u})}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener(te.POINTER_MOVE,t.eventListeners.onMove),window.removeEventListener(te.POINTER_UP,t.eventListeners.onUp),window.removeEventListener(te.KEYDOWN,t.eventListeners.onKeyDown),window.removeEventListener(te.KEYUP,t.eventListeners.onKeyUp),this.props?.onPointerUp?.(s,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,n),r?.type==="freedraw"){let E=He(n,this.state),w=r.points,v=E.x-r.x,C=E.y-r.y;v===w[0][0]&&C===w[0][1]&&(C+=1e-4,v+=1e-4);let S=r.simulatePressure?[]:[...r.pressures,n.pressure];this.scene.mutateElement(r,{points:[...w,ie(v,C)],pressures:S,lastCommittedPoint:ie(v,C)}),this.actionManager.executeAction(_t);return}if(jt(r)){r.points.length>1&&this.store.scheduleCapture();let E=He(n,this.state),w=Rn(ie(E.x,E.y),ie(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||w<wI)&&r&&!l)if(this.device.isTouchScreen){let v=Math.min(this.state.width*.7/this.state.zoom.value,100);this.scene.mutateElement(r,{x:r.x-v/2,points:[ie(0,0),ie(v,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(_t)}else{let v=E.x-r.x,C=E.y-r.y;this.scene.mutateElement(r,{points:[...r.points,ie(v,C)]},{informMutation:!1,isDragging:!1}),this.setState({multiElement:r,newElement:r})}else t.drag.hasOccurred&&!l&&(Cf(this.state)&&Lf(r,!1)&&this.actionManager.executeAction(_t,"ui",{event:n,sceneCoords:u}),this.setState({suggestedBindings:[],startBoundElement:null}),s.locked?this.setState(v=>({newElement:null})):(Ut(this.interactiveCanvas),this.setState(v=>({newElement:null,activeTool:$o(this.state,{type:this.defaultSelectionTool}),selectedElementIds:ve({...v.selectedElementIds,[r.id]:!0},v),selectedLinearElement:new Ie(r,this.scene.getNonDeletedElementsMap())}))),this.scene.triggerUpdate());return}if(po(r)){let E=FG(wf({fontSize:r.fontSize,fontFamily:r.fontFamily}),r.lineHeight);r.width<E&&this.scene.mutateElement(r,{autoResize:!0}),this.resetCursor(),this.handleTextWysiwyg(r,{isExistingElement:!0})}if(s.type!=="selection"&&r&&RI(r)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==r.id),appState:{newElement:null},captureUpdate:Et.NEVER});return}if(kt(r)){let E=EG(this.scene.getElementsIncludingDeleted(),r,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(Of(this.scene.getElementsMapIncludingDeleted(),E,r,this.state))}if(r&&(this.scene.mutateElement(r,cG(r),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let E=He(n,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let w=this.scene.getElement(this.state.selectedLinearElement.elementId);if(w?.frameId){let v=Hf(w,f);v&&w&&(yG(w,v,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(w,{groupIds:[]}),xG([w],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let w=this.getTopLayerFrameAtSceneCoords(E),v=this.scene.getSelectedElements(this.state),C=this.scene.getElementsMapIncludingDeleted(),S=L=>{if(L.length>0){for(let P of L){let B=P.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(P,{groupIds:P.groupIds.slice(0,B)},{informMutation:!1,isDragging:!1})}C.forEach(P=>{P.groupIds.length&&xr(C,P.groupIds[P.groupIds.length-1]).length<2&&this.scene.mutateElement(P,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(w&&!this.state.selectedElementIds[w.id]){let L=v.filter(P=>P.frameId!==w.id&&GI(P,C,this.state));this.state.editingGroupId&&S(L),C=Of(C,L,w,this.state)}else if(!w&&this.state.editingGroupId){let L=v.filter(P=>P.frameId&&!GI(P,C,this.state));S(L)}C=HI(C,this.state,this),this.scene.replaceAllElements(C)}}if(i&&this.store.scheduleCapture(),i&&RI(i)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==i.id),captureUpdate:Et.NEVER}),t.resize.isResizing){let E=HI(this.scene.getElementsIncludingDeleted(),this.state,this),w=this.scene.getSelectedElements(this.state).filter(v=>kt(v));for(let v of w)E=bG(E,zf(this.scene.getElementsIncludingDeleted(),v,this.state,f),v,this);this.scene.replaceAllElements(E)}let b=t.hit.element;this.state.selectedLinearElement?.elementId!==b?.id&&jt(b)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new Ie(b,this.scene.getNonDeletedElementsMap())}),(!a||a&&(!b&&!c||b&&b.id!==a))&&this.finishImageCropping();let x=this.lastPointerDownEvent,y=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(yt(this.state)&&x&&y){if(this.eraserTrail.endPath(),Rn(ie(x.clientX,x.clientY),ie(y.clientX,y.clientY))===0){let w=He({clientX:y.clientX,clientY:y.clientY},this.state);this.getElementsAtPosition(w.x,w.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"&&(n.shiftKey&&!this.state.selectedLinearElement?.isEditing?this.state.selectedElementIds[b.id]?UG(this.state,b)?this.setState(E=>{let w={...E.selectedElementIds};for(let v of b.groupIds.flatMap(C=>xr(this.scene.getNonDeletedElements(),C)))delete w[v.id];return{selectedGroupIds:{...E.selectedElementIds,...b.groupIds.map(v=>({[v]:!1})).reduce((v,C)=>({...v,...C}),{})},selectedElementIds:ve(w,E)}}):this.state.selectedLinearElement?.isDragging||this.setState(E=>{let w={...E.selectedElementIds};delete w[b.id];let v=j(this.scene.getNonDeletedElements(),{selectedElementIds:w});return{...qt({editingGroupId:E.editingGroupId,selectedElementIds:w},this.scene.getNonDeletedElements(),E,this),selectedLinearElement:v.length===1&&jt(v[0])?new Ie(v[0],this.scene.getNonDeletedElementsMap()):E.selectedLinearElement}}):b.frameId&&this.state.selectedElementIds[b.frameId]?this.setState(E=>{let w={...E.selectedElementIds,[b.id]:!0};return delete w[b.frameId],(this.scene.getElement(b.frameId)?.groupIds??[]).flatMap(v=>xr(this.scene.getNonDeletedElements(),v)).forEach(v=>{delete w[v.id]}),{...qt({editingGroupId:E.editingGroupId,selectedElementIds:w},this.scene.getNonDeletedElements(),E,this),showHyperlinkPopup:b.link||jo(b)?"info":!1}}):this.setState(E=>({selectedElementIds:ve({...E.selectedElementIds,[b.id]:!0},E)})):this.setState(E=>({...qt({editingGroupId:E.editingGroupId,selectedElementIds:{[b.id]:!0}},this.scene.getNonDeletedElements(),E,this),selectedLinearElement:jt(b)&&E.selectedLinearElement?.elementId!==b.id?new Ie(b,this.scene.getNonDeletedElementsMap()):E.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(b&&Xe(b))&&!t.drag.hasOccurred&&!this.state.isResizing&&(b&&CG({point:ie(t.origin.x,t.origin.y),element:b,elementsMap:f,threshold:this.getElementHitThreshold(b),frameNameBound:kt(b)?this.frameNameBoundsCache.get(b):null},f)||!b&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(Di):this.setState({selectedElementIds:ve({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),ye(this.interactiveCanvas,_e.AUTO);return}if(!s.locked&&s.type!=="freedraw"&&r&&this.setState(E=>({selectedElementIds:ve({...E.selectedElementIds,[r.id]:!0},E),showHyperlinkPopup:jo(r)&&!r.link?"editor":E.showHyperlinkPopup})),(s.type!=="selection"||we(this.scene.getNonDeletedElements(),this.state)||!zH(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),t.drag.hasOccurred&&!this.state.selectedLinearElement||m||d||c){let E=this.scene.getSelectedElements(this.state).filter(jt);II(E,Cf(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)?(Ut(this.interactiveCanvas),this.setState({newElement:null,suggestedBindings:[],activeTool:$o(this.state,{type:this.defaultSelectionTool})})):this.setState({newElement:null,suggestedBindings:[]}),b&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&ge.pointers.size<=1&&Pl(b)&&this.isIframeLikeElementCenter(b,this.lastPointerUpEvent,t.origin.x,t.origin.y)&&this.handleEmbeddableCenterClick(b)})}clearSelection(t){this.setState(n=>({selectedElementIds:ve({},n),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:n.editingGroupId&&t!=null&&WI(t,n.editingGroupId)?n.editingGroupId:null})),this.setState({selectedElementIds:ve({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds})}getTextWysiwygSnappedToCenterPosition(t,n,r,i){if(i){let a=i.x+i.width/2,l=i.y+i.height/2,s=Bf(i,r,this.scene.getNonDeletedElementsMap());if(s&&(a=s.x,l=s.y),Math.hypot(t-a,n-l)<EH){let{x:c,y:p}=gm({sceneX:a,sceneY:l},r);return{viewportX:c,viewportY:p,elementCenterX:a,elementCenterY:l}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let t=this.excalidrawContainerRef.current,{left:n,top:r}=t.getBoundingClientRect();return{offsetLeft:n,offsetTop:r}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=Mr.find(n=>n.code===this.props.langCode)||fo;await es(t),this.setAppState({})}},QG=()=>{(Xf()||oC())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(nC(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};QG();var lC=Kf;import{useEffect as tU,useState as oU}from"react";import{jsx as nU}from"react/jsx-runtime";var sC=e=>{let[o,t]=oU(!0);return tU(()=>{let n=async()=>{await es(r),t(!1)},r=Mr.find(i=>i.code===e.langCode)||fo;n()},[e.langCode]),o?nU(Id,{theme:e.theme}):e.children};import rU from"clsx";import{jsx as cC}from"react/jsx-runtime";var dC=({children:e})=>{let{FooterCenterTunnel:o}=Ce(),t=be();return cC(o.In,{children:cC("div",{className:rU("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},iU=dC;dC.displayName="FooterCenter";import aU from"clsx";import{isMobileOrTablet as lU,MQ_MIN_WIDTH_DESKTOP as sU}from"@excalidraw/common";import{jsx as dU,jsxs as mU}from"react/jsx-runtime";var mC=({isCollaborating:e,onSelect:o,...t})=>{let n=be(),r=lU()||n.width<sU;return mU(Nt,{...t,className:aU("collab-button",{active:e}),type:"button",onSelect:o,style:{position:"relative",width:r?void 0:"auto"},title:g("labels.liveCollaboration"),children:[r?g0:g("labels.share"),n.collaborators.size>0&&dU("div",{className:"CollabButton-collaborators",children:n.collaborators.size})]})},cU=mC;mC.displayName="LiveCollaborationTrigger";import{jsx as Hn,jsxs as uC}from"react/jsx-runtime";var pU=()=>Hn("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Hn("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"})}),uU=()=>uC("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Hn("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)"}),Hn("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)"}),Hn("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)"}),Hn("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)"})]}),pC=({style:e,size:o="small",withText:t})=>uC("div",{className:`ExcalidrawLogo is-${o}`,style:e,children:[Hn(pU,{}),t&&Hn(uU,{})]});import{Fragment as fC,jsx as Ke,jsxs as e1}from"react/jsx-runtime";var t1=({icon:e,shortcut:o,children:t})=>{let n=de();return e1(fC,{children:[Ke("div",{className:"welcome-screen-menu-item__icon",children:e}),Ke("div",{className:"welcome-screen-menu-item__text",children:t}),o&&!n.editor.isMobile&&Ke("div",{className:"welcome-screen-menu-item__shortcut",children:o})]})};t1.displayName="WelcomeScreenMenuItemContent";var Ol=({onSelect:e,children:o,icon:t,shortcut:n,className:r="",...i})=>Ke("button",{...i,type:"button",className:`welcome-screen-menu-item ${r}`,onClick:e,children:Ke(t1,{icon:t,shortcut:n,children:o})});Ol.displayName="WelcomeScreenMenuItem";var hC=({children:e,href:o,icon:t,shortcut:n,className:r="",...i})=>Ke("a",{...i,className:`welcome-screen-menu-item ${r}`,href:o,target:"_blank",rel:"noopener",children:Ke(t1,{icon:t,shortcut:n,children:e})});hC.displayName="WelcomeScreenMenuItemLink";var Jt=({children:e})=>{let{WelcomeScreenCenterTunnel:o}=Ce();return Ke(o.In,{children:Ke("div",{className:"welcome-screen-center",children:e||e1(fC,{children:[Ke(o1,{}),Ke(n1,{children:g("welcomeScreen.defaults.center_heading")}),e1(r1,{children:[Ke(a1,{}),Ke(i1,{})]})]})})})};Jt.displayName="Center";var o1=({children:e})=>Ke("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||Ke(pC,{withText:!0})});o1.displayName="Logo";var n1=({children:e})=>Ke("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});n1.displayName="Heading";var r1=({children:e})=>Ke("div",{className:"welcome-screen-menu",children:e});r1.displayName="Menu";var i1=()=>{let e=We();return Ke(Ol,{onSelect:()=>e.executeAction(nr),shortcut:"?",icon:Dr,children:g("helpDialog.title")})};i1.displayName="MenuItemHelp";var a1=()=>{let e=be(),o=We();return e.viewModeEnabled?null:Ke(Ol,{onSelect:()=>o.executeAction(ri),shortcut:Fe("loadScene"),icon:_r,children:g("buttons.load")})};a1.displayName="MenuItemLoadScene";var gC=({onSelect:e})=>{let{t:o}=Ge();return Ke(Ol,{shortcut:null,onSelect:e,icon:cs,children:o("labels.liveCollaboration")})};gC.displayName="MenuItemLiveCollaborationTrigger";Jt.Logo=o1;Jt.Heading=n1;Jt.Menu=r1;Jt.MenuItem=Ol;Jt.MenuItemLink=hC;Jt.MenuItemHelp=i1;Jt.MenuItemLoadScene=a1;Jt.MenuItemLiveCollaborationTrigger=gC;import{jsx as Ji,jsxs as l1}from"react/jsx-runtime";var ym=({children:e})=>{let{WelcomeScreenMenuHintTunnel:o}=Ce();return Ji(o.In,{children:l1("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[$1,Ji("div",{className:"welcome-screen-decor-hint__label",children:e||g("welcomeScreen.defaults.menuHint")})]})})};ym.displayName="MenuHint";var wm=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:o}=Ce();return Ji(o.In,{children:l1("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[Ji("div",{className:"welcome-screen-decor-hint__label",children:e||g("welcomeScreen.defaults.toolbarHint")}),q1]})})};wm.displayName="ToolbarHint";var vm=({children:e})=>{let{WelcomeScreenHelpHintTunnel:o}=Ce();return Ji(o.In,{children:l1("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[Ji("div",{children:e||g("welcomeScreen.defaults.helpHint")}),j1]})})};vm.displayName="HelpHint";import{Fragment as bC,jsx as zl,jsxs as gU}from"react/jsx-runtime";var Tm=e=>zl(bC,{children:e.children||gU(bC,{children:[zl(Jt,{}),zl(ym,{}),zl(wm,{}),zl(vm,{})]})});Tm.displayName="WelcomeScreen";Tm.Center=Jt;Tm.Hints={MenuHint:ym,ToolbarHint:wm,HelpHint:vm};var hU=Tm;var fU=()=>{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)})},xC=fU;import{getSceneVersion as J7e,hashElementsVersion as Q7e,hashString as eDe,getNonDeletedElements as tDe}from"@excalidraw/element";import{getTextFromElements as nDe}from"@excalidraw/element";import{isInvisiblySmallElement as iDe}from"@excalidraw/element";import bU from"lodash.throttle";import{arrayToMap as xU,isDevEnv as EC,isTestEnv as yC}from"@excalidraw/common";import{orderByFractionalIndex as EU,syncInvalidIndices as wC,validateFractionalIndices as yU}from"@excalidraw/element";var wU=(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)),vU=bU((e,o,t)=>{if(EC()||yC()||window?.DEBUG_FRACTIONAL_INDICES){let n=wC(e.map(r=>({...r})));yU(n,{shouldThrow:yC()||EC(),includeBoundTextValidation:!0,reconciliationContext:{localElements:o,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),TU=(e,o,t)=>{let n=xU(e),r=[],i=new Set;for(let l of o)if(!i.has(l.id)){let s=n.get(l.id),m=wU(t,s,l);s&&m?(r.push(s),i.add(s.id)):(r.push(l),i.add(l.id))}for(let l of e)i.has(l.id)||(r.push(l),i.add(l.id));let a=EU(r);return vU(a,e,o),wC(a),a};import{getFreeDrawSvgPath as uDe}from"@excalidraw/element";import{isLinearElement as fDe}from"@excalidraw/element";import{FONT_FAMILY as xDe,THEME as EDe,MIME_TYPES as yDe,ROUNDNESS as vc,DEFAULT_LASER_COLOR as wDe,UserIdleState as vDe,normalizeLink as TDe}from"@excalidraw/common";import{mutateElement as Ic,newElementWith as CDe,bumpVersion as gi}from"@excalidraw/element";import{CaptureUpdateAction as kDe}from"@excalidraw/element";import{sceneCoordsToViewportCoords as Dy,viewportCoordsToSceneCoords as LDe}from"@excalidraw/common";import{jsx as vC,jsxs as IU}from"react/jsx-runtime";var TC=({children:e,icon:o})=>{let{TTDDialogTriggerTunnel:t}=Ce(),n=ae();return vC(t.In,{children:IU(xe.Item,{onSelect:()=>{re("ai","dialog open","ttd"),n({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:o??mb,children:[e??g("labels.textToDiagram"),vC(xe.Item.Badge,{children:"AI"})]})})};TC.displayName="TTDDialogTrigger";import{getCommonBounds as UDe,getVisibleSceneBounds as YDe}from"@excalidraw/element";import{useLayoutEffect as CU}from"react";var SU=e=>{let o=Be();return CU(()=>{o.setPlugins({diagramToCode:{generate:e.generate}})},[o,e.generate]),null};import{isElementLink as ZDe}from"@excalidraw/element";import{setCustomTextMetricsProvider as jDe}from"@excalidraw/element";import{jsx as s1}from"react/jsx-runtime";xC();var LU=e=>{let{onChange:o,onIncrement:t,initialData:n,excalidrawAPI:r,isCollaborating:i=!1,onPointerUpdate:a,renderTopRightUI:l,langCode:s=fo.code,viewModeEnabled:m,zenModeEnabled:d,gridModeEnabled:c,libraryReturnUrl:p,theme:u,name:f,renderCustomStats:b,onPaste:x,detectScroll:y=!0,handleKeyboardGlobally:E=!1,onLibraryChange:w,autoFocus:v=!1,generateIdForFile:C,onLinkOpen:S,generateLinkForSelection:L,onPointerDown:P,onPointerUp:B,onScrollChange:k,onDuplicate:A,children:F,validateEmbeddable:Y,renderEmbeddable:Q,aiEnabled:_,showDeprecatedFonts:R,renderScrollbars:W}=e,X=e.UIOptions?.canvasActions,G={...e.UIOptions,canvasActions:{...IC.canvasActions,...X},tools:{image:e.UIOptions?.tools?.image??!0}};return X?.export&&(G.canvasActions.export.saveFileToDisk=X.export?.saveFileToDisk??IC.canvasActions.export.saveFileToDisk),G.canvasActions.toggleTheme===null&&typeof u>"u"&&(G.canvasActions.toggleTheme=!0),MU(()=>{(async()=>{await import("canvas-roundrect-polyfill")})();let ue=pe=>{typeof pe.scale=="number"&&pe.scale!==1&&pe.preventDefault()};return document.addEventListener("touchmove",ue,{passive:!1}),()=>{document.removeEventListener("touchmove",ue)}},[]),s1(H1,{store:Ue,children:s1(sC,{langCode:s,theme:u,children:s1(lC,{onChange:o,onIncrement:t,initialData:n,excalidrawAPI:r,isCollaborating:i,onPointerUpdate:a,renderTopRightUI:l,langCode:s,viewModeEnabled:m,zenModeEnabled:d,gridModeEnabled:c,libraryReturnUrl:p,theme:u,name:f,renderCustomStats:b,UIOptions:G,onPaste:x,detectScroll:y,handleKeyboardGlobally:E,onLibraryChange:w,autoFocus:v,generateIdForFile:C,onLinkOpen:S,generateLinkForSelection:L,onPointerDown:P,onPointerUp:B,onScrollChange:k,onDuplicate:A,validateEmbeddable:Y,renderEmbeddable:Q,aiEnabled:_!==!1,showDeprecatedFonts:R,renderScrollbars:W,children:F})})})},AU=(e,o)=>{if(e.children!==o.children)return!1;let{initialData:t,UIOptions:n={},...r}=e,{initialData:i,UIOptions:a={},...l}=o,s=Object.keys(n),m=Object.keys(a);return s.length!==m.length?!1:s.every(c=>c==="canvasActions"?Object.keys(n.canvasActions).every(u=>u==="export"&&n?.canvasActions?.export&&a?.canvasActions?.export?n.canvasActions.export.saveFileToDisk===a.canvasActions.export.saveFileToDisk:n?.canvasActions?.[u]===a?.canvasActions?.[u]):n[c]===a[c])&&PU(r,l)},DU=kU.memo(LU,AU);DU.displayName="Excalidraw";export{Nt as Button,kDe as CaptureUpdateAction,wDe as DEFAULT_LASER_COLOR,Gd as DefaultSidebar,SU as DiagramToCodePlugin,Ia as Ellipsify,DU as Excalidraw,xDe as FONT_FAMILY,iU as Footer,cU as LiveCollaborationTrigger,yDe as MIME_TYPES,mt as MainMenu,vc as ROUNDNESS,$t as Sidebar,vl as Stats,EDe as THEME,Yg as TTDDialog,TC as TTDDialogTrigger,vDe as UserIdleState,hU as WelcomeScreen,gi as bumpVersion,Ni as convertToExcalidrawElements,fo as defaultLang,hw as elementPartiallyOverlapsWithOrContainsBBox,gw as elementsOverlappingBBox,Fy as exportToBlob,gn as exportToCanvas,wA as exportToClipboard,Ei as exportToSvg,UDe as getCommonBounds,Rm as getDataURL,uDe as getFreeDrawSvgPath,Pc as getLibraryItemsHash,tDe as getNonDeletedElements,J7e as getSceneVersion,nDe as getTextFromElements,YDe as getVisibleSceneBounds,Q7e as hashElementsVersion,eDe as hashString,Bh as isElementInsideBBox,ZDe as isElementLink,iDe as isInvisiblySmallElement,fDe as isLinearElement,Mr as languages,$l as loadFromBlob,_m as loadLibraryFromBlob,Dm as loadSceneOrLibraryFromBlob,Xy as mergeLibraryItems,Ic as mutateElement,CDe as newElementWith,TDe as normalizeLink,nh as parseLibraryTokensFromUrl,TU as reconcileElements,Sr as restore,LC as restoreAppState,PC as restoreElement,Lm as restoreElements,ra as restoreLibraryItems,Dy as sceneCoordsToViewportCoords,ta as serializeAsJSON,MC as serializeLibraryAsJSON,jDe as setCustomTextMetricsProvider,de as useDevice,OA as useHandleLibrary,Ge as useI18n,LDe as viewportCoordsToSceneCoords,Xx as zoomToFitBounds};
|