@myoc/excalidraw 0.19.509 → 0.19.510

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.
@@ -1,5 +1,5 @@
1
- import{$ as oc,A as Lk,B as Ab,C as Lb,D as qs,E as Qa,F as Js,G as Qs,H as el,I as _b,J as Db,K as Rb,L as ec,M as yr,N as Nb,O as _k,P as wr,Q as li,R as tl,T as Bb,V as Fb,W as Ob,X as tc,Y as zb,Z as Tp,_ as Sp,a as Cb,aa as Hb,b as xr,ba as Cp,c as Jt,ca as vr,d as kb,da as Gb,e as Pe,ea as kp,f as Pb,fa as Ub,g as ee,ga as Wb,h as ni,ha as Pp,i as Lo,ia as Yb,j as $a,ja as Vb,k as ja,ka as Xb,l as ri,la as ol,m as qa,n as ii,o as Mb,p as wp,q as nn,r as Pn,s as Mt,t as bo,u as ai,v as $s,w as vp,x as Ja,y as js,z as Ip}from"./chunk-WBVFIETZ.js";import{a as T}from"./chunk-QTEN3SXT.js";import{K as yp}from"./chunk-SC7IWESZ.js";import{c as Sb}from"./chunk-3PELD44J.js";import{b as Ib,c as Tb,d as S}from"./chunk-SRAX5OIU.js";import ZV,{useCallback as $V,useContext as jV,useEffect as qV,useRef as JV,useState as QV}from"react";import{DEFAULT_UI_OPTIONS as Pk,isShallowEqual as eX}from"@excalidraw/common";import QC from"clsx";import fW from"lodash.throttle";import go,{useContext as Cn}from"react";import{flushSync as $t}from"react-dom";import bW from"roughjs/bin/rough";import{nanoid as EW}from"nanoid";import{clamp as P1,pointFrom as oe,pointDistance as In,vector as e5,pointRotateRads as M1,vectorFromPoint as A1,vectorSubtract as t5,vectorDot as o5,vectorNormalize as n5}from"@excalidraw/math";import{COLOR_PALETTE as xW,CODES as r5,shouldResizeFromCenter as i5,shouldMaintainAspectRatio as _s,shouldRotateWithDiscreteAngle as a5,isArrowKey as np,KEYS as X,APP_NAME as yW,CURSOR_TYPE as Re,DEFAULT_TRANSFORM_HANDLE_SPACING as wW,DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT as vW,DEFAULT_VERTICAL_ALIGN as l5,DRAGGING_THRESHOLD as s5,ELEMENT_SHIFT_TRANSLATE_AMOUNT as IW,ELEMENT_TRANSLATE_AMOUNT as c5,EVENT as Q,FRAME_STYLE as $o,IMAGE_MIME_TYPES as TW,IMAGE_RENDER_TIMEOUT as SW,LINE_CONFIRM_THRESHOLD as L1,MAX_ALLOWED_FILE_BYTES as d5,MIME_TYPES as jo,MQ_RIGHT_SIDEBAR_MIN_WIDTH as CW,POINTER_BUTTON as qo,ROUNDNESS as rp,SCROLL_TIMEOUT as kW,TAP_TWICE_TIMEOUT as m5,TEXT_TO_CENTER_SNAP_THRESHOLD as PW,THEME as za,TOUCH_CTX_MENU_TIMEOUT as MW,VERTICAL_ALIGN as AW,YOUTUBE_STATES as ip,ZOOM_STEP as LW,POINTER_EVENTS as Ha,TOOL_TYPE as Jo,supportsResizeObserver as _W,DEFAULT_COLLISION_THRESHOLD as p5,DEFAULT_TEXT_ALIGN as DW,ARROW_TYPE as ur,DEFAULT_REDUCED_GLOBAL_ALPHA as RW,isLocalLink as NW,normalizeLink as _1,toValidURL as BW,getGridPoint as xt,getLineHeight as u5,debounce as h5,distance as Ga,getFontString as D1,getNearestScrollableContainer as FW,isInputLike as g5,isToolIcon as OW,isWritableElement as Ds,sceneCoordsToViewportCoords as ap,tupleToCoors as R1,viewportCoordsToSceneCoords as He,wrapEvent as zW,updateObject as N1,updateActiveTool as Qo,isTransparent as HW,easeToValuesRAF as GW,muteFSAbortError as UW,isTestEnv as rk,isDevEnv as ik,easeOut as WW,updateStable as Rs,addEventListener as Xe,normalizeEOL as YW,getDateTime as f5,isShallowEqual as b5,arrayToMap as lp,applyDarkModeFilter as VW,AppEventBus as XW,randomInteger as KW,CLASSES as B1,Emitter as Jr,MINIMUM_ARROW_SIZE as ZW,DOUBLE_TAP_POSITION_THRESHOLD as E5,BIND_MODE_TIMEOUT as $W,invariant as en,getFeatureFlag as Tn,createUserAgentDescriptor as ak,getFormFactor as jW,deriveStylesPanelMode as up,isIOS as qW,isBrave as JW,isSafari as QW,loadDesktopUIModePreference as eY,setDesktopUIMode as tY,isSelectionLikeTool as Ns,oneOf as oY,matchKey as x5}from"@excalidraw/common";import{getObservedAppState as nY,getCommonBounds as Ua,getElementAbsoluteCoords as y5,bindOrUnbindBindingElements as w5,fixBindingsAfterDeletion as rY,getHoveredElementForBinding as tn,isBindingEnabled as Bs,updateBoundElements as sp,newElementWith as hr,newFrameElement as iY,newFreeDrawElement as aY,newEmbeddableElement as v5,newMagicFrameElement as I5,newIframeElement as lY,newArrowElement as sY,newElement as cY,newImageElement as dY,newLinearElement as mY,newTextElement as T5,refreshTextDimensions as pY,deepCopyElement as S5,duplicateElements as F1,hasBoundTextElement as C5,isArrowElement as Wa,isBindingElement as on,isBindingElementType as uY,isBoundToContainer as O1,isFrameLikeElement as ht,isImageElement as Qr,isEmbeddableElement as Sn,isInitializedImageElement as Fs,isLinearElement as kt,isLinearElementType as hY,isUsingAdaptiveRadius as gY,isIframeElement as Ya,isIframeLikeElement as z1,isMagicFrameElement as k5,isTextBindableContainer as P5,isElbowArrow as Ht,isFlowchartNodeElement as fY,isBindableElement as H1,isTextElement as jt,getNormalizedDimensions as bY,isElementCompletelyInViewport as G1,isElementInViewport as M5,isInvisiblySmallElement as A5,getCornerRadius as EY,isPathALoop as L5,createSrcDoc as _5,embeddableURLValidator as U1,maybeParseEmbedSrc as xY,getEmbedLink as cp,getInitializedImageElements as yY,normalizeSVG as D5,updateImageCache as wY,getBoundTextElement as W1,getContainerCenter as Y1,getContainerElement as R5,isValidTextContainer as N5,redrawTextBoundingBox as vY,hasBoundingBox as IY,getCommonFrameId as B5,getFrameChildren as V1,getFrameChildrenInsertionIndex as TY,isCursorInFrame as F5,addElementsToFrame as X1,replaceAllElementsInFrame as SY,removeElementsFromFrame as CY,getElementsInResizingFrame as K1,getElementsInNewFrame as kY,getContainingFrame as Z1,elementOverlapsWithFrame as PY,updateFrameMembershipOfSelectedElements as O5,isElementInFrame as z5,getFrameLikeTitle as MY,getElementsOverlappingFrame as AY,filterElementsEligibleAsFrameChildren as LY,hitElementBoundText as _Y,hitElementBoundingBoxOnly as DY,hitElementItself as Os,getVisibleSceneBounds as RY,FlowChartCreator as NY,FlowChartNavigator as BY,getLinkDirectionFromKey as H5,cropElement as FY,wrapText as OY,isElementLink as $1,parseElementLinkFromURL as zY,isMeasureTextSupported as HY,normalizeText as GY,measureText as G5,getLineHeightInPx as U5,getApproxMinLineWidth as UY,getApproxMinLineHeight as WY,getMinTextElementWidth as YY,ShapeCache as zs,getRenderOpacity as VY,editGroupForSelectedElement as XY,getElementsInGroup as ei,getSelectedGroupIdForElement as KY,getSelectedGroupIds as ZY,isElementInGroup as W5,isSelectedViaGroup as $Y,selectGroupsForSelectedElements as ho,syncInvalidIndices as lk,syncMovedIndices as Y5,excludeElementsInFramesFromSelection as jY,getSelectionStateForElements as qY,makeNextSelectedElementIds as Ce,getResizeOffsetXY as JY,getResizeArrowDirection as QY,transformElements as eV,getCursorForResizingElement as V5,getElementWithTransformHandleType as X5,getTransformHandleTypeFromCoords as K5,dragNewElement as Z5,dragSelectedElements as tV,getDragOffsetXY as oV,isNonDeletedElement as $5,Scene as j5,Store as nV,CaptureUpdateAction as Pt,hitElementBoundingBox as rV,isLineElement as j1,isSimpleArrow as q1,StoreDelta as q5,positionElementsOnGrid as J5,calculateFixedPointForNonElbowArrowBinding as Q5,bindOrUnbindBindingElement as iV,mutateElement as dp,getElementBounds as ek,doBoundsIntersect as aV,isPointInElement as lV,maxBindingDistance_simple as J1,convertToExcalidrawElements as sV,getSnapOutlineMidPoint as Q1,handleFocusPointDrag as cV,handleFocusPointHover as dV,handleFocusPointPointerDown as mV,handleFocusPointPointerUp as pV,maybeHandleArrowPointlikeDrag as mp,getUncroppedWidthAndHeight as uV,getActiveTextElement as tk,isEligibleFrameChildType as hV}from"@excalidraw/element";import{LinearElementEditor as he}from"@excalidraw/element/linearElementEditor";import{findShapeByKey as gV}from"@excalidraw/element/shapes";import{KEYS as tu,MOBILE_ACTION_BUTTON_BG as Kk,updateActiveTool as Zk}from"@excalidraw/common";import{getNonDeletedElements as ou}from"@excalidraw/element";import{fixBindingsAfterDeletion as $k}from"@excalidraw/element";import{LinearElementEditor as Y0}from"@excalidraw/element/linearElementEditor";import{newElementWith as Pc}from"@excalidraw/element";import{getContainerElement as V0}from"@excalidraw/element";import{isBoundToContainer as Cc,isElbowArrow as jk,isFrameLikeElement as qk}from"@excalidraw/element";import{getFrameChildren as Jk}from"@excalidraw/element";import{getElementsInGroup as nu,selectGroupsForSelectedElements as Qk}from"@excalidraw/element";import{CaptureUpdateAction as kc}from"@excalidraw/element";import{isDevEnv as Bk}from"@excalidraw/common";import{atom as _e,createStore as Dk}from"jotai";import{createIsolation as Rk}from"jotai-scope";var Kb=Rk();var{useAtom:fe,useSetAtom:si,useAtomValue:nc,useStore:aX}=Kb,Zb=Kb.Provider,ot=Dk();var Nk=Ib({"./locales/ar-SA.json":()=>import("./locales/ar-SA-TS6M4GHP.js"),"./locales/az-AZ.json":()=>import("./locales/az-AZ-HJWG4CPD.js"),"./locales/bg-BG.json":()=>import("./locales/bg-BG-K42QREUV.js"),"./locales/bn-BD.json":()=>import("./locales/bn-BD-IFEECH4W.js"),"./locales/bn-IN.json":()=>import("./locales/bn-IN-OE7SKNFR.js"),"./locales/ca-ES.json":()=>import("./locales/ca-ES-MKBCGNOG.js"),"./locales/cs-CZ.json":()=>import("./locales/cs-CZ-V77HGUP7.js"),"./locales/da-DK.json":()=>import("./locales/da-DK-I5RFNTM4.js"),"./locales/de-CH.json":()=>import("./locales/de-CH-WLRDEVBV.js"),"./locales/de-DE.json":()=>import("./locales/de-DE-DTI4WUSC.js"),"./locales/el-GR.json":()=>import("./locales/el-GR-ZXDJ2OS4.js"),"./locales/en.json":()=>import("./locales/en-NJXWY54O.js"),"./locales/es-ES.json":()=>import("./locales/es-ES-DYQHAD43.js"),"./locales/eu-ES.json":()=>import("./locales/eu-ES-QDSYU5Y3.js"),"./locales/fa-IR.json":()=>import("./locales/fa-IR-26LZG4PM.js"),"./locales/fi-FI.json":()=>import("./locales/fi-FI-6YS4KDE4.js"),"./locales/fr-FR.json":()=>import("./locales/fr-FR-BRLLPTZC.js"),"./locales/gl-ES.json":()=>import("./locales/gl-ES-OKUZTLYG.js"),"./locales/he-IL.json":()=>import("./locales/he-IL-26MGYIU7.js"),"./locales/hi-IN.json":()=>import("./locales/hi-IN-Q4ZOGTP2.js"),"./locales/hu-HU.json":()=>import("./locales/hu-HU-P2OXPSN5.js"),"./locales/id-ID.json":()=>import("./locales/id-ID-2EIKXYN6.js"),"./locales/it-IT.json":()=>import("./locales/it-IT-4CFKVXI2.js"),"./locales/ja-JP.json":()=>import("./locales/ja-JP-MAND2Z4V.js"),"./locales/kaa.json":()=>import("./locales/kaa-HQRTCXTJ.js"),"./locales/kab-KAB.json":()=>import("./locales/kab-KAB-JKIKKTGH.js"),"./locales/kk-KZ.json":()=>import("./locales/kk-KZ-HXQ63ZFC.js"),"./locales/km-KH.json":()=>import("./locales/km-KH-PKL3LSGX.js"),"./locales/ko-KR.json":()=>import("./locales/ko-KR-KXLREZX3.js"),"./locales/ku-TR.json":()=>import("./locales/ku-TR-MJ4IER3X.js"),"./locales/lt-LT.json":()=>import("./locales/lt-LT-H6WFQ6FJ.js"),"./locales/lv-LV.json":()=>import("./locales/lv-LV-GOCK6SJW.js"),"./locales/mr-IN.json":()=>import("./locales/mr-IN-IXVLDMEQ.js"),"./locales/my-MM.json":()=>import("./locales/my-MM-YG6MYTTD.js"),"./locales/nb-NO.json":()=>import("./locales/nb-NO-XGWJISD2.js"),"./locales/nl-NL.json":()=>import("./locales/nl-NL-XVDVCPNC.js"),"./locales/nn-NO.json":()=>import("./locales/nn-NO-EMX5MJX5.js"),"./locales/oc-FR.json":()=>import("./locales/oc-FR-ROEINTVO.js"),"./locales/pa-IN.json":()=>import("./locales/pa-IN-ZYN6SUDY.js"),"./locales/percentages.json":()=>import("./locales/percentages-5DKR754L.js"),"./locales/pl-PL.json":()=>import("./locales/pl-PL-6VTG7PHC.js"),"./locales/pt-BR.json":()=>import("./locales/pt-BR-5YFKRR5G.js"),"./locales/pt-PT.json":()=>import("./locales/pt-PT-GEIXXZ67.js"),"./locales/ro-RO.json":()=>import("./locales/ro-RO-E2P6TFZI.js"),"./locales/ru-RU.json":()=>import("./locales/ru-RU-YBIIY43T.js"),"./locales/si-LK.json":()=>import("./locales/si-LK-673C2CI2.js"),"./locales/sk-SK.json":()=>import("./locales/sk-SK-CKZHQ4AP.js"),"./locales/sl-SI.json":()=>import("./locales/sl-SI-557H2GWM.js"),"./locales/sv-SE.json":()=>import("./locales/sv-SE-XOPKKDWS.js"),"./locales/ta-IN.json":()=>import("./locales/ta-IN-XBH7DQI3.js"),"./locales/th-TH.json":()=>import("./locales/th-TH-TOCWH3R4.js"),"./locales/tr-TR.json":()=>import("./locales/tr-TR-GXW6CYY5.js"),"./locales/uk-UA.json":()=>import("./locales/uk-UA-IJKTNUDG.js"),"./locales/uz-UZ.json":()=>import("./locales/uz-UZ-TBZZEA4V.js"),"./locales/vi-VN.json":()=>import("./locales/vi-VN-MULSGNVB.js"),"./locales/zh-CN.json":()=>import("./locales/zh-CN-MVX3E32U.js"),"./locales/zh-HK.json":()=>import("./locales/zh-HK-JNU5RLIE.js"),"./locales/zh-TW.json":()=>import("./locales/zh-TW-LENVCA6T.js")});var Fk=85,_o={code:"en",label:"English"},di=[_o,...[{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=>Sb[e.code]>=Fk).sort((e,o)=>e.label>o.label?1:-1)],ic="__test__";Bk()&&di.unshift({code:ic,label:"test language"},{code:`${ic}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var ci=_o,rc={},ac=async e=>{if(ci=e,document.documentElement.dir=ci.rtl?"rtl":"ltr",document.documentElement.lang=ci.code,e.code.startsWith(ic))rc={};else try{rc=await Nk(`./locales/${ci.code}.json`)}catch(o){console.error(`Failed to load language ${e.code}:`,o.message),rc=yp}ot.set(jb,e.code)},rn=()=>ci,$b=(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},f=(e,o,t)=>{if(ci.code.startsWith(ic))return`\u202A[[${o?`${e}(${JSON.stringify(o).slice(1,-1)})`:e}]]\u202C`;let n=e.split("."),r=$b(rc,n)||$b(yp,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},jb=_e(_o.code),Me=()=>{let e=nc(jb);return{t:f,langCode:e}};import Ok from"clsx";import $e from"react";import{THEME as zk}from"@excalidraw/common";import{Fragment as Ae,jsx as h,jsxs as B}from"react/jsx-runtime";var Eo=e=>"var(--icon-fill-color)",qb=e=>e===zk.LIGHT?"#fff":"#1e1e1e",P=(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:Ok({"rtl-mirror":r}),style:i,...a,children:typeof e=="string"?h("path",{fill:"currentColor",d:e}):e})},H={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},le={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},yt={width:40,height:20},wX=P(B("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"})]}),H),lc=P(B("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"})]}),H),Jb=P(B("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"})]}),H),Qb=P(B("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"})]}),H),eE=P(B("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"})]}),H),tE=P(B("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"})]}),H),Mp=P(B("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"})]}),H),an=P(B("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"})})]}),le),Mn=P(B("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"})]}),le),oE=P(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}),nE=P(B(Ae,{children:[h("path",{d:"M38.5 83.5c-14-2-17.833-10.473-21-22.5C14.333 48.984 12 22 12 12.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),h("path",{d:"M12.005 10.478c1.92 3.495 3.838 7 7.905 14.423m-7.905-14.423c3.11 5.683 6.23 11.368 7.905 14.423m0 0c-3.68.226-7.35.455-13.91.85m13.91-.85c-5.279.33-10.566.647-13.91.85m0 0c1.936-4.931 3.882-9.86 6.005-15.273M6 25.75c2.069-5.257 4.135-10.505 6.005-15.272",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:41,height:94,fill:"none"}),rE=P(B(Ae,{children:[h("path",{d:"M18.026 1.232c-5.268 13.125-5.548 33.555 3.285 42.311 8.823 8.75 33.31 12.304 42.422 13.523",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),h("path",{d:"M72.181 59.247c-3.163-2.429-6.337-4.856-13.058-10m13.058 10c-5.145-3.936-10.292-7.882-13.058-10m0 0c-.78 3.603-1.563 7.196-2.948 13.62m2.948-13.62c-1.126 5.168-2.24 10.346-2.948 13.62m0 0c5.168-1.166 10.334-2.343 16.006-3.62m-16.006 3.62c5.51-1.248 11.01-2.495 16.006-3.62",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:85,height:71,fill:"none"}),iE=P(B(Ae,{children:[h("path",{d:"M1 77c14-2 31.833-11.973 35-24 3.167-12.016-6-35-9.5-43.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),h("path",{d:"M24.165 1.093c-.522 3.953-1.037 7.916-2.132 16.309m2.131-16.309c-.835 6.424-1.68 12.854-2.13 16.308m0 0c3.51-1.125 7.013-2.243 13.27-4.257m-13.27 4.257c5.038-1.608 10.08-3.232 13.27-4.257m0 0c-3.595-3.892-7.197-7.777-11.14-12.05m11.14 12.05c-3.837-4.148-7.667-8.287-11.14-12.05",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:38,height:78,fill:"none"}),vX=P(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"}),sc=P(B("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}),An=P(B("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}),cc=P(B("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"})]}),H),dc=P(B("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"})]}),H),mc=P(B("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"})]}),H),aE=P(B("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"})]}),H),pc=P(h("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),le),lE=P(B("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"})]}),H),Ln=P(B("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"})]}),le),_n=P(B("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"})]}),H),sE=P(B("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"})]}),H),uc=P(B("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"})]}),le),cE=P(B("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"})]}),H),Ap=P(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),le),Lp=P(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),le),dE=P(B("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"})]}),H),ln=P(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"}),le),hc=P(B("g",{strokeWidth:"1.5",children:[h("polyline",{points:"12 16 18 10 12 4"}),h("polyline",{points:"8 4 2 10 8 16"})]}),le),nl=P(B("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"})]}),le),rl=P(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"}),le),il=P(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"})}),{...le,strokeWidth:1.5}),mE=P(B("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"})]}),H),Ir=P(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"}),le),mi=P(B("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"})]}),H),pE=P(B("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"})]}),H),IX=P(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"}),le),uE=P(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"}),le),hE=P(B("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"})]}),le),gE=P(B("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"})]}),H),gc=P(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),al=P(B("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"})]}),le),fE=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}),bE=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}),pi=P(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"}),le),TX=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}),SX=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"),ui=P(B("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"})]}),H),EE=P(h("g",{strokeWidth:1.5,children:h("path",{d:"M6 18l12 -12"})}),H),fc=P(B("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"})]}),H),xE=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}),CX=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}),kX=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}),yE=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"),PX=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"),_p=P(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"}),le),Dp=P(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"}),le),wE=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}),vE=P(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"}),le),MX=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"),AX=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}),LX=P(B("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"})]}),H),_X=P(B(Ae,{children:[h("path",{fill:"currentColor",d:"M40 5.6v6.1l-4.1.7c-8.9 1.4-16.5 6.9-20.6 15C13 32 10.9 43 12.4 43c.4 0 2.4-1.3 4.4-3 5-3.9 12.1-7 18.2-7.7l5-.6v12.8l11.2-11.3L62.5 22 51.2 10.8 40-.5v6.1zm10.2 22.6L44 34.5v-6.8l-6.9.6c-3.9.3-9.8 1.7-13.2 3.1-3.5 1.4-6.5 2.4-6.7 2.2-.9-1 3-7.5 6.4-10.8C28 18.6 34.4 16 40.1 16c3.7 0 3.9-.1 3.9-3.2V9.5l6.2 6.3 6.3 6.2-6.3 6.2z"}),h("path",{stroke:"currentColor",fill:"currentColor",d:"M0 36v20h48v-6.2c0-6 0-6.1-2-4.3-1.1 1-2 2.9-2 4.2V52H4V34c0-17.3-.1-18-2-18s-2 .7-2 20z"})]}),{width:64,height:64}),DX=P(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}),IE=B("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"})]}),TE=B("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"})]}),Rp=P(TE,H),Np=P(TE,{...H,style:{transform:"rotate(180deg)"}}),Bp=P(IE,H),Fp=P(IE,{...H,style:{transform:"rotate(180deg)"}}),Op=P(B(Ae,{children:[B("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"})})})]}),le),zp=P(B(Ae,{children:[B("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"})})})]}),le),Hp=P(B(Ae,{children:[B("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"})})})]}),le),Gp=P(B(Ae,{children:[B("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"})})})]}),le),SE=P(B(Ae,{children:[B("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"})})})]}),le),CE=P(B(Ae,{children:[B("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"})})})]}),le),Up=P(B("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"})]}),le),Wp=P(B("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"})]}),le),bc=P(B("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"})]}),H),RX=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"),NX=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"),Qt=P(B(Ae,{children:[h("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M15 5 5 15M5 5l10 10"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),BX=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}),FX=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}),OX=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}),Yp=$e.memo(({theme:e})=>P(B(Ae,{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"}),B("g",{fill:qb(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})),Vp=$e.memo(({theme:e})=>P(B(Ae,{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"}),B("g",{fill:qb(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})),kE=P(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"})}),le),PE=P(B(Ae,{children:[h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.25"})}),h("g",{mask:"url(#FillHachureIcon)",children:h("path",{d:"M2.258 15.156 15.156 2.258M7.324 20.222 20.222 7.325m-20.444 5.35L12.675-.222m-8.157 18.34L17.416 5.22",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})]}),le),ME=P(B(Ae,{children:[B("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"})})})]}),le),AE=P(B(Ae,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z",stroke:"currentColor",strokeWidth:"1.25"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...le,fill:"currentColor"}),Xp=P(h(Ae,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),le),LE=P(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),le),_E=P(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),le),zX=$e.memo(({theme:e})=>P(h("path",{d:"M6 10H34",stroke:Eo(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),DE=P(B("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"})]}),H),RE=P(B("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"})]}),H),NE=P(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"}),le),BE=P(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"}),le),FE=P(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"}),le),OE=P(B("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"})]}),le),zE=P(B("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"})]}),H),HE=$e.memo(({flip:e=!1})=>P(B("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",opacity:.3,strokeWidth:2,fill:"none",strokeLinecap:"round",children:[h("path",{d:"M7,11 H19"}),h("path",{d:"M25,6 L33,16 M33,6 L25,16"})]}),yt)),GE=$e.memo(({flip:e=!1})=>P(h("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M7,11 H33 M23,5 L33,11 L23,17"})}),yt)),UE=$e.memo(({flip:e=!1})=>P(B("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",children:[h("path",{d:"M7,11 H23",strokeWidth:2,strokeLinecap:"round"}),h("path",{d:"M23,5 L35,11 L23,17 Z"})]}),yt)),WE=$e.memo(({flip:e=!1})=>P(B("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",children:[h("path",{d:"M7,11 H23"}),h("path",{d:"M23,5 L35,11 L23,17 Z"})]}),yt)),YE=$e.memo(({flip:e=!1})=>P(B("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[h("path",{d:"M7,11 H25",strokeWidth:2,strokeLinecap:"round"}),h("circle",{cx:"29",cy:"11",r:"4"})]}),yt)),VE=$e.memo(({flip:e=!1})=>P(B("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[h("path",{d:"M7,11 H25",strokeLinecap:"round"}),h("circle",{cx:"29",cy:"11",r:"4"})]}),yt)),XE=$e.memo(({flip:e=!1})=>P(B("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",children:[h("path",{d:"M7,11 H21",strokeWidth:2,strokeLinecap:"round"}),h("path",{d:"M21,11 L28,5 L35,11 L28,17 Z"})]}),yt)),KE=$e.memo(({flip:e=!1})=>P(B("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,strokeLinecap:"round",children:[h("path",{d:"M7,11 H21"}),h("path",{d:"M21,11 L28,5 L35,11 L28,17 Z"})]}),yt)),ZE=$e.memo(({flip:e=!1})=>P(h("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",strokeLinecap:"round",children:h("path",{d:"M11,11 H31 M31,5 V17"})}),yt)),$E=$e.memo(({flip:e=!1})=>P(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M15,5 V17"})}),yt)),jE=$e.memo(({flip:e=!1})=>P(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M15,11 L7,5 M15,11 L7,17"})}),yt)),qE=$e.memo(({flip:e=!1})=>P(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M23,5 V17 M15,11 L7,5 M15,11 L7,17"})}),yt)),JE=$e.memo(({flip:e=!1})=>P(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M15,5 V17 M7,5 V17"})}),yt)),QE=$e.memo(({flip:e=!1})=>P(B("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M35,11 H19 M11,11 H7 M7,5 V17"}),h("circle",{cx:"15",cy:"11",r:"4"})]}),yt)),e0=$e.memo(({flip:e=!1})=>P(B("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M35,11 H27 M19,11 H7 M15,11 L7,5 M15,11 L7,17"}),h("circle",{cx:"23",cy:"11",r:"4"})]}),yt)),t0=P(B(Ae,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M14.167 6.667a3.333 3.333 0 0 0-3.334-3.334H9.167a3.333 3.333 0 0 0 0 6.667h1.666a3.333 3.333 0 0 1 0 6.667H9.167a3.333 3.333 0 0 1-3.334-3.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),o0=P(B(Ae,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),n0=P(B(Ae,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),r0=P(h(Ae,{children:h("path",{d:"m1.667 3.333 6.666 13.334M8.333 3.333 1.667 16.667M11.667 3.333v13.334h6.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),le),Tr=P(B("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"})]}),H),i0=P(h(Ae,{children:B("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"})]})}),H),ll=P(h(Ae,{children:h("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M5.833 16.667v-10a3.333 3.333 0 0 1 3.334-3.334h1.666a3.333 3.333 0 0 1 3.334 3.334v10M5.833 10.833h8.334"})})}),le),Hk=P(B("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 8l-4 4l4 4"}),h("path",{d:"M17 8l4 4l-4 4"}),h("path",{d:"M14 4l-4 16"})]}),H),Ec=Hk,a0=P(B("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"})]}),H),l0=P(B("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"})]}),H),s0=P(B("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"})]}),H),c0=$e.memo(({theme:e})=>P(B("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"})]}),H)),d0=$e.memo(({theme:e})=>P(B("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"})]}),H)),m0=$e.memo(({theme:e})=>P(B("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"})]}),H)),xc=P(B("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"})]}),H),p0=P(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}),HX=P(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"})),yc=P(B("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"})]}),H),Kp=P(B(Ae,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),h("path",{d:"M7 11l5 5l5 -5"}),h("path",{d:"M12 4l0 12"})]}),H),hi=P(B(Ae,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 8m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z"}),h("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),H),u0=P(B("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"})]}),H),h0=P(B(Ae,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),h("path",{d:"M12 17l0 .01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),H),GX=P(B(Ae,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),H),UX=P(B(Ae,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M17 4h-10a3 3 0 0 0 -3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3 -3v-10a3 3 0 0 0 -3 -3z",strokeWidth:"0",fill:"currentColor"})]}),H),g0=P(B(Ae,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),H),f0=P(B(Ae,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.24 3.957l-8.422 14.06a1.989 1.989 0 0 0 1.7 2.983h16.845a1.989 1.989 0 0 0 1.7 -2.983l-8.423 -14.06a1.989 1.989 0 0 0 -3.4 0z"}),h("path",{d:"M12 9v4"}),h("path",{d:"M12 17h.01"})]}),H),b0=P(B("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"})]}),H),gi=P(B("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"})]}),H),Dn=P(B("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"})]}),H),WX=P(B("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4"}),h("path",{d:"M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"})]}),H),YX=P(B("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 10l-2 1l8 4l8 -4l-2 -1"}),h("path",{d:"M4 15l8 4l8 -4"}),h("path",{d:"M12 4v7"}),h("path",{d:"M15 8l-3 3l-3 -3"})]}),H),VX=P(B("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"})]}),le),fi=P(B("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),E0=P(B("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"})]}),H),XX=P(B("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"})]}),H),KX=P(B("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"})]}),H),x0=P(B("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"})]}),H),Sr=P(B("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"})]}),H),y0=P(B("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"})]}),H),ZX=P(B("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"})]}),H),$X=P(B("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"})]}),H),Gt=P(B("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"})]}),H),w0=P(B("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"})]}),H),jX=P(B("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 8l0 4l2 2"}),h("path",{d:"M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5"})]}),H),v0=P(B("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"})]}),H),I0=P(B("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"})]}),H),sl=P(B("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"})]}),H),T0=P(B("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"})]}),H),S0=P(B("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"})]}),H),C0=P(B("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"})]}),H),k0=P(B("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"})]}),H),Zp=P(B("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"})]}),H),wc=P(B("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"})]}),H),P0=P(B("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"})]}),H),M0=P(B("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"})]}),H),A0=P(B("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"})]}),H),L0=P(B("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"})]}),H),_0=P(B("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"})]}),{...H,strokeWidth:1.5}),qX=P(B("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"})]}),H),JX=P(B("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"})]}),H),D0=P(B("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"})]}),H),R0=P(B("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"})]}),H),bi=P(B("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 18l12 -12"}),h("path",{d:"M18 10v-4h-4"})]}),H),Ei=P(B("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"})]}),H),xi=P(B("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),H),vc=P(B("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),H),N0=P(B("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),H),B0=P(B("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),H),$p=P(B("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"})]}),H),Ic=P(B("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"})]}),H),jp=P(B("g",{strokeWidth:"1.25",children:[h("rect",{x:"4",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"4",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"4",y:"16",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"16",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"16",width:"4",height:"4",rx:"1"})]}),H),qp=P(B("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:"7",y:"6",width:"10",height:"8",rx:"1",strokeDasharray:"2 2"}),h("line",{x1:"3",y1:"6",x2:"3",y2:"14"}),h("polyline",{points:"2 8 3 6 4 8"}),h("polyline",{points:"2 12 3 14 4 12"}),h("line",{x1:"7",y1:"18",x2:"17",y2:"18"}),h("polyline",{points:"9 17 7 18 9 19"}),h("polyline",{points:"15 17 17 18 15 19"})]}),H),QX=P(B("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"})]}),H),Jp=P(h("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:.5,viewBox:"0 0 640 512",children:h("path",{d:"M15 15C24.4 5.7 39.6 5.7 49 15l63 63L112 40c0-13.3 10.7-24 24-24s24 10.7 24 24l0 96c0 13.3-10.7 24-24 24l-96 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l38.1 0L15 49C5.7 39.6 5.7 24.4 15 15zM133.5 243.9C158.6 193.6 222.7 112 320 112s161.4 81.6 186.5 131.9c3.8 7.6 3.8 16.5 0 24.2C481.4 318.4 417.3 400 320 400s-161.4-81.6-186.5-131.9c-3.8-7.6-3.8-16.5 0-24.2zM320 320a64 64 0 1 0 0-128 64 64 0 1 0 0 128zM591 15c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-63 63 38.1 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-96 0c-13.3 0-24-10.7-24-24l0-96c0-13.3 10.7-24 24-24s24 10.7 24 24l0 38.1 63-63zM15 497c-9.4-9.4-9.4-24.6 0-33.9l63-63L40 400c-13.3 0-24-10.7-24-24s10.7-24 24-24l96 0c13.3 0 24 10.7 24 24l0 96c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-38.1L49 497c-9.4 9.4-24.6 9.4-33.9 0zm576 0l-63-63 0 38.1c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-96c0-13.3 10.7-24 24-24l96 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-38.1 0 63 63c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0z"})})),F0=P(B("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"})]}),H),O0=P(B("g",{strokeWidth:1,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 10l4 -4 L6 14l8 -8 L6 18l12 -12 L10 18l8 -8 L14 18l4 -4"})]}),H),Gk=P(B("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4"}),h("path",{d:"M13.5 6.5l4 4"})]}),H),eK=P(B("g",{strokeWidth:1,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M11 7l-5 5l5 5"}),h("path",{d:"M17 7l-5 5l5 5"})]}),H),z0=P(B("g",{strokeWidth:"1.75",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 4m0 2a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2z"}),h("path",{d:"M15 4l0 16"})]}),H),tK=P(B("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 20l1.3 -3.9c-2.324 -3.437 -1.426 -7.872 2.1 -10.374c3.526 -2.501 8.59 -2.296 11.845 .48c3.255 2.777 3.695 7.266 1.029 10.501c-2.666 3.235 -7.615 4.215 -11.574 2.293l-4.7 1"})]}),H),oK=P(B("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 4l18 0"}),h("path",{d:"M4 4v10a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-10"}),h("path",{d:"M12 16l0 4"}),h("path",{d:"M9 20l6 0"}),h("path",{d:"M8 12l3 -3l2 2l3 -3"})]}),H),Tc=h("div",{style:{width:"1rem",height:"1rem"}}),H0=P(B("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("polyline",{points:"9 6 15 12 9 18"})]}),H),G0=P(B("g",{strokeWidth:1.25,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"})]}),H);import U0 from"clsx";import eu,{useEffect as Yk,useRef as W0,useState as Vk}from"react";import{isPromiseLike as Xk}from"@excalidraw/common";import Uk from"react";import{jsx as Qp}from"react/jsx-runtime";var Wk=({size:e="1em",circleWidth:o=8,synchronized:t=!1,className:n=""})=>{let i=-(Uk.useRef(Date.now()).current%1600);return Qp("div",{className:`Spinner ${n}`,children:Qp("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:Qp("circle",{cx:"50",cy:"50",r:50-o/2,strokeWidth:o,fill:"none",strokeMiterlimit:"10"})})})},Ut=Wk;import{jsx as cl,jsxs as dl}from"react/jsx-runtime";var Z=eu.forwardRef(({size:e="medium",visible:o=!0,className:t="",...n},r)=>{let{id:i}=Ne(),a=eu.useRef(null);eu.useImperativeHandle(r,()=>a.current);let l=`ToolIcon_size_${e}`,[s,c]=Vk(!1),m=W0(!0),p=async u=>{let b="onClick"in n&&n.onClick?.(u);if(Xk(b))try{c(!0),await b}catch(g){if(g instanceof ii)console.warn(g);else throw g}finally{m.current&&c(!1)}};Yk(()=>(m.current=!0,()=>{m.current=!1}),[]);let d=W0(null);if(n.type==="button"||n.type==="icon"||n.type==="submit"){let u=n.type==="icon"?"button":n.type;return dl("button",{className:U0("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:p,ref:a,disabled:s||n.isLoading||!!n.disabled,children:[(n.icon||n.label)&&dl("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!n.disabled,children:[n.icon||n.label,n.keyBindingLabel&&cl("span",{className:"ToolIcon__keybinding",children:n.keyBindingLabel}),n.isLoading&&cl(Ut,{})]}),n.showAriaLabel&&dl("div",{className:"ToolIcon__label",children:[n["aria-label"]," ",s&&cl(Ut,{})]}),n.children]})}return dl("label",{className:U0("ToolIcon",t),title:n.title,onPointerDown:u=>{d.current=u.pointerType||null,n.onPointerDown?.({pointerType:u.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{d.current=null})},children:[cl("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:d.current})},checked:n.checked,ref:a}),dl("div",{className:"ToolIcon__icon",children:[n.icon,n.keyBindingLabel&&cl("span",{className:"ToolIcon__keybinding",children:n.keyBindingLabel})]})]})});Z.displayName="ToolButton";var Sc=[],F=e=>(Sc=Sc.concat(e),e);import{jsx as tP}from"react/jsx-runtime";var eP=(e,o,t)=>{let n=new Set(ee(e.filter(m=>qk(m)),o).map(m=>m.id)),r={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let m of n){let p=Jk(e,m);for(let d of p)if(!a.has(d.id)){if(Cc(d)){let u=V0(d,i);u&&(r[u.id]=!0)}else r[d.id]=!0;a.add(d.id)}}let l=!0,s=e.map(m=>{if(o.selectedElementIds[m.id]){let p=Cc(m)?V0(m,i):null;return m.frameId&&n.has(m.frameId)?(l=!1,r[m.id]=!0,m):p?.frameId&&n.has(p?.frameId)?m:(m.boundElements&&m.boundElements.forEach(d=>{let u=t.scene.getNonDeletedElementsMap().get(d.id);u&&jk(u)&&t.scene.mutateElement(u,{startBinding:m.id===u.startBinding?.elementId?null:u.startBinding,endBinding:m.id===u.endBinding?.elementId?null:u.endBinding})}),Pc(m,{isDeleted:!0}))}return m.frameId&&n.has(m.frameId)?(l=!1,Cc(m)||(r[m.id]=!0),Pc(m,{frameId:null})):Cc(m)&&o.selectedElementIds[m.containerId]?Pc(m,{isDeleted:!0}):m}),c=o.editingGroupId;if(l&&o.editingGroupId){let m=nu(s,o.editingGroupId).filter(p=>!p.isDeleted);if(m.length>1)m[0]&&(r[m[0].id]=!0);else{c=null,m[0]&&(r[m[0].id]=!0);let p=m[0];if(p){let d=p.groupIds.findIndex(b=>b===o.editingGroupId),u=p.groupIds[d+1];if(u){let b=nu(s,u).filter(g=>!g.isDeleted);b.length>1&&(c=u,b.forEach(g=>{r[g.id]=!0}))}}}}return{elements:s,appState:{...o,...Qk({selectedElementIds:r,editingGroupId:c},s,o,null)}}},X0=(e,o)=>{if(e.editingGroupId){let t=nu(ou(o),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},ml=F({name:"deleteSelectedElements",label:"labels.delete",icon:ln,trackEvent:{category:"element",action:"delete"},perform:(e,o,t,n)=>{if(o.selectedLinearElement?.isEditing){let{elementId:a,selectedPointsIndices:l}=o.selectedLinearElement,s=n.scene.getNonDeletedElementsMap(),c=Y0.getElement(a,s);if(!c||l==null)return!1;if(l.length>=c.points.length){let m=e.map(d=>d.id===c.id?Pc(d,{isDeleted:!0}):d),p=X0(o,m);return{elements:m,appState:{...p,selectedLinearElement:null},captureUpdate:kc.IMMEDIATELY}}return Y0.deletePoints(c,n,l),{elements:e,appState:{...o,selectedLinearElement:{...o.selectedLinearElement,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},captureUpdate:kc.IMMEDIATELY}}let{elements:r,appState:i}=eP(e,o,n);return $k(r,r.filter(a=>a.isDeleted)),i=X0(i,r),{elements:r,appState:{...i,activeTool:Zk(o,{type:n.state.preferredSelectionTool.type}),multiElement:null,newElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Pe(ou(e),o)?kc.IMMEDIATELY:kc.EVENTUALLY}},keyTest:(e,o,t)=>(e.key===tu.BACKSPACE||e.key===tu.DELETE)&&!e[tu.CTRL_OR_CMD],PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=nt()==="mobile";return tP(Z,{type:"button",icon:ln,title:f("labels.delete"),"aria-label":f("labels.delete"),onClick:()=>t(null),disabled:!Pe(ou(e),o),style:{...r&&o.openPopup!=="compactOtherProperties"?Kk:{}}})}});import{KEYS as yi,CODES as wi,isDarwin as Mc}from"@excalidraw/common";import{moveOneLeft as oP,moveOneRight as nP,moveAllLeft as rP,moveAllRight as iP}from"@excalidraw/element";import{CaptureUpdateAction as Ac}from"@excalidraw/element";import{isDarwin as K0}from"@excalidraw/common";var N=e=>e.replace(/\b(Opt(?:ion)?|Alt)\b/i,K0?f("keys.option"):f("keys.alt")).replace(/\bShift\b/i,f("keys.shift")).replace(/\b(Enter|Return)\b/i,f("keys.enter")).replace(/\b(Ctrl|Cmd|Command|CtrlOrCmd)\b/gi,K0?f("keys.cmd"):f("keys.ctrl")).replace(/\b(Esc(?:ape)?)\b/i,f("keys.escape")).replace(/\b(Space(?:bar)?)\b/i,f("keys.spacebar")).replace(/\b(Del(?:ete)?)\b/i,f("keys.delete"));import{jsx as Lc}from"react/jsx-runtime";var ru=F({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:Np,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:oP(e,o,n.scene),appState:o,captureUpdate:Ac.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[yi.CTRL_OR_CMD]&&!e.shiftKey&&e.code===wi.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>Lc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendBackward")} \u2014 ${N("CtrlOrCmd+[")}`,children:Np})}),iu=F({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:Rp,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:nP(e,o,n.scene),appState:o,captureUpdate:Ac.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[yi.CTRL_OR_CMD]&&!e.shiftKey&&e.code===wi.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>Lc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.bringForward")} \u2014 ${N("CtrlOrCmd+]")}`,children:Rp})}),au=F({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:Fp,trackEvent:{category:"element"},perform:(e,o)=>({elements:rP(e,o),appState:o,captureUpdate:Ac.IMMEDIATELY}),keyTest:e=>Mc?e[yi.CTRL_OR_CMD]&&e.altKey&&e.code===wi.BRACKET_LEFT:e[yi.CTRL_OR_CMD]&&e.shiftKey&&e.code===wi.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>Lc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendToBack")} \u2014 ${Mc?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")}`,children:Fp})}),lu=F({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:Bp,trackEvent:{category:"element"},perform:(e,o)=>({elements:iP(e,o),appState:o,captureUpdate:Ac.IMMEDIATELY}),keyTest:e=>Mc?e[yi.CTRL_OR_CMD]&&e.altKey&&e.code===wi.BRACKET_RIGHT:e[yi.CTRL_OR_CMD]&&e.shiftKey&&e.code===wi.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>Lc("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${f("labels.bringToFront")} \u2014 ${Mc?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")}`,children:Bp})});import{getNonDeletedElements as aP}from"@excalidraw/element";import{LinearElementEditor as lP}from"@excalidraw/element/linearElementEditor";import{isLinearElement as sP,isTextElement as cP}from"@excalidraw/element";import{arrayToMap as dP,KEYS as Z0}from"@excalidraw/common";import{selectGroupsForSelectedElements as mP}from"@excalidraw/element";import{CaptureUpdateAction as pP}from"@excalidraw/element";var su=F({name:"selectAll",label:"labels.selectAll",icon:T0,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,o,t,n)=>{if(o.selectedLinearElement?.isEditing)return!1;let r=e.filter(i=>!i.isDeleted&&!(cP(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...o,...mP({editingGroupId:null,selectedElementIds:r},aP(e),o,n),selectedLinearElement:Object.keys(r).length===1&&sP(e[0])?new lP(e[0],dP(e)):null},captureUpdate:pP.IMMEDIATELY}},keyTest:e=>e[Z0.CTRL_OR_CMD]&&e.key===Z0.A});import{DEFAULT_GRID_SIZE as $0,KEYS as j0,MOBILE_ACTION_BUTTON_BG as uP,arrayToMap as q0}from"@excalidraw/common";import{getNonDeletedElements as J0}from"@excalidraw/element";import{LinearElementEditor as hP}from"@excalidraw/element/linearElementEditor";import{getSelectedElements as gP,getSelectionStateForElements as fP}from"@excalidraw/element";import{syncMovedIndices as bP}from"@excalidraw/element";import{duplicateElements as EP}from"@excalidraw/element";import{CaptureUpdateAction as Q0}from"@excalidraw/element";import{jsx as xP}from"react/jsx-runtime";var cu=F({name:"duplicateSelection",label:"labels.duplicateSelection",icon:nl,trackEvent:{category:"element"},perform:(e,o,t,n)=>{if(o.selectedElementsAreBeingDragged)return!1;if(o.selectedLinearElement?.isEditing)try{let a=hP.duplicateSelectedPoints(o,n.scene);return{elements:e,appState:a,captureUpdate:Q0.IMMEDIATELY}}catch{return!1}let{duplicatedElements:r,elementsWithDuplicates:i}=EP({type:"in-place",elements:e,idsOfElementsToDuplicate:q0(gP(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+$0/2,y:a.y+$0/2,frameId:s??a.frameId}}});if(n.props.onDuplicate&&i){let a=n.props.onDuplicate(i,e);a&&(i=a)}return{elements:bP(i,q0(r)),appState:{...o,...fP(r,J0(i),o)},captureUpdate:Q0.IMMEDIATELY}},keyTest:e=>e[j0.CTRL_OR_CMD]&&e.key===j0.D,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=nt()==="mobile";return xP(Z,{type:"button",icon:nl,title:`${f("labels.duplicateSelection")} \u2014 ${N("CtrlOrCmd+D")}`,"aria-label":f("labels.duplicateSelection"),onClick:()=>t(null),disabled:!Pe(J0(e),o),style:{...r&&o.openPopup!=="compactOtherProperties"?uP:{}}})}});import{pointFrom as SM}from"@excalidraw/math";import{useEffect as Lu,useMemo as Nu,useRef as _u,useState as CM}from"react";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as kM,DEFAULT_ELEMENT_BACKGROUND_PICKS as PM,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as MM,DEFAULT_ELEMENT_STROKE_PICKS as AM,ARROW_TYPE as ro,DEFAULT_FONT_FAMILY as LM,DEFAULT_FONT_SIZE as _M,FONT_FAMILY as DM,ROUNDNESS as $c,STROKE_WIDTH as Du,VERTICAL_ALIGN as Kc,KEYS as Ai,randomInteger as RM,arrayToMap as Bu,getFontFamilyString as NM,getLineHeight as BM,isTransparent as FM,reduceToCommonValue as OM,invariant as Fu,FONT_SIZES as Zc}from"@excalidraw/common";import{canBecomePolygon as zM,getNonDeletedElements as Xx}from"@excalidraw/element";import{bindBindingElement as Gx,calculateFixedPointForElbowArrowBinding as Ux,updateBoundElements as HM}from"@excalidraw/element";import{LinearElementEditor as kr}from"@excalidraw/element/linearElementEditor";import{newElementWith as Qe}from"@excalidraw/element";import{getArrowheadForPicker as Wx}from"@excalidraw/element";import{getBoundTextElement as Yn,redrawTextBoundingBox as vl}from"@excalidraw/element";import{isArrowElement as jc,isBoundToContainer as GM,isElbowArrow as Kx,isLinearElement as Ru,isLineElement as Yx,isTextElement as Lt,isUsingAdaptiveRadius as UM}from"@excalidraw/element";import{hasStrokeColor as WM}from"@excalidraw/element";import{updateElbowArrowPoints as YM,CaptureUpdateAction as et,toggleLinePolygonState as VM}from"@excalidraw/element";import{deriveStylesPanelMode as XM}from"@excalidraw/common";import{isDevEnv as yP}from"@excalidraw/common";var wP=new Set(["command_palette","export"]),ce=(e,o,t,n)=>{try{if(typeof window>"u"||T.VITE_WORKER_ID||T.VITE_APP_ENABLE_TRACKING!=="true"||!wP.has(e)||yP())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 SP from"clsx";import vP from"clsx";import{forwardRef as IP}from"react";import{jsx as TP}from"react/jsx-runtime";var vi=IP((e,o)=>{let{title:t,className:n,testId:r,active:i,standalone:a,icon:l,onClick:s}=e;return TP("button",{type:"button",ref:o,title:t,"data-testid":r,className:vP(n,{standalone:a,active:i}),onClick:s,style:e.style,children:l},t)});import{Fragment as kP,jsx as du,jsxs as CP}from"react/jsx-runtime";var eo=e=>du(kP,{children:e.options.map(o=>e.type==="button"?du(vi,{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):CP("label",{className:SP({active:e.value===o.value}),title:o.text,children:[du("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{Popover as xx}from"radix-ui";import yx from"clsx";import{useRef as wx,useEffect as M4}from"react";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as bx,COLOR_PALETTE as vx,isColorDark as Ex,isWritableElement as A4}from"@excalidraw/common";import{jsx as PP}from"react/jsx-runtime";var _c=()=>PP("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as DP,useRef as RP}from"react";import{createPortal as NP}from"react-dom";import{EVENT as Nn,KEYS as BP,rgbToHex as FP}from"@excalidraw/common";import ex from"react";var mu=ex.createContext(null),de=()=>ex.useContext(mu);import{useState as MP,useLayoutEffect as tx}from"react";import{THEME as AP}from"@excalidraw/common";var Dc=e=>{let[o,t]=MP(null),n=pe(),{theme:r}=de(),{container:i}=Ne();return tx(()=>{o&&(o.className="",o.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),o.classList.toggle("excalidraw--mobile",n.formFactor==="phone"),o.classList.toggle("theme--dark",r===AP.DARK))},[o,r,n.formFactor,e?.className]),tx(()=>{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 LP}from"react";import{EVENT as Rc}from"@excalidraw/common";function Ii(e,o,t){LP(()=>{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(Rc.POINTER_DOWN,n),document.addEventListener(Rc.TOUCH_START,n),()=>{document.removeEventListener(Rc.POINTER_DOWN,n),document.removeEventListener(Rc.TOUCH_START,n)}},[e,o,t])}import{useRef as _P}from"react";var Rn=e=>{let o=_P(e);return Object.assign(o.current,e),o.current};import{jsx as OP}from"react/jsx-runtime";var Bn=_e(null),ox=({onCancel:e,onChange:o,onSelect:t,colorPickerType:n})=>{let r=Dc({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=de(),a=Fn(),l=je(),s=ee(a,i),c=Rn({app:l,onCancel:e,onChange:o,onSelect:t,selectedElements:s}),{container:m}=Ne();DP(()=>{let d=p.current;if(!d||!l.canvas||!r)return;let u=!1,b=l.canvas.getContext("2d"),g=({clientX:C,clientY:A})=>{let k=b.getImageData((C-i.offsetLeft)*window.devicePixelRatio,(A-i.offsetTop)*window.devicePixelRatio,1,1).data;return FP(k[0],k[1],k[2])},E=({clientX:C,clientY:A,altKey:k})=>{d.style.top=`${A+20}px`,d.style.left=`${C+20}px`;let L=g({clientX:C,clientY:A});u&&c.onChange(n,L,c.selectedElements,{altKey:k}),d.style.background=L},y=()=>{c.onCancel()},v=(C,A)=>{c.onSelect(C,A)},x=C=>{u=!0,C.stopImmediatePropagation()},w=C=>{u=!1,m?.focus(),C.stopImmediatePropagation(),C.preventDefault(),v(g(C),C)},I=C=>{C.key===BP.ESCAPE&&(C.preventDefault(),C.stopImmediatePropagation(),y())};return r.tabIndex=-1,r.focus(),E({clientX:c.app.lastViewportPosition.x,clientY:c.app.lastViewportPosition.y,altKey:!1}),r.addEventListener(Nn.KEYDOWN,I),r.addEventListener(Nn.POINTER_DOWN,x),r.addEventListener(Nn.POINTER_UP,w),window.addEventListener("pointermove",E,{passive:!0}),window.addEventListener(Nn.BLUR,y),()=>{u=!1,r.removeEventListener(Nn.KEYDOWN,I),r.removeEventListener(Nn.POINTER_DOWN,x),r.removeEventListener(Nn.POINTER_UP,w),window.removeEventListener("pointermove",E),window.removeEventListener(Nn.BLUR,y)}},[c,l.canvas,r,n,m,i.offsetLeft,i.offsetTop]);let p=RP(null);return Ii(p,()=>{e()},d=>!!d.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),r?NP(OP("div",{ref:p,className:"excalidraw-eye-dropper-preview"}),r):null};import{Popover as pu}from"radix-ui";import UP from"clsx";import WP from"react";import{isInteractive as YP}from"@excalidraw/common";import zP from"react";import HP from"clsx";import{jsx as GP}from"react/jsx-runtime";var We=zP.forwardRef(({children:e,padding:o,className:t,style:n},r)=>GP("div",{className:HP("Island",t),style:{"--padding":o,...n},ref:r,children:e}));import{jsx as uu,jsxs as VP}from"react/jsx-runtime";var sn=WP.forwardRef(({className:e,container:o,children:t,style:n,onClose:r,onKeyDown:i,onFocusOutside:a,onPointerLeave:l,onPointerDownOutside:s,preventAutoFocusOnTouch:c=!1},m)=>{let p=pe(),d=p.formFactor==="phone"&&!p.isLandscape;return uu(pu.Portal,{container:o,children:VP(pu.Content,{ref:m,className:UP("focus-visible-none",e),"data-prevent-outside-click":!0,side:d?"bottom":"right",align:d?"center":"start",alignOffset:-16,sideOffset:20,collisionBoundary:o??void 0,style:{zIndex:"var(--zIndex-ui-styles-popup)",marginLeft:p.formFactor==="phone"?"0.5rem":void 0},onPointerLeave:l,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:s,onOpenAutoFocus:u=>{c&&p.isTouchScreen&&u.preventDefault()},onCloseAutoFocus:u=>{u.stopPropagation(),u.preventDefault(),o&&!YP(document.activeElement)&&o.focus(),r()},children:[uu(We,{padding:3,style:n,children:t}),uu(pu.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 XP,useCallback as hu}from"react";var Nc=()=>document.querySelector(".excalidraw-wysiwyg"),Bc=()=>{let e=Nc();return e?{start:e.selectionStart,end:e.selectionEnd}:null},pl=e=>{setTimeout(()=>{let o=Nc();o&&(o.focus(),e&&(o.selectionStart=e.start,o.selectionEnd=e.end))},0)},ul=(e,o,t,n)=>{o&&n&&n();let r=o&&t?Bc():null;e(),o&&t&&pl(r)},nx=()=>{let[e,o]=XP(null),t=hu(()=>{let i=Bc();o(i)},[]),n=hu(()=>{setTimeout(()=>{let i=Nc();i&&(i.focus(),e&&(i.selectionStart=e.start,i.selectionEnd=e.end,o(null)))},0)},[e]),r=hu(()=>{o(null)},[]);return{saveCaretPosition:t,restoreCaretPosition:n,clearSavedPosition:r,hasSavedPosition:!!e}},rx=(e=100)=>{let o=Nc();if(o){let t=o.onblur;o.onblur=null,setTimeout(()=>{o.onblur=t},e)}};import ZP from"clsx";import{useCallback as $P,useEffect as fu,useRef as ax,useState as jP}from"react";import{KEYS as bu,normalizeInputColor as qP}from"@excalidraw/common";import{MAX_CUSTOM_COLORS_USED_IN_CANVAS as KP}from"@excalidraw/common";var On=({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},hl=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),gu=({color:e,palette:o})=>!Object.values(o).flat().includes(e),ix=(e,o,t)=>{let n={elementBackground:"backgroundColor",elementStroke:"strokeColor"},r=e.filter(a=>{if(a.isDeleted)return!1;let l=a[n[o]];return gu({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,KP)},to=_e(null);import{Fragment as JP,jsx as Fc,jsxs as lx}from"react/jsx-runtime";var sx=({color:e,onChange:o,label:t,colorPickerType:n,placeholder:r})=>{let i=pe(),[a,l]=jP(e),[s,c]=fe(to);fu(()=>{l(e)},[e]);let m=$P(g=>{let E=g.toLowerCase(),y=qP(E);y&&o(y),l(E)},[o]),p=ax(null),d=ax(null);fu(()=>{p.current&&p.current.focus()},[s]);let[u,b]=fe(Bn);return fu(()=>()=>{b(null)},[b]),lx("div",{className:"color-picker__input-label",children:[Fc("div",{className:"color-picker__input-hash",children:"#"}),Fc("input",{ref:s==="hex"?p:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,onChange:g=>{m(g.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{l(e)},tabIndex:-1,onFocus:()=>c("hex"),onKeyDown:g=>{g.key!==bu.TAB&&(g.key===bu.ESCAPE&&d.current?.focus(),g.stopPropagation())},placeholder:r}),i.formFactor!=="phone"&&lx(JP,{children:[Fc("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),Fc("div",{ref:d,className:ZP("excalidraw-eye-dropper-trigger",{selected:u}),onClick:()=>b(g=>g?null:{keepOpenOnAlt:!1,onSelect:E=>o(E),colorPickerType:n}),title:`${f("labels.eyeDropper")} \u2014 ${bu.I.toLocaleUpperCase()} or ${N("Alt")} `,children:b0})]})]})};import wu,{useEffect as vu,useImperativeHandle as E4,useState as x4}from"react";import{EVENT as hx}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as y4,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as w4,KEYS as v4}from"@excalidraw/common";import o4 from"clsx";import{useEffect as n4,useRef as r4}from"react";import{isColorDark as QP}from"@excalidraw/common";import{jsxs as t4}from"react/jsx-runtime";var e4=({color:e,keyLabel:o,isShade:t=!1})=>t4("div",{className:"color-picker__button__hotkey-label",style:{color:QP(e)?"#fff":"#000"},children:[t&&"\u21E7",o]}),Ti=e4;import{jsx as Eu,jsxs as i4}from"react/jsx-runtime";var cx=({colors:e,color:o,onChange:t,label:n})=>{let[r,i]=fe(to),a=r4(null);return n4(()=>{a.current&&a.current.focus()},[o,r]),Eu("div",{className:"color-picker-content--default",children:e.map((l,s)=>i4("button",{ref:o===l?a:void 0,tabIndex:-1,type:"button",className:o4("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:[Eu("div",{className:"color-picker__button-outline"}),Eu(Ti,{color:l,keyLabel:s+1})]},s))})};import a4 from"clsx";import{useEffect as l4,useRef as s4}from"react";import{jsx as xu,jsxs as d4}from"react/jsx-runtime";var c4=({palette:e,color:o,onChange:t,activeShade:n,showHotKey:r=!0})=>{let i=On({color:o,palette:e}),[a,l]=fe(to),s=s4(null);return l4(()=>{s.current&&a==="baseColors"&&s.current.focus()},[i?.colorName,a]),xu("div",{className:"color-picker-content--default",children:Object.entries(e).map(([c,m],p)=>{let d=(Array.isArray(m)?m[n]:m)||"transparent",u=hl[p],b=f(`colors.${c.replace(/\d+/,"")}`,null,"");return d4("button",{ref:i?.colorName===c?s:void 0,tabIndex:-1,type:"button",className:a4("color-picker__button color-picker__button--large has-outline",{active:i?.colorName===c,"is-transparent":d==="transparent"||!d}),onClick:()=>{t(d),l("baseColors")},title:`${b}${d.startsWith("#")?` ${d}`:""} \u2014 ${u}`,"aria-label":`${b} \u2014 ${u}`,style:d?{"--swatch-color":d}:void 0,"data-testid":`color-${c}`,children:[xu("div",{className:"color-picker__button-outline"}),r&&xu(Ti,{color:d,keyLabel:u})]},c)})})},dx=c4;import{jsx as p4}from"react/jsx-runtime";var m4=({children:e})=>p4("div",{className:"color-picker__heading",children:e}),Si=m4;import u4 from"clsx";import{useEffect as h4,useRef as g4}from"react";import{jsx as gl,jsxs as mx}from"react/jsx-runtime";var px=({color:e,onChange:o,palette:t,showHotKey:n})=>{let r=On({color:e||"transparent",palette:t}),[i,a]=fe(to),l=g4(null);if(h4(()=>{l.current&&i==="shades"&&l.current.focus()},[r,i]),r){let{colorName:s,shade:c}=r,m=t[s];if(Array.isArray(m))return gl("div",{className:"color-picker-content--default shades",children:m.map((p,d)=>mx("button",{ref:d===c&&i==="shades"?l:void 0,tabIndex:-1,type:"button",className:u4("color-picker__button color-picker__button--large has-outline",{active:d===c}),"aria-label":"Shade",title:`${s} - ${d+1}`,style:p?{"--swatch-color":p}:void 0,onClick:()=>{o(p),a("shades")},children:[gl("div",{className:"color-picker__button-outline"}),n&&gl(Ti,{color:p,keyLabel:d+1,isShade:!0})]},d))})}return mx("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[gl("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),gl("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")})]})};import{COLORS_PER_ROW as Ci,COLOR_PALETTE as f4,KEYS as fl}from"@excalidraw/common";var yu=(e,o,t)=>{let n=Math.ceil(t/Ci);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+Ci;return r>=t?o%Ci:r}case"ArrowUp":{let r=o-Ci,i=r<0?Ci*n+r:r;return i>=t?void 0:i}}},b4=({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(hl.includes(e.key)){let l=hl.indexOf(e.key),s=Object.keys(n)[l],c=n[s],m=Array.isArray(c)?c[a]:c;return t(m),i("baseColors"),!0}return!1},ux=({event:e,activeColorPickerSection:o,palette:t,color:n,onChange:r,customColors:i,setActiveColorPickerSection:a,updateData:l,activeShade:s,onEyeDropperToggle:c,onEscape:m})=>{if(e[fl.CTRL_OR_CMD])return!1;if(e.key===fl.ESCAPE)return m(e),!0;if(e.key===fl.ALT)return c(!0),!0;if(e.key===fl.I)return c(),!0;let p=On({color:n,palette:t});if(e.key===fl.TAB){let d={custom:!!i.length,baseColors:!0,shades:p?.shade!=null,hex:!0},u=Object.entries(d).reduce((v,[x,w])=>(w&&v.push(x),v),[]),b=u.indexOf(o),g=e.shiftKey?-1:1,E=b+g>u.length-1?0:b+g<0?u.length-1:b+g,y=u[E];return y&&a(y),y==="custom"?r(i[0]):y==="baseColors"&&(Object.entries(t).find(([x,w])=>Array.isArray(w)?w.includes(n):w===n?x:null)||r(f4.black)),e.preventDefault(),e.stopPropagation(),!0}if(b4({e,colorObj:p,onChange:r,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:s}))return!0;if(o==="shades"&&p){let{shade:d}=p,u=yu(e.key,d,Ci);if(u!==void 0)return r(t[p.colorName][u]),!0}if(o==="baseColors"&&p){let{colorName:d}=p,u=Object.keys(t),b=u.indexOf(d),g=yu(e.key,b,u.length);if(g!==void 0){let E=u[g],y=t[E];return r(Array.isArray(y)?y[s]:y),!0}}if(o==="custom"){let d=n!=null?i.indexOf(n):0,u=yu(e.key,d,i.length);if(u!==void 0){let b=i[u];return r(b),!0}}return!1};import{jsx as zn,jsxs as Oc}from"react/jsx-runtime";var gx=wu.forwardRef(({color:e,onChange:o,type:t,elements:n,palette:r,updateData:i,children:a,showTitle:l,onEyeDropperToggle:s,onEscape:c,showHotKey:m=!0},p)=>{let d=l?t==="elementStroke"?f("labels.stroke"):t==="elementBackground"?f("labels.background"):null:null,[u]=wu.useState(()=>t==="canvasBackground"?[]:ix(n,t,r)),[b,g]=fe(to),E=On({color:e,palette:r});vu(()=>{if(!b){let w=!!e&&gu({color:e,palette:r}),I=w&&!u.includes(e);g(I?null:w?"custom":E?.shade!=null?"shades":"baseColors")}},[b,e,r,g,E,u]);let[y,v]=x4(E?.shade??(t==="elementBackground"?y4:w4));vu(()=>{E?.shade!=null&&v(E.shade);let w=I=>{I.key===v4.ALT&&s(!1)};return document.addEventListener(hx.KEYUP,w,{capture:!0}),()=>{document.removeEventListener(hx.KEYUP,w,{capture:!0})}},[E,s]);let x=wu.useRef(null);return E4(p,()=>x.current),vu(()=>{x?.current?.focus()},[]),zn("div",{role:"dialog","aria-modal":"true","aria-label":f("labels.colorPicker"),children:Oc("div",{ref:x,onKeyDown:w=>{ux({event:w,activeColorPickerSection:b,palette:r,color:e,onChange:o,onEyeDropperToggle:s,customColors:u,setActiveColorPickerSection:g,updateData:i,activeShade:y,onEscape:c})&&(w.preventDefault(),w.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[d&&zn("div",{className:"color-picker__title",children:d}),!!u.length&&Oc("div",{children:[zn(Si,{children:f("colorPicker.mostUsedCustomColors")}),zn(cx,{colors:u,color:e,label:f("colorPicker.mostUsedCustomColors"),onChange:o})]}),Oc("div",{children:[zn(Si,{children:f("colorPicker.colors")}),zn(dx,{color:e,palette:r,onChange:o,activeShade:y,showHotKey:m})]}),Oc("div",{children:[zn(Si,{children:f("colorPicker.shades")}),zn(px,{color:e,onChange:o,palette:r,showHotKey:m})]}),a]})})});import I4 from"clsx";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as T4,DEFAULT_CANVAS_BACKGROUND_PICKS as S4,DEFAULT_ELEMENT_BACKGROUND_PICKS as C4,DEFAULT_ELEMENT_STROKE_PICKS as k4,isColorDark as P4}from"@excalidraw/common";import{jsx as Iu}from"react/jsx-runtime";var fx=({onChange:e,type:o,activeColor:t,topPicks:n})=>{let r;return o==="elementStroke"&&(r=k4),o==="elementBackground"&&(r=C4),o==="canvasBackground"&&(r=S4),n&&(r=n),r?Iu("div",{className:"color-picker__top-picks",children:r.map(i=>Iu("button",{className:I4("color-picker__button",{active:i===t,"is-transparent":i==="transparent"||!i,"has-outline":!P4(i,T4)}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:Iu("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};import{jsx as oo,jsxs as zc}from"react/jsx-runtime";var L4=({type:e,color:o,onChange:t,label:n,elements:r,palette:i=vx,updateData:a,getOpenPopup:l,appState:s})=>{let{container:c}=Ne(),m=nt(),p=m!=="full",d=m==="mobile",[,u]=fe(to),[b,g]=fe(Bn),E=zc("div",{children:[oo(Si,{children:f("colorPicker.hexCode")}),oo(sx,{color:o||"",label:n,onChange:x=>{t(x)},colorPickerType:e,placeholder:f("colorPicker.color")})]}),y=wx(null),v=()=>{y.current?.focus()};return oo(sn,{container:c,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!s.editingTextElement,onFocusOutside:x=>{A4(x.target)||v(),x.preventDefault()},onPointerDownOutside:x=>{b&&x.preventDefault()},onClose:()=>{l()===e&&a({openPopup:null}),u(null),s.editingTextElement&&setTimeout(()=>{let x=document.querySelector(".excalidraw-wysiwyg");x&&x.focus()},0)},children:i?oo(gx,{ref:y,palette:i,color:o,onChange:x=>{let w=s.editingTextElement?Bc():null;t(x),s.editingTextElement&&w&&pl(w)},onEyeDropperToggle:x=>{g(w=>x?(w=w||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},w.keepOpenOnAlt=!0,w):x===!1||w?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:x=>{b?g(null):a({openPopup:null})},type:e,elements:r,updateData:a,showTitle:p,showHotKey:!d,children:E}):E})},_4=({label:e,color:o,type:t,mode:n="background",onToggle:r,editingTextElement:i})=>{let a=nt(),l=a!=="full",s=a==="mobile",c=m=>{m.preventDefault(),m.stopPropagation(),i&&rx(),r()};return zc(xx.Trigger,{type:"button",className:yx("color-picker__button active-color properties-trigger",{"is-transparent":!o||o==="transparent","has-outline":!o||!Ex(o,bx),"compact-sizing":l,"mobile-border":s}),"aria-label":e,style:o?{"--swatch-color":o}:void 0,title:t==="elementStroke"?f("labels.showStroke"):f("labels.showBackground"),"data-openpopup":t,onClick:c,children:[oo("div",{className:"color-picker__button-outline",children:!o&&EE}),l&&o&&n==="stroke"&&oo("div",{className:"color-picker__button-background",children:oo("span",{style:{color:o&&Ex(o,bx)?"#fff":"#111"},children:O0})})]})},bl=({type:e,color:o,onChange:t,label:n,elements:r,palette:i=vx,topPicks:a,updateData:l,appState:s})=>{let c=wx(s.openPopup);M4(()=>{c.current=s.openPopup},[s.openPopup]);let p=nt()!=="full";return oo("div",{children:zc("div",{role:"dialog","aria-modal":"true",className:yx("color-picker-container",{"color-picker-container--no-top-picks":p}),children:[!p&&oo(fx,{activeColor:o,onChange:t,type:e,topPicks:a}),!p&&oo(_c,{}),zc(xx.Root,{open:s.openPopup===e,onOpenChange:d=>{d&&l({openPopup:e})},children:[oo(_4,{color:o,label:n,type:e,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&&oo(L4,{type:e,color:o,onChange:t,label:n,elements:r,palette:i,updateData:l,getOpenPopup:()=>c.current,appState:s})]})]})})};import{Popover as aM}from"radix-ui";import lM from"clsx";import sM,{useCallback as cM,useMemo as dM}from"react";import{FONT_FAMILY as ku}from"@excalidraw/common";import j4,{useMemo as Un,useState as q4,useRef as Cx,useEffect as kx,useCallback as Px}from"react";import{arrayToList as J4,debounce as Q4,FONT_FAMILY as Wn,getFontFamilyString as eM}from"@excalidraw/common";import D4 from"clsx";import R4 from"react";import{jsx as N4,jsxs as B4}from"react/jsx-runtime";var Hc=R4.forwardRef(({className:e,placeholder:o,onChange:t},n)=>B4("div",{className:D4("QuickSearch__wrapper",e),children:[Gt,N4("input",{ref:n,className:"QuickSearch__input",type:"text",placeholder:o,onChange:r=>t(r.target.value.trim().toLowerCase())})]}));import F4 from"clsx";import{Children as O4}from"react";import{jsx as Ix}from"react/jsx-runtime";var Gc=({className:e,placeholder:o,children:t})=>{let n=!O4.count(t);return Ix("div",{className:F4("ScrollableList__wrapper",e),role:"menu",children:n?Ix("div",{className:"empty",children:o}):t})};import{jsx as z4,jsxs as H4}from"react/jsx-runtime";var Tx=({children:e,className:o="",style:t,title:n})=>H4("div",{className:`dropdown-menu-group ${o}`,style:t,children:[n&&z4("p",{className:"dropdown-menu-group-title",children:n}),e]}),El=Tx;Tx.displayName="DropdownMenuGroup";import{THEME as Z4}from"@excalidraw/common";import{DropdownMenu as $4}from"radix-ui";import G4,{useContext as U4}from"react";import{composeEventHandlers as W4}from"@excalidraw/common";var Tu=G4.createContext({}),Hn=(e="",o=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${o?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),Uc=e=>{let o=U4(Tu);return W4(e,t=>{o.onSelect?.(t)})};import{jsx as Y4}from"react/jsx-runtime";var Cr=({children:e,...o})=>Y4("span",{...o,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...o.style},children:e});import{Fragment as X4,jsx as xl,jsxs as K4}from"react/jsx-runtime";var V4=({textStyle:e,icon:o,shortcut:t,children:n,badge:r})=>{let i=pe();return K4(X4,{children:[o&&xl("div",{className:"dropdown-menu-item__icon",children:o}),xl("div",{style:e,className:"dropdown-menu-item__text",children:xl(Cr,{children:n})}),r&&xl("div",{className:"dropdown-menu-item__badge",children:r}),t&&i.formFactor!=="phone"&&xl("div",{className:"dropdown-menu-item__shortcut",children:t})]})},Gn=V4;import{jsx as Wc}from"react/jsx-runtime";var Su=({icon:e,badge:o,value:t,children:n,shortcut:r,className:i,selected:a,onSelect:l,...s})=>{let c=Uc(l);return Wc($4.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:Wc("button",{...s,value:t,className:Hn(i,a),title:s.title??s["aria-label"],children:Wc(Gn,{icon:e,shortcut:r,badge:o,children:n})})})};Su.displayName="DropdownMenuItem";var ki={GREEN:"green",RED:"red",BLUE:"blue"},Yc=({type:e=ki.BLUE,children:o})=>{let{theme:t}=Do(),n={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===Z4.LIGHT?"1.5px solid white":"none"};switch(e){case ki.GREEN:Object.assign(n,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case ki.RED:Object.assign(n,{backgroundColor:"pink",color:"darkred"});break;case ki.BLUE:default:Object.assign(n,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return Wc("div",{className:"DropDownMenuItemBadge",style:n,children:o})};Yc.displayName="DropdownMenuItemBadge";Su.Badge=Yc;var At=Su;import{KEYS as Pi}from"@excalidraw/common";var Sx=({event:e,inputRef:o,hoveredFont:t,filteredFonts:n,onClose:r,onSelect:i,onHover:a})=>{if(!e[Pi.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===Pi.F)return o.current?.focus(),!0;if(e.key===Pi.ESCAPE)return r(),!0;if(e.key===Pi.ENTER)return t?.value&&i(t.value),!0;if(e.key===Pi.ARROW_DOWN)return t?.next?a(t.next.value):n[0]?.value&&a(n[0].value),!0;if(e.key===Pi.ARROW_UP)return t?.prev?a(t.prev.value):n[n.length-1]?.value&&a(n[n.length-1].value),!0};import{jsx as cn,jsxs as nM}from"react/jsx-runtime";var tM=e=>{switch(e){case Wn.Excalifont:case Wn.Virgil:return Ln;case Wn.Nunito:case Wn.Helvetica:return ll;case Wn["Lilita One"]:return i0;case Wn["Comic Shanns"]:case Wn.Cascadia:return Ec;default:return ll}},oM=(e,o)=>Object.entries(Wn).find(([,t])=>t===e)?.[0]??o[0]?.fontFace?.family??"Unknown",Mx=j4.memo(({selectedFontFamily:e,hoveredFontFamily:o,onSelect:t,onHover:n,onLeave:r,onOpen:i,onClose:a})=>{let{container:l}=Ne(),s=je(),{fonts:c}=s,{showDeprecatedFonts:m}=no(),p=nt(),[d,u]=q4(""),b=Cx(null),g=Un(()=>Array.from(nn.registered.entries()).filter(([M,{metadata:D}])=>!D.private&&!D.fallback).map(([M,{metadata:D,fontFaces:z}])=>{let W={value:M,icon:tM(M),text:oM(M,z)};return D.deprecated&&Object.assign(W,{deprecated:D.deprecated,badge:{type:ki.RED,placeholder:f("fontList.badge.old")}}),W}).sort((M,D)=>M.text.toLowerCase()>D.text.toLowerCase()?1:-1),[]),E=Un(()=>new Set(c.getSceneFamilies()),[e]),y=Un(()=>g.filter(M=>E.has(M.value)),[g,E]),v=Un(()=>g.filter(M=>!E.has(M.value)&&(m||!M.deprecated)),[g,E,m]),x=Un(()=>J4([...y,...v].filter(M=>M.text?.toLowerCase().includes(d))),[y,v,d]),w=Un(()=>{let M;return o?M=x.find(D=>D.value===o):e&&(M=x.find(D=>D.value===e)),!M&&d&&(x[0]?.value?n(x[0].value):r()),M},[o,e,d,x,n,r]),I=Px(M=>{let D=null;if(s.state.editingTextElement){let z=document.querySelector(".excalidraw-wysiwyg");z&&(D={start:z.selectionStart,end:z.selectionEnd})}t(M),s.state.editingTextElement&&D&&setTimeout(()=>{let z=document.querySelector(".excalidraw-wysiwyg");z&&D&&(z.focus(),z.selectionStart=D.start,z.selectionEnd=D.end)},0)},[t,s.state.editingTextElement]),C=Px(M=>{Sx({event:M,inputRef:b,hoveredFont:w,filteredFonts:x,onSelect:I,onHover:n,onClose:a})&&(M.preventDefault(),M.stopPropagation())},[w,x,I,n,a]);kx(()=>(i(),()=>{a()}),[]);let A=Un(()=>x.filter(M=>E.has(M.value)),[x,E]),k=Un(()=>x.filter(M=>!E.has(M.value)),[x,E]),L=({font:M,order:D})=>{let z=Cx(null),W=M.value===w?.value,O=M.value===e;return kx(()=>{W&&(D===0?z.current?.scrollIntoView?.({block:"end"}):z.current?.scrollIntoView?.({block:"nearest"}))},[W,D]),cn("button",{ref:z,type:"button",value:M.value,className:Hn("",O,W),title:M.text,tabIndex:O?0:-1,onClick:K=>{I(Number(K.currentTarget.value))},onMouseMove:()=>{w?.value!==M.value&&n(M.value)},children:cn(Gn,{icon:M.icon,badge:M.badge&&cn(Yc,{type:M.badge.type,children:M.badge.placeholder}),textStyle:{fontFamily:eM({fontFamily:M.value})},children:M.text})})},_=[];return A.length&&_.push(cn(El,{title:f("fontList.sceneFonts"),children:A.map((M,D)=>cn(L,{font:M,order:D},M.value))},"group_1")),k.length&&_.push(cn(El,{title:f("fontList.availableFonts"),children:k.map((M,D)=>cn(L,{font:M,order:D+A.length},M.value))},"group_2")),nM(sn,{className:"properties-content",container:l,style:{width:"15rem"},onClose:()=>{a(),s.state.editingTextElement&&setTimeout(()=>{let M=document.querySelector(".excalidraw-wysiwyg");M&&M.focus()},0)},onPointerLeave:r,onKeyDown:C,preventAutoFocusOnTouch:!!s.state.editingTextElement,children:[p==="full"&&cn(Hc,{ref:b,placeholder:f("quickSearch.placeholder"),onChange:Q4(u,20)}),cn(Gc,{className:"dropdown-menu fonts manual-hover",placeholder:f("fontList.empty"),children:_.length?_:null})]})},(e,o)=>e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import{Popover as rM}from"radix-ui";import{MOBILE_ACTION_BUTTON_BG as iM}from"@excalidraw/common";import{jsx as Cu}from"react/jsx-runtime";var Ax=({selectedFontFamily:e,isOpened:o=!1,compactMode:t=!1})=>{let n=be(),r=t?{...iM,width:"2rem",height:"2rem"}:{};return Cu(rM.Trigger,{asChild:!0,children:Cu("div",{"data-openpopup":"fontFamily",className:"properties-trigger",children:Cu(vi,{standalone:!0,icon:_n,title:f("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:o,onClick:()=>{n(i=>({openPopup:i.openPopup==="fontFamily"?null:i.openPopup}))},style:{border:"none",...r}})})})};import{jsx as yl,jsxs as Lx}from"react/jsx-runtime";var _x=[{value:ku.Excalifont,icon:Ln,text:f("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:ku.Nunito,icon:ll,text:f("labels.normal"),testId:"font-family-normal"},{value:ku["Comic Shanns"],icon:Ec,text:f("labels.code"),testId:"font-family-code"}],pQ=new Set(_x.map(e=>e.value));var Dx=sM.memo(({isOpened:e,selectedFontFamily:o,hoveredFontFamily:t,onSelect:n,onHover:r,onLeave:i,onPopupChange:a,compactMode:l=!1})=>{let s=dM(()=>_x,[]),c=cM(m=>{m&&n(m)},[n]);return Lx("div",{role:"dialog","aria-modal":"true",className:lM("FontPicker__container",{"FontPicker__container--compact":l}),children:[!l&&yl("div",{className:"buttonList",children:yl(eo,{type:"button",options:s,value:o,onClick:c})}),!l&&yl(_c,{}),Lx(aM.Root,{open:e,onOpenChange:a,children:[yl(Ax,{selectedFontFamily:o,isOpened:e,compactMode:l}),e&&yl(Mx,{selectedFontFamily:o,hoveredFontFamily:t,onSelect:c,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{Popover as Pu}from"radix-ui";import hM from"clsx";import Fx,{useEffect as gM,useMemo as fM}from"react";import{isArrowKey as bM,KEYS as dn}from"@excalidraw/common";import{jsx as mM}from"react/jsx-runtime";var Mi=({className:e,icon:o,size:t="1em"})=>mM("span",{className:e,style:{width:t,height:"100%",margin:"0 0.5ex 0 0.5ex",display:"inline-flex",lineHeight:0,verticalAlign:"middle",flex:"0 0 auto"},children:o});import{Fragment as uM,jsx as Rx,jsxs as Nx}from"react/jsx-runtime";var pM=({label:e,open:o,openTrigger:t,children:n,className:r,showCollapsedIcon:i=!0})=>Nx(uM,{children:[Nx("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:r,onClick:t,children:[e,i&&Rx(Mi,{icon:o?N0:vc})]}),o&&Rx("div",{style:{display:"flex",flexDirection:"column"},children:n})]}),wl=pM;import{jsx as Ro,jsxs as Xc}from"react/jsx-runtime";var EM=_e(!1),Vc=4,xM="default",yM=e=>e.flatMap(o=>o.options),Bx=(e,o)=>{for(let t of e){let n=t.options.find(o);if(n)return n}return null},wM=(e,o)=>e.some(t=>t.options.some(o)),vM=e=>e.flatMap(o=>Array.from({length:Math.ceil(o.options.length/Vc)},(t,n)=>o.options.slice(n*Vc,n*Vc+Vc)));function IM({visibleSections:e,hiddenSections:o=[],value:t,label:n,onChange:r,onClose:i}){let{container:a}=Ne(),[l,s]=fe(EM),c=[...e,...o],m=yM(c),p=vM([...e,...l?o:[]]),d=g=>{let E=m.find(y=>y.keyBinding===g.key.toLowerCase());if(!(g.metaKey||g.altKey||g.ctrlKey)&&E)r(E.value),g.preventDefault();else if(g.key===dn.TAB){let y=m.findIndex(x=>x.value===t),v=g.shiftKey?(m.length+y-1)%m.length:(y+1)%m.length;r(m[v].value)}else if(bM(g.key)){let y=rn().rtl,v=m.findIndex(x=>x.value===t);if(v!==-1){let x=m.length,w=v;switch(g.key){case(y?dn.ARROW_LEFT:dn.ARROW_RIGHT):w=(v+1)%x;break;case(y?dn.ARROW_RIGHT:dn.ARROW_LEFT):w=(x+v-1)%x;break;case dn.ARROW_DOWN:{let I=p.findIndex(A=>A.some(k=>k.value===t)),C=p[I];if(I!==-1&&C){let A=C.findIndex(_=>_.value===t),k=p[(I+1)%p.length],L=k[Math.min(A,k.length-1)]??m[v];r(L.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}case dn.ARROW_UP:{let I=p.findIndex(A=>A.some(k=>k.value===t)),C=p[I];if(I!==-1&&C){let A=C.findIndex(_=>_.value===t),k=p[(p.length+I-1)%p.length],L=k[Math.min(A,k.length-1)]??m[v];r(L.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}}r(m[w].value)}g.preventDefault()}else(g.key===dn.ESCAPE||g.key===dn.ENTER)&&(g.preventDefault(),i());g.nativeEvent.stopImmediatePropagation(),g.stopPropagation()};gM(()=>{wM(o,g=>g.value===t)&&s(!0)},[t,o,s]);let u=g=>Ro("div",{className:"picker-content",children:g.map(E=>Xc("button",{type:"button",className:hM("picker-option",{active:t===E.value}),onClick:()=>{r(E.value)},title:E.keyBinding?`${E.text} \u2014 ${E.keyBinding.toUpperCase()}`:E.text,"aria-label":E.text||"none","aria-keyshortcuts":E.keyBinding||void 0,ref:y=>{t===E.value&&setTimeout(()=>{y?.focus()},0)},children:[E.icon,E.keyBinding&&Ro("span",{className:"picker-keybinding",children:E.keyBinding})]},E.text))}),b=g=>g.map((E,y)=>E.name===xM?Ro(Fx.Fragment,{children:u(E.options)},`${E.name}-${y}`):Xc("div",{className:"picker-section",children:[Ro("div",{className:"picker-section-label",children:E.name}),u(E.options)]},`${E.name}-${y}`));return Ro(Pu.Content,{className:"picker",role:"dialog","aria-modal":"true","aria-label":n,side:"bottom",align:"start",sideOffset:12,alignOffset:12,style:{zIndex:"var(--zIndex-ui-styles-popup)"},onKeyDown:d,collisionBoundary:a??void 0,children:Xc("div",{className:"picker-sections",children:[b(e),o.length>0&&Ro(wl,{label:f("labels.more_options"),open:l,openTrigger:()=>{s(g=>!g)},className:"picker-collapsible",children:Ro("div",{className:"picker-sections",children:b(o)})})]})})}function Mu({value:e,label:o,visibleSections:t,hiddenSections:n,onChange:r}){let[i,a]=Fx.useState(!1),l=fM(()=>Bx(t,s=>s.value===e)??Bx(n??[],s=>s.value===e),[t,n,e]);return Ro("div",{children:Xc(Pu.Root,{open:i,onOpenChange:s=>a(s),children:[Ro(Pu.Trigger,{type:"button","aria-label":o,onClick:()=>a(!i),className:i?"active":"",children:l?.icon}),i&&Ro(IM,{visibleSections:t,hiddenSections:n,value:e,label:o,onChange:r,onClose:()=>{a(!1)}})]})})}import Ox,{useEffect as TM}from"react";import{jsx as Au,jsxs as zx}from"react/jsx-runtime";var Hx=({label:e,value:o,onChange:t,min:n=0,max:r=100,step:i=10,minLabel:a=n,hasCommonValue:l=!0,testId:s})=>{let c=Ox.useRef(null),m=Ox.useRef(null);return TM(()=>{if(c.current&&m.current){let p=c.current,d=m.current,u=p.offsetWidth,b=parseFloat(getComputedStyle(p).getPropertyValue("--slider-thumb-size"))||16,g=(o-n)/(r-n||1)*100,E=g/100*(u-b)+b/2;d.style.left=`${E}px`,p.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${g}%, var(--button-bg) ${g}%, var(--button-bg) 100%)`}},[r,n,o]),zx("label",{className:"control-label",children:[e,zx("div",{className:"range-wrapper",children:[Au("input",{style:{"--color-slider-track":l?void 0:"var(--button-bg)"},ref:c,type:"range",min:n,max:r,step:i,onChange:p=>{t(+p.target.value)},value:o,className:"range-input","data-testid":s}),Au("div",{className:"value-bubble",ref:m,children:o!==n?o:null}),Au("div",{className:"zero-label",children:a})]})]})};import{Fragment as Gu,jsx as te,jsxs as vt}from"react/jsx-runtime";var Zx=.1,Li=e=>{let o=XM(e.editorInterface);return{stylesPanelMode:o,isCompact:o!=="full",isMobile:o==="mobile"}},wt=(e,o,t,n=!1)=>{let r=Bu(ee(e,o,{includeBoundTextElement:n}));return e.map(i=>r.get(i.id)||i.id===o.editingTextElement?.id?t(i):i)},pt=function(e,o,t,n,r){let i=o.state.editingTextElement,a=Xx(e),l=null;if(i&&(l=t(i)),!l)if(Pe(a,o.state)){let c=o.scene.getSelectedElements(o.state),m=n===!0?c:c.filter(p=>n(p));l=OM(m,t)??(typeof r=="function"?r(!0):r)}else l=typeof r=="function"?r(!1):r;return l},KM=(e,o,t)=>GM(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}),Ou=(e,o,t,n,r)=>{let i=new Set,a=wt(e,o,l=>{if(Lt(l)){let s=n(l);i.add(s);let c=Qe(l,{fontSize:s});return vl(c,t.scene.getContainerElement(l),t.scene),c=KM(l,c,t.scene),c}return l},!0);return ee(e,o,{includeBoundTextElement:!0}).forEach(l=>{Lt(l)&&HM(l,t.scene)}),{elements:a,appState:{...o,currentItemFontSize:i.size===1?[...i][0]:r??o.currentItemFontSize},captureUpdate:et.IMMEDIATELY}},ZM=F({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,o,t)=>({...t?.currentItemStrokeColor&&{elements:wt(e,o,n=>WM(n.type)?Qe(n,{strokeColor:t.currentItemStrokeColor}):n,!0)},appState:{...o,...t},captureUpdate:t?.currentItemStrokeColor?et.IMMEDIATELY:et.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{stylesPanelMode:i}=Li(n);return vt(Gu,{children:[i==="full"&&te("h3",{"aria-hidden":"true",children:f("labels.stroke")}),te(bl,{topPicks:AM,palette:MM,type:"elementStroke",label:f("labels.stroke"),color:pt(e,n,a=>a.strokeColor,!0,a=>a?null:o.currentItemStrokeColor),onChange:a=>t({currentItemStrokeColor:a}),elements:e,appState:o,updateData:t})]})}}),$M=F({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,o,t,n)=>{if(!t?.currentItemBackgroundColor)return{appState:{...o,...t},captureUpdate:et.EVENTUALLY};let r,i=n.scene.getSelectedElements(o);if(!FM(t.currentItemBackgroundColor)&&i.every(l=>Yx(l)&&zM(l.points))){let l=Bu(i);r=e.map(s=>l.has(s.id)&&Yx(s)?Qe(s,{backgroundColor:t.currentItemBackgroundColor,...VM(s,!0)}):s)}else r=wt(e,o,l=>Qe(l,{backgroundColor:t.currentItemBackgroundColor}));return{elements:r,appState:{...o,...t},captureUpdate:et.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{stylesPanelMode:i}=Li(n);return vt(Gu,{children:[i==="full"&&te("h3",{"aria-hidden":"true",children:f("labels.background")}),te(bl,{topPicks:PM,palette:kM,type:"elementBackground",label:f("labels.background"),color:pt(e,n,a=>a.backgroundColor,!0,a=>a?null:o.currentItemBackgroundColor),onChange:a=>t({currentItemBackgroundColor:a}),elements:e,appState:o,updateData:t})]})}}),jM=F({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,o,t,n)=>(ce("element","changeFillStyle",`${t} (${n.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),{elements:wt(e,o,r=>Qe(r,{fillStyle:t})),appState:{...o,currentItemFillStyle:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=ee(e,o),i=r.length>0&&r.every(a=>a.fillStyle==="zigzag");return vt("fieldset",{children:[te("legend",{children:f("labels.fill")}),te("div",{className:"buttonList",children:te(eo,{type:"button",options:[{value:"hachure",text:`${i?f("labels.zigzag"):f("labels.hachure")} (${N("Alt-Click")})`,icon:i?kE:PE,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:f("labels.crossHatch"),icon:ME,testId:"fill-cross-hatch"},{value:"solid",text:f("labels.solid"),icon:AE,testId:"fill-solid"}],value:pt(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(c=>c.fillStyle==="hachure")?"zigzag":a;t(s)}})})]})}}),qM=F({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,o,t)=>({elements:wt(e,o,n=>Qe(n,{strokeWidth:t})),appState:{...o,currentItemStrokeWidth:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>vt("fieldset",{children:[te("legend",{children:f("labels.strokeWidth")}),te("div",{className:"buttonList",children:te(eo,{group:"stroke-width",options:[{value:Du.thin,text:f("labels.thin"),icon:Xp,testId:"strokeWidth-thin"},{value:Du.bold,text:f("labels.bold"),icon:LE,testId:"strokeWidth-bold"},{value:Du.extraBold,text:f("labels.extraBold"),icon:_E,testId:"strokeWidth-extraBold"}],value:pt(e,n,i=>i.strokeWidth,i=>i.hasOwnProperty("strokeWidth"),i=>i?null:o.currentItemStrokeWidth),onChange:i=>t(i)})})]})}),JM=F({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,o,t)=>({elements:wt(e,o,n=>Qe(n,{seed:RM(),roughness:t})),appState:{...o,currentItemRoughness:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>vt("fieldset",{children:[te("legend",{children:f("labels.sloppiness")}),te("div",{className:"buttonList",children:te(eo,{group:"sloppiness",options:[{value:0,text:f("labels.architect"),icon:NE},{value:1,text:f("labels.artist"),icon:BE},{value:2,text:f("labels.cartoonist"),icon:FE}],value:pt(e,n,i=>i.roughness,i=>i.hasOwnProperty("roughness"),i=>i?null:o.currentItemRoughness),onChange:i=>t(i)})})]})}),bee=F({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,o,t)=>({elements:wt(e,o,n=>Qe(n,{strokeStyle:t})),appState:{...o,currentItemStrokeStyle:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>vt("fieldset",{children:[te("legend",{children:f("labels.strokeStyle")}),te("div",{className:"buttonList",children:te(eo,{group:"strokeStyle",options:[{value:"solid",text:f("labels.strokeStyle_solid"),icon:Xp},{value:"dashed",text:f("labels.strokeStyle_dashed"),icon:DE},{value:"dotted",text:f("labels.strokeStyle_dotted"),icon:RE}],value:pt(e,n,i=>i.strokeStyle,i=>i.hasOwnProperty("strokeStyle"),i=>i?null:o.currentItemStrokeStyle),onChange:i=>t(i)})})]})}),QM=F({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,o,t)=>({elements:wt(e,o,n=>Qe(n,{opacity:t}),!0),appState:{...o,currentItemOpacity:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,app:t,updateData:n})=>{let r=pt(e,t,i=>i.opacity,!0,i=>i?null:o.currentItemOpacity);return te(Hx,{label:f("labels.opacity"),value:r??o.currentItemOpacity,hasCommonValue:r!==null,onChange:n,min:0,max:100,step:10,testId:"opacity"})}}),e6=F({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,o,t,n)=>Ou(e,o,n,()=>(Fu(t,"actionChangeFontSize: Expected a font size value"),t),t),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{isCompact:i}=Li(n);return vt("fieldset",{children:[te("legend",{children:f("labels.fontSize")}),te("div",{className:"buttonList",children:te(eo,{group:"font-size",options:[{value:Zc.sm,text:f("labels.small"),icon:t0,testId:"fontSize-small"},{value:Zc.md,text:f("labels.medium"),icon:o0,testId:"fontSize-medium"},{value:Zc.lg,text:f("labels.large"),icon:n0,testId:"fontSize-large"},{value:Zc.xl,text:f("labels.veryLarge"),icon:r0,testId:"fontSize-veryLarge"}],value:pt(e,n,a=>{if(Lt(a))return a.fontSize;let l=Yn(a,n.scene.getNonDeletedElementsMap());return l?l.fontSize:null},a=>Lt(a)||Yn(a,n.scene.getNonDeletedElementsMap())!==null,a=>a?null:o.currentItemFontSize||_M),onChange:a=>{ul(()=>t(a),i,!!o.editingTextElement,r?.onPreventClose)}})})]})}}),zu=F({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:Tr,trackEvent:!1,perform:(e,o,t,n)=>Ou(e,o,n,r=>Math.round(1/(1+Zx)*r.fontSize)),keyTest:e=>e[Ai.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Ai.CHEVRON_LEFT||e.key===Ai.COMMA)}),Hu=F({name:"increaseFontSize",label:"labels.increaseFontSize",icon:Tr,trackEvent:!1,perform:(e,o,t,n)=>Ou(e,o,n,r=>Math.round(r.fontSize*(1+Zx))),keyTest:e=>e[Ai.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Ai.CHEVRON_RIGHT||e.key===Ai.PERIOD)}),t6=F({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:wt(e,o,g=>{let E=r?.get(g.id);return E?Qe(g,{...E}):g},!0),appState:{...o,...l},captureUpdate:et.NEVER};Fu(t,"actionChangeFontFamily: value must be defined");let{currentItemFontFamily:s,currentHoveredFontFamily:c}=t,m=et.EVENTUALLY,p,d=!1;if(s)p=s,m=et.IMMEDIATELY;else if(c){p=c,m=et.EVENTUALLY;let b=ee(e,o,{includeBoundTextElement:!0}).filter(g=>Lt(g));if(b.length>200)d=!0;else{let g=0,E=0;for(;g<b.length&&E<5e3;){let y=b[g];E+=y?.originalText.length||0,g++}E>5e3&&(d=!0)}}let u={appState:{...o,...l},captureUpdate:m};if(p&&!d){let b=new Map,g=new Set,E=!1,y=Array.from(nn.loadedFontsCache.values()),v=Object.entries(DM).find(([I,C])=>C===p)?.[0];c&&v&&y.some(I=>I.startsWith(v))&&(E=!0),Object.assign(u,{elements:wt(e,o,I=>{if(Lt(I)&&(I.fontFamily!==p||s)){let C=Qe(I,{fontFamily:p,lineHeight:BM(p)}),A=r?.get(I.containerId||"")||{},k=n.scene.getContainerElement(I);return a&&k&&A&&n.scene.mutateElement(k,{...A}),E||(g=new Set([...g,...Array.from(C.originalText)])),b.set(C,k),C}return I},!0)});let x=`10px ${NM({fontFamily:p})}`,w=Array.from(g.values()).join();if(E||window.document.fonts.check(x,w))for(let[I,C]of b)vl(I,C,n.scene);else window.document.fonts.load(x,w).then(I=>{for(let[C,A]of b){let k=n.scene.getElement(C.id),L=A?n.scene.getElement(A.id):null;k&&vl(k,L,n.scene)}n.fonts.onLoaded(I)})}return u},PanelComponent:({elements:e,appState:o,app:t,updateData:n})=>{let r=_u(new Map),i=_u(null),[a,l]=CM({}),s=_u(!0),{stylesPanelMode:c,isCompact:m}=Li(t),p=Nu(()=>{let d=(u,b)=>pt(u,t,g=>{if(Lt(g))return g.fontFamily;let E=Yn(g,b);return E?E.fontFamily:null},g=>Lt(g)||Yn(g,b)!==null,g=>g?null:o.currentItemFontFamily||LM);return a.openPopup==="fontFamily"&&o.openPopup==="fontFamily"?d(Array.from(r.current?.values()??[]),r.current):!a.openPopup&&o.openPopup!=="fontFamily"?d(e,t.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,o,e,t]);return Lu(()=>{i.current=p},[p]),Lu(()=>{Object.keys(a).length&&(n(a),l({}))},[a]),Lu(()=>(s.current=!1,()=>{s.current=!0}),[]),vt(Gu,{children:[c==="full"&&te("legend",{children:f("labels.fontFamily")}),te(Dx,{isOpened:o.openPopup==="fontFamily",selectedFontFamily:p,hoveredFontFamily:o.currentHoveredFontFamily,compactMode:c!=="full",onSelect:d=>{ul(()=>{l({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:d}),r.current.clear()},m,!!o.editingTextElement)},onHover:d=>{l({currentHoveredFontFamily:d,cachedElements:new Map(r.current),resetContainers:!0})},onLeave:()=>{l({currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0})},onPopupChange:d=>{if(d){r.current.clear();let{editingTextElement:u}=o;if(u?.type==="text"){let b=t.scene.getElement(u.id);r.current.set(u.id,Qe(b||u,{},!0))}else{let b=ee(e,o,{includeBoundTextElement:!0});for(let g of b)r.current.set(g.id,Qe(g,{},!0))}l({...a,openPopup:"fontFamily"})}else{let u={currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0};l({...u}),r.current.clear(),m&&o.editingTextElement&&pl(null)}}})]})}}),o6=F({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,o,t,n)=>({elements:wt(e,o,r=>{if(Lt(r)){let i=Qe(r,{textAlign:t});return vl(i,n.scene.getContainerElement(r),n.scene),i}return r},!0),appState:{...o,currentItemTextAlign:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let i=n.scene.getNonDeletedElementsMap(),{isCompact:a}=Li(n);return vt("fieldset",{children:[te("legend",{children:f("labels.textAlign")}),te("div",{className:"buttonList",children:te(eo,{group:"text-align",options:[{value:"left",text:f("labels.left"),icon:a0,testId:"align-left"},{value:"center",text:f("labels.center"),icon:l0,testId:"align-horizontal-center"},{value:"right",text:f("labels.right"),icon:s0,testId:"align-right"}],value:pt(e,n,l=>{if(Lt(l))return l.textAlign;let s=Yn(l,i);return s?s.textAlign:null},l=>Lt(l)||Yn(l,i)!==null,l=>l?null:o.currentItemTextAlign),onChange:l=>{ul(()=>t(l),a,!!o.editingTextElement,r?.onPreventClose)}})})]})}}),n6=F({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:wt(e,o,r=>{if(Lt(r)){let i=Qe(r,{verticalAlign:t});return vl(i,n.scene.getContainerElement(r),n.scene),i}return r},!0),appState:{...o},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{isCompact:i}=Li(n);return te("fieldset",{children:te("div",{className:"buttonList",children:te(eo,{group:"text-align",options:[{value:Kc.TOP,text:f("labels.alignTop"),icon:te(c0,{theme:o.theme}),testId:"align-top"},{value:Kc.MIDDLE,text:f("labels.centerVertically"),icon:te(m0,{theme:o.theme}),testId:"align-middle"},{value:Kc.BOTTOM,text:f("labels.alignBottom"),icon:te(d0,{theme:o.theme}),testId:"align-bottom"}],value:pt(e,n,a=>{if(Lt(a)&&a.containerId)return a.verticalAlign;let l=Yn(a,n.scene.getNonDeletedElementsMap());return l?l.verticalAlign:null},a=>Lt(a)||Yn(a,n.scene.getNonDeletedElementsMap())!==null,a=>a?null:Kc.MIDDLE),onChange:a=>{ul(()=>t(a),i,!!o.editingTextElement,r?.onPreventClose)}})})})}}),Eee=F({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,o,t)=>({elements:wt(e,o,n=>Kx(n)?n:Qe(n,{roundness:t==="round"?{type:UM(n.type)?$c.ADAPTIVE_RADIUS:$c.PROPORTIONAL_RADIUS}:null})),appState:{...o,currentItemRoundness:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,renderAction:r})=>{let a=ni(Xx(e),o).some(l=>l.roundness?.type===$c.LEGACY);return vt("fieldset",{children:[te("legend",{children:f("labels.edges")}),vt("div",{className:"buttonList",children:[te(eo,{group:"edges",options:[{value:"sharp",text:f("labels.sharp"),icon:OE},{value:"round",text:f("labels.round"),icon:zE}],value:pt(e,n,l=>a?null:l.roundness?"round":"sharp",l=>!jc(l)&&l.hasOwnProperty("roundness"),l=>l?null:o.currentItemRoundness),onChange:l=>t(l)}),r("togglePolygon")]})]})}}),Vx=e=>({visibleSections:[{name:"default",options:[{value:null,text:f("labels.arrowhead_none"),keyBinding:"q",icon:te(HE,{flip:e})},{value:"arrow",text:f("labels.arrowhead_arrow"),keyBinding:"w",icon:te(GE,{flip:e})},{value:"triangle",text:f("labels.arrowhead_triangle"),icon:te(UE,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:f("labels.arrowhead_triangle_outline"),icon:te(WE,{flip:e}),keyBinding:"r"}]}],hiddenSections:[{name:"default",options:[{value:"circle",text:f("labels.arrowhead_circle"),keyBinding:"a",icon:te(YE,{flip:e})},{value:"circle_outline",text:f("labels.arrowhead_circle_outline"),keyBinding:"s",icon:te(VE,{flip:e})},{value:"diamond",text:f("labels.arrowhead_diamond"),icon:te(XE,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:f("labels.arrowhead_diamond_outline"),icon:te(KE,{flip:e}),keyBinding:"f"},{value:"bar",text:f("labels.arrowhead_bar"),keyBinding:"z",icon:te(ZE,{flip:e})}]},{name:f("labels.cardinality"),options:[{value:"cardinality_one",text:f("labels.arrowhead_cardinality_one"),icon:te($E,{flip:e}),keyBinding:"x"},{value:"cardinality_many",text:f("labels.arrowhead_cardinality_many"),icon:te(jE,{flip:e}),keyBinding:"c"},{value:"cardinality_one_or_many",text:f("labels.arrowhead_cardinality_one_or_many"),icon:te(qE,{flip:e}),keyBinding:"v"},{value:"cardinality_exactly_one",text:f("labels.arrowhead_cardinality_exactly_one"),icon:te(JE,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_one",text:f("labels.arrowhead_cardinality_zero_or_one"),icon:te(QE,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_many",text:f("labels.arrowhead_cardinality_zero_or_many"),icon:te(e0,{flip:e}),keyBinding:null}]}]}),xee=F({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,o,t)=>(Fu(t,"actionChangeArrowhead: value must be defined"),{elements:wt(e,o,n=>{if(Ru(n)){let{position:r,type:i}=t;if(r==="start")return Qe(n,{startArrowhead:i});if(r==="end")return Qe(n,{endArrowhead:i})}return n}),appState:{...o,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=rn().rtl,i=Nu(()=>Vx(!r),[r]),a=Nu(()=>Vx(!!r),[r]);return vt("fieldset",{children:[te("legend",{children:f("labels.arrowheads")}),vt("div",{className:"iconSelectList buttonList",children:[te(Mu,{visibleSections:i.visibleSections,hiddenSections:i.hiddenSections,label:"arrowhead_start",value:pt(e,n,l=>Ru(l)&&ri(l.type)?Wx(l.startArrowhead):o.currentItemStartArrowhead,!0,l=>l?null:o.currentItemStartArrowhead),onChange:l=>t({position:"start",type:l})}),te(Mu,{visibleSections:a.visibleSections,hiddenSections:a.hiddenSections,label:"arrowhead_end",value:pt(e,n,l=>Ru(l)&&ri(l.type)?Wx(l.endArrowhead):o.currentItemEndArrowhead,!0,l=>l?null:o.currentItemEndArrowhead),onChange:l=>t({position:"end",type:l})})]})]})}}),r6=F({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})=>vt("div",{className:"selected-shape-actions",children:[r("changeArrowhead"),r("changeArrowType")]})}),yee=F({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,o,t,n)=>{let r=wt(e,o,l=>{if(!jc(l))return l;let s=n.scene.getNonDeletedElementsMap(),c=kr.getPointAtIndexGlobalCoordinates(l,0,s),m=kr.getPointAtIndexGlobalCoordinates(l,-1,s),p=Qe(l,{x:t===ro.elbow?c[0]:l.x,y:t===ro.elbow?c[1]:l.y,roundness:t===ro.round?{type:$c.PROPORTIONAL_RADIUS}:null,elbowed:t===ro.elbow,angle:t===ro.elbow?0:l.angle,points:t===ro.elbow||l.elbowed?[kr.pointFromAbsoluteCoords({...l,x:c[0],y:c[1],angle:0},c,s),kr.pointFromAbsoluteCoords({...l,x:c[0],y:c[1],angle:0},m,s)]:l.points});if(Kx(p)){p.fixedSegments=null;let d=n.scene.getNonDeletedElementsMap();n.dismissLinearEditor();let u=kr.getPointAtIndexGlobalCoordinates(p,0,d),b=kr.getPointAtIndexGlobalCoordinates(p,-1,d),g=p.startBinding&&d.get(p.startBinding.elementId),E=p.endBinding&&d.get(p.endBinding.elementId),y=g&&p.startBinding?{...p.startBinding,...Ux(p,g,"start",d,o.isBindingEnabled)}:null,v=E&&p.endBinding?{...p.endBinding,...Ux(p,E,"end",d,o.isBindingEnabled)}:null;p={...p,startBinding:y,endBinding:v,...YM(p,d,{points:[u,b].map(x=>SM(x[0]-p.x,x[1]-p.y)),startBinding:y,endBinding:v,fixedSegments:null})}}else{let d=n.scene.getNonDeletedElementsMap();if(p.startBinding){let u=d.get(p.startBinding.elementId);u&&Gx(p,u,o.bindMode==="inside"?"inside":"orbit","start",n.scene)}if(p.endBinding){let u=d.get(p.endBinding.elementId);u&&Gx(p,u,o.bindMode==="inside"?"inside":"orbit","end",n.scene)}}return p}),i={...o,currentItemArrowType:t},a=o.selectedLinearElement?.elementId;if(a){let l=r.find(s=>s.id===a);l&&(i.selectedLinearElement=new kr(l,Bu(e)))}return{elements:r,appState:i,captureUpdate:et.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>vt("fieldset",{children:[te("legend",{children:f("labels.arrowtypes")}),te("div",{className:"buttonList",children:te(eo,{group:"arrowtypes",options:[{value:ro.sharp,text:f("labels.arrowtype_sharp"),icon:bi,testId:"sharp-arrow"},{value:ro.round,text:f("labels.arrowtype_round"),icon:xi,testId:"round-arrow"},{value:ro.elbow,text:f("labels.arrowtype_elbowed"),icon:Ei,testId:"elbow-arrow"}],value:pt(e,n,r=>jc(r)?r.elbowed?ro.elbow:r.roundness?ro.round:ro.sharp:null,r=>jc(r),r=>r?null:o.currentItemArrowType),onChange:r=>t(r)})})]})});import{clamp as Xu,roundToStep as m6}from"@excalidraw/math";import{DEFAULT_CANVAS_BACKGROUND_PICKS as p6,CURSOR_TYPE as Qx,MAX_ZOOM as ey,MIN_ZOOM as ty,THEME as Il,ZOOM_STEP as Ku,updateActiveTool as Di,CODES as Fo,KEYS as mn}from"@excalidraw/common";import{getNonDeletedElements as u6}from"@excalidraw/element";import{getCommonBounds as h6}from"@excalidraw/element";import{CaptureUpdateAction as Oo}from"@excalidraw/element";import{useEffect as i6}from"react";import{jsx as l6}from"react/jsx-runtime";var _i=()=>{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},Uu=(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`})},a6=(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();Uu(o,r)},gt=({children:e,label:o,long:t=!1,style:n,disabled:r})=>(i6(()=>()=>_i().classList.remove("excalidraw-tooltip--visible"),[]),r?null:l6("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>a6(i.currentTarget,_i(),o,t),onPointerLeave:()=>_i().classList.remove("excalidraw-tooltip--visible"),style:n,children:e}));import{CURSOR_TYPE as Wu,MIME_TYPES as Yu,THEME as jx}from"@excalidraw/common";var qx='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',s6='<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"/>',Jx='<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"/>',c6=`data:${Yu.svg},${encodeURIComponent(`${qx}${Jx}</svg>`)}`,d6=`data:${Yu.svg},${encodeURIComponent(`${qx}${s6}${Jx}</svg>`)}`,_t=e=>{e&&(e.style.cursor="")},Ee=(e,o)=>{e&&(e.style.cursor=o)},No,$x,Vu=(e,o)=>{let n=()=>{let r=o===jx.DARK;No=document.createElement("canvas"),No.theme=o,No.height=20,No.width=20;let i=No.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(No.width/2,No.height/2,5,0,2*Math.PI),i.fillStyle=r?"#000":"#fff",i.fill(),i.strokeStyle=r?"#fff":"#000",i.stroke(),$x=No.toDataURL(Yu.svg)};(!No||No.theme!==o)&&n(),Ee(e,`url(${$x}) ${20/2} ${20/2}, auto`)},Dt=(e,o)=>{if(e)if(o.activeTool.type==="selection")_t(e);else if(bo(o))e.style.cursor=Wu.GRAB;else if(Mt(o))Vu(e,o.theme);else if(o.activeTool.type==="laser"){let t=o.theme===jx.LIGHT?c6:d6;e.style.cursor=`url(${t}), auto`}else["image","custom"].includes(o.activeTool.type)?o.activeTool.type!=="image"&&(e.style.cursor=Wu.AUTO):e.style.cursor=Wu.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),c=-(r-r/t),m=-(i-i/t);return{scrollX:l+c,scrollY:s+m,zoom:{value:t}}};import{jsx as ed,jsxs as E6}from"react/jsx-runtime";var g6=F({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?Oo.IMMEDIATELY:Oo.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:n,data:r})=>ed(bl,{palette:null,topPicks:p6,label:f("labels.canvasBackground"),type:"canvasBackground",color:o.viewBackgroundColor,onChange:i=>t({viewBackgroundColor:i}),"data-testid":"canvas-background-picker",elements:e,appState:o,updateData:t})}),qc=F({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:Ap,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>({appState:{...o,...Bo({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:Jt(o.zoom.value+Ku)},o),userToFollow:null},captureUpdate:Oo.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>ed(Z,{type:"button",className:"zoom-in-button zoom-button",icon:Ap,title:`${f("buttons.zoomIn")} \u2014 ${N("CtrlOrCmd++")}`,"aria-label":f("buttons.zoomIn"),disabled:o.zoom.value>=ey,onClick:()=>{e(null)}}),keyTest:e=>(e.code===Fo.EQUAL||e.code===Fo.NUM_ADD)&&(e[mn.CTRL_OR_CMD]||e.shiftKey)}),Jc=F({name:"zoomOut",label:"buttons.zoomOut",icon:Lp,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:Jt(o.zoom.value-Ku)},o),userToFollow:null},captureUpdate:Oo.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>ed(Z,{type:"button",className:"zoom-out-button zoom-button",icon:Lp,title:`${f("buttons.zoomOut")} \u2014 ${N("CtrlOrCmd+-")}`,"aria-label":f("buttons.zoomOut"),disabled:o.zoom.value<=ty,onClick:()=>{e(null)}}),keyTest:e=>(e.code===Fo.MINUS||e.code===Fo.NUM_SUBTRACT)&&(e[mn.CTRL_OR_CMD]||e.shiftKey)}),Qc=F({name:"resetZoom",label:"buttons.resetZoom",icon:dE,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:Jt(1)},o),userToFollow:null},captureUpdate:Oo.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>ed(gt,{label:f("buttons.resetZoom"),style:{height:"100%"},children:E6(Z,{type:"button",className:"reset-zoom-button zoom-button",title:f("buttons.resetZoom"),"aria-label":f("buttons.resetZoom"),onClick:()=>{e(null)},children:[(o.zoom.value*100).toFixed(0),"%"]})}),keyTest:e=>(e.code===Fo.ZERO||e.code===Fo.NUM_ZERO)&&(e[mn.CTRL_OR_CMD]||e.shiftKey)}),f6=(e,o,t=1)=>{let[n,r,i,a]=e,l=i-n,s=o.width/l,c=a-r,m=o.height/c,d=Math.min(s,m)*Xu(t,.1,1);return Math.min(d,1)},oy=({bounds:e,appState:o,canvasOffsets:t,fitToViewport:n=!1,viewportZoomFactor:r=1,minZoom:i=-1/0,maxZoom:a=1/0})=>{r=Xu(r,ty,ey);let[l,s,c,m]=e,p=(l+c)/2,d=(s+m)/2,u=t?.left??0,b=t?.top??0,g=t?.right??0,E=t?.bottom??0,y=o.width-u-g,v=o.height-b-E,x;if(n){let C=c-l,A=m-s;x=Math.min(y/C,v/A)*r}else x=f6(e,{width:y,height:v},r);let w=Jt(Xu(m6(x,Ku,"floor"),i,a)),I=Cb({scenePoint:{x:p,y:d},viewportDimensions:{width:o.width,height:o.height},offsets:t,zoom:{value:w}});return{appState:{...o,scrollX:I.scrollX,scrollY:I.scrollY,zoom:{value:w}},captureUpdate:Oo.EVENTUALLY}},Tl=({canvasOffsets:e,targetElements:o,appState:t,fitToViewport:n,viewportZoomFactor:r,minZoom:i,maxZoom:a})=>{let l=h6(u6(o));return oy({canvasOffsets:e,bounds:l,appState:t,fitToViewport:n,viewportZoomFactor:r,minZoom:i,maxZoom:a})},tte=F({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:wc,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return Tl({targetElements:r.length?r:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:n.getEditorUIOffsets()})},keyTest:e=>e.code===Fo.TWO&&e.shiftKey&&!e.altKey&&!e[mn.CTRL_OR_CMD]}),ote=F({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:wc,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return Tl({targetElements:r.length?r:e,appState:{...o,userToFollow:null},fitToViewport:!0,canvasOffsets:n.getEditorUIOffsets()})},keyTest:e=>e.code===Fo.THREE&&e.shiftKey&&!e.altKey&&!e[mn.CTRL_OR_CMD]}),b6=F({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:wc,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>Tl({targetElements:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:n.getEditorUIOffsets()}),keyTest:e=>e.code===Fo.ONE&&e.shiftKey&&!e.altKey&&!e[mn.CTRL_OR_CMD]}),Pr=F({name:"toggleTheme",label:(e,o)=>o.theme===Il.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:(e,o)=>e.theme===Il.LIGHT?rl:il,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t)=>({appState:{...o,theme:t||(o.theme===Il.LIGHT?Il.DARK:Il.LIGHT)},captureUpdate:Oo.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===Fo.D,predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.toggleTheme}),nte=F({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,o,t,n)=>{let r;return Mt(o)?r=Di(o,{...o.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveToolBeforeEraser:null}):r=Di(o,{type:"eraser",lastActiveToolBeforeEraser:o.activeTool}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:Oo.IMMEDIATELY}},keyTest:e=>e.key===mn.E}),rte=F({name:"toggleLassoTool",label:"toolBar.lasso",icon:An,trackEvent:{category:"toolbar"},predicate:(e,o,t,n)=>n.state.preferredSelectionTool.type!=="lasso",perform:(e,o,t,n)=>{let r;return o.activeTool.type!=="lasso"?(r=Di(o,{type:"lasso",fromSelection:!1}),Ee(n.interactiveCanvas,Qx.CROSSHAIR)):r=Di(o,{type:"selection"}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:Oo.NEVER}}}),ny=F({name:"toggleHandTool",label:"toolBar.hand",trackEvent:{category:"toolbar"},icon:yc,viewMode:!1,perform:(e,o,t,n)=>{let r;return bo(o)?r=Di(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(r=Di(o,{type:"hand",lastActiveToolBeforeEraser:o.activeTool}),Ee(n.interactiveCanvas,Qx.GRAB)),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:Oo.IMMEDIATELY}},keyTest:e=>!e.altKey&&!e[mn.CTRL_OR_CMD]&&e.key===mn.H});import{updateActiveTool as ry}from"@excalidraw/common";import{CaptureUpdateAction as x6}from"@excalidraw/element";var y6=F({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,o,t,n)=>{let r=ry(o,{type:"embeddable"});return Dt(n.canvas,{...o,activeTool:r}),{elements:e,appState:{...o,activeTool:ry(o,{type:"embeddable"})},captureUpdate:x6.EVENTUALLY}}});import{pointFrom as iy}from"@excalidraw/math";import{bindOrUnbindBindingElement as w6}from"@excalidraw/element/binding";import{isValidPolygon as ay,newElementWith as Zu}from"@excalidraw/element";import{LinearElementEditor as td}from"@excalidraw/element/linearElementEditor";import{isBindingElement as ly,isFreeDrawElement as sy,isLinearElement as cy,isLineElement as od}from"@excalidraw/element";import{KEYS as $u,arrayToMap as v6,invariant as dy,shouldRotateWithDiscreteAngle as I6,updateActiveTool as my}from"@excalidraw/common";import{isPathALoop as T6}from"@excalidraw/element";import{isInvisiblySmallElement as ju}from"@excalidraw/element";import{CaptureUpdateAction as py}from"@excalidraw/element";import{jsx as S6}from"react/jsx-runtime";var It=F({name:"finalize",label:"",trackEvent:!1,perform:(e,o,t,n)=>{let r=e,{interactiveCanvas:i,focusContainer:a,scene:l}=n,s=l.getNonDeletedElementsMap();if(t&&o.selectedLinearElement){let{event:d,sceneCoords:u}=t,b=td.getElement(o.selectedLinearElement.elementId,s);dy(b,"Arrow element should exist if selectedLinearElement is set"),dy(u,"sceneCoords should be defined if actionFinalize is called with event");let g=td.handlePointerUp(d,o.selectedLinearElement,o,n.scene);if(ly(b)&&!o.selectedLinearElement.segmentMidPointHoveredCoords){let E=!!o.newElement,v=(E||!o.selectedLinearElement.selectedPointsIndices?[b.points.length-1]:o.selectedLinearElement.selectedPointsIndices).reduce((x,w)=>(x.set(w,{point:td.pointFromAbsoluteCoords(b,iy(u.x-g.pointerOffset.x,u.y-g.pointerOffset.y),s)}),x),new Map)??new Map;w6(b,v,u.x-g.pointerOffset.x,u.y-g.pointerOffset.y,l,o,{newArrow:E,altKey:d.altKey,angleLocked:I6(d)})}else od(b)&&o.selectedLinearElement?.isEditing&&!o.newElement&&!ay(b.points)&&l.mutateElement(b,{polygon:!1});if(g!==o.selectedLinearElement){b&&ju(b)&&(r=r.map(y=>y.id===b.id?Zu(y,{isDeleted:!0}):y));let E=o.activeTool?.locked;return{elements:b.points.length<2||ju(b)?e.map(y=>y.id===b.id?Zu(y,{isDeleted:!0}):y):r,appState:{...o,cursorButton:"up",selectedLinearElement:E?null:{...g,selectedPointsIndices:null,isEditing:!1,initialState:{...g.initialState,lastClickedPoint:-1},pointerOffset:{x:0,y:0}},selectionElement:null,suggestedBinding:null,newElement:null,multiElement:null},captureUpdate:py.IMMEDIATELY}}}window.document.activeElement instanceof HTMLElement&&a();let c=null;if(o.multiElement)c=o.multiElement;else if(o.newElement?.type==="freedraw"||ly(o.newElement))c=o.newElement;else if(Object.keys(o.selectedElementIds).length===1){let d=s.get(Object.keys(o.selectedElementIds)[0]);d&&(c=d)}if(c){if(o.selectedLinearElement&&o.multiElement&&c.type!=="freedraw"&&o.lastPointerDownWith!=="touch"){let{points:d}=c,{lastCommittedPoint:u}=o.selectedLinearElement;(!u||d[d.length-1]!==u)&&l.mutateElement(c,{points:c.points.slice(0,-1)})}if(c&&ju(c)&&(r=r.map(d=>d.id===c?.id?Zu(d,{isDeleted:!0}):d)),cy(c)||sy(c)){if(T6(c.points,o.zoom.value)&&(od(c)||sy(c))){let u=c.points,b=u[0],g=u.map((E,y)=>y===u.length-1?iy(b[0],b[1]):E);od(c)?l.mutateElement(c,{points:g,polygon:!0}):l.mutateElement(c,{points:g})}od(c)&&!ay(c.points)&&l.mutateElement(c,{polygon:!1})}}(!o.activeTool.locked&&o.activeTool.type!=="freedraw"||!c)&&_t(i);let m;o.activeTool.type==="eraser"?m=my(o,{...o.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveToolBeforeEraser:null}):m=my(o,{type:n.state.preferredSelectionTool.type});let p=c&&cy(c)?new td(c,v6(r)):o.selectedLinearElement;return p=p&&{...p,isEditing:o.newElement?!1:p.isEditing,initialState:{...p.initialState,lastClickedPoint:-1,origin:null}},{elements:r,appState:{...o,cursorButton:"up",activeTool:(o.activeTool.locked||o.activeTool.type==="freedraw")&&c?o.activeTool:m,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,suggestedBinding:null,frameToHighlight:null,selectedElementIds:c&&!o.activeTool.locked&&o.activeTool.type!=="freedraw"?{...o.selectedElementIds,[c.id]:!0}:o.selectedElementIds,selectedLinearElement:p},captureUpdate:py.IMMEDIATELY}},keyTest:(e,o)=>e.key===$u.ESCAPE&&o.selectedLinearElement?.isEditing||(e.key===$u.ESCAPE||e.key===$u.ENTER)&&o.multiElement!==null,PanelComponent:({appState:e,updateData:o,data:t})=>S6(Z,{type:"button",icon:yE,title:f("buttons.done"),"aria-label":f("buttons.done"),onClick:o,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import{getElementsInGroup as gy,isSomeElementSelected as C6,makeNextSelectedElementIds as k6,selectGroupsForSelectedElements as P6}from"@excalidraw/element";import{CaptureUpdateAction as uy}from"@excalidraw/element";import{KEYS as M6,isWritableElement as A6,updateActiveTool as hy}from"@excalidraw/common";var L6=(e,o)=>e.activeTool.type==="eraser"?hy(e,{...e.activeTool.lastActiveTool||{type:o.state.preferredSelectionTool.type},lastActiveToolBeforeEraser:null}):hy(e,{type:o.state.preferredSelectionTool.type}),_6=(e,o,t)=>{if(!e.editingGroupId)return null;let n=o.scene.getNonDeletedElements(),r=o.scene.getSelectedElements({selectedElementIds:t,elements:n}),i=r.length?r:gy(n,e.editingGroupId);for(let a of i){let l=a.groupIds.indexOf(e.editingGroupId);if(l!==-1&&a.groupIds[l+1])return a.groupIds[l+1]}return null},D6=F({name:"deselect",label:"",trackEvent:!1,perform:(e,o,t,n)=>{let r=L6(o,n);if(o.editingGroupId){let i=n.scene.getNonDeletedElements(),a=Object.keys(o.selectedElementIds).length>0?o.selectedElementIds:gy(i,o.editingGroupId).reduce((l,s)=>(l[s.id]=!0,l),{});return{appState:{...o,...P6({editingGroupId:_6(o,n,a),selectedElementIds:a},i,o,n),activeEmbeddable:null,activeTool:r,selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,frameToHighlight:null},captureUpdate:uy.IMMEDIATELY}}return{appState:{...o,activeEmbeddable:null,activeTool:r,editingGroupId:null,selectedElementIds:k6({},o),selectedGroupIds:{},selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,frameToHighlight:null},captureUpdate:uy.IMMEDIATELY}},keyTest:(e,o,t,n)=>e.key!==M6.ESCAPE||A6(e.target)?!1:!o.newElement&&o.multiElement===null&&!o.selectedLinearElement?.isEditing&&(o.activeEmbeddable!==null||o.activeTool.type!==n.state.preferredSelectionTool.type||!!o.editingGroupId||!!o.selectedLinearElement||C6(n.scene.getNonDeletedElements(),o))});import{KEYS as cd,DEFAULT_EXPORT_PADDING as xA,EXPORT_SCALES as yA,THEME as Ml}from"@excalidraw/common";import{getNonDeletedElements as wA}from"@excalidraw/element";import{CaptureUpdateAction as yo}from"@excalidraw/element";import R6 from"clsx";import{jsx as fy,jsxs as N6}from"react/jsx-runtime";var Sl=({children:e,checked:o,onChange:t,className:n})=>N6("div",{className:R6("Checkbox",n,{"is-checked":o}),onClick:r=>{t(!o,r),r.currentTarget.querySelector(".Checkbox-box").focus()},children:[fy("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":o,children:gc}),fy("div",{className:"Checkbox-label",children:e})]});import{THEME as Cl}from"@excalidraw/common";import{jsx as kl}from"react/jsx-runtime";var Ey=e=>{let o=e.title||(e.value===Cl.DARK?f("buttons.lightMode"):f("buttons.darkMode"));return kl(Z,{type:"icon",icon:e.value===Cl.LIGHT?by.MOON:by.SUN,title:o,"aria-label":o,onClick:()=>e.onChange(e.value===Cl.DARK?Cl.LIGHT:Cl.DARK),"data-testid":"toggle-dark-mode"})},by={SUN:kl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:kl("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:kl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:kl("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 B6}from"react";import{focusNearestParent as F6,KEYS as O6}from"@excalidraw/common";import{jsx as xy,jsxs as z6}from"react/jsx-runtime";var yy=e=>{let{id:o}=Ne(),[t,n]=B6(e.value),r=a=>{e.ignoreFocus||F6(a.target);let l=a.target.value;l!==e.value&&e.onChange(l)},i=a=>{if(a.key===O6.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return z6("div",{className:"ProjectName",children:[xy("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),xy("input",{type:"text",className:"TextInput",onBlur:r,onKeyDown:i,id:`${o}-filename`,value:t,onChange:a=>n(a.target.value)})]})};import{useCallback as H6,useEffect as G6,useRef as U6}from"react";import{jsx as nd,jsxs as X6}from"react/jsx-runtime";var W6=5e3,Y6=({progress:e})=>nd("div",{className:"Toast__progress-bar",children:nd("div",{className:"Toast__progress-bar-fill",style:{width:`${Math.min(5,Math.round(e*100))}%`}})}),V6=({message:e,onClose:o,closable:t=!1,duration:n=W6,style:r})=>{let i=U6(0),a=n!==1/0,l=H6(()=>{a&&(i.current=window.setTimeout(()=>o(),n))},[o,n,a]);return G6(()=>{if(a)return l(),()=>clearTimeout(i.current)},[l,e,n,a]),X6("div",{className:"Toast",role:"status",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?l:void 0,style:r,children:[nd("div",{className:"Toast__message",children:e}),t&&nd(Z,{icon:Qt,"aria-label":"close",type:"icon",onClick:o,className:"close"})]})},Ri=Object.assign(V6,{ProgressBar:Y6});import{DEFAULT_EXPORT_PADDING as cA,DEFAULT_FILENAME as dA,IMAGE_MIME_TYPES as ky,isFirefox as mA,MIME_TYPES as pA,cloneJSON as uA,SVG_DOCUMENT_PREAMBLE as hA,arrayToMap as gA}from"@excalidraw/common";import{getNonDeletedElements as fA}from"@excalidraw/element";import{isFrameLikeElement as bA}from"@excalidraw/element";import{getElementsOverlappingFrame as EA}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as K6,EXPORT_DATA_TYPES as Pl,MIME_TYPES as Wt,arrayToMap as Z6,isMemberOf as $6,isPromiseLike as j6,EVENT as rd}from"@excalidraw/common";import{mutateElement as q6}from"@excalidraw/element";import{deepCopyElement as J6}from"@excalidraw/element";import{isFrameLikeElement as Q6,isInitializedImageElement as eA}from"@excalidraw/element";import{getContainingFrame as wy}from"@excalidraw/element";var koe="clipboard"in navigator&&"readText"in navigator.clipboard,id="clipboard"in navigator&&"writeText"in navigator.clipboard,Vn="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,tA=e=>!!([Pl.excalidraw,Pl.excalidrawClipboard,Pl.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),vy=({types:e,files:o})=>{!e&&!o&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent(rd.PASTE,{clipboardData:new DataTransfer});if(e)for(let[n,r]of Object.entries(e)){if(typeof r!="string"){o=o||[],o.push(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},oA=({elements:e,files:o})=>{let t=Z6(e),n=new Set(e.filter(l=>Q6(l))),r=!1,i=e.reduce((l,s)=>(eA(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:Pl.excalidrawClipboard,elements:e.map(l=>{if(wy(l,t)&&!n.has(wy(l,t))){let s=J6(l);return q6(s,t,{frameId:null}),s}return l}),files:o?i:void 0};return JSON.stringify(a)},ad=async(e,o,t)=>{let n=oA({elements:e,files:o});await xo({[Wt.excalidrawClipboard]:n,[Wt.text]:n},t)};function Iy(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(Iy(t));return o}var nA=e=>{let o=e.value;try{let t=new DOMParser().parseFromString(o,Wt.html),n=Iy(t.body);if(n.length)return{type:"mixedContent",value:n}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},Ty=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{[Wt.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($6(K6,n))try{if(n===Wt.text||n===Wt.html)e[n]=await(await t.getType(n)).text();else if(zb(n)){let r=await t.getType(n),i=Xb(r,n,void 0);e[n]=i}else throw new wp(`Unsupported clipboard type: ${n}`)}catch(r){console.warn(r instanceof wp?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},rA=async(e,o=!1)=>{try{let t=e.findByType(Wt.html),n=!o&&t&&nA(t);return n?n.value.every(r=>r.type==="text")?{type:"text",value:e.getData(Wt.text)??n.value.map(r=>r.value).join(`
2
- `).trim()}:n:{type:"text",value:(e.getData(Wt.text)||"").trim()}}catch{return{type:"text",value:""}}},iA=function(e){return this.find(o=>o.type===e)||null},aA=function(e){return this.find(t=>t.type===e)?.value??null},lA=function(){return this.filter(e=>e.kind==="file")},Sy=e=>{let o;Cy(e)?o=e.clipboardData?.items:o=e.dataTransfer?.items;let t=new Set;for(let n of Array.from(o||[]))t.has(n.type)||t.add(n.type);return t},Ni=async e=>{let o;Cy(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 Vb(n);return r=await ol(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:iA,getData:aA,getFiles:lA})},ld=async(e,o=!1)=>{let t=await rA(e,o);if(t.type==="mixedContent")return{mixedContent:t.value};try{let n=JSON.parse(t.value),r=n.type===Pl.excalidrawClipboardWithAPI;if(tA(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}},sd=async e=>{try{await navigator.clipboard.write([new ClipboardItem({[Wt.png]:e})])}catch(o){if(j6(e))await navigator.clipboard.write([new ClipboardItem({[Wt.png]:await e})]);else throw o}},xo=async(e,o)=>{e=e||"";let t=Object.entries(typeof e=="string"?{[Wt.text]:e}:e);try{if(o){for(let[r,i]of t)if(o.clipboardData?.setData(r,i),o.clipboardData?.getData(r)!==i)throw new Error("Failed to setData on clipboardEvent");return}}catch(r){console.error(r)}let n=t.find(([r])=>r===Wt.text);if(id&&n)try{await navigator.clipboard.writeText(n[1]);return}catch(r){console.error(r)}if(n&&!sA(n[1]))throw new Error("Error copying to clipboard.")},sA=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},Cy=e=>e.type===rd.PASTE||e.type===rd.COPY||e.type===rd.CUT;var Mr=(e,{selectedElementIds:o},t)=>{e=fA(e);let n=gA(e),r=t&&Pe(e,{selectedElementIds:o}),i=null,a=r?ee(e,{selectedElementIds:o},{includeBoundTextElement:!0}):e;return r&&(a.length===1&&bA(a[0])?(i=a[0],a=EA(e,i,n)):a.length>1&&(a=ee(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:i,exportedElements:uA(a)}},Ar=async(e,o,t,n,{exportBackground:r,exportPadding:i=cA,viewBackgroundColor:a,name:l=t.name||dA,fileHandle:s=null,exportingFrame:c=null})=>{if(o.length===0)throw new Error(f("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let p=yr(o,{exportBackground:r,exportWithDarkMode:t.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:t.exportScale,exportEmbedScene:t.exportEmbedScene&&e==="svg"},n,{exportingFrame:c});if(e==="svg")return vp(p.then(d=>new Blob([hA+d.outerHTML],{type:pA.svg})),{description:"Export to SVG",name:l,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[ky.svg],fileHandle:s});if(e==="clipboard-svg"){let d=await p.then(u=>u.outerHTML);try{await xo(d)}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return}}let m=ec(o,t,n,{exportBackground:r,viewBackgroundColor:a,exportPadding:i,exportingFrame:c});if(e==="png"){let p=vr(m);return t.exportEmbedScene&&(p=p.then(d=>import("./data/image-AN67VCG3.js").then(({encodePngMetadata:u})=>u({blob:d,metadata:Ja(o,t,n,"local")})))),vp(p,{description:"Export to PNG",name:l,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[ky.png],fileHandle:s})}else if(e==="clipboard")try{let p=vr(m);await sd(p)}catch(p){throw console.warn(p),p.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):mA&&p.name==="TypeError"?new Error(`${f("alerts.couldNotCopyToClipboard")}
1
+ import{$ as oc,A as Lk,B as Ab,C as Lb,D as qs,E as Qa,F as Js,G as Qs,H as el,I as _b,J as Db,K as Rb,L as ec,M as yr,N as Nb,O as _k,P as wr,Q as li,R as tl,T as Bb,V as Fb,W as Ob,X as tc,Y as zb,Z as Tp,_ as Sp,a as Cb,aa as Hb,b as xr,ba as Cp,c as Jt,ca as vr,d as kb,da as Gb,e as Pe,ea as kp,f as Pb,fa as Ub,g as ee,ga as Wb,h as ni,ha as Pp,i as Lo,ia as Yb,j as $a,ja as Vb,k as ja,ka as Xb,l as ri,la as ol,m as qa,n as ii,o as Mb,p as wp,q as nn,r as Pn,s as Mt,t as bo,u as ai,v as $s,w as vp,x as Ja,y as js,z as Ip}from"./chunk-SGSDFYY3.js";import{a as T}from"./chunk-YUBA7MSK.js";import{K as yp}from"./chunk-SC7IWESZ.js";import{c as Sb}from"./chunk-3PELD44J.js";import{b as Ib,c as Tb,d as S}from"./chunk-SRAX5OIU.js";import ZV,{useCallback as $V,useContext as jV,useEffect as qV,useRef as JV,useState as QV}from"react";import{DEFAULT_UI_OPTIONS as Pk,isShallowEqual as eX}from"@excalidraw/common";import QC from"clsx";import fW from"lodash.throttle";import go,{useContext as Cn}from"react";import{flushSync as $t}from"react-dom";import bW from"roughjs/bin/rough";import{nanoid as EW}from"nanoid";import{clamp as P1,pointFrom as oe,pointDistance as In,vector as e5,pointRotateRads as M1,vectorFromPoint as A1,vectorSubtract as t5,vectorDot as o5,vectorNormalize as n5}from"@excalidraw/math";import{COLOR_PALETTE as xW,CODES as r5,shouldResizeFromCenter as i5,shouldMaintainAspectRatio as _s,shouldRotateWithDiscreteAngle as a5,isArrowKey as np,KEYS as X,APP_NAME as yW,CURSOR_TYPE as Re,DEFAULT_TRANSFORM_HANDLE_SPACING as wW,DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT as vW,DEFAULT_VERTICAL_ALIGN as l5,DRAGGING_THRESHOLD as s5,ELEMENT_SHIFT_TRANSLATE_AMOUNT as IW,ELEMENT_TRANSLATE_AMOUNT as c5,EVENT as Q,FRAME_STYLE as $o,IMAGE_MIME_TYPES as TW,IMAGE_RENDER_TIMEOUT as SW,LINE_CONFIRM_THRESHOLD as L1,MAX_ALLOWED_FILE_BYTES as d5,MIME_TYPES as jo,MQ_RIGHT_SIDEBAR_MIN_WIDTH as CW,POINTER_BUTTON as qo,ROUNDNESS as rp,SCROLL_TIMEOUT as kW,TAP_TWICE_TIMEOUT as m5,TEXT_TO_CENTER_SNAP_THRESHOLD as PW,THEME as za,TOUCH_CTX_MENU_TIMEOUT as MW,VERTICAL_ALIGN as AW,YOUTUBE_STATES as ip,ZOOM_STEP as LW,POINTER_EVENTS as Ha,TOOL_TYPE as Jo,supportsResizeObserver as _W,DEFAULT_COLLISION_THRESHOLD as p5,DEFAULT_TEXT_ALIGN as DW,ARROW_TYPE as ur,DEFAULT_REDUCED_GLOBAL_ALPHA as RW,isLocalLink as NW,normalizeLink as _1,toValidURL as BW,getGridPoint as xt,getLineHeight as u5,debounce as h5,distance as Ga,getFontString as D1,getNearestScrollableContainer as FW,isInputLike as g5,isToolIcon as OW,isWritableElement as Ds,sceneCoordsToViewportCoords as ap,tupleToCoors as R1,viewportCoordsToSceneCoords as He,wrapEvent as zW,updateObject as N1,updateActiveTool as Qo,isTransparent as HW,easeToValuesRAF as GW,muteFSAbortError as UW,isTestEnv as rk,isDevEnv as ik,easeOut as WW,updateStable as Rs,addEventListener as Xe,normalizeEOL as YW,getDateTime as f5,isShallowEqual as b5,arrayToMap as lp,applyDarkModeFilter as VW,AppEventBus as XW,randomInteger as KW,CLASSES as B1,Emitter as Jr,MINIMUM_ARROW_SIZE as ZW,DOUBLE_TAP_POSITION_THRESHOLD as E5,BIND_MODE_TIMEOUT as $W,invariant as en,getFeatureFlag as Tn,createUserAgentDescriptor as ak,getFormFactor as jW,deriveStylesPanelMode as up,isIOS as qW,isBrave as JW,isSafari as QW,loadDesktopUIModePreference as eY,setDesktopUIMode as tY,isSelectionLikeTool as Ns,oneOf as oY,matchKey as x5}from"@excalidraw/common";import{getObservedAppState as nY,getCommonBounds as Ua,getElementAbsoluteCoords as y5,bindOrUnbindBindingElements as w5,fixBindingsAfterDeletion as rY,getHoveredElementForBinding as tn,isBindingEnabled as Bs,updateBoundElements as sp,newElementWith as hr,newFrameElement as iY,newFreeDrawElement as aY,newEmbeddableElement as v5,newMagicFrameElement as I5,newIframeElement as lY,newArrowElement as sY,newElement as cY,newImageElement as dY,newLinearElement as mY,newTextElement as T5,refreshTextDimensions as pY,deepCopyElement as S5,duplicateElements as F1,hasBoundTextElement as C5,isArrowElement as Wa,isBindingElement as on,isBindingElementType as uY,isBoundToContainer as O1,isFrameLikeElement as ht,isImageElement as Qr,isEmbeddableElement as Sn,isInitializedImageElement as Fs,isLinearElement as kt,isLinearElementType as hY,isUsingAdaptiveRadius as gY,isIframeElement as Ya,isIframeLikeElement as z1,isMagicFrameElement as k5,isTextBindableContainer as P5,isElbowArrow as Ht,isFlowchartNodeElement as fY,isBindableElement as H1,isTextElement as jt,getNormalizedDimensions as bY,isElementCompletelyInViewport as G1,isElementInViewport as M5,isInvisiblySmallElement as A5,getCornerRadius as EY,isPathALoop as L5,createSrcDoc as _5,embeddableURLValidator as U1,maybeParseEmbedSrc as xY,getEmbedLink as cp,getInitializedImageElements as yY,normalizeSVG as D5,updateImageCache as wY,getBoundTextElement as W1,getContainerCenter as Y1,getContainerElement as R5,isValidTextContainer as N5,redrawTextBoundingBox as vY,hasBoundingBox as IY,getCommonFrameId as B5,getFrameChildren as V1,getFrameChildrenInsertionIndex as TY,isCursorInFrame as F5,addElementsToFrame as X1,replaceAllElementsInFrame as SY,removeElementsFromFrame as CY,getElementsInResizingFrame as K1,getElementsInNewFrame as kY,getContainingFrame as Z1,elementOverlapsWithFrame as PY,updateFrameMembershipOfSelectedElements as O5,isElementInFrame as z5,getFrameLikeTitle as MY,getElementsOverlappingFrame as AY,filterElementsEligibleAsFrameChildren as LY,hitElementBoundText as _Y,hitElementBoundingBoxOnly as DY,hitElementItself as Os,getVisibleSceneBounds as RY,FlowChartCreator as NY,FlowChartNavigator as BY,getLinkDirectionFromKey as H5,cropElement as FY,wrapText as OY,isElementLink as $1,parseElementLinkFromURL as zY,isMeasureTextSupported as HY,normalizeText as GY,measureText as G5,getLineHeightInPx as U5,getApproxMinLineWidth as UY,getApproxMinLineHeight as WY,getMinTextElementWidth as YY,ShapeCache as zs,getRenderOpacity as VY,editGroupForSelectedElement as XY,getElementsInGroup as ei,getSelectedGroupIdForElement as KY,getSelectedGroupIds as ZY,isElementInGroup as W5,isSelectedViaGroup as $Y,selectGroupsForSelectedElements as ho,syncInvalidIndices as lk,syncMovedIndices as Y5,excludeElementsInFramesFromSelection as jY,getSelectionStateForElements as qY,makeNextSelectedElementIds as Ce,getResizeOffsetXY as JY,getResizeArrowDirection as QY,transformElements as eV,getCursorForResizingElement as V5,getElementWithTransformHandleType as X5,getTransformHandleTypeFromCoords as K5,dragNewElement as Z5,dragSelectedElements as tV,getDragOffsetXY as oV,isNonDeletedElement as $5,Scene as j5,Store as nV,CaptureUpdateAction as Pt,hitElementBoundingBox as rV,isLineElement as j1,isSimpleArrow as q1,StoreDelta as q5,positionElementsOnGrid as J5,calculateFixedPointForNonElbowArrowBinding as Q5,bindOrUnbindBindingElement as iV,mutateElement as dp,getElementBounds as ek,doBoundsIntersect as aV,isPointInElement as lV,maxBindingDistance_simple as J1,convertToExcalidrawElements as sV,getSnapOutlineMidPoint as Q1,handleFocusPointDrag as cV,handleFocusPointHover as dV,handleFocusPointPointerDown as mV,handleFocusPointPointerUp as pV,maybeHandleArrowPointlikeDrag as mp,getUncroppedWidthAndHeight as uV,getActiveTextElement as tk,isEligibleFrameChildType as hV}from"@excalidraw/element";import{LinearElementEditor as he}from"@excalidraw/element/linearElementEditor";import{findShapeByKey as gV}from"@excalidraw/element/shapes";import{KEYS as tu,MOBILE_ACTION_BUTTON_BG as Kk,updateActiveTool as Zk}from"@excalidraw/common";import{getNonDeletedElements as ou}from"@excalidraw/element";import{fixBindingsAfterDeletion as $k}from"@excalidraw/element";import{LinearElementEditor as Y0}from"@excalidraw/element/linearElementEditor";import{newElementWith as Pc}from"@excalidraw/element";import{getContainerElement as V0}from"@excalidraw/element";import{isBoundToContainer as Cc,isElbowArrow as jk,isFrameLikeElement as qk}from"@excalidraw/element";import{getFrameChildren as Jk}from"@excalidraw/element";import{getElementsInGroup as nu,selectGroupsForSelectedElements as Qk}from"@excalidraw/element";import{CaptureUpdateAction as kc}from"@excalidraw/element";import{isDevEnv as Bk}from"@excalidraw/common";import{atom as _e,createStore as Dk}from"jotai";import{createIsolation as Rk}from"jotai-scope";var Kb=Rk();var{useAtom:fe,useSetAtom:si,useAtomValue:nc,useStore:aX}=Kb,Zb=Kb.Provider,ot=Dk();var Nk=Ib({"./locales/ar-SA.json":()=>import("./locales/ar-SA-TS6M4GHP.js"),"./locales/az-AZ.json":()=>import("./locales/az-AZ-HJWG4CPD.js"),"./locales/bg-BG.json":()=>import("./locales/bg-BG-K42QREUV.js"),"./locales/bn-BD.json":()=>import("./locales/bn-BD-IFEECH4W.js"),"./locales/bn-IN.json":()=>import("./locales/bn-IN-OE7SKNFR.js"),"./locales/ca-ES.json":()=>import("./locales/ca-ES-MKBCGNOG.js"),"./locales/cs-CZ.json":()=>import("./locales/cs-CZ-V77HGUP7.js"),"./locales/da-DK.json":()=>import("./locales/da-DK-I5RFNTM4.js"),"./locales/de-CH.json":()=>import("./locales/de-CH-WLRDEVBV.js"),"./locales/de-DE.json":()=>import("./locales/de-DE-DTI4WUSC.js"),"./locales/el-GR.json":()=>import("./locales/el-GR-ZXDJ2OS4.js"),"./locales/en.json":()=>import("./locales/en-NJXWY54O.js"),"./locales/es-ES.json":()=>import("./locales/es-ES-DYQHAD43.js"),"./locales/eu-ES.json":()=>import("./locales/eu-ES-QDSYU5Y3.js"),"./locales/fa-IR.json":()=>import("./locales/fa-IR-26LZG4PM.js"),"./locales/fi-FI.json":()=>import("./locales/fi-FI-6YS4KDE4.js"),"./locales/fr-FR.json":()=>import("./locales/fr-FR-BRLLPTZC.js"),"./locales/gl-ES.json":()=>import("./locales/gl-ES-OKUZTLYG.js"),"./locales/he-IL.json":()=>import("./locales/he-IL-26MGYIU7.js"),"./locales/hi-IN.json":()=>import("./locales/hi-IN-Q4ZOGTP2.js"),"./locales/hu-HU.json":()=>import("./locales/hu-HU-P2OXPSN5.js"),"./locales/id-ID.json":()=>import("./locales/id-ID-2EIKXYN6.js"),"./locales/it-IT.json":()=>import("./locales/it-IT-4CFKVXI2.js"),"./locales/ja-JP.json":()=>import("./locales/ja-JP-MAND2Z4V.js"),"./locales/kaa.json":()=>import("./locales/kaa-HQRTCXTJ.js"),"./locales/kab-KAB.json":()=>import("./locales/kab-KAB-JKIKKTGH.js"),"./locales/kk-KZ.json":()=>import("./locales/kk-KZ-HXQ63ZFC.js"),"./locales/km-KH.json":()=>import("./locales/km-KH-PKL3LSGX.js"),"./locales/ko-KR.json":()=>import("./locales/ko-KR-KXLREZX3.js"),"./locales/ku-TR.json":()=>import("./locales/ku-TR-MJ4IER3X.js"),"./locales/lt-LT.json":()=>import("./locales/lt-LT-H6WFQ6FJ.js"),"./locales/lv-LV.json":()=>import("./locales/lv-LV-GOCK6SJW.js"),"./locales/mr-IN.json":()=>import("./locales/mr-IN-IXVLDMEQ.js"),"./locales/my-MM.json":()=>import("./locales/my-MM-YG6MYTTD.js"),"./locales/nb-NO.json":()=>import("./locales/nb-NO-XGWJISD2.js"),"./locales/nl-NL.json":()=>import("./locales/nl-NL-XVDVCPNC.js"),"./locales/nn-NO.json":()=>import("./locales/nn-NO-EMX5MJX5.js"),"./locales/oc-FR.json":()=>import("./locales/oc-FR-ROEINTVO.js"),"./locales/pa-IN.json":()=>import("./locales/pa-IN-ZYN6SUDY.js"),"./locales/percentages.json":()=>import("./locales/percentages-5DKR754L.js"),"./locales/pl-PL.json":()=>import("./locales/pl-PL-6VTG7PHC.js"),"./locales/pt-BR.json":()=>import("./locales/pt-BR-5YFKRR5G.js"),"./locales/pt-PT.json":()=>import("./locales/pt-PT-GEIXXZ67.js"),"./locales/ro-RO.json":()=>import("./locales/ro-RO-E2P6TFZI.js"),"./locales/ru-RU.json":()=>import("./locales/ru-RU-YBIIY43T.js"),"./locales/si-LK.json":()=>import("./locales/si-LK-673C2CI2.js"),"./locales/sk-SK.json":()=>import("./locales/sk-SK-CKZHQ4AP.js"),"./locales/sl-SI.json":()=>import("./locales/sl-SI-557H2GWM.js"),"./locales/sv-SE.json":()=>import("./locales/sv-SE-XOPKKDWS.js"),"./locales/ta-IN.json":()=>import("./locales/ta-IN-XBH7DQI3.js"),"./locales/th-TH.json":()=>import("./locales/th-TH-TOCWH3R4.js"),"./locales/tr-TR.json":()=>import("./locales/tr-TR-GXW6CYY5.js"),"./locales/uk-UA.json":()=>import("./locales/uk-UA-IJKTNUDG.js"),"./locales/uz-UZ.json":()=>import("./locales/uz-UZ-TBZZEA4V.js"),"./locales/vi-VN.json":()=>import("./locales/vi-VN-MULSGNVB.js"),"./locales/zh-CN.json":()=>import("./locales/zh-CN-MVX3E32U.js"),"./locales/zh-HK.json":()=>import("./locales/zh-HK-JNU5RLIE.js"),"./locales/zh-TW.json":()=>import("./locales/zh-TW-LENVCA6T.js")});var Fk=85,_o={code:"en",label:"English"},di=[_o,...[{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=>Sb[e.code]>=Fk).sort((e,o)=>e.label>o.label?1:-1)],ic="__test__";Bk()&&di.unshift({code:ic,label:"test language"},{code:`${ic}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var ci=_o,rc={},ac=async e=>{if(ci=e,document.documentElement.dir=ci.rtl?"rtl":"ltr",document.documentElement.lang=ci.code,e.code.startsWith(ic))rc={};else try{rc=await Nk(`./locales/${ci.code}.json`)}catch(o){console.error(`Failed to load language ${e.code}:`,o.message),rc=yp}ot.set(jb,e.code)},rn=()=>ci,$b=(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},f=(e,o,t)=>{if(ci.code.startsWith(ic))return`\u202A[[${o?`${e}(${JSON.stringify(o).slice(1,-1)})`:e}]]\u202C`;let n=e.split("."),r=$b(rc,n)||$b(yp,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},jb=_e(_o.code),Me=()=>{let e=nc(jb);return{t:f,langCode:e}};import Ok from"clsx";import $e from"react";import{THEME as zk}from"@excalidraw/common";import{Fragment as Ae,jsx as h,jsxs as B}from"react/jsx-runtime";var Eo=e=>"var(--icon-fill-color)",qb=e=>e===zk.LIGHT?"#fff":"#1e1e1e",P=(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:Ok({"rtl-mirror":r}),style:i,...a,children:typeof e=="string"?h("path",{fill:"currentColor",d:e}):e})},H={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},le={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},yt={width:40,height:20},wX=P(B("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"})]}),H),lc=P(B("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"})]}),H),Jb=P(B("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"})]}),H),Qb=P(B("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"})]}),H),eE=P(B("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"})]}),H),tE=P(B("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"})]}),H),Mp=P(B("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"})]}),H),an=P(B("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"})})]}),le),Mn=P(B("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"})]}),le),oE=P(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}),nE=P(B(Ae,{children:[h("path",{d:"M38.5 83.5c-14-2-17.833-10.473-21-22.5C14.333 48.984 12 22 12 12.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),h("path",{d:"M12.005 10.478c1.92 3.495 3.838 7 7.905 14.423m-7.905-14.423c3.11 5.683 6.23 11.368 7.905 14.423m0 0c-3.68.226-7.35.455-13.91.85m13.91-.85c-5.279.33-10.566.647-13.91.85m0 0c1.936-4.931 3.882-9.86 6.005-15.273M6 25.75c2.069-5.257 4.135-10.505 6.005-15.272",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:41,height:94,fill:"none"}),rE=P(B(Ae,{children:[h("path",{d:"M18.026 1.232c-5.268 13.125-5.548 33.555 3.285 42.311 8.823 8.75 33.31 12.304 42.422 13.523",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),h("path",{d:"M72.181 59.247c-3.163-2.429-6.337-4.856-13.058-10m13.058 10c-5.145-3.936-10.292-7.882-13.058-10m0 0c-.78 3.603-1.563 7.196-2.948 13.62m2.948-13.62c-1.126 5.168-2.24 10.346-2.948 13.62m0 0c5.168-1.166 10.334-2.343 16.006-3.62m-16.006 3.62c5.51-1.248 11.01-2.495 16.006-3.62",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:85,height:71,fill:"none"}),iE=P(B(Ae,{children:[h("path",{d:"M1 77c14-2 31.833-11.973 35-24 3.167-12.016-6-35-9.5-43.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),h("path",{d:"M24.165 1.093c-.522 3.953-1.037 7.916-2.132 16.309m2.131-16.309c-.835 6.424-1.68 12.854-2.13 16.308m0 0c3.51-1.125 7.013-2.243 13.27-4.257m-13.27 4.257c5.038-1.608 10.08-3.232 13.27-4.257m0 0c-3.595-3.892-7.197-7.777-11.14-12.05m11.14 12.05c-3.837-4.148-7.667-8.287-11.14-12.05",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:38,height:78,fill:"none"}),vX=P(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"}),sc=P(B("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}),An=P(B("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}),cc=P(B("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"})]}),H),dc=P(B("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"})]}),H),mc=P(B("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"})]}),H),aE=P(B("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"})]}),H),pc=P(h("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),le),lE=P(B("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"})]}),H),Ln=P(B("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"})]}),le),_n=P(B("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"})]}),H),sE=P(B("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"})]}),H),uc=P(B("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"})]}),le),cE=P(B("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"})]}),H),Ap=P(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),le),Lp=P(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),le),dE=P(B("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"})]}),H),ln=P(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"}),le),hc=P(B("g",{strokeWidth:"1.5",children:[h("polyline",{points:"12 16 18 10 12 4"}),h("polyline",{points:"8 4 2 10 8 16"})]}),le),nl=P(B("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"})]}),le),rl=P(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"}),le),il=P(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"})}),{...le,strokeWidth:1.5}),mE=P(B("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"})]}),H),Ir=P(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"}),le),mi=P(B("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"})]}),H),pE=P(B("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"})]}),H),IX=P(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"}),le),uE=P(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"}),le),hE=P(B("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"})]}),le),gE=P(B("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"})]}),H),gc=P(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),al=P(B("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"})]}),le),fE=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}),bE=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}),pi=P(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"}),le),TX=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}),SX=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"),ui=P(B("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"})]}),H),EE=P(h("g",{strokeWidth:1.5,children:h("path",{d:"M6 18l12 -12"})}),H),fc=P(B("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"})]}),H),xE=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}),CX=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}),kX=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}),yE=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"),PX=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"),_p=P(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"}),le),Dp=P(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"}),le),wE=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}),vE=P(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"}),le),MX=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"),AX=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}),LX=P(B("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"})]}),H),_X=P(B(Ae,{children:[h("path",{fill:"currentColor",d:"M40 5.6v6.1l-4.1.7c-8.9 1.4-16.5 6.9-20.6 15C13 32 10.9 43 12.4 43c.4 0 2.4-1.3 4.4-3 5-3.9 12.1-7 18.2-7.7l5-.6v12.8l11.2-11.3L62.5 22 51.2 10.8 40-.5v6.1zm10.2 22.6L44 34.5v-6.8l-6.9.6c-3.9.3-9.8 1.7-13.2 3.1-3.5 1.4-6.5 2.4-6.7 2.2-.9-1 3-7.5 6.4-10.8C28 18.6 34.4 16 40.1 16c3.7 0 3.9-.1 3.9-3.2V9.5l6.2 6.3 6.3 6.2-6.3 6.2z"}),h("path",{stroke:"currentColor",fill:"currentColor",d:"M0 36v20h48v-6.2c0-6 0-6.1-2-4.3-1.1 1-2 2.9-2 4.2V52H4V34c0-17.3-.1-18-2-18s-2 .7-2 20z"})]}),{width:64,height:64}),DX=P(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}),IE=B("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"})]}),TE=B("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"})]}),Rp=P(TE,H),Np=P(TE,{...H,style:{transform:"rotate(180deg)"}}),Bp=P(IE,H),Fp=P(IE,{...H,style:{transform:"rotate(180deg)"}}),Op=P(B(Ae,{children:[B("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"})})})]}),le),zp=P(B(Ae,{children:[B("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"})})})]}),le),Hp=P(B(Ae,{children:[B("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"})})})]}),le),Gp=P(B(Ae,{children:[B("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"})})})]}),le),SE=P(B(Ae,{children:[B("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"})})})]}),le),CE=P(B(Ae,{children:[B("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"})})})]}),le),Up=P(B("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"})]}),le),Wp=P(B("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"})]}),le),bc=P(B("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"})]}),H),RX=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"),NX=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"),Qt=P(B(Ae,{children:[h("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M15 5 5 15M5 5l10 10"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),BX=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}),FX=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}),OX=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}),Yp=$e.memo(({theme:e})=>P(B(Ae,{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"}),B("g",{fill:qb(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})),Vp=$e.memo(({theme:e})=>P(B(Ae,{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"}),B("g",{fill:qb(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})),kE=P(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"})}),le),PE=P(B(Ae,{children:[h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.25"})}),h("g",{mask:"url(#FillHachureIcon)",children:h("path",{d:"M2.258 15.156 15.156 2.258M7.324 20.222 20.222 7.325m-20.444 5.35L12.675-.222m-8.157 18.34L17.416 5.22",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})]}),le),ME=P(B(Ae,{children:[B("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"})})})]}),le),AE=P(B(Ae,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z",stroke:"currentColor",strokeWidth:"1.25"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...le,fill:"currentColor"}),Xp=P(h(Ae,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),le),LE=P(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),le),_E=P(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),le),zX=$e.memo(({theme:e})=>P(h("path",{d:"M6 10H34",stroke:Eo(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),DE=P(B("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"})]}),H),RE=P(B("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"})]}),H),NE=P(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"}),le),BE=P(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"}),le),FE=P(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"}),le),OE=P(B("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"})]}),le),zE=P(B("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"})]}),H),HE=$e.memo(({flip:e=!1})=>P(B("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",opacity:.3,strokeWidth:2,fill:"none",strokeLinecap:"round",children:[h("path",{d:"M7,11 H19"}),h("path",{d:"M25,6 L33,16 M33,6 L25,16"})]}),yt)),GE=$e.memo(({flip:e=!1})=>P(h("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M7,11 H33 M23,5 L33,11 L23,17"})}),yt)),UE=$e.memo(({flip:e=!1})=>P(B("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",children:[h("path",{d:"M7,11 H23",strokeWidth:2,strokeLinecap:"round"}),h("path",{d:"M23,5 L35,11 L23,17 Z"})]}),yt)),WE=$e.memo(({flip:e=!1})=>P(B("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",children:[h("path",{d:"M7,11 H23"}),h("path",{d:"M23,5 L35,11 L23,17 Z"})]}),yt)),YE=$e.memo(({flip:e=!1})=>P(B("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[h("path",{d:"M7,11 H25",strokeWidth:2,strokeLinecap:"round"}),h("circle",{cx:"29",cy:"11",r:"4"})]}),yt)),VE=$e.memo(({flip:e=!1})=>P(B("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[h("path",{d:"M7,11 H25",strokeLinecap:"round"}),h("circle",{cx:"29",cy:"11",r:"4"})]}),yt)),XE=$e.memo(({flip:e=!1})=>P(B("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",children:[h("path",{d:"M7,11 H21",strokeWidth:2,strokeLinecap:"round"}),h("path",{d:"M21,11 L28,5 L35,11 L28,17 Z"})]}),yt)),KE=$e.memo(({flip:e=!1})=>P(B("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,strokeLinecap:"round",children:[h("path",{d:"M7,11 H21"}),h("path",{d:"M21,11 L28,5 L35,11 L28,17 Z"})]}),yt)),ZE=$e.memo(({flip:e=!1})=>P(h("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",strokeLinecap:"round",children:h("path",{d:"M11,11 H31 M31,5 V17"})}),yt)),$E=$e.memo(({flip:e=!1})=>P(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M15,5 V17"})}),yt)),jE=$e.memo(({flip:e=!1})=>P(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M15,11 L7,5 M15,11 L7,17"})}),yt)),qE=$e.memo(({flip:e=!1})=>P(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M23,5 V17 M15,11 L7,5 M15,11 L7,17"})}),yt)),JE=$e.memo(({flip:e=!1})=>P(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M15,5 V17 M7,5 V17"})}),yt)),QE=$e.memo(({flip:e=!1})=>P(B("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M35,11 H19 M11,11 H7 M7,5 V17"}),h("circle",{cx:"15",cy:"11",r:"4"})]}),yt)),e0=$e.memo(({flip:e=!1})=>P(B("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M35,11 H27 M19,11 H7 M15,11 L7,5 M15,11 L7,17"}),h("circle",{cx:"23",cy:"11",r:"4"})]}),yt)),t0=P(B(Ae,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M14.167 6.667a3.333 3.333 0 0 0-3.334-3.334H9.167a3.333 3.333 0 0 0 0 6.667h1.666a3.333 3.333 0 0 1 0 6.667H9.167a3.333 3.333 0 0 1-3.334-3.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),o0=P(B(Ae,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),n0=P(B(Ae,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),r0=P(h(Ae,{children:h("path",{d:"m1.667 3.333 6.666 13.334M8.333 3.333 1.667 16.667M11.667 3.333v13.334h6.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),le),Tr=P(B("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"})]}),H),i0=P(h(Ae,{children:B("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"})]})}),H),ll=P(h(Ae,{children:h("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M5.833 16.667v-10a3.333 3.333 0 0 1 3.334-3.334h1.666a3.333 3.333 0 0 1 3.334 3.334v10M5.833 10.833h8.334"})})}),le),Hk=P(B("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 8l-4 4l4 4"}),h("path",{d:"M17 8l4 4l-4 4"}),h("path",{d:"M14 4l-4 16"})]}),H),Ec=Hk,a0=P(B("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"})]}),H),l0=P(B("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"})]}),H),s0=P(B("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"})]}),H),c0=$e.memo(({theme:e})=>P(B("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"})]}),H)),d0=$e.memo(({theme:e})=>P(B("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"})]}),H)),m0=$e.memo(({theme:e})=>P(B("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"})]}),H)),xc=P(B("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"})]}),H),p0=P(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}),HX=P(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"})),yc=P(B("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"})]}),H),Kp=P(B(Ae,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),h("path",{d:"M7 11l5 5l5 -5"}),h("path",{d:"M12 4l0 12"})]}),H),hi=P(B(Ae,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 8m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z"}),h("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),H),u0=P(B("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"})]}),H),h0=P(B(Ae,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),h("path",{d:"M12 17l0 .01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),H),GX=P(B(Ae,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),H),UX=P(B(Ae,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M17 4h-10a3 3 0 0 0 -3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3 -3v-10a3 3 0 0 0 -3 -3z",strokeWidth:"0",fill:"currentColor"})]}),H),g0=P(B(Ae,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),H),f0=P(B(Ae,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.24 3.957l-8.422 14.06a1.989 1.989 0 0 0 1.7 2.983h16.845a1.989 1.989 0 0 0 1.7 -2.983l-8.423 -14.06a1.989 1.989 0 0 0 -3.4 0z"}),h("path",{d:"M12 9v4"}),h("path",{d:"M12 17h.01"})]}),H),b0=P(B("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"})]}),H),gi=P(B("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"})]}),H),Dn=P(B("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"})]}),H),WX=P(B("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4"}),h("path",{d:"M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"})]}),H),YX=P(B("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 10l-2 1l8 4l8 -4l-2 -1"}),h("path",{d:"M4 15l8 4l8 -4"}),h("path",{d:"M12 4v7"}),h("path",{d:"M15 8l-3 3l-3 -3"})]}),H),VX=P(B("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"})]}),le),fi=P(B("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),E0=P(B("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"})]}),H),XX=P(B("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"})]}),H),KX=P(B("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"})]}),H),x0=P(B("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"})]}),H),Sr=P(B("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"})]}),H),y0=P(B("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"})]}),H),ZX=P(B("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"})]}),H),$X=P(B("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"})]}),H),Gt=P(B("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"})]}),H),w0=P(B("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"})]}),H),jX=P(B("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 8l0 4l2 2"}),h("path",{d:"M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5"})]}),H),v0=P(B("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"})]}),H),I0=P(B("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"})]}),H),sl=P(B("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"})]}),H),T0=P(B("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"})]}),H),S0=P(B("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"})]}),H),C0=P(B("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"})]}),H),k0=P(B("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"})]}),H),Zp=P(B("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"})]}),H),wc=P(B("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"})]}),H),P0=P(B("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"})]}),H),M0=P(B("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"})]}),H),A0=P(B("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"})]}),H),L0=P(B("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"})]}),H),_0=P(B("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"})]}),{...H,strokeWidth:1.5}),qX=P(B("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"})]}),H),JX=P(B("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"})]}),H),D0=P(B("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"})]}),H),R0=P(B("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"})]}),H),bi=P(B("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 18l12 -12"}),h("path",{d:"M18 10v-4h-4"})]}),H),Ei=P(B("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"})]}),H),xi=P(B("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),H),vc=P(B("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),H),N0=P(B("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),H),B0=P(B("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),H),$p=P(B("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"})]}),H),Ic=P(B("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"})]}),H),jp=P(B("g",{strokeWidth:"1.25",children:[h("rect",{x:"4",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"4",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"4",y:"16",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"16",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"16",width:"4",height:"4",rx:"1"})]}),H),qp=P(B("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:"7",y:"6",width:"10",height:"8",rx:"1",strokeDasharray:"2 2"}),h("line",{x1:"3",y1:"6",x2:"3",y2:"14"}),h("polyline",{points:"2 8 3 6 4 8"}),h("polyline",{points:"2 12 3 14 4 12"}),h("line",{x1:"7",y1:"18",x2:"17",y2:"18"}),h("polyline",{points:"9 17 7 18 9 19"}),h("polyline",{points:"15 17 17 18 15 19"})]}),H),QX=P(B("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"})]}),H),Jp=P(h("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:.5,viewBox:"0 0 640 512",children:h("path",{d:"M15 15C24.4 5.7 39.6 5.7 49 15l63 63L112 40c0-13.3 10.7-24 24-24s24 10.7 24 24l0 96c0 13.3-10.7 24-24 24l-96 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l38.1 0L15 49C5.7 39.6 5.7 24.4 15 15zM133.5 243.9C158.6 193.6 222.7 112 320 112s161.4 81.6 186.5 131.9c3.8 7.6 3.8 16.5 0 24.2C481.4 318.4 417.3 400 320 400s-161.4-81.6-186.5-131.9c-3.8-7.6-3.8-16.5 0-24.2zM320 320a64 64 0 1 0 0-128 64 64 0 1 0 0 128zM591 15c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-63 63 38.1 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-96 0c-13.3 0-24-10.7-24-24l0-96c0-13.3 10.7-24 24-24s24 10.7 24 24l0 38.1 63-63zM15 497c-9.4-9.4-9.4-24.6 0-33.9l63-63L40 400c-13.3 0-24-10.7-24-24s10.7-24 24-24l96 0c13.3 0 24 10.7 24 24l0 96c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-38.1L49 497c-9.4 9.4-24.6 9.4-33.9 0zm576 0l-63-63 0 38.1c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-96c0-13.3 10.7-24 24-24l96 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-38.1 0 63 63c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0z"})})),F0=P(B("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"})]}),H),O0=P(B("g",{strokeWidth:1,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 10l4 -4 L6 14l8 -8 L6 18l12 -12 L10 18l8 -8 L14 18l4 -4"})]}),H),Gk=P(B("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4"}),h("path",{d:"M13.5 6.5l4 4"})]}),H),eK=P(B("g",{strokeWidth:1,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M11 7l-5 5l5 5"}),h("path",{d:"M17 7l-5 5l5 5"})]}),H),z0=P(B("g",{strokeWidth:"1.75",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 4m0 2a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2z"}),h("path",{d:"M15 4l0 16"})]}),H),tK=P(B("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 20l1.3 -3.9c-2.324 -3.437 -1.426 -7.872 2.1 -10.374c3.526 -2.501 8.59 -2.296 11.845 .48c3.255 2.777 3.695 7.266 1.029 10.501c-2.666 3.235 -7.615 4.215 -11.574 2.293l-4.7 1"})]}),H),oK=P(B("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 4l18 0"}),h("path",{d:"M4 4v10a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-10"}),h("path",{d:"M12 16l0 4"}),h("path",{d:"M9 20l6 0"}),h("path",{d:"M8 12l3 -3l2 2l3 -3"})]}),H),Tc=h("div",{style:{width:"1rem",height:"1rem"}}),H0=P(B("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("polyline",{points:"9 6 15 12 9 18"})]}),H),G0=P(B("g",{strokeWidth:1.25,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"})]}),H);import U0 from"clsx";import eu,{useEffect as Yk,useRef as W0,useState as Vk}from"react";import{isPromiseLike as Xk}from"@excalidraw/common";import Uk from"react";import{jsx as Qp}from"react/jsx-runtime";var Wk=({size:e="1em",circleWidth:o=8,synchronized:t=!1,className:n=""})=>{let i=-(Uk.useRef(Date.now()).current%1600);return Qp("div",{className:`Spinner ${n}`,children:Qp("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:Qp("circle",{cx:"50",cy:"50",r:50-o/2,strokeWidth:o,fill:"none",strokeMiterlimit:"10"})})})},Ut=Wk;import{jsx as cl,jsxs as dl}from"react/jsx-runtime";var Z=eu.forwardRef(({size:e="medium",visible:o=!0,className:t="",...n},r)=>{let{id:i}=Ne(),a=eu.useRef(null);eu.useImperativeHandle(r,()=>a.current);let l=`ToolIcon_size_${e}`,[s,c]=Vk(!1),m=W0(!0),p=async u=>{let b="onClick"in n&&n.onClick?.(u);if(Xk(b))try{c(!0),await b}catch(g){if(g instanceof ii)console.warn(g);else throw g}finally{m.current&&c(!1)}};Yk(()=>(m.current=!0,()=>{m.current=!1}),[]);let d=W0(null);if(n.type==="button"||n.type==="icon"||n.type==="submit"){let u=n.type==="icon"?"button":n.type;return dl("button",{className:U0("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:p,ref:a,disabled:s||n.isLoading||!!n.disabled,children:[(n.icon||n.label)&&dl("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!n.disabled,children:[n.icon||n.label,n.keyBindingLabel&&cl("span",{className:"ToolIcon__keybinding",children:n.keyBindingLabel}),n.isLoading&&cl(Ut,{})]}),n.showAriaLabel&&dl("div",{className:"ToolIcon__label",children:[n["aria-label"]," ",s&&cl(Ut,{})]}),n.children]})}return dl("label",{className:U0("ToolIcon",t),title:n.title,onPointerDown:u=>{d.current=u.pointerType||null,n.onPointerDown?.({pointerType:u.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{d.current=null})},children:[cl("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:d.current})},checked:n.checked,ref:a}),dl("div",{className:"ToolIcon__icon",children:[n.icon,n.keyBindingLabel&&cl("span",{className:"ToolIcon__keybinding",children:n.keyBindingLabel})]})]})});Z.displayName="ToolButton";var Sc=[],F=e=>(Sc=Sc.concat(e),e);import{jsx as tP}from"react/jsx-runtime";var eP=(e,o,t)=>{let n=new Set(ee(e.filter(m=>qk(m)),o).map(m=>m.id)),r={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let m of n){let p=Jk(e,m);for(let d of p)if(!a.has(d.id)){if(Cc(d)){let u=V0(d,i);u&&(r[u.id]=!0)}else r[d.id]=!0;a.add(d.id)}}let l=!0,s=e.map(m=>{if(o.selectedElementIds[m.id]){let p=Cc(m)?V0(m,i):null;return m.frameId&&n.has(m.frameId)?(l=!1,r[m.id]=!0,m):p?.frameId&&n.has(p?.frameId)?m:(m.boundElements&&m.boundElements.forEach(d=>{let u=t.scene.getNonDeletedElementsMap().get(d.id);u&&jk(u)&&t.scene.mutateElement(u,{startBinding:m.id===u.startBinding?.elementId?null:u.startBinding,endBinding:m.id===u.endBinding?.elementId?null:u.endBinding})}),Pc(m,{isDeleted:!0}))}return m.frameId&&n.has(m.frameId)?(l=!1,Cc(m)||(r[m.id]=!0),Pc(m,{frameId:null})):Cc(m)&&o.selectedElementIds[m.containerId]?Pc(m,{isDeleted:!0}):m}),c=o.editingGroupId;if(l&&o.editingGroupId){let m=nu(s,o.editingGroupId).filter(p=>!p.isDeleted);if(m.length>1)m[0]&&(r[m[0].id]=!0);else{c=null,m[0]&&(r[m[0].id]=!0);let p=m[0];if(p){let d=p.groupIds.findIndex(b=>b===o.editingGroupId),u=p.groupIds[d+1];if(u){let b=nu(s,u).filter(g=>!g.isDeleted);b.length>1&&(c=u,b.forEach(g=>{r[g.id]=!0}))}}}}return{elements:s,appState:{...o,...Qk({selectedElementIds:r,editingGroupId:c},s,o,null)}}},X0=(e,o)=>{if(e.editingGroupId){let t=nu(ou(o),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},ml=F({name:"deleteSelectedElements",label:"labels.delete",icon:ln,trackEvent:{category:"element",action:"delete"},perform:(e,o,t,n)=>{if(o.selectedLinearElement?.isEditing){let{elementId:a,selectedPointsIndices:l}=o.selectedLinearElement,s=n.scene.getNonDeletedElementsMap(),c=Y0.getElement(a,s);if(!c||l==null)return!1;if(l.length>=c.points.length){let m=e.map(d=>d.id===c.id?Pc(d,{isDeleted:!0}):d),p=X0(o,m);return{elements:m,appState:{...p,selectedLinearElement:null},captureUpdate:kc.IMMEDIATELY}}return Y0.deletePoints(c,n,l),{elements:e,appState:{...o,selectedLinearElement:{...o.selectedLinearElement,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},captureUpdate:kc.IMMEDIATELY}}let{elements:r,appState:i}=eP(e,o,n);return $k(r,r.filter(a=>a.isDeleted)),i=X0(i,r),{elements:r,appState:{...i,activeTool:Zk(o,{type:n.state.preferredSelectionTool.type}),multiElement:null,newElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Pe(ou(e),o)?kc.IMMEDIATELY:kc.EVENTUALLY}},keyTest:(e,o,t)=>(e.key===tu.BACKSPACE||e.key===tu.DELETE)&&!e[tu.CTRL_OR_CMD],PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=nt()==="mobile";return tP(Z,{type:"button",icon:ln,title:f("labels.delete"),"aria-label":f("labels.delete"),onClick:()=>t(null),disabled:!Pe(ou(e),o),style:{...r&&o.openPopup!=="compactOtherProperties"?Kk:{}}})}});import{KEYS as yi,CODES as wi,isDarwin as Mc}from"@excalidraw/common";import{moveOneLeft as oP,moveOneRight as nP,moveAllLeft as rP,moveAllRight as iP}from"@excalidraw/element";import{CaptureUpdateAction as Ac}from"@excalidraw/element";import{isDarwin as K0}from"@excalidraw/common";var N=e=>e.replace(/\b(Opt(?:ion)?|Alt)\b/i,K0?f("keys.option"):f("keys.alt")).replace(/\bShift\b/i,f("keys.shift")).replace(/\b(Enter|Return)\b/i,f("keys.enter")).replace(/\b(Ctrl|Cmd|Command|CtrlOrCmd)\b/gi,K0?f("keys.cmd"):f("keys.ctrl")).replace(/\b(Esc(?:ape)?)\b/i,f("keys.escape")).replace(/\b(Space(?:bar)?)\b/i,f("keys.spacebar")).replace(/\b(Del(?:ete)?)\b/i,f("keys.delete"));import{jsx as Lc}from"react/jsx-runtime";var ru=F({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:Np,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:oP(e,o,n.scene),appState:o,captureUpdate:Ac.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[yi.CTRL_OR_CMD]&&!e.shiftKey&&e.code===wi.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>Lc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendBackward")} \u2014 ${N("CtrlOrCmd+[")}`,children:Np})}),iu=F({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:Rp,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:nP(e,o,n.scene),appState:o,captureUpdate:Ac.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[yi.CTRL_OR_CMD]&&!e.shiftKey&&e.code===wi.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>Lc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.bringForward")} \u2014 ${N("CtrlOrCmd+]")}`,children:Rp})}),au=F({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:Fp,trackEvent:{category:"element"},perform:(e,o)=>({elements:rP(e,o),appState:o,captureUpdate:Ac.IMMEDIATELY}),keyTest:e=>Mc?e[yi.CTRL_OR_CMD]&&e.altKey&&e.code===wi.BRACKET_LEFT:e[yi.CTRL_OR_CMD]&&e.shiftKey&&e.code===wi.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>Lc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendToBack")} \u2014 ${Mc?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")}`,children:Fp})}),lu=F({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:Bp,trackEvent:{category:"element"},perform:(e,o)=>({elements:iP(e,o),appState:o,captureUpdate:Ac.IMMEDIATELY}),keyTest:e=>Mc?e[yi.CTRL_OR_CMD]&&e.altKey&&e.code===wi.BRACKET_RIGHT:e[yi.CTRL_OR_CMD]&&e.shiftKey&&e.code===wi.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>Lc("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${f("labels.bringToFront")} \u2014 ${Mc?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")}`,children:Bp})});import{getNonDeletedElements as aP}from"@excalidraw/element";import{LinearElementEditor as lP}from"@excalidraw/element/linearElementEditor";import{isLinearElement as sP,isTextElement as cP}from"@excalidraw/element";import{arrayToMap as dP,KEYS as Z0}from"@excalidraw/common";import{selectGroupsForSelectedElements as mP}from"@excalidraw/element";import{CaptureUpdateAction as pP}from"@excalidraw/element";var su=F({name:"selectAll",label:"labels.selectAll",icon:T0,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,o,t,n)=>{if(o.selectedLinearElement?.isEditing)return!1;let r=e.filter(i=>!i.isDeleted&&!(cP(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...o,...mP({editingGroupId:null,selectedElementIds:r},aP(e),o,n),selectedLinearElement:Object.keys(r).length===1&&sP(e[0])?new lP(e[0],dP(e)):null},captureUpdate:pP.IMMEDIATELY}},keyTest:e=>e[Z0.CTRL_OR_CMD]&&e.key===Z0.A});import{DEFAULT_GRID_SIZE as $0,KEYS as j0,MOBILE_ACTION_BUTTON_BG as uP,arrayToMap as q0}from"@excalidraw/common";import{getNonDeletedElements as J0}from"@excalidraw/element";import{LinearElementEditor as hP}from"@excalidraw/element/linearElementEditor";import{getSelectedElements as gP,getSelectionStateForElements as fP}from"@excalidraw/element";import{syncMovedIndices as bP}from"@excalidraw/element";import{duplicateElements as EP}from"@excalidraw/element";import{CaptureUpdateAction as Q0}from"@excalidraw/element";import{jsx as xP}from"react/jsx-runtime";var cu=F({name:"duplicateSelection",label:"labels.duplicateSelection",icon:nl,trackEvent:{category:"element"},perform:(e,o,t,n)=>{if(o.selectedElementsAreBeingDragged)return!1;if(o.selectedLinearElement?.isEditing)try{let a=hP.duplicateSelectedPoints(o,n.scene);return{elements:e,appState:a,captureUpdate:Q0.IMMEDIATELY}}catch{return!1}let{duplicatedElements:r,elementsWithDuplicates:i}=EP({type:"in-place",elements:e,idsOfElementsToDuplicate:q0(gP(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+$0/2,y:a.y+$0/2,frameId:s??a.frameId}}});if(n.props.onDuplicate&&i){let a=n.props.onDuplicate(i,e);a&&(i=a)}return{elements:bP(i,q0(r)),appState:{...o,...fP(r,J0(i),o)},captureUpdate:Q0.IMMEDIATELY}},keyTest:e=>e[j0.CTRL_OR_CMD]&&e.key===j0.D,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=nt()==="mobile";return xP(Z,{type:"button",icon:nl,title:`${f("labels.duplicateSelection")} \u2014 ${N("CtrlOrCmd+D")}`,"aria-label":f("labels.duplicateSelection"),onClick:()=>t(null),disabled:!Pe(J0(e),o),style:{...r&&o.openPopup!=="compactOtherProperties"?uP:{}}})}});import{pointFrom as SM}from"@excalidraw/math";import{useEffect as Lu,useMemo as Nu,useRef as _u,useState as CM}from"react";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as kM,DEFAULT_ELEMENT_BACKGROUND_PICKS as PM,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as MM,DEFAULT_ELEMENT_STROKE_PICKS as AM,ARROW_TYPE as ro,DEFAULT_FONT_FAMILY as LM,DEFAULT_FONT_SIZE as _M,FONT_FAMILY as DM,ROUNDNESS as $c,STROKE_WIDTH as Du,VERTICAL_ALIGN as Kc,KEYS as Ai,randomInteger as RM,arrayToMap as Bu,getFontFamilyString as NM,getLineHeight as BM,isTransparent as FM,reduceToCommonValue as OM,invariant as Fu,FONT_SIZES as Zc}from"@excalidraw/common";import{canBecomePolygon as zM,getNonDeletedElements as Xx}from"@excalidraw/element";import{bindBindingElement as Gx,calculateFixedPointForElbowArrowBinding as Ux,updateBoundElements as HM}from"@excalidraw/element";import{LinearElementEditor as kr}from"@excalidraw/element/linearElementEditor";import{newElementWith as Qe}from"@excalidraw/element";import{getArrowheadForPicker as Wx}from"@excalidraw/element";import{getBoundTextElement as Yn,redrawTextBoundingBox as vl}from"@excalidraw/element";import{isArrowElement as jc,isBoundToContainer as GM,isElbowArrow as Kx,isLinearElement as Ru,isLineElement as Yx,isTextElement as Lt,isUsingAdaptiveRadius as UM}from"@excalidraw/element";import{hasStrokeColor as WM}from"@excalidraw/element";import{updateElbowArrowPoints as YM,CaptureUpdateAction as et,toggleLinePolygonState as VM}from"@excalidraw/element";import{deriveStylesPanelMode as XM}from"@excalidraw/common";import{isDevEnv as yP}from"@excalidraw/common";var wP=new Set(["command_palette","export"]),ce=(e,o,t,n)=>{try{if(typeof window>"u"||T.VITE_WORKER_ID||T.VITE_APP_ENABLE_TRACKING!=="true"||!wP.has(e)||yP())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 SP from"clsx";import vP from"clsx";import{forwardRef as IP}from"react";import{jsx as TP}from"react/jsx-runtime";var vi=IP((e,o)=>{let{title:t,className:n,testId:r,active:i,standalone:a,icon:l,onClick:s}=e;return TP("button",{type:"button",ref:o,title:t,"data-testid":r,className:vP(n,{standalone:a,active:i}),onClick:s,style:e.style,children:l},t)});import{Fragment as kP,jsx as du,jsxs as CP}from"react/jsx-runtime";var eo=e=>du(kP,{children:e.options.map(o=>e.type==="button"?du(vi,{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):CP("label",{className:SP({active:e.value===o.value}),title:o.text,children:[du("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{Popover as xx}from"radix-ui";import yx from"clsx";import{useRef as wx,useEffect as M4}from"react";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as bx,COLOR_PALETTE as vx,isColorDark as Ex,isWritableElement as A4}from"@excalidraw/common";import{jsx as PP}from"react/jsx-runtime";var _c=()=>PP("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as DP,useRef as RP}from"react";import{createPortal as NP}from"react-dom";import{EVENT as Nn,KEYS as BP,rgbToHex as FP}from"@excalidraw/common";import ex from"react";var mu=ex.createContext(null),de=()=>ex.useContext(mu);import{useState as MP,useLayoutEffect as tx}from"react";import{THEME as AP}from"@excalidraw/common";var Dc=e=>{let[o,t]=MP(null),n=pe(),{theme:r}=de(),{container:i}=Ne();return tx(()=>{o&&(o.className="",o.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),o.classList.toggle("excalidraw--mobile",n.formFactor==="phone"),o.classList.toggle("theme--dark",r===AP.DARK))},[o,r,n.formFactor,e?.className]),tx(()=>{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 LP}from"react";import{EVENT as Rc}from"@excalidraw/common";function Ii(e,o,t){LP(()=>{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(Rc.POINTER_DOWN,n),document.addEventListener(Rc.TOUCH_START,n),()=>{document.removeEventListener(Rc.POINTER_DOWN,n),document.removeEventListener(Rc.TOUCH_START,n)}},[e,o,t])}import{useRef as _P}from"react";var Rn=e=>{let o=_P(e);return Object.assign(o.current,e),o.current};import{jsx as OP}from"react/jsx-runtime";var Bn=_e(null),ox=({onCancel:e,onChange:o,onSelect:t,colorPickerType:n})=>{let r=Dc({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=de(),a=Fn(),l=je(),s=ee(a,i),c=Rn({app:l,onCancel:e,onChange:o,onSelect:t,selectedElements:s}),{container:m}=Ne();DP(()=>{let d=p.current;if(!d||!l.canvas||!r)return;let u=!1,b=l.canvas.getContext("2d"),g=({clientX:C,clientY:A})=>{let k=b.getImageData((C-i.offsetLeft)*window.devicePixelRatio,(A-i.offsetTop)*window.devicePixelRatio,1,1).data;return FP(k[0],k[1],k[2])},E=({clientX:C,clientY:A,altKey:k})=>{d.style.top=`${A+20}px`,d.style.left=`${C+20}px`;let L=g({clientX:C,clientY:A});u&&c.onChange(n,L,c.selectedElements,{altKey:k}),d.style.background=L},y=()=>{c.onCancel()},v=(C,A)=>{c.onSelect(C,A)},x=C=>{u=!0,C.stopImmediatePropagation()},w=C=>{u=!1,m?.focus(),C.stopImmediatePropagation(),C.preventDefault(),v(g(C),C)},I=C=>{C.key===BP.ESCAPE&&(C.preventDefault(),C.stopImmediatePropagation(),y())};return r.tabIndex=-1,r.focus(),E({clientX:c.app.lastViewportPosition.x,clientY:c.app.lastViewportPosition.y,altKey:!1}),r.addEventListener(Nn.KEYDOWN,I),r.addEventListener(Nn.POINTER_DOWN,x),r.addEventListener(Nn.POINTER_UP,w),window.addEventListener("pointermove",E,{passive:!0}),window.addEventListener(Nn.BLUR,y),()=>{u=!1,r.removeEventListener(Nn.KEYDOWN,I),r.removeEventListener(Nn.POINTER_DOWN,x),r.removeEventListener(Nn.POINTER_UP,w),window.removeEventListener("pointermove",E),window.removeEventListener(Nn.BLUR,y)}},[c,l.canvas,r,n,m,i.offsetLeft,i.offsetTop]);let p=RP(null);return Ii(p,()=>{e()},d=>!!d.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),r?NP(OP("div",{ref:p,className:"excalidraw-eye-dropper-preview"}),r):null};import{Popover as pu}from"radix-ui";import UP from"clsx";import WP from"react";import{isInteractive as YP}from"@excalidraw/common";import zP from"react";import HP from"clsx";import{jsx as GP}from"react/jsx-runtime";var We=zP.forwardRef(({children:e,padding:o,className:t,style:n},r)=>GP("div",{className:HP("Island",t),style:{"--padding":o,...n},ref:r,children:e}));import{jsx as uu,jsxs as VP}from"react/jsx-runtime";var sn=WP.forwardRef(({className:e,container:o,children:t,style:n,onClose:r,onKeyDown:i,onFocusOutside:a,onPointerLeave:l,onPointerDownOutside:s,preventAutoFocusOnTouch:c=!1},m)=>{let p=pe(),d=p.formFactor==="phone"&&!p.isLandscape;return uu(pu.Portal,{container:o,children:VP(pu.Content,{ref:m,className:UP("focus-visible-none",e),"data-prevent-outside-click":!0,side:d?"bottom":"right",align:d?"center":"start",alignOffset:-16,sideOffset:20,collisionBoundary:o??void 0,style:{zIndex:"var(--zIndex-ui-styles-popup)",marginLeft:p.formFactor==="phone"?"0.5rem":void 0},onPointerLeave:l,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:s,onOpenAutoFocus:u=>{c&&p.isTouchScreen&&u.preventDefault()},onCloseAutoFocus:u=>{u.stopPropagation(),u.preventDefault(),o&&!YP(document.activeElement)&&o.focus(),r()},children:[uu(We,{padding:3,style:n,children:t}),uu(pu.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 XP,useCallback as hu}from"react";var Nc=()=>document.querySelector(".excalidraw-wysiwyg"),Bc=()=>{let e=Nc();return e?{start:e.selectionStart,end:e.selectionEnd}:null},pl=e=>{setTimeout(()=>{let o=Nc();o&&(o.focus(),e&&(o.selectionStart=e.start,o.selectionEnd=e.end))},0)},ul=(e,o,t,n)=>{o&&n&&n();let r=o&&t?Bc():null;e(),o&&t&&pl(r)},nx=()=>{let[e,o]=XP(null),t=hu(()=>{let i=Bc();o(i)},[]),n=hu(()=>{setTimeout(()=>{let i=Nc();i&&(i.focus(),e&&(i.selectionStart=e.start,i.selectionEnd=e.end,o(null)))},0)},[e]),r=hu(()=>{o(null)},[]);return{saveCaretPosition:t,restoreCaretPosition:n,clearSavedPosition:r,hasSavedPosition:!!e}},rx=(e=100)=>{let o=Nc();if(o){let t=o.onblur;o.onblur=null,setTimeout(()=>{o.onblur=t},e)}};import ZP from"clsx";import{useCallback as $P,useEffect as fu,useRef as ax,useState as jP}from"react";import{KEYS as bu,normalizeInputColor as qP}from"@excalidraw/common";import{MAX_CUSTOM_COLORS_USED_IN_CANVAS as KP}from"@excalidraw/common";var On=({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},hl=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),gu=({color:e,palette:o})=>!Object.values(o).flat().includes(e),ix=(e,o,t)=>{let n={elementBackground:"backgroundColor",elementStroke:"strokeColor"},r=e.filter(a=>{if(a.isDeleted)return!1;let l=a[n[o]];return gu({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,KP)},to=_e(null);import{Fragment as JP,jsx as Fc,jsxs as lx}from"react/jsx-runtime";var sx=({color:e,onChange:o,label:t,colorPickerType:n,placeholder:r})=>{let i=pe(),[a,l]=jP(e),[s,c]=fe(to);fu(()=>{l(e)},[e]);let m=$P(g=>{let E=g.toLowerCase(),y=qP(E);y&&o(y),l(E)},[o]),p=ax(null),d=ax(null);fu(()=>{p.current&&p.current.focus()},[s]);let[u,b]=fe(Bn);return fu(()=>()=>{b(null)},[b]),lx("div",{className:"color-picker__input-label",children:[Fc("div",{className:"color-picker__input-hash",children:"#"}),Fc("input",{ref:s==="hex"?p:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,onChange:g=>{m(g.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{l(e)},tabIndex:-1,onFocus:()=>c("hex"),onKeyDown:g=>{g.key!==bu.TAB&&(g.key===bu.ESCAPE&&d.current?.focus(),g.stopPropagation())},placeholder:r}),i.formFactor!=="phone"&&lx(JP,{children:[Fc("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),Fc("div",{ref:d,className:ZP("excalidraw-eye-dropper-trigger",{selected:u}),onClick:()=>b(g=>g?null:{keepOpenOnAlt:!1,onSelect:E=>o(E),colorPickerType:n}),title:`${f("labels.eyeDropper")} \u2014 ${bu.I.toLocaleUpperCase()} or ${N("Alt")} `,children:b0})]})]})};import wu,{useEffect as vu,useImperativeHandle as E4,useState as x4}from"react";import{EVENT as hx}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as y4,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as w4,KEYS as v4}from"@excalidraw/common";import o4 from"clsx";import{useEffect as n4,useRef as r4}from"react";import{isColorDark as QP}from"@excalidraw/common";import{jsxs as t4}from"react/jsx-runtime";var e4=({color:e,keyLabel:o,isShade:t=!1})=>t4("div",{className:"color-picker__button__hotkey-label",style:{color:QP(e)?"#fff":"#000"},children:[t&&"\u21E7",o]}),Ti=e4;import{jsx as Eu,jsxs as i4}from"react/jsx-runtime";var cx=({colors:e,color:o,onChange:t,label:n})=>{let[r,i]=fe(to),a=r4(null);return n4(()=>{a.current&&a.current.focus()},[o,r]),Eu("div",{className:"color-picker-content--default",children:e.map((l,s)=>i4("button",{ref:o===l?a:void 0,tabIndex:-1,type:"button",className:o4("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:[Eu("div",{className:"color-picker__button-outline"}),Eu(Ti,{color:l,keyLabel:s+1})]},s))})};import a4 from"clsx";import{useEffect as l4,useRef as s4}from"react";import{jsx as xu,jsxs as d4}from"react/jsx-runtime";var c4=({palette:e,color:o,onChange:t,activeShade:n,showHotKey:r=!0})=>{let i=On({color:o,palette:e}),[a,l]=fe(to),s=s4(null);return l4(()=>{s.current&&a==="baseColors"&&s.current.focus()},[i?.colorName,a]),xu("div",{className:"color-picker-content--default",children:Object.entries(e).map(([c,m],p)=>{let d=(Array.isArray(m)?m[n]:m)||"transparent",u=hl[p],b=f(`colors.${c.replace(/\d+/,"")}`,null,"");return d4("button",{ref:i?.colorName===c?s:void 0,tabIndex:-1,type:"button",className:a4("color-picker__button color-picker__button--large has-outline",{active:i?.colorName===c,"is-transparent":d==="transparent"||!d}),onClick:()=>{t(d),l("baseColors")},title:`${b}${d.startsWith("#")?` ${d}`:""} \u2014 ${u}`,"aria-label":`${b} \u2014 ${u}`,style:d?{"--swatch-color":d}:void 0,"data-testid":`color-${c}`,children:[xu("div",{className:"color-picker__button-outline"}),r&&xu(Ti,{color:d,keyLabel:u})]},c)})})},dx=c4;import{jsx as p4}from"react/jsx-runtime";var m4=({children:e})=>p4("div",{className:"color-picker__heading",children:e}),Si=m4;import u4 from"clsx";import{useEffect as h4,useRef as g4}from"react";import{jsx as gl,jsxs as mx}from"react/jsx-runtime";var px=({color:e,onChange:o,palette:t,showHotKey:n})=>{let r=On({color:e||"transparent",palette:t}),[i,a]=fe(to),l=g4(null);if(h4(()=>{l.current&&i==="shades"&&l.current.focus()},[r,i]),r){let{colorName:s,shade:c}=r,m=t[s];if(Array.isArray(m))return gl("div",{className:"color-picker-content--default shades",children:m.map((p,d)=>mx("button",{ref:d===c&&i==="shades"?l:void 0,tabIndex:-1,type:"button",className:u4("color-picker__button color-picker__button--large has-outline",{active:d===c}),"aria-label":"Shade",title:`${s} - ${d+1}`,style:p?{"--swatch-color":p}:void 0,onClick:()=>{o(p),a("shades")},children:[gl("div",{className:"color-picker__button-outline"}),n&&gl(Ti,{color:p,keyLabel:d+1,isShade:!0})]},d))})}return mx("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[gl("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),gl("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")})]})};import{COLORS_PER_ROW as Ci,COLOR_PALETTE as f4,KEYS as fl}from"@excalidraw/common";var yu=(e,o,t)=>{let n=Math.ceil(t/Ci);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+Ci;return r>=t?o%Ci:r}case"ArrowUp":{let r=o-Ci,i=r<0?Ci*n+r:r;return i>=t?void 0:i}}},b4=({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(hl.includes(e.key)){let l=hl.indexOf(e.key),s=Object.keys(n)[l],c=n[s],m=Array.isArray(c)?c[a]:c;return t(m),i("baseColors"),!0}return!1},ux=({event:e,activeColorPickerSection:o,palette:t,color:n,onChange:r,customColors:i,setActiveColorPickerSection:a,updateData:l,activeShade:s,onEyeDropperToggle:c,onEscape:m})=>{if(e[fl.CTRL_OR_CMD])return!1;if(e.key===fl.ESCAPE)return m(e),!0;if(e.key===fl.ALT)return c(!0),!0;if(e.key===fl.I)return c(),!0;let p=On({color:n,palette:t});if(e.key===fl.TAB){let d={custom:!!i.length,baseColors:!0,shades:p?.shade!=null,hex:!0},u=Object.entries(d).reduce((v,[x,w])=>(w&&v.push(x),v),[]),b=u.indexOf(o),g=e.shiftKey?-1:1,E=b+g>u.length-1?0:b+g<0?u.length-1:b+g,y=u[E];return y&&a(y),y==="custom"?r(i[0]):y==="baseColors"&&(Object.entries(t).find(([x,w])=>Array.isArray(w)?w.includes(n):w===n?x:null)||r(f4.black)),e.preventDefault(),e.stopPropagation(),!0}if(b4({e,colorObj:p,onChange:r,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:s}))return!0;if(o==="shades"&&p){let{shade:d}=p,u=yu(e.key,d,Ci);if(u!==void 0)return r(t[p.colorName][u]),!0}if(o==="baseColors"&&p){let{colorName:d}=p,u=Object.keys(t),b=u.indexOf(d),g=yu(e.key,b,u.length);if(g!==void 0){let E=u[g],y=t[E];return r(Array.isArray(y)?y[s]:y),!0}}if(o==="custom"){let d=n!=null?i.indexOf(n):0,u=yu(e.key,d,i.length);if(u!==void 0){let b=i[u];return r(b),!0}}return!1};import{jsx as zn,jsxs as Oc}from"react/jsx-runtime";var gx=wu.forwardRef(({color:e,onChange:o,type:t,elements:n,palette:r,updateData:i,children:a,showTitle:l,onEyeDropperToggle:s,onEscape:c,showHotKey:m=!0},p)=>{let d=l?t==="elementStroke"?f("labels.stroke"):t==="elementBackground"?f("labels.background"):null:null,[u]=wu.useState(()=>t==="canvasBackground"?[]:ix(n,t,r)),[b,g]=fe(to),E=On({color:e,palette:r});vu(()=>{if(!b){let w=!!e&&gu({color:e,palette:r}),I=w&&!u.includes(e);g(I?null:w?"custom":E?.shade!=null?"shades":"baseColors")}},[b,e,r,g,E,u]);let[y,v]=x4(E?.shade??(t==="elementBackground"?y4:w4));vu(()=>{E?.shade!=null&&v(E.shade);let w=I=>{I.key===v4.ALT&&s(!1)};return document.addEventListener(hx.KEYUP,w,{capture:!0}),()=>{document.removeEventListener(hx.KEYUP,w,{capture:!0})}},[E,s]);let x=wu.useRef(null);return E4(p,()=>x.current),vu(()=>{x?.current?.focus()},[]),zn("div",{role:"dialog","aria-modal":"true","aria-label":f("labels.colorPicker"),children:Oc("div",{ref:x,onKeyDown:w=>{ux({event:w,activeColorPickerSection:b,palette:r,color:e,onChange:o,onEyeDropperToggle:s,customColors:u,setActiveColorPickerSection:g,updateData:i,activeShade:y,onEscape:c})&&(w.preventDefault(),w.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[d&&zn("div",{className:"color-picker__title",children:d}),!!u.length&&Oc("div",{children:[zn(Si,{children:f("colorPicker.mostUsedCustomColors")}),zn(cx,{colors:u,color:e,label:f("colorPicker.mostUsedCustomColors"),onChange:o})]}),Oc("div",{children:[zn(Si,{children:f("colorPicker.colors")}),zn(dx,{color:e,palette:r,onChange:o,activeShade:y,showHotKey:m})]}),Oc("div",{children:[zn(Si,{children:f("colorPicker.shades")}),zn(px,{color:e,onChange:o,palette:r,showHotKey:m})]}),a]})})});import I4 from"clsx";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as T4,DEFAULT_CANVAS_BACKGROUND_PICKS as S4,DEFAULT_ELEMENT_BACKGROUND_PICKS as C4,DEFAULT_ELEMENT_STROKE_PICKS as k4,isColorDark as P4}from"@excalidraw/common";import{jsx as Iu}from"react/jsx-runtime";var fx=({onChange:e,type:o,activeColor:t,topPicks:n})=>{let r;return o==="elementStroke"&&(r=k4),o==="elementBackground"&&(r=C4),o==="canvasBackground"&&(r=S4),n&&(r=n),r?Iu("div",{className:"color-picker__top-picks",children:r.map(i=>Iu("button",{className:I4("color-picker__button",{active:i===t,"is-transparent":i==="transparent"||!i,"has-outline":!P4(i,T4)}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:Iu("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};import{jsx as oo,jsxs as zc}from"react/jsx-runtime";var L4=({type:e,color:o,onChange:t,label:n,elements:r,palette:i=vx,updateData:a,getOpenPopup:l,appState:s})=>{let{container:c}=Ne(),m=nt(),p=m!=="full",d=m==="mobile",[,u]=fe(to),[b,g]=fe(Bn),E=zc("div",{children:[oo(Si,{children:f("colorPicker.hexCode")}),oo(sx,{color:o||"",label:n,onChange:x=>{t(x)},colorPickerType:e,placeholder:f("colorPicker.color")})]}),y=wx(null),v=()=>{y.current?.focus()};return oo(sn,{container:c,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!s.editingTextElement,onFocusOutside:x=>{A4(x.target)||v(),x.preventDefault()},onPointerDownOutside:x=>{b&&x.preventDefault()},onClose:()=>{l()===e&&a({openPopup:null}),u(null),s.editingTextElement&&setTimeout(()=>{let x=document.querySelector(".excalidraw-wysiwyg");x&&x.focus()},0)},children:i?oo(gx,{ref:y,palette:i,color:o,onChange:x=>{let w=s.editingTextElement?Bc():null;t(x),s.editingTextElement&&w&&pl(w)},onEyeDropperToggle:x=>{g(w=>x?(w=w||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},w.keepOpenOnAlt=!0,w):x===!1||w?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:x=>{b?g(null):a({openPopup:null})},type:e,elements:r,updateData:a,showTitle:p,showHotKey:!d,children:E}):E})},_4=({label:e,color:o,type:t,mode:n="background",onToggle:r,editingTextElement:i})=>{let a=nt(),l=a!=="full",s=a==="mobile",c=m=>{m.preventDefault(),m.stopPropagation(),i&&rx(),r()};return zc(xx.Trigger,{type:"button",className:yx("color-picker__button active-color properties-trigger",{"is-transparent":!o||o==="transparent","has-outline":!o||!Ex(o,bx),"compact-sizing":l,"mobile-border":s}),"aria-label":e,style:o?{"--swatch-color":o}:void 0,title:t==="elementStroke"?f("labels.showStroke"):f("labels.showBackground"),"data-openpopup":t,onClick:c,children:[oo("div",{className:"color-picker__button-outline",children:!o&&EE}),l&&o&&n==="stroke"&&oo("div",{className:"color-picker__button-background",children:oo("span",{style:{color:o&&Ex(o,bx)?"#fff":"#111"},children:O0})})]})},bl=({type:e,color:o,onChange:t,label:n,elements:r,palette:i=vx,topPicks:a,updateData:l,appState:s})=>{let c=wx(s.openPopup);M4(()=>{c.current=s.openPopup},[s.openPopup]);let p=nt()!=="full";return oo("div",{children:zc("div",{role:"dialog","aria-modal":"true",className:yx("color-picker-container",{"color-picker-container--no-top-picks":p}),children:[!p&&oo(fx,{activeColor:o,onChange:t,type:e,topPicks:a}),!p&&oo(_c,{}),zc(xx.Root,{open:s.openPopup===e,onOpenChange:d=>{d&&l({openPopup:e})},children:[oo(_4,{color:o,label:n,type:e,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&&oo(L4,{type:e,color:o,onChange:t,label:n,elements:r,palette:i,updateData:l,getOpenPopup:()=>c.current,appState:s})]})]})})};import{Popover as aM}from"radix-ui";import lM from"clsx";import sM,{useCallback as cM,useMemo as dM}from"react";import{FONT_FAMILY as ku}from"@excalidraw/common";import j4,{useMemo as Un,useState as q4,useRef as Cx,useEffect as kx,useCallback as Px}from"react";import{arrayToList as J4,debounce as Q4,FONT_FAMILY as Wn,getFontFamilyString as eM}from"@excalidraw/common";import D4 from"clsx";import R4 from"react";import{jsx as N4,jsxs as B4}from"react/jsx-runtime";var Hc=R4.forwardRef(({className:e,placeholder:o,onChange:t},n)=>B4("div",{className:D4("QuickSearch__wrapper",e),children:[Gt,N4("input",{ref:n,className:"QuickSearch__input",type:"text",placeholder:o,onChange:r=>t(r.target.value.trim().toLowerCase())})]}));import F4 from"clsx";import{Children as O4}from"react";import{jsx as Ix}from"react/jsx-runtime";var Gc=({className:e,placeholder:o,children:t})=>{let n=!O4.count(t);return Ix("div",{className:F4("ScrollableList__wrapper",e),role:"menu",children:n?Ix("div",{className:"empty",children:o}):t})};import{jsx as z4,jsxs as H4}from"react/jsx-runtime";var Tx=({children:e,className:o="",style:t,title:n})=>H4("div",{className:`dropdown-menu-group ${o}`,style:t,children:[n&&z4("p",{className:"dropdown-menu-group-title",children:n}),e]}),El=Tx;Tx.displayName="DropdownMenuGroup";import{THEME as Z4}from"@excalidraw/common";import{DropdownMenu as $4}from"radix-ui";import G4,{useContext as U4}from"react";import{composeEventHandlers as W4}from"@excalidraw/common";var Tu=G4.createContext({}),Hn=(e="",o=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${o?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),Uc=e=>{let o=U4(Tu);return W4(e,t=>{o.onSelect?.(t)})};import{jsx as Y4}from"react/jsx-runtime";var Cr=({children:e,...o})=>Y4("span",{...o,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...o.style},children:e});import{Fragment as X4,jsx as xl,jsxs as K4}from"react/jsx-runtime";var V4=({textStyle:e,icon:o,shortcut:t,children:n,badge:r})=>{let i=pe();return K4(X4,{children:[o&&xl("div",{className:"dropdown-menu-item__icon",children:o}),xl("div",{style:e,className:"dropdown-menu-item__text",children:xl(Cr,{children:n})}),r&&xl("div",{className:"dropdown-menu-item__badge",children:r}),t&&i.formFactor!=="phone"&&xl("div",{className:"dropdown-menu-item__shortcut",children:t})]})},Gn=V4;import{jsx as Wc}from"react/jsx-runtime";var Su=({icon:e,badge:o,value:t,children:n,shortcut:r,className:i,selected:a,onSelect:l,...s})=>{let c=Uc(l);return Wc($4.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:Wc("button",{...s,value:t,className:Hn(i,a),title:s.title??s["aria-label"],children:Wc(Gn,{icon:e,shortcut:r,badge:o,children:n})})})};Su.displayName="DropdownMenuItem";var ki={GREEN:"green",RED:"red",BLUE:"blue"},Yc=({type:e=ki.BLUE,children:o})=>{let{theme:t}=Do(),n={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===Z4.LIGHT?"1.5px solid white":"none"};switch(e){case ki.GREEN:Object.assign(n,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case ki.RED:Object.assign(n,{backgroundColor:"pink",color:"darkred"});break;case ki.BLUE:default:Object.assign(n,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return Wc("div",{className:"DropDownMenuItemBadge",style:n,children:o})};Yc.displayName="DropdownMenuItemBadge";Su.Badge=Yc;var At=Su;import{KEYS as Pi}from"@excalidraw/common";var Sx=({event:e,inputRef:o,hoveredFont:t,filteredFonts:n,onClose:r,onSelect:i,onHover:a})=>{if(!e[Pi.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===Pi.F)return o.current?.focus(),!0;if(e.key===Pi.ESCAPE)return r(),!0;if(e.key===Pi.ENTER)return t?.value&&i(t.value),!0;if(e.key===Pi.ARROW_DOWN)return t?.next?a(t.next.value):n[0]?.value&&a(n[0].value),!0;if(e.key===Pi.ARROW_UP)return t?.prev?a(t.prev.value):n[n.length-1]?.value&&a(n[n.length-1].value),!0};import{jsx as cn,jsxs as nM}from"react/jsx-runtime";var tM=e=>{switch(e){case Wn.Excalifont:case Wn.Virgil:return Ln;case Wn.Nunito:case Wn.Helvetica:return ll;case Wn["Lilita One"]:return i0;case Wn["Comic Shanns"]:case Wn.Cascadia:return Ec;default:return ll}},oM=(e,o)=>Object.entries(Wn).find(([,t])=>t===e)?.[0]??o[0]?.fontFace?.family??"Unknown",Mx=j4.memo(({selectedFontFamily:e,hoveredFontFamily:o,onSelect:t,onHover:n,onLeave:r,onOpen:i,onClose:a})=>{let{container:l}=Ne(),s=je(),{fonts:c}=s,{showDeprecatedFonts:m}=no(),p=nt(),[d,u]=q4(""),b=Cx(null),g=Un(()=>Array.from(nn.registered.entries()).filter(([M,{metadata:D}])=>!D.private&&!D.fallback).map(([M,{metadata:D,fontFaces:z}])=>{let W={value:M,icon:tM(M),text:oM(M,z)};return D.deprecated&&Object.assign(W,{deprecated:D.deprecated,badge:{type:ki.RED,placeholder:f("fontList.badge.old")}}),W}).sort((M,D)=>M.text.toLowerCase()>D.text.toLowerCase()?1:-1),[]),E=Un(()=>new Set(c.getSceneFamilies()),[e]),y=Un(()=>g.filter(M=>E.has(M.value)),[g,E]),v=Un(()=>g.filter(M=>!E.has(M.value)&&(m||!M.deprecated)),[g,E,m]),x=Un(()=>J4([...y,...v].filter(M=>M.text?.toLowerCase().includes(d))),[y,v,d]),w=Un(()=>{let M;return o?M=x.find(D=>D.value===o):e&&(M=x.find(D=>D.value===e)),!M&&d&&(x[0]?.value?n(x[0].value):r()),M},[o,e,d,x,n,r]),I=Px(M=>{let D=null;if(s.state.editingTextElement){let z=document.querySelector(".excalidraw-wysiwyg");z&&(D={start:z.selectionStart,end:z.selectionEnd})}t(M),s.state.editingTextElement&&D&&setTimeout(()=>{let z=document.querySelector(".excalidraw-wysiwyg");z&&D&&(z.focus(),z.selectionStart=D.start,z.selectionEnd=D.end)},0)},[t,s.state.editingTextElement]),C=Px(M=>{Sx({event:M,inputRef:b,hoveredFont:w,filteredFonts:x,onSelect:I,onHover:n,onClose:a})&&(M.preventDefault(),M.stopPropagation())},[w,x,I,n,a]);kx(()=>(i(),()=>{a()}),[]);let A=Un(()=>x.filter(M=>E.has(M.value)),[x,E]),k=Un(()=>x.filter(M=>!E.has(M.value)),[x,E]),L=({font:M,order:D})=>{let z=Cx(null),W=M.value===w?.value,O=M.value===e;return kx(()=>{W&&(D===0?z.current?.scrollIntoView?.({block:"end"}):z.current?.scrollIntoView?.({block:"nearest"}))},[W,D]),cn("button",{ref:z,type:"button",value:M.value,className:Hn("",O,W),title:M.text,tabIndex:O?0:-1,onClick:K=>{I(Number(K.currentTarget.value))},onMouseMove:()=>{w?.value!==M.value&&n(M.value)},children:cn(Gn,{icon:M.icon,badge:M.badge&&cn(Yc,{type:M.badge.type,children:M.badge.placeholder}),textStyle:{fontFamily:eM({fontFamily:M.value})},children:M.text})})},_=[];return A.length&&_.push(cn(El,{title:f("fontList.sceneFonts"),children:A.map((M,D)=>cn(L,{font:M,order:D},M.value))},"group_1")),k.length&&_.push(cn(El,{title:f("fontList.availableFonts"),children:k.map((M,D)=>cn(L,{font:M,order:D+A.length},M.value))},"group_2")),nM(sn,{className:"properties-content",container:l,style:{width:"15rem"},onClose:()=>{a(),s.state.editingTextElement&&setTimeout(()=>{let M=document.querySelector(".excalidraw-wysiwyg");M&&M.focus()},0)},onPointerLeave:r,onKeyDown:C,preventAutoFocusOnTouch:!!s.state.editingTextElement,children:[p==="full"&&cn(Hc,{ref:b,placeholder:f("quickSearch.placeholder"),onChange:Q4(u,20)}),cn(Gc,{className:"dropdown-menu fonts manual-hover",placeholder:f("fontList.empty"),children:_.length?_:null})]})},(e,o)=>e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import{Popover as rM}from"radix-ui";import{MOBILE_ACTION_BUTTON_BG as iM}from"@excalidraw/common";import{jsx as Cu}from"react/jsx-runtime";var Ax=({selectedFontFamily:e,isOpened:o=!1,compactMode:t=!1})=>{let n=be(),r=t?{...iM,width:"2rem",height:"2rem"}:{};return Cu(rM.Trigger,{asChild:!0,children:Cu("div",{"data-openpopup":"fontFamily",className:"properties-trigger",children:Cu(vi,{standalone:!0,icon:_n,title:f("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:o,onClick:()=>{n(i=>({openPopup:i.openPopup==="fontFamily"?null:i.openPopup}))},style:{border:"none",...r}})})})};import{jsx as yl,jsxs as Lx}from"react/jsx-runtime";var _x=[{value:ku.Excalifont,icon:Ln,text:f("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:ku.Nunito,icon:ll,text:f("labels.normal"),testId:"font-family-normal"},{value:ku["Comic Shanns"],icon:Ec,text:f("labels.code"),testId:"font-family-code"}],pQ=new Set(_x.map(e=>e.value));var Dx=sM.memo(({isOpened:e,selectedFontFamily:o,hoveredFontFamily:t,onSelect:n,onHover:r,onLeave:i,onPopupChange:a,compactMode:l=!1})=>{let s=dM(()=>_x,[]),c=cM(m=>{m&&n(m)},[n]);return Lx("div",{role:"dialog","aria-modal":"true",className:lM("FontPicker__container",{"FontPicker__container--compact":l}),children:[!l&&yl("div",{className:"buttonList",children:yl(eo,{type:"button",options:s,value:o,onClick:c})}),!l&&yl(_c,{}),Lx(aM.Root,{open:e,onOpenChange:a,children:[yl(Ax,{selectedFontFamily:o,isOpened:e,compactMode:l}),e&&yl(Mx,{selectedFontFamily:o,hoveredFontFamily:t,onSelect:c,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{Popover as Pu}from"radix-ui";import hM from"clsx";import Fx,{useEffect as gM,useMemo as fM}from"react";import{isArrowKey as bM,KEYS as dn}from"@excalidraw/common";import{jsx as mM}from"react/jsx-runtime";var Mi=({className:e,icon:o,size:t="1em"})=>mM("span",{className:e,style:{width:t,height:"100%",margin:"0 0.5ex 0 0.5ex",display:"inline-flex",lineHeight:0,verticalAlign:"middle",flex:"0 0 auto"},children:o});import{Fragment as uM,jsx as Rx,jsxs as Nx}from"react/jsx-runtime";var pM=({label:e,open:o,openTrigger:t,children:n,className:r,showCollapsedIcon:i=!0})=>Nx(uM,{children:[Nx("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:r,onClick:t,children:[e,i&&Rx(Mi,{icon:o?N0:vc})]}),o&&Rx("div",{style:{display:"flex",flexDirection:"column"},children:n})]}),wl=pM;import{jsx as Ro,jsxs as Xc}from"react/jsx-runtime";var EM=_e(!1),Vc=4,xM="default",yM=e=>e.flatMap(o=>o.options),Bx=(e,o)=>{for(let t of e){let n=t.options.find(o);if(n)return n}return null},wM=(e,o)=>e.some(t=>t.options.some(o)),vM=e=>e.flatMap(o=>Array.from({length:Math.ceil(o.options.length/Vc)},(t,n)=>o.options.slice(n*Vc,n*Vc+Vc)));function IM({visibleSections:e,hiddenSections:o=[],value:t,label:n,onChange:r,onClose:i}){let{container:a}=Ne(),[l,s]=fe(EM),c=[...e,...o],m=yM(c),p=vM([...e,...l?o:[]]),d=g=>{let E=m.find(y=>y.keyBinding===g.key.toLowerCase());if(!(g.metaKey||g.altKey||g.ctrlKey)&&E)r(E.value),g.preventDefault();else if(g.key===dn.TAB){let y=m.findIndex(x=>x.value===t),v=g.shiftKey?(m.length+y-1)%m.length:(y+1)%m.length;r(m[v].value)}else if(bM(g.key)){let y=rn().rtl,v=m.findIndex(x=>x.value===t);if(v!==-1){let x=m.length,w=v;switch(g.key){case(y?dn.ARROW_LEFT:dn.ARROW_RIGHT):w=(v+1)%x;break;case(y?dn.ARROW_RIGHT:dn.ARROW_LEFT):w=(x+v-1)%x;break;case dn.ARROW_DOWN:{let I=p.findIndex(A=>A.some(k=>k.value===t)),C=p[I];if(I!==-1&&C){let A=C.findIndex(_=>_.value===t),k=p[(I+1)%p.length],L=k[Math.min(A,k.length-1)]??m[v];r(L.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}case dn.ARROW_UP:{let I=p.findIndex(A=>A.some(k=>k.value===t)),C=p[I];if(I!==-1&&C){let A=C.findIndex(_=>_.value===t),k=p[(p.length+I-1)%p.length],L=k[Math.min(A,k.length-1)]??m[v];r(L.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}}r(m[w].value)}g.preventDefault()}else(g.key===dn.ESCAPE||g.key===dn.ENTER)&&(g.preventDefault(),i());g.nativeEvent.stopImmediatePropagation(),g.stopPropagation()};gM(()=>{wM(o,g=>g.value===t)&&s(!0)},[t,o,s]);let u=g=>Ro("div",{className:"picker-content",children:g.map(E=>Xc("button",{type:"button",className:hM("picker-option",{active:t===E.value}),onClick:()=>{r(E.value)},title:E.keyBinding?`${E.text} \u2014 ${E.keyBinding.toUpperCase()}`:E.text,"aria-label":E.text||"none","aria-keyshortcuts":E.keyBinding||void 0,ref:y=>{t===E.value&&setTimeout(()=>{y?.focus()},0)},children:[E.icon,E.keyBinding&&Ro("span",{className:"picker-keybinding",children:E.keyBinding})]},E.text))}),b=g=>g.map((E,y)=>E.name===xM?Ro(Fx.Fragment,{children:u(E.options)},`${E.name}-${y}`):Xc("div",{className:"picker-section",children:[Ro("div",{className:"picker-section-label",children:E.name}),u(E.options)]},`${E.name}-${y}`));return Ro(Pu.Content,{className:"picker",role:"dialog","aria-modal":"true","aria-label":n,side:"bottom",align:"start",sideOffset:12,alignOffset:12,style:{zIndex:"var(--zIndex-ui-styles-popup)"},onKeyDown:d,collisionBoundary:a??void 0,children:Xc("div",{className:"picker-sections",children:[b(e),o.length>0&&Ro(wl,{label:f("labels.more_options"),open:l,openTrigger:()=>{s(g=>!g)},className:"picker-collapsible",children:Ro("div",{className:"picker-sections",children:b(o)})})]})})}function Mu({value:e,label:o,visibleSections:t,hiddenSections:n,onChange:r}){let[i,a]=Fx.useState(!1),l=fM(()=>Bx(t,s=>s.value===e)??Bx(n??[],s=>s.value===e),[t,n,e]);return Ro("div",{children:Xc(Pu.Root,{open:i,onOpenChange:s=>a(s),children:[Ro(Pu.Trigger,{type:"button","aria-label":o,onClick:()=>a(!i),className:i?"active":"",children:l?.icon}),i&&Ro(IM,{visibleSections:t,hiddenSections:n,value:e,label:o,onChange:r,onClose:()=>{a(!1)}})]})})}import Ox,{useEffect as TM}from"react";import{jsx as Au,jsxs as zx}from"react/jsx-runtime";var Hx=({label:e,value:o,onChange:t,min:n=0,max:r=100,step:i=10,minLabel:a=n,hasCommonValue:l=!0,testId:s})=>{let c=Ox.useRef(null),m=Ox.useRef(null);return TM(()=>{if(c.current&&m.current){let p=c.current,d=m.current,u=p.offsetWidth,b=parseFloat(getComputedStyle(p).getPropertyValue("--slider-thumb-size"))||16,g=(o-n)/(r-n||1)*100,E=g/100*(u-b)+b/2;d.style.left=`${E}px`,p.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${g}%, var(--button-bg) ${g}%, var(--button-bg) 100%)`}},[r,n,o]),zx("label",{className:"control-label",children:[e,zx("div",{className:"range-wrapper",children:[Au("input",{style:{"--color-slider-track":l?void 0:"var(--button-bg)"},ref:c,type:"range",min:n,max:r,step:i,onChange:p=>{t(+p.target.value)},value:o,className:"range-input","data-testid":s}),Au("div",{className:"value-bubble",ref:m,children:o!==n?o:null}),Au("div",{className:"zero-label",children:a})]})]})};import{Fragment as Gu,jsx as te,jsxs as vt}from"react/jsx-runtime";var Zx=.1,Li=e=>{let o=XM(e.editorInterface);return{stylesPanelMode:o,isCompact:o!=="full",isMobile:o==="mobile"}},wt=(e,o,t,n=!1)=>{let r=Bu(ee(e,o,{includeBoundTextElement:n}));return e.map(i=>r.get(i.id)||i.id===o.editingTextElement?.id?t(i):i)},pt=function(e,o,t,n,r){let i=o.state.editingTextElement,a=Xx(e),l=null;if(i&&(l=t(i)),!l)if(Pe(a,o.state)){let c=o.scene.getSelectedElements(o.state),m=n===!0?c:c.filter(p=>n(p));l=OM(m,t)??(typeof r=="function"?r(!0):r)}else l=typeof r=="function"?r(!1):r;return l},KM=(e,o,t)=>GM(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}),Ou=(e,o,t,n,r)=>{let i=new Set,a=wt(e,o,l=>{if(Lt(l)){let s=n(l);i.add(s);let c=Qe(l,{fontSize:s});return vl(c,t.scene.getContainerElement(l),t.scene),c=KM(l,c,t.scene),c}return l},!0);return ee(e,o,{includeBoundTextElement:!0}).forEach(l=>{Lt(l)&&HM(l,t.scene)}),{elements:a,appState:{...o,currentItemFontSize:i.size===1?[...i][0]:r??o.currentItemFontSize},captureUpdate:et.IMMEDIATELY}},ZM=F({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,o,t)=>({...t?.currentItemStrokeColor&&{elements:wt(e,o,n=>WM(n.type)?Qe(n,{strokeColor:t.currentItemStrokeColor}):n,!0)},appState:{...o,...t},captureUpdate:t?.currentItemStrokeColor?et.IMMEDIATELY:et.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{stylesPanelMode:i}=Li(n);return vt(Gu,{children:[i==="full"&&te("h3",{"aria-hidden":"true",children:f("labels.stroke")}),te(bl,{topPicks:AM,palette:MM,type:"elementStroke",label:f("labels.stroke"),color:pt(e,n,a=>a.strokeColor,!0,a=>a?null:o.currentItemStrokeColor),onChange:a=>t({currentItemStrokeColor:a}),elements:e,appState:o,updateData:t})]})}}),$M=F({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,o,t,n)=>{if(!t?.currentItemBackgroundColor)return{appState:{...o,...t},captureUpdate:et.EVENTUALLY};let r,i=n.scene.getSelectedElements(o);if(!FM(t.currentItemBackgroundColor)&&i.every(l=>Yx(l)&&zM(l.points))){let l=Bu(i);r=e.map(s=>l.has(s.id)&&Yx(s)?Qe(s,{backgroundColor:t.currentItemBackgroundColor,...VM(s,!0)}):s)}else r=wt(e,o,l=>Qe(l,{backgroundColor:t.currentItemBackgroundColor}));return{elements:r,appState:{...o,...t},captureUpdate:et.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{stylesPanelMode:i}=Li(n);return vt(Gu,{children:[i==="full"&&te("h3",{"aria-hidden":"true",children:f("labels.background")}),te(bl,{topPicks:PM,palette:kM,type:"elementBackground",label:f("labels.background"),color:pt(e,n,a=>a.backgroundColor,!0,a=>a?null:o.currentItemBackgroundColor),onChange:a=>t({currentItemBackgroundColor:a}),elements:e,appState:o,updateData:t})]})}}),jM=F({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,o,t,n)=>(ce("element","changeFillStyle",`${t} (${n.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),{elements:wt(e,o,r=>Qe(r,{fillStyle:t})),appState:{...o,currentItemFillStyle:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=ee(e,o),i=r.length>0&&r.every(a=>a.fillStyle==="zigzag");return vt("fieldset",{children:[te("legend",{children:f("labels.fill")}),te("div",{className:"buttonList",children:te(eo,{type:"button",options:[{value:"hachure",text:`${i?f("labels.zigzag"):f("labels.hachure")} (${N("Alt-Click")})`,icon:i?kE:PE,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:f("labels.crossHatch"),icon:ME,testId:"fill-cross-hatch"},{value:"solid",text:f("labels.solid"),icon:AE,testId:"fill-solid"}],value:pt(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(c=>c.fillStyle==="hachure")?"zigzag":a;t(s)}})})]})}}),qM=F({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,o,t)=>({elements:wt(e,o,n=>Qe(n,{strokeWidth:t})),appState:{...o,currentItemStrokeWidth:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>vt("fieldset",{children:[te("legend",{children:f("labels.strokeWidth")}),te("div",{className:"buttonList",children:te(eo,{group:"stroke-width",options:[{value:Du.thin,text:f("labels.thin"),icon:Xp,testId:"strokeWidth-thin"},{value:Du.bold,text:f("labels.bold"),icon:LE,testId:"strokeWidth-bold"},{value:Du.extraBold,text:f("labels.extraBold"),icon:_E,testId:"strokeWidth-extraBold"}],value:pt(e,n,i=>i.strokeWidth,i=>i.hasOwnProperty("strokeWidth"),i=>i?null:o.currentItemStrokeWidth),onChange:i=>t(i)})})]})}),JM=F({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,o,t)=>({elements:wt(e,o,n=>Qe(n,{seed:RM(),roughness:t})),appState:{...o,currentItemRoughness:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>vt("fieldset",{children:[te("legend",{children:f("labels.sloppiness")}),te("div",{className:"buttonList",children:te(eo,{group:"sloppiness",options:[{value:0,text:f("labels.architect"),icon:NE},{value:1,text:f("labels.artist"),icon:BE},{value:2,text:f("labels.cartoonist"),icon:FE}],value:pt(e,n,i=>i.roughness,i=>i.hasOwnProperty("roughness"),i=>i?null:o.currentItemRoughness),onChange:i=>t(i)})})]})}),bee=F({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,o,t)=>({elements:wt(e,o,n=>Qe(n,{strokeStyle:t})),appState:{...o,currentItemStrokeStyle:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>vt("fieldset",{children:[te("legend",{children:f("labels.strokeStyle")}),te("div",{className:"buttonList",children:te(eo,{group:"strokeStyle",options:[{value:"solid",text:f("labels.strokeStyle_solid"),icon:Xp},{value:"dashed",text:f("labels.strokeStyle_dashed"),icon:DE},{value:"dotted",text:f("labels.strokeStyle_dotted"),icon:RE}],value:pt(e,n,i=>i.strokeStyle,i=>i.hasOwnProperty("strokeStyle"),i=>i?null:o.currentItemStrokeStyle),onChange:i=>t(i)})})]})}),QM=F({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,o,t)=>({elements:wt(e,o,n=>Qe(n,{opacity:t}),!0),appState:{...o,currentItemOpacity:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,app:t,updateData:n})=>{let r=pt(e,t,i=>i.opacity,!0,i=>i?null:o.currentItemOpacity);return te(Hx,{label:f("labels.opacity"),value:r??o.currentItemOpacity,hasCommonValue:r!==null,onChange:n,min:0,max:100,step:10,testId:"opacity"})}}),e6=F({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,o,t,n)=>Ou(e,o,n,()=>(Fu(t,"actionChangeFontSize: Expected a font size value"),t),t),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{isCompact:i}=Li(n);return vt("fieldset",{children:[te("legend",{children:f("labels.fontSize")}),te("div",{className:"buttonList",children:te(eo,{group:"font-size",options:[{value:Zc.sm,text:f("labels.small"),icon:t0,testId:"fontSize-small"},{value:Zc.md,text:f("labels.medium"),icon:o0,testId:"fontSize-medium"},{value:Zc.lg,text:f("labels.large"),icon:n0,testId:"fontSize-large"},{value:Zc.xl,text:f("labels.veryLarge"),icon:r0,testId:"fontSize-veryLarge"}],value:pt(e,n,a=>{if(Lt(a))return a.fontSize;let l=Yn(a,n.scene.getNonDeletedElementsMap());return l?l.fontSize:null},a=>Lt(a)||Yn(a,n.scene.getNonDeletedElementsMap())!==null,a=>a?null:o.currentItemFontSize||_M),onChange:a=>{ul(()=>t(a),i,!!o.editingTextElement,r?.onPreventClose)}})})]})}}),zu=F({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:Tr,trackEvent:!1,perform:(e,o,t,n)=>Ou(e,o,n,r=>Math.round(1/(1+Zx)*r.fontSize)),keyTest:e=>e[Ai.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Ai.CHEVRON_LEFT||e.key===Ai.COMMA)}),Hu=F({name:"increaseFontSize",label:"labels.increaseFontSize",icon:Tr,trackEvent:!1,perform:(e,o,t,n)=>Ou(e,o,n,r=>Math.round(r.fontSize*(1+Zx))),keyTest:e=>e[Ai.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Ai.CHEVRON_RIGHT||e.key===Ai.PERIOD)}),t6=F({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:wt(e,o,g=>{let E=r?.get(g.id);return E?Qe(g,{...E}):g},!0),appState:{...o,...l},captureUpdate:et.NEVER};Fu(t,"actionChangeFontFamily: value must be defined");let{currentItemFontFamily:s,currentHoveredFontFamily:c}=t,m=et.EVENTUALLY,p,d=!1;if(s)p=s,m=et.IMMEDIATELY;else if(c){p=c,m=et.EVENTUALLY;let b=ee(e,o,{includeBoundTextElement:!0}).filter(g=>Lt(g));if(b.length>200)d=!0;else{let g=0,E=0;for(;g<b.length&&E<5e3;){let y=b[g];E+=y?.originalText.length||0,g++}E>5e3&&(d=!0)}}let u={appState:{...o,...l},captureUpdate:m};if(p&&!d){let b=new Map,g=new Set,E=!1,y=Array.from(nn.loadedFontsCache.values()),v=Object.entries(DM).find(([I,C])=>C===p)?.[0];c&&v&&y.some(I=>I.startsWith(v))&&(E=!0),Object.assign(u,{elements:wt(e,o,I=>{if(Lt(I)&&(I.fontFamily!==p||s)){let C=Qe(I,{fontFamily:p,lineHeight:BM(p)}),A=r?.get(I.containerId||"")||{},k=n.scene.getContainerElement(I);return a&&k&&A&&n.scene.mutateElement(k,{...A}),E||(g=new Set([...g,...Array.from(C.originalText)])),b.set(C,k),C}return I},!0)});let x=`10px ${NM({fontFamily:p})}`,w=Array.from(g.values()).join();if(E||window.document.fonts.check(x,w))for(let[I,C]of b)vl(I,C,n.scene);else window.document.fonts.load(x,w).then(I=>{for(let[C,A]of b){let k=n.scene.getElement(C.id),L=A?n.scene.getElement(A.id):null;k&&vl(k,L,n.scene)}n.fonts.onLoaded(I)})}return u},PanelComponent:({elements:e,appState:o,app:t,updateData:n})=>{let r=_u(new Map),i=_u(null),[a,l]=CM({}),s=_u(!0),{stylesPanelMode:c,isCompact:m}=Li(t),p=Nu(()=>{let d=(u,b)=>pt(u,t,g=>{if(Lt(g))return g.fontFamily;let E=Yn(g,b);return E?E.fontFamily:null},g=>Lt(g)||Yn(g,b)!==null,g=>g?null:o.currentItemFontFamily||LM);return a.openPopup==="fontFamily"&&o.openPopup==="fontFamily"?d(Array.from(r.current?.values()??[]),r.current):!a.openPopup&&o.openPopup!=="fontFamily"?d(e,t.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,o,e,t]);return Lu(()=>{i.current=p},[p]),Lu(()=>{Object.keys(a).length&&(n(a),l({}))},[a]),Lu(()=>(s.current=!1,()=>{s.current=!0}),[]),vt(Gu,{children:[c==="full"&&te("legend",{children:f("labels.fontFamily")}),te(Dx,{isOpened:o.openPopup==="fontFamily",selectedFontFamily:p,hoveredFontFamily:o.currentHoveredFontFamily,compactMode:c!=="full",onSelect:d=>{ul(()=>{l({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:d}),r.current.clear()},m,!!o.editingTextElement)},onHover:d=>{l({currentHoveredFontFamily:d,cachedElements:new Map(r.current),resetContainers:!0})},onLeave:()=>{l({currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0})},onPopupChange:d=>{if(d){r.current.clear();let{editingTextElement:u}=o;if(u?.type==="text"){let b=t.scene.getElement(u.id);r.current.set(u.id,Qe(b||u,{},!0))}else{let b=ee(e,o,{includeBoundTextElement:!0});for(let g of b)r.current.set(g.id,Qe(g,{},!0))}l({...a,openPopup:"fontFamily"})}else{let u={currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0};l({...u}),r.current.clear(),m&&o.editingTextElement&&pl(null)}}})]})}}),o6=F({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,o,t,n)=>({elements:wt(e,o,r=>{if(Lt(r)){let i=Qe(r,{textAlign:t});return vl(i,n.scene.getContainerElement(r),n.scene),i}return r},!0),appState:{...o,currentItemTextAlign:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let i=n.scene.getNonDeletedElementsMap(),{isCompact:a}=Li(n);return vt("fieldset",{children:[te("legend",{children:f("labels.textAlign")}),te("div",{className:"buttonList",children:te(eo,{group:"text-align",options:[{value:"left",text:f("labels.left"),icon:a0,testId:"align-left"},{value:"center",text:f("labels.center"),icon:l0,testId:"align-horizontal-center"},{value:"right",text:f("labels.right"),icon:s0,testId:"align-right"}],value:pt(e,n,l=>{if(Lt(l))return l.textAlign;let s=Yn(l,i);return s?s.textAlign:null},l=>Lt(l)||Yn(l,i)!==null,l=>l?null:o.currentItemTextAlign),onChange:l=>{ul(()=>t(l),a,!!o.editingTextElement,r?.onPreventClose)}})})]})}}),n6=F({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:wt(e,o,r=>{if(Lt(r)){let i=Qe(r,{verticalAlign:t});return vl(i,n.scene.getContainerElement(r),n.scene),i}return r},!0),appState:{...o},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{isCompact:i}=Li(n);return te("fieldset",{children:te("div",{className:"buttonList",children:te(eo,{group:"text-align",options:[{value:Kc.TOP,text:f("labels.alignTop"),icon:te(c0,{theme:o.theme}),testId:"align-top"},{value:Kc.MIDDLE,text:f("labels.centerVertically"),icon:te(m0,{theme:o.theme}),testId:"align-middle"},{value:Kc.BOTTOM,text:f("labels.alignBottom"),icon:te(d0,{theme:o.theme}),testId:"align-bottom"}],value:pt(e,n,a=>{if(Lt(a)&&a.containerId)return a.verticalAlign;let l=Yn(a,n.scene.getNonDeletedElementsMap());return l?l.verticalAlign:null},a=>Lt(a)||Yn(a,n.scene.getNonDeletedElementsMap())!==null,a=>a?null:Kc.MIDDLE),onChange:a=>{ul(()=>t(a),i,!!o.editingTextElement,r?.onPreventClose)}})})})}}),Eee=F({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,o,t)=>({elements:wt(e,o,n=>Kx(n)?n:Qe(n,{roundness:t==="round"?{type:UM(n.type)?$c.ADAPTIVE_RADIUS:$c.PROPORTIONAL_RADIUS}:null})),appState:{...o,currentItemRoundness:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,renderAction:r})=>{let a=ni(Xx(e),o).some(l=>l.roundness?.type===$c.LEGACY);return vt("fieldset",{children:[te("legend",{children:f("labels.edges")}),vt("div",{className:"buttonList",children:[te(eo,{group:"edges",options:[{value:"sharp",text:f("labels.sharp"),icon:OE},{value:"round",text:f("labels.round"),icon:zE}],value:pt(e,n,l=>a?null:l.roundness?"round":"sharp",l=>!jc(l)&&l.hasOwnProperty("roundness"),l=>l?null:o.currentItemRoundness),onChange:l=>t(l)}),r("togglePolygon")]})]})}}),Vx=e=>({visibleSections:[{name:"default",options:[{value:null,text:f("labels.arrowhead_none"),keyBinding:"q",icon:te(HE,{flip:e})},{value:"arrow",text:f("labels.arrowhead_arrow"),keyBinding:"w",icon:te(GE,{flip:e})},{value:"triangle",text:f("labels.arrowhead_triangle"),icon:te(UE,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:f("labels.arrowhead_triangle_outline"),icon:te(WE,{flip:e}),keyBinding:"r"}]}],hiddenSections:[{name:"default",options:[{value:"circle",text:f("labels.arrowhead_circle"),keyBinding:"a",icon:te(YE,{flip:e})},{value:"circle_outline",text:f("labels.arrowhead_circle_outline"),keyBinding:"s",icon:te(VE,{flip:e})},{value:"diamond",text:f("labels.arrowhead_diamond"),icon:te(XE,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:f("labels.arrowhead_diamond_outline"),icon:te(KE,{flip:e}),keyBinding:"f"},{value:"bar",text:f("labels.arrowhead_bar"),keyBinding:"z",icon:te(ZE,{flip:e})}]},{name:f("labels.cardinality"),options:[{value:"cardinality_one",text:f("labels.arrowhead_cardinality_one"),icon:te($E,{flip:e}),keyBinding:"x"},{value:"cardinality_many",text:f("labels.arrowhead_cardinality_many"),icon:te(jE,{flip:e}),keyBinding:"c"},{value:"cardinality_one_or_many",text:f("labels.arrowhead_cardinality_one_or_many"),icon:te(qE,{flip:e}),keyBinding:"v"},{value:"cardinality_exactly_one",text:f("labels.arrowhead_cardinality_exactly_one"),icon:te(JE,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_one",text:f("labels.arrowhead_cardinality_zero_or_one"),icon:te(QE,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_many",text:f("labels.arrowhead_cardinality_zero_or_many"),icon:te(e0,{flip:e}),keyBinding:null}]}]}),xee=F({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,o,t)=>(Fu(t,"actionChangeArrowhead: value must be defined"),{elements:wt(e,o,n=>{if(Ru(n)){let{position:r,type:i}=t;if(r==="start")return Qe(n,{startArrowhead:i});if(r==="end")return Qe(n,{endArrowhead:i})}return n}),appState:{...o,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=rn().rtl,i=Nu(()=>Vx(!r),[r]),a=Nu(()=>Vx(!!r),[r]);return vt("fieldset",{children:[te("legend",{children:f("labels.arrowheads")}),vt("div",{className:"iconSelectList buttonList",children:[te(Mu,{visibleSections:i.visibleSections,hiddenSections:i.hiddenSections,label:"arrowhead_start",value:pt(e,n,l=>Ru(l)&&ri(l.type)?Wx(l.startArrowhead):o.currentItemStartArrowhead,!0,l=>l?null:o.currentItemStartArrowhead),onChange:l=>t({position:"start",type:l})}),te(Mu,{visibleSections:a.visibleSections,hiddenSections:a.hiddenSections,label:"arrowhead_end",value:pt(e,n,l=>Ru(l)&&ri(l.type)?Wx(l.endArrowhead):o.currentItemEndArrowhead,!0,l=>l?null:o.currentItemEndArrowhead),onChange:l=>t({position:"end",type:l})})]})]})}}),r6=F({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})=>vt("div",{className:"selected-shape-actions",children:[r("changeArrowhead"),r("changeArrowType")]})}),yee=F({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,o,t,n)=>{let r=wt(e,o,l=>{if(!jc(l))return l;let s=n.scene.getNonDeletedElementsMap(),c=kr.getPointAtIndexGlobalCoordinates(l,0,s),m=kr.getPointAtIndexGlobalCoordinates(l,-1,s),p=Qe(l,{x:t===ro.elbow?c[0]:l.x,y:t===ro.elbow?c[1]:l.y,roundness:t===ro.round?{type:$c.PROPORTIONAL_RADIUS}:null,elbowed:t===ro.elbow,angle:t===ro.elbow?0:l.angle,points:t===ro.elbow||l.elbowed?[kr.pointFromAbsoluteCoords({...l,x:c[0],y:c[1],angle:0},c,s),kr.pointFromAbsoluteCoords({...l,x:c[0],y:c[1],angle:0},m,s)]:l.points});if(Kx(p)){p.fixedSegments=null;let d=n.scene.getNonDeletedElementsMap();n.dismissLinearEditor();let u=kr.getPointAtIndexGlobalCoordinates(p,0,d),b=kr.getPointAtIndexGlobalCoordinates(p,-1,d),g=p.startBinding&&d.get(p.startBinding.elementId),E=p.endBinding&&d.get(p.endBinding.elementId),y=g&&p.startBinding?{...p.startBinding,...Ux(p,g,"start",d,o.isBindingEnabled)}:null,v=E&&p.endBinding?{...p.endBinding,...Ux(p,E,"end",d,o.isBindingEnabled)}:null;p={...p,startBinding:y,endBinding:v,...YM(p,d,{points:[u,b].map(x=>SM(x[0]-p.x,x[1]-p.y)),startBinding:y,endBinding:v,fixedSegments:null})}}else{let d=n.scene.getNonDeletedElementsMap();if(p.startBinding){let u=d.get(p.startBinding.elementId);u&&Gx(p,u,o.bindMode==="inside"?"inside":"orbit","start",n.scene)}if(p.endBinding){let u=d.get(p.endBinding.elementId);u&&Gx(p,u,o.bindMode==="inside"?"inside":"orbit","end",n.scene)}}return p}),i={...o,currentItemArrowType:t},a=o.selectedLinearElement?.elementId;if(a){let l=r.find(s=>s.id===a);l&&(i.selectedLinearElement=new kr(l,Bu(e)))}return{elements:r,appState:i,captureUpdate:et.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>vt("fieldset",{children:[te("legend",{children:f("labels.arrowtypes")}),te("div",{className:"buttonList",children:te(eo,{group:"arrowtypes",options:[{value:ro.sharp,text:f("labels.arrowtype_sharp"),icon:bi,testId:"sharp-arrow"},{value:ro.round,text:f("labels.arrowtype_round"),icon:xi,testId:"round-arrow"},{value:ro.elbow,text:f("labels.arrowtype_elbowed"),icon:Ei,testId:"elbow-arrow"}],value:pt(e,n,r=>jc(r)?r.elbowed?ro.elbow:r.roundness?ro.round:ro.sharp:null,r=>jc(r),r=>r?null:o.currentItemArrowType),onChange:r=>t(r)})})]})});import{clamp as Xu,roundToStep as m6}from"@excalidraw/math";import{DEFAULT_CANVAS_BACKGROUND_PICKS as p6,CURSOR_TYPE as Qx,MAX_ZOOM as ey,MIN_ZOOM as ty,THEME as Il,ZOOM_STEP as Ku,updateActiveTool as Di,CODES as Fo,KEYS as mn}from"@excalidraw/common";import{getNonDeletedElements as u6}from"@excalidraw/element";import{getCommonBounds as h6}from"@excalidraw/element";import{CaptureUpdateAction as Oo}from"@excalidraw/element";import{useEffect as i6}from"react";import{jsx as l6}from"react/jsx-runtime";var _i=()=>{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},Uu=(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`})},a6=(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();Uu(o,r)},gt=({children:e,label:o,long:t=!1,style:n,disabled:r})=>(i6(()=>()=>_i().classList.remove("excalidraw-tooltip--visible"),[]),r?null:l6("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>a6(i.currentTarget,_i(),o,t),onPointerLeave:()=>_i().classList.remove("excalidraw-tooltip--visible"),style:n,children:e}));import{CURSOR_TYPE as Wu,MIME_TYPES as Yu,THEME as jx}from"@excalidraw/common";var qx='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',s6='<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"/>',Jx='<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"/>',c6=`data:${Yu.svg},${encodeURIComponent(`${qx}${Jx}</svg>`)}`,d6=`data:${Yu.svg},${encodeURIComponent(`${qx}${s6}${Jx}</svg>`)}`,_t=e=>{e&&(e.style.cursor="")},Ee=(e,o)=>{e&&(e.style.cursor=o)},No,$x,Vu=(e,o)=>{let n=()=>{let r=o===jx.DARK;No=document.createElement("canvas"),No.theme=o,No.height=20,No.width=20;let i=No.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(No.width/2,No.height/2,5,0,2*Math.PI),i.fillStyle=r?"#000":"#fff",i.fill(),i.strokeStyle=r?"#fff":"#000",i.stroke(),$x=No.toDataURL(Yu.svg)};(!No||No.theme!==o)&&n(),Ee(e,`url(${$x}) ${20/2} ${20/2}, auto`)},Dt=(e,o)=>{if(e)if(o.activeTool.type==="selection")_t(e);else if(bo(o))e.style.cursor=Wu.GRAB;else if(Mt(o))Vu(e,o.theme);else if(o.activeTool.type==="laser"){let t=o.theme===jx.LIGHT?c6:d6;e.style.cursor=`url(${t}), auto`}else["image","custom"].includes(o.activeTool.type)?o.activeTool.type!=="image"&&(e.style.cursor=Wu.AUTO):e.style.cursor=Wu.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),c=-(r-r/t),m=-(i-i/t);return{scrollX:l+c,scrollY:s+m,zoom:{value:t}}};import{jsx as ed,jsxs as E6}from"react/jsx-runtime";var g6=F({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?Oo.IMMEDIATELY:Oo.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:n,data:r})=>ed(bl,{palette:null,topPicks:p6,label:f("labels.canvasBackground"),type:"canvasBackground",color:o.viewBackgroundColor,onChange:i=>t({viewBackgroundColor:i}),"data-testid":"canvas-background-picker",elements:e,appState:o,updateData:t})}),qc=F({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:Ap,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>({appState:{...o,...Bo({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:Jt(o.zoom.value+Ku)},o),userToFollow:null},captureUpdate:Oo.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>ed(Z,{type:"button",className:"zoom-in-button zoom-button",icon:Ap,title:`${f("buttons.zoomIn")} \u2014 ${N("CtrlOrCmd++")}`,"aria-label":f("buttons.zoomIn"),disabled:o.zoom.value>=ey,onClick:()=>{e(null)}}),keyTest:e=>(e.code===Fo.EQUAL||e.code===Fo.NUM_ADD)&&(e[mn.CTRL_OR_CMD]||e.shiftKey)}),Jc=F({name:"zoomOut",label:"buttons.zoomOut",icon:Lp,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:Jt(o.zoom.value-Ku)},o),userToFollow:null},captureUpdate:Oo.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>ed(Z,{type:"button",className:"zoom-out-button zoom-button",icon:Lp,title:`${f("buttons.zoomOut")} \u2014 ${N("CtrlOrCmd+-")}`,"aria-label":f("buttons.zoomOut"),disabled:o.zoom.value<=ty,onClick:()=>{e(null)}}),keyTest:e=>(e.code===Fo.MINUS||e.code===Fo.NUM_SUBTRACT)&&(e[mn.CTRL_OR_CMD]||e.shiftKey)}),Qc=F({name:"resetZoom",label:"buttons.resetZoom",icon:dE,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:Jt(1)},o),userToFollow:null},captureUpdate:Oo.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>ed(gt,{label:f("buttons.resetZoom"),style:{height:"100%"},children:E6(Z,{type:"button",className:"reset-zoom-button zoom-button",title:f("buttons.resetZoom"),"aria-label":f("buttons.resetZoom"),onClick:()=>{e(null)},children:[(o.zoom.value*100).toFixed(0),"%"]})}),keyTest:e=>(e.code===Fo.ZERO||e.code===Fo.NUM_ZERO)&&(e[mn.CTRL_OR_CMD]||e.shiftKey)}),f6=(e,o,t=1)=>{let[n,r,i,a]=e,l=i-n,s=o.width/l,c=a-r,m=o.height/c,d=Math.min(s,m)*Xu(t,.1,1);return Math.min(d,1)},oy=({bounds:e,appState:o,canvasOffsets:t,fitToViewport:n=!1,viewportZoomFactor:r=1,minZoom:i=-1/0,maxZoom:a=1/0})=>{r=Xu(r,ty,ey);let[l,s,c,m]=e,p=(l+c)/2,d=(s+m)/2,u=t?.left??0,b=t?.top??0,g=t?.right??0,E=t?.bottom??0,y=o.width-u-g,v=o.height-b-E,x;if(n){let C=c-l,A=m-s;x=Math.min(y/C,v/A)*r}else x=f6(e,{width:y,height:v},r);let w=Jt(Xu(m6(x,Ku,"floor"),i,a)),I=Cb({scenePoint:{x:p,y:d},viewportDimensions:{width:o.width,height:o.height},offsets:t,zoom:{value:w}});return{appState:{...o,scrollX:I.scrollX,scrollY:I.scrollY,zoom:{value:w}},captureUpdate:Oo.EVENTUALLY}},Tl=({canvasOffsets:e,targetElements:o,appState:t,fitToViewport:n,viewportZoomFactor:r,minZoom:i,maxZoom:a})=>{let l=h6(u6(o));return oy({canvasOffsets:e,bounds:l,appState:t,fitToViewport:n,viewportZoomFactor:r,minZoom:i,maxZoom:a})},tte=F({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:wc,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return Tl({targetElements:r.length?r:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:n.getEditorUIOffsets()})},keyTest:e=>e.code===Fo.TWO&&e.shiftKey&&!e.altKey&&!e[mn.CTRL_OR_CMD]}),ote=F({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:wc,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return Tl({targetElements:r.length?r:e,appState:{...o,userToFollow:null},fitToViewport:!0,canvasOffsets:n.getEditorUIOffsets()})},keyTest:e=>e.code===Fo.THREE&&e.shiftKey&&!e.altKey&&!e[mn.CTRL_OR_CMD]}),b6=F({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:wc,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>Tl({targetElements:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:n.getEditorUIOffsets()}),keyTest:e=>e.code===Fo.ONE&&e.shiftKey&&!e.altKey&&!e[mn.CTRL_OR_CMD]}),Pr=F({name:"toggleTheme",label:(e,o)=>o.theme===Il.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:(e,o)=>e.theme===Il.LIGHT?rl:il,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t)=>({appState:{...o,theme:t||(o.theme===Il.LIGHT?Il.DARK:Il.LIGHT)},captureUpdate:Oo.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===Fo.D,predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.toggleTheme}),nte=F({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,o,t,n)=>{let r;return Mt(o)?r=Di(o,{...o.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveToolBeforeEraser:null}):r=Di(o,{type:"eraser",lastActiveToolBeforeEraser:o.activeTool}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:Oo.IMMEDIATELY}},keyTest:e=>e.key===mn.E}),rte=F({name:"toggleLassoTool",label:"toolBar.lasso",icon:An,trackEvent:{category:"toolbar"},predicate:(e,o,t,n)=>n.state.preferredSelectionTool.type!=="lasso",perform:(e,o,t,n)=>{let r;return o.activeTool.type!=="lasso"?(r=Di(o,{type:"lasso",fromSelection:!1}),Ee(n.interactiveCanvas,Qx.CROSSHAIR)):r=Di(o,{type:"selection"}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:Oo.NEVER}}}),ny=F({name:"toggleHandTool",label:"toolBar.hand",trackEvent:{category:"toolbar"},icon:yc,viewMode:!1,perform:(e,o,t,n)=>{let r;return bo(o)?r=Di(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(r=Di(o,{type:"hand",lastActiveToolBeforeEraser:o.activeTool}),Ee(n.interactiveCanvas,Qx.GRAB)),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:Oo.IMMEDIATELY}},keyTest:e=>!e.altKey&&!e[mn.CTRL_OR_CMD]&&e.key===mn.H});import{updateActiveTool as ry}from"@excalidraw/common";import{CaptureUpdateAction as x6}from"@excalidraw/element";var y6=F({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,o,t,n)=>{let r=ry(o,{type:"embeddable"});return Dt(n.canvas,{...o,activeTool:r}),{elements:e,appState:{...o,activeTool:ry(o,{type:"embeddable"})},captureUpdate:x6.EVENTUALLY}}});import{pointFrom as iy}from"@excalidraw/math";import{bindOrUnbindBindingElement as w6}from"@excalidraw/element/binding";import{isValidPolygon as ay,newElementWith as Zu}from"@excalidraw/element";import{LinearElementEditor as td}from"@excalidraw/element/linearElementEditor";import{isBindingElement as ly,isFreeDrawElement as sy,isLinearElement as cy,isLineElement as od}from"@excalidraw/element";import{KEYS as $u,arrayToMap as v6,invariant as dy,shouldRotateWithDiscreteAngle as I6,updateActiveTool as my}from"@excalidraw/common";import{isPathALoop as T6}from"@excalidraw/element";import{isInvisiblySmallElement as ju}from"@excalidraw/element";import{CaptureUpdateAction as py}from"@excalidraw/element";import{jsx as S6}from"react/jsx-runtime";var It=F({name:"finalize",label:"",trackEvent:!1,perform:(e,o,t,n)=>{let r=e,{interactiveCanvas:i,focusContainer:a,scene:l}=n,s=l.getNonDeletedElementsMap();if(t&&o.selectedLinearElement){let{event:d,sceneCoords:u}=t,b=td.getElement(o.selectedLinearElement.elementId,s);dy(b,"Arrow element should exist if selectedLinearElement is set"),dy(u,"sceneCoords should be defined if actionFinalize is called with event");let g=td.handlePointerUp(d,o.selectedLinearElement,o,n.scene);if(ly(b)&&!o.selectedLinearElement.segmentMidPointHoveredCoords){let E=!!o.newElement,v=(E||!o.selectedLinearElement.selectedPointsIndices?[b.points.length-1]:o.selectedLinearElement.selectedPointsIndices).reduce((x,w)=>(x.set(w,{point:td.pointFromAbsoluteCoords(b,iy(u.x-g.pointerOffset.x,u.y-g.pointerOffset.y),s)}),x),new Map)??new Map;w6(b,v,u.x-g.pointerOffset.x,u.y-g.pointerOffset.y,l,o,{newArrow:E,altKey:d.altKey,angleLocked:I6(d)})}else od(b)&&o.selectedLinearElement?.isEditing&&!o.newElement&&!ay(b.points)&&l.mutateElement(b,{polygon:!1});if(g!==o.selectedLinearElement){b&&ju(b)&&(r=r.map(y=>y.id===b.id?Zu(y,{isDeleted:!0}):y));let E=o.activeTool?.locked;return{elements:b.points.length<2||ju(b)?e.map(y=>y.id===b.id?Zu(y,{isDeleted:!0}):y):r,appState:{...o,cursorButton:"up",selectedLinearElement:E?null:{...g,selectedPointsIndices:null,isEditing:!1,initialState:{...g.initialState,lastClickedPoint:-1},pointerOffset:{x:0,y:0}},selectionElement:null,suggestedBinding:null,newElement:null,multiElement:null},captureUpdate:py.IMMEDIATELY}}}window.document.activeElement instanceof HTMLElement&&a();let c=null;if(o.multiElement)c=o.multiElement;else if(o.newElement?.type==="freedraw"||ly(o.newElement))c=o.newElement;else if(Object.keys(o.selectedElementIds).length===1){let d=s.get(Object.keys(o.selectedElementIds)[0]);d&&(c=d)}if(c){if(o.selectedLinearElement&&o.multiElement&&c.type!=="freedraw"&&o.lastPointerDownWith!=="touch"){let{points:d}=c,{lastCommittedPoint:u}=o.selectedLinearElement;(!u||d[d.length-1]!==u)&&l.mutateElement(c,{points:c.points.slice(0,-1)})}if(c&&ju(c)&&(r=r.map(d=>d.id===c?.id?Zu(d,{isDeleted:!0}):d)),cy(c)||sy(c)){if(T6(c.points,o.zoom.value)&&(od(c)||sy(c))){let u=c.points,b=u[0],g=u.map((E,y)=>y===u.length-1?iy(b[0],b[1]):E);od(c)?l.mutateElement(c,{points:g,polygon:!0}):l.mutateElement(c,{points:g})}od(c)&&!ay(c.points)&&l.mutateElement(c,{polygon:!1})}}(!o.activeTool.locked&&o.activeTool.type!=="freedraw"||!c)&&_t(i);let m;o.activeTool.type==="eraser"?m=my(o,{...o.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveToolBeforeEraser:null}):m=my(o,{type:n.state.preferredSelectionTool.type});let p=c&&cy(c)?new td(c,v6(r)):o.selectedLinearElement;return p=p&&{...p,isEditing:o.newElement?!1:p.isEditing,initialState:{...p.initialState,lastClickedPoint:-1,origin:null}},{elements:r,appState:{...o,cursorButton:"up",activeTool:(o.activeTool.locked||o.activeTool.type==="freedraw")&&c?o.activeTool:m,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,suggestedBinding:null,frameToHighlight:null,selectedElementIds:c&&!o.activeTool.locked&&o.activeTool.type!=="freedraw"?{...o.selectedElementIds,[c.id]:!0}:o.selectedElementIds,selectedLinearElement:p},captureUpdate:py.IMMEDIATELY}},keyTest:(e,o)=>e.key===$u.ESCAPE&&o.selectedLinearElement?.isEditing||(e.key===$u.ESCAPE||e.key===$u.ENTER)&&o.multiElement!==null,PanelComponent:({appState:e,updateData:o,data:t})=>S6(Z,{type:"button",icon:yE,title:f("buttons.done"),"aria-label":f("buttons.done"),onClick:o,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import{getElementsInGroup as gy,isSomeElementSelected as C6,makeNextSelectedElementIds as k6,selectGroupsForSelectedElements as P6}from"@excalidraw/element";import{CaptureUpdateAction as uy}from"@excalidraw/element";import{KEYS as M6,isWritableElement as A6,updateActiveTool as hy}from"@excalidraw/common";var L6=(e,o)=>e.activeTool.type==="eraser"?hy(e,{...e.activeTool.lastActiveTool||{type:o.state.preferredSelectionTool.type},lastActiveToolBeforeEraser:null}):hy(e,{type:o.state.preferredSelectionTool.type}),_6=(e,o,t)=>{if(!e.editingGroupId)return null;let n=o.scene.getNonDeletedElements(),r=o.scene.getSelectedElements({selectedElementIds:t,elements:n}),i=r.length?r:gy(n,e.editingGroupId);for(let a of i){let l=a.groupIds.indexOf(e.editingGroupId);if(l!==-1&&a.groupIds[l+1])return a.groupIds[l+1]}return null},D6=F({name:"deselect",label:"",trackEvent:!1,perform:(e,o,t,n)=>{let r=L6(o,n);if(o.editingGroupId){let i=n.scene.getNonDeletedElements(),a=Object.keys(o.selectedElementIds).length>0?o.selectedElementIds:gy(i,o.editingGroupId).reduce((l,s)=>(l[s.id]=!0,l),{});return{appState:{...o,...P6({editingGroupId:_6(o,n,a),selectedElementIds:a},i,o,n),activeEmbeddable:null,activeTool:r,selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,frameToHighlight:null},captureUpdate:uy.IMMEDIATELY}}return{appState:{...o,activeEmbeddable:null,activeTool:r,editingGroupId:null,selectedElementIds:k6({},o),selectedGroupIds:{},selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,frameToHighlight:null},captureUpdate:uy.IMMEDIATELY}},keyTest:(e,o,t,n)=>e.key!==M6.ESCAPE||A6(e.target)?!1:!o.newElement&&o.multiElement===null&&!o.selectedLinearElement?.isEditing&&(o.activeEmbeddable!==null||o.activeTool.type!==n.state.preferredSelectionTool.type||!!o.editingGroupId||!!o.selectedLinearElement||C6(n.scene.getNonDeletedElements(),o))});import{KEYS as cd,DEFAULT_EXPORT_PADDING as xA,EXPORT_SCALES as yA,THEME as Ml}from"@excalidraw/common";import{getNonDeletedElements as wA}from"@excalidraw/element";import{CaptureUpdateAction as yo}from"@excalidraw/element";import R6 from"clsx";import{jsx as fy,jsxs as N6}from"react/jsx-runtime";var Sl=({children:e,checked:o,onChange:t,className:n})=>N6("div",{className:R6("Checkbox",n,{"is-checked":o}),onClick:r=>{t(!o,r),r.currentTarget.querySelector(".Checkbox-box").focus()},children:[fy("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":o,children:gc}),fy("div",{className:"Checkbox-label",children:e})]});import{THEME as Cl}from"@excalidraw/common";import{jsx as kl}from"react/jsx-runtime";var Ey=e=>{let o=e.title||(e.value===Cl.DARK?f("buttons.lightMode"):f("buttons.darkMode"));return kl(Z,{type:"icon",icon:e.value===Cl.LIGHT?by.MOON:by.SUN,title:o,"aria-label":o,onClick:()=>e.onChange(e.value===Cl.DARK?Cl.LIGHT:Cl.DARK),"data-testid":"toggle-dark-mode"})},by={SUN:kl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:kl("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:kl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:kl("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 B6}from"react";import{focusNearestParent as F6,KEYS as O6}from"@excalidraw/common";import{jsx as xy,jsxs as z6}from"react/jsx-runtime";var yy=e=>{let{id:o}=Ne(),[t,n]=B6(e.value),r=a=>{e.ignoreFocus||F6(a.target);let l=a.target.value;l!==e.value&&e.onChange(l)},i=a=>{if(a.key===O6.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return z6("div",{className:"ProjectName",children:[xy("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),xy("input",{type:"text",className:"TextInput",onBlur:r,onKeyDown:i,id:`${o}-filename`,value:t,onChange:a=>n(a.target.value)})]})};import{useCallback as H6,useEffect as G6,useRef as U6}from"react";import{jsx as nd,jsxs as X6}from"react/jsx-runtime";var W6=5e3,Y6=({progress:e})=>nd("div",{className:"Toast__progress-bar",children:nd("div",{className:"Toast__progress-bar-fill",style:{width:`${Math.min(5,Math.round(e*100))}%`}})}),V6=({message:e,onClose:o,closable:t=!1,duration:n=W6,style:r})=>{let i=U6(0),a=n!==1/0,l=H6(()=>{a&&(i.current=window.setTimeout(()=>o(),n))},[o,n,a]);return G6(()=>{if(a)return l(),()=>clearTimeout(i.current)},[l,e,n,a]),X6("div",{className:"Toast",role:"status",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?l:void 0,style:r,children:[nd("div",{className:"Toast__message",children:e}),t&&nd(Z,{icon:Qt,"aria-label":"close",type:"icon",onClick:o,className:"close"})]})},Ri=Object.assign(V6,{ProgressBar:Y6});import{DEFAULT_EXPORT_PADDING as cA,DEFAULT_FILENAME as dA,IMAGE_MIME_TYPES as ky,isFirefox as mA,MIME_TYPES as pA,cloneJSON as uA,SVG_DOCUMENT_PREAMBLE as hA,arrayToMap as gA}from"@excalidraw/common";import{getNonDeletedElements as fA}from"@excalidraw/element";import{isFrameLikeElement as bA}from"@excalidraw/element";import{getElementsOverlappingFrame as EA}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as K6,EXPORT_DATA_TYPES as Pl,MIME_TYPES as Wt,arrayToMap as Z6,isMemberOf as $6,isPromiseLike as j6,EVENT as rd}from"@excalidraw/common";import{mutateElement as q6}from"@excalidraw/element";import{deepCopyElement as J6}from"@excalidraw/element";import{isFrameLikeElement as Q6,isInitializedImageElement as eA}from"@excalidraw/element";import{getContainingFrame as wy}from"@excalidraw/element";var koe="clipboard"in navigator&&"readText"in navigator.clipboard,id="clipboard"in navigator&&"writeText"in navigator.clipboard,Vn="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,tA=e=>!!([Pl.excalidraw,Pl.excalidrawClipboard,Pl.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),vy=({types:e,files:o})=>{!e&&!o&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent(rd.PASTE,{clipboardData:new DataTransfer});if(e)for(let[n,r]of Object.entries(e)){if(typeof r!="string"){o=o||[],o.push(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},oA=({elements:e,files:o})=>{let t=Z6(e),n=new Set(e.filter(l=>Q6(l))),r=!1,i=e.reduce((l,s)=>(eA(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:Pl.excalidrawClipboard,elements:e.map(l=>{if(wy(l,t)&&!n.has(wy(l,t))){let s=J6(l);return q6(s,t,{frameId:null}),s}return l}),files:o?i:void 0};return JSON.stringify(a)},ad=async(e,o,t)=>{let n=oA({elements:e,files:o});await xo({[Wt.excalidrawClipboard]:n,[Wt.text]:n},t)};function Iy(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(Iy(t));return o}var nA=e=>{let o=e.value;try{let t=new DOMParser().parseFromString(o,Wt.html),n=Iy(t.body);if(n.length)return{type:"mixedContent",value:n}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},Ty=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{[Wt.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($6(K6,n))try{if(n===Wt.text||n===Wt.html)e[n]=await(await t.getType(n)).text();else if(zb(n)){let r=await t.getType(n),i=Xb(r,n,void 0);e[n]=i}else throw new wp(`Unsupported clipboard type: ${n}`)}catch(r){console.warn(r instanceof wp?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},rA=async(e,o=!1)=>{try{let t=e.findByType(Wt.html),n=!o&&t&&nA(t);return n?n.value.every(r=>r.type==="text")?{type:"text",value:e.getData(Wt.text)??n.value.map(r=>r.value).join(`
2
+ `).trim()}:n:{type:"text",value:(e.getData(Wt.text)||"").trim()}}catch{return{type:"text",value:""}}},iA=function(e){return this.find(o=>o.type===e)||null},aA=function(e){return this.find(t=>t.type===e)?.value??null},lA=function(){return this.filter(e=>e.kind==="file")},Sy=e=>{let o;Cy(e)?o=e.clipboardData?.items:o=e.dataTransfer?.items;let t=new Set;for(let n of Array.from(o||[]))t.has(n.type)||t.add(n.type);return t},Ni=async e=>{let o;Cy(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 Vb(n);return r=await ol(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:iA,getData:aA,getFiles:lA})},ld=async(e,o=!1)=>{let t=await rA(e,o);if(t.type==="mixedContent")return{mixedContent:t.value};try{let n=JSON.parse(t.value),r=n.type===Pl.excalidrawClipboardWithAPI;if(tA(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}},sd=async e=>{try{await navigator.clipboard.write([new ClipboardItem({[Wt.png]:e})])}catch(o){if(j6(e))await navigator.clipboard.write([new ClipboardItem({[Wt.png]:await e})]);else throw o}},xo=async(e,o)=>{e=e||"";let t=Object.entries(typeof e=="string"?{[Wt.text]:e}:e);try{if(o){for(let[r,i]of t)if(o.clipboardData?.setData(r,i),o.clipboardData?.getData(r)!==i)throw new Error("Failed to setData on clipboardEvent");return}}catch(r){console.error(r)}let n=t.find(([r])=>r===Wt.text);if(id&&n)try{await navigator.clipboard.writeText(n[1]);return}catch(r){console.error(r)}if(n&&!sA(n[1]))throw new Error("Error copying to clipboard.")},sA=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},Cy=e=>e.type===rd.PASTE||e.type===rd.COPY||e.type===rd.CUT;var Mr=(e,{selectedElementIds:o},t)=>{e=fA(e);let n=gA(e),r=t&&Pe(e,{selectedElementIds:o}),i=null,a=r?ee(e,{selectedElementIds:o},{includeBoundTextElement:!0}):e;return r&&(a.length===1&&bA(a[0])?(i=a[0],a=EA(e,i,n)):a.length>1&&(a=ee(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:i,exportedElements:uA(a)}},Ar=async(e,o,t,n,{exportBackground:r,exportPadding:i=cA,viewBackgroundColor:a,name:l=t.name||dA,fileHandle:s=null,exportingFrame:c=null})=>{if(o.length===0)throw new Error(f("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let p=yr(o,{exportBackground:r,exportWithDarkMode:t.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:t.exportScale,exportEmbedScene:t.exportEmbedScene&&e==="svg"},n,{exportingFrame:c});if(e==="svg")return vp(p.then(d=>new Blob([hA+d.outerHTML],{type:pA.svg})),{description:"Export to SVG",name:l,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[ky.svg],fileHandle:s});if(e==="clipboard-svg"){let d=await p.then(u=>u.outerHTML);try{await xo(d)}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return}}let m=ec(o,t,n,{exportBackground:r,viewBackgroundColor:a,exportPadding:i,exportingFrame:c});if(e==="png"){let p=vr(m);return t.exportEmbedScene&&(p=p.then(d=>import("./data/image-N3RCNYSN.js").then(({encodePngMetadata:u})=>u({blob:d,metadata:Ja(o,t,n,"local")})))),vp(p,{description:"Export to PNG",name:l,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[ky.png],fileHandle:s})}else if(e==="clipboard")try{let p=vr(m);await sd(p)}catch(p){throw console.warn(p),p.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):mA&&p.name==="TypeError"?new Error(`${f("alerts.couldNotCopyToClipboard")}
3
3
 
4
4
  ${f("hints.firefox_clipboard_write")}`):new Error(f("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var Py=async(e,o,t)=>{let n=Fb(o);if(!Ob(n))throw new Error("fileHandle should exist and should be of type svg or png when resaving");let{elements:r,appState:i,files:a}=await e,{exportBackground:l,viewBackgroundColor:s}=i;i={...i,exportEmbedScene:!0};let{exportedElements:c,exportingFrame:m}=Mr(r,i,!1);return await Ar(n,c,i,a,{exportBackground:l,viewBackgroundColor:s,name:t,fileHandle:o,exportingFrame:m}),{fileHandle:o}};import{Fragment as _y,jsx as zo,jsxs as Dy}from"react/jsx-runtime";var Ju=F({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,o,t)=>({appState:{...o,name:t},captureUpdate:yo.EVENTUALLY}),PanelComponent:({appState:e,updateData:o,appProps:t,data:n,app:r})=>zo(yy,{label:f("labels.fileTitle"),value:r.getName(),onChange:i=>o(i),ignoreFocus:n?.ignoreFocus??!1})}),My=F({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,o,t)=>({appState:{...o,exportScale:t},captureUpdate:yo.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let n=wA(e),i=Pe(n,o)?ee(n,o):n;return zo(_y,{children:yA.map(a=>{let[l,s]=Nb(i,xA,a),c=`${f("imageExportDialog.label.scale")} ${a}x (${l}x${s})`;return zo(Z,{size:"small",type:"radio",icon:`${a}x`,name:"export-canvas-scale",title:c,"aria-label":c,id:"export-canvas-scale",checked:a===o.exportScale,onChange:()=>t(a)},a)})})}}),Qu=F({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,o,t)=>({appState:{...o,exportBackground:t},captureUpdate:yo.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>zo(Sl,{checked:e.exportBackground,onChange:t=>o(t),children:f("imageExportDialog.label.withBackground")})}),dd=F({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,o,t)=>({appState:{...o,exportEmbedScene:t},captureUpdate:yo.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Dy(Sl,{checked:e.exportEmbedScene,onChange:t=>o(t),children:[f("imageExportDialog.label.embedScene"),zo(gt,{label:f("imageExportDialog.tooltip.embedScene"),long:!0,children:zo("div",{className:"excalidraw-tooltip-icon",children:wE})})]})}),Bi=!1,qu=(e,o)=>{let t=o.message??f("progressDialog.defaultMessage");e.setAppState({toast:{message:o.progress!=null?Dy(_y,{children:[t,zo(Ri.ProgressBar,{progress:o.progress})]}):t,duration:1/0}})};async function vA(e,o){if(o.app.state.isLoading&&(qu(o.app,{progress:null}),await o.app.onStateChange({predicate:t=>!t.isLoading})),e!=null&&typeof e=="object"&&Symbol.asyncIterator in e){for await(let t of e){if(o.signal.aborted){e.return();return}if(t.type==="progress")qu(o.app,{message:t.message,progress:t.progress??null});else if(t.type==="done")return}return}e instanceof Promise&&(qu(o.app,{progress:null}),await e)}function Ay(e,o,t,n){let r=new AbortController,i=r.signal,a=new Promise(async l=>{try{n.props.onExport&&await vA(n.props.onExport("json",{elements:e,appState:o,files:t},{signal:i}),{app:n,signal:i})}catch(s){s?.name==="AbortError"?console.warn(`onExport() aborted by host app (signal aborted: ${i.aborted})`):console.error("Error during props.onExport() handling",s)}l({elements:e,appState:o,files:n.files})});return{abortController:r,data:a}}var Lr=F({name:"saveToActiveFile",label:"buttons.save",icon:Ir,trackEvent:{category:"export"},predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.saveToActiveFile&&!!o.fileHandle&&!o.viewModeEnabled,perform:async(e,o,t,n)=>{if(Bi)return!1;Bi=!0;let r=o.fileHandle,i=n.getName(),{abortController:a,data:l}=Ay(e,o,n.files,n);try{let{fileHandle:s}=tc(r)?await Py(l,r,i):await js({data:l,filename:i,fileHandle:r});return{captureUpdate:yo.NEVER,appState:{fileHandle:s,toast:{message:r&&s?.name?f("toast.fileSavedToFilename").replace("{filename}",`"${s.name}"`):f("toast.fileSaved"),duration:1500}}}}catch(s){return a.abort(),s?.name!=="AbortError"?console.error(s):console.warn(s),{captureUpdate:yo.NEVER,appState:{toast:null}}}finally{Bi=!1}},keyTest:e=>!1}),Al=F({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:Ir,viewMode:!0,trackEvent:{category:"export"},perform:async(e,o,t,n)=>{if(Bi)return!1;Bi=!0;let{abortController:r,data:i}=Ay(e,o,n.files,n);try{let{fileHandle:a}=await js({data:i,filename:n.getName(),fileHandle:null});return{captureUpdate:yo.NEVER,appState:{openDialog:null,fileHandle:a,toast:{message:f("toast.fileSaved"),duration:3e3}}}}catch(a){return r.abort(),a?.name!=="AbortError"?console.error(a):console.warn(a),{captureUpdate:yo.NEVER,appState:{toast:null}}}finally{Bi=!1}},keyTest:e=>e.key.toLowerCase()===cd.S&&e.shiftKey&&e[cd.CTRL_OR_CMD],PanelComponent:({updateData:e})=>zo(Z,{type:"button",icon:bE,title:f("buttons.saveAs"),"aria-label":f("buttons.saveAs"),showAriaLabel:pe().formFactor==="phone",hidden:!ai,onClick:()=>e(null),"data-testid":"save-as-button"})}),Fi=F({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 Ip(o,e);return{elements:r,appState:i,files:a,captureUpdate:yo.IMMEDIATELY}}catch(r){return r?.name==="AbortError"?(console.warn(r),!1):{elements:e,appState:{...o,errorMessage:r.message},files:n.files,captureUpdate:yo.EVENTUALLY}}},keyTest:e=>e[cd.CTRL_OR_CMD]&&e.key===cd.O}),Ly=F({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,o,t,n)=>(n.sessionExportThemeOverride=t?Ml.DARK:Ml.LIGHT,{appState:{...o,exportWithDarkMode:t},captureUpdate:yo.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>zo("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:zo(Ey,{value:e.exportWithDarkMode?Ml.DARK:Ml.LIGHT,onChange:t=>{o(t===Ml.DARK)},title:f("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as IA,DEFAULT_FONT_FAMILY as TA,DEFAULT_TEXT_ALIGN as SA,getLineHeight as CA}from"@excalidraw/common";import{newElementWith as md}from"@excalidraw/element";import{hasBoundTextElement as kA,canApplyRoundnessTypeToElement as PA,getDefaultRoundnessTypeForElement as MA,isFrameLikeElement as AA,isArrowElement as LA,isExcalidrawElement as _A,isTextElement as eh}from"@excalidraw/element";import{getBoundTextElement as DA,redrawTextBoundingBox as RA}from"@excalidraw/element";import{CaptureUpdateAction as th}from"@excalidraw/element";var Ry="{}",NA=F({name:"copyStyles",label:"labels.copyStyles",icon:Zp,trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=[],i=e.find(a=>o.selectedElementIds[a.id]);if(r.push(i),i&&kA(i)){let a=DA(i,n.scene.getNonDeletedElementsMap());r.push(a)}return i&&(Ry=JSON.stringify(r)),{appState:{...o,toast:{message:f("toast.copyStyles")}},captureUpdate:th.EVENTUALLY}}}),BA=F({name:"pasteStyles",label:"labels.pasteStyles",icon:Zp,trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=JSON.parse(Ry),i=r[0],a=r[1];if(!_A(i))return{elements:e,captureUpdate:th.EVENTUALLY};let l=ee(e,o,{includeBoundTextElement:!0}),s=l.map(c=>c.id);return{elements:e.map(c=>{if(s.includes(c.id)){let m=i;if(eh(c)&&c.containerId&&(m=a),!m)return c;let p=md(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?PA(m.roundness.type,c)?m.roundness:MA(c):null});if(eh(p)){let d=m.fontSize||IA,u=m.fontFamily||TA;p=md(p,{fontSize:d,fontFamily:u,textAlign:m.textAlign||SA,lineHeight:m.lineHeight||CA(u)});let b=null;p.containerId&&(b=l.find(g=>eh(p)&&g.id===p.containerId)||null),RA(p,b,n.scene)}return p.type==="arrow"&&LA(m)&&(p=md(p,{startArrowhead:m.startArrowhead,endArrowhead:m.endArrowhead})),AA(c)&&(p=md(p,{roundness:null,backgroundColor:"transparent"})),p}return c}),captureUpdate:th.IMMEDIATELY}}});import{KEYS as FA}from"@excalidraw/common";import{CaptureUpdateAction as OA}from"@excalidraw/element";var _r=F({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:pE,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"},openMenu:null,openPopup:null},captureUpdate:OA.EVENTUALLY}),keyTest:e=>e.key===FA.QUESTION_MARK});import{getNonDeletedElements as ud}from"@excalidraw/element";import{newElementWith as Fy}from"@excalidraw/element";import{isBoundToContainer as zA}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as HA,getElementsInResizingFrame as GA,getFrameLikeElements as UA,getRootElements as WA,groupByFrameLikes as YA,removeElementsFromFrame as VA,replaceAllElementsInFrame as XA}from"@excalidraw/element";import{KEYS as hd,randomId as KA,arrayToMap as oh}from"@excalidraw/common";import{getSelectedGroupIds as pd,selectGroup as ZA,selectGroupsForSelectedElements as $A,getElementsInGroup as Ny,addToGroup as jA,removeFromSelectedGroups as qA,isElementInGroup as Oy}from"@excalidraw/element";import{syncMovedIndices as JA}from"@excalidraw/element";import{CaptureUpdateAction as Ll}from"@excalidraw/element";import{jsx as Oi}from"react/jsx-runtime";var QA=e=>{if(e.length>=2){let o=e[0].groupIds;for(let t of o)if(e.reduce((n,r)=>n&&Oy(r,t),!0))return!0}return!1},By=(e,o,t)=>{let n=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});return n.length>=2&&!QA(n)&&!HA(n)},nh=F({name:"group",label:"labels.group",icon:e=>Oi(Yp,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=WA(n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}));if(r.length<2)return{appState:o,elements:e,captureUpdate:Ll.EVENTUALLY};let i=pd(o);if(i.length===1){let E=i[0],y=new Set(Ny(e,E).map(w=>w.id)),v=new Set(r.map(w=>w.id));if(new Set([...Array.from(y),...Array.from(v)]).size===y.size)return{appState:o,elements:e,captureUpdate:Ll.EVENTUALLY}}let a=[...e];new Set(r.map(E=>E.frameId)).size>1&&YA(r).forEach((y,v)=>{VA(y,n.scene.getNonDeletedElementsMap())});let s=KA(),c=oh(r);a=a.map(E=>c.get(E.id)?Fy(E,{groupIds:jA(E.groupIds,s,o.editingGroupId)}):E);let m=Ny(a,s),p=m[m.length-1],d=a.lastIndexOf(p),u=a.slice(d+1),b=a.slice(0,d).filter(E=>!Oy(E,s)),g=JA([...b,...m,...u],oh(m));return{appState:{...o,...ZA(s,{...o,selectedGroupIds:{}},ud(a))},elements:g,captureUpdate:Ll.IMMEDIATELY}},predicate:(e,o,t,n)=>By(e,o,n),keyTest:e=>!e.shiftKey&&e[hd.CTRL_OR_CMD]&&e.key===hd.G,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Oi(Z,{hidden:!By(e,o,n),type:"button",icon:Oi(Yp,{theme:o.theme}),onClick:()=>t(null),title:`${f("labels.group")} \u2014 ${N("CtrlOrCmd+G")}`,"aria-label":f("labels.group"),visible:Pe(ud(e),o)})}),rh=F({name:"ungroup",label:"labels.ungroup",icon:e=>Oi(Vp,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=pd(o),i=oh(e);if(r.length===0)return{appState:o,elements:e,captureUpdate:Ll.EVENTUALLY};let a=[...e],l=[];a=a.map(d=>{zA(d)&&l.push(d.id);let u=qA(d.groupIds,o.selectedGroupIds);return u.length===d.groupIds.length?d:Fy(d,{groupIds:u})});let s=$A(o,ud(a),o,null),c=n.scene.getSelectedElements(o),m=new Set(c.filter(d=>d.frameId).map(d=>d.frameId));return UA(e).filter(d=>m.has(d.id)).forEach(d=>{d&&(a=XA(a,GA(a,d,o,i),d))}),s.selectedElementIds=Object.entries(s.selectedElementIds).reduce((d,[u,b])=>(b&&!l.includes(u)&&(d[u]=!0),d),{}),{appState:{...o,...s},elements:a,captureUpdate:Ll.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[hd.CTRL_OR_CMD]&&e.key===hd.G.toUpperCase(),predicate:(e,o)=>pd(o).length>0,PanelComponent:({elements:e,appState:o,updateData:t})=>Oi(Z,{type:"button",hidden:pd(o).length===0,icon:Oi(Vp,{theme:o.theme}),onClick:()=>t(null),title:`${f("labels.ungroup")} \u2014 ${N("CtrlOrCmd+Shift+G")}`,"aria-label":f("labels.ungroup"),visible:Pe(ud(e),o)})});import aL from"clsx";import{CaptureUpdateAction as Wy}from"@excalidraw/element";import{invariant as lL}from"@excalidraw/common";import{COLOR_CHARCOAL_BLACK as eL,COLOR_VOICE_CALL as tL,COLOR_WHITE as fd,THEME as oL,UserIdleState as zy}from"@excalidraw/common";var gd=(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 nL(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 Dr=(e,o)=>`hsl(${Math.abs(nL(o?.id||e))%37*10}, 100%, 83%)`,Hy=e=>{let o=e?.trim()?.codePointAt(0);return(o?String.fromCodePoint(o):"?").toUpperCase()},Gy=({context:e,renderConfig:o,appState:t,normalizedWidth:n,normalizedHeight:r})=>{for(let[i,a]of o.remotePointerViewportCoords){let{x:l,y:s}=a,c=t.collaborators.get(i);l-=t.offsetLeft,s-=t.offsetTop;let m=11,p=14,d=l<0||l>n-m||s<0||s>r-p;l=Math.max(l,0),l=Math.min(l,n-m),s=Math.max(s,0),s=Math.min(s,r-p);let u=Dr(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let b=o.remotePointerUserStates.get(i),g=d||b===zy.IDLE||b===zy.AWAY;g&&(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 E=t.theme===oL.DARK?"#2f6330":tL,y=c?.isSpeaking;y&&(e.fillStyle=E,e.strokeStyle=E,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=fd,e.strokeStyle=fd,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(),g?(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 v=o.remotePointerUsernames.get(i)||"";if(!d&&v){e.font="600 12px sans-serif";let x=(y?l+0:l)+m/2,w=(y?s+0:s)+p+2,I=5,C=3,A=e.measureText(v),k=A.actualBoundingBoxDescent+A.actualBoundingBoxAscent,L=Math.max(k,12),_=x-1,M=w-1,D=A.width+2+I*2+2,z=L+2+C*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(_,M,D,z,8),e.fillStyle=u,e.fill(),e.strokeStyle=fd,e.stroke(),y&&(e.beginPath(),e.roundRect(_-2,M-2,D+4,z+4,8),e.strokeStyle=E,e.stroke())):gd(e,_,M,D,z,8,fd),e.fillStyle=eL,e.fillText(v,x+I+1,w+C+A.actualBoundingBoxAscent+Math.floor((L-k)/2)+2),y){e.fillStyle=E;let W=8,O=8,K=5;e.fillRect(_+D+O,M+(z/2-W/2),2,W),e.fillRect(_+D+O+K,M+(z/2-W*2/2),2,W*2),e.fillRect(_+D+O+K*2,M+(z/2-W/2),2,W)}}e.restore(),e.closePath()}};import rL from"clsx";import{useState as iL}from"react";import{jsx as Uy}from"react/jsx-runtime";var ih=({color:e,onClick:o,name:t,src:n,className:r})=>{let i=Hy(t),[a,l]=iL(!1),s=!a&&n,c=s?void 0:{background:e};return Uy("div",{className:rL("Avatar",r),style:c,onClick:o,children:s?Uy("img",{className:"Avatar-img",src:n,alt:i,referrerPolicy:"no-referrer",onError:()=>l(!0)}):i})};import{jsx as Ho,jsxs as bd}from"react/jsx-runtime";var sL=F({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,o,t)=>(lL(t,"actionGoToCollaborator: collaborator should be defined when actionGoToCollaborator is called"),!t.socketId||o.userToFollow?.socketId===t.socketId||t.isCurrentUser?{appState:{...o,userToFollow:null},captureUpdate:Wy.EVENTUALLY}:{appState:{...o,userToFollow:{socketId:t.socketId,username:t.username||""},openMenu:o.openMenu==="canvas"?null:o.openMenu},captureUpdate:Wy.EVENTUALLY}),PanelComponent:({updateData:e,data:o,appState:t})=>{let{socketId:n,collaborator:r,withName:i,isBeingFollowed:a}=o,l=Dr(n,r),s=aL({"is-followed":a,"is-current-user":r.isCurrentUser===!0,"is-speaking":r.isSpeaking,"is-in-call":r.isInCall,"is-muted":r.isMuted}),c=r.isInCall?r.isSpeaking?bd("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:f("userList.hint.isSpeaking"),children:[Ho("div",{}),Ho("div",{}),Ho("div",{})]}):r.isMuted?Ho("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:f("userList.hint.micMuted"),children:I0}):Ho("div",{title:f("userList.hint.inCall"),children:v0}):null;return i?bd("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(r),children:[Ho(ih,{color:l,onClick:()=>{},name:r.username||"",src:r.avatarUrl,className:s}),Ho("div",{className:"UserList__collaborator-name",children:r.username}),bd("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&Ho("div",{className:"UserList__collaborator-status-icon-is-followed",title:f("userList.hint.followStatus"),children:Sr}),c]})]}):bd("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[Ho(ih,{color:l,onClick:()=>{e(r)},name:r.username||"",src:r.avatarUrl,className:s}),c&&Ho("div",{className:"UserList__collaborator-status-icon",children:c})]})}});import{LIBRARY_DISABLED_TYPES as cL,randomId as dL}from"@excalidraw/common";import{deepCopyElement as mL}from"@excalidraw/element";import{CaptureUpdateAction as ah}from"@excalidraw/element";var pL=F({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 cL)if(r.some(a=>a.type===i))return{captureUpdate:ah.EVENTUALLY,appState:{...o,errorMessage:f(`errors.libraryElementTypeError.${i}`)}};return n.library.getLatestLibrary().then(i=>n.library.setLibrary([{id:dL(),status:"unpublished",elements:r.map(mL),created:Date.now()},...i])).then(()=>({captureUpdate:ah.EVENTUALLY,appState:{...o,toast:{message:f("toast.addedToLibrary")}}})).catch(i=>({captureUpdate:ah.EVENTUALLY,appState:{...o,errorMessage:i.message}}))},label:"labels.addToLibrary"});import{getNonDeletedElements as zi}from"@excalidraw/element";import{isFrameLikeElement as uL}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as hL}from"@excalidraw/element";import{KEYS as Xn,arrayToMap as gL}from"@excalidraw/common";import{alignElements as fL}from"@excalidraw/element";import{CaptureUpdateAction as Hi}from"@excalidraw/element";import{getSelectedElementsByGroup as bL}from"@excalidraw/element";import{jsx as Ui}from"react/jsx-runtime";var tt=(e,o)=>{let t=o.scene.getSelectedElements(e);return bL(t,o.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(n=>uL(n))},Gi=(e,o,t,n)=>{let r=t.scene.getSelectedElements(o),i=fL(r,n,t.scene,o),a=gL(i);return hL(e.map(l=>a.get(l.id)||l),o,t)},EL=F({name:"alignTop",label:"labels.alignTop",icon:Op,trackEvent:{category:"element"},predicate:(e,o,t,n)=>tt(o,n),perform:(e,o,t,n)=>({appState:o,elements:Gi(e,o,n,{position:"start",axis:"y"}),captureUpdate:Hi.IMMEDIATELY}),keyTest:e=>e[Xn.CTRL_OR_CMD]&&e.shiftKey&&e.key===Xn.ARROW_UP,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Ui(Z,{hidden:!tt(o,n),type:"button",icon:Op,onClick:()=>t(null),title:`${f("labels.alignTop")} \u2014 ${N("CtrlOrCmd+Shift+Up")}`,"aria-label":f("labels.alignTop"),visible:Pe(zi(e),o)})}),xL=F({name:"alignBottom",label:"labels.alignBottom",icon:zp,trackEvent:{category:"element"},predicate:(e,o,t,n)=>tt(o,n),perform:(e,o,t,n)=>({appState:o,elements:Gi(e,o,n,{position:"end",axis:"y"}),captureUpdate:Hi.IMMEDIATELY}),keyTest:e=>e[Xn.CTRL_OR_CMD]&&e.shiftKey&&e.key===Xn.ARROW_DOWN,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Ui(Z,{hidden:!tt(o,n),type:"button",icon:zp,onClick:()=>t(null),title:`${f("labels.alignBottom")} \u2014 ${N("CtrlOrCmd+Shift+Down")}`,"aria-label":f("labels.alignBottom"),visible:Pe(zi(e),o)})}),yL=F({name:"alignLeft",label:"labels.alignLeft",icon:Hp,trackEvent:{category:"element"},predicate:(e,o,t,n)=>tt(o,n),perform:(e,o,t,n)=>({appState:o,elements:Gi(e,o,n,{position:"start",axis:"x"}),captureUpdate:Hi.IMMEDIATELY}),keyTest:e=>e[Xn.CTRL_OR_CMD]&&e.shiftKey&&e.key===Xn.ARROW_LEFT,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Ui(Z,{hidden:!tt(o,n),type:"button",icon:Hp,onClick:()=>t(null),title:`${f("labels.alignLeft")} \u2014 ${N("CtrlOrCmd+Shift+Left")}`,"aria-label":f("labels.alignLeft"),visible:Pe(zi(e),o)})}),wL=F({name:"alignRight",label:"labels.alignRight",icon:Gp,trackEvent:{category:"element"},predicate:(e,o,t,n)=>tt(o,n),perform:(e,o,t,n)=>({appState:o,elements:Gi(e,o,n,{position:"end",axis:"x"}),captureUpdate:Hi.IMMEDIATELY}),keyTest:e=>e[Xn.CTRL_OR_CMD]&&e.shiftKey&&e.key===Xn.ARROW_RIGHT,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Ui(Z,{hidden:!tt(o,n),type:"button",icon:Gp,onClick:()=>t(null),title:`${f("labels.alignRight")} \u2014 ${N("CtrlOrCmd+Shift+Right")}`,"aria-label":f("labels.alignRight"),visible:Pe(zi(e),o)})}),vL=F({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Up,trackEvent:{category:"element"},predicate:(e,o,t,n)=>tt(o,n),perform:(e,o,t,n)=>({appState:o,elements:Gi(e,o,n,{position:"center",axis:"y"}),captureUpdate:Hi.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Ui(Z,{hidden:!tt(o,n),type:"button",icon:Up,onClick:()=>t(null),title:f("labels.centerVertically"),"aria-label":f("labels.centerVertically"),visible:Pe(zi(e),o)})}),IL=F({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Wp,trackEvent:{category:"element"},predicate:(e,o,t,n)=>tt(o,n),perform:(e,o,t,n)=>({appState:o,elements:Gi(e,o,n,{position:"center",axis:"x"}),captureUpdate:Hi.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Ui(Z,{hidden:!tt(o,n),type:"button",icon:Wp,onClick:()=>t(null),title:f("labels.centerHorizontally"),"aria-label":f("labels.centerHorizontally"),visible:Pe(zi(e),o)})});import{getNonDeletedElements as Yy}from"@excalidraw/element";import{isFrameLikeElement as TL}from"@excalidraw/element";import{CODES as Vy,KEYS as Xy,arrayToMap as SL}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as CL}from"@excalidraw/element";import{distributeElements as kL}from"@excalidraw/element";import{CaptureUpdateAction as Ky}from"@excalidraw/element";import{getSelectedElementsByGroup as PL}from"@excalidraw/element";import{jsx as jy}from"react/jsx-runtime";var Zy=(e,o)=>{let t=o.scene.getSelectedElements(e);return PL(t,o.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(n=>TL(n))},$y=(e,o,t,n)=>{let r=t.scene.getSelectedElements(o),i=kL(r,t.scene.getNonDeletedElementsMap(),n,o,t.scene),a=SL(i);return CL(e.map(l=>a.get(l.id)||l),o,t)},ML=F({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,o,t,n)=>({appState:o,elements:$y(e,o,n,{space:"between",axis:"x"}),captureUpdate:Ky.IMMEDIATELY}),keyTest:e=>!e[Xy.CTRL_OR_CMD]&&e.altKey&&e.code===Vy.H,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>jy(Z,{hidden:!Zy(o,n),type:"button",icon:SE,onClick:()=>t(null),title:`${f("labels.distributeHorizontally")} \u2014 ${N("Alt+H")}`,"aria-label":f("labels.distributeHorizontally"),visible:Pe(Yy(e),o)})}),AL=F({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,o,t,n)=>({appState:o,elements:$y(e,o,n,{space:"between",axis:"y"}),captureUpdate:Ky.IMMEDIATELY}),keyTest:e=>!e[Xy.CTRL_OR_CMD]&&e.altKey&&e.code===Vy.V,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>jy(Z,{hidden:!Zy(o,n),type:"button",icon:CE,onClick:()=>t(null),title:`${f("labels.distributeVertically")} \u2014 ${N("Alt+V")}`,"aria-label":f("labels.distributeVertically"),visible:Pe(Yy(e),o)})});import{arrayToMap as qy,KEYS as _L,matchKey as DL}from"@excalidraw/common";import{CaptureUpdateAction as RL}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as NL}from"@excalidraw/element/frame";import{arrangeElements as BL}from"@excalidraw/element/arrange";var LL={fitToViewport:!0,animate:!0,duration:200,viewportZoomFactor:.8},Wi=(e,o)=>({smartZoom:{...LL,...o?.smartZoom},arrange:{...e.arrangeConfiguration,...o?.arrange},normalise:{...e.normaliseConfiguration,...o?.normalise}});import{jsx as zL}from"react/jsx-runtime";var FL=(e,o,t)=>{let n=t.scene.getSelectedElements(o),r=qy(e),{arrange:i}=Wi(o,t.props.editorPreferences),a=BL(t.scene,n,r,i.algorithm,i.gap),l=qy(a);return NL(e.map(s=>l.get(s.id)||s),o,t)},OL=tt,lh=F({name:"arrangeElements",label:"labels.arrangeElements",keywords:["arrange","rearrange","spread"],icon:jp,trackEvent:{category:"element"},viewMode:!1,predicate:(e,o,t,n)=>OL(o,n),perform:(e,o,t,n)=>({appState:o,elements:FL(e,o,n),captureUpdate:RL.IMMEDIATELY}),keyTest:e=>e.shiftKey&&DL(e,_L.R),PanelComponent:({updateData:e})=>zL("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:`${f("labels.arrangeElements")} \u2014 ${N("Shift+R")}`,children:jp})});import{arrayToMap as Jy}from"@excalidraw/common";import{CaptureUpdateAction as HL}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as GL}from"@excalidraw/element/frame";import{normaliseElements as UL}from"@excalidraw/element/normalise";import{jsx as VL}from"react/jsx-runtime";var WL=(e,o,t)=>{let n=t.scene.getSelectedElements(o),r=Jy(e),{normalise:i}=Wi(o,t.props.editorPreferences),a=UL(t.scene,n,r,i.mode,i.metric),l=Jy(a);return GL(e.map(s=>l.get(s.id)||s),o,t)},YL=tt,sh=F({name:"normaliseElements",label:"labels.normaliseElements",keywords:["normalize","normalise","scale","size","image"],icon:qp,trackEvent:{category:"element"},viewMode:!1,predicate:(e,o,t,n)=>YL(o,n),perform:(e,o,t,n)=>({appState:o,elements:WL(e,o,n),captureUpdate:HL.IMMEDIATELY}),PanelComponent:({updateData:e})=>VL("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:f("labels.normaliseElements"),children:qp})});import{getNonDeletedElements as XL}from"@excalidraw/element";import{bindOrUnbindBindingElements as KL}from"@excalidraw/element";import{getCommonBoundingBox as Qy}from"@excalidraw/element";import{newElementWith as ZL}from"@excalidraw/element";import{deepCopyElement as $L}from"@excalidraw/element";import{resizeMultipleElements as jL}from"@excalidraw/element";import{isArrowElement as ew,isElbowArrow as qL}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as tw}from"@excalidraw/element";import{CODES as ow,KEYS as JL,arrayToMap as QL}from"@excalidraw/common";import{CaptureUpdateAction as nw}from"@excalidraw/element";var ch=F({name:"flipHorizontal",label:"labels.flipHorizontal",icon:k0,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:tw(rw(e,n.scene.getNonDeletedElementsMap(),o,"horizontal",n),o,n),appState:o,captureUpdate:nw.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===ow.H}),dh=F({name:"flipVertical",label:"labels.flipVertical",icon:C0,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:tw(rw(e,n.scene.getNonDeletedElementsMap(),o,"vertical",n),o,n),appState:o,captureUpdate:nw.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===ow.V&&!e[JL.CTRL_OR_CMD]}),rw=(e,o,t,n,r)=>{let i=ee(XL(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=e_(i,o,n,r),l=QL(a);return e.map(s=>l.get(s.id)||s)},e_=(e,o,t,n)=>{if(e.every(d=>ew(d)&&(d.startBinding||d.endBinding)))return e.map(d=>{let u=d;return ZL(u,{startArrowhead:u.endArrowhead,endArrowhead:u.startArrowhead})});let{midX:r,midY:i}=Qy(e);jL(e,o,"nw",n.scene,new Map(Array.from(o.values()).map(d=>[d.id,$L(d)])),{flipByX:t==="horizontal",flipByY:t==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),KL(e.filter(ew),n.scene,n.state);let{elbowArrows:a,otherElements:l}=e.reduce((d,u)=>qL(u)?{...d,elbowArrows:d.elbowArrows.concat(u)}:{...d,otherElements:d.otherElements.concat(u)},{elbowArrows:[],otherElements:[]}),{midX:s,midY:c}=Qy(e),[m,p]=[r-s,i-c];return l.forEach(d=>n.scene.mutateElement(d,{x:d.x+m,y:d.y+p})),a.forEach(d=>n.scene.mutateElement(d,{x:d.x+m,y:d.y+p})),e};import{isTextElement as t_}from"@excalidraw/element";import{getTextFromElements as o_}from"@excalidraw/element";import{CODES as n_,KEYS as iw,isFirefox as r_}from"@excalidraw/common";import{CaptureUpdateAction as Yt}from"@excalidraw/element";var Yi=F({name:"copy",label:"labels.copy",icon:nl,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await ad(r,n.files,t)}catch(i){return{captureUpdate:Yt.EVENTUALLY,appState:{...o,errorMessage:i.message}}}return{captureUpdate:Yt.EVENTUALLY}},keyTest:void 0}),mh=F({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r;try{r=await Ty()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),r_?{captureUpdate:Yt.EVENTUALLY,appState:{...o,errorMessage:f("hints.firefox_clipboard_write")}}:{captureUpdate:Yt.EVENTUALLY,appState:{...o,errorMessage:f("errors.asyncPasteFailedOnRead")}})}try{n.pasteFromClipboard(vy({types:r}))}catch(i){return console.error(i),{captureUpdate:Yt.EVENTUALLY,appState:{...o,errorMessage:f("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:Yt.EVENTUALLY}},keyTest:void 0}),Ed=F({name:"cut",label:"labels.cut",icon:u0,trackEvent:{category:"element"},perform:(e,o,t,n)=>(Yi.perform(e,o,t,n),ml.perform(e,o,null,n)),keyTest:e=>e[iw.CTRL_OR_CMD]&&e.key===iw.X}),i_=F({name:"copyAsSvg",label:"labels.copyAsSvg",icon:P0,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{if(!n.canvas)return{captureUpdate:Yt.EVENTUALLY};let{exportedElements:r,exportingFrame:i}=Mr(e,o,!0);try{await Ar("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:f("toast.copyToClipboardAsSvg",{exportSelection:a.length?f("toast.selection"):f("toast.canvas"),exportColorScheme:o.exportWithDarkMode?f("buttons.darkMode"):f("buttons.lightMode")})}},captureUpdate:Yt.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:Yt.EVENTUALLY}}},predicate:e=>id&&e.length>0,keywords:["svg","clipboard","copy"]}),a_=F({name:"copyAsPng",label:"labels.copyAsPng",icon:M0,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{if(!n.canvas)return{captureUpdate:Yt.EVENTUALLY};let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=Mr(e,o,!0);try{return await Ar("clipboard",i,o,n.files,{...o,exportingFrame:a,name:n.getName()}),{appState:{...o,toast:{message:f("toast.copyToClipboardAsPng",{exportSelection:r.length?f("toast.selection"):f("toast.canvas"),exportColorScheme:o.exportWithDarkMode?f("buttons.darkMode"):f("buttons.lightMode")})}},captureUpdate:Yt.EVENTUALLY}}catch(l){return console.error(l),{appState:{...o,errorMessage:l.message},captureUpdate:Yt.EVENTUALLY}}},predicate:e=>Vn&&e.length>0,keyTest:e=>e.code===n_.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),xd=F({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});try{xo(o_(r))}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return{captureUpdate:Yt.EVENTUALLY}},predicate:(e,o,t,n)=>id&&n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}).some(t_),keywords:["text","clipboard","copy"]});import{CODES as l_,KEYS as s_}from"@excalidraw/common";import{CaptureUpdateAction as c_}from"@excalidraw/element";var Vi=F({name:"gridMode",icon:D0,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:c_.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[s_.CTRL_OR_CMD]&&e.code===l_.QUOTE});import{CaptureUpdateAction as d_}from"@excalidraw/element";var _l=F({name:"zenMode",label:"buttons.zenMode",icon:L0,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,o){return{appState:{...o,zenModeEnabled:!this.checked(o)},captureUpdate:d_.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,o,t,n)=>n.editorInterface.formFactor!=="phone"&&typeof t.zenModeEnabled>"u"});import{CODES as m_,KEYS as p_}from"@excalidraw/common";import{CaptureUpdateAction as u_}from"@excalidraw/element";var Dl=F({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:A0,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,o){return{appState:{...o,objectsSnapModeEnabled:!this.checked(o),gridModeEnabled:!1},captureUpdate:u_.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,o,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[p_.CTRL_OR_CMD]&&e.altKey&&e.code===m_.S});import{CaptureUpdateAction as h_}from"@excalidraw/element";var Rl=F({name:"arrowBinding",label:"labels.arrowBinding",viewMode:!1,trackEvent:{category:"canvas",predicate:e=>e.bindingPreference==="disabled"},perform(e,o){let t=o.bindingPreference==="enabled"?"disabled":"enabled";return{appState:{...o,bindingPreference:t,isBindingEnabled:t==="enabled"},captureUpdate:h_.NEVER}},checked:e=>e.bindingPreference==="enabled"});import{CaptureUpdateAction as g_}from"@excalidraw/element";var Nl=F({name:"midpointSnapping",label:"labels.midpointSnapping",viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.isMidpointSnappingEnabled},perform(e,o){return{appState:{...o,isMidpointSnappingEnabled:!this.checked(o)},captureUpdate:g_.NEVER}},checked:e=>e.isMidpointSnappingEnabled});import{CODES as f_,KEYS as b_}from"@excalidraw/common";import{CaptureUpdateAction as E_}from"@excalidraw/element";var Kn=F({name:"stats",label:"stats.fullTitle",icon:S0,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,o){return{appState:{...o,stats:{...o.stats,open:!this.checked(o)}},captureUpdate:E_.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[b_.CTRL_OR_CMD]&&e.altKey&&e.code===f_.SLASH});import{BOUND_TEXT_PADDING as aw,ROUNDNESS as lw,TEXT_ALIGN as dw,VERTICAL_ALIGN as mw,arrayToMap as pw,getFontString as x_}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as y_,isBoundToContainer as sw,resetOriginalContainerCache as w_,updateOriginalContainerCache as v_}from"@excalidraw/element";import{computeBoundTextPosition as I_,computeContainerDimensionForBoundText as cw,getBoundTextElement as uw,redrawTextBoundingBox as hw}from"@excalidraw/element";import{hasBoundTextElement as T_,isArrowElement as S_,isTextBindableContainer as ph,isTextElement as Bl,isUsingAdaptiveRadius as C_}from"@excalidraw/element";import{measureText as k_}from"@excalidraw/element";import{syncMovedIndices as gw}from"@excalidraw/element";import{newElement as P_}from"@excalidraw/element";import{CaptureUpdateAction as uh}from"@excalidraw/element";var hh=F({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,o,t,n)=>n.scene.getSelectedElements(o).some(i=>T_(i)),perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i=n.scene.getNonDeletedElementsMap();return r.forEach(a=>{let l=uw(a,i);if(l){let{width:s,height:c}=k_(l.originalText,x_(l),l.lineHeight),m=y_(a.id);w_(a.id);let{x:p,y:d}=I_(a,l,i);n.scene.mutateElement(l,{containerId:null,width:s,height:c,text:l.originalText,x:p,y:d}),n.scene.mutateElement(a,{boundElements:a.boundElements?.filter(u=>u.id!==l.id),height:m||a.height})}}),{elements:e,appState:o,captureUpdate:uh.IMMEDIATELY}}}),gh=F({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=Bl(r[0])||Bl(r[1]),a;if(ph(r[0])?a=r[0]:ph(r[1])&&(a=r[1]),i&&a&&uw(a,n.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i,a;Bl(r[0])&&ph(r[1])?(i=r[0],a=r[1]):(i=r[1],a=r[0]),n.scene.mutateElement(i,{containerId:a.id,verticalAlign:mw.MIDDLE,textAlign:dw.CENTER,autoResize:!0,angle:S_(a)?0:a?.angle??0}),n.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let l=a.height;return hw(i,a,n.scene),v_(a.id,l),{elements:M_(e,a,i),appState:{...o,selectedElementIds:{[a.id]:!0}},captureUpdate:uh.IMMEDIATELY}}}),M_=(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),gw(n,pw([o,t])),n},A_=(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),gw(n,pw([o,t])),n},fw=F({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i=r.some(a=>Bl(a)&&!sw(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(Bl(l)&&!sw(l)){let s=P_({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:C_("rectangle")?lw.ADAPTIVE_RADIUS:lw.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:l.x-aw,y:l.y-aw,width:cw(l.width,"rectangle"),height:cw(l.height,"rectangle"),groupIds:l.groupIds,frameId:l.frameId});if(l.boundElements?.length){let c=l.boundElements.filter(p=>p.type==="arrow").map(p=>p.id);i.filter(p=>c.includes(p.id)).forEach(p=>{let d=p.startBinding,u=p.endBinding;d?.elementId===l.id&&(d={...d,elementId:s.id}),u?.elementId===l.id&&(u={...u,elementId:s.id}),(d||u)&&n.scene.mutateElement(p,{startBinding:d,endBinding:u})})}n.scene.mutateElement(l,{containerId:s.id,verticalAlign:mw.MIDDLE,boundElements:null,textAlign:dw.CENTER,autoResize:!0}),hw(l,s,n.scene),i=A_([...i,s],s,l),a[s.id]=!0}return{elements:i,appState:{...o,selectedElementIds:a},captureUpdate:uh.IMMEDIATELY}}});import{isEmbeddableElement as K_}from"@excalidraw/element";import{KEYS as Cw}from"@excalidraw/common";import{CaptureUpdateAction as Z_}from"@excalidraw/element";import{pointFrom as yw}from"@excalidraw/math";import L_ from"clsx";import{useCallback as bw,useEffect as Ew,useLayoutEffect as __,useRef as D_,useState as R_}from"react";import{EVENT as fh,HYPERLINK_TOOLTIP_DELAY as N_,KEYS as yd}from"@excalidraw/common";import{getElementAbsoluteCoords as wh}from"@excalidraw/element";import{hitElementBoundingBox as B_}from"@excalidraw/element";import{isElementLink as F_}from"@excalidraw/element";import{getEmbedLink as O_,embeddableURLValidator as z_}from"@excalidraw/element";import{sceneCoordsToViewportCoords as ww,viewportCoordsToSceneCoords as H_,wrapEvent as G_,isLocalLink as U_,normalizeLink as bh}from"@excalidraw/common";import{isEmbeddableElement as Eh}from"@excalidraw/element";import{jsx as Xi,jsxs as xw}from"react/jsx-runtime";var vh=380,W_=42,xh=5,vw=85,Y_=500,yh=!1,wd=new Map,Iw=({element:e,scene:o,setAppState:t,onLinkOpen:n,setToast:r,updateEmbedValidationStatus:i})=>{let a=o.getNonDeletedElementsMap(),l=Do(),s=no(),c=pe(),m=e.link||"",[p,d]=R_(m),u=D_(null),b=l.showHyperlinkPopup==="editor",g=bw(()=>{if(!u.current)return;let w=bh(u.current.value)||null;if(!e.link&&w&&ce("hyperlink","create"),Eh(e)){if(l.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!w){o.mutateElement(e,{link:null}),i(e,!1);return}if(!z_(w,s.validateEmbeddable))w&&r({message:f("toast.unableToEmbed"),closable:!0}),e.link&&wd.set(e.id,e.link),o.mutateElement(e,{link:w}),i(e,!1);else{let{width:I,height:C}=e,A=O_(w);A?.error instanceof URIError&&r({message:f("toast.unrecognizedLinkFormat"),closable:!0});let k=A?A.intrinsicSize.w/A.intrinsicSize.h:1,L=wd.get(e.id)!==e.link;o.mutateElement(e,{...L?{width:A?.type==="video"?I>C?I:C*k:I,height:A?.type==="video"&&I>C?I/k:C}:{},link:w}),i(e,!0),wd.has(e.id)&&wd.delete(e.id)}}else o.mutateElement(e,{link:w})},[e,o,r,s.validateEmbeddable,l.activeEmbeddable,t,i]);__(()=>()=>{g()},[g]),Ew(()=>{b&&u?.current&&!(c.formFactor==="phone"||c.isTouchScreen)&&u.current.select()},[b,c.formFactor,c.isTouchScreen]),Ew(()=>{let w=null,I=C=>{if(b)return;w&&clearTimeout(w),X_(e,a,l,yw(C.clientX,C.clientY))&&(w=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},Y_))};return window.addEventListener(fh.POINTER_MOVE,I,!1),()=>{window.removeEventListener(fh.POINTER_MOVE,I,!1),w&&clearTimeout(w)}},[l,e,b,t,a]);let E=bw(()=>{ce("hyperlink","delete"),o.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,o]),y=()=>{ce("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:v,y:x}=Tw(e,l,a);return l.contextMenu||l.selectedElementsAreBeingDragged||l.resizingElement||l.isRotating||l.openMenu||l.viewModeEnabled?null:xw("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${x}px`,left:`${v}px`,width:vh,padding:xh},children:[b?Xi("input",{className:L_("excalidraw-hyperlinkContainer-input"),placeholder:f("labels.link.hint"),ref:u,value:p,onChange:w=>d(w.target.value),autoFocus:!0,onKeyDown:w=>{w.stopPropagation(),w[yd.CTRL_OR_CMD]&&w.key===yd.K&&w.preventDefault(),(w.key===yd.ENTER||w.key===yd.ESCAPE)&&(g(),t({showHyperlinkPopup:"info"}))}}):e.link?Xi("a",{href:bh(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:U_(e.link)?"_self":"_blank",onClick:w=>{if(e.link&&n){let I=G_(fh.EXCALIDRAW_LINK,w.nativeEvent);n({...e,link:bh(e.link)},I),I.defaultPrevented&&w.preventDefault()}},rel:"noopener noreferrer",children:e.link}):Xi("div",{className:"excalidraw-hyperlinkContainer-link",children:f("labels.link.empty")}),xw("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!b&&Xi(Z,{type:"button",title:f("buttons.edit"),"aria-label":f("buttons.edit"),label:f("buttons.edit"),onClick:y,className:"excalidraw-hyperlinkContainer--edit",icon:Ln}),Xi(Z,{type:"button",title:f("labels.linkToElement"),"aria-label":f("labels.linkToElement"),label:f("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:Ic}),m&&!Eh(e)&&Xi(Z,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:E,className:"excalidraw-hyperlinkContainer--remove",icon:ln})]})]})},Tw=(e,o,t)=>{let[n,r]=wh(e,t),{x:i,y:a}=ww({sceneX:n+e.width/2,sceneY:r},o),l=i-o.offsetLeft-vh/2,s=a-o.offsetTop-vw;return{x:l,y:s}},Ih=(e,o)=>{let t=ee(e,o);return Eh(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},Fl=null,Sw=(e,o,t)=>{Fl&&clearTimeout(Fl),Fl=window.setTimeout(()=>V_(e,o,t),N_)},V_=(e,o,t)=>{if(!e.link)return;let n=_i();n.classList.add("excalidraw-tooltip--visible"),n.style.maxWidth="20rem",n.textContent=F_(e.link)?f("labels.link.goToElement"):e.link;let[r,i,a,l]=wh(e,t),[s,c,m,p]=Lb([r,i,a,l],e.angle,o),d=ww({sceneX:s,sceneY:c},o);Uu(n,{left:d.x,top:d.y,width:m,height:p},"top"),ce("hyperlink","tooltip","link-icon"),yh=!0},Th=()=>{Fl&&clearTimeout(Fl),yh&&(yh=!1,_i().classList.remove("excalidraw-tooltip--visible"))},X_=(e,o,t,[n,r])=>{let{x:i,y:a}=H_({clientX:n,clientY:r},t),l=15/t.zoom.value;if(B_(yw(i,a),e,o))return!1;let[s,c,m]=wh(e,o);if(i>=s&&i<=m&&a>=c-vw&&a<=c)return!1;let{x:p,y:d}=Tw(e,t,o);return!(n>=p-l&&n<=p+vh+xh*2+l&&r>=d-l&&r<=d+l+xh*2+W_)};import{jsx as $_}from"react/jsx-runtime";var Ol=F({name:"hyperlink",label:(e,o)=>Ih(e,o),icon:al,perform:(e,o)=>o.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...o,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:Z_.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[Cw.CTRL_OR_CMD]&&e.key===Cw.K,predicate:(e,o)=>ee(e,o).length===1,PanelComponent:({elements:e,appState:o,updateData:t})=>{let n=ee(e,o);return $_(Z,{type:"button",icon:al,"aria-label":f(Ih(e,o)),title:`${K_(e[0])?f("labels.link.labelEmbed"):f("labels.link.label")} - ${N("CtrlOrCmd+K")}`,onClick:()=>t(null),selected:n.length===1&&!!n[0].link})}});import{KEYS as kw,arrayToMap as Ch,randomId as j_}from"@excalidraw/common";import{elementsAreInSameGroup as q_,newElementWith as Pw,selectGroupsFromGivenElements as Mw}from"@excalidraw/element";import{CaptureUpdateAction as Aw}from"@excalidraw/element";var Sh=e=>e.every(o=>!o.locked),zl=F({name:"toggleElementLock",label:(e,o,t)=>{let n=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1});return Sh(n)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,o)=>{let t=ee(o,e);return Sh(t)?Mn:an},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=Sh(r),a=Ch(r),l=r.length>1&&q_(r),c=r.length===1||l?null:j_(),m={...o.lockedMultiSelections};if(i)m={...o.lockedMultiSelections,...c?{[c]:!0}:{}};else if(l){let y=r[0].groupIds.at(-1);delete m[y]}let p=e.map(y=>{if(!a.has(y.id))return y;let v=y.groupIds;return i?c&&(v=[...v,c]):v=v.filter(x=>!o.lockedMultiSelections[x]),Pw(y,{locked:i,groupIds:v.length!==y.groupIds.length?v:y.groupIds})}),d=Ch(p),u=i?{}:Object.fromEntries(r.map(y=>[y.id,!0])),b=r.map(y=>d.get(y.id)||y),g=i?{}:Mw(b,o),E=i?c||(l?r[0].groupIds.at(-1):r[0].id):null;return{elements:p,appState:{...o,selectedElementIds:u,selectedGroupIds:g,selectedLinearElement:i?null:o.selectedLinearElement,lockedMultiSelections:m,activeLockedId:E},captureUpdate:Aw.IMMEDIATELY}},keyTest:(e,o,t,n)=>e.key.toLocaleLowerCase()===kw.L&&e[kw.CTRL_OR_CMD]&&e.shiftKey&&n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}).length>0}),Lw=F({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:an,predicate:(e,o)=>ee(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 Pw(a,{locked:!1,groupIds:a.groupIds.length!==l.length?l:a.groupIds})}return a}),r=Ch(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:Mw(i,o),lockedMultiSelections:{},activeLockedId:null},captureUpdate:Aw.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as LN,isLinearElement as _N,isLineElement as ma}from"@excalidraw/element";import{arrayToMap as DN,invariant as Lg}from"@excalidraw/common";import{toggleLinePolygonState as RN,CaptureUpdateAction as jv}from"@excalidraw/element";import Sv from"clsx";import kR from"fuzzy";import{useEffect as Zd,useRef as Cv,useMemo as PR,useState as Kd}from"react";import{DEFAULT_SIDEBAR as vv,EVENT as jd,KEYS as To,capitalizeString as MR,isWritableElement as AR}from"@excalidraw/common";import{SHAPES as LR}from"@excalidraw/element/shapes";import{CaptureUpdateAction as R7}from"@excalidraw/element";import{useEffect as Wl,useMemo as _w,useRef as Lh,useState as J_}from"react";import{bumpVersion as Hl,getLinearElementSubType as Zi,mutateElement as _h,updateElbowArrowPoints as Q_}from"@excalidraw/element";import{pointFrom as Id,pointRotateRads as e7}from"@excalidraw/math";import{hasBoundTextElement as t7,isArrowBoundToElement as o7,isArrowElement as n7,isElbowArrow as r7,isLinearElement as Bh,isUsingAdaptiveRadius as i7}from"@excalidraw/element";import{getCommonBoundingBox as a7,getElementAbsoluteCoords as l7}from"@excalidraw/element";import{getBoundTextElement as Fw,getBoundTextMaxHeight as s7,getBoundTextMaxWidth as c7,redrawTextBoundingBox as d7}from"@excalidraw/element";import{wrapText as m7}from"@excalidraw/element";import{assertNever as p7,CLASSES as u7,getFontString as kh,isProdEnv as h7,mapFind as g7,reduceToCommonValue as f7,ROUNDNESS as Ph,sceneCoordsToViewportCoords as b7,updateActiveTool as Dw}from"@excalidraw/common";import{measureText as Rw}from"@excalidraw/element";import{LinearElementEditor as E7}from"@excalidraw/element/linearElementEditor";import{newArrowElement as Mh,newElement as x7,newLinearElement as y7}from"@excalidraw/element";import{ShapeCache as w7}from"@excalidraw/element";import{updateBindings as v7}from"@excalidraw/element";import{jsx as Nh}from"react/jsx-runtime";var I7=8,T7=10,Gl=["rectangle","diamond","ellipse"],Ul=["line","sharpArrow","curvedArrow","elbowArrow"],S7=new Set(Gl),C7=new Set(Ul),$i=e=>S7.has(e),Td=e=>e==="arrow"||C7.has(e),wo=_e(null),Yl=new Map,Vl=new Map,k7=({app:e})=>{let o=e.scene.getSelectedElements(e.state),t=Lh(null);return Wl(()=>{if(o.length===0){e.updateEditorAtom(wo,null);return}let n=ji(o);n&&!t.current?t.current=n:(t.current&&!n||t.current&&n!==t.current)&&(e.updateEditorAtom(wo,null),t.current=null)},[o,e]),Wl(()=>()=>{Yl.clear(),Vl.clear()},[]),Nh(P7,{app:e,elements:o})},P7=({app:e,elements:o})=>{let t=ji(o),n=_w(()=>t==="generic"?zw(o):[],[t,o]),r=_w(()=>t==="linear"?Rh(o):[],[t,o]),i=t==="generic"?n.every(p=>p.type===n[0].type):t==="linear"?r.every(p=>Zi(p)===Zi(r[0])):!1,[a,l]=J_({x:0,y:0}),s=Lh(""),c=Lh(null);Wl(()=>{let p=[...n,...r].sort((E,y)=>E.id.localeCompare(y.id)),d=`
5
5
  ${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${p.map(E=>E.id).join(",")}`;if(d===s.current)return;s.current=d;let u;if(p.length===1){let[E,,,y,v,x]=l7(p[0],e.scene.getNonDeletedElementsMap());u=e7(Id(E,y),Id(v,x),p[0].angle)}else{let{minX:E,maxY:y}=a7(p);u=Id(E,y)}let{x:b,y:g}=b7({sceneX:u[0],sceneY:u[1]},e.state);l({x:b,y:g})},[n,r,e.scene,e.state]),Wl(()=>{for(let p of r){let d=Dh(p.id,D7(p));Vl.has(d)||Vl.set(d,p)}},[r]),Wl(()=>{for(let p of n)if(!Yl.has(p.id)){let d=Fw(p,e.scene.getNonDeletedElementsMap());d&&Yl.set(p.id,{fontSize:d.fontSize})}},[n,e.scene]);let m=t==="linear"?[["line",pc],["sharpArrow",bi],["curvedArrow",xi],["elbowArrow",Ei]]:t==="generic"?[["rectangle",cc],["diamond",dc],["ellipse",mc]]:[];return Nh("div",{ref:c,tabIndex:-1,style:{position:"absolute",top:`${a.y+(T7+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-I7}px`,zIndex:2},className:u7.CONVERT_ELEMENT_TYPE_POPUP,children:m.map(([p,d])=>{let u=i&&(t==="generic"&&n[0].type===p||t==="linear"&&Zi(r[0])===p);return Nh(Z,{className:"Shape",type:"radio",icon:d,checked:u,name:"convertElementType-option",title:p,keyBindingLabel:"","aria-label":p,"data-testid":`toolbar-${p}`,onChange:()=>{e.state.activeTool.type!==p&&ce("convertElementType",p,"ui"),Fh(e,{conversionType:t,nextType:p}),c.current?.focus()}},`${o[0].id}${o[0].version}_${p}`)})})},M7=(e,o,t)=>{let n=c7(e,o),r=s7(e,o),i=m7(o.text,kh(o),n),a=Rw(i,kh(o),o.lineHeight),l=o.fontSize;for(;(a.width>n||a.height>r)&&l>0;){l-=1;let s={...o,fontSize:l};a=Rw(o.text,kh(s),o.lineHeight)}_h(o,t.getNonDeletedElementsMap(),{fontSize:l,width:a.width,height:a.height}),d7(o,e,t)},Fh=(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=zw(r),c=l.every(m=>m.type===l[0].type)?Gl.indexOf(l[0].type):-1;if(t=t??Gl[(c+Gl.length+a)%Gl.length],t&&$i(t)){let m={};for(let d of l){let u=Bw(d,t,e);m[u.id]=u}let p=[];for(let d of e.scene.getElementsIncludingDeleted())m[d.id]?p.push(m[d.id]):p.push(d);e.scene.replaceAllElements(p);for(let d of Object.values(m)){let u=Fw(d,e.scene.getNonDeletedElementsMap());u&&(Yl.get(d.id)&&_h(u,e.scene.getNonDeletedElementsMap(),{fontSize:Yl.get(d.id)?.fontSize??u.fontSize}),M7(d,u,e.scene))}e.setState(d=>({selectedElementIds:i,activeTool:Dw(d,{type:"selection"})}))}}if(o==="linear"){let l=Rh(r);if(!t){let c=f7(l,Zi),m=c?Ul.indexOf(c):-1;t=Ul[(m+Ul.length+a)%Ul.length]}if(Td(t)){let c=[],m=e.scene.getElementsMapIncludingDeleted();for(let p of l){let d=Vl.get(Dh(p.id,t));if(d&&Zi(d)===t)m.set(d.id,d),c.push(d);else{let u=Bw(p,t,e);m.set(u.id,u),c.push(u)}}e.scene.replaceAllElements(m);for(let p of c)if(Bh(p))if(r7(p)){let d=A7(p);if(d.length<2)continue;let u=[];for(let g=1;g<d.length-2;g++)u.push({start:d[g],end:d[g+1],index:g+1});let b=Q_(p,e.scene.getNonDeletedElementsMap(),{points:d,fixedSegments:u});_h(p,e.scene.getNonDeletedElementsMap(),{...b,endArrowhead:"arrow"})}else{let d=g7(["line","sharpArrow","curvedArrow"],u=>Vl.get(Dh(p.id,u)));if(d){let u=d.points;e.scene.mutateElement(p,{points:u})}}}let s=Rh(e.scene.getSelectedElements(e.state));e.setState(c=>({selectedElementIds:i,selectedLinearElement:s.length===1?new E7(s[0],e.scene.getNonDeletedElementsMap()):null,activeTool:Dw(c,{type:"selection"})}))}return!0},ji=e=>{if(e.length===0)return null;let o=!1;for(let t of e){if($i(t.type))return"generic";Ow(t)&&(o=!0)}return o?"linear":null},Ow=e=>Bh(e)&&(!n7(e)||!o7(e)&&!t7(e)),Dh=(e,o)=>`${e}:${o}`,zw=e=>e.filter(o=>$i(o.type)),Rh=e=>e.filter(o=>Ow(o)),vd=20,Ki=(e,o)=>e[0]===o[0],Ah=(e,o)=>e[1]===o[1],Nw=(e,o)=>Ki(e,o)?Math.abs(e[1]-o[1]):Math.abs(e[0]-o[0]),A7=e=>{let o=[e.points[0]],t=L7(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])<vd?l[0]=a[0]:Math.abs(l[1]-a[1])<vd&&(l[1]=a[1]),Ki(a,l)||Ah(a,l)||o.push(Id(a[0],l[1])),o.push(l)}let n=[o[0]];for(let i=1;i<o.length-1;++i)Ki(o[i-1],o[i])&&Ki(o[i],o[i+1])||Ah(o[i-1],o[i])&&Ah(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],c=Ki(a,l),m=Ki(l,s);if(c!==m){let p=Nw(a,l),d=Nw(l,s);if(p<vd||d<vd){if(d<p)c?s[0]=a[0]:s[1]=a[1];else if(m)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},L7=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},Bw=(e,o,t)=>{if(!_7(e.type,o)){if(!h7())throw Error(`Invalid conversion from ${e.type} to ${o}.`);return e}if(e.type===o)return e;if(w7.delete(e),$i(o)){let n=Hl(x7({...e,type:o,roundness:o==="diamond"&&e.roundness?{type:i7(o)?Ph.ADAPTIVE_RADIUS:Ph.PROPORTIONAL_RADIUS}:e.roundness}));return v7(n,t.scene,t.state),n}if(Td(o))switch(o){case"line":return Hl(y7({...e,type:"line"}));case"sharpArrow":return Hl(Mh({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return Hl(Mh({...e,type:"arrow",elbowed:!1,roundness:{type:Ph.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return Hl(Mh({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return p7(o,`unhandled conversion type: ${o}`),e},_7=(e,o)=>!!($i(e)&&$i(o)||Td(e)&&Td(o)),D7=e=>Bh(e)?Zi(e):e.type,Hw=k7;var Gw=F({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 ot.set(wo,{type:"panel"}),{captureUpdate:R7.NEVER}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>ji(e)!==null});import{canCreateLinkFromElements as Oh,defaultGetElementLinkFromSelection as N7,getLinkIdAndTypeFromSelection as B7}from"@excalidraw/element";import{CaptureUpdateAction as Xl}from"@excalidraw/element";var Sd=F({name:"copyElementLink",label:"labels.copyElementLink",icon:hi,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r=ee(e,o);try{if(window.location){let i=B7(r,o);return i?(await xo(n.props.generateLinkForSelection?n.props.generateLinkForSelection(i.id,i.type):N7(i.id,i.type)),{appState:{toast:{message:f("toast.elementLinkCopied"),closable:!0}},captureUpdate:Xl.EVENTUALLY}):{appState:o,elements:e,app:n,captureUpdate:Xl.EVENTUALLY}}}catch(i){console.error(i)}return{appState:o,elements:e,app:n,captureUpdate:Xl.EVENTUALLY}},predicate:(e,o)=>Oh(ee(e,o))}),Uw=F({name:"linkToElement",label:"labels.linkToElement",icon:Ic,perform:(e,o,t,n)=>{let r=ee(e,o);return r.length!==1||!Oh(r)?{elements:e,appState:o,app:n,captureUpdate:Xl.EVENTUALLY}:{appState:{...o,openDialog:{name:"elementLinkSelector",sourceElementId:ee(e,o)[0].id}},captureUpdate:Xl.IMMEDIATELY}},predicate:(e,o,t,n)=>{let r=ee(e,o);return o.openDialog?.name!=="elementLinkSelector"&&r.length===1&&Oh(r)},trackEvent:!1});import{isDarwin as Ww}from"@excalidraw/common";var F7={toggleTheme:[N("Shift+Alt+D")],saveScene:[N("CtrlOrCmd+S")],loadScene:[N("CtrlOrCmd+O")],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:[Ww?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")],bringToFront:[Ww?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:[],arrangeElements:[N("Shift+R")],toolLock:[N("Q")]},Se=(e,o=0)=>{let t=F7[e];return t&&t.length>0?t[o]||t[0]:""};var O7="\\u0300-\\u036f",z7="\\ufe20-\\ufe2f",H7="\\u20d0-\\u20ff",G7=O7+z7+H7,U7=`[${G7}]`,W7=RegExp(U7,"g"),Y7=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,V7={\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"},Rr=e=>e.replace(Y7,o=>V7[o]||o).replace(W7,"");import iR from"clsx";import{useEffect as aR,useState as lR}from"react";import{KEYS as sR,queryFocusableElements as tv}from"@excalidraw/common";import{useCallback as X7,useState as K7}from"react";var Yw=()=>{let[e,o]=K7(null),t=X7(n=>o(n),[]);return[e,t]};import{useState as Z2,useCallback as ag,useMemo as $2,useEffect as lg,memo as j2,useRef as VD}from"react";import{LIBRARY_DISABLED_TYPES as XD,randomId as KD,isShallowEqual as ZD,KEYS as $D,isWritableElement as jD,addEventListener as qD,EVENT as JD,CLASSES as V2}from"@excalidraw/common";import{useEffect as Zw,useRef as $w}from"react";import{URL_HASH_KEYS as Gh,URL_QUERY_KEYS as Uh,APP_NAME as jw,EVENT as kd,DEFAULT_SIDEBAR as q7,LIBRARY_SIDEBAR_TAB as J7,arrayToMap as Wh,cloneJSON as Q7,preventUnload as e8,promiseTry as qw,resolvablePromise as t8,toValidURL as o8,Queue as n8,Emitter as r8}from"@excalidraw/common";import{hashElementsVersion as i8,hashString as a8}from"@excalidraw/element";import{getCommonBoundingBox as Hh}from"@excalidraw/element";import{MIME_TYPES as Nr}from"@excalidraw/common";var qi=({elements:e,appState:o,files:t,maxWidthOrHeight:n,getDimensions:r,exportPadding:i,exportingFrame:a})=>{let l=wr(e,null,{deleteInvisibleElements:!0}),s=li(o,null),{exportBackground:c,viewBackgroundColor:m}=s;return ec(l,{...s,offsetTop:0,offsetLeft:0,width:0,height:0},t||{},{exportBackground:c,exportPadding:i,viewBackgroundColor:m,exportingFrame:a},(p,d)=>{let u=document.createElement("canvas");if(n){typeof r=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let g=Math.max(p,d),E=n<g?n/g:o?.exportScale??1;return u.width=p*E,u.height=d*E,{canvas:u,scale:E}}let b=r?.(p,d)||{width:p,height:d};return u.width=b.width,u.height=b.height,{canvas:u,scale:b.scale??1}})},Vw=async e=>{let{mimeType:o=Nr.png,quality:t}=e;o===Nr.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${Nr.png}" mimeType`),o==="image/jpg"&&(o=Nr.jpg),o===Nr.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${Nr.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let n=await qi(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===Nr.png&&e.appState?.exportEmbedScene&&(a=await Bb({blob:a,metadata:Ja(e.elements,e.appState,e.files||{},"local")})),r(a)},o,t)})},Ji=async({elements:e,appState:o=Pn(),files:t={},exportPadding:n,renderEmbeddables:r,exportingFrame:i,skipInliningFonts:a,reuseImages:l})=>{let s=wr(e,null,{deleteInvisibleElements:!0}),m={...li(o,null),exportPadding:n};return yr(s,m,t,{exportingFrame:i,renderEmbeddables:r,skipInliningFonts:a,reuseImages:l})},Z7=async e=>{if(e.type==="svg"){let o=await Ji(e);await xo(o.outerHTML)}else if(e.type==="png")await sd(Vw(e));else if(e.type==="json")await ad(e.elements,e.files);else throw new Error("Invalid export type")};import{useEffect as Xw,useState as $7}from"react";import{COLOR_PALETTE as j7}from"@excalidraw/common";var zh=_e(new Map),Kw=async e=>await Ji({elements:e,appState:{exportBackground:!1,viewBackgroundColor:j7.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),Cd=(e,o,t,n)=>{let[r,i]=$7();return Xw(()=>{if(o)if(e){let a=t.get(e);a?i(a):(async()=>{let l=await Kw(o);l.querySelector(".style-fonts")?.remove(),l&&(t.set(e,l),i(l))})()}else(async()=>{let a=await Kw(o);i(a)})()},[e,o,t,i]),Xw(()=>{let a=n.current;if(a)return r&&(a.innerHTML=r.outerHTML),()=>{a.innerHTML=""}},[r,n]),r},Qi=()=>{let[e]=fe(zh);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:n=>{n.forEach(r=>e.delete(r))},svgCache:e}};var l8=["excalidraw.com","raw.githubusercontent.com/excalidraw/excalidraw-libraries"],Qw=new r8,pn=_e({status:"loaded",isInitialized:!1,libraryItems:[]}),Kl=e=>Q7(e),s8=(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)),e2=(e,o)=>{let t=[];for(let n of o)s8(e,n)&&t.push(n);return[...t,...e]},t2=(e,o)=>{let t=Wh(o),n={deletedItems:new Map,addedItems:new Map,updatedItems:new Map};for(let i of e)t.has(i.id)||n.deletedItems.set(i.id,i);let r=Wh(e);for(let i of o){let a=r.get(i.id);a?Xh(a)!==Xh(i)&&n.updatedItems.set(i.id,i):n.addedItems.set(i.id,i)}return n},Yh=class{constructor(o){S(this,"currLibraryItems",[]);S(this,"prevLibraryItems",Kl(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)ot.set(pn,o=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:o.isInitialized}));else{ot.set(pn,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let o=this.prevLibraryItems;this.prevLibraryItems=Kl(this.currLibraryItems);let t=Kl(this.currLibraryItems);this.app.props.onLibraryChange?.(t),Qw.trigger(t2(o,t),t)}catch(o){console.error(o)}}});S(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],ot.set(zh,new Map)});S(this,"resetLibrary",()=>this.setLibrary([]));S(this,"getLatestLibrary",()=>new Promise(async o=>{try{let t=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?o(this.getLatestLibrary()):o(Kl(t))}catch{return o(this.currLibraryItems)}}));S(this,"updateLibrary",async({libraryItems:o,prompt:t=!1,merge:n=!1,openLibraryMenu:r=!1,defaultStatus:i="unpublished"})=>(r&&this.app.setState({openSidebar:{name:q7.name,tab:J7}}),this.setLibrary(()=>new Promise(async(a,l)=>{try{let s=await(typeof o=="function"&&!(o instanceof Blob)?o(this.currLibraryItems):o),c;s instanceof Blob?c=await Cp(s,i):c=tl(s,i),!t||window.confirm(f("alerts.confirmAddLibrary",{numShapes:c.length}))?(t&&this.app.focusContainer(),a(n?e2(this.currLibraryItems,c):c)):l(new ii)}catch(s){l(s)}}))));S(this,"setLibrary",o=>{let t=new Promise(async(n,r)=>{try{await this.getLastUpdateTask(),typeof o=="function"&&(o=o(this.currLibraryItems)),this.currLibraryItems=Kl(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}},o2=Yh,ta=e=>{let t=Math.ceil(Math.sqrt(e.length)),n=[],r=u=>e.slice(u*t,u*t+t).reduce((g,E)=>{let{height:y}=Hh(E.elements);return Math.max(g,y)},0),i=u=>{let b=0,g=0,E=0;for(let y of e){if(b%t===0&&(g=0),g===u){let{width:v}=Hh(y.elements);E=Math.max(E,v)}b++,g++}return E},a=0,l=0,s=0,c=0,m=0,p=0,d=0;for(let u of e){m&&m%t===0&&(l+=s+50,a=0,p=0,d++),p===0&&(s=r(d)),c=i(p);let{minX:b,minY:g,width:E,height:y}=Hh(u.elements),v=(c-E)/2,x=(s-y)/2;n.push(...u.elements.map(w=>({...w,x:w.x+a+v-b,y:w.y+l+x-g}))),a+=c+50,m++,p++}return n},c8=(e,o=l8)=>{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}"`)},Vh=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(Gh.addLibrary)||new URLSearchParams(window.location.search).get(Uh.addLibrary),o=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:o}:null},Zn=class Zn{constructor(o){S(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(tl(l?.libraryItems||[],"published"))}catch(l){a(l)}});return n?Zn.queue.push(r):r()}getLibraryItems(o){return Zn.getLibraryItems(this.adapter,o,!1)}};S(Zn,"queue",new n8),S(Zn,"run",async(o,t)=>{let n=new Zn(o);return Zn.queue.push(()=>t(n))});var ea=Zn,Zl=0,Pd=0,Xh=e=>`${e.id}:${e.name||""}:${i8(e.elements)}`,Md=e=>a8(e.map(o=>Xh(o)).sort().join()),Jw=async(e,o)=>{try{return Pd++,await ea.run(e,async t=>{let n=Wh(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);if(o.updatedItems)for(let[l,s]of o.updatedItems)n.set(l,s);let i=r.concat(Array.from(n.values())),a=Md(i);return a!==Zl&&await e.save({libraryItems:i}),Zl=a,i})}finally{Pd--}},d8=e=>{let{excalidrawAPI:o}=e,t=$w(e);t.current=e;let n=$w(!1);Zw(()=>{if(!o)return;n.current=!1;let r=async({libraryUrl:l,idToken:s})=>{let c=new Promise(async(p,d)=>{try{l=decodeURIComponent(l),l=o8(l),c8(l,t.current.validateLibraryUrl);let b=await(await fetch(l)).blob();p(b)}catch(u){d(u)}}),m=s!==o.id;await(m&&document.hidden?new Promise(p=>{window.addEventListener("focus",()=>p(),{once:!0})}):null);try{await o.updateLibrary({libraryItems:c,prompt:m,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(p){throw o.updateScene({appState:{errorMessage:p.message}}),p}finally{if(window.location.hash.includes(Gh.addLibrary)){let p=new URLSearchParams(window.location.hash.slice(1));p.delete(Gh.addLibrary),window.history.replaceState({},jw,`#${p.toString()}`)}else if(window.location.search.includes(Uh.addLibrary)){let p=new URLSearchParams(window.location.search);p.delete(Uh.addLibrary),window.history.replaceState({},jw,`?${p.toString()}`)}}},i=l=>{l.preventDefault();let s=Vh();s&&(l.stopImmediatePropagation(),window.history.replaceState({},"",l.oldURL),r(s))},a=Vh();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,c=t8();s?c.resolve(qw(s.load).then(async m=>{let p=null;try{if(!m)return ea.getLibraryItems(l,"load");p=tl(m.libraryItems||[],"published");let d=await Jw(l,t2([],p));try{await s.clear()}catch(u){console.error(`couldn't delete legacy library data: ${u.message}`)}return d}catch(d){return console.error(`couldn't migrate legacy library data: ${d.message}`),p}}).catch(m=>(console.error(`error during library migration: ${m.message}`),ea.getLibraryItems(l,"load")))):c.resolve(qw(ea.getLibraryItems,l,"load")),o.updateLibrary({libraryItems:c.then(m=>{let p=m||[];return Zl=Md(p),p}),merge:!0}).finally(()=>{n.current=!0})}return window.addEventListener(kd.HASHCHANGE,i),()=>{window.removeEventListener(kd.HASHCHANGE,i)}},[o]),Zw(()=>{let r=Qw.on(async(a,l)=>{let s=n.current,c="adapter"in t.current&&t.current.adapter||null;try{c&&Zl!==Md(l)&&await Jw(c,a)}catch(m){console.error(`couldn't persist library update: ${m.message}`,a),s&&t.current.excalidrawAPI&&t.current.excalidrawAPI.updateScene({appState:{errorMessage:f("errors.saveLibraryError")}})}}),i=a=>{Pd&&e8(a)};return window.addEventListener(kd.BEFORE_UNLOAD,i),()=>{window.removeEventListener(kd.BEFORE_UNLOAD,i),r(),Zl=0,Pd=0}},[])};import h8 from"clsx";import{VERSIONS as m8}from"@excalidraw/common";import{jsx as u8}from"react/jsx-runtime";var p8=({theme:e,id:o,libraryReturnUrl:t})=>{let n=t||window.location.origin+window.location.pathname;return u8("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=${m8.excalidrawLibrary}`,target:"_excalidraw_libraries",children:f("labels.libraries")})},n2=p8;import{jsx as g8,jsxs as f8}from"react/jsx-runtime";var Ad=({libraryReturnUrl:e,theme:o,id:t,style:n,children:r,className:i})=>f8("div",{className:h8("library-menu-control-buttons",i),style:n,children:[g8(n2,{id:t,libraryReturnUrl:e,theme:o}),r]});import{useCallback as ra,useEffect as og,useMemo as ng,useRef as U2,useState as W2}from"react";import{MIME_TYPES as OD,arrayToMap as zD,nextAnimationFrame as HD}from"@excalidraw/common";import{duplicateElements as GD}from"@excalidraw/element";import UD from"clsx";import b8 from"lodash.throttle";import{useEffect as E8}from"react";var x8=_e(0),r2=e=>{let[o,t]=fe(x8);return E8(()=>{let{current:n}=e;if(!n)return;let r=b8(()=>{let{scrollTop:i}=n;t(i)},200);return n.addEventListener("scroll",r),()=>{r.cancel(),n.removeEventListener("scroll",r)}},[e,t]),o};import hD from"clsx";import{useCallback as gD,useState as Qh}from"react";import{muteFSAbortError as fD}from"@excalidraw/common";import{flushSync as i2}from"react-dom";import y8 from"clsx";import{jsx as Ld,jsxs as v8}from"react/jsx-runtime";var w8=({label:e,onClick:o,className:t,children:n,actionType:r,type:i="button",isLoading:a,...l})=>{let s=r?`Dialog__action-button--${r}`:"";return v8("button",{className:y8("Dialog__action-button",s,t),type:i,"aria-label":e,onClick:o,...l,children:[n&&Ld("div",{style:a?{visibility:"hidden"}:{},children:n}),Ld("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&Ld("div",{style:{position:"absolute",inset:0},children:Ld(Ut,{})})]})},un=w8;import{jsx as a2,jsxs as l2}from"react/jsx-runtime";var I8=e=>{let{onConfirm:o,onCancel:t,children:n,confirmText:r=f("buttons.confirm"),cancelText:i=f("buttons.cancel"),className:a="",...l}=e,s=be(),c=si(oa),{container:m}=Ne();return l2(qe,{onCloseRequest:t,size:"small",...l,className:`confirm-dialog ${a}`,children:[n,l2("div",{className:"confirm-dialog-buttons",children:[a2(un,{label:i,onClick:()=>{s({openMenu:null}),c(!1),i2(()=>{t()}),m?.focus()}}),a2(un,{label:r,onClick:()=>{s({openMenu:null}),c(!1),i2(()=>{o()}),m?.focus()},actionType:"danger"})]})]})},s2=I8;import{useCallback as A8,useEffect as $h,useRef as c2,useState as Kh}from"react";import{EDITOR_LS_KEYS as Zh,EXPORT_DATA_TYPES as L8,MIME_TYPES as d2,VERSIONS as _8,chunk as D8,getExportSource as R8}from"@excalidraw/common";var $n=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}}};S($n,"set",(o,t)=>{try{return window.localStorage.setItem(o,JSON.stringify(t)),!0}catch(n){return console.warn(`localStorage.setItem error: ${n.message}`),!1}}),S($n,"delete",o=>{try{window.localStorage.removeItem(o)}catch(t){console.warn(`localStorage.removeItem error: ${t.message}`)}});import _d from"react";var T8=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,S8=/{{([\w-]+)}}/,C8=/<([\w-]+)>/,k8=/<\/([\w-]+)>/,P8=(e,o)=>{let t=[{name:"",children:[]}];return e.split(T8).filter(Boolean).forEach(n=>{let r=n.match(C8),i=n.match(k8),a=n.match(S8);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(),c=_d.createElement(_d.Fragment,{},...s.children),m=o[s.name];typeof m=="function"&&t[t.length-1].children.push(m(c))}else console.warn(`Trans: unexpected end tag ${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},M8=({i18nKey:e,children:o,...t})=>{let{t:n}=Me();return _d.createElement(_d.Fragment,{},...P8(n(e),t))},Vt=M8;import{jsx as ue,jsxs as ft}from"react/jsx-runtime";var N8=async(e,o)=>{let r=Math.round(8),i=Math.max(Math.round(128/64),2),a=D8(e,6),l=document.createElement("canvas");l.width=a[0].length*128+(a[0].length+1)*(r*2)-r*2,l.height=a.length*128+(a.length+1)*(r*2)-r*2;let s=l.getContext("2d");s.fillStyle="#fff",s.fillRect(0,0,l.width,l.height);for(let[c,m]of e.entries()){let p=await qi({elements:m.elements,files:null,maxWidthOrHeight:128}),{width:d,height:u}=p,b=Math.floor(c/6)*(128+r*2),g=c%6*(128+r*2);s.drawImage(p,g+(128-d)/2+r,b+(128-u)/2+r),s.lineWidth=i,s.strokeStyle="#ced4da",s.strokeRect(g+r/2,b+r/2,128+r,128+r)}return await o(new File([await vr(l)],"preview",{type:d2.png}),{outputType:d2.jpg,maxWidthOrHeight:5e3})},B8=({libItem:e,appState:o,index:t,onChange:n,onRemove:r})=>{let i=c2(null),a=c2(null);return $h(()=>{let l=i.current;l&&(async()=>{let s=await Ji({elements:e.elements,appState:{...o,viewBackgroundColor:"#fff",exportBackground:!0},files:null,skipInliningFonts:!0});l.innerHTML=s.outerHTML})()},[e.elements,o]),ft("div",{className:"single-library-item",children:[e.status==="published"&&ue("span",{className:"single-library-item-status",children:f("labels.statusPublished")}),ue("div",{ref:i,className:"single-library-item__svg"}),ue(Z,{"aria-label":f("buttons.remove"),type:"button",icon:Qt,className:"single-library-item--remove",onClick:r.bind(null,e.id),title:f("buttons.remove")}),ft("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[ft("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[ft("div",{style:{padding:"0.5em 0"},children:[ue("span",{style:{fontWeight:500,color:"#868e96"},children:f("publishDialog.itemName")}),ue("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ue("input",{type:"text",ref:a,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:l=>{n(l.target.value,t)}})]}),ue("span",{className:"error",children:e.error})]})]})},F8=({onClose:e,libraryItems:o,appState:t,onSuccess:n,onError:r,updateItemsInStorage:i,onRemove:a,compressImageFile:l})=>{let[s,c]=Kh({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[m,p]=Kh(!1);$h(()=>{let w=$n.get(Zh.PUBLISH_LIBRARY);w&&c(w)},[]);let[d,u]=Kh(o.slice());$h(()=>{u(o.slice())},[o]);let b=w=>{c({...s,[w.target.name]:w.target.value})},g=async w=>{w.preventDefault(),p(!0);let I=[],C=!1;if(d.forEach(D=>{let z="";D.name||(z=f("publishDialog.errors.required"),C=!0),I.push({...D,error:z})}),C){u(I),p(!1);return}let A=await N8(d,l),k={type:L8.excalidrawLibrary,version:_8.excalidrawLibrary,source:R8(),libraryItems:d},L=JSON.stringify(k,null,2),_=new Blob([L],{type:"application/json"}),M=new FormData;M.append("excalidrawLib",_),M.append("previewImage",A),M.append("previewImageType",A.type),M.append("title",s.name),M.append("authorName",s.authorName),M.append("githubHandle",s.githubHandle),M.append("name",s.name),M.append("description",s.description),M.append("twitterHandle",s.twitterHandle),M.append("website",s.website),fetch(`${T.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:M}).then(D=>D.ok?D.json().then(({url:z})=>{$n.delete(Zh.PUBLISH_LIBRARY),n({url:z,authorName:s.authorName,items:d})}):D.json().catch(()=>{throw new Error(D.statusText||"something went wrong")}).then(z=>{throw new Error(z.message||D.statusText||"something went wrong")}),D=>{console.error(D),r(D),p(!1)}).catch(D=>{console.error(D),r(D),p(!1)})},E=()=>{let w=[];return d.forEach((I,C)=>{w.push(ue("div",{className:"single-library-item-wrapper",children:ue(B8,{libItem:I,appState:t,index:C,onChange:(A,k)=>{let L=d.slice();L[k].name=A,u(L)},onRemove:a})},C))}),ue("div",{className:"selected-library-items",children:w})},y=A8(()=>{i(d),$n.set(Zh.PUBLISH_LIBRARY,s),e()},[d,e,i,s]),v=!!o.length,x=o.some(w=>w.status==="published");return ue(qe,{onCloseRequest:y,title:f("publishDialog.title"),className:"publish-library",children:v?ft("form",{onSubmit:g,children:[ue("div",{className:"publish-library-note",children:ue(Vt,{i18nKey:"publishDialog.noteDescription",link:w=>ue("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener",children:w})})}),ue("span",{className:"publish-library-note",children:ue(Vt,{i18nKey:"publishDialog.noteGuidelines",link:w=>ue("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:w})})}),ue("div",{className:"publish-library-note",children:f("publishDialog.noteItems")}),x&&ue("span",{className:"publish-library-note publish-library-warning",children:f("publishDialog.republishWarning")}),E(),ft("div",{className:"publish-library__fields",children:[ft("label",{children:[ft("div",{children:[ue("span",{children:f("publishDialog.libraryName")}),ue("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ue("input",{type:"text",name:"name",required:!0,value:s.name,onChange:b,placeholder:f("publishDialog.placeholder.libraryName")})]}),ft("label",{style:{alignItems:"flex-start"},children:[ft("div",{children:[ue("span",{children:f("publishDialog.libraryDesc")}),ue("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ue("textarea",{name:"description",rows:4,required:!0,value:s.description,onChange:b,placeholder:f("publishDialog.placeholder.libraryDesc")})]}),ft("label",{children:[ft("div",{children:[ue("span",{children:f("publishDialog.authorName")}),ue("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ue("input",{type:"text",name:"authorName",required:!0,value:s.authorName,onChange:b,placeholder:f("publishDialog.placeholder.authorName")})]}),ft("label",{children:[ue("span",{children:f("publishDialog.githubUsername")}),ue("input",{type:"text",name:"githubHandle",value:s.githubHandle,onChange:b,placeholder:f("publishDialog.placeholder.githubHandle")})]}),ft("label",{children:[ue("span",{children:f("publishDialog.twitterUsername")}),ue("input",{type:"text",name:"twitterHandle",value:s.twitterHandle,onChange:b,placeholder:f("publishDialog.placeholder.twitterHandle")})]}),ft("label",{children:[ue("span",{children:f("publishDialog.website")}),ue("input",{type:"text",name:"website",pattern:"https?://.+",title:f("publishDialog.errors.website"),value:s.website,onChange:b,placeholder:f("publishDialog.placeholder.website")})]}),ue("span",{className:"publish-library-note",children:ue(Vt,{i18nKey:"publishDialog.noteLicense",link:w=>ue("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:w})})})]}),ft("div",{className:"publish-library__buttons",children:[ue(un,{label:f("buttons.saveLibNames"),onClick:y,"data-testid":"cancel-clear-canvas-button"}),ue(un,{type:"submit",label:f("buttons.submit"),actionType:"primary",isLoading:m})]})]}):ue("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:f("publishDialog.atleastOneLibItem")})})},m2=F8;import N2 from"react";import{DropdownMenu as dD}from"radix-ui";import{CLASSES as mD}from"@excalidraw/common";import H8 from"clsx";import{useCallback as G8,useEffect as U8,useRef as W8}from"react";import{CLASSES as Y8,EVENT as g2,KEYS as V8}from"@excalidraw/common";import{DropdownMenu as X8}from"radix-ui";import{forwardRef as p2}from"react";import u2 from"clsx";import{jsx as h2}from"react/jsx-runtime";var O8=p2(({children:e,gap:o,align:t,justifyContent:n,className:r,style:i},a)=>h2("div",{className:u2("Stack Stack_horizontal",r),style:{"--gap":o,alignItems:t,justifyContent:n,...i},ref:a,children:e})),z8=p2(({children:e,gap:o,align:t,justifyContent:n,className:r,style:i},a)=>h2("div",{className:u2("Stack Stack_vertical",r),style:{"--gap":o,justifyItems:t,justifyContent:n,...i},ref:a,children:e})),bt={Row:O8,Col:z8};import{jsx as Dd}from"react/jsx-runtime";var f2=({children:e,onClickOutside:o,className:t="",onSelect:n,open:r=!0,align:i="end",style:a})=>{let l=pe(),s=W8(null),c=Rn({onClickOutside:o});Ii(s,G8(p=>{s.current?.closest(`.${Y8.DROPDOWN_MENU_EVENT_WRAPPER}`)?.contains(p.target)||c.onClickOutside?.()},[c])),U8(()=>{if(!r)return;let p=u=>{u.key===V8.ESCAPE&&(u.stopImmediatePropagation(),c.onClickOutside?.())},d={capture:!0};return document.addEventListener(g2.KEYDOWN,p,d),()=>{document.removeEventListener(g2.KEYDOWN,p,d)}},[c,r]);let m=H8(`dropdown-menu ${t}`,{"dropdown-menu--mobile":l.formFactor==="phone"}).trim();return Dd(Tu.Provider,{value:{onSelect:n},children:Dd(X8.Content,{ref:s,className:m,style:a,"data-testid":"dropdown-menu",align:i,sideOffset:8,onCloseAutoFocus:p=>p.preventDefault(),children:l.formFactor==="phone"?Dd(bt.Col,{className:"dropdown-menu-container",children:e}):Dd(We,{className:"dropdown-menu-container",padding:2,children:e})})})};f2.displayName="DropdownMenuContent";var b2=f2;import{jsx as Z8}from"react/jsx-runtime";var K8=({children:e,className:o="",selected:t,...n})=>Z8("div",{...n,className:`dropdown-menu-item-base dropdown-menu-item-custom ${o} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),E2=K8;import{DropdownMenu as $8}from"radix-ui";import{jsx as jh}from"react/jsx-runtime";var x2=({icon:e,shortcut:o,href:t,children:n,onSelect:r,className:i="",selected:a,rel:l="noopener",...s})=>{let c=Uc(r);return jh($8.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:jh("a",{...s,href:t,target:"_blank",rel:`noopener ${l}`,className:Hn(i,a),title:s.title??s["aria-label"],children:jh(Gn,{icon:e,shortcut:o,children:n})})})},na=x2;x2.displayName="DropdownMenuItemLink";import{jsx as j8}from"react/jsx-runtime";var y2=()=>j8("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:"6px 0",flex:"0 0 auto"}}),w2=y2;y2.displayName="DropdownMenuSeparator";import{DropdownMenu as nD}from"radix-ui";import q8 from"clsx";import{DropdownMenu as J8}from"radix-ui";import{useCallback as Q8,useState as v2}from"react";import{jsx as Jh}from"react/jsx-runtime";var qh=-4,eD=4,I2=({children:e,className:o})=>{let t=pe(),n=q8(`dropdown-menu dropdown-submenu ${o}`,{"dropdown-menu--mobile":t.formFactor==="phone"}).trim(),r=Q8(c=>{if(c){let p=c.closest(".dropdown-menu-container")?.getBoundingClientRect();if(p){let d=c.getBoundingClientRect().width,b=window.innerWidth-p.right;b<d+20&&(a(b-d+qh),s(qh+8))}}},[]),[i,a]=v2(eD),[l,s]=v2(qh);return Jh(J8.SubContent,{className:n,sideOffset:i,alignOffset:l,collisionPadding:8,ref:r,children:t.formFactor==="phone"?Jh(bt.Col,{className:"dropdown-menu-container",children:e}):Jh(We,{className:"dropdown-menu-container",padding:2,style:{zIndex:1},children:e})})},T2=I2;I2.displayName="DropdownMenuSubContent";import{DropdownMenu as tD}from"radix-ui";import{jsx as S2,jsxs as oD}from"react/jsx-runtime";var C2=({children:e,icon:o,shortcut:t,className:n})=>oD(tD.SubTrigger,{className:`${Hn(n)} dropdown-menu__submenu-trigger`,children:[S2(Gn,{icon:o,shortcut:t,children:e}),S2("div",{className:"dropdown-menu__submenu-trigger-icon",children:H0})]}),k2=C2;C2.displayName="DropdownMenuSubTrigger";import P2 from"react";var Rd=e=>o=>{let t=P2.Children.toArray(o).find(n=>P2.isValidElement(n)&&typeof n.type!="string"&&n?.type.displayName&&n.type.displayName===e);return t||null},M2=Rd("DropdownMenuTrigger"),A2=Rd("DropdownMenuContent"),L2=Rd("DropdownMenuSubTrigger"),_2=Rd("DropdownMenuSubContent");import{jsxs as rD}from"react/jsx-runtime";var Nd=({children:e})=>{let o=L2(e),t=_2(e);return rD(nD.Sub,{children:[o,t]})};Nd.Trigger=k2;Nd.Content=T2;Nd.displayName="DropdownMenuSub";var jn=Nd;import iD from"clsx";import{DropdownMenu as aD}from"radix-ui";import{jsx as lD}from"react/jsx-runtime";var D2=({className:e="",children:o,onToggle:t,title:n,...r})=>{let i=pe(),a=iD(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.formFactor==="phone"}).trim();return lD(aD.Trigger,{className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:n,...r,children:o})},R2=D2;D2.displayName="DropdownMenuTrigger";import{jsx as cD}from"react/jsx-runtime";var sD=e=>cD(At,{...e,icon:e.checked?gc:Tc}),vo=sD;import{jsx as uD,jsxs as pD}from"react/jsx-runtime";var Io=({children:e,open:o})=>{let t=M2(e),n=A2(e),r=n&&N2.isValidElement(n)?N2.cloneElement(n,{open:o}):n;return uD(dD.Root,{open:o,modal:!1,children:pD("div",{className:mD.DROPDOWN_MENU_EVENT_WRAPPER,style:{display:"contents"},children:[t,r]})})};Io.Trigger=R2;Io.Content=b2;Io.Item=At;Io.ItemCheckbox=vo;Io.ItemLink=na;Io.ItemCustom=E2;Io.Group=El;Io.Separator=w2;Io.Sub=jn;var we=Io;Io.displayName="DropdownMenu";import{jsx as Rt,jsxs as Bd}from"react/jsx-runtime";var bD=(e,o)=>e.filter(t=>o.includes(t.id)),ED=({setAppState:e,selectedItems:o,library:t,onRemoveFromLibrary:n,resetLibrary:r,onSelectItems:i,appState:a,className:l})=>{let[s]=fe(pn),{compressImageFile:c}=no(),[m,p]=fe(oa),d=()=>{let M=o.length?f("alerts.removeItemsFromsLibrary",{count:o.length}):f("alerts.resetLibrary"),D=o.length?f("confirmDialog.removeItemsFromLib"):f("confirmDialog.resetLibrary");return Rt(s2,{onConfirm:()=>{o.length?n():r(),b(!1)},onCancel:()=>{b(!1)},title:D,children:Rt("p",{children:M})})},[u,b]=Qh(!1),g=!!o.length,E=g?s.libraryItems.filter(M=>o.includes(M.id)):s.libraryItems,y=g?f("buttons.remove"):f("buttons.resetLibrary"),[v,x]=Qh(!1),[w,I]=Qh(null),C=gD(()=>Bd(qe,{onCloseRequest:()=>I(null),title:f("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[Rt("p",{children:Rt(Vt,{i18nKey:"publishSuccessDialog.content",authorName:w.authorName,link:M=>Rt("a",{href:w?.url,target:"_blank",rel:"noopener noreferrer",children:M})})}),Rt(Z,{type:"button",title:f("buttons.close"),"aria-label":f("buttons.close"),label:f("buttons.close"),onClick:()=>I(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[I,w]),A=(M,D)=>{x(!1),I({url:M.url,authorName:M.authorName});let z=D.slice();z.forEach(W=>{o.includes(W.id)&&(W.status="published")}),t.setLibrary(z)},k=async()=>{try{await t.updateLibrary({libraryItems:$s({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(M){if(M?.name==="AbortError"){console.warn(M);return}e({errorMessage:f("errors.importLibraryError")})}},L=async()=>{let M=g?E:await t.getLatestLibrary();Ab(M).catch(fD).catch(D=>{e({errorMessage:D.message})})},_=()=>Bd(we,{open:m,children:[Rt(we.Trigger,{onToggle:()=>p(!m),children:Qb}),Bd(we.Content,{onClickOutside:()=>p(!1),onSelect:()=>p(!1),className:"library-menu",children:[!g&&Rt(we.Item,{onSelect:k,icon:pi,"data-testid":"lib-dropdown--load",children:f("buttons.load")}),!!E.length&&Rt(we.Item,{onSelect:L,icon:Ir,"data-testid":"lib-dropdown--export",children:f("buttons.export")}),g&&Rt(we.Item,{icon:p0,onSelect:()=>x(!0),"data-testid":"lib-dropdown--remove",children:f("buttons.publishLibrary")}),!!E.length&&Rt(we.Item,{onSelect:()=>b(!0),icon:ln,children:y})]})]});return Bd("div",{className:hD("library-menu-dropdown-container",l),children:[_(),o.length>0&&Rt("div",{className:"library-actions-counter",children:o.length}),u&&d(),v&&Rt(m2,{onClose:()=>x(!1),libraryItems:bD(s.libraryItems,o),appState:a,onSuccess:M=>A(M,s.libraryItems),onError:M=>window.alert(M),compressImageFile:c,updateItemsInStorage:()=>t.setLibrary(s.libraryItems),onRemove:M=>i(o.filter(D=>D!==M))}),w&&C()]})},B2=({selectedItems:e,onSelectItems:o,className:t})=>{let{library:n}=je(),{clearLibraryCache:r,deleteItemsFromLibraryCache:i}=Qi(),a=de(),l=be(),[s]=fe(pn),c=async p=>{let d=p.filter(u=>!e.includes(u.id));n.setLibrary(d).catch(()=>{l({errorMessage:f("alerts.errorRemovingFromLibrary")})}),i(e),o([])};return Rt(ED,{appState:a,setAppState:l,selectedItems:e,onSelectItems:o,library:n,onRemoveFromLibrary:()=>c(s.libraryItems),resetLibrary:()=>{n.resetLibrary(),r()},className:t})};import{memo as CD,useEffect as kD,useState as PD}from"react";import xD,{useCallback as yD}from"react";function wD(){return[!1,yD(o=>o(),[])]}var F2=xD.useTransition||wD;import O2 from"clsx";import{memo as vD,useRef as ID,useState as TD}from"react";import{jsx as Fd,jsxs as SD}from"react/jsx-runtime";var z2=vD(({id:e,elements:o,isPending:t,onClick:n,selected:r,onToggle:i,onDrag:a,svgCache:l})=>{let s=ID(null),c=Cd(e,o,l,s),[m,p]=TD(!1),d=pe().formFactor==="phone",u=t&&Fd("div",{className:"library-unit__adder",children:Jb});return SD("div",{className:O2("library-unit",{"library-unit__active":o,"library-unit--hover":o&&m,"library-unit--selected":r,"library-unit--skeleton":!c}),onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),children:[Fd("div",{className:O2("library-unit__dragger",{"library-unit__pulse":!!t}),ref:s,draggable:!!o,onClick:o||t?b=>{e&&b.shiftKey?i(e,b):n(e)}:void 0,onDragStart:b=>{if(!e){b.preventDefault();return}p(!1),a(e,b)}}),u,e&&o&&(m||d||r)&&Fd(Sl,{checked:r,onChange:(b,g)=>i(e,g),className:"library-unit__checkbox"})]})}),H2=()=>Fd("div",{className:"library-unit library-unit--skeleton"});import{Fragment as MD,jsx as Od}from"react/jsx-runtime";var zd=({children:e})=>Od("div",{className:"library-menu-items-container__grid",children:e}),$l=CD(({items:e,onItemSelectToggle:o,onItemDrag:t,isItemSelected:n,onClick:r,svgCache:i,itemsRenderedPerBatch:a})=>{let[,l]=F2(),[s,c]=PD(0);return kD(()=>{s<e.length&&l(()=>{c(s+a)})},[s,e.length,l,a]),Od(MD,{children:e.map((m,p)=>p<s?Od(z2,{elements:m?.elements,isPending:!m?.id&&!!m?.elements,onClick:r,svgCache:i,id:m?.id,selected:n(m.id),onToggle:o,onDrag:t},m?.id??p):Od(H2,{},p))})});import eg from"clsx";import{forwardRef as DD,useRef as RD,useImperativeHandle as ND,useLayoutEffect as BD,useState as FD}from"react";import AD from"clsx";import{composeEventHandlers as LD}from"@excalidraw/common";import{jsx as _D}from"react/jsx-runtime";var Xt=({type:e="button",onSelect:o,selected:t,children:n,className:r="",...i})=>_D("button",{onClick:LD(i.onClick,a=>{o()}),type:e,className:AD("excalidraw-button",r,{selected:t}),...i,children:n});import{jsx as tg,jsxs as G2}from"react/jsx-runtime";var qn=DD(({onChange:e,label:o,fullWidth:t,placeholder:n,readonly:r,selectOnRender:i,onKeyDown:a,isRedacted:l=!1,icon:s,className:c,type:m,...p},d)=>{let u=RD(null);ND(d,()=>u.current),BD(()=>{i&&(u.current?.focus(),u.current?.select())},[i]);let[b,g]=FD(!1);return G2("div",{className:eg("ExcTextField",c,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!s}),onClick:()=>{u.current?.focus()},children:[s,o&&tg("div",{className:"ExcTextField__label",children:o}),G2("div",{className:eg("ExcTextField__input",{"ExcTextField__input--readonly":r}),children:[tg("input",{className:eg({"is-redacted":"value"in p&&p.value&&l&&!b}),readOnly:r,value:"value"in p?p.value:void 0,defaultValue:"defaultValue"in p?p.defaultValue:void 0,placeholder:n,ref:u,onChange:E=>e?.(E.target.value),onKeyDown:a,type:m}),l&&tg(Xt,{onSelect:()=>g(!b),style:{border:0,userSelect:"none"},children:b?y0:Sr})]})]})});import{Fragment as Y2,jsx as rt,jsxs as Go}from"react/jsx-runtime";var WD=17,YD=64;function rg({isLoading:e,libraryItems:o,onAddToLibrary:t,onInsertLibraryItems:n,pendingElements:r,theme:i,id:a,libraryReturnUrl:l,onSelectItems:s,selectedItems:c}){let m=pe(),p=U2(null),d=r2(p);og(()=>{d>0&&p.current?.scrollTo(0,d)},[]);let{svgCache:u}=Qi(),[b,g]=W2(null),[E,y]=W2(""),v=!o.length&&!r.length,x=!v&&!!E.trim(),w=ng(()=>{let Y=Rr(E.trim().toLowerCase());return Y?o.filter(q=>{let ne=q.name||"";return ne.trim()&&Rr(ne.toLowerCase()).includes(Y)}):[]},[o,E]),I=ng(()=>o.filter(Y=>Y.status!=="published"),[o]),C=ng(()=>o.filter(Y=>Y.status==="published"),[o]),A=ra((Y,q)=>{let ne=!c.includes(Y),ae=[...I,...C];if(ne){if(q.shiftKey&&b){let R=ae.findIndex(Le=>Le.id===b),G=ae.findIndex(Le=>Le.id===Y);if(R===-1||G===-1){s([...c,Y]);return}let ie=zD(c),ge=Math.min(R,G),ke=Math.max(R,G),De=ae.reduce((Le,se,Te)=>((Te>=ge&&Te<=ke||ie.has(se.id))&&Le.push(se.id),Le),[]);s(De)}else s([...c,Y]);g(Y)}else g(null),s(c.filter(R=>R!==Y))},[b,s,C,c,I]);og(()=>{c.length||g(null)},[c]);let k=ra(Y=>{let q;return c.includes(Y)?q=o.filter(ne=>c.includes(ne.id)):q=o.filter(ne=>ne.id===Y),q.map(ne=>({...ne,elements:GD({type:"everything",elements:ne.elements,randomizeSeed:!0,preserveFrameChildrenOrder:!0}).duplicatedElements}))},[o,c]),L=ra((Y,q)=>{let ne={itemIds:c.includes(Y)?c:[Y]};q.dataTransfer.setData(OD.excalidrawlibIds,JSON.stringify(ne))},[c]),_=ra(Y=>Y?c.includes(Y):!1,[c]),M=ra(()=>{t(r)},[r,t]),D=ra(Y=>{Y&&n(k(Y))},[k,n]),z=u.size>=(w.length?w:o).length?YD:WD,W=U2(null);og(()=>{HD(()=>{W.current?.focus()})},[]);let O=!x&&Go(Y2,{children:[!v&&rt("div",{className:"library-menu-items-container__header",children:f("labels.personalLib")}),!r.length&&!I.length?Go("div",{className:"library-menu-items__no-items",children:[!C.length&&rt("div",{className:"library-menu-items__no-items__label",children:f("library.noItems")}),rt("div",{className:"library-menu-items__no-items__hint",children:C.length>0?f("library.hint_emptyPrivateLibrary"):f("library.hint_emptyLibrary")})]}):Go(zd,{children:[r.length>0&&rt($l,{itemsRenderedPerBatch:z,items:[{id:null,elements:r}],onItemSelectToggle:A,onItemDrag:L,onClick:M,isItemSelected:_,svgCache:u}),rt($l,{itemsRenderedPerBatch:z,items:I,onItemSelectToggle:A,onItemDrag:L,onClick:D,isItemSelected:_,svgCache:u})]}),C.length>0&&rt("div",{className:"library-menu-items-container__header",style:{marginTop:"0.75rem"},children:f("labels.excalidrawLib")}),C.length>0&&rt(zd,{children:rt($l,{itemsRenderedPerBatch:z,items:C,onItemSelectToggle:A,onItemDrag:L,onClick:D,isItemSelected:_,svgCache:u})})]}),K=x&&Go(Y2,{children:[Go("div",{className:"library-menu-items-container__header",children:[f("library.search.heading"),!e&&Go("div",{className:"library-menu-items-container__header__hint",style:{cursor:"pointer"},onPointerDown:Y=>Y.preventDefault(),onClick:Y=>{y("")},children:[rt("kbd",{children:"esc"})," to clear"]})]}),w.length>0?rt(zd,{children:rt($l,{itemsRenderedPerBatch:z,items:w,onItemSelectToggle:A,onItemDrag:L,onClick:D,isItemSelected:_,svgCache:u})}):Go("div",{className:"library-menu-items__no-items",children:[rt("div",{className:"library-menu-items__no-items__hint",children:f("library.search.noResults")}),rt(Xt,{onPointerDown:Y=>Y.preventDefault(),onSelect:()=>{y("")},style:{width:"auto",marginTop:"1rem"},children:f("library.search.clearSearch")})]})]});return Go("div",{className:"library-menu-items-container",style:r.length||I.length||C.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[Go("div",{className:"library-menu-items-header",children:[!v&&rt(qn,{ref:W,type:"search",className:UD("library-menu-items-container__search",{hideCancelButton:m.formFactor!=="phone"}),placeholder:f("library.search.inputPlaceholder"),value:E,onChange:Y=>y(Y)}),rt(B2,{selectedItems:c,onSelectItems:s,className:"library-menu-dropdown-container--in-heading"})]}),Go(bt.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:C.length>0?1:"0 1 auto",margin:v?"auto":0},ref:p,children:[e&&rt("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:rt(Ut,{})}),O,K,v&&rt(Ad,{style:{padding:"16px 0",width:"100%"},id:a,libraryReturnUrl:l,theme:i})]})]})}import{jsx as Jn,jsxs as K2}from"react/jsx-runtime";var oa=_e(!1),X2=({children:e})=>Jn("div",{className:"layer-ui__library",children:e}),QD=j2(({onInsertLibraryItems:e,pendingElements:o,onAddToLibrary:t,setAppState:n,libraryReturnUrl:r,library:i,id:a,theme:l,selectedItems:s,onSelectItems:c})=>{let[m]=fe(pn),p=ag(b=>{(async(E,y)=>{ce("element","addToLibrary","ui");for(let x of XD)if(E.some(w=>w.type===x))return n({errorMessage:f(`errors.libraryElementTypeError.${x}`)});let v=[{status:"unpublished",elements:E,id:KD(),created:Date.now()},...y];t(),i.setLibrary(v).catch(()=>{n({errorMessage:f("alerts.errorAddingToLibrary")})})})(b,m.libraryItems)},[t,i,n,m.libraryItems]),d=$2(()=>m.libraryItems,[m]);if(m.status==="loading"&&!m.isInitialized)return Jn(X2,{children:Jn("div",{className:"layer-ui__library-message",children:K2("div",{children:[Jn(Ut,{size:"2em"}),Jn("span",{children:f("labels.libraryLoadingMessage")})]})})});let u=m.libraryItems.length>0||o.length>0;return K2(X2,{children:[Jn(rg,{isLoading:m.status==="loading",libraryItems:d,onAddToLibrary:p,onInsertLibraryItems:e,pendingElements:o,id:a,libraryReturnUrl:r,theme:l,onSelectItems:c,selectedItems:s}),u&&Jn(Ad,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:a,libraryReturnUrl:r,theme:l})]})}),ig=(e,o)=>({elements:e,pending:ee(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:o}),eR=(e,o)=>{let t=Fn(),[n,r]=Z2(()=>ig(t,e.selectedElementIds)),i=VD(new Map);return lg(()=>{for(let a of n.pending)i.current.set(a.id,a.version)},[n.pending]),lg(()=>{o.state.cursorButton==="up"&&o.state.activeTool.type==="selection"&&r(a=>{if(!ZD(a.selectedElementIds,e.selectedElementIds))return i.current.clear(),ig(t,e.selectedElementIds);let l=o.scene.getNonDeletedElementsMap();for(let s of Object.keys(e.selectedElementIds)){let c=l.get(s)?.version;if(c&&c!==i.current.get(s))return ig(t,e.selectedElementIds)}return a})},[o,o.state.cursorButton,o.state.activeTool.type,e.selectedElementIds,t]),n.pending},q2=j2(()=>{let e=je(),{onInsertElements:o}=e,t=no(),n=de(),r=be(),[i,a]=Z2([]),l=$2(()=>e.library,[e.library]),s=eR(n,e);lg(()=>qD(document,JD.KEYDOWN,p=>{if(p.key===$D.ESCAPE&&p.target instanceof HTMLElement){let d=p.target;if(d.closest(`.${V2.SIDEBAR}`))i.length>0?(p.stopPropagation(),a([])):jD(d)&&d instanceof HTMLInputElement&&!d.value&&(p.stopPropagation(),r({openSidebar:null}),e.focusContainer());else if(i.length>0){let{x:u,y:b}=e.lastViewportPosition;document.elementFromPoint(u,b)?.closest(`.${V2.SIDEBAR}`)&&(p.stopPropagation(),a([]))}}},{capture:!0}),[i,r,e]);let c=ag(p=>{o(ta(p)),e.focusContainer()},[o,e]),m=ag(()=>{r({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[r]);return Jn(QD,{pendingElements:s,onInsertLibraryItems:c,onAddToLibrary:m,setAppState:r,libraryReturnUrl:t.libraryReturnUrl,library:l,id:e.id,theme:n.theme,selectedItems:i,onSelectItems:a})});import J2 from"clsx";import{useRef as tR}from"react";import{createPortal as oR}from"react-dom";import{KEYS as nR}from"@excalidraw/common";import{jsx as Q2,jsxs as rR}from"react/jsx-runtime";var ev=e=>{let{closeOnClickOutside:o=!0}=e,t=Dc({className:J2("excalidraw-modal-container",e.portalContainerClassName)}),n=tR(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let r=i=>{i.key===nR.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return oR(rR("div",{className:J2("Modal",e.className,{"animations-disabled":n.current}),role:"dialog","aria-modal":"true",onKeyDown:r,"aria-labelledby":e.labelledBy,children:[Q2("div",{className:"Modal__background",onClick:o?e.onCloseRequest:void 0}),Q2("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as Hd,jsxs as ov}from"react/jsx-runtime";function cR(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var qe=e=>{let[o,t]=Yw(),[n]=lR(document.activeElement),{id:r}=Ne(),i=pe().formFactor==="phone";aR(()=>{if(!o)return;let c=tv(o);setTimeout(()=>{c.length>0&&e.autofocus!==!1&&(c[1]||c[0]).focus()});let m=p=>{if(p.key===sR.TAB){let d=tv(o),{activeElement:u}=document,b=d.findIndex(g=>g===u);b===0&&p.shiftKey?(d[d.length-1].focus(),p.preventDefault()):b===d.length-1&&!p.shiftKey&&(d[0].focus(),p.preventDefault())}};return o.addEventListener("keydown",m),()=>o.removeEventListener("keydown",m)},[o,e.autofocus]);let a=be(),l=si(oa),s=()=>{a({openMenu:null}),l(!1),n.focus(),e.onCloseRequest()};return Hd(ev,{className:iR("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:cR(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,portalContainerClassName:e.portalContainerClassName,children:ov(We,{ref:t,children:[e.title&&ov("h2",{id:`${r}-dialog-title`,className:"Dialog__title",children:[Hd("span",{className:"Dialog__titleContent",children:e.title}),e.titleButton]}),i&&Hd("button",{className:"Dialog__close",onClick:s,title:f("buttons.close"),"aria-label":f("buttons.close"),type:"button",children:Qt}),Hd("div",{className:"Dialog__content",children:e.children})]})})};import Uo from"clsx";import{useMemo as ER,useRef as xR,useState as yR}from"react";import{Popover as Qn}from"radix-ui";import{CLASSES as lv,KEYS as wR,capitalizeString as hn,isTransparent as Wd}from"@excalidraw/common";import{shouldAllowVerticalAlign as sv,suppportsHorizontalAlign as cv,hasBoundTextElement as Yd,isElbowArrow as cg,isImageElement as dv,isLinearElement as dg,isTextElement as Xd,isArrowElement as iv,hasStrokeColor as av,toolIsArrow as Vd}from"@excalidraw/element";import{getToolbarTools as vR,SHAPES as IR}from"@excalidraw/element/shapes";import{CODES as dR,KEYS as mR}from"@excalidraw/common";import pR from"clsx";import{CaptureUpdateAction as uR}from"@excalidraw/element";import{jsx as hR}from"react/jsx-runtime";var ia=F({name:"viewMode",label:"labels.viewMode",icon:Sr,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,o){return{appState:{...o,viewModeEnabled:!this.checked(o)},captureUpdate:uR.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,o,t)=>typeof t.viewModeEnabled>"u",keyTest:e=>!e[mR.CTRL_OR_CMD]&&e.altKey&&e.code===dR.R,PanelComponent:({data:e,updateData:o,appState:t})=>hR(Z,{type:"button",icon:Sr,"aria-label":f("labels.viewMode"),onClick:()=>o(null),size:e?.size||"medium","data-testid":"button-view-mode",className:pR({enabled:t.viewModeEnabled})})});import{useEffect as gR,useState as fR}from"react";import nv from"clsx";import{capitalizeString as rv}from"@excalidraw/common";import{Popover as sg}from"radix-ui";import{jsx as Gd,jsxs as bR}from"react/jsx-runtime";var Ud=({app:e,options:o,activeTool:t,defaultOption:n,className:r="Shape",namePrefix:i,title:a,"data-testid":l,onToolChange:s,displayedOption:c,fillable:m=!1})=>{let[p,d]=fR(!1),u=t.type,b=c.type===u,g=32/2+10,{container:E}=Ne();return!o.some(y=>y.type===u)&&p&&d(!1),gR(()=>{let y=e.onPointerDownEmitter.on(()=>{d(!1)});return()=>y?.()},[e]),bR(sg.Root,{open:p,children:[Gd(sg.Trigger,{asChild:!0,children:Gd(Z,{className:nv(r,{fillable:m,active:o.some(y=>y.type===t.type)}),type:"radio",icon:c.icon,checked:b,name:"editor-current-shape",title:a,"aria-label":a,"data-testid":l,onPointerDown:()=>{d(y=>!y),s(n)}})}),Gd(sg.Content,{className:"tool-popover-content",sideOffset:g,collisionBoundary:E??void 0,children:o.map(({type:y,icon:v,title:x})=>Gd(Z,{className:nv(r,{active:u===y}),type:"radio",icon:v,checked:u===y,name:`${i}-option`,title:x||rv(y),keyBindingLabel:"","aria-label":x||rv(y),"data-testid":`toolbar-${y}`,onChange:()=>{e.state.activeTool.type!==y&&ce("toolbar",y,"ui"),e.setActiveTool({type:y}),s?.(y)}},y))})]})};import{Fragment as Kt,jsx as $,jsxs as me}from"react/jsx-runtime";var mg=Uo([lv.SHAPE_ACTIONS_THEME_SCOPE,"properties-content"]),jl=(e,o)=>{let t=o[0]?.type||null;for(let n of o)if(n.type!==t){t=null;break}return av(e.activeTool.type)&&e.activeTool.type!=="image"&&t!=="image"&&t!=="frame"&&t!=="magicframe"||o.some(n=>av(n.type))},ql=(e,o)=>Lo(e.activeTool.type)||o.some(t=>Lo(t.type)),mv=({appState:e,elementsMap:o,renderAction:t,app:n})=>{let r=ni(o,e),i=!1;r.length===2&&(Yd(r[0])||Yd(r[1]))&&(i=!0);let a=!!(e.editingTextElement||e.newElement),l=pe(),s=document.documentElement.getAttribute("dir")==="rtl",c=Lo(e.activeTool.type)&&!Wd(e.currentItemBackgroundColor)||r.some(b=>Lo(b.type)&&!Wd(b.backgroundColor)),m=r.length===1||i,p=!e.selectedLinearElement?.isEditing&&r.length===1&&dg(r[0])&&!cg(r[0]),d=!e.croppingElementId&&r.length===1&&dv(r[0]),u=!i&&tt(e,n);return me("div",{className:"selected-shape-actions",children:[$("div",{children:jl(e,r)&&t("changeStrokeColor")}),ql(e,r)&&$("div",{children:t("changeBackgroundColor")}),c&&t("changeFillStyle"),($a(e.activeTool.type)||r.some(b=>$a(b.type)))&&t("changeStrokeWidth"),(e.activeTool.type==="freedraw"||r.some(b=>b.type==="freedraw"))&&t("changeStrokeShape"),(ja(e.activeTool.type)||r.some(b=>ja(b.type)))&&me(Kt,{children:[t("changeStrokeStyle"),t("changeSloppiness")]}),(qa(e.activeTool.type)||r.some(b=>qa(b.type)))&&$(Kt,{children:t("changeRoundness")}),(Vd(e.activeTool.type)||r.some(b=>Vd(b.type)))&&$(Kt,{children:t("changeArrowType")}),(e.activeTool.type==="text"||r.some(Xd))&&me(Kt,{children:[$("fieldset",{children:t("changeFontFamily")}),t("changeFontSize"),(e.activeTool.type==="text"||cv(r,o))&&t("changeTextAlign")]}),sv(r,o)&&t("changeVerticalAlign"),(ri(e.activeTool.type)||r.some(b=>ri(b.type)))&&$(Kt,{children:t("changeArrowhead")}),t("changeOpacity"),me("fieldset",{children:[$("legend",{children:f("labels.layers")}),me("div",{className:"buttonList",children:[t("sendToBack"),t("sendBackward"),t("bringForward"),t("bringToFront")]})]}),u&&!i&&me("fieldset",{children:[$("legend",{children:f("labels.align")}),me("div",{className:"buttonList",children:[s?me(Kt,{children:[t("alignRight"),t("alignHorizontallyCentered"),t("alignLeft")]}):me(Kt,{children:[t("alignLeft"),t("alignHorizontallyCentered"),t("alignRight")]}),r.length>2&&t("distributeHorizontally"),$("div",{style:{flexBasis:"100%",height:0}}),me("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[t("alignTop"),t("alignVerticallyCentered"),t("alignBottom"),r.length>2&&t("distributeVertically"),$("div",{style:{flexBasis:"100%",height:0}}),t("arrangeElements"),t("normaliseElements")]})]})]}),!a&&r.length>0&&me("fieldset",{children:[$("legend",{children:f("labels.actions")}),me("div",{className:"buttonList",children:[l.formFactor!=="phone"&&t("duplicateSelection"),l.formFactor!=="phone"&&t("deleteSelectedElements"),t("group"),t("ungroup"),m&&t("hyperlink"),d&&t("cropEditor"),p&&t("toggleLinearEditor"),t("smartZoom")]})]})]})},pv=({appState:e,renderAction:o,setAppState:t,targetElements:n,container:r})=>{let i=Lo(e.activeTool.type)&&!Wd(e.currentItemBackgroundColor)||n.some(s=>Lo(s.type)&&!Wd(s.backgroundColor)),a=n.length>0||e.activeTool.type!=="selection"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser"&&e.activeTool.type!=="lasso",l=e.openPopup==="compactStrokeStyles";return a?$("div",{className:"compact-action-item",children:me(Qn.Root,{open:l,onOpenChange:s=>{t(s?{openPopup:"compactStrokeStyles"}:{openPopup:null})},children:[$(Qn.Trigger,{asChild:!0,children:$("button",{type:"button",className:Uo("compact-action-button properties-trigger",{active:l}),title:f("labels.stroke"),onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:l?null:"compactStrokeStyles"})},children:F0})}),l&&$(sn,{className:mg,container:r,style:{maxWidth:"13rem"},onClose:()=>{},children:me("div",{className:"selected-shape-actions",children:[i&&o("changeFillStyle"),($a(e.activeTool.type)||n.some(s=>$a(s.type)))&&o("changeStrokeWidth"),(ja(e.activeTool.type)||n.some(s=>ja(s.type)))&&me(Kt,{children:[o("changeStrokeStyle"),o("changeSloppiness")]}),(qa(e.activeTool.type)||n.some(s=>qa(s.type)))&&o("changeRoundness"),o("changeOpacity")]})})]})}):null},uv=({appState:e,renderAction:o,setAppState:t,targetElements:n,container:r,app:i})=>{let a=Vd(e.activeTool.type)||n.some(s=>Vd(s.type)),l=e.openPopup==="compactArrowProperties";return a?$("div",{className:"compact-action-item",children:me(Qn.Root,{open:l,onOpenChange:s=>{t(s?{openPopup:"compactArrowProperties"}:{openPopup:null})},children:[$(Qn.Trigger,{asChild:!0,children:$("button",{type:"button",className:Uo("compact-action-button properties-trigger",{active:l}),title:f("labels.arrowtypes"),onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:l?null:"compactArrowProperties"})},children:(()=>{let s=pt(n,i,c=>iv(c)?c.elbowed?"elbow":c.roundness?"round":"sharp":null,c=>iv(c),c=>c?null:e.currentItemArrowType);return s==="elbow"?Ei:s==="round"?xi:bi})()})}),l&&$(sn,{container:r,className:"properties-content",style:{maxWidth:"13rem"},onClose:()=>{},children:o("changeArrowProperties")})]})}):null},hv=({appState:e,renderAction:o,setAppState:t,targetElements:n,container:r,elementsMap:i})=>{let{saveCaretPosition:a,restoreCaretPosition:l}=nx(),s=e.openPopup==="compactTextProperties";return $("div",{className:"compact-action-item",children:me(Qn.Root,{open:s,onOpenChange:c=>{c?(e.editingTextElement&&a(),t({openPopup:"compactTextProperties"})):(t({openPopup:null}),e.editingTextElement&&l())},children:[$(Qn.Trigger,{asChild:!0,children:$("button",{type:"button",className:Uo("compact-action-button properties-trigger",{active:s}),title:f("labels.textAlign"),onClick:c=>{c.preventDefault(),c.stopPropagation(),s?t({openPopup:null}):(e.editingTextElement&&a(),t({openPopup:"compactTextProperties"}))},children:sE})}),e.openPopup==="compactTextProperties"&&$(sn,{className:mg,container:r,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&l()},children:me("div",{className:"selected-shape-actions",children:[(e.activeTool.type==="text"||n.some(Xd))&&o("changeFontSize"),(e.activeTool.type==="text"||cv(n,i))&&o("changeTextAlign"),sv(n,i)&&o("changeVerticalAlign")]})})]})})},gv=({appState:e,renderAction:o,targetElements:t,setAppState:n,container:r,app:i,showDuplicate:a,showDelete:l})=>{let s=!!(e.editingTextElement||e.newElement),c=!e.croppingElementId&&t.length===1&&dv(t[0]),m=t.length===1,p=tt(e,i),d=!1;t.length===2&&(Yd(t[0])||Yd(t[1]))&&(d=!0);let u=document.documentElement.getAttribute("dir")==="rtl",b=e.openPopup==="compactOtherProperties";return s||t.length===0?null:$("div",{className:"compact-action-item",children:me(Qn.Root,{open:b,onOpenChange:g=>{n(g?{openPopup:"compactOtherProperties"}:{openPopup:null})},children:[$(Qn.Trigger,{asChild:!0,children:$("button",{type:"button",className:Uo("compact-action-button properties-trigger",{active:b}),title:f("labels.actions"),onClick:g=>{g.preventDefault(),g.stopPropagation(),n({openPopup:b?null:"compactOtherProperties"})},children:eE})}),b&&$(sn,{className:mg,container:r,style:{maxWidth:"12rem",justifyContent:"center",alignItems:"center"},onClose:()=>{},children:me("div",{className:"selected-shape-actions",children:[me("fieldset",{children:[$("legend",{children:f("labels.layers")}),me("div",{className:"buttonList",children:[o("sendToBack"),o("sendBackward"),o("bringForward"),o("bringToFront")]})]}),p&&!d&&me("fieldset",{children:[$("legend",{children:f("labels.align")}),me("div",{className:"buttonList",children:[u?me(Kt,{children:[o("alignRight"),o("alignHorizontallyCentered"),o("alignLeft")]}):me(Kt,{children:[o("alignLeft"),o("alignHorizontallyCentered"),o("alignRight")]}),t.length>2&&o("distributeHorizontally"),$("div",{style:{flexBasis:"100%",height:0}}),me("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[o("alignTop"),o("alignVerticallyCentered"),o("alignBottom"),t.length>2&&o("distributeVertically"),$("div",{style:{flexBasis:"100%",height:0}}),o("arrangeElements"),o("normaliseElements")]})]})]}),me("fieldset",{children:[$("legend",{children:f("labels.actions")}),me("div",{className:"buttonList",children:[o("group"),o("ungroup"),m&&o("hyperlink"),c&&o("cropEditor"),a&&o("duplicateSelection"),l&&o("deleteSelectedElements")]})]})]})})]})})},TR=({appState:e,renderAction:o,targetElements:t})=>!e.selectedLinearElement?.isEditing&&t.length===1&&dg(t[0])&&!cg(t[0])?$("div",{className:"compact-action-item",children:o("toggleLinearEditor")}):null,fv=({appState:e,elementsMap:o,renderAction:t,app:n,setAppState:r})=>{let i=ni(o,e),{container:a}=Ne(),l=!!(e.editingTextElement||e.newElement),s=!e.selectedLinearElement?.isEditing&&i.length===1&&dg(i[0])&&!cg(i[0]);return me("div",{className:"compact-shape-actions",children:[jl(e,i)&&$("div",{className:Uo("compact-action-item"),children:t("changeStrokeColor")}),ql(e,i)&&$("div",{className:"compact-action-item",children:t("changeBackgroundColor")}),$(pv,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:a}),$(uv,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:a,app:n}),s&&$("div",{className:"compact-action-item",children:t("toggleLinearEditor")}),(e.activeTool.type==="text"||i.some(Xd))&&me(Kt,{children:[$("div",{className:"compact-action-item",children:t("changeFontFamily")}),$(hv,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:a,elementsMap:o})]}),!l&&i.length>0&&$("div",{className:"compact-action-item",children:t("duplicateSelection")}),!l&&i.length>0&&$("div",{className:"compact-action-item",children:t("deleteSelectedElements")}),$(gv,{appState:e,renderAction:t,targetElements:i,setAppState:r,container:a,app:n})]})},bv=({appState:e,elementsMap:o,renderAction:t,app:n,setAppState:r})=>{let i=ni(o,e),{container:a}=Ne(),l=xR(null),s=l.current?.getBoundingClientRect()?.width??0,c=9,m=6,p=32,d=c*p+(c-1)*m,u=p+m,b=s>=d+u,g=s>=d+2*u;return me(We,{className:"compact-shape-actions mobile-shape-actions",style:{flexDirection:"row",boxShadow:"none",padding:0,zIndex:2,backgroundColor:"transparent",height:p*1.35,marginBottom:4,alignItems:"center",gap:m,pointerEvents:"none"},ref:l,children:[me("div",{style:{display:"flex",flexDirection:"row",gap:m,flex:1},children:[jl(e,i)&&$("div",{className:Uo("compact-action-item"),children:t("changeStrokeColor")}),ql(e,i)&&$("div",{className:"compact-action-item",children:t("changeBackgroundColor")}),$(pv,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:a}),$(uv,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:a,app:n}),$(TR,{appState:e,renderAction:t,targetElements:i}),(e.activeTool.type==="text"||i.some(Xd))&&me(Kt,{children:[$("div",{className:"compact-action-item",children:t("changeFontFamily")}),$(hv,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:a,elementsMap:o})]}),$(gv,{appState:e,renderAction:t,targetElements:i,setAppState:r,container:a,app:n,showDuplicate:!g,showDelete:!b})]}),me("div",{style:{display:"flex",flexDirection:"row",gap:m},children:[$("div",{className:"compact-action-item",children:t("undo")}),$("div",{className:"compact-action-item",children:t("redo")}),g&&$("div",{className:"compact-action-item",children:t("duplicateSelection")}),b&&$("div",{className:"compact-action-item",children:t("deleteSelectedElements")})]})]})},Ev=({activeTool:e,setAppState:o,app:t,UIOptions:n})=>{let[r,i]=yR(!1),a=nt(),l=a==="full",s=a==="compact",c=[{type:"selection",icon:sc,title:hn(f("toolBar.selection"))},{type:"lasso",icon:An,title:hn(f("toolBar.lasso"))}],m=l&&e.type==="lasso"&&t.state.preferredSelectionTool.type!=="lasso",p=IR.filter(u=>u.myocSimplifiedMode===!1),d=ER(()=>{switch(e.type){case"frame":return{icon:Dn,highlight:!1};case"lasso":return{icon:An,highlight:!0};case"embeddable":return{icon:hc,highlight:!0};case"laser":return t.props.isCollaborating?{icon:gi,highlight:!0}:{icon:fi,highlight:!0};case"diamond":return{icon:dc,highlight:!0};case"rectangle":return{icon:cc,highlight:!0};case"ellipse":return{icon:mc,highlight:!0};case"arrow":return{icon:aE,highlight:!0};case"line":return{icon:pc,highlight:!0};default:return{icon:gi,highlight:!1}}},[e.type,t.props.isCollaborating]);return me(Kt,{children:[vR(t).filter(u=>!t.state.myocSimplifiedMode||u.myocSimplifiedMode).map(({value:u,icon:b,key:g,fillable:E})=>{if(n.tools?.[u]===!1)return null;let y=f(`toolBar.${u}`),v=g&&hn(typeof g=="string"?g:g[0]),x=v;return(u==="selection"||u==="lasso")&&s?$(Ud,{app:t,options:c,activeTool:e,defaultOption:t.state.preferredSelectionTool.type,namePrefix:"selectionType",title:hn(f("toolBar.selection")),"data-testid":"toolbar-selection",onToolChange:w=>{(w==="selection"||w==="lasso")&&(t.setActiveTool({type:w}),o({preferredSelectionTool:{type:w,initialized:!0}}))},displayedOption:c.find(w=>w.type===t.state.preferredSelectionTool.type)||c[0],fillable:e.type==="selection"},"selection-popover"):$(Z,{className:Uo("Shape",{fillable:E}),type:"radio",icon:b,checked:e.type===u,name:"editor-current-shape",title:`${hn(y)} \u2014 ${x}`,keyBindingLabel:v,"aria-label":hn(y),"aria-keyshortcuts":x,"data-testid":`toolbar-${u}`,onPointerDown:({pointerType:w})=>{!t.state.penDetected&&w==="pen"&&t.togglePenMode(!0),u==="selection"&&(t.state.activeTool.type==="selection"?t.setActiveTool({type:"lasso"}):t.setActiveTool({type:"selection"}))},onChange:({pointerType:w})=>{t.state.activeTool.type!==u&&ce("toolbar",u,"ui"),u==="image"?t.setActiveTool({type:u}):t.setActiveTool({type:u})}},u)}),$("div",{className:"App-toolbar__divider"}),me(we,{open:r,children:[$(we.Trigger,{className:Uo("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":d.highlight}),onToggle:()=>{i(!r),o({openMenu:null,openPopup:null})},title:f("toolBar.extraTools"),children:d.icon}),me(we.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[$(we.Item,{onSelect:()=>t.setActiveTool({type:"lasso"}),icon:An,"data-testid":"toolbar-lasso",selected:m,children:f("toolBar.lasso")}),p.map(({value:u,icon:b,key:g,fillable:E})=>{let y=f(`toolBar.${u}`),v=g&&hn(typeof g=="string"?g:g[0]);return $(we.Item,{onSelect:()=>t.setActiveTool({type:u}),icon:b,"data-testid":`toolbar-${u}`,selected:e.type===u,shortcut:v??void 0,children:hn(y)},u)}),$("div",{className:"App-toolbar__dropdown-divider"}),$(we.Item,{onSelect:()=>t.toggleLock(),icon:t.state.activeTool.locked?Mn:an,"data-testid":"toolbar-lock",selected:t.state.activeTool.locked,shortcut:wR.Q,children:hn(f("toolBar.lock-short"))})]})]})]})},xv=({renderAction:e,zoom:o})=>$(bt.Col,{gap:1,className:lv.ZOOM_ACTIONS,children:me(bt.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),yv=({renderAction:e,className:o})=>me("div",{className:`undo-redo-buttons ${o}`,children:[$("div",{className:"undo-button-container",children:$(gt,{label:f("buttons.undo"),children:e("undo")})}),$("div",{className:"redo-button-container",children:me(gt,{label:f("buttons.redo"),children:[" ",e("redo")]})})]}),wv=({actionManager:e,showExitZenModeBtn:o})=>$("button",{type:"button",className:Uo("disable-zen-mode",{"disable-zen-mode--visible":o}),onClick:()=>e.executeAction(_l),children:f("buttons.exitZenMode")});import{useRef as SR}from"react";var pg=e=>{let o=SR({userFn:e});return o.current.userFn=e,o.current.stableFn||(o.current.stableFn=(...t)=>o.current.userFn(...t)),o.current.stableFn};var ug={};Tb(ug,{toggleTheme:()=>CR});var CR={...Pr,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(Pr,"commandPalette")}};import{jsx as it,jsxs as Wo}from"react/jsx-runtime";var _R=_e(null),Ke={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links",library:"Library"},Iv=e=>{switch(e){case Ke.app:return 1;case Ke.export:return 2;case Ke.editor:return 3;case Ke.tools:return 4;case Ke.elements:return 5;case Ke.links:return 6;default:return 10}},$d=({shortcut:e,className:o,children:t})=>{let n=e.replace("++","+$").split("+");return Wo("div",{className:Sv("shortcut",o),children:[n.map((r,i)=>it("div",{className:"shortcut-wrapper",children:it("div",{className:"shortcut-key",children:r==="$"?"+":r})},r)),it("div",{className:"shortcut-desc",children:t})]})},kv=e=>!e.altKey&&e[To.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===To.P||e.key===To.SLASH),DR=Object.assign(e=>{let o=de(),t=be();return Zd(()=>{let n=r=>{kv(r)&&(r.preventDefault(),r.stopPropagation(),t(i=>{let a=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return a&&ce("command_palette","open","shortcut"),{openDialog:a}}))};return window.addEventListener(jd.KEYDOWN,n,{capture:!0}),()=>window.removeEventListener(jd.KEYDOWN,n,{capture:!0})},[t]),o.openDialog?.name!=="commandPalette"?null:it(RR,{...e})},{defaultItems:ug});function RR({customCommandPaletteItems:e}){let o=je(),t=de(),n=be(),r=no(),i=Ye(),[a,l]=fe(_R),[s,c]=Kd(null),m=Cv(null),p=Rn({uiAppState:t,customCommandPaletteItems:e,appProps:r}),[d]=fe(pn),u=PR(()=>d.libraryItems?.filter(k=>!!k.name).map(k=>({label:k.name,icon:it(NR,{id:k.id,elements:k.elements}),category:"Library",order:Iv("Library"),haystack:Rr(k.name),perform:()=>{o.onInsertElements(ta([k]))}}))||[],[o,d.libraryItems]);Zd(()=>{let{uiAppState:k,customCommandPaletteItems:L,appProps:_}=p,M=O=>{let K="";return O.label&&(typeof O.label=="function"?K=f(O.label(o.scene.getNonDeletedElements(),k,o)):K=f(O.label)),K},D=O=>typeof O.icon=="function"?O.icon(k,o.scene.getNonDeletedElements()):O.icon,z=[],W=(O,K,Y)=>{let q={label:M(O),icon:D(O),category:K,shortcut:Se(O.name),keywords:O.keywords,predicate:O.predicate,viewMode:O.viewMode,perform:()=>{i.executeAction(O,"commandPalette")}};return Y?Y(q,O):q};if(k&&o.scene&&i){let O=[i.actions.group,i.actions.ungroup,i.actions.cut,i.actions.copy,i.actions.deleteSelectedElements,i.actions.wrapSelectionInFrame,i.actions.bringToFront,i.actions.bringForward,i.actions.sendBackward,i.actions.sendToBack,i.actions.alignTop,i.actions.alignBottom,i.actions.alignLeft,i.actions.alignRight,i.actions.alignVerticallyCentered,i.actions.alignHorizontallyCentered,i.actions.arrangeElements,i.actions.normaliseElements,i.actions.duplicateSelection,i.actions.smartZoom,i.actions.flipHorizontal,i.actions.flipVertical,i.actions.zoomToFitSelection,i.actions.zoomToFitSelectionInViewport,i.actions.increaseFontSize,i.actions.decreaseFontSize,i.actions.toggleLinearEditor,i.actions.cropEditor,i.actions.togglePolygon,Ol,Sd,Uw].map(R=>W(R,Ke.elements,(G,ie)=>({...G,predicate:ie.predicate?ie.predicate:(ge,ke,De,Le)=>ee(ge,ke).length>0}))),K=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool,i.actions.toggleLassoTool].map(R=>W(R,Ke.tools)),Y=[i.actions.undo,i.actions.redo,i.actions.zoomIn,i.actions.zoomOut,i.actions.resetZoom,i.actions.zoomToFit,i.actions.smartZoom,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(R=>W(R,Ke.editor)),q=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng].map(R=>W(R,Ke.export));z=[...O,...Y,{label:f("buttons.exportImage"),category:Ke.export,icon:fc,shortcut:Se("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{n({openDialog:{name:"imageExport"}})}},...q];let ne=[{label:f("toolBar.library"),category:Ke.app,icon:lc,viewMode:!1,perform:()=>{k.openSidebar?n({openSidebar:null}):n({openSidebar:{name:vv.name,tab:vv.defaultTab}})}},{label:f("search.title"),category:Ke.app,icon:Gt,viewMode:!0,perform:()=>{i.executeAction(Jl)}},{label:f("labels.shapeSwitch"),category:Ke.elements,icon:sl,perform:()=>{i.executeAction(Gw)}},{label:f("labels.changeStroke"),keywords:["color","outline"],category:Ke.elements,icon:ui,viewMode:!1,predicate:(R,G)=>{let ie=ee(R,G);return ie.length>0&&jl(G,ie)},perform:()=>{n(R=>({openPopup:"elementStroke"}))}},{label:f("labels.changeBackground"),keywords:["color","fill"],icon:ui,category:Ke.elements,viewMode:!1,predicate:(R,G)=>{let ie=ee(R,G);return ie.length>0&&ql(G,ie)},perform:()=>{n(R=>({openPopup:"elementBackground"}))}},{label:f("labels.canvasBackground"),keywords:["color"],icon:ui,category:Ke.editor,viewMode:!1,perform:()=>{n(R=>({openMenu:R.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...LR.reduce((R,G)=>{let{value:ie,icon:ge,key:ke}=G;if(_.UIOptions.tools?.[ie]===!1)return R;let Le=ke&&MR(typeof ke=="string"?ke:ke[0]),se={label:f(`toolBar.${ie}`),category:Ke.tools,shortcut:Le,icon:ge,keywords:["toolbar"],viewMode:!1,perform:({event:Te})=>{ie==="image"?o.setActiveTool({type:ie}):o.setActiveTool({type:ie})}};return R.push(se),R},[]),...K,{label:f("toolBar.lock"),category:Ke.tools,icon:k.activeTool.locked?Mn:an,shortcut:To.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{o.toggleLock()}}],ae=[...z,...ne,...L||[]].map(R=>({...R,icon:R.icon||sl,order:R.order??Iv(R.category),haystack:`${Rr(R.label.toLocaleLowerCase())} ${R.keywords?.join(" ")||""}`}));c(ae),l([...ae,...u].find(R=>R.label===a?.label)??null)}},[p,o,i,c,a?.label,l,n,u]);let[b,g]=Kd(""),[E,y]=Kd(null),[v,x]=Kd({}),w=k=>{n({openDialog:null},k),g("")},I=(k,L)=>{t.openDialog?.name==="commandPalette"&&(L.stopPropagation(),L.preventDefault(),document.body.classList.add("excalidraw-animations-disabled"),w(()=>{k.perform({actionManager:i,event:L}),l(k),requestAnimationFrame(()=>{document.body.classList.remove("excalidraw-animations-disabled")})}))},C=pg(k=>k.viewMode===!1&&t.viewModeEnabled?!1:typeof k.predicate=="function"?k.predicate(o.scene.getNonDeletedElements(),t,r,o):k.predicate===void 0||k.predicate),A=pg(k=>{let L=AR(k.target)||kv(k)||k.key===To.ESCAPE;if(L&&k.key!==To.ARROW_UP&&k.key!==To.ARROW_DOWN&&k.key!==To.ENTER)return;let _=Object.values(v).flat(),M=a&&!b&&C(a);if(k.key===To.ARROW_UP){k.preventDefault();let D=_.findIndex(O=>O.label===E?.label);if(M){if(D===0){y(a);return}if(E===a){let O=_[_.length-1];O&&y(O);return}}let z;D===-1?z=_.length-1:z=D===0?_.length-1:(D-1)%_.length;let W=_[z];W&&y(W);return}if(k.key===To.ARROW_DOWN){k.preventDefault();let D=_.findIndex(O=>O.label===E?.label);if(M){if(!E||D===_.length-1){y(a);return}if(E===a){let O=_[0];O&&y(O);return}}let z=(D+1)%_.length,W=_[z];W&&y(W);return}if(k.key===To.ENTER&&E&&setTimeout(()=>{I(E,k)}),!L){if(k.stopPropagation(),/^[a-zA-Z0-9]$/.test(k.key)){m?.current?.focus();return}k.preventDefault()}});return Zd(()=>(window.addEventListener(jd.KEYDOWN,A,{capture:!0}),()=>window.removeEventListener(jd.KEYDOWN,A,{capture:!0})),[A]),Zd(()=>{if(!s)return;let k=D=>{let z={};for(let W of D)z[W.category]?z[W.category].push(W):z[W.category]=[W];return z},L=b?.length>1?[...s.filter(C).sort((D,z)=>D.order-z.order),...u]:s.filter(C).sort((D,z)=>D.order-z.order),_=!b&&a&&C(a);if(!b){x(k(_?L.filter(D=>D.label!==a?.label):L)),y(_?a:L[0]||null);return}let M=Rr(b.toLocaleLowerCase().replace(/[<>_| -]/g,""));L=kR.filter(M,L,{extract:D=>D.haystack??""}).sort((D,z)=>z.score-D.score).map(D=>D.original),x(k(L)),y(L[0]??null)},[b,s,C,a,u]),Wo(qe,{onCloseRequest:()=>w(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[it(qn,{value:b,placeholder:f("commandPalette.search.placeholder"),onChange:k=>{g(k)},selectOnRender:!0,ref:m}),o.editorInterface.formFactor!=="phone"&&Wo("div",{className:"shortcuts-wrapper",children:[it($d,{shortcut:"\u2191\u2193",children:f("commandPalette.shortcuts.select")}),it($d,{shortcut:"\u21B5",children:f("commandPalette.shortcuts.confirm")}),it($d,{shortcut:N("Esc"),children:f("commandPalette.shortcuts.close")})]}),Wo("div",{className:"commands",children:[a&&!b&&Wo("div",{className:"command-category",children:[Wo("div",{className:"command-category-title",children:[f("commandPalette.recents"),it("div",{className:"icon",style:{marginLeft:"6px"},children:w0})]}),it(Tv,{command:a,isSelected:a.label===E?.label,onClick:k=>I(a,k),disabled:!C(a),onMouseMove:()=>y(a),showShortcut:o.editorInterface.formFactor!=="phone",appState:t})]}),Object.keys(v).length>0?Object.keys(v).map((k,L)=>Wo("div",{className:"command-category",children:[it("div",{className:"command-category-title",children:k}),v[k].map(_=>it(Tv,{command:_,isSelected:_.label===E?.label,onClick:M=>I(_,M),onMouseMove:()=>y(_),showShortcut:o.editorInterface.formFactor!=="phone",appState:t,size:k==="Library"?"large":"small"},_.label))]},k)):s?Wo("div",{className:"no-match",children:[it("div",{className:"icon",children:Gt})," ",f("commandPalette.search.noMatch")]}):null]})]})}var NR=({id:e,elements:o})=>{let t=Cv(null),{svgCache:n}=Qi();return Cd(e,o,n,t),it("div",{className:"library-item-icon",ref:t})},Tv=({command:e,isSelected:o,disabled:t,onMouseMove:n,onClick:r,showShortcut:i,appState:a,size:l="small"})=>{let s=()=>{};return Wo("div",{className:Sv("command-item",{"item-selected":o,"item-disabled":t,"command-item-large":l==="large"}),ref:c=>{o&&!t&&c?.scrollIntoView?.({block:"nearest"})},onClick:t?s:r,onMouseMove:t?s:n,title:t?f("commandPalette.itemNotAvailable"):"",children:[Wo("div",{className:"name",children:[e.icon&&it(Mi,{className:"icon",size:"var(--icon-size, 1rem)",icon:typeof e.icon=="function"?e.icon(a,[]):e.icon}),it(Cr,{children:e.label})]}),i&&e.shortcut&&it($d,{shortcut:e.shortcut})]})};import{getSizeFromPoints as G2e,randomInteger as MN,getUpdatedTimestamp as AN}from"@excalidraw/common";import{simplify as hN}from"points-on-curve";import{getStroke as gN}from"perfect-freehand";import{pointsOnBezierCurves as cfe}from"points-on-curve";import{invariant as mfe}from"@excalidraw/common";import{curve as ufe,lineSegment as hfe,pointFrom as gfe,pointDistance as ffe,pointFromArray as bfe,pointFromVector as Efe,pointRotateRads as xfe,polygon as yfe,polygonFromPoints as wfe,PRECISION as vfe,segmentsIntersectAt as Ife,vector as Tfe,vectorAdd as Sfe,vectorFromPoint as Cfe,vectorScale as kfe}from"@excalidraw/math";import{getElementAbsoluteCoords as Mfe}from"@excalidraw/element";var hg=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 fN,pointDistance as Vv,pointRotateRads as C2e}from"@excalidraw/math";import{ROUGHNESS as bN,THEME as Ag,isTransparent as is,assertNever as EN,COLOR_PALETTE as xN,LINE_POLYGON_POINT_MERGE_DISTANCE as P2e,applyDarkModeFilter as as}from"@excalidraw/common";import{RoughGenerator as yN}from"roughjs/bin/generator";import Owe from"roughjs/bin/rough";import{isRightAngleRads as Hwe,lineSegment as Gwe,pointFrom as Uwe,pointRotateRads as Wwe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as Vwe,DEFAULT_REDUCED_GLOBAL_ALPHA as Xwe,ELEMENT_READY_TO_ERASE_OPACITY as Kwe,FRAME_STYLE as Zwe,DARK_THEME_FILTER as $we,MIME_TYPES as Yv,THEME as jwe,distance as qwe,getFontString as Jwe,isRTL as Qwe,getVerticalOffset as e2e,invariant as t2e,applyDarkModeFilter as o2e,isSafari as n2e}from"@excalidraw/common";import Xye from"roughjs/bin/rough";import{arrayToMap as Zye,invariant as Wv,rescalePoints as $ye,sizeOf as jye}from"@excalidraw/common";import{degreesToRadians as kg,lineSegment as Jye,pointDistance as Qye,pointFrom as ut,pointFromArray as lN,pointRotateRads as da}from"@excalidraw/math";import{pointsOnBezierCurves as owe}from"points-on-curve";import{pointCenter as mye,pointFrom as pye,pointRotateRads as uye,pointsEqual as hye,pointDistance as gye,vectorFromPoint as fye,curveLength as bye,curvePointAtLength as Eye}from"@excalidraw/math";import{DRAGGING_THRESHOLD as wye,KEYS as vye,shouldRotateWithDiscreteAngle as Iye,getGridPoint as Tye,invariant as Sye,isShallowEqual as Cye,getFeatureFlag as kye}from"@excalidraw/common";import{arrayToMap as XEe,getFeatureFlag as KEe,invariant as ZEe,isTransparent as $Ee}from"@excalidraw/common";import{PRECISION as qEe,clamp as JEe,lineSegment as QEe,pointDistance as e0e,pointDistanceSq as t0e,pointFrom as o0e,pointFromVector as n0e,pointRotateRads as r0e,pointsEqual as i0e,vectorFromPoint as a0e,vectorNormalize as l0e,vectorScale as s0e}from"@excalidraw/math";import{invariant as ybe,isTransparent as wbe}from"@excalidraw/common";import{curveIntersectLineSegment as Ibe,isPointWithinBounds as Tbe,lineSegment as Sbe,lineSegmentIntersectionPoints as Cbe,pointFrom as kbe,pointFromVector as Pbe,pointRotateRads as Mbe,pointsEqual as Abe,vectorFromPoint as Lbe,vectorNormalize as _be,vectorScale as Dbe}from"@excalidraw/math";import{ellipse as Nbe,ellipseSegmentInterceptPoints as Bbe}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as OR,DEFAULT_PROPORTIONAL_RADIUS as fg,invariant as Hfe,LINE_CONFIRM_THRESHOLD as zR,ROUNDNESS as bg}from"@excalidraw/common";import{bezierEquation as Ufe,curve as Wfe,curveCatmullRomCubicApproxPoints as Yfe,curveOffsetPoints as Vfe,lineSegment as Xfe,lineSegmentIntersectionPoints as Kfe,pointDistance as HR,pointFrom as Zfe,pointFromArray as $fe,pointFromVector as jfe,pointRotateRads as qfe,pointTranslate as Jfe,rectangle as Qfe,vectorFromPoint as e1e,vectorNormalize as t1e,vectorScale as o1e}from"@excalidraw/math";import{ROUNDNESS as Dfe,assertNever as Rfe}from"@excalidraw/common";import{pointsEqual as Bfe}from"@excalidraw/math";var Pv=e=>!!e&&e.type==="embeddable",Mv=e=>!!e&&e.type==="iframe",gg=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),gn=e=>e!=null&&e.type==="text";var Ql=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var Br=e=>e!=null&&BR(e.type);var er=e=>e!=null&&e.type==="arrow",es=e=>er(e)&&e.elbowed;var BR=e=>e==="arrow"||e==="line";var aa=e=>e!==null&&"containerId"in e&&e.containerId!==null&&gn(e);var ts=(e,o=1)=>{if(e.length>=3){let[t,n]=[e[0],e[e.length-1]];return HR(t,n)<=zR/o}return!1},os=(e,o)=>{if(o.roundness?.type===bg.PROPORTIONAL_RADIUS||o.roundness?.type===bg.LEGACY)return e*fg;if(o.roundness?.type===bg.ADAPTIVE_RADIUS){let t=o.roundness?.value??OR,n=t/fg;return e<=n?e*fg:t}return 0};import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as H1e,ARROW_LABEL_WIDTH_FRACTION as G1e,BOUND_TEXT_PADDING as U1e,DEFAULT_FONT_SIZE as W1e,TEXT_ALIGN as Y1e,VERTICAL_ALIGN as V1e,getFontString as X1e,isProdEnv as K1e,invariant as Z1e}from"@excalidraw/common";import{pointFrom as j1e,pointRotateRads as q1e}from"@excalidraw/math";import{BOUND_TEXT_PADDING as b1e,DEFAULT_FONT_SIZE as E1e,DEFAULT_FONT_FAMILY as x1e,getFontString as y1e,isTestEnv as w1e,normalizeEOL as v1e}from"@excalidraw/common";var I1e="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as A1e,isTestEnv as L1e}from"@excalidraw/common";import{curvePointDistance as abe,distanceToLineSegment as lbe,pointRotateRads as sbe}from"@excalidraw/math";import{ellipse as dbe,ellipseDistanceFromPoint as mbe}from"@excalidraw/math/ellipse";var Lv=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";import{invariant as jbe,isDevEnv as qbe,isTestEnv as Jbe}from"@excalidraw/common";import{pointFrom as eEe,pointFromVector as tEe,pointRotateRads as oEe,pointScaleFromOrigin as nEe,pointsEqual as rEe,triangleIncludesPoint as iEe,vectorCross as aEe,vectorFromPoint as KR,vectorScale as lEe}from"@excalidraw/math";var wg=[1,0],Ov=[0,1],vg=[-1,0],zv=[0,-1],em=e=>{let[o,t]=e,n=Math.abs(o),r=Math.abs(t);return o>r?wg:o<=-r?vg:t>n?Ov:zv},Hv=(e,o)=>em(KR(e,o)),tm=(e,o)=>om(Hv(e,o)),yg=(e,o)=>e[0]===o[0]&&e[1]===o[1],om=e=>yg(e,wg)||yg(e,vg);import{clamp as uEe,pointDistance as hEe,pointFrom as gEe,pointScaleFromOrigin as fEe,pointsEqual as bEe,pointTranslate as EEe,vector as xEe,vectorCross as yEe,vectorFromPoint as wEe,vectorScale as vEe}from"@excalidraw/math";import{BinaryHeap as TEe,invariant as SEe,isAnyTrue as CEe,getSizeFromPoints as kEe,isDevEnv as PEe,arrayToMap as MEe}from"@excalidraw/common";var y0e=10/1.5;import{SHIFT_LOCKING_ANGLE as S0e,viewportCoordsToSceneCoords as C0e}from"@excalidraw/common";import{normalizeRadians as P0e,radiansBetweenAngles as M0e,radiansDifference as A0e}from"@excalidraw/math";import{pointsEqual as _0e}from"@excalidraw/math";import{arrayToMap as Yxe,findIndex as Vxe,findLastIndex as Xxe}from"@excalidraw/common";import{arrayToMap as vxe,isShallowEqual as rN}from"@excalidraw/common";import{lineSegment as Txe,pointFrom as Sxe,pointRotateRads as Cxe}from"@excalidraw/math";import{arrayToMap as oxe}from"@excalidraw/common";import{isPointWithinBounds as rxe,pointFrom as ixe}from"@excalidraw/math";import{vectorCross as O0e,vectorFromPoint as z0e}from"@excalidraw/math";import{arrayToMap as W0e}from"@excalidraw/common";import{validateOrderKey as V0e,generateNKeysBetween as X0e}from"@excalidraw/fractional-indexing";var Uv=(e,o)=>{let t=[];for(let n of e.values())n.frameId===o&&t.push(n);return t};var Nxe=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}(),nm=(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&&aa(i)&&o.selectedElementIds[i?.containerId]){r.push(i),n.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return r.forEach(a=>{Ql(a)&&Uv(e,a.id).forEach(l=>!n.has(l.id)&&i.push(l)),i.push(a)}),i}return r};var Cg=(e,o)=>rN(o.selectedElementIds,e)?o.selectedElementIds:e;var iN=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 c={};for(let d of i){let u=d.groupIds;if(l.editingGroupId){let b=u.indexOf(l.editingGroupId);b>-1&&(u=u.slice(0,b))}if(u.length>0){let b=u[u.length-1];c[b]=!0}}let m={},p=a.reduce((d,u)=>{if(u.isDeleted)return d;let b=u.groupIds.find(g=>c[g]);return b&&(d[u.id]=!0,Array.isArray(m[b])?m[b].push(u.id):m[b]=[u.id]),d},{});for(let d of Object.keys(m))m[d].length<2&&c[d]&&(c[d]=!1);return o=a,e=i,t={editingGroupId:l.editingGroupId,selectedGroupIds:c,selectedElementIds:Cg({...l.selectedElementIds,...p},s)},t},r=(i,a,l,s)=>{let c=s?s.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):nm(a,i);return c.length?n(c,a,i,l):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:Cg(i.selectedElementIds,l)}};return r.clearCache=()=>{o=null,e=null,t=null},r}();var qd=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 sN=20,cN=15,dN=e=>{switch(e){case"arrow":return 25;case"diamond":case"diamond_outline":return 12;case"cardinality_many":case"cardinality_one_or_many":case"cardinality_zero_or_many":return cN;case"cardinality_one":case"cardinality_exactly_one":case"cardinality_zero_or_one":return sN;default:return 15}},mN=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},Tt=(e,o,t,n,r=0)=>{if(n===null||o.length<1)return null;let i=hg(o[0]);if(i.length<1)return null;let a=t==="start"?1:i.length-1,l=i[a].data;Wv(l.length===6,"Op data length is not 6");let s=ut(l[4],l[5]),c=ut(l[2],l[3]),m=ut(l[0],l[1]),p=i[a-1],d=ut(0,0);if(p.op==="move"){let q=lN(p.data);Wv(q!=null,"Op data is not a point"),d=q}else p.op==="bcurveTo"&&(d=ut(p.data[4],p.data[5]));let u=(q,ne)=>Math.pow(1-q,3)*s[ne]+3*q*Math.pow(1-q,2)*c[ne]+3*Math.pow(q,2)*(1-q)*m[ne]+d[ne]*Math.pow(q,3),[b,g]=t==="start"?d:s,[E,y]=[u(.3,0),u(.3,1)],v=Math.hypot(b-E,g-y),x=(b-E)/v,w=(g-y)/v,I=dN(n),C=0;{let[q,ne]=t==="end"?e.points[e.points.length-1]:e.points[0],[ae,R]=e.points.length>1?t==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];C=Math.hypot(q-ae,ne-R)}let k=Math.min(I,C*(n==="diamond"||n==="diamond_outline"?.25:.5)),L=b-x*k*r,_=g-w*k*r,M=L-x*k,D=_-w*k;if(n==="circle"||n==="circle_outline"){let q=Math.hypot(D-_,M-L)+e.strokeWidth-2;return[L,_,q]}let z=mN(n);if(n==="cardinality_many"||n==="cardinality_one_or_many"){let[q,ne]=da(ut(L,_),ut(M,D),kg(-z)),[ae,R]=da(ut(L,_),ut(M,D),kg(z));return[M,D,q,ne,ae,R]}let[W,O]=da(ut(M,D),ut(L,_),-z*Math.PI/180),[K,Y]=da(ut(M,D),ut(L,_),kg(z));if(n==="diamond"||n==="diamond_outline"){let q,ne;if(t==="start"){let[ae,R]=e.points.length>1?e.points[1]:[0,0];[q,ne]=da(ut(L+k*2,_),ut(L,_),Math.atan2(R-_,ae-L))}else{let[ae,R]=e.points.length>1?e.points[e.points.length-2]:[0,0];[q,ne]=da(ut(L-k*2,_),ut(L,_),Math.atan2(_-R,L-ae))}return[L,_,W,O,q,ne,K,Y]}return[L,_,W,O,K,Y]};import{pointFrom as fwe,pointCenter as bwe,pointRotateRads as Ewe,vectorFromPoint as xwe,vectorNormalize as ywe,vectorSubtract as wwe,vectorAdd as vwe,vectorScale as Iwe,pointFromVector as Twe,clamp as Swe,isCloseTo as Cwe}from"@excalidraw/math";var pN=typeof document<"u"?document.createElement("img"):{src:""};pN.src=`data:${Yv.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 uN=typeof document<"u"?document.createElement("img"):{src:""};uN.src=`data:${Yv.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 Pg=new WeakMap;var Nt=class Nt{};S(Nt,"rg",new yN),S(Nt,"cache",new WeakMap),S(Nt,"get",(o,t)=>{let n=Nt.cache.get(o);if(n&&(t===null||n.theme===t))return n.shape}),S(Nt,"delete",o=>{Nt.cache.delete(o),Pg.delete(o)}),S(Nt,"destroy",()=>{Nt.cache=new WeakMap}),S(Nt,"generateElementShape",(o,t)=>{let n=t?.isExporting?void 0:Nt.get(o,t?t.theme:null);if(n!==void 0)return n;Pg.delete(o);let r=IN(o,Nt.rg,t||{isExporting:!1,canvasBackgroundColor:xN.white,embedsValidationStatus:null,theme:Ag.LIGHT});return t?.isExporting||Nt.cache.set(o,{shape:r,theme:t?.theme||Ag.LIGHT}),r});var ca=Nt,wN=e=>[8,8+e],$v=e=>[1.5,6+e];function vN(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&&Lv(e.type)||Br(e)&&t>=50?o:Math.min(o/(t<10?3:2),2.5)}var bn=(e,o=!1,t=!1)=>{let n={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?wN(e.strokeWidth):e.strokeStyle==="dotted"?$v(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:vN(e),stroke:t?as(e.strokeColor):e.strokeColor,preserveVertices:o||e.roughness<bN.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return n.fillStyle=e.fillStyle,n.fill=is(e.backgroundColor)?void 0:t?as(e.backgroundColor):e.backgroundColor,e.type==="ellipse"&&(n.curveFitting=1),n;case"line":case"freedraw":return ts(e.points)&&(n.fillStyle=e.fillStyle,n.fill=e.backgroundColor==="transparent"?void 0:t?as(e.backgroundColor):e.backgroundColor),n;case"arrow":return n;default:throw new Error(`Unimplemented type ${e.type}`)}},Xv=(e,o,t)=>gg(e)&&(o||Pv(e)&&t?.get(e.id)!==!0)&&is(e.backgroundColor)&&is(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:Mv(e)?{...e,strokeColor:is(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:is(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,rs=(e,o,t)=>{if(o===null)return[];let[,,n,r,i,a]=o;return[e.line(n,r,i,a,t)]},rm=(e,o,t)=>{if(o===null)return[];let[n,r,i,a,l,s]=o;return[e.line(i,a,n,r,t),e.line(l,s,n,r,t)]},Fr=(e,o)=>{let t={...o};if(e.strokeStyle==="dotted"){let n=$v(e.strokeWidth-1);t.strokeLineDash=[n[0],n[1]-1]}else delete t.strokeLineDash;return t.roughness=Math.min(1,t.roughness||0),t},Mg=(e,o,t,n,r,i=1)=>{if(n===null)return[];let[a,l,s]=n,c={...o,fill:r,fillStyle:"solid",stroke:t,roughness:Math.min(.5,o.roughness||0)};return delete c.strokeLineDash,[e.circle(a,l,s*i,c)]},Kv=(e,o,t,n,r,i,a,l)=>{if(n===null)return[];let s=l?as(e.strokeColor):e.strokeColor,c=l?as(a):a,m=-.25,p=.8;switch(n){case"circle":case"circle_outline":return Mg(r,i,s,Tt(e,o,t,n),n==="circle_outline"?c:s);case"triangle":case"triangle_outline":{let d=Tt(e,o,t,n);if(d===null)return[];let[u,b,g,E,y,v]=d,x={...i,fill:n==="triangle_outline"?c:s,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)};return delete x.strokeLineDash,[r.polygon([[u,b],[g,E],[y,v],[u,b]],x)]}case"diamond":case"diamond_outline":{let d=Tt(e,o,t,n);if(d===null)return[];let[u,b,g,E,y,v,x,w]=d,I={...i,fill:n==="diamond_outline"?c:s,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)};return delete I.strokeLineDash,[r.polygon([[u,b],[g,E],[y,v],[x,w],[u,b]],I)]}case"cardinality_one":return rs(r,Tt(e,o,t,n),Fr(e,i));case"cardinality_many":return rm(r,Tt(e,o,t,n),Fr(e,i));case"cardinality_one_or_many":{let d=Fr(e,i);return[...rm(r,Tt(e,o,t,"cardinality_many"),d),...rs(r,Tt(e,o,t,"cardinality_one",m),d)]}case"cardinality_exactly_one":{let d=Fr(e,i);return[...rs(r,Tt(e,o,t,"cardinality_one",-.5),d),...rs(r,Tt(e,o,t,"cardinality_one"),d)]}case"cardinality_zero_or_one":{let d=Fr(e,i);return[...Mg(r,i,s,Tt(e,o,t,"circle_outline",1.5),c,p),...rs(r,Tt(e,o,t,"cardinality_one",-.5),d)]}case"cardinality_zero_or_many":{let d=Fr(e,i);return[...rm(r,Tt(e,o,t,"cardinality_many"),d),...Mg(r,i,s,Tt(e,o,t,"circle_outline",1.5),c,p)]}case"bar":case"arrow":default:return rm(r,Tt(e,o,t,n),Fr(e,i))}};var IN=(e,o,{isExporting:t,canvasBackgroundColor:n,embedsValidationStatus:r,theme:i})=>{let a=i===Ag.DARK;switch(e.type){case"rectangle":case"iframe":case"embeddable":{let l;if(e.roundness){let s=e.width,c=e.height,m=os(Math.min(s,c),e);l=o.path(`M ${m} 0 L ${s-m} 0 Q ${s} 0, ${s} ${m} L ${s} ${c-m} Q ${s} ${c}, ${s-m} ${c} L ${m} ${c} Q 0 ${c}, 0 ${c-m} L 0 ${m} Q 0 0, ${m} 0`,bn(Xv(e,t,r),!0,a))}else l=o.rectangle(0,0,e.width,e.height,bn(Xv(e,t,r),!1,a));return l}case"diamond":{let l,[s,c,m,p,d,u,b,g]=qd(e);if(e.roundness){let E=os(Math.abs(s-b),e),y=os(Math.abs(p-c),e);l=o.path(`M ${s+E} ${c+y} L ${m-E} ${p-y}
@@ -18,7 +18,7 @@ ${f("hints.firefox_clipboard_write")}`):new Error(f("alerts.couldNotCopyToClipbo
18
18
  `).filter(s=>s.trim().length>0).map(s=>s.split(l).map(c=>c.trim())),t=[" ",",",";"].map(l=>{let s=o(l),c=s[0]?.length??0,m=s.length>0&&s.every(p=>p.length===c);return{delimiter:l,parsed:s,numCols:c,isConsistent:m}}),r=(t.find(l=>l.isConsistent&&l.numCols>1)??t.find(l=>l.isConsistent)??t[0]).parsed;if(r.length===0)return{ok:!1,reason:"No values"};let i=r[0].length;return r.every(l=>l.length===i)?D3(r):{ok:!1,reason:"All rows don't have same number of columns"}};import{pointFrom as Ca}from"@excalidraw/math";import{FONT_FAMILY as uF,FONT_SIZES as hF,getFontString as gF,getLineHeight as fF,ROUGHNESS as R3}from"@excalidraw/common";import{measureText as bF,newLinearElement as uf,newTextElement as EF}from"@excalidraw/element";var N3=(e,o,t,n)=>{if(!ya(e,"radar"))return null;let r=e.labels??e.series[0].values.map((O,K)=>`Value ${K+1}`),i=e.series,{normalize:a,renderSteps:l}=k3(i,r.length),s=Ia(n),c=Ta(s),m=va(i.length,s),{chartWidth:p,chartHeight:d}=C3(),u=o+p/2,b=t-d/2,g=fa/2,E=r.map((O,K)=>-Math.PI/2+Math.PI*2*K/r.length),{axisLabels:y,axisLabelTopY:v,axisLabelBottomY:x}=P3(r,E,u,b,g,c),w=uF["Lilita One"],I=hF.xl,C=fF(w),A=gF({fontFamily:w,fontSize:I}),k=e.title?ym(e.title,A,p+ba*2):null,L=k?bF(k,A,C):null,_=k?EF({backgroundColor:c,...Be,text:k,originalText:e.title??k,x:o+p/2,y:v-ba-L.height/2,fontFamily:w,fontSize:I,lineHeight:C,textAlign:"center"}):null,M=l?Array.from({length:of},(O,K)=>{let Y=(K+1)/of,q=g*Y,ne=E.map(ae=>Ca(Math.cos(ae)*q,Math.sin(ae)*q));return ne.push(Ca(ne[0][0],ne[0][1])),uf({backgroundColor:"transparent",...Be,type:"line",x:u,y:b,width:q*2,height:q*2,strokeStyle:"solid",roughness:R3.architect,opacity:Ur,polygon:!0,points:ne})}):[],D=E.map(O=>{let K=Math.cos(O)*g,Y=Math.sin(O)*g;return uf({backgroundColor:"transparent",...Be,type:"line",x:u,y:b,width:Math.abs(K),height:Math.abs(Y),strokeStyle:"solid",roughness:R3.architect,opacity:Ur,points:[Ca(0,0),Ca(K,Y)]})}),z=i.map((O,K)=>{let Y=E.map((q,ne)=>{let ae=O.values[ne]??0,R=a(ae,ne)*g;return Ca(Math.cos(q)*R,Math.sin(q)*R)});return Y.push(Ca(Y[0][0],Y[0][1])),uf({backgroundColor:"transparent",...Be,type:"line",x:u,y:b,width:g*2,height:g*2,strokeColor:m[K],strokeWidth:2,polygon:!0,points:Y})}),W=Sa(i,m,u,x,t+Yo*5,c);return[..._?[_]:[],...y,...M,...D,...z,...W]};var hf=(e,o,t,n,r)=>e==="line"?_3(o,t,n,r):e==="radar"?N3(o,t,n,r):A3(o,t,n,r);import{jsx as so,jsxs as B3}from"react/jsx-runtime";var xF=()=>B3("div",{"data-testid":"brave-measure-text-error",children:[so("p",{children:so(Vt,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>so("span",{style:{fontWeight:600},children:e})})}),so("p",{children:so(Vt,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>so("span",{style:{fontWeight:600},children:e})})}),so("p",{children:so(Vt,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>so("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),so("p",{children:so(Vt,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>so("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>B3("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),F3=xF;import CF from"clsx";import kF from"react";import{useLayoutEffect as yF,useRef as O3,useEffect as z3}from"react";import{unstable_batchedUpdates as wF}from"react-dom";import{KEYS as vF,queryFocusableElements as IF}from"@excalidraw/common";import TF from"clsx";import{jsx as SF}from"react/jsx-runtime";var H3=({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,className:c})=>{let m=O3(null);z3(()=>{let d=m.current;if(!d)return;d.contains(document.activeElement)||d.focus();let u=b=>{if(b.key===vF.TAB){let g=IF(d),{activeElement:E}=document,y=g.findIndex(v=>v===E);E===d?(b.shiftKey?g[g.length-1]?.focus():g[0].focus(),b.preventDefault(),b.stopImmediatePropagation()):y===0&&b.shiftKey?(g[g.length-1]?.focus(),b.preventDefault(),b.stopImmediatePropagation()):y===g.length-1&&!b.shiftKey&&(g[0]?.focus(),b.preventDefault(),b.stopImmediatePropagation())}};return d.addEventListener("keydown",u),()=>d.removeEventListener("keydown",u)},[]);let p=O3(null);return yF(()=>{if(r&&m.current&&t!=null&&o!=null){let d=m.current,{width:u,height:b}=d.getBoundingClientRect();if(p.current?.top===t&&p.current?.left===o)return;p.current={top:t,left:o},u>=l?(d.style.width=`${l}px`,d.style.left="0px",d.style.overflowX="scroll"):o+u-i>l?d.style.left=`${l-u-10}px`:d.style.left=`${o}px`,b>=s?(d.style.height=`${s-20}px`,d.style.top="10px",d.style.overflowY="scroll"):t+b-a>s?d.style.top=`${s-b}px`:d.style.top=`${t}px`}},[t,o,r,l,s,i,a]),z3(()=>{if(n){let d=u=>{m.current?.contains(u.target)||wF(()=>n(u))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[n]),SF("div",{className:TF("popover",c),ref:m,tabIndex:-1,children:e})};import{jsx as ka,jsxs as PF}from"react/jsx-runtime";var at="separator",G3=kF.memo(({actionManager:e,items:o,top:t,left:n,onClose:r})=>{let i=Do(),a=Fn(),l=o.reduce((s,c)=>(c&&(c===at||!c.predicate||c.predicate(a,i,e.app.props,e.app))&&s.push(c),s),[]);return ka(H3,{onCloseRequest:()=>{r()},top:t,left:n,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,className:"context-menu-popover",children:ka("ul",{className:"context-menu",onContextMenu:s=>s.preventDefault(),children:l.map((s,c)=>{if(s===at)return!l[c-1]||l[c-1]===at?null:ka("hr",{className:"context-menu-item-separator"},c);let m=s.name,p="";return s.label&&(typeof s.label=="function"?p=f(s.label(a,i,e.app)):p=f(s.label)),ka("li",{"data-testid":m,onClick:()=>{r(()=>{e.executeAction(s,"contextMenu")})},children:PF("button",{type:"button",className:CF("context-menu-item",{dangerous:m==="deleteSelectedElements",checkmark:s.checked?.(i)}),children:[ka("div",{className:"context-menu-item__label",children:p}),ka("kbd",{className:"context-menu-item__shortcut",children:m?Se(m):""})]})},c)})})})});import{jsx as gf,jsxs as U3}from"react/jsx-runtime";var MF=({height:e,width:o,userToFollow:t,onDisconnect:n})=>gf("div",{className:"follow-mode",style:{width:o,height:e},children:U3("div",{className:"follow-mode__badge",children:[U3("div",{className:"follow-mode__badge__label",children:["Following"," ",gf("span",{className:"follow-mode__badge__username",title:t.username,children:t.username})]}),gf("button",{type:"button",onClick:n,className:"follow-mode__disconnect-btn",children:Qt})]})}),W3=MF;import qr from"clsx";import HG from"react";import{CLASSES as GG,DEFAULT_SIDEBAR as f1,TOOL_TYPE as EC,arrayToMap as UG,capitalizeString as WG,isShallowEqual as Qm}from"@excalidraw/common";import{mutateElement as YG}from"@excalidraw/element";import{showSelectedShapeActions as VG}from"@excalidraw/element";import{ShapeCache as XG}from"@excalidraw/element";import{createIsolation as AF}from"jotai-scope";import ff from"react";import Vo from"tunnel-rat";var bf=ff.createContext(null),Ze=()=>ff.useContext(bf),LF=AF(),Y3=()=>ff.useMemo(()=>({MainMenuTunnel:Vo(),WelcomeScreenMenuHintTunnel:Vo(),WelcomeScreenToolbarHintTunnel:Vo(),WelcomeScreenHelpHintTunnel:Vo(),WelcomeScreenCenterTunnel:Vo(),FooterCenterTunnel:Vo(),DefaultSidebarTriggerTunnel:Vo(),DefaultSidebarTabTriggersTunnel:Vo(),OverwriteConfirmDialogTunnel:Vo(),TTDDialogTriggerTunnel:Vo(),tunnelsJotai:LF}),[]);import _F from"clsx";import{useState as DF,useEffect as RF}from"react";import{THEME as NF}from"@excalidraw/common";import{jsx as Ef,jsxs as BF}from"react/jsx-runtime";var Tm=({delay:e,theme:o})=>{let[t,n]=DF(!!e);return RF(()=>{if(!e)return;let r=setTimeout(()=>{n(!1)},e);return()=>clearTimeout(r)},[e]),t?null:BF("div",{className:_F("LoadingMessage",{"LoadingMessage--dark":o===NF.DARK}),children:[Ef("div",{children:Ef(Ut,{})}),Ef("div",{className:"LoadingMessage-text",children:f("labels.loadingScene")})]})};import{useState as X3}from"react";import fs from"clsx";import{KEYS as K3,capitalizeString as Bt}from"@excalidraw/common";import{SHAPES as zF}from"@excalidraw/element/shapes";import FF from"clsx";import{KEYS as V3}from"@excalidraw/common";import{jsx as OF}from"react/jsx-runtime";var Sm=e=>OF(Z,{className:FF("Shape",{fillable:!1,active:e.checked}),type:"radio",icon:yc,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:V3.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":V3.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});import{jsx as co,jsxs as yf}from"react/jsx-runtime";var xf=[{type:"selection",icon:sc,title:Bt(f("toolBar.selection"))},{type:"lasso",icon:An,title:Bt(f("toolBar.lasso"))}],Z3=({app:e,onHandToolToggle:o,setAppState:t})=>{let n=e.state.activeTool,[r,i]=X3(!1),a=(I,C)=>{e.state.activeTool.type!==I&&ce("toolbar",I,"ui"),I==="selection"?e.state.activeTool.type==="selection"||e.setActiveTool({type:"selection"}):e.setActiveTool({type:I})},[l,s]=X3(0),c=36,m=4,p=7,d=p*c+(p-1)*m,u=c+m,b=l>=d+1*u,g=l>=d+2*u,E=l>=d+3*u,y=zF.filter(I=>I.myocSimplifiedMode===!1),x=["text","frame","embeddable","laser","magicframe"].filter(I=>!(b&&I==="text"||g&&I==="image"||E&&I==="frame")).includes(n.type),w=x?n.type==="text"?_n:n.type==="image"?uc:n.type==="frame"?Dn:n.type==="embeddable"?hc:n.type==="laser"?fi:n.type==="magicframe"?E0:gi:gi;return yf("div",{className:"mobile-toolbar",ref:I=>{I&&s(I.getBoundingClientRect().width)},children:[co(Sm,{checked:bo(e.state),onChange:o,title:f("toolBar.hand"),isMobile:!0}),co(Ud,{app:e,options:xf,activeTool:n,defaultOption:e.state.preferredSelectionTool.type,namePrefix:"selectionType",title:Bt(f("toolBar.selection")),"data-testid":"toolbar-selection",onToolChange:I=>{(I==="selection"||I==="lasso")&&(e.setActiveTool({type:I}),t({preferredSelectionTool:{type:I,initialized:!0}}))},displayedOption:xf.find(I=>I.type===e.state.preferredSelectionTool.type)||xf[0]}),co(Z,{className:fs({active:n.type==="freedraw"}),type:"radio",icon:Ln,checked:n.type==="freedraw",name:"editor-current-shape",title:`${Bt(f("toolBar.freedraw"))}`,"aria-label":Bt(f("toolBar.freedraw")),"data-testid":"toolbar-freedraw",onChange:()=>a("freedraw")}),b&&co(Z,{className:fs({active:n.type==="text"}),type:"radio",icon:_n,checked:n.type==="text",name:"editor-current-shape",title:`${Bt(f("toolBar.text"))}`,"aria-label":Bt(f("toolBar.text")),"data-testid":"toolbar-text",onChange:()=>a("text")}),g&&co(Z,{className:fs({active:n.type==="image"}),type:"radio",icon:uc,checked:n.type==="image",name:"editor-current-shape",title:`${Bt(f("toolBar.image"))}`,"aria-label":Bt(f("toolBar.image")),"data-testid":"toolbar-image",onChange:()=>a("image")}),co(Z,{className:fs({active:n.type==="eraser"}),type:"radio",icon:cE,checked:n.type==="eraser",name:"editor-current-shape",title:`${Bt(f("toolBar.eraser"))}`,"aria-label":Bt(f("toolBar.eraser")),"data-testid":"toolbar-eraser",onChange:()=>a("eraser")}),yf(we,{open:r,children:[co(we.Trigger,{className:fs("App-toolbar__extra-tools-trigger App-toolbar__extra-tools-trigger--mobile",{"App-toolbar__extra-tools-trigger--selected":x||r}),onToggle:()=>{i(!r),t({openMenu:null,openPopup:null})},title:f("toolBar.extraTools"),style:{width:c,height:c,display:"flex",alignItems:"center",justifyContent:"center"},children:w}),yf(we.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",align:"start",children:[y.map(({value:I,icon:C,key:A,fillable:k})=>{let L=f(`toolBar.${I}`),_=A&&Bt(typeof A=="string"?A:A[0]);return co(we.Item,{onSelect:()=>e.setActiveTool({type:I}),icon:C,"data-testid":`toolbar-${I}`,selected:n.type===I,shortcut:_??void 0,children:Bt(L)},I)}),co("div",{className:"App-toolbar__dropdown-divider"}),co(we.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?Mn:an,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:K3.Q,children:Bt(f("toolBar.lock-short"))}),!b&&co(we.Item,{onSelect:()=>e.setActiveTool({type:"text"}),icon:_n,shortcut:K3.T.toLocaleUpperCase(),"data-testid":"toolbar-text",selected:n.type==="text",children:f("toolBar.text")}),!g&&co(we.Item,{onSelect:()=>e.setActiveTool({type:"image"}),icon:uc,"data-testid":"toolbar-image",selected:n.type==="image",children:f("toolBar.image")})]})]})]})};import{Fragment as HF,jsx as Yr,jsxs as bs}from"react/jsx-runtime";var $3=({appState:e,elements:o,actionManager:t,setAppState:n,onHandToolToggle:r,renderTopLeftUI:i,renderTopRightUI:a,renderSidebars:l,renderWelcomeScreen:s,UIOptions:c,app:m,onPenModeToggle:p})=>{let{WelcomeScreenCenterTunnel:d}=Ze(),u=()=>Yr(Z3,{app:m,onHandToolToggle:r,setAppState:n});return bs(HF,{children:[l(),Yr("div",{className:"App-welcome-screen",children:s&&Yr(d.Out,{})}),bs("div",{className:"App-bottom-bar-container",style:{marginBottom:lo+yn},children:[Yr("div",{className:"App-bottom-bar-item",children:Yr(We,{children:bs("div",{className:"mobile-toolbar",children:[t.renderAction("viewMode"),t.renderAction("smartZoom")]})})}),!e.viewModeEnabled&&bs("div",{className:"App-bottom-bar-item",children:[Yr(bv,{appState:e,elementsMap:m.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:m,setAppState:n}),bs(We,{className:"App-toolbar",children:[!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&u(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&Yr("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{n(b=>({...xr(o,b)}))},children:f("buttons.scrollBackToContent")})]})]})]})]})};import j3,{useLayoutEffect as q3,useRef as J3,useState as Q3}from"react";import{newTextElement as eT}from"@excalidraw/element";import{jsx as wn,jsxs as Cm}from"react/jsx-runtime";var GF=e=>{switch(e){case"bar":return f("labels.chartType_bar");case"line":return f("labels.chartType_line");case"radar":return f("labels.chartType_radar");default:return e}},UF=e=>{let o=J3(null),[t,n]=Q3(null),{theme:r}=de();q3(()=>{if(!e.spreadsheet){n(null);return}let a=hf(e.chartType,e.spreadsheet,0,0,e.colorSeed);if(!a){n(null),o.current?.replaceChildren();return}n(a);let l,s=o.current;return(async()=>(l=await yr(a,{exportBackground:!1,viewBackgroundColor:"#fff",exportWithDarkMode:r==="dark"},null,{skipInliningFonts:!0}),l.querySelector(".style-fonts")?.remove(),s.replaceChildren(),s.appendChild(l)))(),()=>{s.replaceChildren()}},[e.spreadsheet,e.chartType,e.colorSeed,r]);let i=GF(e.chartType);return Cm("button",{type:"button",className:"ChartPreview","aria-label":i,onClick:()=>{t&&e.onClick(e.chartType,t)},children:[wn("div",{className:"ChartPreview__canvas",ref:o}),wn("div",{className:"ChartPreview__label",children:i})]})},WF=e=>{let o=J3(null),{theme:t}=de();return q3(()=>{if(!e.rawText)return;let n=eT({text:e.rawText,x:0,y:0}),r=o.current;return(async()=>{let i=await yr([n],{exportBackground:!1,viewBackgroundColor:"#fff",exportWithDarkMode:t==="dark"},null,{skipInliningFonts:!0});i.querySelector(".style-fonts")?.remove(),r.replaceChildren(),r.appendChild(i)})(),()=>{r.replaceChildren()}},[e.rawText,t]),Cm("button",{type:"button",className:"ChartPreview","aria-label":f("labels.chartType_plaintext"),onClick:()=>{e.onClick(e.rawText)},children:[wn("div",{className:"ChartPreview__canvas",ref:o}),wn("div",{className:"ChartPreview__label",children:f("labels.chartType_plaintext")})]})},tT=({data:e,rawText:o,onClose:t})=>{let{onInsertElements:n,focusContainer:r}=je(),[i,a]=Q3(Math.random()),l=j3.useCallback(()=>{a(Math.random())},[]),s=j3.useCallback(()=>{t&&t()},[t]),c=(p,d)=>{n(d),ce("paste","chart",p),t(),r()},m=p=>{let d=eT({text:p,x:0,y:0});n([d]),ce("paste","chart","plaintext"),t(),r()};return wn(qe,{size:"regular",onCloseRequest:s,title:Cm("div",{className:"PasteChartDialog__title",children:[wn("div",{className:"PasteChartDialog__titleText",children:f("labels.pasteCharts")}),wn("div",{className:"PasteChartDialog__reshuffleBtn",onClick:l,role:"button",tabIndex:0,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),l())},children:ui})]}),className:"PasteChartDialog",autofocus:!1,children:Cm("div",{className:"container",children:[["bar","line","radar"].map(p=>ya(e,p)?wn(UF,{chartType:p,spreadsheet:e,colorSeed:i,onClick:c},p):null),o&&wn(WF,{rawText:o,onClick:m})]})})};import{Fragment as YF,jsx as oT,jsxs as VF}from"react/jsx-runtime";var Es=({heading:e,children:o,...t})=>{let{id:n}=Ne(),r=oT("h2",{className:"visually-hidden",id:`${n}-${e}-title`,children:f(`headings.${e}`)});return oT("section",{...t,"aria-labelledby":`${n}-${e}-title`,children:typeof o=="function"?o(r):VF(YF,{children:[r,o]})})};import{Popover as km}from"radix-ui";import nT from"clsx";import Pm,{useLayoutEffect as XF}from"react";import{supportsResizeObserver as KF,isShallowEqual as ZF}from"@excalidraw/common";import{Fragment as QF,jsx as Xo,jsxs as Mm}from"react/jsx-runtime";var $F=4,jF=8,qF=({shouldWrap:e,children:o,username:t})=>e?Xo(gt,{label:t||"Unknown user",children:o}):Xo(QF,{children:o}),wf=({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 Xo(qF,{username:o.username,shouldWrap:r,children:l},t)},JF=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],Am=Pm.memo(({className:e,mobile:o,collaborators:t,userToFollow:n})=>{let r=Ye(),i=new Map;t.forEach((g,E)=>{let y=g.id||E;i.set(y,{...g,socketId:E})});let a=Array.from(i.values()).filter(g=>g.username?.trim()),[l,s]=Pm.useState(""),c=a.filter(g=>g.username?.toLowerCase().includes(l)),m=Pm.useRef(null);XF(()=>{if(m.current){let g=y=>{let v=Math.max(1,Math.min(8,Math.floor(y/38)));d(v)};if(g(m.current.clientWidth),!KF)return;let E=new ResizeObserver(y=>{for(let v of y){let{width:x}=v.contentRect;g(x)}});return E.observe(m.current),()=>{E.disconnect()}}},[]);let[p,d]=Pm.useState($F),b=a.slice(0,p-1).map(g=>wf({actionManager:r,collaborator:g,socketId:g.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:g.socketId===n}));return o?Xo("div",{className:nT("UserList UserList_mobile",e),children:a.map(g=>wf({actionManager:r,collaborator:g,socketId:g.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:g.socketId===n}))}):Xo("div",{className:"UserList__wrapper",ref:m,children:Mm("div",{className:nT("UserList",e),style:{"--max-avatars":p},children:[b,a.length>p-1&&Mm(km.Root,{children:[Mm(km.Trigger,{className:"UserList__more",children:["+",a.length-p+1]}),Xo(km.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:Mm(We,{padding:2,children:[a.length>=jF&&Xo(Hc,{placeholder:f("quickSearch.placeholder"),onChange:s}),Xo(Gc,{className:"dropdown-menu UserList__collaborators",placeholder:f("userList.empty"),children:c.length>0?[Xo("div",{className:"hint",children:f("userList.hint.text")}),c.map(g=>wf({actionManager:r,collaborator:g,socketId:g.socketId,withName:!0,isBeingFollowed:g.socketId===n}))]:[]}),Xo(km.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||!ZF(r,i,JF))return!1}return!0});import eO from"clsx";import{jsx as rT,jsxs as oO}from"react/jsx-runtime";var tO="medium",iT=e=>e.penDetected?oO("label",{className:eO("ToolIcon ToolIcon__penMode",`ToolIcon_size_${tO}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[rT("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),rT("div",{className:"ToolIcon__icon",children:lE})]}):null;import xs from"clsx";import{jsx as nO}from"react/jsx-runtime";var aT=e=>nO("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${f("helpDialog.title")} \u2014 ?`,"aria-label":f("helpDialog.title"),children:mi});import{jsx as Zt,jsxs as vf}from"react/jsx-runtime";var lT=({appState:e,actionManager:o,showExitZenModeBtn:t,renderWelcomeScreen:n})=>{let{FooterCenterTunnel:r,WelcomeScreenHelpHintTunnel:i}=Ze();return vf("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[Zt("div",{className:xs("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:Zt(bt.Col,{gap:2,children:vf(Es,{heading:"canvasActions",children:[Zt(gt,{label:f("labels.viewMode"),children:Zt("div",{className:xs("view-mode-button"),children:o.renderAction("viewMode")})}),Zt(gt,{label:f("buttons.smartZoom"),children:Zt("div",{className:xs("smart-zoom-button"),children:o.renderAction("smartZoom")})}),Zt(xv,{renderAction:o.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&Zt(yv,{renderAction:o.renderAction,className:xs("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),Zt(r.Out,{}),Zt("div",{className:xs("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:vf("div",{style:{position:"relative"},children:[n&&Zt(i.Out,{}),Zt(aT,{onClick:()=>o.executeAction(_r)})]})}),Zt(wv,{actionManager:o,showExitZenModeBtn:t})]})},sT=lT;lT.displayName="Footer";import gO from"clsx";import{useEffect as gT,useLayoutEffect as fT,useRef as Lf,useState as fO,forwardRef as bT,useImperativeHandle as bO,useCallback as pT}from"react";import{CLASSES as EO,EVENT as uT,isDevEnv as xO,KEYS as yO,updateObject as wO}from"@excalidraw/common";import iO from"clsx";import{useContext as aO}from"react";import rO from"react";var Lm=rO.createContext({});import{jsx as If,jsxs as cT}from"react/jsx-runtime";var Tf=({children:e,className:o})=>{let t=pe(),n=aO(Lm),r=!!(t.canFitSidebar&&n.shouldRenderDockButton);return cT("div",{className:iO("sidebar__header",o),"data-testid":"sidebar-header",children:[e,cT("div",{className:"sidebar__header__buttons",children:[r&&If(gt,{label:f("labels.sidebarLock"),children:If(Xt,{onSelect:()=>n.onDock?.(!n.docked),selected:!!n.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":f("labels.sidebarLock"),children:tE})}),If(Xt,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:n.onCloseRequest,"aria-label":f("buttons.close"),children:Qt})]})]})};Tf.displayName="SidebarHeader";import{Tabs as lO}from"radix-ui";import{jsx as dT}from"react/jsx-runtime";var Sf=({children:e,tab:o,onSelect:t,...n})=>dT(lO.Trigger,{value:o,asChild:!0,onSelect:t,children:dT("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...n,children:e})});Sf.displayName="SidebarTabTrigger";import{Tabs as sO}from"radix-ui";import{jsx as cO}from"react/jsx-runtime";var Cf=({children:e,...o})=>cO(sO.List,{className:"sidebar-triggers",...o,children:e});Cf.displayName="SidebarTabTriggers";import dO from"clsx";import{jsx as kf,jsxs as mT}from"react/jsx-runtime";var Pf=({name:e,tab:o,icon:t,title:n,children:r,onToggle:i,className:a,style:l})=>{let s=be(),c=de();return mT("label",{title:n,className:"sidebar-trigger__label-element",children:[kf("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:m=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let p=m.target.checked;s({openSidebar:p?{name:e,tab:o}:null,openMenu:null,openPopup:null}),i?.(p)},checked:c.openSidebar?.name===e,"aria-label":n,"aria-keyshortcuts":"0"}),mT("div",{className:dO("sidebar-trigger",a),style:l,children:[t&&kf("div",{children:t}),r&&kf("div",{className:"sidebar-trigger__label",children:r})]})]})};Pf.displayName="SidebarTrigger";import{Tabs as mO}from"radix-ui";import{jsx as pO}from"react/jsx-runtime";var Mf=({children:e,...o})=>{let t=de(),n=be();if(!t.openSidebar)return null;let{name:r}=t.openSidebar;return pO(mO.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>n(a=>({...a,openSidebar:{...a.openSidebar,name:r,tab:i}})),...o,children:e})};Mf.displayName="SidebarTabs";import{Tabs as uO}from"radix-ui";import{jsx as hO}from"react/jsx-runtime";var Af=({tab:e,children:o,...t})=>hO(uO.Content,{...t,value:e,"data-testid":e,children:o});Af.displayName="SidebarTab";import{jsx as hT}from"react/jsx-runtime";import{createElement as vO}from"react";var ys=_e(!1),ET=bT(({name:e,children:o,onDock:t,docked:n,className:r,...i},a)=>{xO()&&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=be(),s=si(ys);fT(()=>(s(!!n),()=>{s(!1)}),[s,n]);let c=Lf({});c.current.onCloseRequest=()=>{l({openSidebar:null})},c.current.onDock=u=>t?.(u),c.current=wO(c.current,{docked:n,shouldRenderDockButton:!!t&&n!=null});let m=Lf(null);bO(a,()=>m.current);let p=pe(),d=pT(()=>{document.querySelector(".Dialog")||l({openSidebar:null})},[l]);return Ii(m,pT(u=>{u.target.closest(".sidebar-trigger")||(!n||!p.canFitSidebar)&&d()},[d,n,p.canFitSidebar])),gT(()=>{let u=b=>{b.key===yO.ESCAPE&&(!n||!p.canFitSidebar)&&d()};return document.addEventListener(uT.KEYDOWN,u),()=>{document.removeEventListener(uT.KEYDOWN,u)}},[d,n,p.canFitSidebar]),hT(We,{...i,className:gO(EO.SIDEBAR,{"sidebar--docked":n},r),ref:m,children:hT(Lm.Provider,{value:c.current,children:o})})});ET.displayName="SidebarInner";var mo=Object.assign(bT((e,o)=>{let t=de(),{onStateChange:n}=e,r=Lf(t.openSidebar);gT(()=>{(!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]=fO(!1);return fT(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?vO(ET,{...e,ref:o,key:e.name}):null}),{Header:Tf,TabTriggers:Cf,TabTrigger:Sf,Tabs:Mf,Tab:Af,Trigger:Pf});mo.displayName="Sidebar";import{composeEventHandlers as AO}from"@excalidraw/common";import{useLayoutEffect as IO,useRef as TO}from"react";import{jsx as SO}from"react/jsx-runtime";var Vr=(e,o)=>{let t=_e(0),n=r=>{let{tunnelsJotai:{useAtom:i}}=Ze(),[,a]=i(t),l=TO({preferHost:!1,counter:0});return IO(()=>{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]),r.__fallback||(l.current.preferHost=!0),!l.current.counter&&r.__fallback&&l.current.preferHost||l.current.counter>1&&r.__fallback?null:SO(o,{...r})};return n.displayName=e,n};var Nf={};Tb(Nf,{ChangeCanvasBackground:()=>AT,CommandPalette:()=>CT,Export:()=>LT,Help:()=>PT,LiveCollaborationTrigger:()=>DT,LoadScene:()=>IT,Preferences:()=>Co,PreferencesToggleGridModeItem:()=>Rf,PreferencesToggleZenModeItem:()=>zT,SaveAsImage:()=>ST,SaveToActiveFile:()=>TT,SearchMenu:()=>kT,Socials:()=>_T,ToggleTheme:()=>MT});import MO from"clsx";import{THEME as ir}from"@excalidraw/common";var _f=_e({active:!1});async function xT({title:e,description:o,actionLabel:t,color:n}){return new Promise(r=>{ot.set(_f,{active:!0,onConfirm:()=>r(!0),onClose:()=>r(!1),onReject:()=>r(!1),title:e,description:o,actionLabel:t,color:n})})}import CO from"clsx";import{jsx as yT,jsxs as kO}from"react/jsx-runtime";var _m=function({onChange:e,value:o,choices:t,name:n}){return yT("div",{className:"RadioGroup",children:t.map(r=>kO("div",{className:CO("RadioGroup__choice",{active:r.value===o}),title:r.ariaLabel,children:[yT("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 PO,jsx as ws,jsxs as wT}from"react/jsx-runtime";var vT=({value:e,shortcut:o,onChange:t,choices:n,children:r,name:i,icon:a})=>{let l=pe();return wT(PO,{children:[wT("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[a&&ws("div",{className:"dropdown-menu-item__icon",children:a}),ws("label",{className:"dropdown-menu-item__text",children:ws(Cr,{children:r})}),ws(_m,{name:i,value:e,onChange:t,choices:n})]}),o&&l.formFactor!=="phone"&&ws("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:o})]})};vT.displayName="DropdownMenuItemContentRadio";var Df=vT;import{Fragment as UT,jsx as xe,jsxs as vs}from"react/jsx-runtime";var IT=()=>{let{t:e}=Me(),o=Ye(),t=Fn();return o.isActionEnabled(Fi)?xe(At,{icon:pi,onSelect:async()=>{(!t.length||await xT({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:xe(Vt,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:r=>xe("strong",{children:r}),br:()=>xe("br",{})})}))&&o.executeAction(Fi)},"data-testid":"load-button",shortcut:Se("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};IT.displayName="LoadScene";var TT=()=>{let{t:e}=Me(),o=Ye();return o.isActionEnabled(Lr)?xe(At,{shortcut:Se("saveScene"),"data-testid":"save-button",onSelect:()=>o.executeAction(Lr),icon:fE,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};TT.displayName="SaveToActiveFile";var ST=()=>{let e=be(),{t:o}=Me();return xe(At,{icon:fc,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:Se("imageExport"),"aria-label":o("buttons.exportImage"),children:o("buttons.exportImage")})};ST.displayName="SaveAsImage";var CT=e=>{let o=be(),{t}=Me();return xe(At,{icon:sl,"data-testid":"command-palette-button",onSelect:()=>{ce("command_palette","open","menu"),o({openDialog:{name:"commandPalette"}})},shortcut:Se("commandPalette"),"aria-label":t("commandPalette.title"),className:e?.className,children:t("commandPalette.title")})};CT.displayName="CommandPalette";var kT=e=>{let{t:o}=Me(),t=Ye();return xe(At,{icon:Gt,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(Jl)},shortcut:Se("searchMenu"),"aria-label":o("search.title"),className:e?.className,children:o("search.title")})};kT.displayName="SearchMenu";var PT=()=>{let{t:e}=Me(),o=Ye();return xe(At,{"data-testid":"help-menu-item",icon:mi,onSelect:()=>o.executeAction(_r),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};PT.displayName="Help";var MT=e=>{let{t:o}=Me(),t=de(),n=Ye(),r=Se("toggleTheme");return n.isActionEnabled(Pr)?e?.allowSystemTheme?xe(Df,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:ir.LIGHT,label:il,ariaLabel:`${o("buttons.lightMode")} - ${r}`},{value:ir.DARK,label:rl,ariaLabel:`${o("buttons.darkMode")} - ${r}`},{value:"system",label:_0,ariaLabel:o("buttons.systemMode")}],children:o("labels.theme")}):xe(At,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(t.theme===ir.DARK?ir.LIGHT:ir.DARK);else return n.executeAction(Pr)},icon:t.theme===ir.DARK?il:rl,"data-testid":"toggle-dark-mode",shortcut:r,"aria-label":t.theme===ir.DARK?o("buttons.lightMode"):o("buttons.darkMode"),children:t.theme===ir.DARK?o("buttons.lightMode"):o("buttons.darkMode")}):null};MT.displayName="ToggleTheme";var AT=()=>{let{t:e}=Me(),o=de(),t=Ye(),n=no();return o.viewModeEnabled||!n.UIOptions.canvasActions.changeViewBackgroundColor?null:vs("div",{style:{marginTop:"0.75rem"},children:[xe("div",{"data-testid":"canvas-background-label",style:{fontSize:"0.875rem",marginBottom:"0.25rem",marginLeft:"0.5rem"},children:e("labels.canvasBackground")}),xe("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};AT.displayName="ChangeCanvasBackground";var LT=()=>{let{t:e}=Me(),o=be();return xe(At,{icon:Ir,onSelect:()=>{o({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};LT.displayName="Export";var _T=()=>{let{t:e}=Me();return vs(UT,{children:[xe(na,{icon:uE,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),xe(na,{icon:gE,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),xe(na,{icon:hE,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};_T.displayName="Socials";var DT=({onSelect:e,isCollaborating:o})=>{let{t}=Me();return xe(At,{"data-testid":"collab-button",icon:bc,className:MO({"active-collab":o}),onSelect:e,children:t("labels.liveCollaboration")})};DT.displayName="LiveCollaborationTrigger";var RT=()=>{let{t:e}=Me(),o=je(),t=de();return xe(vo,{checked:t.activeTool.locked,shortcut:Se("toolLock"),onSelect:n=>{o.toggleLock(),n.preventDefault()},children:e("labels.preferences_toolLock")})},NT=()=>{let{t:e}=Me(),o=de(),t=be();return xe(Df,{name:"boxSelectionMode",icon:Tc,value:o.boxSelectionMode,onChange:n=>{t({boxSelectionMode:n})},choices:[{value:"contain",label:e("labels.boxSelectionContain"),ariaLabel:e("labels.boxSelectionContain")},{value:"overlap",label:e("labels.boxSelectionOverlap"),ariaLabel:e("labels.boxSelectionOverlap")}],children:e("labels.boxSelectionMode")})},BT=()=>{let{t:e}=Me(),o=Ye(),t=de();return xe(vo,{checked:t.objectsSnapModeEnabled,shortcut:Se("objectsSnapMode"),onSelect:n=>{o.executeAction(Dl),n.preventDefault()},children:e("buttons.objectsSnapMode")})},FT=()=>{let{t:e}=Me(),o=Ye(),t=de();return xe(vo,{checked:t.bindingPreference==="enabled",onSelect:n=>{o.executeAction(Rl),n.preventDefault()},children:e("labels.arrowBinding")})},OT=()=>{let{t:e}=Me(),o=Ye(),t=de();return xe(vo,{checked:t.isMidpointSnappingEnabled,onSelect:n=>{o.executeAction(Nl),n.preventDefault()},children:e("labels.midpointSnapping")})},Rf=()=>{let{t:e}=Me(),o=Ye(),t=de();return xe(vo,{checked:t.gridModeEnabled,shortcut:Se("gridMode"),onSelect:n=>{o.executeAction(Vi),n.preventDefault()},children:e("labels.toggleGrid")})},zT=()=>{let{t:e}=Me(),o=Ye(),t=de();return xe(vo,{checked:t.zenModeEnabled,shortcut:Se("zenMode"),onSelect:n=>{o.executeAction(_l),n.preventDefault()},children:e("buttons.zenMode")})},HT=()=>{let{t:e}=Me(),o=Ye(),t=de();return xe(vo,{checked:t.viewModeEnabled,shortcut:Se("viewMode"),onSelect:n=>{o.executeAction(ia),n.preventDefault()},children:e("labels.viewMode")})},GT=()=>{let{t:e}=Me(),o=Ye(),t=de();return xe(vo,{checked:t.stats.open,shortcut:Se("stats"),onSelect:n=>{o.executeAction(Kn),n.preventDefault()},children:e("stats.fullTitle")})},Co=({children:e,additionalItems:o})=>{let{t}=Me();return vs(jn,{children:[xe(jn.Trigger,{icon:G0,children:t("labels.preferences")}),vs(jn.Content,{className:"excalidraw-main-menu-preferences-submenu",children:[e||vs(UT,{children:[xe(NT,{}),xe(RT,{}),xe(BT,{}),xe(Rf,{}),xe(HT,{}),xe(GT,{}),xe(FT,{}),xe(OT,{})]}),o]})]})};Co.ToggleToolLock=RT;Co.BoxSelectionMode=NT;Co.ToggleSnapMode=BT;Co.ToggleArrowBinding=FT;Co.ToggleMidpointSnapping=OT;Co.ToggleGridMode=Rf;Co.ToggleZenMode=zT;Co.ToggleViewMode=HT;Co.ToggleElementProperties=GT;Co.displayName="Preferences";import{jsx as Dm,jsxs as Bf}from"react/jsx-runtime";var LO=Object.assign(Vr("MainMenu",({children:e,onSelect:o})=>{let{MainMenuTunnel:t}=Ze(),n=pe(),r=de(),i=be();return Dm(t.In,{children:Bf(we,{open:r.openMenu==="canvas",children:[Dm(we.Trigger,{onToggle:()=>{i({openMenu:r.openMenu==="canvas"?null:"canvas",openPopup:null,openDialog:null})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:mE}),Bf(we.Content,{onClickOutside:()=>i({openMenu:null}),onSelect:AO(o,()=>{i({openMenu:null})}),className:"main-menu",align:"start",children:[e,n.formFactor==="phone"&&r.collaborators.size>0&&Bf("fieldset",{className:"UserList-Wrapper",children:[Dm("legend",{children:f("labels.collaborators")}),Dm(Am,{mobile:!0,collaborators:r.collaborators,userToFollow:r.userToFollow?.socketId||null})]})]})]})})}),{Trigger:we.Trigger,Item:we.Item,ItemLink:we.ItemLink,ItemCustom:we.ItemCustom,Group:we.Group,Separator:we.Separator,Sub:jn,DefaultItems:Nf}),Ct=LO;import _O from"clsx";import{forwardRef as DO,useState as RO}from"react";import{isPromiseLike as NO}from"@excalidraw/common";import{jsx as Rm,jsxs as BO}from"react/jsx-runtime";var ar=DO(({children:e,icon:o,onClick:t,label:n,variant:r="filled",color:i="primary",size:a="medium",fullWidth:l,className:s,status:c,disabled:m},p)=>{let[d,u]=RO(!1),b=async E=>{let y=t?.(E);if(NO(y)){let v=window.setTimeout(()=>{u(!0)},50);try{await y}catch(x){if(x instanceof ii)console.warn(x);else throw x}finally{clearTimeout(v),u(!1)}}},g=d?"loading":c;return i=g==="success"?"success":i,Rm("button",{className:_O("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${r}`,`ExcButton--size-${a}`,`ExcButton--status-${g}`,{"ExcButton--fullWidth":l},s),onClick:b,type:"button","aria-label":n,ref:p,disabled:m||g==="loading"||g==="success",children:BO("div",{className:"ExcButton__contents",children:[g==="loading"?Rm(Ut,{className:"ExcButton__statusIcon"}):g==="success"&&Rm("div",{className:"ExcButton__statusIcon",children:g0}),o&&Rm("div",{className:"ExcButton__icon","aria-hidden":!0,children:o}),r!=="icon"&&(e??n)]})})});import{jsx as Pa,jsxs as zO}from"react/jsx-runtime";var Nm=({title:e,children:o,actionLabel:t,onClick:n})=>zO("div",{className:"OverwriteConfirm__Actions__Action",children:[Pa("h4",{children:e}),Pa("div",{className:"OverwriteConfirm__Actions__Action__content",children:o}),Pa(ar,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:n})]}),FO=()=>{let{t:e}=Me(),o=Ye(),t=be();return Pa(Nm,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{o.executeAction(dd,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},OO=()=>{let{t:e}=Me(),o=Ye();return Pa(Nm,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{o.executeAction(Al,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},Ff=Object.assign(({children:e})=>Pa("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:FO,SaveToDisk:OO});import{jsx as lr,jsxs as WT}from"react/jsx-runtime";var Bm=Object.assign(Vr("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:o}=Ze(),[t,n]=fe(_f);if(!t.active)return null;let r=()=>{t.onClose(),n(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),n(a=>({...a,active:!1}))};return lr(o.In,{children:lr(qe,{onCloseRequest:r,title:!1,size:916,children:WT("div",{className:"OverwriteConfirm",children:[lr("h3",{children:t.title}),WT("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[lr("div",{className:"OverwriteConfirm__Description__icon",children:f0}),lr("div",{children:t.description}),lr("div",{className:"OverwriteConfirm__Description__spacer"}),lr(ar,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),lr(Ff,{children:e})]})})})}),{Actions:Ff,Action:Nm});import lz from"clsx";import{CANVAS_SEARCH_TAB as Uf,DEFAULT_SIDEBAR as sz,LIBRARY_SIDEBAR_TAB as QT,composeEventHandlers as cz}from"@excalidraw/common";import{round as HO}from"@excalidraw/math";import GO from"clsx";import UO from"lodash.debounce";import{Fragment as WO,memo as YO,useEffect as Is,useMemo as YT,useRef as Of,useState as VT}from"react";import{CLASSES as VO,EVENT as XO,FONT_FAMILY as zf,FRAME_STYLE as Hf,getLineHeight as KO}from"@excalidraw/common";import{isElementCompletelyInViewport as ZO}from"@excalidraw/element";import{measureText as Ts}from"@excalidraw/element";import{KEYS as Ma,randomInteger as XT,addEventListener as $O,getFontString as Fm}from"@excalidraw/common";import{newTextElement as jO}from"@excalidraw/element";import{isTextElement as jT,isFrameLikeElement as Om}from"@excalidraw/element";import{getDefaultFrameName as qT}from"@excalidraw/element/frame";import{Fragment as az,jsx as lt,jsxs as Ko}from"react/jsx-runtime";var qO=_e(""),Gf=_e(null),JO=350,JT=()=>{let e=je(),o=be(),t=Of(null),[n,r]=fe(qO),i=n.trim(),[a,l]=VT(!1),[s,c]=VT({nonce:null,items:[]}),m=Of(null),p=Of(void 0),[d,u]=fe(Gf),b=e.scene.getNonDeletedElementsMap();Is(()=>{a||(i!==m.current||e.scene.getSceneNonce()!==p.current)&&(m.current=null,$T(i,e,(x,w)=>{c({nonce:XT(),items:x}),m.current=i,p.current=e.scene.getSceneNonce(),o({searchMatches:x.length?{focusedId:null,matches:x.map(I=>({id:I.element.id,focus:!1,matchedLines:I.matchedLines}))}:null})}))},[a,i,b,e,o,u,p]);let g=()=>{s.items.length>0&&u(x=>x===null?0:(x+1)%s.items.length)},E=()=>{s.items.length>0&&u(x=>x===null?0:x-1<0?s.items.length-1:x-1)};Is(()=>{o(x=>x.searchMatches?{searchMatches:{focusedId:d!==null&&x.searchMatches?.matches[d]?.id||null,matches:x.searchMatches.matches.map((I,C)=>C===d?{...I,focus:!0}:{...I,focus:!1})}}:null)},[d,o]),Is(()=>{if(s.items.length>0&&d!==null){let x=s.items[d];if(x){let w=e.state.zoom.value,I=jO({text:x.searchQuery,x:x.element.x+(x.matchedLines[0]?.offsetX??0),y:x.element.y+(x.matchedLines[0]?.offsetY??0),width:x.matchedLines[0]?.width,height:x.matchedLines[0]?.height,fontSize:Om(x.element)?Hf.nameFontSize:x.element.fontSize,fontFamily:Om(x.element)?zf.Assistant:x.element.fontFamily}),C=14,A=I.fontSize,k=A*w<C;if(!ZO([I],e.canvas.width/window.devicePixelRatio,e.canvas.height/window.devicePixelRatio,{offsetLeft:e.state.offsetLeft,offsetTop:e.state.offsetTop,scrollX:e.state.scrollX,scrollY:e.state.scrollY,zoom:e.state.zoom},e.scene.getNonDeletedElementsMap(),e.getEditorUIOffsets())||k){let L;k?A>=C?L={fitToContent:!0}:L={fitToViewport:!0,maxZoom:HO(C/A,1)}:L={fitToContent:!0},e.scrollToContent(I,{animate:!0,duration:300,...L,canvasOffsets:e.getEditorUIOffsets()})}}}},[d,s,e]),Is(()=>()=>{u(null),m.current=null,p.current=void 0,o({searchMatches:null}),l(!1)},[o,u]);let y=Rn({goToNextItem:g,goToPreviousItem:E,searchMatches:s});Is(()=>{let x=w=>{if(w.key===Ma.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){w.preventDefault(),w.stopPropagation(),o({openSidebar:null});return}if(w[Ma.CTRL_OR_CMD]&&w.key===Ma.F){if(w.preventDefault(),w.stopPropagation(),e.state.openDialog)return;t.current?.matches(":focus")||(e.state.openDialog&&o({openDialog:null}),t.current?.focus(),t.current?.select())}w.target instanceof HTMLElement&&w.target.closest(".layer-ui__search")&&y.searchMatches.items.length&&(w.key===Ma.ENTER&&(w.stopPropagation(),y.goToNextItem()),w.key===Ma.ARROW_UP?(w.stopPropagation(),y.goToPreviousItem()):w.key===Ma.ARROW_DOWN&&(w.stopPropagation(),y.goToNextItem()))};return $O(window,XO.KEYDOWN,x,{capture:!0,passive:!1})},[o,y,e]);let v=`${s.items.length} ${s.items.length===1?f("search.singleResult"):f("search.multipleResults")}`;return Ko("div",{className:"layer-ui__search",children:[lt("div",{className:"layer-ui__search-header",children:lt(qn,{className:VO.SEARCH_MENU_INPUT_WRAPPER,value:n,ref:t,placeholder:f("search.placeholder"),icon:Gt,onChange:x=>{r(x),l(!0);let w=x.trim();$T(w,e,(I,C)=>{c({nonce:XT(),items:I}),u(C),m.current=w,p.current=e.scene.getSceneNonce(),o({searchMatches:I.length?{focusedId:null,matches:I.map(A=>({id:A.element.id,focus:!1,matchedLines:A.matchedLines}))}:null}),l(!1)})},selectOnRender:!0})}),Ko("div",{className:"layer-ui__search-count",children:[s.items.length>0&&Ko(az,{children:[d!==null&&d>-1?Ko("div",{children:[d+1," / ",v]}):lt("div",{children:v}),Ko("div",{className:"result-nav",children:[lt(Xt,{onSelect:()=>{g()},className:"result-nav-btn",children:vc}),lt(Xt,{onSelect:()=>{E()},className:"result-nav-btn",children:B0})]})]}),s.items.length===0&&i&&m.current&&lt("div",{style:{margin:"1rem auto"},children:f("search.noMatch")})]}),lt(tz,{matches:s,onItemClick:u,focusIndex:d,searchQuery:i})]})},KT=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 lt("div",{tabIndex:-1,className:GO("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:lt("div",{className:"preview-text",children:o.flatMap((t,n)=>lt(WO,{children:n===2?lt("b",{children:t}):t},n))})})},QO=e=>{let o=YT(()=>e.matches.items.filter(n=>Om(n.element)),[e.matches]),t=YT(()=>e.matches.items.filter(n=>jT(n.element)),[e.matches]);return Ko("div",{children:[o.length>0&&Ko("div",{className:"layer-ui__search-result-container",children:[Ko("div",{className:"layer-ui__search-result-title",children:[lt("div",{className:"title-icon",children:Dn}),lt("div",{children:f("search.frames")})]}),o.map((n,r)=>lt(KT,{searchQuery:e.searchQuery,preview:n.preview,highlighted:r===e.focusIndex,onClick:()=>e.onItemClick(r)},n.element.id+n.index)),t.length>0&&lt("div",{className:"layer-ui__divider"})]}),t.length>0&&Ko("div",{className:"layer-ui__search-result-container",children:[Ko("div",{className:"layer-ui__search-result-title",children:[lt("div",{className:"title-icon",children:_n}),lt("div",{children:f("search.texts")})]}),t.map((n,r)=>lt(KT,{searchQuery:e.searchQuery,preview:n.preview,highlighted:r+o.length===e.focusIndex,onClick:()=>e.onItemClick(r+o.length)},n.element.id+n.index))]})]})},ez=(e,o)=>e.matches.nonce===o.matches.nonce&&e.focusIndex===o.focusIndex,tz=YO(QO,ez),ZT=(e,o,t)=>{let i=e.slice(0,o),a=i.split(/\s+/),l=i.endsWith(" "),s=a.length-2-1-(l?0:1),c=a.slice(s<=0?0:s).join(" ")+(l?" ":""),m=20;c=c.length>m?c.slice(-m):c;let p=e.slice(o+t.length),d=p.split(/\s+/),u=!p.startsWith(" "),b=u?6:5,g=(u?"":" ")+d.slice(0,b).join(" ");return{indexInSearchQuery:c.length,previewText:c+t+g,moreBefore:s>0,moreAfter:d.length>b}},oz=(e,o)=>{let t=e.split(`
19
19
  `),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 c=s-(a.length+r);for(;c>0;)a+=" ",c--}}n.push(a),r=r+a.length}return n.join(`
20
20
  `)},nz=(e,o,t)=>{let r=oz(e.text,e.originalText).split(`
21
- `),i=[],a=0,l=0;for(let p of r){let d=a,u=d+p.length-1;i.push({line:p,startIndex:d,endIndex:u,lineNumber:l}),a=u+1,l++}let s=t,c=e.originalText.slice(t,t+o.length),m=[];for(let p of i){if(c==="")break;if(s>=p.startIndex&&s<=p.endIndex){let d=p.endIndex+1-s,u=p.line.slice(0,s-p.startIndex),b=c.slice(0,d);c=c.slice(d);let g=Ts(u,Fm(e),e.lineHeight);if(u===""&&(g.width=0),e.textAlign!=="left"&&p.line.length>0){let w=Ts(p.line,Fm(e),e.lineHeight),I=e.textAlign==="center"?(e.width-w.width)/2:e.width-w.width;g.width+=I}let{width:E,height:y}=Ts(b,Fm(e),e.lineHeight),v=g.width,x=p.lineNumber*g.height;m.push({offsetX:v,offsetY:x,width:E,height:y,showOnCanvas:!0}),s+=d}}return m},rz=(e,o,t,n)=>{let r=e.name??qT(e),i=r.slice(t,t+o.length),a=r.slice(0,t),l=Fm({fontSize:Hf.nameFontSize,fontFamily:zf.Assistant}),s=KO(zf.Assistant),c=Ts(a,l,s);a===""&&(c.width=0);let m=Ts(i,l,s),p=c.width,d=-c.height-Hf.strokeWidth,u=m.width;return[{offsetX:p,offsetY:d,width:u,height:m.height,showOnCanvas:p+u<=e.width*n}]},iz=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),$T=UO((e,o,t)=>{if(!e||e===""){t([],null);return}let n=o.scene.getNonDeletedElements(),r=n.filter(d=>jT(d)),i=n.filter(d=>Om(d));r.sort((d,u)=>d.y-u.y),i.sort((d,u)=>d.y-u.y);let a=[],l=new RegExp(iz(e),"gi");for(let d of r){let u=null,b=d.originalText;for(;(u=l.exec(b))!==null;){let g=ZT(b,u.index,e),E=nz(d,e,u.index);E.length>0&&a.push({element:d,searchQuery:e,preview:g,index:u.index,matchedLines:E})}}let s=[];for(let d of i){let u=null,b=d.name??qT(d);for(;(u=l.exec(b))!==null;){let g=ZT(b,u.index,e),E=rz(d,e,u.index,o.state.zoom.value);E.length>0&&s.push({element:d,searchQuery:e,preview:g,index:u.index,matchedLines:E})}}let c=new Set(o.visibleElements.map(d=>d.id)),m=[...s,...a],p=m.findIndex(d=>c.has(d.element.id))??null;t(m,p)},JO);import{jsx as ko,jsxs as eS}from"react/jsx-runtime";import{createElement as dz}from"react";var tS=Vr("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:o}=Ze();return ko(o.In,{children:ko(mo.Trigger,{...e,className:"default-sidebar-trigger",name:sz.name})})});tS.displayName="DefaultSidebarTrigger";var oS=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:o}=Ze();return ko(o.In,{children:e})};oS.displayName="DefaultTabTriggers";var zm=Object.assign(Vr("DefaultSidebar",({children:e,className:o,onDock:t,docked:n,...r})=>{let i=de(),a=be(),{DefaultSidebarTabTriggersTunnel:l}=Ze(),s=i.openSidebar?.tab===Uf;return dz(mo,{...r,name:"default",key:"default",className:lz("default-sidebar",o),docked:s||(n??i.defaultSidebarDockedPreference),onDock:s||t===!1||!t&&n!=null?void 0:cz(t,c=>{a({defaultSidebarDockedPreference:c})})},eS(mo.Tabs,{children:[ko(mo.Header,{children:eS(mo.TabTriggers,{children:[ko(mo.TabTrigger,{tab:Uf,children:Gt}),ko(mo.TabTrigger,{tab:QT,children:lc}),ko(l.Out,{})]})}),ko(mo.Tab,{tab:QT,children:ko(q2,{})}),ko(mo.Tab,{tab:Uf,children:ko(JT,{})}),e]}))}),{Trigger:tS,TabTriggers:oS});import{round as XS}from"@excalidraw/math";import NH from"clsx";import BH from"lodash.throttle";import{useEffect as KS,useMemo as n1,useState as FH,memo as OH}from"react";import{STATS_PANELS as $m}from"@excalidraw/common";import{getCommonBounds as zH}from"@excalidraw/element";import{getUncroppedWidthAndHeight as HH}from"@excalidraw/element";import{isImageElement as r1}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as GH}from"@excalidraw/element";import{elementsAreInSameGroup as UH}from"@excalidraw/element";import{degreesToRadians as dS,radiansToDegrees as hS}from"@excalidraw/math";import{getBoundTextElement as mS}from"@excalidraw/element";import{isArrowElement as pS,isElbowArrow as Iz}from"@excalidraw/element";import{updateBindings as uS}from"@excalidraw/element";import bz from"clsx";import{useEffect as sS,useRef as Gm,useState as Ez}from"react";import{EVENT as _a,KEYS as xz,cloneJSON as Wf}from"@excalidraw/common";import{deepCopyElement as yz}from"@excalidraw/element";import{CaptureUpdateAction as cS}from"@excalidraw/element";import{pointFrom as sr,pointRotateRads as Hm}from"@excalidraw/math";import{getBoundTextElement as mz,isBindingElement as pz,unbindBindingElement as nS}from"@excalidraw/element";import{isFrameLikeElement as aS}from"@excalidraw/element";import{getSelectedGroupIds as uz,getElementsInGroup as hz,isInGroup as gz}from"@excalidraw/element";import{getFrameChildren as fz}from"@excalidraw/element";import{updateBindings as rS}from"@excalidraw/element";import{DRAGGING_THRESHOLD as iS}from"@excalidraw/common";var lS=.01,Ss=10,Ft=(e,o)=>!(o==="angle"&&aS(e)),Ue=(e,o)=>{let t=e+o/2;return t-t%o},Aa=(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 Xr=(e,o,t,n,r,i,a=!0)=>{if(pz(t)&&(t.startBinding||t.endBinding)){if(Math.abs(e-t.x)<iS&&Math.abs(o-t.y)<iS)return;nS(t,"start",n),nS(t,"end",n)}let l=n.getNonDeletedElementsMap(),s=l.get(t.id);if(!s)return;let[c,m]=[t.x+t.width/2,t.y+t.height/2],[p,d]=Hm(sr(t.x,t.y),sr(c,m),t.angle),u=e-p,b=o-d,[g,E]=Hm(sr(e,o),sr(c+u,m+b),-t.angle);n.mutateElement(s,{x:g,y:E},{informMutation:a,isDragging:!1}),rS(s,n,r);let y=mz(t,i);if(y){let v=l.get(y.id);v&&n.mutateElement(v,{x:y.x+u,y:y.y+b},{informMutation:a,isDragging:!1})}if(aS(t)){let v=fz(i,t.id);v.forEach(x=>{let w=l.get(x.id);if(!w)return;let[I,C]=[x.x+x.width/2,x.y+x.height/2],[A,k]=Hm(sr(x.x,x.y),sr(I,C),x.angle),L=Math.round(A+u),_=Math.round(k+b),[M,D]=Hm(sr(L,_),sr(I+u,C+b),-x.angle);n.mutateElement(w,{x:M,y:D},{informMutation:a,isDragging:!1}),rS(w,n,r,{simultaneouslyUpdated:v})})}},La=(e,o)=>{let n=uz(o).map(r=>hz(e,r).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(r=>!gz(r)).forEach(r=>{n.push({[r.id]:!0})}),n};import{jsx as Yf,jsxs as vz}from"react/jsx-runtime";var wz=({label:e,icon:o,dragInputCallback:t,value:n,elements:r,editable:i=!0,shouldKeepAspectRatio:a,property:l,scene:s,appState:c,sensitivity:m=1,dragFinishedCallback:p})=>{let d=je(),u=be(),b=Gm(null),g=Gm(null),[E,y]=Ez(n.toString()),v=Gm(null);v.current||(v.current={originalAppState:Wf(c),originalElements:r,lastUpdatedValue:E,updatePending:!1}),sS(()=>{let I=n.toString();y(I),v.current.lastUpdatedValue=I},[n]);let x=(I,C,A)=>{if(!v.current.updatePending)return!1;v.current.updatePending=!1;let k=Number(I);if(isNaN(k)){y(n.toString());return}let L=Number(k.toFixed(2)),_=Number(n);(isNaN(_)||Math.abs(L-_)>=lS)&&(v.current.lastUpdatedValue=I,t({accumulatedChange:0,instantChange:0,originalElements:C,originalElementsMap:d.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:s,nextValue:L,property:l,originalAppState:A,setInputValue:M=>y(String(M)),app:d,setAppState:u}),d.syncActionResult({captureUpdate:cS.IMMEDIATELY}))},w=Gm({});return w.current.handleInputValue=x,sS(()=>{let I=b.current,C=w.current;return()=>{let A=I?.value;A&&C.handleInputValue?.(A,v.current.originalElements,v.current.originalAppState),window.removeEventListener(_a.POINTER_MOVE,C.onPointerMove,!1),window.removeEventListener(_a.POINTER_UP,C.onPointerUp,!1)}},[i]),i?vz("div",{className:bz("drag-input-container",!i&&"disabled"),"data-testid":e,children:[Yf("div",{className:"drag-input-label",ref:g,onPointerDown:I=>{if(b.current&&i){document.body.classList.add("excalidraw-cursor-resize");let C=Number(b.current.value);isNaN(C)&&(C=0);let A=null,k=d.scene.getNonDeletedElements().reduce((O,K)=>(O.set(K.id,yz(K)),O),new Map),L=r.map(O=>k.get(O.id)),_=Wf(c),M=0,D=0,z=O=>{if(A&&k!==null&&L!==null){let K=O.clientX-A.x;K!==0&&(D+=K,Math.abs(D)>=m&&(D=Math.sign(D)*Math.floor(Math.abs(D)/m),M+=D,t({accumulatedChange:M,instantChange:D,originalElements:L,originalElementsMap:k,shouldKeepAspectRatio:a,shouldChangeByStepSize:O.shiftKey,property:l,scene:s,originalAppState:_,setInputValue:Y=>y(String(Y)),app:d,setAppState:u}),D=0))}A={x:O.clientX,y:O.clientY}},W=()=>{window.removeEventListener(_a.POINTER_MOVE,z,!1),d.syncActionResult({captureUpdate:cS.IMMEDIATELY}),p?.({app:d,setAppState:u,originalElements:L,originalAppState:_}),A=null,M=0,D=0,L=null,k=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(_a.POINTER_UP,W,!1)};w.current.onPointerMove=z,w.current.onPointerUp=W,window.addEventListener(_a.POINTER_MOVE,z,!1),window.addEventListener(_a.POINTER_UP,W,!1)}},onPointerEnter:()=>{g.current&&(g.current.style.cursor="ew-resize")},children:o?Yf(Mi,{icon:o}):e}),Yf("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:I=>{if(i){let C=I.target;C instanceof HTMLInputElement&&I.key===xz.ENTER&&(x(C.value,r,c),d.focusContainer())}},ref:b,value:E,onChange:I=>{v.current.updatePending=!0,y(I.target.value)},onFocus:I=>{I.target.select(),v.current.originalElements=r,v.current.originalAppState=Wf(c)},onBlur:I=>{E?i&&x(I.target.value,v.current.originalElements,v.current.originalAppState):y(n.toString())},disabled:!i})]}):null},st=wz;import{jsx as kz}from"react/jsx-runtime";var Tz=15,Sz=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,scene:r,app:i})=>{let a=r.getNonDeletedElementsMap(),l=o[0];if(l&&!Iz(l)){let s=a.get(l.id);if(!s)return;if(n!==void 0){let b=dS(n);r.mutateElement(s,{angle:b}),uS(s,r,i.state);let g=mS(s,a);g&&!pS(s)&&r.mutateElement(g,{angle:b});return}let c=Math.round(hS(l.angle)*100)/100,m=Math.round(e),p=(c+m)%360;t&&(p=Ue(p,Tz)),p=p<0?p+360:p;let d=dS(p);r.mutateElement(s,{angle:d}),uS(s,r,i.state);let u=mS(s,a);u&&!pS(s)&&r.mutateElement(u,{angle:d})}},Cz=({element:e,scene:o,appState:t,property:n})=>kz(st,{label:"A",icon:xc,value:Math.round(hS(e.angle)%360*100)/100,elements:[e],dragInputCallback:Sz,editable:Ft(e,"angle"),scene:o,appState:t,property:n}),gS=Cz;import{jsx as Mz}from"react/jsx-runtime";var fS=5,Pz=({property:e,scene:o,appState:t,setAppState:n})=>Mz(st,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:r,instantChange:i,shouldChangeByStepSize:a,setInputValue:l})=>{n(s=>{let c;return r?c=r:i&&(c=a?Ue(s.gridStep+fS*Math.sign(i),fS):s.gridStep+i),c?(c=kb(c),l(c),{gridStep:c}):(l(s.gridStep),null)})},scene:o,value:t.gridStep,property:e,appState:t}),bS=Pz;import{clamp as Um,round as Vf}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as Wm}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as ES,getUncroppedWidthAndHeight as wS}from"@excalidraw/element";import{resizeSingleElement as xS}from"@excalidraw/element";import{isImageElement as vS}from"@excalidraw/element";import{isFrameLikeElement as Xf}from"@excalidraw/element";import{getElementsInResizingFrame as Kf}from"@excalidraw/element";import{replaceAllElementsInFrame as IS}from"@excalidraw/element";import{jsx as Rz}from"react/jsx-runtime";var yS=10,Az=e=>e.type==="image",Lz=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldKeepAspectRatio:n,shouldChangeByStepSize:r,nextValue:i,property:a,originalAppState:l,instantChange:s,scene:c,app:m,setAppState:p})=>{let d=c.getNonDeletedElementsMap(),u=o[0],b=d.get(u.id);if(u&&b){let g=n||Az(u),E=u.width/u.height;if(l.croppingElementId===u.id){let y=d.get(u.id);if(!y||!vS(y)||!y.crop)return;let v=y.crop,x={...v},w=y.scale[0]===-1,I=y.scale[1]===-1,{width:C,height:A}=wS(y),k=v.naturalWidth/C,L=v.naturalHeight/A,_=w?v.width+v.x:v.naturalWidth-v.x,M=I?v.height+v.y:v.naturalHeight-v.y,D=ES*k,z=ES*L;if(i!==void 0){if(a==="width"){let q=i*k,ne=Um(q,D,_);x={...x,width:ne,x:w?v.x+v.width-ne:v.x}}else if(a==="height"){let q=i*L,ne=Um(q,z,M);x={...x,height:ne,y:I?v.y+v.height-ne:v.y}}c.mutateElement(y,{crop:x,width:x.width/(v.naturalWidth/C),height:x.height/(v.naturalHeight/A)});return}let W=a==="width"?s:0,O=a==="height"?s:0,K=Um(v.width+W,D,_),Y=Um(v.height+O,D,M);x={...v,x:w?v.x+v.width-K:v.x,y:I?v.y+v.height-Y:v.y,width:K,height:Y},c.mutateElement(y,{crop:x,width:x.width/(v.naturalWidth/C),height:x.height/(v.naturalHeight/A)});return}if(i!==void 0){let y=Math.max(a==="width"?i:g?i*E:u.width,Wm),v=Math.max(a==="height"?i:g?i/E:u.height,Wm);if(xS(y,v,b,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),Xf(b)){let x=Kf(c.getElementsIncludingDeleted(),b,l,c.getNonDeletedElementsMap()),w=IS(c.getElementsIncludingDeleted(),x,b);c.replaceAllElements(w)}return}{let y=a==="width"?e:0,v=a==="height"?e:0,x=Math.max(0,u.width+y);a==="width"&&(r?x=Ue(x,yS):x=Math.round(x));let w=Math.max(0,u.height+v);if(a==="height"&&(r?w=Ue(w,yS):w=Math.round(w)),g&&(a==="width"?w=Math.round(x/E*100)/100:x=Math.round(w*E*100)/100),w=Math.max(Wm,w),x=Math.max(Wm,x),xS(x,w,b,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),Xf(b)){let I=Kf(c.getElementsIncludingDeleted(),b,l,c.getNonDeletedElementsMap());p({elementsToHighlight:I})}}}},_z=({setAppState:e,app:o,originalElements:t,originalAppState:n})=>{let r=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&Xf(a)){let l=Kf(o.scene.getElementsIncludingDeleted(),a,n,o.scene.getNonDeletedElementsMap()),s=IS(o.scene.getElementsIncludingDeleted(),l,a);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},Dz=({property:e,element:o,scene:t,appState:n})=>{let r=Vf(e==="width"?o.width:o.height,2);if(n.croppingElementId&&n.croppingElementId===o.id&&vS(o)&&o.crop){let{width:i,height:a}=wS(o);if(e==="width"){let l=i/o.crop.naturalWidth;r=Vf(o.crop.width*l,2)}if(e==="height"){let l=a/o.crop.naturalHeight;r=Vf(o.crop.height*l,2)}}return Rz(st,{label:e==="width"?"W":"H",elements:[o],dragInputCallback:Lz,value:r,editable:Ft(o,e),scene:t,appState:n,property:e,dragFinishedCallback:_z})},Zf=Dz;import{getBoundTextElement as Nz,redrawTextBoundingBox as Bz}from"@excalidraw/element";import{hasBoundTextElement as Fz,isTextElement as SS}from"@excalidraw/element";import{jsx as Gz}from"react/jsx-runtime";var TS=4,Oz=4,zz=({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||!SS(l))return;let s;if(n!==void 0)s=Math.max(Math.round(n),TS);else if(a.type==="text"){let c=Math.round(a.fontSize),m=Math.round(e);s=Math.max(c+m,TS),t&&(s=Ue(s,Oz))}s&&(r.mutateElement(l,{fontSize:s}),Bz(l,r.getContainerElement(l),r))}},Hz=({element:e,scene:o,appState:t,property:n})=>{let r=SS(e)?e:Fz(e)?Nz(e,o.getNonDeletedElementsMap()):null;return r?Gz(st,{label:"F",value:Math.round(r.fontSize*10)/10,elements:[r],dragInputCallback:zz,icon:Tr,appState:t,scene:o,property:n}):null},CS=Hz;import{degreesToRadians as kS,radiansToDegrees as AS}from"@excalidraw/math";import{getBoundTextElement as PS}from"@excalidraw/element";import{isArrowElement as MS}from"@excalidraw/element";import{isInGroup as $f}from"@excalidraw/element";import{jsx as Vz}from"react/jsx-runtime";var Uz=15,Wz=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,property:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),l=o.map(c=>a.get(c.id)).filter(c=>c&&!$f(c)&&Ft(c,r)),s=o.filter(c=>!$f(c)&&Ft(c,r));if(n!==void 0){let c=kS(n);for(let m of l){if(!m)continue;i.mutateElement(m,{angle:c});let p=PS(m,a);p&&!MS(m)&&i.mutateElement(p,{angle:c})}i.triggerUpdate();return}for(let c=0;c<l.length;c++){let m=l[c];if(!m)continue;let p=s[c],d=Math.round(AS(p.angle)*100)/100,u=Math.round(e),b=(d+u)%360;t&&(b=Ue(b,Uz)),b=b<0?b+360:b;let g=kS(b);i.mutateElement(m,{angle:g});let E=PS(m,a);E&&!MS(m)&&i.mutateElement(E,{angle:g})}i.triggerUpdate()},Yz=({elements:e,scene:o,appState:t,property:n})=>{let r=e.filter(s=>!$f(s)&&Ft(s,"angle")),i=r.map(s=>Math.round(AS(s.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",l=r.some(s=>Ft(s,"angle"));return Vz(st,{label:"A",icon:xc,value:a,elements:e,dragInputCallback:Wz,editable:l,appState:t,scene:o,property:n})},LS=Yz;import{pointFrom as NS}from"@excalidraw/math";import{useMemo as nH}from"react";import{MIN_WIDTH_OR_HEIGHT as cr}from"@excalidraw/common";import{getElementsInResizingFrame as qf,isFrameLikeElement as Jf,replaceAllElementsInFrame as OS,updateBoundElements as rH}from"@excalidraw/element";import{rescalePointsInElement as iH,resizeSingleElement as BS}from"@excalidraw/element";import{getBoundTextElement as aH,handleBindTextResize as lH}from"@excalidraw/element";import{isTextElement as zS}from"@excalidraw/element";import{arrayToMap as Xz}from"@excalidraw/common";import{getElementBounds as Kz}from"@excalidraw/element";import{isArrowElement as Zz,isExcalidrawElement as $z,isFreeDrawElement as jz,isLinearElement as qz,isTextElement as Jz}from"@excalidraw/element";import{rangeIncludesValue as Ym,pointFrom as vn,pointRotateRads as Qz,rangeInclusive as Vm}from"@excalidraw/math";var eH=e=>e.type==="diamond"?[vn(e.width/2,0),vn(e.width,e.height/2),vn(e.width/2,e.height),vn(0,e.height/2)]:[vn(0,0),vn(0+e.width,0),vn(0+e.width,e.height),vn(0,e.height)],tH=e=>qz(e)||jz(e)?e.points:eH(e),_S=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},DS=e=>{let o=tH(e),{cx:t,cy:n}=_S(o),r=vn(t,n),i=o.map(m=>Qz(m,r,e.angle)),{minX:a,minY:l,maxX:s,maxY:c}=_S(i);return[a+e.x,l+e.y,s+e.x,c+e.y]},jf=(e,o,t=!1)=>{let n=DS(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},RS=(e,o)=>{let t=DS(e);return(Ym(t[0],Vm(o[0],o[2]))||Ym(o[0],Vm(t[0],t[2])))&&(Ym(t[1],Vm(o[1],o[3]))||Ym(o[1],Vm(t[1],t[3])))},oH=({elements:e,bounds:o,type:t,errorMargin:n=0})=>{$z(o)&&(o=Kz(o,Xz(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"?RS(a,r):t==="inside"?jf(a,r):jf(a,r,!0)){if(i.add(a.id),a.boundElements)for(let s of a.boundElements)i.add(s.id);Jz(a)&&a.containerId&&i.add(a.containerId),Zz(a)&&(a.startBinding&&i.add(a.startBinding.elementId),a.endBinding&&i.add(a.endBinding?.elementId))}}return e.filter(a=>i.has(a.id))};import{getCommonBounds as Xm}from"@excalidraw/element";import{jsx as uH}from"react/jsx-runtime";var Da=10,sH=(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,c=o+i*t;return{width:a,height:l,x:s,y:c,...iH(n,a,l,!1),...zS(n)?{fontSize:n.fontSize*t}:{}}},cH=(e,o,t,n,r,i,a,l)=>{let s=l.getNonDeletedElementsMap(),c=sH(e,o,n,i);l.mutateElement(r,c);let m=aH(i,a);if(m){let p=m.fontSize*n;rH(r,l);let d=s.get(m.id);d&&zS(d)&&(l.mutateElement(d,{fontSize:p}),lH(r,l,t==="width"?"e":"s",!0))}},FS=(e,o,t,n,r,i,a,l,s,c)=>{i==="width"?o=Math.round(e/n*100)/100:e=Math.round(o*n*100)/100;let m=o/t;for(let p=0;p<l.length;p++){let d=l[p],u=a[p];cH(r[0],r[1],i,m,u,d,s,c)}},dH=({accumulatedChange:e,originalElements:o,originalElementsMap:t,originalAppState:n,shouldChangeByStepSize:r,nextValue:i,scene:a,property:l,setAppState:s,app:c})=>{let m=a.getNonDeletedElementsMap(),p=La(o,n);if(i!==void 0){for(let g of p){let E=Aa(g,m,t);if(E.length>1){let y=E.map(D=>D.latest),v=E.map(D=>D.original),[x,w,I,C]=Xm(v),A=I-x,k=C-w,L=A/k,_=Math.max(cr,l==="width"?Math.max(0,i):A),M=Math.max(cr,l==="height"?Math.max(0,i):k);FS(_,M,k,L,NS(x,w),l,y,v,t,a)}else{let[y]=E,v=y?.latest,x=y?.original;if(v&&x&&Ft(v,l)){let w=l==="width"?Math.max(0,i):v.width;l==="width"&&(r?w=Ue(w,Da):w=Math.round(w));let I=l==="height"?Math.max(0,i):v.height;if(l==="height"&&(r?I=Ue(I,Da):I=Math.round(I)),w=Math.max(cr,w),I=Math.max(cr,I),BS(w,I,v,x,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),Jf(v)){let C=qf(a.getElementsIncludingDeleted(),v,n,a.getNonDeletedElementsMap()),A=OS(a.getElementsIncludingDeleted(),C,v);a.replaceAllElements(A)}}}}a.triggerUpdate();return}let d=l==="width"?e:0,u=l==="height"?e:0,b=[];for(let g of p){let E=Aa(g,m,t);if(E.length>1){let y=E.map(D=>D.latest),v=E.map(D=>D.original),[x,w,I,C]=Xm(v),A=I-x,k=C-w,L=A/k,_=Math.max(0,A+d);l==="width"&&(r?_=Ue(_,Da):_=Math.round(_));let M=Math.max(0,k+u);l==="height"&&(r?M=Ue(M,Da):M=Math.round(M)),_=Math.max(cr,_),M=Math.max(cr,M),FS(_,M,k,L,NS(x,w),l,y,v,t,a)}else{let[y]=E,v=y?.latest,x=y?.original;if(v&&x&&Ft(v,l)){let w=Math.max(0,x.width+d);l==="width"&&(r?w=Ue(w,Da):w=Math.round(w));let I=Math.max(0,x.height+u);if(l==="height"&&(r?I=Ue(I,Da):I=Math.round(I)),w=Math.max(cr,w),I=Math.max(cr,I),BS(w,I,v,x,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),Jf(v)){let C=qf(a.getElementsIncludingDeleted(),v,n,a.getNonDeletedElementsMap());b.push(...C)}}}}s({elementsToHighlight:b}),a.triggerUpdate()},mH=({setAppState:e,app:o,originalElements:t,originalAppState:n})=>{let r=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&Jf(a)){let l=qf(o.scene.getElementsIncludingDeleted(),a,n,o.scene.getNonDeletedElementsMap()),s=OS(o.scene.getElementsIncludingDeleted(),l,a);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},pH=({property:e,elements:o,elementsMap:t,atomicUnits:n,scene:r,appState:i})=>{let a=nH(()=>n.map(c=>{let m=Aa(c,t);if(m.length>1){let[d,u,b,g]=Xm(m.map(E=>E.latest));return Math.round((e==="width"?b-d:g-u)*100)/100}let[p]=m;return Math.round((e==="width"?p.latest.width:p.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 uH(st,{label:e==="width"?"W":"H",elements:o,dragInputCallback:dH,value:l,editable:s,appState:i,property:e,scene:r,dragFinishedCallback:mH})},Qf=pH;import{getBoundTextElement as hH,redrawTextBoundingBox as HS}from"@excalidraw/element";import{hasBoundTextElement as gH,isTextElement as fH}from"@excalidraw/element";import{isInGroup as bH}from"@excalidraw/element";import{jsx as vH}from"react/jsx-runtime";var GS=4,EH=4,xH=(e,o)=>e.reduce((t,n)=>{if(!n||bH(n))return t;if(fH(n))return t.push(n),t;if(gH(n)){let r=hH(n,o);if(r)return t.push(r),t}return t},[]),yH=({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),GS);for(let s of a)r.mutateElement(s,{fontSize:l}),HS(s,r.getContainerElement(s),r);r.triggerUpdate()}else{let s=o;for(let c=0;c<a.length;c++){let m=a[c],p=s[c],d=Math.round(p.fontSize),u=Math.round(e),b=Math.max(d+u,GS);t&&(b=Ue(b,EH)),r.mutateElement(m,{fontSize:b}),HS(m,r.getContainerElement(m),r)}r.triggerUpdate()}},wH=({elements:e,scene:o,appState:t,property:n,elementsMap:r})=>{let i=xH(e,r);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 vH(st,{label:"F",icon:Tr,elements:i,dragInputCallback:yH,value:l,editable:s,scene:o,property:n,appState:t})},US=wH;import{pointFrom as dr,pointRotateRads as Km}from"@excalidraw/math";import{useMemo as IH}from"react";import{isTextElement as TH}from"@excalidraw/element";import{getCommonBounds as e1}from"@excalidraw/element";import{jsx as MH}from"react/jsx-runtime";var SH=(e,o,t,n,r,i,a)=>{for(let l=0;l<n.length;l++){let s=n[l],[c,m]=[s.x+s.width/2,s.y+s.height/2],[p,d]=Km(dr(s.x,s.y),dr(c,m),s.angle),u=e==="x"?Math.round(p+o):p,b=e==="y"?Math.round(d+t):d;Xr(u,b,s,i,a,r,!1)}},CH=(e,o,t,n,r,i)=>{let a=r.getNonDeletedElementsMap(),[l,s,,]=e1(t),c=e-l,m=o-s;for(let p=0;p<t.length;p++){let d=t[p],u=a.get(d.id);if(u&&(!TH(u)||!u.containerId)){let[b,g]=[u.x+u.width/2,u.y+u.height/2],[E,y]=Km(dr(u.x,u.y),dr(b,g),u.angle);Xr(E+c,y+m,d,r,i,n,!1)}}},kH=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldChangeByStepSize:n,nextValue:r,property:i,scene:a,originalAppState:l,app:s})=>{let c=a.getNonDeletedElementsMap();if(r!==void 0){for(let u of La(o,l)){let b=Aa(u,c,t);if(b.length>1){let[g,E,,]=e1(b.map(x=>x.latest));CH(i==="x"?r:g,i==="y"?r:E,b.map(x=>x.original),t,a,s.state)}else{let g=b[0]?.original,E=b[0]?.latest;if(g&&E&&Ft(E,i)){let[y,v]=[g.x+g.width/2,g.y+g.height/2],[x,w]=Km(dr(g.x,g.y),dr(y,v),g.angle);Xr(i==="x"?r:x,i==="y"?r:w,g,a,s.state,t,!1)}}}a.triggerUpdate();return}let m=n?Ue(e,Ss):e;SH(i,i==="x"?m:0,i==="y"?m:0,o,t,a,s.state),a.triggerUpdate()},PH=({property:e,elements:o,elementsMap:t,atomicUnits:n,scene:r,appState:i})=>{let a=IH(()=>n.map(s=>{let c=Object.keys(s).map(g=>t.get(g)).filter(g=>g!==void 0);if(c.length>1){let[g,E]=e1(c);return Math.round((e==="x"?g:E)*100)/100}let[m]=c,[p,d]=[m.x+m.width/2,m.y+m.height/2],[u,b]=Km(dr(m.x,m.y),dr(p,d),m.angle);return Math.round((e==="x"?u:b)*100)/100}),[n,t,e]),l=new Set(a).size===1?a[0]:"Mixed";return MH(st,{label:e==="x"?"X":"Y",elements:o,dragInputCallback:kH,value:l,property:e,scene:r,appState:i})},t1=PH;import{clamp as Cs,pointFrom as Zm,pointRotateRads as YS,round as WS}from"@excalidraw/math";import{getFlipAdjustedCropPosition as AH,getUncroppedWidthAndHeight as LH}from"@excalidraw/element";import{isImageElement as VS}from"@excalidraw/element";import{jsx as RH}from"react/jsx-runtime";var _H=({accumulatedChange:e,instantChange:o,originalElements:t,originalElementsMap:n,shouldChangeByStepSize:r,nextValue:i,property:a,scene:l,originalAppState:s,app:c})=>{let m=l.getNonDeletedElementsMap(),p=t[0],[d,u]=[p.x+p.width/2,p.y+p.height/2],[b,g]=YS(Zm(p.x,p.y),Zm(d,u),p.angle);if(s.croppingElementId===p.id){let w=m.get(p.id);if(!w||!VS(w)||!w.crop)return;let I=w.crop,C=I,A=w.scale[0]===-1,k=w.scale[1]===-1,{width:L,height:_}=LH(w);if(i!==void 0){if(a==="x"){let z=i*(I.naturalWidth/L);A?C={...I,x:Cs(I.naturalWidth-z-I.width,0,I.naturalWidth-I.width)}:C={...I,x:Cs(i*(I.naturalWidth/L),0,I.naturalWidth-I.width)}}a==="y"&&(C={...I,y:Cs(i*(I.naturalHeight/_),0,I.naturalHeight-I.height)}),l.mutateElement(w,{crop:C});return}let M=(a==="x"?o:0)*(A?-1:1),D=(a==="y"?o:0)*(k?-1:1);C={...I,x:Cs(I.x+M,0,I.naturalWidth-I.width),y:Cs(I.y+D,0,I.naturalHeight-I.height)},l.mutateElement(w,{crop:C});return}if(i!==void 0){Xr(a==="x"?i:b,a==="y"?i:g,p,l,c.state,n);return}let E=a==="x"?e:0,y=a==="y"?e:0,v=a==="x"?Math.round(r?Ue(p.x+E,Ss):b+E):b,x=a==="y"?Math.round(r?Ue(p.y+y,Ss):g+y):g;Xr(v,x,p,l,c.state,n)},DH=({property:e,element:o,elementsMap:t,scene:n,appState:r})=>{let[i,a]=YS(Zm(o.x,o.y),Zm(o.x+o.width/2,o.y+o.height/2),o.angle),l=WS(e==="x"?i:a,2);if(r.croppingElementId===o.id&&VS(o)&&o.crop){let s=AH(o);s&&(l=WS(e==="x"?s.x:s.y,2))}return RH(st,{label:e==="x"?"X":"Y",elements:[o],dragInputCallback:_H,scene:n,value:l,property:e,appState:r})},o1=DH;import{Fragment as i1,jsx as re,jsxs as Ot}from"react/jsx-runtime";var WH=50,ks=e=>{let o=Do(),t=e.app.scene.getSceneNonce()||1,n=e.app.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}),r=or(e.app);return re(YH,{...e,appState:o,sceneNonce:t,selectedElements:n,gridModeEnabled:r})},Fe=({children:e,columns:o=1,heading:t,style:n,...r})=>re("div",{className:NH("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${o}, 1fr)`,...n},...r,children:e});Fe.displayName="StatsRow";var jm=({children:e,order:o,style:t,...n})=>re("div",{className:"exc-stats__rows",style:{order:o,...t},...n,children:e});jm.displayName="StatsRows";ks.StatsRow=Fe;ks.StatsRows=jm;var YH=OH(({app:e,onClose:o,renderCustomStats:t,selectedElements:n,appState:r,sceneNonce:i,gridModeEnabled:a})=>{let l=e.scene,s=l.getNonDeletedElements(),c=l.getNonDeletedElementsMap(),m=be(),p=n.length===1?n[0]:null,d=n.length>1?n:null,u=r.croppingElementId&&r1(p),b=u?HH(p):null,[g,E]=FH({width:0,height:0}),y=n1(()=>BH(w=>{let I=zH(w);E({width:Math.round(I[2])-Math.round(I[0]),height:Math.round(I[3])-Math.round(I[1])})},WH),[]);KS(()=>{y(s)},[i,s,y]),KS(()=>()=>y.cancel(),[y]);let v=n1(()=>La(n,r),[n,r]),x=n1(()=>GH(n),[n]);return re("div",{className:"exc-stats",children:Ot(We,{padding:3,children:[Ot("div",{className:"title",children:[re("h2",{children:f("stats.title")}),re("div",{className:"close",onClick:o,children:Qt})]}),Ot(wl,{label:re("h3",{children:f("stats.generalStats")}),open:!!(r.stats.panels&$m.generalStats),openTrigger:()=>m(w=>({stats:{open:!0,panels:w.stats.panels^$m.generalStats}})),children:[Ot(jm,{children:[re(Fe,{heading:!0,children:f("stats.scene")}),Ot(Fe,{columns:2,children:[re("div",{children:f("stats.shapes")}),re("div",{children:s.length})]}),Ot(Fe,{columns:2,children:[re("div",{children:f("stats.width")}),re("div",{children:g.width})]}),Ot(Fe,{columns:2,children:[re("div",{children:f("stats.height")}),re("div",{children:g.height})]}),a&&Ot(i1,{children:[re(Fe,{heading:!0,children:"Canvas"}),re(Fe,{children:re(bS,{property:"gridStep",scene:l,appState:r,setAppState:m})})]})]}),t?.(s,r)]}),!x&&n.length>0&&re("div",{id:"elementStats",style:{marginTop:12},children:re(wl,{label:re("h3",{children:f("stats.elementProperties")}),open:!!(r.stats.panels&$m.elementProperties),openTrigger:()=>m(w=>({stats:{open:!0,panels:w.stats.panels^$m.elementProperties}})),children:Ot(jm,{children:[p&&Ot(i1,{children:[u&&re(Fe,{heading:!0,children:f("labels.unCroppedDimension")}),r.croppingElementId&&r1(p)&&b&&Ot(Fe,{columns:2,children:[re("div",{children:f("stats.width")}),re("div",{children:XS(b.width,2)})]}),r.croppingElementId&&r1(p)&&b&&Ot(Fe,{columns:2,children:[re("div",{children:f("stats.height")}),re("div",{children:XS(b.height,2)})]}),re(Fe,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:r.croppingElementId?f("labels.imageCropping"):f(`element.${p.type}`)}),re(Fe,{children:re(o1,{element:p,property:"x",elementsMap:c,scene:l,appState:r})}),re(Fe,{children:re(o1,{element:p,property:"y",elementsMap:c,scene:l,appState:r})}),re(Fe,{children:re(Zf,{property:"width",element:p,scene:l,appState:r})}),re(Fe,{children:re(Zf,{property:"height",element:p,scene:l,appState:r})}),re(Fe,{children:re(gS,{property:"angle",element:p,scene:l,appState:r})}),re(Fe,{children:re(CS,{property:"fontSize",element:p,scene:l,appState:r})})]}),d&&Ot(i1,{children:[UH(d)&&re(Fe,{heading:!0,children:f("element.group")}),Ot(Fe,{columns:2,style:{margin:"0.3125rem 0"},children:[re("div",{children:f("stats.shapes")}),re("div",{children:n.length})]}),re(Fe,{children:re(t1,{property:"x",elements:d,elementsMap:c,atomicUnits:v,scene:l,appState:r})}),re(Fe,{children:re(t1,{property:"y",elements:d,elementsMap:c,atomicUnits:v,scene:l,appState:r})}),re(Fe,{children:re(Qf,{property:"width",elements:d,elementsMap:c,atomicUnits:v,scene:l,appState:r})}),re(Fe,{children:re(Qf,{property:"height",elements:d,elementsMap:c,atomicUnits:v,scene:l,appState:r})}),re(Fe,{children:re(LS,{property:"angle",elements:d,scene:l,appState:r})}),re(Fe,{children:re(US,{property:"fontSize",elements:d,scene:l,appState:r,elementsMap:c})})]})]})})})]})})},(e,o)=>e.sceneNonce===o.sceneNonce&&e.selectedElements===o.selectedElements&&e.appState.stats.panels===o.appState.stats.panels&&e.gridModeEnabled===o.gridModeEnabled&&e.appState.gridStep===o.appState.gridStep&&e.appState.croppingElementId===o.appState.croppingElementId);import{useCallback as VH,useEffect as ZS,useState as $S}from"react";import{normalizeLink as XH,KEYS as a1}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as KH,getLinkIdAndTypeFromSelection as ZH}from"@excalidraw/element";import{jsx as Ra,jsxs as qm}from"react/jsx-runtime";var $H=({sourceElementId:e,onClose:o,appState:t,scene:n,generateLinkForSelection:r=KH})=>{let i=n.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[l,s]=$S(a),[c,m]=$S(!1);ZS(()=>{let d=ee(i,t),u=a;if(d.length>0&&r){let b=ZH(d,t);b&&(u=XH(r(b.id,b.type)))}s(u)},[i,t,t.selectedElementIds,a,r]);let p=VH(()=>{if(l&&l!==i.get(e)?.link){let d=i.get(e);d&&n.mutateElement(d,{link:l})}if(!l&&c&&e){let d=i.get(e);d&&n.mutateElement(d,{link:null})}o?.()},[e,l,i,c,n,o]);return ZS(()=>{let d=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===a1.ENTER&&p(),t.openDialog?.name==="elementLinkSelector"&&u.key===a1.ESCAPE&&o?.()};return window.addEventListener("keydown",d),()=>{window.removeEventListener("keydown",d)}},[t,o,p]),qm("div",{className:"ElementLinkDialog",children:[qm("div",{className:"ElementLinkDialog__header",children:[Ra("h2",{children:f("elementLink.title")}),Ra("p",{children:f("elementLink.desc")})]}),qm("div",{className:"ElementLinkDialog__input",children:[Ra(qn,{value:l??"",onChange:d=>{c||m(!0),s(d)},onKeyDown:d=>{d.key===a1.ENTER&&p()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&l&&Ra(Z,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:()=>{s(null),m(!0)},className:"ElementLinkDialog__remove",icon:ln})]}),qm("div",{className:"ElementLinkDialog__actions",children:[Ra(un,{label:f("buttons.cancel"),onClick:()=>{o?.()},style:{marginRight:10}}),Ra(un,{label:f("buttons.confirm"),onClick:p,actionType:"primary"})]})]})},jS=$H;import jH,{useState as qH}from"react";import{Fragment as JH,jsx as l1}from"react/jsx-runtime";var qS=({children:e,onClose:o})=>{let[t,n]=qH(!!e),{container:r}=Ne(),i=jH.useCallback(()=>{n(!1),o&&o(),r?.focus()},[o,r]);return l1(JH,{children:t&&l1(qe,{size:"small",onCloseRequest:i,title:f("errorDialog.title"),children:l1("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import QH from"clsx";import{jsx as eG}from"react/jsx-runtime";var JS=({children:e,side:o,className:t})=>eG("div",{className:QH("FixedSideContainer",`FixedSideContainer_side_${o}`,t),children:e});import eC,{useMemo as lG}from"react";import tC from"clsx";import{isDarwin as oC,isFirefox as nC,isWindows as sG}from"@excalidraw/common";import{KEYS as Zr}from"@excalidraw/common";import{SHAPES as cG}from"@excalidraw/element/shapes";import{isFirefox as QS,KEYS as s1}from"@excalidraw/common";import{SHAPES as tG}from"@excalidraw/element/shapes";import{Fragment as aG,jsx as Oe,jsxs as Kr}from"react/jsx-runtime";var oG=e=>Kr(aG,{children:[Oe("h3",{children:e.title}),Oe("div",{className:"HelpDialog__islands-container",children:e.children})]}),c1=e=>Kr("div",{className:`HelpDialog__island ${e.className}`,children:[Oe("h4",{className:"HelpDialog__island-title",children:e.caption}),Oe("div",{className:"HelpDialog__island-content",children:e.children})]});function*nG(e,o){let t=!0;for(let n of e)t||(yield o),t=!1,yield n}var rG=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),ct=({label:e,shortcuts:o,isOr:t=!0})=>{let n=o.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>Oe(iG,{children:rG(a)},a)));return Kr("div",{className:"HelpDialog__shortcut",children:[Oe("div",{children:e}),Oe("div",{className:"HelpDialog__key-container",children:[...nG(n,t?f("helpDialog.or"):null)]})]})},iG=e=>Oe("kbd",{className:"HelpDialog__key",...e});function d1(){return Kr(oG,{title:f("helpDialog.shortcuts"),children:[Kr(c1,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[Oe(ct,{label:f("toolBar.hand"),shortcuts:[s1.H]}),tG.filter(({myocSimplifiedMode:e})=>e).map(({value:e,key:o})=>Oe(ct,{label:f(`toolBar.${e}`),shortcuts:[...o]},e)),Oe(ct,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),Oe(ct,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0})]}),Kr(c1,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[Oe(ct,{label:f("helpDialog.smartZoom"),shortcuts:[s1.F]}),Oe(ct,{label:f("helpDialog.dragToZoom"),shortcuts:[`${s1.Z}+${f("helpDialog.drag")}`]}),Oe(ct,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]}),Oe(ct,{label:f("commandPalette.title"),shortcuts:QS?[Se("commandPalette")]:[Se("commandPalette"),Se("commandPalette",1)]})]}),Kr(c1,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[Oe(ct,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),Oe(ct,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),Oe(ct,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),Oe(ct,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(Vn||QS)&&Oe(ct,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),Oe(ct,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),Oe(ct,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),Oe(ct,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),Oe(ct,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),Oe(ct,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]})]})]})}import{Fragment as iC,jsx as V,jsxs as $r}from"react/jsx-runtime";var dG=e=>$r(iC,{children:[V("h3",{children:e.title}),V("div",{className:"HelpDialog__islands-container",children:e.children})]}),m1=e=>$r("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*mG(e,o){let t=!0;for(let n of e)t||(yield o),t=!1,yield n}var pG=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),j=({label:e,shortcuts:o,isOr:t=!0})=>{let n=o.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>V(uG,{children:pG(a)},a)));return $r("div",{className:"HelpDialog__shortcut",children:[V("div",{children:e}),V("div",{className:"HelpDialog__key-container",children:[...mG(n,t?f("helpDialog.or"):null)]})]})},uG=e=>V("kbd",{className:"HelpDialog__key",...e}),rC=({onClose:e})=>{let[o,t]=eC.useState(!1),n=eC.useCallback(()=>{e&&e()},[e]),r=lG(()=>o?V("button",{className:tC("toggle-button",{}),onClick:()=>t(!1),children:f("helpDialog.myoc.showingAll")}):V("button",{className:tC("toggle-button",{}),onClick:()=>t(!0),children:f("helpDialog.myoc.showingBasic")}),[o]);return V(iC,{children:V(qe,{onCloseRequest:n,title:f("helpDialog.title"),className:"HelpDialog",titleButton:r,portalContainerClassName:"HelpDialog__modalContainer",children:o?$r(dG,{title:f("helpDialog.shortcuts"),children:[$r(m1,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[V(j,{label:f("toolBar.hand"),shortcuts:[Zr.H]}),cG.map(({value:i,key:a})=>V(j,{label:f(`toolBar.${i}`),shortcuts:[...a]},i)),V(j,{label:f("toolBar.frame"),shortcuts:[Zr.F]}),V(j,{label:f("toolBar.laser"),shortcuts:[Zr.K]}),V(j,{label:f("labels.eyeDropper"),shortcuts:[Zr.I,"Shift+S","Shift+G"]}),V(j,{label:f("helpDialog.editLineArrowPoints"),shortcuts:[N("CtrlOrCmd+Enter")]}),V(j,{label:f("helpDialog.editText"),shortcuts:[N("Enter")]}),V(j,{label:f("helpDialog.textNewLine"),shortcuts:[N("Enter"),N("Shift+Enter")]}),V(j,{label:f("helpDialog.textFinish"),shortcuts:[N("Esc"),N("CtrlOrCmd+Enter")]}),V(j,{label:f("helpDialog.curvedArrow"),shortcuts:["A",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),V(j,{label:f("helpDialog.curvedLine"),shortcuts:["L",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),V(j,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),V(j,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0}),V(j,{label:f("toolBar.lock"),shortcuts:[Zr.Q]}),V(j,{label:f("helpDialog.preventBinding"),shortcuts:[N("CtrlOrCmd")]}),V(j,{label:f("toolBar.link"),shortcuts:[N("CtrlOrCmd+K")]}),V(j,{label:f("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),$r(m1,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[V(j,{label:f("helpDialog.smartZoom"),shortcuts:[Zr.F]}),V(j,{label:f("helpDialog.dragToZoom"),shortcuts:[`${Zr.Z}+${f("helpDialog.drag")}`]}),V(j,{label:f("buttons.zoomIn"),shortcuts:[N("CtrlOrCmd++")]}),V(j,{label:f("buttons.zoomOut"),shortcuts:[N("CtrlOrCmd+-")]}),V(j,{label:f("buttons.resetZoom"),shortcuts:[N("CtrlOrCmd+0")]}),V(j,{label:f("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),V(j,{label:f("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),V(j,{label:f("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),V(j,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]}),V(j,{label:f("labels.toggleGrid"),shortcuts:[N("CtrlOrCmd+'")]}),V(j,{label:f("labels.viewMode"),shortcuts:[N("Alt+R")]}),V(j,{label:f("stats.fullTitle"),shortcuts:[N("Alt+/")]}),V(j,{label:f("search.title"),shortcuts:[Se("searchMenu")]}),V(j,{label:f("commandPalette.title"),shortcuts:nC?[Se("commandPalette")]:[Se("commandPalette"),Se("commandPalette",1)]})]}),$r(m1,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[V(j,{label:f("labels.moveCanvas"),shortcuts:[N(`Space+${f("helpDialog.drag")}`),N(`Wheel+${f("helpDialog.drag")}`)],isOr:!0}),V(j,{label:f("labels.delete"),shortcuts:[N("Delete")]}),V(j,{label:f("labels.cut"),shortcuts:[N("CtrlOrCmd+X")]}),V(j,{label:f("labels.copy"),shortcuts:[N("CtrlOrCmd+C")]}),V(j,{label:f("labels.paste"),shortcuts:[N("CtrlOrCmd+V")]}),V(j,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),V(j,{label:f("labels.selectAll"),shortcuts:[N("CtrlOrCmd+A")]}),V(j,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),V(j,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),V(j,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(Vn||nC)&&V(j,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),V(j,{label:f("labels.sendToBack"),shortcuts:[oC?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")]}),V(j,{label:f("labels.bringToFront"),shortcuts:[oC?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")]}),V(j,{label:f("labels.sendBackward"),shortcuts:[N("CtrlOrCmd+[")]}),V(j,{label:f("labels.bringForward"),shortcuts:[N("CtrlOrCmd+]")]}),V(j,{label:f("labels.alignTop"),shortcuts:[N("CtrlOrCmd+Shift+Up")]}),V(j,{label:f("labels.alignBottom"),shortcuts:[N("CtrlOrCmd+Shift+Down")]}),V(j,{label:f("labels.alignLeft"),shortcuts:[N("CtrlOrCmd+Shift+Left")]}),V(j,{label:f("labels.alignRight"),shortcuts:[N("CtrlOrCmd+Shift+Right")]}),V(j,{label:f("labels.arrangeElements"),shortcuts:[N("Shift+R")]}),V(j,{label:f("labels.duplicateSelection"),shortcuts:[N("CtrlOrCmd+D"),N(`Alt+${f("helpDialog.drag")}`)]}),V(j,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),V(j,{label:f("buttons.undo"),shortcuts:[N("CtrlOrCmd+Z")]}),V(j,{label:f("buttons.redo"),shortcuts:sG?[N("CtrlOrCmd+Y"),N("CtrlOrCmd+Shift+Z")]:[N("CtrlOrCmd+Shift+Z")]}),V(j,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),V(j,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),V(j,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),V(j,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]}),V(j,{label:f("labels.showStroke"),shortcuts:[N("S")]}),V(j,{label:f("labels.showBackground"),shortcuts:[N("G")]}),V(j,{label:f("labels.showFonts"),shortcuts:[N("Shift+F")]}),V(j,{label:f("labels.decreaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+<")]}),V(j,{label:f("labels.increaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+>")]})]})]}):V(d1,{})})})};import{CANVAS_SEARCH_TAB as hG,DEFAULT_SIDEBAR as gG}from"@excalidraw/common";import{isFlowchartNodeElement as fG,isImageElement as aC,isLinearElement as lC,isLineElement as bG,isTextBindableContainer as EG,isTextElement as xG}from"@excalidraw/element";import{isNodeInFlowchart as yG}from"@excalidraw/element";import{jsx as p1}from"react/jsx-runtime";var Ie=e=>Array.isArray(e)?`<kbd>${e.map(N).join(" + ")}</kbd>`:`<kbd>${N(e)}</kbd>`,wG=({appState:e,isMobile:o,editorInterface:t,app:n})=>{let{activeTool:r,isResizing:i,isRotating:a,lastPointerDownWith:l}=e,s=e.multiElement!==null;if(e.openSidebar?.name===gG.name&&e.openSidebar.tab===hG&&e.searchMatches?.matches.length)return f("hints.dismissSearch",{shortcut:Ie("Escape")});if(e.openSidebar&&!t.canFitSidebar)return null;if(Mt(e))return f("hints.eraserRevert",{shortcut:Ie("Alt")});let c=n.scene.getSelectedElements(e);if(e.selectedLinearElement?.isDragging&&c[0]?.type==="arrow")return f("hints.arrowBindModifiers",{shortcut_1:Ie("Ctrl"),shortcut_2:Ie("Alt")});if(r.type==="arrow"||r.type==="line")return s?f("hints.linearElementMulti",{shortcut_1:Ie("Escape"),shortcut_2:Ie("Enter")}):r.type==="arrow"?f("hints.arrowTool",{shortcut:Ie("A")}):f("hints.linearElement");if(r.type==="freedraw")return f("hints.freeDraw");if(r.type==="text")return f("hints.text");if(r.type==="embeddable")return f("hints.embeddable");if(i&&l==="mouse"&&c.length===1){let m=c[0];return lC(m)&&m.points.length===2?f("hints.lockAngle",{shortcut:Ie("Shift")}):aC(m)?f("hints.resizeImage",{shortcut_1:Ie("Shift"),shortcut_2:Ie("Alt")}):f("hints.resize",{shortcut_1:Ie("Shift"),shortcut_2:Ie("Alt")})}if(a&&l==="mouse")return f("hints.rotate",{shortcut:Ie("Shift")});if(c.length===1&&xG(c[0]))return f("hints.text_selected",{shortcut:Ie("Enter")});if(e.editingTextElement)return f("hints.text_editing",{shortcut_1:Ie("Escape"),shortcut_2:Ie(["CtrlOrCmd","Enter"])});if(e.croppingElementId)return f("hints.leaveCropEditor",{shortcut_1:Ie("Enter"),shortcut_2:Ie("Escape")});if(c.length===1&&aC(c[0]))return f("hints.enterCropEditor",{shortcut:Ie("Enter")});if(r.type==="selection"){if(e.selectionElement&&!c.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return f("hints.deepBoxSelect",{shortcut:Ie("CtrlOrCmd")});if(or(n)&&e.selectedElementsAreBeingDragged)return f("hints.disableSnapping",{shortcut:Ie("CtrlOrCmd")});if(!c.length&&!o)return f("hints.canvasPanning",{shortcut_1:Ie(f("keys.mmb")),shortcut_2:Ie("Space")});if(c.length===1){if(lC(c[0]))return e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?f("hints.lineEditor_pointSelected",{shortcut_1:Ie("Delete"),shortcut_2:Ie(["CtrlOrCmd","D"])}):f("hints.lineEditor_nothingSelected",{shortcut_1:Ie("Shift"),shortcut_2:Ie("Alt")}):bG(c[0])?f("hints.lineEditor_line_info",{shortcut:Ie("Enter")}):f("hints.lineEditor_info",{shortcut_1:Ie("CtrlOrCmd"),shortcut_2:Ie(["CtrlOrCmd","Enter"])});if(!e.newElement&&!e.selectedElementsAreBeingDragged&&EG(c[0])){let m=f("hints.bindTextToElement",{shortcut:Ie("Enter")}),p=f("hints.createFlowchart",{shortcut:Ie(["CtrlOrCmd","\u2191\u2193"])});return fG(c[0])?yG(c[0],n.scene.getNonDeletedElementsMap())?[m,p]:[m,p]:m}}}return null},sC=({appState:e,isMobile:o,editorInterface:t,app:n})=>{let r=wG({appState:e,isMobile:o,editorInterface:t,app:n});if(!r)return null;let a=(Array.isArray(r)?r.map(l=>l.replace(/\. ?$/,"")).join(", "):r).split(/(<kbd>[^<]+<\/kbd>)/g).map((l,s)=>{if(s%2===1){let c=l[0]==="<"&&l.match(/^<kbd>([^<]+)<\/kbd>$/);return p1("kbd",{children:c?c[1]:l},s)}return l});return p1("div",{className:"HintViewer",children:p1("span",{children:a})})};import{useEffect as mC,useRef as pC,useState as jr}from"react";import{DEFAULT_EXPORT_PADDING as kG,EXPORT_IMAGE_TYPES as u1,isFirefox as PG,EXPORT_SCALES as MG,cloneJSON as uC}from"@excalidraw/common";import{useCallback as vG,useRef as IG,useState as TG}from"react";var SG=2e3,cC=()=>{let[e,o]=TG(null),t=IG(0),n=()=>{clearTimeout(t.current),o("success"),t.current=window.setTimeout(()=>{o(null)},SG)},r=vG(()=>{o(null)},[]);return{copyStatus:e,resetCopyStatus:r,onCopy:n}};import CG from"clsx";import{jsx as dC}from"react/jsx-runtime";var Ps=({title:e,name:o,checked:t,onChange:n,disabled:r=!1})=>dC("div",{className:CG("Switch",{toggled:t,disabled:r}),children:dC("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 ze,jsxs as mr}from"react/jsx-runtime";var AG=()=>mr("div",{children:[ze("h3",{children:f("canvasError.cannotShowPreview")}),ze("p",{children:ze("span",{children:f("canvasError.canvasTooBig")})}),mr("em",{children:["(",f("canvasError.canvasTooBigTip"),")"]})]}),LG=({appStateSnapshot:e,elementsSnapshot:o,files:t,actionManager:n,onExportImage:r,name:i,exportWithDarkMode:a})=>{let l=Pe(o,e),[s,c]=jr(i),[m,p]=jr(l),[d,u]=jr(e.exportBackground),[b,g]=jr(e.exportEmbedScene),[E,y]=jr(e.exportScale),v=pC(null),x=pC(0),[w,I]=jr(null),{onCopy:C,copyStatus:A,resetCopyStatus:k}=cC();mC(()=>{k()},[s,d,a,E,b,k]);let{exportedElements:L,exportingFrame:_}=Mr(o,e,m);return mC(()=>{let M=v.current;if(!M)return;let D=M.offsetWidth,z=M.offsetHeight;if(!D)return;let W=++x.current,O=()=>W!==x.current;return qi({elements:L,appState:{...e,name:s,exportBackground:d,exportWithDarkMode:a,exportScale:E,exportEmbedScene:b},files:t,exportPadding:kG,maxWidthOrHeight:Math.max(D,z),exportingFrame:_}).then(async K=>{if(!O()){try{await vr(K)}catch(Y){throw Y.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):Y}O()||(I(null),M.replaceChildren(K))}}).catch(K=>{O()||(console.error(K),I(K))}),()=>{x.current+=1}},[e,t,L,_,s,d,a,E,b]),mr("div",{className:"ImageExportModal",children:[ze("h3",{children:f("imageExportDialog.header")}),mr("div",{className:"ImageExportModal__preview",children:[ze("div",{className:"ImageExportModal__preview__canvas",ref:v,children:w&&ze(AG,{})}),ze("div",{className:"ImageExportModal__preview__filename",children:!ai&&ze("input",{type:"text",className:"TextInput",value:s,style:{width:"30ch"},onChange:M=>{c(M.target.value),n.executeAction(Ju,"ui",M.target.value)}})})]}),mr("div",{className:"ImageExportModal__settings",children:[ze("h3",{children:f("imageExportDialog.header")}),l&&ze(Ms,{label:f("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:ze(Ps,{name:"exportOnlySelected",checked:m,onChange:M=>{p(M)}})}),ze(Ms,{label:f("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:ze(Ps,{name:"exportBackgroundSwitch",checked:d,onChange:M=>{u(M),n.executeAction(Qu,"ui",M)}})}),ze(Ms,{label:f("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:ze(Ps,{name:"exportDarkModeSwitch",checked:a,onChange:M=>{n.executeAction(Ly,"ui",M)}})}),ze(Ms,{label:f("imageExportDialog.label.embedScene"),tooltip:f("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:ze(Ps,{name:"exportEmbedSwitch",checked:b,onChange:M=>{g(M),n.executeAction(dd,"ui",M)}})}),ze(Ms,{label:f("imageExportDialog.label.scale"),name:"exportScale",children:ze(_m,{name:"exportScale",value:E,onChange:M=>{y(M),n.executeAction(My,"ui",M)},choices:MG.map(M=>({value:M,label:`${M}\xD7`}))})}),mr("div",{className:"ImageExportModal__settings__buttons",children:[ze(ar,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToPng"),onClick:()=>r(u1.png,L,{exportingFrame:_}),icon:Kp,children:f("imageExportDialog.button.exportToPng")}),ze(ar,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToSvg"),onClick:()=>r(u1.svg,L,{exportingFrame:_}),icon:Kp,children:f("imageExportDialog.button.exportToSvg")}),(Vn||PG)&&ze(ar,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.copyPngToClipboard"),status:A,onClick:async()=>{await r(u1.clipboard,L,{exportingFrame:_}),C()},icon:hi,children:f("imageExportDialog.button.copyPngToClipboard")})]})]})]})},Ms=({label:e,children:o,tooltip:t,name:n})=>mr("div",{className:"ImageExportModal__settings__setting",title:e,children:[mr("label",{htmlFor:n,className:"ImageExportModal__settings__setting__label",children:[e,t&&ze(gt,{label:t,long:!0,children:h0})]}),ze("div",{className:"ImageExportModal__settings__setting__content",children:o})]}),hC=({elements:e,appState:o,files:t,actionManager:n,onExportImage:r,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:l,elementsSnapshot:s}]=jr(()=>({appStateSnapshot:uC(o),elementsSnapshot:uC(e)}));return ze(qe,{onCloseRequest:i,size:"wide",title:!1,children:ze(LG,{elementsSnapshot:s,appStateSnapshot:l,files:t,actionManager:n,onExportImage:r,name:a,exportWithDarkMode:o.exportWithDarkMode})})};import DG from"react";import{getFrame as RG}from"@excalidraw/common";import{jsx as _G}from"react/jsx-runtime";var h1={primary:{base:"var(--color-primary)",darker:"var(--color-primary-darker)",darkest:"var(--color-primary-darkest)"},lime:{base:"#74b816",darker:"#66a80f",darkest:"#5c940d"},pink:{base:"#d6336c",darker:"#c2255c",darkest:"#a61e4d"}},g1=({children:e,color:o})=>_G("div",{className:"Card",style:{"--card-color":h1[o].base,"--card-color-darker":h1[o].darker,"--card-color-darkest":h1[o].darkest},children:e});import{Fragment as BG,jsx as Po,jsxs as Jm}from"react/jsx-runtime";var NG=({elements:e,appState:o,setAppState:t,files:n,actionManager:r,exportOpts:i,canvas:a,onCloseRequest:l})=>{let{onExportToBackend:s}=i;return Po("div",{className:"ExportDialog ExportDialog--json",children:Jm("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&Jm(g1,{color:"lime",children:[Po("div",{className:"Card-icon",children:xE}),Po("h2",{children:f("exportDialog.disk_title")}),Jm("div",{className:"Card-details",children:[f("exportDialog.disk_details"),!ai&&r.renderAction("changeProjectName")]}),Po(Z,{className:"Card-button",type:"button",title:f("exportDialog.disk_button"),"aria-label":f("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{r.executeAction(Al,"ui")}})]}),s&&Jm(g1,{color:"pink",children:[Po("div",{className:"Card-icon",children:al}),Po("h2",{children:f("exportDialog.link_title")}),Po("div",{className:"Card-details",children:f("exportDialog.link_details")}),Po(Z,{className:"Card-button",type:"button",title:f("exportDialog.link_button"),"aria-label":f("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{ce("export","link",`ui (${RG()})`),await s(e,o,n),l()}catch(c){t({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,o,n,a)]})})},gC=({elements:e,appState:o,files:t,actionManager:n,exportOpts:r,canvas:i,setAppState:a})=>{let l=DG.useCallback(()=>{a({openDialog:null})},[a]);return Po(BG,{children:o.openDialog?.name==="jsonExport"&&Po(qe,{onCloseRequest:l,title:f("buttons.export"),children:Po(NG,{elements:e,appState:o,setAppState:a,files:t,actionManager:n,onCloseRequest:l,exportOpts:r,canvas:i})})})};import FG from"clsx";import{jsx as fC,jsxs as zG}from"react/jsx-runtime";var OG="small",bC=e=>zG("label",{className:FG("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${OG}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[fC("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),fC("div",{className:"ToolIcon__icon",children:fi})]});import{Fragment as yC,jsx as J,jsxs as zt}from"react/jsx-runtime";var KG=({UIOptions:e})=>zt(Ct,{__fallback:!0,children:[J(Ct.DefaultItems.LoadScene,{}),J(Ct.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&J(Ct.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&J(Ct.DefaultItems.SaveAsImage,{}),J(Ct.DefaultItems.SearchMenu,{}),J(Ct.DefaultItems.Help,{}),J(Ct.Separator,{}),J(Ct.Group,{title:"Excalidraw links",children:J(Ct.DefaultItems.Socials,{})}),J(Ct.Separator,{}),J(Ct.DefaultItems.ToggleTheme,{}),J(Ct.DefaultItems.ChangeCanvasBackground,{})]}),ZG=()=>zt(Bm,{__fallback:!0,children:[J(Bm.Actions.SaveToDisk,{}),J(Bm.Actions.ExportToImage,{})]}),$G=({actionManager:e,appState:o,files:t,setAppState:n,elements:r,canvas:i,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,showExitZenModeBtn:c,renderTopLeftUI:m,renderTopRightUI:p,renderCustomStats:d,UIOptions:u,onExportImage:b,renderWelcomeScreen:g,children:E,app:y,isCollaborating:v,generateLinkForSelection:x})=>{let w=pe(),C=nt()==="compact",A=Y3(),k=C?{menuTopGap:4,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:.5,islandPadding:1,collabMarginLeft:8}:{menuTopGap:6,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:1,islandPadding:1,collabMarginLeft:8},L=A.tunnelsJotai.Provider,[_,M]=fe(Bn),D=()=>u.canvasActions.export?J(gC,{elements:r,appState:o,files:t,actionManager:e,exportOpts:u.canvasActions.export,canvas:i,setAppState:n}):null,z=()=>!u.canvasActions.saveAsImage||o.openDialog?.name!=="imageExport"?null:J(hC,{elements:r,appState:o,files:t,actionManager:e,onExportImage:b,onCloseRequest:()=>n({openDialog:null}),name:y.getName()}),W=()=>zt("div",{style:{position:"relative"},children:[J(A.MainMenuTunnel.Out,{}),g&&J(A.WelcomeScreenMenuHintTunnel.Out,{})]}),O=()=>{let ae=C;return J(Es,{heading:"selectedShapeActions",className:qr("selected-shape-actions zen-mode-transition",{"transition-left":o.zenModeEnabled}),children:ae?J(We,{className:qr("compact-shape-actions-island"),padding:0,style:{maxHeight:`${o.height-166}px`},children:J(fv,{appState:o,elementsMap:y.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:y,setAppState:n})}):J(We,{className:GG.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${o.height-166}px`},children:J(mv,{appState:o,elementsMap:y.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:y})})})},K=()=>{let ae=VG(o,r),R=o.stats.open&&!o.zenModeEnabled&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector";return J(JS,{side:"top",children:zt("div",{className:"App-menu App-menu_top",children:[zt(bt.Col,{gap:k.menuTopGap,className:qr("App-menu_top__left"),children:[W(),J("div",{className:qr("selected-shape-actions-container",{"selected-shape-actions-container--compact":C}),children:ae&&O()})]}),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&J(Es,{heading:"shapes",className:"shapes-section",children:G=>zt("div",{style:{position:"relative"},children:[g&&J(A.WelcomeScreenToolbarHintTunnel.Out,{}),J(bt.Col,{gap:k.toolbarColGap,align:"start",children:zt(bt.Row,{gap:k.toolbarRowGap,className:qr("App-toolbar-container",{"zen-mode":o.zenModeEnabled}),children:[zt(We,{padding:k.islandPadding,className:qr("App-toolbar",{"zen-mode":o.zenModeEnabled,"App-toolbar--compact":C}),children:[J(sC,{appState:o,isMobile:w.formFactor==="phone",editorInterface:w,app:y}),G,zt(bt.Row,{gap:k.toolbarInnerRowGap,children:[J(iT,{zenModeEnabled:o.zenModeEnabled,checked:o.penMode,onChange:()=>s(null),title:f("toolBar.penMode"),penDetected:o.penDetected}),J(Sm,{checked:bo(o),onChange:l,title:f("toolBar.hand")}),J(Ev,{setAppState:n,activeTool:o.activeTool,UIOptions:u,app:y})]})]}),v&&J(We,{style:{marginLeft:k.collabMarginLeft,alignSelf:"center",height:"fit-content"},children:J(bC,{title:f("toolBar.laser"),checked:o.activeTool.type===EC.laser,onChange:()=>y.setActiveTool({type:EC.laser}),isMobile:!0})})]})})]})}),zt("div",{className:qr("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":o.zenModeEnabled,"layer-ui__wrapper__top-right--compact":C}),children:[o.collaborators.size>0&&J(Am,{collaborators:o.collaborators,userToFollow:o.userToFollow?.socketId||null}),p?.(w.formFactor==="phone",o),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&(!q||o.openSidebar?.name!==f1.name)&&J(A.DefaultSidebarTriggerTunnel.Out,{}),R&&J(ks,{app:y,onClose:()=>{e.executeAction(Kn)},renderCustomStats:d})]})]})})},Y=()=>J(zm,{__fallback:!0,onDock:ae=>{ce("sidebar",`toggleDock (${ae?"dock":"undock"})`,`(${w.formFactor==="phone"?"mobile":"desktop"})`)}}),q=nc(ys),ne=zt(yC,{children:[E,J(KG,{UIOptions:u}),J(zm.Trigger,{__fallback:!0,icon:z0,title:WG(f("toolBar.library")),onToggle:ae=>{ae&&ce("sidebar",`${f1.name} (open)`,`button (${w.formFactor==="phone"?"mobile":"desktop"})`)},tab:f1.defaultTab}),J(ZG,{}),o.isLoading&&J(Tm,{delay:250}),o.errorMessage&&J(qS,{onClose:()=>n({errorMessage:null}),children:o.errorMessage}),_&&w.formFactor!=="phone"&&J(ox,{colorPickerType:_.colorPickerType,onCancel:()=>{M(null)},onChange:(ae,R,G,{altKey:ie})=>{if(!(ae!=="elementBackground"&&ae!=="elementStroke"))if(G.length){for(let ge of G)YG(ge,UG(r),{[ie&&_.swapPreviewOnAlt?ae==="elementBackground"?"strokeColor":"backgroundColor":ae==="elementBackground"?"backgroundColor":"strokeColor"]:R}),XG.delete(ge);y.scene.triggerUpdate()}else n(ae==="elementBackground"?{currentItemBackgroundColor:R}:{currentItemStrokeColor:R})},onSelect:(ae,R)=>{M(G=>G?.keepOpenOnAlt&&R.altKey?G:null),_?.onSelect?.(ae,R)}}),o.openDialog?.name==="help"&&J(rC,{onClose:()=>{n({openDialog:null})}}),o.openDialog?.name==="elementLinkSelector"&&J(jS,{sourceElementId:o.openDialog.sourceElementId,onClose:()=>{n({openDialog:null})},scene:y.scene,appState:o,generateLinkForSelection:x}),J(A.OverwriteConfirmDialogTunnel.Out,{}),z(),D(),o.openDialog?.name==="charts"&&J(tT,{data:o.openDialog.data,rawText:o.openDialog.rawText,onClose:()=>n({openDialog:null})}),w.formFactor==="phone"&&J($3,{app:y,appState:o,elements:r,actionManager:e,renderJSONExportDialog:D,renderImageExportDialog:z,setAppState:n,onHandToolToggle:l,onPenModeToggle:s,renderTopLeftUI:m,renderTopRightUI:p,renderSidebars:Y,renderWelcomeScreen:g,UIOptions:u}),w.formFactor!=="phone"&&zt(yC,{children:[zt("div",{className:"layer-ui__wrapper",style:o.openSidebar&&q&&w.canFitSidebar?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[g&&J(A.WelcomeScreenCenterTunnel.Out,{}),K(),J(sT,{appState:o,actionManager:e,showExitZenModeBtn:c,renderWelcomeScreen:g}),(o.toast||o.scrolledOutside)&&zt("div",{className:"floating-status-stack",children:[o.toast&&J(Ri,{message:o.toast.message,onClose:()=>n({toast:null}),duration:o.toast.duration,closable:o.toast.closable}),!o.toast&&o.scrolledOutside&&J("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{n(ae=>({...xr(r,ae)}))},children:f("buttons.scrollBackToContent")})]})]}),Y()]})]});return J(mu.Provider,{value:o,children:J(L,{children:J(bf.Provider,{value:A,children:ne})})})},xC=e=>{let{cursorButton:o,scrollX:t,scrollY:n,...r}=e;return r},jG=(e,o)=>{if(e.children!==o.children)return!1;let{canvas:t,appState:n,...r}=e,{canvas:i,appState:a,...l}=o;return Qm(xC(n),xC(a),{selectedElementIds:Qm,selectedGroupIds:Qm})&&Qm(r,l)},wC=HG.memo($G,jG);import qG from"clsx";import{jsx as vC,jsxs as QG}from"react/jsx-runtime";var JG="small",b1=e=>QG("label",{className:qG("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${JG}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[vC("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),vC("div",{className:"ToolIcon__icon",children:e.icon})]});import{useEffect as eU,useRef as tU}from"react";import{jsx as IC}from"react/jsx-runtime";var TC=({trails:e})=>{let o=tU(null);return eU(()=>{if(o.current)for(let t of e)t.start(o.current);return()=>{for(let t of e)t.stop()}},e),IC("div",{className:"SVGLayer",children:IC("svg",{ref:o})})};import UU,{useEffect as WU,useRef as GC}from"react";import{CURSOR_TYPE as UC,isShallowEqual as YU,sceneCoordsToViewportCoords as VU}from"@excalidraw/common";import{clamp as w1,pointFrom as Na,pointsEqual as sU,bezierEquation as NC,pointRotateRads as ep,pointDistance as cU}from"@excalidraw/math";import{arrayToMap as dU,BIND_MODE_TIMEOUT as As,DEFAULT_TRANSFORM_HANDLE_SPACING as BC,FRAME_STYLE as uo,getFeatureFlag as mU,invariant as MC,THEME as pr}from"@excalidraw/common";import{deconstructDiamondElement as v1,deconstructRectanguloidElement as FC,elementCenterPoint as Ba,getDiamondBaseCorners as pU,FOCUS_POINT_SIZE as uU,getOmitSidesForEditorInterface as E1,getTransformHandles as hU,getTransformHandlesFromCoords as gU,hasBoundingBox as fU,hitElementItself as bU,isArrowElement as EU,isBindableElement as OC,isElbowArrow as Fa,isFrameLikeElement as Oa,isImageElement as AC,isLinearElement as xU,isLineElement as yU,maxBindingDistance_simple as wU,isTextElement as vU,getActiveTextElement as IU}from"@excalidraw/element";import{LinearElementEditor as Zo}from"@excalidraw/element/linearElementEditor";import{renderSelectionElement as TU}from"@excalidraw/element";import{getElementsInGroup as I1,getSelectedGroupIds as SU,isSelectedViaGroup as CU,selectGroupsFromGivenElements as kU}from"@excalidraw/element";import{getCommonBounds as T1,getElementAbsoluteCoords as tp}from"@excalidraw/element";import{getGlobalFixedPointForBindableElement as LC,isFocusPointVisible as PU}from"@excalidraw/element";import{pointFrom as Et}from"@excalidraw/math";import{THEME as oU}from"@excalidraw/common";var nU="#ff6b6b",rU="#ff0000",SC=1,CC=2,kC=(e,o)=>{if(!o.snapLines.length)return;let t=o.theme===oU.LIGHT||o.zenModeEnabled?nU:rU,n=(o.zenModeEnabled?SC*1.5:SC)/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,aU(r,e,o)):r.type==="gap"?(e.lineWidth=n,e.strokeStyle=t,lU(r.points[0],r.points[1],r.direction,o,e)):r.type==="points"&&(e.lineWidth=n,e.strokeStyle=t,iU(r,e,o));e.restore()},iU=(e,o,t)=>{if(!t.zenModeEnabled){let n=e.points[0],r=e.points[e.points.length-1];po(n,r,o)}for(let n of e.points)PC(n,t,o)},aU=(e,o,t)=>{PC(e.points[0],t,o),t.zenModeEnabled||po(e.points[0],e.points[1],o)},PC=([e,o],t,n)=>{n.save();let r=(t.zenModeEnabled?CC*1.5:CC)/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()},po=(e,o,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(o[0],o[1]),t.stroke()},lU=(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||po(Et(e[0],e[1]-i),Et(e[0],e[1]+i),r),po(Et(s[0]-l,s[1]-a),Et(s[0]-l,s[1]+a),r),po(Et(s[0]+l,s[1]-a),Et(s[0]+l,s[1]+a),r),n.zenModeEnabled||(po(Et(o[0],o[1]-i),Et(o[0],o[1]+i),r),po(e,o,r))}else{let s=[e[0],(e[1]+o[1])/2];n.zenModeEnabled||po(Et(e[0]-i,e[1]),Et(e[0]+i,e[1]),r),po(Et(s[0]-a,s[1]-l),Et(s[0]+a,s[1]-l),r),po(Et(s[0]-a,s[1]+l),Et(s[0]+a,s[1]+l),r),n.zenModeEnabled||(po(Et(o[0]-i,o[1]),Et(o[0]+i,o[1]),r),po(e,o,r))}};var MU=(e,o)=>{MC(o.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=o.selectedLinearElement;MC(t,"midPointCoords is null"),e.save(),e.translate(o.scrollX,o.scrollY),S1(t,e,o),e.restore()},AU=(e,o,t)=>{let{elementId:n,hoverPointIndex:r}=o.selectedLinearElement;if(o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(r)||o.selectedLinearElement?.isDragging)return;let i=Zo.getElement(n,t);if(!i)return;let a=Zo.getPointAtIndexGlobalCoordinates(i,r,t);e.save(),e.translate(o.scrollX,o.scrollY),S1(a,e,o),e.restore()},S1=(e,o,t)=>{o.fillStyle="rgba(105, 101, 219, 0.4)",Qa(o,e[0],e[1],Zo.POINT_HANDLE_SIZE/t.zoom.value,!1)},LU=(e,o,t)=>{e.save(),e.translate(o.scrollX,o.scrollY),S1(t,e,o),e.restore()},x1=(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)"),Qa(e,t[0],t[1],(a?n*(o.selectedLinearElement?.isEditing?1.5:2):n)/o.zoom.value,!i,!a||r)},_U=(e,o,t,n,r)=>{let i=o.element.frameId&&t.get(o.element.frameId);switch(i&&Oa(i)&&(e.translate(i.x,i.y),e.beginPath(),uo.radius&&e.roundRect?e.roundRect(-1,-1,i.width+1,i.height+1,uo.radius/n.zoom.value):e.rect(-1,-1,i.width+1,i.height+1),e.clip(),e.translate(-i.x,-i.y)),o.element.type){case"magicframe":case"frame":e.save(),e.translate(o.element.x,o.element.y),e.lineWidth=uo.strokeWidth/n.zoom.value,e.strokeStyle=n.theme===pr.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",uo.radius&&e.roundRect?(e.beginPath(),e.roundRect(0,0,o.element.width,o.element.height,uo.radius/n.zoom.value),e.stroke(),e.closePath()):e.strokeRect(0,0,o.element.width,o.element.height),e.restore();break;default:e.save();let a=Ba(o.element,t);switch(e.translate(a[0],a[1]),e.rotate(o.element.angle),e.translate(-a[0],-a[1]),e.translate(o.element.x,o.element.y),e.lineWidth=w1(1.75,o.element.strokeWidth,4)/Math.max(.25,n.zoom.value),e.strokeStyle=n.theme===pr.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",o.element.type){case"ellipse":e.beginPath(),e.ellipse(o.element.width/2,o.element.height/2,o.element.width/2,o.element.height/2,0,0,2*Math.PI),e.closePath(),e.stroke();break;case"diamond":{let[l,s]=v1(o.element);l.forEach(c=>{e.beginPath(),e.moveTo(c[0][0]-o.element.x,c[0][1]-o.element.y),e.lineTo(c[1][0]-o.element.x,c[1][1]-o.element.y),e.stroke()}),s.forEach(c=>{let[m,p,d,u]=c;e.beginPath(),e.moveTo(m[0]-o.element.x,m[1]-o.element.y),e.bezierCurveTo(p[0]-o.element.x,p[1]-o.element.y,d[0]-o.element.x,d[1]-o.element.y,u[0]-o.element.x,u[1]-o.element.y),e.stroke()})}break;default:{let[l,s]=FC(o.element);l.forEach(c=>{e.beginPath(),e.moveTo(c[0][0]-o.element.x,c[0][1]-o.element.y),e.lineTo(c[1][0]-o.element.x,c[1][1]-o.element.y),e.stroke()}),s.forEach(c=>{let[m,p,d,u]=c;e.beginPath(),e.moveTo(m[0]-o.element.x,m[1]-o.element.y),e.bezierCurveTo(p[0]-o.element.x,p[1]-o.element.y,d[0]-o.element.x,d[1]-o.element.y,u[0]-o.element.x,u[1]-o.element.y),e.stroke()})}break}e.restore();break}if(n.isMidpointSnappingEnabled&&(Oa(o.element)||OC(o.element))){let a=n.selectedLinearElement,l=a?.elementId&&Zo.getElement(a?.elementId,t),s=r&&bU({point:r,element:o.element,elementsMap:t,threshold:0,overrideShouldTestInside:!0}),c=l&&Fa(l)||n.activeTool.type==="arrow"&&n.currentItemArrowType==="elbow";if(!s||c){e.save();let m=Ba(o.element,t),p;if(o.element.type==="diamond"){let g=Ba(o.element,t);p=pU(o.element).map(E=>{let y=NC(E,.5),v=ep(y,g,o.element.angle);return Na(v[0],v[1])})}else p=[{x:o.element.width,y:o.element.height/2},{x:o.element.width/2,y:o.element.height},{x:0,y:o.element.height/2},{x:o.element.width/2,y:0}].map(E=>{let y=Na(E.x+o.element.x,E.y+o.element.y),v=ep(y,m,o.element.angle);return Na(v[0],v[1])});let d=r&&p.reduce((g,E,y)=>{let v=cU(E,r);return y===-1||v<g.distance?{idx:y,distance:v}:g},{idx:-1,distance:1/0}),u=4/n.zoom.value,b=wU(n.zoom)+o.element.strokeWidth/2;p.forEach((g,E)=>{let y=(!s||c)&&d?.idx===E&&d.distance<=b,v=!y&&(c||E===d?.idx&&d.distance<=b*2);y?(e.fillStyle=n.theme===pr.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",e.beginPath(),e.arc(g[0],g[1],u,0,2*Math.PI),e.fill()):v&&(e.fillStyle=n.theme===pr.DARK?"rgba(0, 0, 0, 0.8)":"rgba(65, 65, 65, 0.5)",e.beginPath(),e.arc(g[0],g[1],u,0,2*Math.PI),e.fill())}),e.restore()}}},DU=(e,o,t,n,r,i,a)=>{let l=e.state.bindMode==="orbit"&&e.bindModeHandler!==null,s=As-(a?.runtime??(l?0:As)),c=w1(1/As*s,1e-4,1),m=t.strokeWidth/2,p=t.frameId&&n.get(t.frameId);switch(p&&Oa(p)&&(o.translate(p.x,p.y),o.beginPath(),uo.radius&&o.roundRect?o.roundRect(-1,-1,p.width+1,p.height+1,uo.radius/r.zoom.value):o.rect(-1,-1,p.width+1,p.height+1),o.clip(),o.translate(-p.x,-p.y)),t.type){case"magicframe":case"frame":o.save(),o.translate(t.x,t.y),o.lineWidth=uo.strokeWidth/r.zoom.value,o.strokeStyle=r.theme===pr.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,uo.radius&&o.roundRect?(o.beginPath(),o.roundRect(0,0,t.width,t.height,uo.radius/r.zoom.value),o.stroke(),o.closePath()):o.strokeRect(0,0,t.width,t.height),o.restore();break;default:o.save();let u=Ba(t,n),b=u[0]+r.scrollX,g=u[1]+r.scrollY;switch(o.translate(b,g),o.rotate(t.angle),o.translate(-b,-g),o.translate(t.x+r.scrollX-m,t.y+r.scrollY-m),o.lineWidth=w1(2.5,t.strokeWidth*1.75,4)/Math.max(.25,r.zoom.value),o.strokeStyle=r.theme===pr.DARK?`rgba(3, 93, 161, ${c/2})`:`rgba(106, 189, 252, ${c/2})`,t.type){case"ellipse":o.beginPath(),o.ellipse((t.width+m*2)/2,(t.height+m*2)/2,(t.width+m*2)/2,(t.height+m*2)/2,0,0,2*Math.PI),o.closePath(),o.stroke();break;case"diamond":{let[E,y]=v1(t,m);E.forEach(v=>{o.beginPath(),o.moveTo(v[0][0]-t.x+m,v[0][1]-t.y+m),o.lineTo(v[1][0]-t.x+m,v[1][1]-t.y+m),o.stroke()}),y.forEach(v=>{let[x,w,I,C]=v;o.beginPath(),o.moveTo(x[0]-t.x+m,x[1]-t.y+m),o.bezierCurveTo(w[0]-t.x+m,w[1]-t.y+m,I[0]-t.x+m,I[1]-t.y+m,C[0]-t.x+m,C[1]-t.y+m),o.stroke()})}break;default:{let[E,y]=FC(t,m);E.forEach(v=>{o.beginPath(),o.moveTo(v[0][0]-t.x+m,v[0][1]-t.y+m),o.lineTo(v[1][0]-t.x+m,v[1][1]-t.y+m),o.stroke()}),y.forEach(v=>{let[x,w,I,C]=v;o.beginPath(),o.moveTo(x[0]-t.x+m,x[1]-t.y+m),o.bezierCurveTo(w[0]-t.x+m,w[1]-t.y+m,I[0]-t.x+m,I[1]-t.y+m,C[0]-t.x+m,C[1]-t.y+m),o.stroke()})}break}o.restore();break}if(!l||(a?.runtime??0)>As)return;let d=.5*(Math.min(t.width,t.height)/2);if(!Oa(t)){o.save(),o.translate(t.x+r.scrollX,t.y+r.scrollY);let u=1/As*s;if(o.strokeStyle="rgba(0, 0, 0, 0.2)",o.lineWidth=1/r.zoom.value,o.setLineDash([4/r.zoom.value,4/r.zoom.value]),o.lineDashOffset=-u*10/r.zoom.value,o.beginPath(),o.ellipse(t.width/2,t.height/2,d,d,0,0,2*Math.PI),o.stroke(),o.fillStyle="rgba(0, 0, 0, 0.04)",o.beginPath(),o.ellipse(t.width/2,t.height/2,d*(1-c),d*(1-c),0,0,2*Math.PI),o.fill(),o.restore(),r.isMidpointSnappingEnabled){o.save(),o.translate(t.x+r.scrollX,t.y+r.scrollY);let b=5/r.zoom.value,g=5/r.zoom.value,E=b+g,y;if(t.type==="diamond"){let[,v]=v1(t),x=Ba(t,n);y=v.map(w=>{let I=NC(w,.5),C=ep(I,x,t.angle);return{x:C[0]-t.x,y:C[1]-t.y}})}else{let v=Ba(t,n);y=[{x:t.width/2,y:0},{x:t.width,y:t.height/2},{x:t.width/2,y:t.height},{x:0,y:t.height/2}].map(w=>{let I=Na(w.x+t.x,w.y+t.y),C=ep(I,v,t.angle);return{x:C[0]-t.x,y:C[1]-t.y}})}y.forEach(v=>{o.clearRect(v.x-E,v.y-E,E*2,E*2)}),o.fillStyle=r.theme===pr.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,y.forEach(v=>{o.beginPath(),o.arc(v.x,v.y,b,0,2*Math.PI),o.fill()}),o.restore()}}return{runtime:(a?.runtime??0)+i}},RU=(e,o,t,n,r,i,a)=>{if(t===null)return;if(mU("COMPLEX_BINDINGS"))return DU(e,o,t.element,n,r,i,a);o.save(),o.translate(r.scrollX,r.scrollY);let l=e.lastPointerMoveCoords?Na(e.lastPointerMoveCoords.x,e.lastPointerMoveCoords.y):null;_U(o,t,n,r,l),o.restore()},zC=(e,o,t)=>{let{angle:n,x1:r,y1:i,x2:a,y2:l,selectionColors:s,cx:c,cy:m,dashed:p,activeEmbeddable:d}=t,u=a-r,b=l-i,E=(t.padding??BC*2)/o.zoom.value,y=8/o.zoom.value,v=4/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=(d?4:1)/o.zoom.value;let x=s.length;for(let w=0;w<x;++w)e.strokeStyle=s[w],p&&e.setLineDash([y,v+(y+v)*(x-1)]),e.lineDashOffset=(y+v)*w,el(e,r-E,i-E,u+E*2,b+E*2,c,m,n);e.restore()},NU=(e,o,t,n)=>{let[r,i,a,l]=tp(t,n),s=a-r,c=l-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=uo.strokeWidth/o.zoom.value,e.save(),e.translate(o.scrollX,o.scrollY),el(e,r,i,s,c,r+s/2,i+c/2,t.angle,!1,uo.radius/o.zoom.value),e.restore()},_C=(e,o,t,n)=>{let{colors:r=["rgb(0,118,255)"],dashed:i=!1}=n||{},a=t.filter(m=>m.groupIds.length===0),l=t.filter(m=>m.groupIds.length>0),s=m=>{let[p,d,u,b]=T1(m);return{angle:0,x1:p,x2:u,y1:d,y2:b,selectionColors:r,dashed:i,cx:p+(u-p)/2,cy:d+(b-d)/2,activeEmbeddable:!1}},c=m=>{let p=I1(t,m);return s(p)};Object.entries(kU(l,o)).filter(([m,p])=>p).map(([m,p])=>m).map(m=>c(m)).concat(a.map(m=>s([m]))).forEach(m=>zC(e,o,m))},y1=(e,o,t,n)=>{if(!o.selectedLinearElement)return;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=1/o.zoom.value;let r=Zo.getPointsGlobalCoordinates(t,n),{POINT_HANDLE_SIZE:i}=Zo,a=o.selectedLinearElement?.isEditing?i:i/2,l=Fa(t),s=yU(t);if(r.forEach((c,m)=>{if(l&&m!==0&&m!==r.length-1)return;let p=m>0&&(m!==r.length-1||!s||!t.polygon)&&sU(c,m===r.length-1?r[0]:r[m-1],2/o.zoom.value),d=!!o.selectedLinearElement?.isEditing&&!!o.selectedLinearElement?.selectedPointsIndices?.includes(m);s&&t.polygon&&!d&&m===t.points.length-1&&o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(d=!0),x1(e,o,c,a,d,!1,p)}),Fa(t)){let c=t.fixedSegments?.map(m=>m.index)||[];r.slice(0,-1).forEach((m,p)=>{Zo.isSegmentTooShort(t,r[p+1],r[p],p,o.zoom,n)||x1(e,o,Na((m[0]+r[p+1][0])/2,(m[1]+r[p+1][1])/2),i/2,!1,!c.includes(p+1),!1)})}else Zo.getEditorMidPoints(t,n,o).filter((m,p,d)=>m!==null&&!(Fa(t)&&(p===0||p===d.length-1))).forEach(m=>{(o.selectedLinearElement?.isEditing||r.length===2)&&x1(e,o,m,i/2,!1,!0,!1)});e.restore()},BU=(e,o,t,n)=>{e.save(),e.translate(o.scrollX,o.scrollY),e.strokeStyle="rgba(134, 131, 226, 0.6)",e.lineWidth=1/o.zoom.value,e.setLineDash([4/o.zoom.value,4/o.zoom.value]),e.beginPath(),e.moveTo(t[0],t[1]),e.lineTo(n[0],n[1]),e.stroke(),e.restore()},FU=(e,o,t,n,r)=>{e.save(),e.translate(o.scrollX,o.scrollY),e.strokeStyle="rgba(134, 131, 226, 0.6)",e.lineWidth=1/o.zoom.value,e.setLineDash([]),e.fillStyle=r?"rgba(134, 131, 226, 0.9)":"rgba(255, 255, 255, 0.9)",Qa(e,t[0],t[1],n/o.zoom.value,!0,!0),e.restore()},DC=({arrow:e,appState:o,type:t,context:n,elementsMap:r})=>{let i=t==="start"?e.startBinding:e.endBinding,a=i?.elementId&&r.get(i.elementId);if(!a||!OC(a)||a.isDeleted)return;let l=LC(i.fixedPoint,a,r);if(!PU(l,e,a,r,o,t))return;let s=o.selectedLinearElement,c=!!s?.isDragging,m=t==="start"?0:e.points.length-1,p=!!s?.selectedPointsIndices?.includes(m);if(s?.hoveredFocusPointBinding===t&&!s.draggedFocusPointBinding&&LU(n,o,l),!(p&&c)){let d=LC(i.fixedPoint,a,r),u=s?.hoveredFocusPointBinding===t,b=Zo.getPointAtIndexGlobalCoordinates(e,m,r);BU(n,o,b,d),FU(n,o,d,uU/1.5,u)}},RC=(e,o,t,n,r)=>{Object.keys(n).forEach(i=>{let a=n[i];if(a!==void 0){let[l,s,c,m]=a;e.save(),e.lineWidth=1/t.zoom.value,o.selectionColor&&(e.strokeStyle=o.selectionColor),i==="rotation"?Qa(e,l+c/2,s+m/2,c/2,!0):e.roundRect?(e.beginPath(),e.roundRect(l,s,c,m,2/t.zoom.value),e.fill(),e.stroke()):el(e,l,s,c,m,l+c/2,s+m/2,r,!0),e.restore()}})},OU=(e,o,t,n,r)=>{let[i,a,,,l,s]=tp(n,r),c=3,m=20,p=c/t.zoom.value,d=p/2,u=l-i+p,b=s-a+p,g=Math.min(m/t.zoom.value,u),E=Math.min(m/t.zoom.value,b);e.save(),e.fillStyle=o.selectionColor,e.strokeStyle=o.selectionColor,e.lineWidth=p,[[[-u,-b],[0,d],[g,d],[d,0],[d,E]],[[u-d,-b],[d,d],[-g+d,d],[0,0],[0,E]],[[-u,b],[0,-d],[g,-d],[d,0],[d,-E]],[[u-d,b],[d,-d],[-g+d,-d],[0,0],[0,-E]]].forEach(v=>{let[[x,w],[I,C],[A,k],[L,_],[M,D]]=v;e.save(),e.translate(l,s),e.rotate(n.angle),e.beginPath(),e.moveTo(x+I,w+C),e.lineTo(x+A,w+k),e.stroke(),e.beginPath(),e.moveTo(x+L,w+_),e.lineTo(x+M,w+D),e.stroke(),e.restore()}),e.restore()},zU=(e,o,t,n)=>{o.save();let r=Xg(t.zoom.value),i=e.width+r*2,a=e.height+r*2,l=e.x+e.width/2,s=e.y+e.height/2,c=-(e.width/2+r),m=-(e.height/2+r);o.translate(l+t.scrollX,s+t.scrollY),o.rotate(e.angle),o.lineWidth=1/t.zoom.value,o.strokeStyle=n,o.globalAlpha=.5,o.setLineDash([6/t.zoom.value,4/t.zoom.value]),o.strokeRect(c,m,i,a),o.restore()},HU=(e,o,t,n,r)=>{let i=Kg(e,t.zoom.value,r);i&&(o.save(),o.globalAlpha=.5,o.lineWidth=1.5/t.zoom.value,o.lineCap="round",o.strokeStyle=n,o.beginPath(),o.moveTo(i.start[0]+t.scrollX,i.start[1]+t.scrollY),o.lineTo(i.end[0]+t.scrollX,i.end[1]+t.scrollY),o.stroke(),o.restore())},GU=({app:e,canvas:o,elementsMap:t,visibleElements:n,selectedElements:r,allElementsMap:i,scale:a,appState:l,renderConfig:s,editorInterface:c,animationState:m,deltaTime:p})=>{if(o===null)return{atLeastOneVisibleElement:!1,elementsMap:t};let[d,u]=Js(o,a),b=m,g=Qs({canvas:o,scale:a,normalizedWidth:d,normalizedHeight:u});g.save(),g.scale(l.zoom.value,l.zoom.value);let E;if(n.forEach(C=>{l.selectedLinearElement?.isEditing&&l.selectedLinearElement.elementId===C.id&&C&&(E=C)}),E&&y1(g,l,E,t),l.selectionElement&&!l.isCropping)try{TU(l.selectionElement,g,l,s.selectionColor)}catch(C){console.error(C)}let y=IU(r,l);if(y&&!y.autoResize&&HU(y,g,l,s.selectionColor,c.formFactor),l.editingTextElement){let C=i.get(l.editingTextElement.id);C&&!C.autoResize&&zU(C,g,l,s.selectionColor)}if(l.isBindingEnabled&&l.suggestedBinding?b={...m,bindingHighlight:RU(e,g,l.suggestedBinding,i,l,p,m?.bindingHighlight)}:b={...m,bindingHighlight:void 0},l.frameToHighlight&&NU(g,l,l.frameToHighlight,t),l.elementsToHighlight&&_C(g,l,l.elementsToHighlight),l.activeLockedId){let C=i.get(l.activeLockedId),A=C?[C]:I1(i,l.activeLockedId);_C(g,l,A,{colors:["#ced4da"],dashed:!0})}let v=r.some(C=>Oa(C));r.length===1&&l.selectedLinearElement?.isEditing&&l.selectedLinearElement.elementId===r[0].id&&y1(g,l,r[0],t);let x=l.selectedLinearElement,w=x&&Zo.getElement(x.elementId,i);if(w&&(l.selectedLinearElement.isDragging||(x.segmentMidPointHoveredCoords?MU(g,l):(Fa(w)?x.hoverPointIndex===0||x.hoverPointIndex===w.points.length-1:x.hoverPointIndex>=0)&&AU(g,l,t)),EU(w)&&(DC({arrow:w,elementsMap:i,appState:l,context:g,type:"start"}),DC({arrow:w,elementsMap:i,appState:l,context:g,type:"end"}))),!l.multiElement&&!l.newElement&&!l.selectedLinearElement?.isEditing){let C=fU(r,l,c),A=r.length===1&&xU(r[0]);A&&l.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&y1(g,l,r[0],t);let k=s.selectionColor||"#000";if(C){let L=dU(r),_=[];for(let D of t.values()){let z=[],W=s.remoteSelectedElementIds.get(D.id);if(A&&Fa(D)&&(D.startBinding||D.endBinding)||(L.has(D.id)&&!CU(l,D)&&z.push(k),W&&z.push(...W.map(O=>Dr(O,l.collaborators.get(O))))),z.length){let[O,K,Y,q,ne,ae]=tp(D,t,!0);_.push({angle:D.angle,x1:O,y1:K,x2:Y,y2:q,selectionColors:D.locked?["#ced4da"]:z,dashed:!!W||D.locked,cx:ne,cy:ae,activeEmbeddable:l.activeEmbeddable?.element===D&&l.activeEmbeddable.state==="active",padding:D.id===l.croppingElementId||AC(D)?0:void 0})}}let M=D=>{let z=I1(t,D),[W,O,K,Y]=T1(z);_.push({angle:0,x1:W,x2:K,y1:O,y2:Y,selectionColors:z.some(q=>q.locked)?["#ced4da"]:["#000"],dashed:!0,cx:W+(K-W)/2,cy:O+(Y-O)/2,activeEmbeddable:!1})};for(let D of SU(l))M(D);l.editingGroupId&&M(l.editingGroupId),_.forEach(D=>zC(g,l,D))}if(g.save(),g.translate(l.scrollX,l.scrollY),r.length===1){g.fillStyle="#fff";let L=hU(r[0],l.zoom,t,"mouse",E1(c));if(!l.viewModeEnabled&&C&&!vU(l.editingTextElement)&&!l.croppingElementId&&RC(g,s,l,L,r[0].angle),l.croppingElementId&&!l.isCropping){let _=t.get(l.croppingElementId);_&&AC(_)&&OU(g,s,l,_,t)}}else if(r.length>1&&!l.isRotating&&!r.some(L=>L.locked)){let L=BC*2/l.zoom.value;g.fillStyle="#fff";let[_,M,D,z]=T1(r,t),W=g.getLineDash();g.setLineDash([2/l.zoom.value]);let O=g.lineWidth;g.lineWidth=1/l.zoom.value,g.strokeStyle=k,el(g,_-L,M-L,D-_+L*2,z-M+L*2,(_+D)/2,(M+z)/2,0),g.lineWidth=O,g.setLineDash(W);let K=gU([_,M,D,z,(_+D)/2,(M+z)/2],0,l.zoom,"mouse",v?{...E1(c),rotation:!0}:E1(c));r.some(Y=>!Y.locked)&&RC(g,s,l,K,0)}g.restore()}l.searchMatches?.matches.forEach(({id:C,focus:A,matchedLines:k})=>{let L=t.get(C);if(L){let[_,M,,,D,z]=tp(L,t,!0);g.save(),l.theme===pr.LIGHT?A?g.fillStyle="rgba(255, 124, 0, 0.4)":g.fillStyle="rgba(255, 226, 0, 0.4)":A?g.fillStyle="rgba(229, 82, 0, 0.4)":g.fillStyle="rgba(99, 52, 0, 0.4)";let W=Oa(L)?l.zoom.value:1;g.translate(l.scrollX,l.scrollY),g.translate(D,z),g.rotate(L.angle),k.forEach(O=>{(O.showOnCanvas||A)&&g.fillRect(_+O.offsetX/W-D,M+O.offsetY/W-z,O.width/W,O.height/W)}),g.restore()}}),kC(g,l),g.restore(),Gy({context:g,renderConfig:s,appState:l,normalizedWidth:d,normalizedHeight:u});let I;return s.renderScrollbars&&(I=YI(t,d,u,l),g.save(),g.fillStyle=WI,g.strokeStyle="rgba(255,255,255,0.8)",[I.horizontal,I.vertical].forEach(C=>{C&&gd(g,C.x,C.y,C.width,C.height,lo/2)}),g.restore()),{scrollBars:I,atLeastOneVisibleElement:n.length>0,elementsMap:t,animationState:b}},HC=e=>{let o=GU(e);return e.callback(o),o};var dt=class dt{static start(o,t){let n=t({deltaTime:0,state:void 0});n&&(dt.animations.set(o,{animation:t,lastTime:0,state:n}),dt.isRunning||(dt.isRunning=!0,Gr()?requestAnimationFrame(dt.tick):setTimeout(dt.tick,0)))}static tick(){if(dt.animations.size>0){for(let[o,t]of dt.animations){let n=performance.now(),r=t.lastTime===0?0:n-t.lastTime,i=t.animation({deltaTime:r,state:t.state});if(i)t.lastTime=n,t.state=i;else if(dt.animations.delete(o),dt.animations.size===0){dt.isRunning=!1;return}}Gr()?requestAnimationFrame(dt.tick):setTimeout(dt.tick,0)}}static running(o){return dt.animations.has(o)}static cancel(o){dt.animations.delete(o)}};S(dt,"isRunning",!1),S(dt,"animations",new Map);var Ls=dt;import{jsx as ZU}from"react/jsx-runtime";var WC="animateInteractiveScene",XU=e=>{let o=GC(!1),t=GC(null);return WU(()=>{if(!o.current){o.current=!0;return}let n=new Map,r=new Map,i=new Map,a=new Map,l=new Map;e.appState.collaborators.forEach((c,m)=>{if(c.selectedElementIds)for(let p of Object.keys(c.selectedElementIds))i.has(p)||i.set(p,[]),i.get(p).push(m);!c.pointer||c.pointer.renderCursor===!1||(c.username&&a.set(m,c.username),c.userState&&l.set(m,c.userState),r.set(m,VU({sceneX:c.pointer.x,sceneY:c.pointer.y},e.appState)),n.set(m,c.button))});let s=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";t.current={app:e.app,canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:r,remotePointerButton:n,remoteSelectedElementIds:i,remotePointerUsernames:a,remotePointerUserStates:l,selectionColor:s,renderScrollbars:e.renderScrollbars,lastViewportPosition:e.app.lastViewportPosition},editorInterface:e.editorInterface,callback:e.renderInteractiveSceneCallback,animationState:{bindingHighlight:void 0},deltaTime:0},Ls.running(WC)||Ls.start(WC,({deltaTime:c,state:m})=>{let p=HC({...t.current,deltaTime:c,animationState:m}).animationState;if(p){for(let d in p)if(p[d]!==void 0)return p}})}),ZU("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled&&e.appState.activeTool.type!=="laser"?UC.GRAB:UC.AUTO},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onClick:e.onClick,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.appState.viewModeEnabled?void 0:e.onDoubleClick,children:f("labels.drawingCanvas")})},YC=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,activeTool:e.activeTool,openDialog:e.openDialog,editingGroupId:e.editingGroupId,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,newElement:e.newElement,isBindingEnabled:e.isBindingEnabled,isMidpointSnappingEnabled:e.isMidpointSnappingEnabled,suggestedBinding:e.suggestedBinding,isRotating:e.isRotating,elementsToHighlight:e.elementsToHighlight,collaborators:e.collaborators,activeEmbeddable:e.activeEmbeddable,snapLines:e.snapLines,zenModeEnabled:e.zenModeEnabled,editingTextElement:e.editingTextElement,isCropping:e.isCropping,croppingElementId:e.croppingElementId,searchMatches:e.searchMatches,activeLockedId:e.activeLockedId,hoveredElementIds:e.hoveredElementIds,frameRendering:e.frameRendering,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,exportScale:e.exportScale,currentItemArrowType:e.currentItemArrowType}),KU=(e,o)=>e.selectionNonce!==o.selectionNonce||e.canvasNonce!==o.canvasNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements||e.selectedElements!==o.selectedElements||e.renderScrollbars!==o.renderScrollbars?!1:YU(YC(e.appState),YC(o.appState)),C1=UU.memo(XU,KU);import $U,{useEffect as VC,useRef as XC}from"react";import{isShallowEqual as KC}from"@excalidraw/common";import{jsx as JU}from"react/jsx-runtime";var jU=e=>{let o=XC(null),t=XC(!1);return VC(()=>{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]),VC(()=>{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"));let i=getComputedStyle(n).getPropertyValue("--color-grid-bold").trim(),a=getComputedStyle(n).getPropertyValue("--color-grid-regular").trim();Rb({canvas:r,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:{...e.renderConfig,gridColorBold:i,gridColorRegular:a}},Gr())}),JU("div",{className:"excalidraw__canvas-wrapper",ref:o})},ZC=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,openDialog:e.openDialog,hoveredElementIds:e.hoveredElementIds,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,viewBackgroundColor:e.viewBackgroundColor,exportScale:e.exportScale,selectedElementsAreBeingDragged:e.selectedElementsAreBeingDragged,gridSize:e.gridSize,gridStep:e.gridStep,frameRendering:e.frameRendering,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,editingGroupId:e.editingGroupId,currentHoveredFontFamily:e.currentHoveredFontFamily,croppingElementId:e.croppingElementId,suggestedBinding:e.suggestedBinding}),qU=(e,o)=>e.canvasNonce!==o.canvasNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements?!1:KC(ZC(e.appState),ZC(o.appState))&&KC(e.renderConfig,o.renderConfig),k1=$U.memo(jU,qU);import{useEffect as iW,useRef as aW}from"react";import{throttleRAF as QU}from"@excalidraw/common";import{getTargetFrame as eW,isInvisiblySmallElement as tW,renderElement as oW,shouldApplyFrameClip as nW}from"@excalidraw/element";var $C=({canvas:e,rc:o,newElement:t,elementsMap:n,allElementsMap:r,scale:i,appState:a,renderConfig:l})=>{if(e){let[s,c]=Js(e,i),m=Qs({canvas:e,scale:i,normalizedWidth:s,normalizedHeight:c});if(m.save(),m.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"){if(tW(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let d=eW(t,n,a);d&&nW(t,d,a,n)&&_b(d,m,l,a)}oW(t,n,r,o,m,l,a)}else m.clearRect(0,0,s,c);m.restore()}},rW=QU(e=>{$C(e)}),jC=(e,o)=>{if(o){rW(e);return}$C(e)};import{jsx as sW}from"react/jsx-runtime";var lW=e=>{let o=aW(null);return iW(()=>{o.current&&jC({canvas:o.current,scale:e.scale,newElement:e.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},Gr())}),sW("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})},qC=lW;var op=class{constructor(o){this.getState=o;S(this,"listeners",[]);S(this,"onStateChange",(o,t,n)=>{let{predicate:r,getValue:i,callback:a,once:l,matchesImmediately:s}=this.normalize(o,t,n);return a?s&&(queueMicrotask(()=>{let c=this.getState();a(i(c),c)}),l)?()=>{}:this.subscribe({predicate:r,getValue:i,callback:a,once:l}):s?Promise.resolve(i(this.getState())):new Promise(c=>{this.subscribe({predicate:r,getValue:i,callback:m=>c(m),once:!0})})})}isStateChangePredicateOptions(o){return typeof o=="object"&&!Array.isArray(o)&&"predicate"in o}subscribe(o){return this.listeners.push(o),()=>{this.listeners=this.listeners.filter(t=>t!==o)}}normalize(o,t,n){let r,i,a=t,l=n?.once??!1,s=!1;if(this.isStateChangePredicateOptions(o)){let{predicate:c,callback:m,once:p}=o;r=c,i=d=>d,a=m?(d,u)=>m(u):void 0,l=p??!1,s=c(this.getState())}else if(typeof o=="function"){let c=o;r=(m,p)=>c(m)!==c(p),i=m=>c(m)}else if(Array.isArray(o)){let c=o;r=(m,p)=>c.some(d=>m[d]!==p[d]),i=m=>m}else{let c=o;r=(m,p)=>m[c]!==p[c],i=m=>m[c]}return{predicate:r,getValue:i,callback:a,once:l,matchesImmediately:s}}flush(o){if(!this.listeners.length)return;let t=this.getState(),n=[];for(let r of this.listeners)r.predicate(t,o)?(r.callback(r.getValue(t),t),r.once||n.push(r)):n.push(r);this.listeners=n}clear(){this.listeners=[]}};import{getCommonBounds as cW,getElementsInGroup as dW,selectGroupsFromGivenElements as mW}from"@excalidraw/element";import{sceneCoordsToViewportCoords as pW}from"@excalidraw/common";import{flushSync as uW}from"react-dom";import{jsx as gW}from"react/jsx-runtime";var hW=({app:e,activeLockedId:o})=>{let t=e.scene.getElement(o),n=t?[t]:dW(e.scene.getNonDeletedElementsMap(),o);if(n.length===0)return null;let[r,i]=cW(n),{x:a,y:l}=pW({sceneX:r,sceneY:i},e.state);return gW("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${a-e.state.offsetLeft}px`},onClick:()=>{uW(()=>{let s=mW(n,e.state);e.setState({selectedElementIds:n.reduce((c,m)=>({...c,[m.id]:!0}),{}),selectedGroupIds:s,activeLockedId:null})}),e.actionManager.executeAction(zl)},title:f("labels.elementLock.unlock"),children:oE})},JC=hW;import{Fragment as yV,jsx as ve,jsxs as pp}from"react/jsx-runtime";var sk=go.createContext(null),ck=go.createContext(null),rb={formFactor:"desktop",desktopUIMode:"full",userAgent:ak(typeof navigator<"u"?navigator.userAgent:""),isTouchScreen:!1,canFitSidebar:!1,isLandscape:!0},ab=go.createContext(rb);ab.displayName="EditorInterfaceContext";var fV={"editor:mount":{cardinality:"once",replay:"last"},"editor:initialize":{cardinality:"once",replay:"last"},"editor:unmount":{cardinality:"once",replay:"last"}},lb=go.createContext({container:null,id:null});lb.displayName="ExcalidrawContainerContext";var sb=go.createContext([]);sb.displayName="ExcalidrawElementsContext";var cb=go.createContext({...Pn(),width:0,height:0,offsetLeft:0,offsetTop:0});cb.displayName="ExcalidrawAppStateContext";var db=go.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});db.displayName="ExcalidrawSetAppStateContext";var mb=go.createContext(null);mb.displayName="ExcalidrawActionManagerContext";var Xa=go.createContext(null);Xa.displayName="ExcalidrawAPIContext";var hp=go.createContext(null);hp.displayName="ExcalidrawAPISetContext";var je=()=>Cn(sk),no=()=>Cn(ck),pe=()=>Cn(ab),nt=()=>up(pe()),Ne=()=>Cn(lb),Fn=()=>Cn(sb),Do=()=>Cn(cb),be=()=>Cn(db),Ye=()=>Cn(mb),gp=()=>Cn(Xa),Hs=!1,eb=0,Gs=null,gr=!1,Va=!1,Us=!1,Ws=!1,tb=!1,Ys={horizontal:null,vertical:null},fr=0,Vs=!1,ob=new Map,bV=4,nb=!1,ok=0,nk=!1,ti=null,EV="zoom-in",ye={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},ib=class e extends go.Component{constructor(t){super(t);S(this,"canvas");S(this,"interactiveCanvas",null);S(this,"sessionExportThemeOverride");S(this,"rc");S(this,"unmounted",!1);S(this,"actionManager");S(this,"editorInterface",rb);S(this,"stylesPanelMode",up(rb));S(this,"excalidrawContainerRef",go.createRef());S(this,"scene");S(this,"fonts");S(this,"renderer");S(this,"visibleElements");S(this,"resizeObserver");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,"_initialized",!1);S(this,"editorLifecycleEvents",new XW(fV));S(this,"onEvent",this.editorLifecycleEvents.on.bind(this.editorLifecycleEvents));S(this,"appStateObserver",new op(()=>this.state));S(this,"onStateChange",this.appStateObserver.onStateChange);S(this,"flowChartCreator",new NY);S(this,"flowChartNavigator",new BY);S(this,"bindModeHandler",null);S(this,"hitLinkElement");S(this,"lastPointerDownEvent",null);S(this,"lastPointerUpEvent",null);S(this,"lastPointerUpIsDoubleClick",!1);S(this,"lastPointerMoveEvent",null);S(this,"lastPointerMoveCoords",null);S(this,"lastCompletedCanvasClicks",[]);S(this,"previousPointerMoveCoords",null);S(this,"lastViewportPosition",{x:0,y:0});S(this,"animationFrameHandler",new lm);S(this,"laserTrails",new mm(this.animationFrameHandler,this));S(this,"eraserTrail",new fm(this.animationFrameHandler,this));S(this,"lassoTrail",new gm(this.animationFrameHandler,this));S(this,"onChangeEmitter",new Jr);S(this,"onPointerDownEmitter",new Jr);S(this,"onPointerUpEmitter",new Jr);S(this,"onUserFollowEmitter",new Jr);S(this,"onScrollChangeEmitter",new Jr);S(this,"missingPointerEventCleanupEmitter",new Jr);S(this,"onRemoveEventListenersEmitter",new Jr);S(this,"api");S(this,"addImageElementsToScene",async(t,n,r)=>{await this.insertImages(t,n,r)});S(this,"updateEditorAtom",(t,...n)=>{let r=ot.set(t,...n);return this.triggerRender(),r});S(this,"previousHoveredBindableElement",null);S(this,"getEffectiveGridSize",()=>or(this)?this.state.gridSize:null);S(this,"getTextCreationGridPoint",(t,n)=>{let r=this.getEffectiveGridSize();if(r===null)return null;let i=a=>Math.floor(a/r)*r;return{x:i(t),y:i(n)}});S(this,"handleIframeLikeElementHover",({hitElement:t,scenePointer:n,moveEvent:r})=>t&&z1(t)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(t,r,n.x,n.y))?(Ee(this.interactiveCanvas,Re.POINTER),this.setState({activeEmbeddable:{element:t,state:"hover"}}),!0):(this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null}),!1));S(this,"isDoubleClick",(t,n)=>t!=null&&n.timeStamp-t.timeStamp<=m5);S(this,"updateEmbedValidationStatus",(t,n)=>{this.embedsValidationStatus.set(t.id,n),zs.delete(t)});S(this,"updateEmbeddables",()=>{let t=new Set,n=!1;this.scene.getNonDeletedElements().filter(r=>{if(Sn(r)){if(t.add(r.id),!this.embedsValidationStatus.has(r.id)){n=!0;let i=U1(r.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(r,i)}}else Ya(r)&&t.add(r.id);return!1}),n&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((r,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});S(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);S(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});S(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.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 t=this.state.theme===za.DARK,n=this.scene.getNonDeletedFramesLikes(),r=n.length>0&&this.state.searchMatches?.focusedId&&ht(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return n.map(i=>{if(!M5(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}=ap({sceneX:i.x,sceneY:i.y},this.state),s=6,c,m=MY(i);if(i.id===this.state.editingFrame){let p=m;c=ve("input",{autoFocus:!0,value:p,onChange:d=>{this.scene.mutateElement(i,{name:d.target.value})},onFocus:d=>d.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:d=>{(d.key===X.ESCAPE||d.key===X.ENTER)&&this.resetEditingFrame(i)},style:{background:t?VW(this.state.viewBackgroundColor):this.state.viewBackgroundColor,zIndex:2,border:"none",display:"block",padding:`${s}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${$o.nameFontSize}px`,transform:`translate(-${s}px, ${s}px)`,color:t?$o.nameColorDarkTheme:$o.nameColorLightTheme,overflow:"hidden",maxWidth:`${document.body.clientWidth-a-s}px`},size:p.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else c=m;return ve("div",{id:this.getFrameNameDOMId(i),className:B1.FRAME_NAME,style:{position:"absolute",bottom:`${this.state.height+$o.nameOffsetY-l+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:$o.nameFontSize,color:t?$o.nameColorDarkTheme:$o.nameColorLightTheme,lineHeight:$o.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:Re.MOVE,pointerEvents:this.state.viewModeEnabled?Ha.disabled:Ha.enabled},onPointerDown:p=>this.handleCanvasPointerDown(p),onWheel:p=>this.handleWheel(p),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",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});S(this,"onExportImage",async(t,n,r)=>{ce("export",t,"ui");let i=await Ar(t,n,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:r.exportingFrame}).catch(UW).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&tc(i)&&this.setState({fileHandle:i})});S(this,"magicGenerations",new Map);S(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()});S(this,"plugins",{});S(this,"onMagicframeToolSelect",()=>{let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(t.length===0)this.setActiveTool({type:Jo.magicframe}),ce("ai","tool-select (empty-selection)","d2c");else{let n=t.length===1&&k5(t[0])&&t[0];if(!n&&t.some(i=>ht(i)||i.frameId)){this.setActiveTool({type:Jo.magicframe});return}ce("ai","tool-select (existing selection)","d2c");let r;if(n)r=n;else{let[i,a,l,s]=Ua(t),c=50;r=I5({...$o,x:i-c,y:a-c,width:l-i+c*2,height:s-a+c*2,opacity:100,locked:!1}),this.insertNewElement(r);for(let m of t)this.scene.mutateElement(m,{frameId:r.id});this.setState({selectedElementIds:{[r.id]:!0}})}this.onMagicFrameGenerate(r,"upstream")}});S(this,"openEyeDropper",({type:t})=>{this.updateEditorAtom(Bn,{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:Pt.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:n},captureUpdate:Pt.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?hr(l,{[i?"strokeColor":"backgroundColor"]:n}):l),captureUpdate:Pt.IMMEDIATELY})},keepOpenOnAlt:!1})});S(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});S(this,"syncActionResult",Ge(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||za.LIGHT,s=t?.appState?.name??this.state.name,c=t?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(a=this.props.zenModeEnabled),r=t.appState?.editingTextElement||null,t.elements&&r&&t.elements.forEach(m=>{r?.id===m.id&&r!==m&&$5(m)&&jt(m)&&(r=m)}),r?.isDeleted&&(r=null),this.setState(m=>{let p=t.appState||{};return{...m,...p,contextMenu:null,editingTextElement:r,viewModeEnabled:i,zenModeEnabled:a,theme:l,name:s,errorMessage:c}}),n=!0}n||this.scene.triggerUpdate()}));S(this,"onBlur",Ge(()=>{gr=!1,Va=!1,Ws=!1,this.restoreCursorAfterZoomKey(),this.setState({isBindingEnabled:this.state.bindingPreference==="enabled"})}));S(this,"onUnload",()=>{this.onBlur()});S(this,"disableEvent",t=>{t.preventDefault()});S(this,"resetHistory",()=>{this.history.clear()});S(this,"resetStore",()=>{this.store.clear()});S(this,"resetScene",Ge(t=>{this.scene.replaceAllElements([]),this.setState(n=>({...Pn(),isLoading:t?.resetLoadingState?!1:n.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));S(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async a=>{if(!a.files.length)return;let l=a.files[0],s=await l.getFile();this.loadFileToCanvas(new File([s],s.name||"",{type:s.type}),l)}),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(a=>{console.error(a)})}catch(a){console.error(a),t={appState:{errorMessage:a.message||"Encountered an error during importing or restoring scene data"}}}let n=wr(t?.elements,null,{repairBindings:!0,deleteInvisibleElements:!0}),r=li(t?.appState,null),i=r.activeTool;r.preferredSelectionTool.initialized||(r.preferredSelectionTool={type:this.editorInterface.formFactor==="phone"?"lasso":"selection",initialized:!0}),r={...r,theme:this.props.theme||r.theme,openSidebar:r?.openSidebar||this.state.openSidebar,activeTool:i.type==="image"||i.type==="lasso"||i.type==="selection"?{...i,type:r.preferredSelectionTool.type}:r.activeTool,isLoading:!1,toast:this.state.toast},t?.scrollToContent&&(r={...r,...xr(n,{...r,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})}),this.resetStore(),this.resetHistory(),this.syncActionResult({elements:n,appState:r,files:t?.files,captureUpdate:Pt.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(a=>{this.fonts.onLoaded(a)}),$1(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})});S(this,"getFormFactor",(t,n)=>this.props.UIOptions.getFormFactor?.(t,n)??jW(t,n));S(this,"refreshEditorInterface",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:n,height:r}=t.getBoundingClientRect(),i=eY(),a=ak(typeof navigator<"u"?navigator.userAgent:""),l=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:CW,s=N1(this.editorInterface,{desktopUIMode:i??this.editorInterface.desktopUIMode,formFactor:this.getFormFactor(n,r),userAgent:a,canFitSidebar:n>l,isLandscape:n>r});this.editorInterface=s,this.reconcileStylesPanelMode(s)});S(this,"reconcileStylesPanelMode",t=>{let n=up(t);if(n===this.stylesPanelMode)return;let r=this.stylesPanelMode;this.stylesPanelMode=n,r!=="full"&&n==="full"&&this.setState(i=>({preferredSelectionTool:{type:"selection",initialized:!0}}))});S(this,"setDesktopUIMode",t=>{let n=tY(t);this.editorInterface=N1(this.editorInterface,{desktopUIMode:n}),this.reconcileStylesPanelMode(this.editorInterface)});S(this,"onResize",Ge(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>zs.delete(t)),this.refreshEditorInterface(),this.updateDOMRect(),this.setState({})}));S(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});S(this,"renderInteractiveSceneCallback",({atLeastOneVisibleElement:t,scrollBars:n,elementsMap:r})=>{n&&(Ys=n);let i=this.state.editingTextElement?!1:!t&&r.size>0;this.state.scrolledOutside!==i&&this.setState({scrolledOutside:i}),this.scheduleImageRefresh()});S(this,"onScroll",h5(()=>{let{offsetTop:t,offsetLeft:n}=this.getCanvasOffsets();this.setState(r=>r.offsetLeft===n&&r.offsetTop===t?null:{offsetTop:t,offsetLeft:n})},kW));S(this,"onCut",Ge(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||Ds(t.target)||(this.actionManager.executeAction(Ed,"keyboard",t),t.preventDefault(),t.stopPropagation())}));S(this,"onCopy",Ge(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||Ds(t.target)||(this.actionManager.executeAction(Yi,"keyboard",t),t.preventDefault(),t.stopPropagation())}));S(this,"onTouchStart",t=>{if(qW&&t.preventDefault(),!Hs){Hs=!0,t.touches.length===1&&(Gs={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(eb),eb=window.setTimeout(e.resetTapTwice,m5);return}if(Hs&&t.touches.length===1&&Gs){let n=t.touches[0];In(oe(n.clientX,n.clientY),oe(Gs.x,Gs.y))<=E5&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:n.clientX,clientY:n.clientY,type:"touch",altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1})),Hs=!1,clearTimeout(eb)}t.touches.length===2&&this.setState({selectedElementIds:Ce({},this.state),activeEmbeddable:null})});S(this,"onTouchEnd",t=>{this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:Ce(this.state.previousSelectedElementIds,this.state)}):ye.pointers.clear()});S(this,"pasteFromClipboard",Ge(async t=>{let n=!!nb,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)||Ds(r)))return;let l=await Ni(t),s=l.getFiles(),c=await ld(l,n);if(this.props.onPaste)try{if(await this.props.onPaste(c,t)===!1)return}catch(m){console.error(m)}await this.insertClipboardContent(c,s,n),this.setActiveTool({type:this.state.preferredSelectionTool.type},!0),t?.preventDefault()}));S(this,"addElementsFromPasteOrLibrary",t=>{let n=wr(t.elements,null,{deleteInvisibleElements:!0}),[r,i,a,l]=Ua(n),s=Ga(r,a)/2,c=Ga(i,l)/2,m=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,p=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop,{x:d,y:u}=He({clientX:m,clientY:p},this.state),b=d-s,g=u-c,[E,y]=xt(b,g,this.getEffectiveGridSize()),{duplicatedElements:v}=F1({type:"everything",elements:n.map(k=>hr(k,{x:k.x+E-r,y:k.y+y-i})),randomizeSeed:!t.retainSeed,preserveFrameChildrenOrder:t.preserveFrameChildrenOrder}),x=this.scene.getElementsIncludingDeleted(),w=[...x,...v];w=this.props.onDuplicate?.(w,x)||w,Y5(w,lp(v));let C=this.getTopLayerFrameAtSceneCoords({x:d,y:u});if(C){let k=LY(v,C);w=X1(w,k,C)}this.scene.replaceAllElements(w),v.forEach(k=>{if(jt(k)&&O1(k)){let L=R5(k,this.scene.getElementsMapIncludingDeleted());vY(k,L,this.scene)}}),QW&&nn.loadElementsFonts(v).then(k=>{this.fonts.onLoaded(k)}),t.files&&this.addMissingFiles(t.files);let A=jY(v);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.editorInterface.canFitSidebar&&ot.get(ys)?this.state.openSidebar:null,...ho({editingGroupId:null,selectedElementIds:A.reduce((k,L)=>(O1(L)||(k[L.id]=!0),k),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:this.state.preferredSelectionTool.type},!0),t.fitToContent&&this.scrollToContent(v,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})});S(this,"setAppState",(t,n)=>{this.setState(t,n)});S(this,"removePointer",t=>{fr&&this.resetContextMenuTimer(),ye.pointers.delete(t.pointerId)});S(this,"toggleLock",(t="ui")=>{this.state.activeTool.locked||ce("toolbar","toggleLock",`${t} (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),this.setState(n=>({activeTool:{...n.activeTool,...Qo(this.state,n.activeTool.locked?{type:this.state.preferredSelectionTool.type}:n.activeTool),locked:!n.activeTool.locked}}))});S(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}}})});S(this,"togglePenMode",t=>{this.setState(n=>({penMode:t??!n.penMode,penDetected:!0}))});S(this,"onHandToolToggle",()=>{this.actionManager.executeAction(ny)});S(this,"zoomCanvas",t=>{this.setState({...Bo({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:Jt(t)},this.state)})});S(this,"cancelInProgressAnimation",null);S(this,"scrollToViewport",(t,n)=>{this.cancelInProgressAnimation?.();let r={value:Jt(t.zoom)},i=n?.duration??500;if(n?.animate&&i>0){let a=this.state.scrollX,l=this.state.scrollY,s=this.state.zoom.value,c=GW({fromValues:{scrollX:a,scrollY:l,zoom:s},toValues:{scrollX:t.scrollX,scrollY:t.scrollY,zoom:r.value},interpolateValue:(m,p,d,u)=>{if(u==="zoom")return m*Math.pow(p/m,WW(d))},onStep:({scrollX:m,scrollY:p,zoom:d})=>{this.setState({scrollX:m,scrollY:p,zoom:{value:d}})},onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.cancelInProgressAnimation=null,this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.cancelInProgressAnimation=null,this.setState({shouldCacheIgnoreZoom:!1})},duration:i});this.cancelInProgressAnimation=()=>{c(),this.cancelInProgressAnimation=null}}else this.setState({scrollX:t.scrollX,scrollY:t.scrollY,zoom:r})});S(this,"scrollToContent",(t=this.scene.getNonDeletedElements(),n)=>{if(typeof t=="string"){let s;if($1(t)?s=zY(t):s=t,s){let c=this.scene.getElementsFromId(s);c?.length?this.scrollToContent(c,{fitToContent:n?.fitToContent??!0,animate:n?.animate??!0}):$1(t)&&this.setState({toast:{message:f("elementLink.notFound"),duration:3e3,closable:!0}})}return}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}=Tl({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=xr(r,this.state);a=s.scrollX,l=s.scrollY}this.scrollToViewport({scrollX:a,scrollY:l,zoom:i.value},{animate:n?.animate,duration:n?.duration})});S(this,"maybeUnfollowRemoteUser",()=>{this.state.userToFollow&&this.setState({userToFollow:null})});S(this,"translateCanvas",t=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(t)});S(this,"setToast",t=>{this.setState({toast:t})});S(this,"handleToastClose",()=>{this.setToast(null)});S(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,yW,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});S(this,"addFiles",Ge(t=>{let{addedFiles:n}=this.addMissingFiles(t);this.clearImageShapeCache(n),this.scene.triggerUpdate(),this.addNewImagesToImageCache()}));S(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===jo.svg))try{let s=Ub(D5(Wb(l.dataURL)),jo.svg);l.dataURL!==s&&(l.version=(l.version??1)+1,l.dataURL=s)}catch(s){console.error(s)}return this.files=r,{addedFiles:i}});S(this,"updateScene",Ge(t=>{let{elements:n,appState:r,collaborators:i,captureUpdate:a}=t;if(a){let l=n||void 0,s=r?nY({...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})}));S(this,"applyDeltas",(t,n)=>{let r=q5.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return q5.applyTo(r,a,i,n)});S(this,"mutateElement",(t,n,r=!0)=>this.scene.mutateElement(t,n,{informMutation:r,isDragging:!1}));S(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});S(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});S(this,"updateCurrentCursorPosition",Ge(t=>{this.lastViewportPosition.x=t.clientX,this.lastViewportPosition.y=t.clientY}));S(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 rn().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}});S(this,"onKeyDown",Ge(t=>{if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(l,s){let c=l[s];return typeof c=="function"?c.bind(l):s==="key"?t.shiftKey?l.key.toUpperCase():l.key.toLowerCase():c}})),!g5(t.target)){if((t.key===X.ESCAPE||t.key===X.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let l=ee(this.scene.getNonDeletedElementsMap(),this.state);if(l.length===1&&Qr(l[0])&&t.key===X.ENTER){this.startImageCropping(l[0]);return}if(t.key===X.ESCAPE)this.updateEditorAtom(wo,null);else if(t.key===X.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(B1.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let c=ji(l);ot.get(wo)?.type==="panel"&&Fh(this,{conversionType:c,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),c&&this.updateEditorAtom(wo,{type:"panel"})}if(t.key===X.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let s=np(t.key);if(t[X.CTRL_OR_CMD]&&s&&!t.shiftKey){t.preventDefault();let c=ee(this.scene.getNonDeletedElementsMap(),this.state);c.length===1&&fY(c[0])&&this.flowChartCreator.createNodes(c[0],this.state,H5(t.key),this.scene),this.flowChartCreator.pendingNodes?.length&&!G1(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 c=ee(this.scene.getNonDeletedElementsMap(),this.state);if(c.length===1&&s){t.preventDefault();let m=this.flowChartNavigator.exploreByDirection(c[0],this.scene.getNonDeletedElementsMap(),H5(t.key));if(m){this.setState(d=>({selectedElementIds:Ce({[m]:!0},d)}));let p=this.scene.getNonDeletedElementsMap().get(m);p&&!G1([p],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(p,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})}return}}}if(t[X.CTRL_OR_CMD]&&t.key===X.P&&!t.shiftKey&&!t.altKey){this.setToast({message:f("commandPalette.shortcutHint",{shortcut:Se("commandPalette")})}),t.preventDefault();return}if(t[X.CTRL_OR_CMD]&&t.key.toLowerCase()===X.V&&(nb=t.shiftKey,clearTimeout(ok),ok=window.setTimeout(()=>{nb=!1},100)),t[X.CTRL_OR_CMD]&&Ds(t.target)&&(t.code===r5.MINUS||t.code===r5.EQUAL)){t.preventDefault();return}if(Ds(t.target)&&t.key!==X.ESCAPE||np(t.key)&&g5(t.target))return;if(t.key===X.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===X.E&&t.shiftKey&&t[X.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(t.key===X.PAGE_UP||t.key===X.PAGE_DOWN){let l=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;t.key===X.PAGE_DOWN&&(l=-l),t.shiftKey?this.translateCanvas(s=>({scrollX:s.scrollX+l})):this.translateCanvas(s=>({scrollY:s.scrollY+l}))}if(this.state.openDialog?.name==="elementLinkSelector"||(t.key===X.ALT&&(Tn("COMPLEX_BINDINGS")?this.handleSkipBindMode():mp({app:this,event:t})),this.actionManager.handleKeyDown(t)))return;if(!t.altKey&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey&&x5(t,X.Z)){Va=!0,Ee(this.interactiveCanvas,EV),t.preventDefault();return}let n=this.props.viewModeEnabled===!0;if(!n&&this.state.viewModeEnabled&&t.key===X.ESCAPE){this.setActiveTool({type:"selection"});return}if(!n&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let l=gV(t.key,this);if(this.state.viewModeEnabled&&l)return;if(l){this.state.activeTool.type!==l&&ce("toolbar",l,`keyboard (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),l==="arrow"&&this.state.activeTool.type==="arrow"&&this.setState(s=>({currentItemArrowType:s.currentItemArrowType===ur.sharp?ur.round:s.currentItemArrowType===ur.round?ur.elbow:ur.sharp})),l==="lasso"&&this.state.activeTool.type==="laser"?this.setActiveTool({type:this.state.preferredSelectionTool.type}):this.setActiveTool({type:l}),t.stopPropagation();return}else if(t.key===X.Q){this.toggleLock("keyboard"),t.stopPropagation();return}}if(this.state.viewModeEnabled)return;if(t[X.CTRL_OR_CMD]&&!t.repeat&&(Tn("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),$t(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),mp({app:this,event:t})),np(t.key)){let l=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),s=new Set;l.filter(d=>on(d)).filter(d=>{let u=d.startBinding&&!l.some(g=>g.id===d.startBinding?.elementId),b=d.endBinding&&!l.some(g=>g.id===d.endBinding?.elementId);return u||b}).forEach(d=>s.add(d.id)),l=l.filter(d=>!s.has(d.id));let c=this.getEffectiveGridSize()&&(t.shiftKey?c5:this.getEffectiveGridSize())||(t.shiftKey?IW:c5),m=0,p=0;t.key===X.ARROW_LEFT?m=-c:t.key===X.ARROW_RIGHT?m=c:t.key===X.ARROW_UP?p=-c:t.key===X.ARROW_DOWN&&(p=c),l.forEach(d=>{this.scene.mutateElement(d,{x:d.x+m,y:d.y+p},{informMutation:!1,isDragging:!1}),sp(d,this.scene,{simultaneouslyUpdated:l})}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===X.ENTER){let l=this.scene.getSelectedElements(this.state);if(l.length===1){let s=l[0];if(t[X.CTRL_OR_CMD]||j1(s))kt(s)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==s.id)&&(this.store.scheduleCapture(),Ht(s)||this.actionManager.executeAction(pa));else if(jt(s)||N5(s)){let c;jt(s)||(c=s);let m=Y1(s,this.state,this.scene.getNonDeletedElementsMap()),p=m.x,d=m.y;this.startTextEditing({sceneX:p,sceneY:d,container:c}),t.preventDefault();return}else ht(s)&&this.setState({editingFrame:s.id})}}if(t.key===X.SPACE&&ye.pointers.size===0&&(gr=!0,Ee(this.interactiveCanvas,Re.GRAB),t.preventDefault()),(t.key===X.G||t.key===X.S)&&!t.altKey&&!t[X.CTRL_OR_CMD]){let l=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!l.length)return;t.key===X.G&&(Lo(this.state.activeTool.type)||l.some(s=>Lo(s.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===X.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[X.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===X.F){let l=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!l.length)return;(this.state.activeTool.type==="text"||l.find(s=>jt(s)||W1(s,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}let r=t.key.toLocaleLowerCase(),i=r===X.S&&t.shiftKey&&!t[X.CTRL_OR_CMD],a=t.key===X.I||r===X.G&&t.shiftKey;(i||a)&&this.openEyeDropper({type:i?"stroke":"background"})}));S(this,"onKeyUp",Ge(t=>{if(t.key===X.SPACE&&(this.state.viewModeEnabled&&this.state.activeTool.type!=="laser"||this.state.openDialog?.name==="elementLinkSelector"?Ee(this.interactiveCanvas,Re.GRAB):Ns(this.state.activeTool.type)?_t(this.interactiveCanvas):(Dt(this.interactiveCanvas,this.state),this.setState({selectedElementIds:Ce({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),gr=!1),x5(t,X.Z)&&(Va=!1,this.restoreCursorAfterZoomKey()),t.key===X.ALT&&mp({app:this,event:t}),(t.key===X.ALT&&this.state.bindMode==="skip"||!t[X.CTRL_OR_CMD]&&!Bs(this.state))&&(this.setState({bindMode:"orbit"}),this.lastPointerMoveEvent&&Tn("COMPLEX_BINDINGS"))){let n=He({clientX:this.lastPointerMoveEvent.clientX,clientY:this.lastPointerMoveEvent.clientY},this.state),r=tn(oe(n.x,n.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(this.state.selectedLinearElement){let i=he.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());on(i)&&this.handleDelayedBindModeChange(i,r)}}if(!t[X.CTRL_OR_CMD]){let n=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==n&&$t(()=>{this.setState({isBindingEnabled:n})}),mp({app:this,event:t})}if(np(t.key)){w5(this.scene.getSelectedElements(this.state).filter(Wa),this.scene,this.state);let n=this.scene.getNonDeletedElementsMap();this.scene.getSelectedElements(this.state).filter(q1).forEach(r=>{r.startBinding&&this.scene.mutateElement(r,{startBinding:{...r.startBinding,...Q5(r,n.get(r.startBinding.elementId),"start",n)}}),r.endBinding&&this.scene.mutateElement(r,{endBinding:{...r.endBinding,...Q5(r,n.get(r.endBinding.elementId),"end",n)}})}),this.setState({suggestedBinding:null})}if(t.altKey||this.flowChartNavigator.isExploring&&(this.flowChartNavigator.clear(),this.syncActionResult({captureUpdate:Pt.IMMEDIATELY})),!t[X.CTRL_OR_CMD]&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.pendingNodes?.length&&this.insertNewElements(this.flowChartCreator.pendingNodes);let n=this.flowChartCreator.pendingNodes?.[0];n&&(this.setState(r=>({selectedElementIds:Ce({[n.id]:!0},r)})),G1([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:Pt.IMMEDIATELY})}}));S(this,"isToolSupported",t=>this.props.UIOptions.tools?.[t]!==!1);S(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=Qo(this.state,t);r.type==="hand"?Ee(this.interactiveCanvas,Re.GRAB):gr||Dt(this.interactiveCanvas,{...this.state,activeTool:r}),OW(document.activeElement)&&this.focusContainer(),hY(r.type)||this.setState({suggestedBinding:null}),r.type==="image"&&this.onImageToolbarButtonClick(),this.setState(i=>{let a={snapLines:i.snapLines.length?[]:i.snapLines,originSnapOffset:null,activeEmbeddable:null,selectedLinearElement:Ns(r.type)?i.selectedLinearElement:null,frameToHighlight:null};return r.type==="freedraw"&&this.store.scheduleCapture(),r.type==="lasso"?{...i,...a,activeTool:r,...n?{}:{selectedElementIds:Ce({},i),selectedGroupIds:Ce({},i),editingGroupId:null,multiElement:null}}:r.type!=="selection"?{...i,...a,activeTool:r,selectedElementIds:Ce({},i),selectedGroupIds:Ce({},i),editingGroupId:null,multiElement:null}:{...i,...a,activeTool:r}})});S(this,"setOpenDialog",t=>{this.setState({openDialog:t})});S(this,"setCursor",t=>{Ee(this.interactiveCanvas,t)});S(this,"resetCursor",()=>{_t(this.interactiveCanvas)});S(this,"isTouchScreenMultiTouchGesture",()=>ye.pointers.size>=2);S(this,"getName",()=>this.state.name||this.props.name||`${f("labels.untitled")}-${f5()}`);S(this,"onGestureStart",Ge(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:Ce({},this.state),activeEmbeddable:null}),ye.initialScale=this.state.zoom.value}));S(this,"onGestureChange",Ge(t=>{if(t.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let n=ye.initialScale;n&&this.setState(r=>({...Bo({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:Jt(n*t.scale)},r)}))}));S(this,"onGestureEnd",Ge(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:Ce(this.state.previousSelectedElementIds,this.state)}),ye.initialScale=null}));S(this,"isHittingTextAutoResizeHandle",(t,n)=>{let r=tk(t,this.state);return!!(r&&!r.isDeleted&&!r.autoResize&&LI(n,r,this.state.zoom.value,this.editorInterface.formFactor))});S(this,"handleTextAutoResizeHandlePointerDown",(t,n)=>{let r=tk(t,this.state);return!r||!this.isHittingTextAutoResizeHandle(t,n)?!1:(this.actionManager.executeAction(Fg,"ui",r),this.resetCursor(),!0)});S(this,"startTextEditing",({sceneX:t,sceneY:n,insertAtParentCenter:r=!0,container:i,autoEdit:a=!0,initialCaretSceneCoords:l})=>{let s=!1,c=r&&this.getTextWysiwygSnappedToCenterPosition(t,n,this.state,i);i&&c&&(W1(i,this.scene.getNonDeletedElementsMap())||(s=!0));let m=this.getSelectedTextElement(i)||this.getTextElementAtPosition(t,n),p=m?.fontFamily||this.state.currentItemFontFamily,d=m?.lineHeight||u5(p),u=this.state.currentItemFontSize;if(!m&&s&&i&&!Wa(i)){let w=UY(D1({fontSize:u,fontFamily:p}),d),I=WY(u,d),C=Math.max(i.height,I),A=Math.max(i.width,w);this.scene.mutateElement(i,{height:C,width:A}),t=i.x+A/2,n=i.y+C/2,c&&(c=this.getTextWysiwygSnappedToCenterPosition(t,n,this.state,i))}let b=this.getTextCreationGridPoint(t,n),g=c?{x:c.elementCenterX,y:c.elementCenterY}:m?{x:t,y:n}:{x:b?.x??t,y:b===null?n-U5(u,d)/2:b.y},E=this.getTopLayerFrameAtSceneCoords({x:g.x,y:g.y}),y=E&&(!s||!i||i.frameId===E.id)?E.id:null,v=m||T5({x:g.x,y:g.y,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:p,textAlign:c?"center":this.state.currentItemTextAlign,verticalAlign:c?AW.MIDDLE:l5,containerId:s?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:d,angle:i?Wa(i)?0:i.angle:0,frameId:y});if(!m&&s&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:v.id})}),this.setState({editingTextElement:v}),!m)if(i&&s){let x=this.scene.getElementIndex(i.id);this.scene.insertElementsAtIndex([v],x+1)}else this.insertNewElement(v);a||m||i?this.handleTextWysiwyg(v,{isExistingElement:!!m,initialCaretSceneCoords:m?l:null}):this.setState({newElement:v,multiElement:null})});S(this,"startImageCropping",t=>{this.store.scheduleCapture(),this.setState({croppingElementId:t.id})});S(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});S(this,"shouldHandleBrowserCanvasDoubleClick",t=>{if(t==="touch"||this.lastCompletedCanvasClicks.length===0)return!0;if(this.lastCompletedCanvasClicks.length<2)return!1;let[n,r]=this.lastCompletedCanvasClicks;return In(oe(n.x,n.y),oe(r.x,r.y))<=E5});S(this,"handleCanvasDoubleClick",t=>{if(this.state.editingTextElement||!this.shouldHandleBrowserCanvasDoubleClick(t.type)||this.state.multiElement||this.state.activeTool.type!==this.state.preferredSelectionTool.type)return;let n=this.scene.getSelectedElements(this.state),{x:r,y:i}=He(t,this.state);if(n.length===1&&kt(n[0])){let l=n[0];if((t[X.CTRL_OR_CMD]&&q1(l)||j1(l))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)){this.actionManager.executeAction(pa);return}else if(this.state.selectedLinearElement&&Ht(n[0])){let s=he.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),c=s?he.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,s,this.scene.getNonDeletedElementsMap()):-1;if(c&&c>-1){this.store.scheduleCapture(),he.deleteFixedSegment(n[0],this.scene,c);let m=he.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),p=m?he.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,m,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,segmentMidpoint:{index:p,value:s,added:!1}},segmentMidPointHoveredCoords:m}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===l.id&&j1(l))return}if(n.length===1&&Qr(n[0])){this.startImageCropping(n[0]);return}if(_t(this.interactiveCanvas),ZY(this.state).length>0){let l=this.getElementAtPosition(r,i),s=l&&KY(l,this.state.selectedGroupIds);if(s){this.store.scheduleCapture(),this.setState(c=>({...c,...ho({editingGroupId:s,selectedElementIds:{[l.id]:!0}},this.scene.getNonDeletedElements(),c,this)}));return}}if(_t(this.interactiveCanvas),!t[X.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let l=this.getElementAtPosition(r,i);if(z1(l)){this.setState({activeEmbeddable:{element:l,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){let s=this.getTextBindableContainerAtPosition(r,i);if(s&&(C5(s)||!HW(s.backgroundColor)||Os({point:oe(r,i),element:s,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(s)}))){let c=Y1(s,this.state,this.scene.getNonDeletedElementsMap());r=c.x,i=c.y}this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:s})}}});S(this,"handleCanvasClick",t=>{if(t.button!==qo.MAIN){this.lastCompletedCanvasClicks=[];return}this.lastCompletedCanvasClicks=[...this.lastCompletedCanvasClicks.slice(-1),{x:t.clientX,y:t.clientY}]});S(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&&qs(l,this.scene.getNonDeletedElementsMap(),this.state,oe(t.x,t.y),this.editorInterface.formFactor==="phone"))return l}});S(this,"handleElementLinkClick",t=>{let n=In(oe(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),oe(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||n>s5)return;let r=He(this.lastPointerDownEvent,this.state),i=this.scene.getNonDeletedElementsMap(),a=qs(this.hitLinkElement,i,this.state,oe(r.x,r.y),this.editorInterface.formFactor==="phone"),l=He(this.lastPointerUpEvent,this.state),s=qs(this.hitLinkElement,i,this.state,oe(l.x,l.y),this.editorInterface.formFactor==="phone");if(a&&s){Th();let c=this.hitLinkElement.link;if(c){c=_1(c);let m;if(this.props.onLinkOpen&&(m=zW(Q.EXCALIDRAW_LINK,t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:c},m)),!m?.defaultPrevented){let p=NW(c)?"_self":"_blank",d=window.open(void 0,p);d&&(d.opener=null,d.location=c)}}}});S(this,"getTopLayerFrameAtSceneCoords",(t,n)=>{let r=this.scene.getNonDeletedElementsMap(),i=this.scene.getNonDeletedFramesLikes().filter(s=>!s.locked&&F5(t,s,r));if(!i.length)return null;let a=i.at(-1),l=this.getElementsAtPosition(t.x,t.y,{includeLockedElements:!0}).findLast(s=>!n?.excludeElementIds?.[s.id]);if(l){if(ht(l)&&!l.locked)return a;let s=this.scene.getElementIndex(l.id),c=this.scene.getElementIndex(a.id);if(s!==-1&&c!==-1&&s<=c)return a;let m=n?.currentFrameId?i.find(p=>p.id===n.currentFrameId)??null:null;return m||(l.frameId?i.find(p=>p.id===l.frameId)??null:null)}return a});S(this,"updateFrameToHighlight",t=>{this.state.frameToHighlight!==t&&this.setState({frameToHighlight:t})});S(this,"maybeUpdateFrameToHighlightOnPointerMove",(t,n)=>{this.state.newElement||this.state.multiElement||this.state.selectionElement||this.state.selectedElementsAreBeingDragged||this.updateFrameToHighlight(!n&&hV(this.state.activeTool.type)?this.getTopLayerFrameAtSceneCoords(t):null)});S(this,"insertNewElements",t=>{if(!t.length)return;let n=[];for(let r of t){let i=n[n.length-1];i?.[0].frameId===r.frameId?i.push(r):n.push([r])}for(let r of n){let i=r[0].frameId,a=i?TY(this.scene.getElementsIncludingDeleted(),i):null;this.scene.insertElementsAtIndex(r,a)}});S(this,"insertNewElement",t=>{this.insertNewElements([t]);let n=t.frameId?this.scene.getNonDeletedElement(t.frameId):null;this.updateFrameToHighlight(n&&ht(n)?n:null)});S(this,"handleCanvasPointerMove",t=>{this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent;let n=He(t,this.state),{x:r,y:i}=n;this.lastPointerMoveCoords={x:r,y:i},ye.pointers.has(t.pointerId)&&ye.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let a=ye.initialScale;if(ye.pointers.size===2&&ye.lastCenter&&a&&ye.initialDistance){let g=zg(ye.pointers),E=g.x-ye.lastCenter.x,y=g.y-ye.lastCenter.y;ye.lastCenter=g;let v=Hg(Array.from(ye.pointers.values())),x=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:v/ye.initialDistance,w=x?Jt(a*x):this.state.zoom.value;this.setState(I=>{let C=Bo({viewportX:g.x,viewportY:g.y,nextZoom:w},I);return this.translateCanvas({zoom:C.zoom,scrollX:C.scrollX+2*(E/w),scrollY:C.scrollY+2*(y/w),shouldCacheIgnoreZoom:!0}),null}),this.resetShouldCacheIgnoreZoomDebounced()}else ye.lastCenter=ye.initialDistance=ye.initialScale=null;if(gr||Va||Us||Ws||tb||bo(this.state))return;let s=Jg(Ys,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;if(!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(s?_t(this.interactiveCanvas):Dt(this.interactiveCanvas,this.state)),this.maybeUpdateFrameToHighlightOnPointerMove({x:r,y:i},s),!this.state.newElement&&CI(this.state.activeTool.type)){let{originOffset:g,snapLines:E}=SI(this.scene.getNonDeletedElements(),this,{x:r,y:i},t,this.scene.getNonDeletedElementsMap());this.setState(y=>{let v=Rs(y.snapLines,E),x=y.originSnapOffset?Rs(y.originSnapOffset,g):g;return y.snapLines===v&&y.originSnapOffset===x?null:{snapLines:v,originSnapOffset:x}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(g=>g.snapLines.length?{snapLines:[]}:null);if(this.state.selectedLinearElement?.isEditing&&!this.state.selectedLinearElement.isDragging){let g=this.state.newElement?null:he.handlePointerMoveInEditMode(t,r,i,this);g&&g!==this.state.selectedLinearElement&&$t(()=>{this.setState({selectedLinearElement:g})})}if(uY(this.state.activeTool.type)){let{newElement:g}=this.state;if(!g&&Bs(this.state)){let E=oe(r,i),y=this.scene.getNonDeletedElementsMap(),v=tn(E,this.scene.getNonDeletedElements(),y,J1(this.state.zoom));v?this.setState({suggestedBinding:{element:v,midPoint:Q1(E,v,y,this.state.zoom)}}):this.state.suggestedBinding&&this.setState({suggestedBinding:null})}}if(this.state.multiElement&&this.state.selectedLinearElement){let{multiElement:g,selectedLinearElement:E}=this.state,{x:y,y:v,points:x}=g,w=x[x.length-1],{lastCommittedPoint:I}=E;if(Dt(this.interactiveCanvas,this.state),w===I)Wa(this.state.newElement)&&Bs(this.state)&&tn(oe(r,i),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),J1(this.state.zoom))?(this.actionManager.executeAction(It,"ui",{event:t.nativeEvent,sceneCoords:{x:r,y:i}}),this.setState({suggestedBinding:null}),this.state.activeTool.locked||(_t(this.interactiveCanvas),this.setState(A=>({newElement:null,activeTool:Qo(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:Ce({...A.selectedElementIds,[g.id]:!0},A),selectedLinearElement:new he(g,this.scene.getNonDeletedElementsMap())})))):In(oe(r-y,i-v),w)>=L1?(this.scene.mutateElement(g,{points:[...x,oe(r-y,i-v)]},{informMutation:!1,isDragging:!1}),en(this.state.selectedLinearElement?.initialState,"initialState must be set"),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:x[x.length-1],selectedPointsIndices:[g.points.length-1],initialState:{...this.state.selectedLinearElement.initialState,lastClickedPoint:g.points.length-1}}})):Ee(this.interactiveCanvas,Re.POINTER);else if(x.length>2&&I&&In(oe(r-y,i-v),I)<L1){Ee(this.interactiveCanvas,Re.POINTER),this.scene.mutateElement(g,{points:x.slice(0,-1)},{informMutation:!1,isDragging:!1});let C=g.points.length-1;this.setState({selectedLinearElement:{...E,selectedPointsIndices:E.selectedPointsIndices?[...new Set(E.selectedPointsIndices.map(A=>Math.min(A,C)))]:E.selectedPointsIndices,lastCommittedPoint:g.points[C],initialState:{...E.initialState,lastClickedPoint:C}}})}else{L5(x,this.state.zoom.value)&&Ee(this.interactiveCanvas,Re.POINTER);let C=this.scene.getNonDeletedElementsMap();if(q1(g)){let k=tn(oe(r,i),this.scene.getNonDeletedElements(),C);Tn("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(g,k)}en(this.state.selectedLinearElement,"Expected selectedLinearElement to be set to operate on a linear element");let A=he.handlePointerMove(t.nativeEvent,this,r,i,this.state.selectedLinearElement);A&&this.setState(A)}return}if(this.state.activeTool.type==="arrow"){let g=tn(oe(r,i),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),J1(this.state.zoom)),E=oe(r,i),y=this.scene.getNonDeletedElementsMap();g&&!lV(E,g,y)&&this.setState({suggestedBinding:{element:g,midPoint:Q1(E,g,y,this.state.zoom)}})}let c=!!t.buttons,m=this.state.activeTool.type==="laser";if(c||!m&&this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let p=this.scene.getNonDeletedElements(),d=this.scene.getSelectedElements(this.state);if(this.isHittingTextAutoResizeHandle(d,n)){Ee(this.interactiveCanvas,Re.POINTER);return}if(d.length===1&&!s&&!this.state.selectedLinearElement?.isEditing){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&this.state.openDialog?.name!=="elementLinkSelector"&&!(d.length===1&&Ht(d[0]))&&!(kt(d[0])&&(this.editorInterface.userAgent.isMobileDevice||d[0].points.length===2))){let g=X5(p,this.state,r,i,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);if(g&&g.transformHandleType){Ee(this.interactiveCanvas,V5(g));return}}}else if(d.length>1&&!s&&this.state.openDialog?.name!=="elementLinkSelector"){let g=K5(Ua(d),r,i,this.state.zoom,t.pointerType,this.editorInterface);if(g){Ee(this.interactiveCanvas,V5({transformHandleType:g}));return}}if(Mt(this.state))return;let u=this.getElementAtPosition(r,i,{preferSelected:!0,includeLockedElements:!0}),b=null;if(u&&u.locked?b=null:b=u,this.handleIframeLikeElementHover({hitElement:b,scenePointer:n,moveEvent:t})||(this.hitLinkElement=this.getElementLinkAtPosition(n,u)),this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id])Ee(this.interactiveCanvas,Re.POINTER),Sw(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap());else{if(Th(),m)return;b&&(b.link||Sn(b))&&this.state.selectedElementIds[b.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?Ee(this.interactiveCanvas,jt(b)?Re.TEXT:Re.CROSSHAIR):!t[X.CTRL_OR_CMD]&&this.isHittingCommonBoundingBoxOfSelectedElements(n,d)?Ee(this.interactiveCanvas,Re.MOVE):this.state.viewModeEnabled?Ee(this.interactiveCanvas,Re.GRAB):this.state.openDialog?.name==="elementLinkSelector"?Ee(this.interactiveCanvas,Re.AUTO):s?Ee(this.interactiveCanvas,Re.AUTO):!t[X.CTRL_OR_CMD]&&b?.id!==this.state.editingTextElement?.id?(b||this.isHittingCommonBoundingBoxOfSelectedElements(n,d))&&!b?.locked&&(!b||!Ht(b)||!(b.startBinding||b.endBinding))&&(this.state.activeTool.type!=="lasso"||d.length>0)&&Ee(this.interactiveCanvas,Re.MOVE):Ee(this.interactiveCanvas,Re.AUTO),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i)}this.state.openDialog?.name==="elementLinkSelector"&&b?this.setState(g=>({hoveredElementIds:Rs(g.hoveredElementIds,ho({editingGroupId:g.editingGroupId,selectedElementIds:{[b.id]:!0}},this.scene.getNonDeletedElements(),g,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!b&&this.setState(g=>({hoveredElementIds:Rs(g.hoveredElementIds,{})}))});S(this,"handleEraser",(t,n)=>{let r=this.eraserTrail.addPointToPath(n.x,n.y,t.altKey);this.elementsPendingErasure=new Set(r),this.triggerRender()});S(this,"handleTouchMove",t=>{Vs=!0});S(this,"handleCanvasPointerDown",t=>{let n=this.scene.getSelectedElements(this.state);if(!t.ctrlKey){let g=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==g&&this.setState({isBindingEnabled:g})}let r=He(t,this.state),{x:i,y:a}=r;this.lastPointerMoveCoords={x:i,y:a};let l=t.target;if(l.setPointerCapture&&l.setPointerCapture(t.pointerId),this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.searchMatches&&(this.setState(g=>({searchMatches:g.searchMatches&&{focusedId:null,matches:g.searchMatches.matches.map(E=>({...E,focus:!1}))}})),this.updateEditorAtom(Gf,null)),ot.get(wo)&&this.updateEditorAtom(wo,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.state.openPopup&&this.setState({openPopup:null}),this.updateGestureOnPointerDown(t),t.pointerType==="touch"&&this.state.newElement&&this.state.newElement.type==="freedraw"){let g=this.state.newElement;this.updateScene({...g.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==g.id)}:{},appState:{newElement:null,editingTextElement:null,suggestedBinding:null,selectedElementIds:Ce(Object.keys(this.state.selectedElementIds).filter(E=>E!==g.id).reduce((E,y)=>(E[y]=this.state.selectedElementIds[y],E),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?Pt.EVENTUALLY:Pt.NEVER});return}let s=document.getSelection();if(s?.anchorNode&&s.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(g=>({penMode:!0,penDetected:!0})),!this.editorInterface.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.editorInterface=N1(this.editorInterface,{isTouchScreen:!0})),Us||Ws||(this.lastPointerDownEvent=t,this.handleCanvasZoomUsingZDrag(t)||this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===qo.ERASER&&this.state.activeTool.type!==Jo.eraser){this.setState({activeTool:Qo(this.state,{type:Jo.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let g=()=>{E(),y?.(),Mt(this.state)&&this.setState({activeTool:Qo(this.state,{...this.state.activeTool.lastActiveTool||{type:Jo.selection},lastActiveToolBeforeEraser:null})})},E=Xe(window,Q.POINTER_UP,g,{once:!0}),y;requestAnimationFrame(()=>{y=this.missingPointerEventCleanupEmitter.once(g)})});return}if(t.button!==qo.MAIN&&t.button!==qo.TOUCH&&t.button!==qo.ERASER||ye.pointers.size>1)return;let c=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleTextAutoResizeHandlePointerDown(n,c.origin)||this.handleDraggingScrollBar(t,c)||(this.clearSelectionIfNotUsingSelection(),this.handleSelectionOnPointerDown(t,c))||!(!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 g=c.hit.element&&this.isASelectedElement(c.hit.element);(t.altKey&&t[X.CTRL_OR_CMD]&&!c.resize.handleType||!c.hit.hasHitCommonBoundingBoxOfSelectedElements&&!c.resize.handleType&&!g)&&(this.lassoTrail.hasCurrentTrail||this.lassoTrail.startPath(c.origin.x,c.origin.y,t.shiftKey),c.drag.blockDragging=this.editorInterface.formFactor==="desktop"),this.editorInterface.formFactor!=="desktop"&&c.hit.element&&!g&&(this.setState(v=>{let x={...v.selectedElementIds,[c.hit.element.id]:!0},w=[];Object.keys(v.selectedElementIds).forEach(C=>{let A=this.scene.getElement(C);A&&w.push(A)});let I=c.hit.element;if(ht(I))V1(w,I.id).forEach(C=>{delete x[C.id]});else if(I.frameId)x[I.frameId]&&delete x[I.id];else{let C=I.groupIds,A=new Set(C.flatMap(k=>ei(this.scene.getNonDeletedElements(),k)).filter(k=>ht(k)).map(k=>k.id));A.size>0&&w.forEach(k=>{k.frameId&&A.has(k.frameId)&&(delete x[k.id],k.groupIds.flatMap(L=>ei(this.scene.getNonDeletedElements(),L)).forEach(L=>{delete x[L.id]}))})}return{...ho({editingGroupId:v.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),v,this),showHyperlinkPopup:I.link||Sn(I)?"info":!1}}),c.hit.wasAddedToSelection=!0)}else this.state.activeTool.type==="text"?this.handleTextOnPointerDown(t,c):this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line"?this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,c):this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,c):this.state.activeTool.type==="custom"?Dt(this.interactiveCanvas,this.state):this.state.activeTool.type===Jo.frame||this.state.activeTool.type===Jo.magicframe?this.createFrameElementOnPointerDown(c,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(c.lastCoords.x,c.lastCoords.y):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.state.activeTool.type!=="image"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,c);this.props?.onPointerDown?.(this.state.activeTool,c),this.onPointerDownEmitter.trigger(this.state.activeTool,c,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(c.lastCoords.x,c.lastCoords.y);let p=this.onPointerMoveFromPointerDownHandler(c),d=this.onPointerUpFromPointerDownHandler(c),u=this.onKeyDownFromPointerDownHandler(c),b=this.onKeyUpFromPointerDownHandler(c);this.missingPointerEventCleanupEmitter.once(g=>d(g||t.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener(Q.POINTER_MOVE,p),window.addEventListener(Q.POINTER_UP,d),window.addEventListener(Q.KEYDOWN,u),window.addEventListener(Q.KEYUP,b),c.eventListeners.onMove=p,c.eventListeners.onUp=d,c.eventListeners.onKeyUp=b,c.eventListeners.onKeyDown=u)});S(this,"handleCanvasPointerUp",t=>{if(Tn("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.removePointer(t),this.lastPointerUpIsDoubleClick=this.isDoubleClick(this.lastPointerUpEvent,t),this.lastPointerUpEvent=t,!t.ctrlKey){let a=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==a&&this.setState({isBindingEnabled:a})}let n=He({clientX:t.clientX,clientY:t.clientY},this.state),{x:r,y:i}=n;if(this.lastPointerMoveCoords={x:r,y:i},!this.handleIframeLikeCenterClick()){if(this.editorInterface.isTouchScreen){let a=this.getElementAtPosition(n.x,n.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(n,a)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?this.handleElementLinkClick(t):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})}});S(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(Vs=!1,fr?Vs=!0:fr=window.setTimeout(()=>{fr=0,Vs||this.handleCanvasContextMenu(t)},MW))});S(this,"resetContextMenuTimer",()=>{clearTimeout(fr),fr=0,Vs=!1});S(this,"maybeCleanupAfterMissingPointerUp",t=>{ti?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});S(this,"handleCanvasZoomUsingZDrag",t=>{if(!(Va&&ye.pointers.size<=1&&t.button===qo.MAIN&&t.pointerType==="mouse"))return!1;Ws=!0,this.focusContainer(),t.preventDefault();let n=t.clientX,r=t.clientY,i=t.clientX,a=this.state.zoom.value,l=200,s=ds(m=>{let p=Jt(a*2**((m.clientX-i)/l));this.translateCanvas(d=>({...Bo({viewportX:n,viewportY:r,nextZoom:p},d),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced()}),c=Ge(ti=()=>{ti=null,Ws=!1,Va||this.restoreCursorAfterZoomKey(),window.removeEventListener(Q.POINTER_MOVE,s),window.removeEventListener(Q.POINTER_UP,c),window.removeEventListener(Q.BLUR,c),s.flush()});return window.addEventListener(Q.BLUR,c),window.addEventListener(Q.POINTER_MOVE,s,{passive:!0}),window.addEventListener(Q.POINTER_UP,c),!0});S(this,"restoreCursorAfterZoomKey",()=>{this.state.viewModeEnabled&&this.state.activeTool.type!=="laser"?Ee(this.interactiveCanvas,Re.GRAB):Ns(this.state.activeTool.type)?_t(this.interactiveCanvas):Dt(this.interactiveCanvas,this.state)});S(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(ye.pointers.size<=1&&(t.button===qo.WHEEL||t.button===qo.MAIN&&gr||bo(this.state)||this.state.viewModeEnabled&&this.state.activeTool.type!=="laser")))return!1;Us=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let n=!1,r=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);Ee(this.interactiveCanvas,Re.GRABBING);let{clientX:i,clientY:a}=t,l=ds(c=>{let m=i-c.clientX,p=a-c.clientY;if(i=c.clientX,a=c.clientY,r&&!n&&(Math.abs(m)>1||Math.abs(p)>1)){n=!0;let d=b=>{document.body.removeEventListener(Q.PASTE,d),b.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener(Q.PASTE,d),window.removeEventListener(Q.POINTER_UP,u)},100)};document.body.addEventListener(Q.PASTE,d),window.addEventListener(Q.POINTER_UP,u)}this.translateCanvas({scrollX:this.state.scrollX-m/this.state.zoom.value,scrollY:this.state.scrollY-p/this.state.zoom.value})}),s=Ge(ti=()=>{ti=null,Us=!1,gr||(this.state.viewModeEnabled&&this.state.activeTool.type!=="laser"?Ee(this.interactiveCanvas,Re.GRAB):Dt(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(Q.POINTER_MOVE,l),window.removeEventListener(Q.POINTER_UP,s),window.removeEventListener(Q.BLUR,s),l.flush()});return window.addEventListener(Q.BLUR,s),window.addEventListener(Q.POINTER_MOVE,l,{passive:!0}),window.addEventListener(Q.POINTER_UP,s),!0});S(this,"clearSelectionIfNotUsingSelection",()=>{Ns(this.state.activeTool.type)||this.setState({selectedElementIds:Ce({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});S(this,"handleSelectionOnPointerDown",(t,n)=>{if(Ns(this.state.activeTool.type)){let r=this.scene.getNonDeletedElements(),i=this.scene.getNonDeletedElementsMap(),a=this.scene.getSelectedElements(this.state);if(a.length===1&&!this.state.selectedLinearElement?.isEditing&&!Ht(a[0])&&!(kt(a[0])&&(this.editorInterface.userAgent.isMobileDevice||a[0].points.length===2))&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let l=X5(r,this.state,n.origin.x,n.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);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=K5(Ua(a),n.origin.x,n.origin.y,this.state.zoom,t.pointerType,this.editorInterface));if(n.resize.handleType)n.resize.isResizing=!0,n.resize.offset=R1(JY(n.resize.handleType,a,i,n.origin.x,n.origin.y)),a.length===1&&kt(a[0])&&a[0].points.length===2&&(n.resize.arrowDirection=QY(n.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let d=this.state.selectedLinearElement,u=he.handlePointerDown(t,this,this.store,n.origin,d,this.scene);if(u.hitElement&&(n.hit.element=u.hitElement),u.linearElementEditor&&this.setState({selectedLinearElement:u.linearElementEditor}),u.didAddPoint)return!0;let b=this.scene.getNonDeletedElementsMap(),g=he.getElement(d.elementId,b);if(g&&on(g)){let{hitFocusPoint:E,pointerOffset:y}=mV(g,n,b,this.state);if(E)return this.setState({selectedLinearElement:{...d,hoveredFocusPointBinding:E,draggedFocusPointBinding:E,pointerOffset:y}}),!1}}let l=this.getElementsAtPosition(n.origin.x,n.origin.y,{includeLockedElements:!0}),s=l.filter(d=>!d.locked),c=this.getElementAtPosition(n.origin.x,n.origin.y,{allHitElements:l});if((!c||c.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),c&&c.locked&&!s.some(d=>this.state.selectedElementIds[d.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,c),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 m=n.hit.element,p=n.hit.allHitElements.some(d=>this.isASelectedElement(d));if((m===null||!p)&&!t.shiftKey&&!n.hit.hasHitCommonBoundingBoxOfSelectedElements&&(!this.state.selectedLinearElement?.isEditing||m&&m?.id!==this.state.selectedLinearElement?.elementId)&&this.clearSelection(m),this.state.selectedLinearElement?.isEditing)this.setState(d=>({selectedLinearElement:d.selectedLinearElement?{...d.selectedLinearElement,isEditing:!!m&&m.id===this.state.selectedLinearElement?.elementId}:null,selectedElementIds:d.selectedLinearElement?Ce({[d.selectedLinearElement.elementId]:!0},this.state):Ce({},d)}));else if(m!=null){if(t[X.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[m.id]||(n.hit.wasAddedToSelection=!0),this.setState(d=>({...XY(d,m),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[m.id]||(this.state.editingGroupId&&!W5(m,this.state.editingGroupId)&&this.setState({selectedElementIds:Ce({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!p&&!n.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(d=>{let u={...d.selectedElementIds,[m.id]:!0},b=[];if(Object.keys(d.selectedElementIds).forEach(g=>{let E=this.scene.getElement(g);E&&b.push(E)}),ht(m))V1(b,m.id).forEach(g=>{delete u[g.id]});else if(m.frameId)u[m.frameId]&&delete u[m.id];else{let g=m.groupIds,E=new Set(g.flatMap(y=>ei(this.scene.getNonDeletedElements(),y)).filter(y=>ht(y)).map(y=>y.id));E.size>0&&b.forEach(y=>{y.frameId&&E.has(y.frameId)&&(delete u[y.id],y.groupIds.flatMap(v=>ei(this.scene.getNonDeletedElements(),v)).forEach(v=>{delete u[v.id]}))})}return d.openDialog?.name==="elementLinkSelector"&&(m.groupIds.some(g=>d.selectedGroupIds[g])||(u={[m.id]:!0})),{...ho({editingGroupId:d.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),d,this),showHyperlinkPopup:m.link||Sn(m)?"info":!1}}),n.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});S(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);C5(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,initialCaretSceneCoords:{x:r,y:i}}),_t(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:Qo(this.state,{type:this.state.preferredSelectionTool.type})})});S(this,"handleFreeDrawElementOnPointerDown",(t,n,r)=>{let[i,a]=xt(r.origin.x,r.origin.y,null),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),s=t.pressure===.5,c=aY({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:[oe(0,0)],pressures:s?[]:[t.pressure]});this.insertNewElement(c),this.setState(m=>{let p={...m.selectedElementIds};return delete p[c.id],{selectedElementIds:Ce(p,m)}}),this.setState({newElement:c,suggestedBinding:null})});S(this,"insertIframeElement",({sceneX:t,sceneY:n,width:r,height:i})=>{let[a,l]=xt(t,n,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=lY({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.insertNewElement(s),s});S(this,"insertEmbeddableElement",({sceneX:t,sceneY:n,link:r})=>{let[i,a]=xt(t,n,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=cp(r);if(!l)return;l.error instanceof URIError&&this.setToast({message:f("toast.unrecognizedLinkFormat"),closable:!0});let s=v5({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.insertNewElement(s),s});S(this,"newImagePlaceholder",({sceneX:t,sceneY:n,addToFrameUnderCursor:r=!0})=>{let[i,a]=xt(t,n,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=r?this.getTopLayerFrameAtSceneCoords({x:i,y:a}):null,s=100/this.state.zoom.value;return dY({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})});S(this,"handleLinearElementOnPointerDown",(t,n,r)=>{if(t.ctrlKey&&$t(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.state.multiElement){let{multiElement:i,selectedLinearElement:a}=this.state;if(en(a,"selectedLinearElement is expected to be set"),i.type==="line"&&L5(i.points,this.state.zoom.value)){$t(()=>{this.setState({selectedLinearElement:{...a,lastCommittedPoint:i.points[i.points.length-1],initialState:{...a.initialState,lastClickedPoint:-1}}})}),this.actionManager.executeAction(It);return}if(Ht(i)&&i.points.length>1){this.actionManager.executeAction(It,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}let{x:l,y:s}=i,{lastCommittedPoint:c}=a,m=Bs(this.state)&&tn(oe(this.lastPointerMoveCoords?.x??l+i.points[i.points.length-1][0],this.lastPointerMoveCoords?.y??s+i.points[i.points.length-1][1]),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(on(i)&&m||i.points.length>1&&c&&In(oe(r.origin.x-l,r.origin.y-s),c)<L1){this.actionManager.executeAction(It,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}this.setState(p=>({selectedElementIds:Ce({...p.selectedElementIds,[i.id]:!0},p)})),Ee(this.interactiveCanvas,Re.POINTER)}else{let[i,a]=xt(r.origin.x,r.origin.y,t[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:s,currentItemEndArrowhead:c}=this.state,[m,p]=n==="arrow"?[s,c]:[null,null],d=n==="arrow"?sY({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===ur.round?{type:rp.PROPORTIONAL_RADIUS}:null,startArrowhead:m,endArrowhead:p,locked:!1,frameId:l?l.id:null,elbowed:this.state.currentItemArrowType===ur.elbow,fixedSegments:this.state.currentItemArrowType===ur.elbow?[]:null}):mY({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:rp.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:l?l.id:null}),u=oe(r.origin.x,r.origin.y),b=this.scene.getNonDeletedElementsMap(),g=Bs(this.state)?tn(u,this.scene.getNonDeletedElements(),b):null;this.scene.mutateElement(d,{points:[oe(0,0),oe(0,0)]}),this.insertNewElement(d),on(d)&&iV(d,new Map([[0,{point:oe(0,0),isDragging:!1}]]),u[0],u[1],this.scene,this.state,{newArrow:!0,altKey:t.altKey,initialBinding:!0,angleLocked:a5(t.nativeEvent)}),$t(()=>{this.setState(E=>{let y=null,v=E.selectedElementIds;if(kt(d)){y=new he(d,this.scene.getNonDeletedElementsMap());let x=d.points.length-1;y={...y,selectedPointsIndices:[x],initialState:{...y.initialState,arrowStartIsInside:t.altKey,lastClickedPoint:x,origin:oe(r.origin.x,r.origin.y)}}}return v=this.state.activeTool.locked?E.selectedElementIds:Ce({[d.id]:!0},E),{...E,bindMode:"orbit",newElement:d,startBoundElement:g,suggestedBinding:g&&on(d)?{element:g,midPoint:Q1(u,g,b,this.state.zoom)}:null,selectedElementIds:v,selectedLinearElement:y}})}),on(d)&&Tn("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(d,g)}});S(this,"createGenericElementOnPointerDown",(t,n)=>{let[r,i]=xt(n.origin.x,n.origin.y,this.lastPointerDownEvent?.[X.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=v5({type:"embeddable",...l}):s=cY({type:t,...l}),s.type==="selection"?this.setState({selectionElement:s}):(this.insertNewElement(s),this.setState({multiElement:null,newElement:s}))});S(this,"createFrameElementOnPointerDown",(t,n)=>{let[r,i]=xt(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:r,y:i,opacity:this.state.currentItemOpacity,locked:!1,...$o},l=n===Jo.magicframe?I5(a):iY(a);this.insertNewElement(l),this.setState({multiElement:null,newElement:l})});S(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});S(this,"eraseElements",()=>{let t=!1;this.elementsPendingErasure.forEach(r=>{let i=this.scene.getElement(r);if(on(i)){if(i.startBinding){let a=this.scene.getElement(i.startBinding.elementId);dp(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(l=>l.id!==i.id)})}if(i.endBinding){let a=this.scene.getElement(i.endBinding.elementId);dp(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(l=>l.id!==i.id)})}}else H1(i)&&i.boundElements?.forEach(a=>{if(a.type==="arrow"){let l=this.scene.getElement(a.id);l?.startBinding?.elementId===i.id&&dp(l,this.scene.getElementsMapIncludingDeleted(),{startBinding:null}),l?.endBinding?.elementId===i.id&&dp(l,this.scene.getElementsMapIncludingDeleted(),{endBinding:null})}})});let n=this.scene.getElementsIncludingDeleted().map(r=>this.elementsPendingErasure.has(r.id)||r.frameId&&this.elementsPendingErasure.has(r.frameId)||O1(r)&&this.elementsPendingErasure.has(r.containerId)?(t=!0,hr(r,{isDeleted:!0})):r);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(n))});S(this,"initializeImage",async(t,n)=>{if(!Tp(n))throw new Error(f("errors.unsupportedFileType"));let r=n.type,i=n.size>=this.state.dontResizeLimitMBs*1024*1024;if(Ee(this.interactiveCanvas,"wait"),r===jo.svg)try{n=Pp(D5(await n.text()),n.name)}catch(s){throw console.warn(s),new Error(f("errors.svgImageInsertError"))}else if(i)try{n=await this.props.compressImageFile(n,{maxWidthOrHeight:vW}),console.info("Excalidraw: image resized")}catch(s){console.error("Error trying to resizing image file on insertion",s)}if(n.size>d5)throw new Error(f("errors.fileTooBig",{maxSize:`${Math.trunc(d5/1024/1024)}MB`}));let a=await(this.props.generateIdForFile?.(n)||Gb(n));if(console.info("Excalidraw File ID:",a),!a)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(f("errors.imageInsertError"));let l=this.files[a]?.dataURL||await kp(n);return new Promise(async(s,c)=>{try{let m=this.getLatestInitializedImageElement(t,a);if(this.addMissingFiles([{mimeType:r,id:a,dataURL:l,created:Date.now(),lastRetrieved:Date.now()}]),!this.imageCache.get(a)){this.addNewImagesToImageCache();let{erroredFiles:d}=await this.updateImageCache([m]);if(d.size)throw new Error("Image cache update resulted with an error.")}let p=await this.imageCache.get(a)?.image;if(p&&this.state.newElement?.id!==m.id){m=this.getLatestInitializedImageElement(t,a);let d=this.getImageNaturalDimensions(m,p);Object.assign(m,d)}s(m)}catch(m){console.error(m),c(new Error(f("errors.imageInsertError")))}})});S(this,"getLatestInitializedImageElement",(t,n)=>{let r=this.scene.getElement(t.id)??t;return hr(r,{fileId:n})});S(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 $s({description:"Image",extensions:Object.keys(TW),multiple:!0});this.insertImages(a,r,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:Qo(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction(It)})}});S(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,c=t.y+t.height/2-a/2;return{x:s,y:c,width:l,height:a,crop:null}});S(this,"updateImageCache",async(t,n=this.files)=>{let{updatedFiles:r,erroredFiles:i}=await wY({imageCache:this.imageCache,fileIds:t.map(a=>a.fileId),files:n});return i.size&&(this.store.scheduleAction(Pt.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(a=>Fs(a)&&i.has(a.fileId)?hr(a,{status:"error"}):a))),{updatedFiles:r,erroredFiles:i}});S(this,"addNewImagesToImageCache",async(t=yY(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)&&zs.delete(a);i.size&&this.scene.triggerUpdate()}});S(this,"scheduleImageRefresh",fW(()=>{this.addNewImagesToImageCache()},SW));S(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.interactiveCanvas.addEventListener(Q.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(Q.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener(Q.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(Q.TOUCH_END,this.onTouchEnd))});S(this,"insertImages",async(t,n,r)=>{let i=50/this.state.zoom.value,a=J5(t.map(()=>this.newImagePlaceholder({sceneX:n,sceneY:r})),n,r,i);this.insertNewElements(a);let l=await Promise.all(a.map(async(d,u)=>{try{return await this.initializeImage(d,await ol(t[u]))}catch(b){return this.setState({errorMessage:b.message||f("errors.imageInsertError")}),hr(d,{isDeleted:!0})}})),s=lp(l),c=J5(l.filter(d=>!d.isDeleted),n,r,i),m=lp(c),p=this.scene.getElementsIncludingDeleted().map(d=>m.get(d.id)??s.get(d.id)??d);this.updateScene({appState:{selectedElementIds:Ce(Object.fromEntries(c.map(d=>[d.id,!0])),this.state)},elements:p,captureUpdate:Pt.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(It)})});S(this,"handleAppOnDrop",async t=>{let{x:n,y:r}=He(t,this.state),i=await Ni(t),a=i.getFiles();if(a.length===1){let{file:p,fileHandle:d}=a[0];if(p&&(p.type===jo.png||p.type===jo.svg))try{let u=await oc(p,this.state,this.scene.getElementsIncludingDeleted(),d);this.syncActionResult({...u,appState:{...u.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:Pt.IMMEDIATELY});return}catch(u){if(u.name!=="EncodingError")throw new Error(f("alerts.couldNotLoadInvalidFile"))}}let l=a.map(p=>p.file).filter(p=>Tp(p));if(l.length>0&&this.isToolSupported("image"))return this.insertImages(l,n,r);let s=i.getData(jo.excalidrawlibIds),c=i.getData(jo.excalidrawlib);if(s||c){try{let p=null;if(s){let{itemIds:d}=JSON.parse(s);p=(await this.library.getLatestLibrary()).filter(b=>d.includes(b.id))}else c&&(p=Hb(c));p?.length&&(p=p.map(d=>({...d,elements:F1({type:"everything",elements:d.elements,randomizeSeed:!0,preserveFrameChildrenOrder:!0}).duplicatedElements})),this.addElementsFromPasteOrLibrary({elements:ta(p),position:t,files:null}))}catch(p){this.setState({errorMessage:p.message})}return}if(a.length>0){let{file:p,fileHandle:d}=a[0];p&&await this.loadFileToCanvas(p,d)}let m=i.findByType(jo.text);if(m){let p=m.value;if(p&&U1(p,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(p)||cp(p)?.type==="video")){let d=this.insertEmbeddableElement({sceneX:n,sceneY:r,link:_1(p)});d&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[d.id]:!0}}))}}});S(this,"loadFileToCanvas",async(t,n)=>{t=await ol(t);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await Sp(t,this.state,r,n)}catch(a){let l=a instanceof Mb;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===jo.excalidraw?(lk(r.concat(i.data.elements)),this.store.scheduleMicroAction({action:Pt.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:Pt.IMMEDIATELY})):i.type===jo.excalidrawlib&&await this.library.updateLibrary({libraryItems:t,merge:!0,openLibraryMenu:!0}).catch(a=>{console.error(a),this.setState({errorMessage:f("errors.importLibraryError")})})}catch(r){this.setState({isLoading:!1,errorMessage:r.message})}});S(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==qo.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type)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",c=this.excalidrawContainerRef.current,{top:m,left:p}=c.getBoundingClientRect(),d=t.clientX-p,u=t.clientY-m;ce("contextMenu","openContextMenu",s),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,...ho({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:kt(i)?new he(i,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:d,items:this.getContextMenuItems(s)}})})});S(this,"maybeDragNewGenericElement",(t,n,r=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&t.boxSelection.hasOccurred&&this.state.activeTool.type!=="eraser"){Z5({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:Ga(t.origin.x,a.x),height:Ga(t.origin.y,a.y),shouldMaintainAspectRatio:_s(n),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let l=this.state.newElement;if(!l)return;let[s,c]=xt(a.x,a.y,n[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=Fs(l)&&this.imageCache.get(l.fileId)?.image,p=m&&!(m instanceof Promise)?m.width/m.height:null;this.maybeCacheReferenceSnapPoints(n,[l]);let{snapOffset:d,snapLines:u}=TI(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:c-t.originInGrid.y},this.scene.getNonDeletedElementsMap());s+=d.x,c+=d.y,this.setState({snapLines:u}),on(l)||Z5({newElement:l,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:s,y:c,width:Ga(t.originInGrid.x,s),height:Ga(t.originInGrid.y,c),shouldMaintainAspectRatio:Qr(l)?!_s(n):_s(n),shouldResizeFromCenter:i5(n),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:p,originOffset:this.state.originSnapOffset,informMutation:r}),this.setState({newElement:l}),(this.state.activeTool.type===Jo.frame||this.state.activeTool.type===Jo.magicframe)&&this.setState({elementsToHighlight:K1(this.scene.getNonDeletedElements(),l,this.state,this.scene.getNonDeletedElementsMap())})});S(this,"maybeHandleCrop",(t,n)=>{if(!this.state.croppingElementId)return!1;let r=t.resize.handleType,i=t.lastCoords,[a,l]=xt(i.x-t.resize.offset.x,i.y-t.resize.offset.y,n[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(r&&s&&Qr(s)){let c=t.originalElements.get(s.id),m=Fs(s)&&this.imageCache.get(s.fileId)?.image;if(c&&Qr(c)&&m&&!(m instanceof Promise)){let[p,d]=xt(i.x,i.y,n[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:p-t.originInGrid.x,y:d-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(n,[s]);let{snapOffset:b,snapLines:g}=Yg([s],[c],this,n,u,r);this.scene.mutateElement(s,FY(s,this.scene.getNonDeletedElementsMap(),r,m.naturalWidth,m.naturalHeight,a+b.x,l+b.y,n.shiftKey?c.width/c.height:void 0)),sp(s,this.scene),this.setState({isCropping:r&&r!=="rotation",snapLines:g})}return!0}return!1});S(this,"maybeHandleResize",(t,n)=>{let r=this.scene.getSelectedElements(this.state),i=r.filter(p=>ht(p)),a=t.resize.handleType;if(i.length>0&&a==="rotation"||r.length===1&&Ht(r[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let l=t.lastCoords,[s,c]=xt(l.x-t.resize.offset.x,l.y-t.resize.offset.y,n[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=new Map;if(i.forEach(p=>{V1(this.scene.getNonDeletedElements(),p.id).forEach(u=>{m.set(p.id+u.id,{x:u.x-p.x,y:u.y-p.y})})}),!this.state.selectedElementsAreBeingDragged){let[p,d]=xt(l.x,l.y,n[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:p-t.originInGrid.x,y:d-t.originInGrid.y},b=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(n,r);let{snapOffset:g,snapLines:E}=Yg(r,ee(b,this.state),this,n,u,a);s+=g.x,c+=g.y,this.setState({snapLines:E})}if(eV(t.originalElements,a,r,this.scene,a5(n),i5(n),r.some(p=>Qr(p))?!_s(n):_s(n),s,c,t.resize.center.x,t.resize.center.y)){let p=new Set;return i.forEach(d=>{K1(this.scene.getNonDeletedElements(),d,this.state,this.scene.getNonDeletedElementsMap()).forEach(u=>p.add(u))}),this.setState({elementsToHighlight:[...p]}),!0}return!1});S(this,"getContextMenuItems",t=>{let n=[];if(t==="canvas")return this.state.viewModeEnabled?[Vi,ia,Kn]:[mh,at,xd,at,su,Lw,at,Vi,Dl,Rl,Nl,ia,Kn];if(n.push(xd),this.state.viewModeEnabled)return[Yi,...n];let r=this.editorInterface.formFactor==="desktop"?[at,ru,iu,au,lu]:[];return[at,Ed,Yi,mh,at,nI,rI,iI,at,_g,lh,sh,at,...n,at,nh,Fg,hh,gh,fw,rh,...r,at,ch,dh,at,pa,at,Ol,Sd,at,$I,cu,zl,at,ml]});S(this,"handleWheel",Ge(t=>{if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement||t.target instanceof HTMLElement&&t.target.classList.contains(B1.FRAME_NAME))){t[X.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),Us)return;let{deltaX:n,deltaY:r}=t;if(t.metaKey||t.ctrlKey||this.state.wheelZoomsOnDefault){let i=Math.sign(r),a=LW*100,l=Math.abs(r),s=r;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=>({...Bo({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:Jt(c)},m),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}))}));S(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:ye.pointers})});S(this,"resetShouldCacheIgnoreZoomDebounced",h5(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));S(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:c,offsetTop:m,offsetLeft:p}=this.state;if(r===s&&i===c&&a===p&&l===m){t&&t();return}this.setState({width:r,height:i,offsetLeft:a,offsetTop:l},()=>{t&&t()})}});S(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});S(this,"watchState",()=>{});let n=Pn(),{viewModeEnabled:r=!1,zenModeEnabled:i=!1,gridModeEnabled:a=!1,objectsSnapModeEnabled:l=!1,theme:s=n.theme,name:c=`${f("labels.untitled")}-${f5()}`,wheelZoomsOnDefault:m=!1}=t;this.state={...n,theme:s,exportWithDarkMode:s===za.DARK,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:r,zenModeEnabled:i,objectsSnapModeEnabled:l,gridModeEnabled:a??n.gridModeEnabled,name:c,width:window.innerWidth,height:window.innerHeight,wheelZoomsOnDefault:m},this.refreshEditorInterface(),this.stylesPanelMode=up(this.editorInterface),this.id=EW(),this.library=new o2(this),this.actionManager=new am(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new j5,this.canvas=document.createElement("canvas"),this.rc=bW.canvas(this.canvas),this.renderer=new cs(this.scene),this.visibleElements=[],this.store=new nV(this),this.history=new ls(this.store),this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new nn(this.scene),this.history=new ls(this.store),this.actionManager.registerAll(Sc),this.actionManager.registerAction(cI(this.history)),this.actionManager.registerAction(dI(this.history)),this.api=this.createExcalidrawAPI()}createExcalidrawAPI(){return{isDestroyed:!1,updateScene:this.updateScene,applyDeltas:this.applyDeltas,mutateElement:this.mutateElement,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,addImageElementsToScene:this.addImageElementsToScene,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},scrollToViewport:this.scrollToViewport,scrollToContent:this.scrollToContent,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:n=>{this.actionManager.registerAction(n)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.setCursor,resetCursor:this.resetCursor,getEditorInterface:()=>this.editorInterface,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:n=>this.onChangeEmitter.on(n),onIncrement:n=>this.store.onStoreIncrementEmitter.on(n),onPointerDown:n=>this.onPointerDownEmitter.on(n),onPointerUp:n=>this.onPointerUpEmitter.on(n),onScrollChange:n=>this.onScrollChangeEmitter.on(n),onUserFollow:n=>this.onUserFollowEmitter.on(n),onStateChange:this.onStateChange,onEvent:this.onEvent}}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(ip).includes(i)&&ob.set(r,i)}break}}handleSkipBindMode(){if(this.state.selectedLinearElement?.initialState&&!this.state.selectedLinearElement.initialState.arrowStartIsInside){en(this.lastPointerMoveCoords,"Missing last pointer move coords when changing bind skip mode for arrow start");let t=this.scene.getNonDeletedElementsMap(),n=tn(oe(this.lastPointerMoveCoords.x,this.lastPointerMoveCoords.y),this.scene.getNonDeletedElements(),t),r=he.getElement(this.state.selectedLinearElement.elementId,t);r?.startBinding&&n?.id===r.startBinding.elementId&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:!0}}})}if(this.state.bindMode==="orbit"&&(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),$t(()=>{this.setState({bindMode:"skip"})}),this.lastPointerMoveCoords&&this.state.selectedLinearElement?.selectedPointsIndices&&this.state.selectedLinearElement?.selectedPointsIndices.length)){let{x:t,y:n}=this.lastPointerMoveCoords,r=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;en(r,"Last event must exist");let i=t-this.state.selectedLinearElement.pointerOffset.x,a=n-this.state.selectedLinearElement.pointerOffset.y,l=this.state.multiElement?he.handlePointerMove(r,this,i,a,this.state.selectedLinearElement):he.handlePointDragging(r,this,i,a,this.state.selectedLinearElement);l&&this.setState(l)}}resetDelayedBindMode(){this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode!=="orbit"&&setTimeout(()=>this.setState({bindMode:"orbit"}))}handleDelayedBindModeChange(t,n){if(t.isDeleted||Ht(t))return;let r=()=>{if(this.bindModeHandler=null,en(this.lastPointerMoveCoords,"Expected lastPointerMoveCoords to be set"),!this.state.multiElement){if(!this.state.selectedLinearElement||!this.state.selectedLinearElement.selectedPointsIndices||!this.state.selectedLinearElement.selectedPointsIndices.length)return;let b=this.state.selectedLinearElement.selectedPointsIndices.includes(0),g=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1);if(!b&&!g||b&&g)return}let{x:p,y:d}=this.lastPointerMoveCoords,u=tn(oe(p,d),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(u&&this.state.bindMode!=="skip"){en(this.state.selectedLinearElement?.elementId===t.id,"The selectedLinearElement is expected to not change while a bind mode timeout is ticking");let b=this.state.selectedLinearElement.initialState.arrowStartIsInside||t.startBinding?.elementId===u.id;$t(()=>{en(this.state.selectedLinearElement,"this.state.selectedLinearElement must exist"),this.setState({bindMode:"inside",selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:b}}})});let g=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;en(g,"Last event must exist");let E=p-this.state.selectedLinearElement.pointerOffset.x,y=d-this.state.selectedLinearElement.pointerOffset.y,v=this.state.multiElement?he.handlePointerMove(g,this,E,y,this.state.selectedLinearElement):he.handlePointDragging(g,this,E,y,this.state.selectedLinearElement);v&&this.setState(v)}},i=!1;if(this.state.selectedLinearElement?.selectedPointsIndices){let p=this.scene.getNonDeletedElementsMap(),d=this.state.selectedLinearElement.selectedPointsIndices.includes(0),u=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1),b=d?n:t.startBinding&&p.get(t.startBinding.elementId),g=u?n:t.endBinding&&p.get(t.endBinding.elementId),E=b&&ek(b,p),y=g&&ek(g,p);i=!!(E&&y&&b.id!==g.id&&aV(E,y))}let a=this.state.selectedLinearElement?.selectedPointsIndices?.includes(0),l=this.state.selectedLinearElement?.selectedPointsIndices?.includes(t.points.length-1),s=a?"startBinding":l?"endBinding":null,c=a?"endBinding":l?"startBinding":null,m=c&&t[c]?.mode==="inside"&&t[c]?.elementId===n?.id||s&&t[s]?.mode==="inside"&&n?.id===t[s]?.elementId;s&&c&&t[s]?.mode==="inside"&&n?.id!==t[s]?.elementId&&t[c]?.elementId!==t[s]?.elementId&&this.scene.mutateElement(t,{[s]:{...t[s],mode:"orbit"}},{informMutation:!1,isDragging:!0}),!n||this.previousHoveredBindableElement&&n.id!==this.previousHoveredBindableElement.id?(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode==="inside"&&$t(()=>{this.setState({bindMode:"orbit"})}),this.previousHoveredBindableElement=null):!this.bindModeHandler&&(!this.state.newElement||!t.startBinding||i)&&!m&&(this.bindModeHandler=setTimeout(r,$W)),this.previousHoveredBindableElement=n}cacheEmbeddableRef(t,n){n&&this.iFrameRefs.set(t.id,n)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleIframeLikeCenterClick(){if(!this.lastPointerDownEvent||!this.lastPointerUpEvent||this.lastPointerDownEvent.button!==qo.MAIN||gr||!oY(this.state.activeTool.type,["laser","selection","lasso"]))return!1;let t=oe(He({clientX:this.lastPointerDownEvent.clientX,clientY:this.lastPointerDownEvent.clientY},this.state)),n=oe(He({clientX:this.lastPointerUpEvent.clientX,clientY:this.lastPointerUpEvent.clientY},this.state));if(In(t,n)>s5)return!1;let i=this.getElementAtPosition(t[0],t[1]);if(!(i&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<=300&&ye.pointers.size<2&&z1(i)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(i,this.lastPointerUpEvent,n[0],n[1]))))return!1;let l=i;if(this.state.activeEmbeddable?.element===l&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:l,state:"active"},selectedElementIds:{[l.id]:!0},newElement:null,selectionElement:null})},100),Ya(l)))return!0;let s=this.getHTMLIFrameElement(l);if(!s?.contentWindow)return!0;if(s.src.includes("youtube")){let c=ob.get(l.id);switch(c||(ob.set(l.id,ip.UNSTARTED),s.contentWindow.postMessage(JSON.stringify({event:"listening",id:l.id}),"*")),c){case ip.PLAYING:case ip.BUFFERING:s.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:s.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}return s.src.includes("player.vimeo.com")&&s.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*"),!0}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=>Sn(a)&&this.embedsValidationStatus.get(a.id)===!0||Ya(a));return ve(yV,{children:i.map(a=>{let{x:l,y:s}=ap({sceneX:a.x,sceneY:a.y},this.state),c=M5(a,n,r,this.state,this.scene.getNonDeletedElementsMap()),m=this.initializedEmbeds.has(a.id);if(c&&!m&&this.initializedEmbeds.add(a.id),!(c||m))return null;let d;if(Ya(a)){d=null;let y=(a.customData?.generationData??this.magicGenerations.get(a.id))||{status:"error",message:"No generation data",code:"ERR_NO_GENERATION_DATA"};if(y.status==="done"){let v=y.html;d={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>v}}else if(y.status==="pending")d={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>_5(`
21
+ `),i=[],a=0,l=0;for(let p of r){let d=a,u=d+p.length-1;i.push({line:p,startIndex:d,endIndex:u,lineNumber:l}),a=u+1,l++}let s=t,c=e.originalText.slice(t,t+o.length),m=[];for(let p of i){if(c==="")break;if(s>=p.startIndex&&s<=p.endIndex){let d=p.endIndex+1-s,u=p.line.slice(0,s-p.startIndex),b=c.slice(0,d);c=c.slice(d);let g=Ts(u,Fm(e),e.lineHeight);if(u===""&&(g.width=0),e.textAlign!=="left"&&p.line.length>0){let w=Ts(p.line,Fm(e),e.lineHeight),I=e.textAlign==="center"?(e.width-w.width)/2:e.width-w.width;g.width+=I}let{width:E,height:y}=Ts(b,Fm(e),e.lineHeight),v=g.width,x=p.lineNumber*g.height;m.push({offsetX:v,offsetY:x,width:E,height:y,showOnCanvas:!0}),s+=d}}return m},rz=(e,o,t,n)=>{let r=e.name??qT(e),i=r.slice(t,t+o.length),a=r.slice(0,t),l=Fm({fontSize:Hf.nameFontSize,fontFamily:zf.Assistant}),s=KO(zf.Assistant),c=Ts(a,l,s);a===""&&(c.width=0);let m=Ts(i,l,s),p=c.width,d=-c.height-Hf.strokeWidth,u=m.width;return[{offsetX:p,offsetY:d,width:u,height:m.height,showOnCanvas:p+u<=e.width*n}]},iz=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),$T=UO((e,o,t)=>{if(!e||e===""){t([],null);return}let n=o.scene.getNonDeletedElements(),r=n.filter(d=>jT(d)),i=n.filter(d=>Om(d));r.sort((d,u)=>d.y-u.y),i.sort((d,u)=>d.y-u.y);let a=[],l=new RegExp(iz(e),"gi");for(let d of r){let u=null,b=d.originalText;for(;(u=l.exec(b))!==null;){let g=ZT(b,u.index,e),E=nz(d,e,u.index);E.length>0&&a.push({element:d,searchQuery:e,preview:g,index:u.index,matchedLines:E})}}let s=[];for(let d of i){let u=null,b=d.name??qT(d);for(;(u=l.exec(b))!==null;){let g=ZT(b,u.index,e),E=rz(d,e,u.index,o.state.zoom.value);E.length>0&&s.push({element:d,searchQuery:e,preview:g,index:u.index,matchedLines:E})}}let c=new Set(o.visibleElements.map(d=>d.id)),m=[...s,...a],p=m.findIndex(d=>c.has(d.element.id))??null;t(m,p)},JO);import{jsx as ko,jsxs as eS}from"react/jsx-runtime";import{createElement as dz}from"react";var tS=Vr("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:o}=Ze();return ko(o.In,{children:ko(mo.Trigger,{...e,className:"default-sidebar-trigger",name:sz.name})})});tS.displayName="DefaultSidebarTrigger";var oS=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:o}=Ze();return ko(o.In,{children:e})};oS.displayName="DefaultTabTriggers";var zm=Object.assign(Vr("DefaultSidebar",({children:e,className:o,onDock:t,docked:n,...r})=>{let i=de(),a=be(),{DefaultSidebarTabTriggersTunnel:l}=Ze(),s=i.openSidebar?.tab===Uf;return dz(mo,{...r,name:"default",key:"default",className:lz("default-sidebar",o),docked:s||(n??i.defaultSidebarDockedPreference),onDock:s||t===!1||!t&&n!=null?void 0:cz(t,c=>{a({defaultSidebarDockedPreference:c})})},eS(mo.Tabs,{children:[ko(mo.Header,{children:eS(mo.TabTriggers,{children:[ko(mo.TabTrigger,{tab:Uf,children:Gt}),ko(mo.TabTrigger,{tab:QT,children:lc}),ko(l.Out,{})]})}),ko(mo.Tab,{tab:QT,children:ko(q2,{})}),ko(mo.Tab,{tab:Uf,children:ko(JT,{})}),e]}))}),{Trigger:tS,TabTriggers:oS});import{round as XS}from"@excalidraw/math";import NH from"clsx";import BH from"lodash.throttle";import{useEffect as KS,useMemo as n1,useState as FH,memo as OH}from"react";import{STATS_PANELS as $m}from"@excalidraw/common";import{getCommonBounds as zH}from"@excalidraw/element";import{getUncroppedWidthAndHeight as HH}from"@excalidraw/element";import{isImageElement as r1}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as GH}from"@excalidraw/element";import{elementsAreInSameGroup as UH}from"@excalidraw/element";import{degreesToRadians as dS,radiansToDegrees as hS}from"@excalidraw/math";import{getBoundTextElement as mS}from"@excalidraw/element";import{isArrowElement as pS,isElbowArrow as Iz}from"@excalidraw/element";import{updateBindings as uS}from"@excalidraw/element";import bz from"clsx";import{useEffect as sS,useRef as Gm,useState as Ez}from"react";import{EVENT as _a,KEYS as xz,cloneJSON as Wf}from"@excalidraw/common";import{deepCopyElement as yz}from"@excalidraw/element";import{CaptureUpdateAction as cS}from"@excalidraw/element";import{pointFrom as sr,pointRotateRads as Hm}from"@excalidraw/math";import{getBoundTextElement as mz,isBindingElement as pz,unbindBindingElement as nS}from"@excalidraw/element";import{isFrameLikeElement as aS}from"@excalidraw/element";import{getSelectedGroupIds as uz,getElementsInGroup as hz,isInGroup as gz}from"@excalidraw/element";import{getFrameChildren as fz}from"@excalidraw/element";import{updateBindings as rS}from"@excalidraw/element";import{DRAGGING_THRESHOLD as iS}from"@excalidraw/common";var lS=.01,Ss=10,Ft=(e,o)=>!(o==="angle"&&aS(e)),Ue=(e,o)=>{let t=e+o/2;return t-t%o},Aa=(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 Xr=(e,o,t,n,r,i,a=!0)=>{if(pz(t)&&(t.startBinding||t.endBinding)){if(Math.abs(e-t.x)<iS&&Math.abs(o-t.y)<iS)return;nS(t,"start",n),nS(t,"end",n)}let l=n.getNonDeletedElementsMap(),s=l.get(t.id);if(!s)return;let[c,m]=[t.x+t.width/2,t.y+t.height/2],[p,d]=Hm(sr(t.x,t.y),sr(c,m),t.angle),u=e-p,b=o-d,[g,E]=Hm(sr(e,o),sr(c+u,m+b),-t.angle);n.mutateElement(s,{x:g,y:E},{informMutation:a,isDragging:!1}),rS(s,n,r);let y=mz(t,i);if(y){let v=l.get(y.id);v&&n.mutateElement(v,{x:y.x+u,y:y.y+b},{informMutation:a,isDragging:!1})}if(aS(t)){let v=fz(i,t.id);v.forEach(x=>{let w=l.get(x.id);if(!w)return;let[I,C]=[x.x+x.width/2,x.y+x.height/2],[A,k]=Hm(sr(x.x,x.y),sr(I,C),x.angle),L=Math.round(A+u),_=Math.round(k+b),[M,D]=Hm(sr(L,_),sr(I+u,C+b),-x.angle);n.mutateElement(w,{x:M,y:D},{informMutation:a,isDragging:!1}),rS(w,n,r,{simultaneouslyUpdated:v})})}},La=(e,o)=>{let n=uz(o).map(r=>hz(e,r).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(r=>!gz(r)).forEach(r=>{n.push({[r.id]:!0})}),n};import{jsx as Yf,jsxs as vz}from"react/jsx-runtime";var wz=({label:e,icon:o,dragInputCallback:t,value:n,elements:r,editable:i=!0,shouldKeepAspectRatio:a,property:l,scene:s,appState:c,sensitivity:m=1,dragFinishedCallback:p})=>{let d=je(),u=be(),b=Gm(null),g=Gm(null),[E,y]=Ez(n.toString()),v=Gm(null);v.current||(v.current={originalAppState:Wf(c),originalElements:r,lastUpdatedValue:E,updatePending:!1}),sS(()=>{let I=n.toString();y(I),v.current.lastUpdatedValue=I},[n]);let x=(I,C,A)=>{if(!v.current.updatePending)return!1;v.current.updatePending=!1;let k=Number(I);if(isNaN(k)){y(n.toString());return}let L=Number(k.toFixed(2)),_=Number(n);(isNaN(_)||Math.abs(L-_)>=lS)&&(v.current.lastUpdatedValue=I,t({accumulatedChange:0,instantChange:0,originalElements:C,originalElementsMap:d.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:s,nextValue:L,property:l,originalAppState:A,setInputValue:M=>y(String(M)),app:d,setAppState:u}),d.syncActionResult({captureUpdate:cS.IMMEDIATELY}))},w=Gm({});return w.current.handleInputValue=x,sS(()=>{let I=b.current,C=w.current;return()=>{let A=I?.value;A&&C.handleInputValue?.(A,v.current.originalElements,v.current.originalAppState),window.removeEventListener(_a.POINTER_MOVE,C.onPointerMove,!1),window.removeEventListener(_a.POINTER_UP,C.onPointerUp,!1)}},[i]),i?vz("div",{className:bz("drag-input-container",!i&&"disabled"),"data-testid":e,children:[Yf("div",{className:"drag-input-label",ref:g,onPointerDown:I=>{if(b.current&&i){document.body.classList.add("excalidraw-cursor-resize");let C=Number(b.current.value);isNaN(C)&&(C=0);let A=null,k=d.scene.getNonDeletedElements().reduce((O,K)=>(O.set(K.id,yz(K)),O),new Map),L=r.map(O=>k.get(O.id)),_=Wf(c),M=0,D=0,z=O=>{if(A&&k!==null&&L!==null){let K=O.clientX-A.x;K!==0&&(D+=K,Math.abs(D)>=m&&(D=Math.sign(D)*Math.floor(Math.abs(D)/m),M+=D,t({accumulatedChange:M,instantChange:D,originalElements:L,originalElementsMap:k,shouldKeepAspectRatio:a,shouldChangeByStepSize:O.shiftKey,property:l,scene:s,originalAppState:_,setInputValue:Y=>y(String(Y)),app:d,setAppState:u}),D=0))}A={x:O.clientX,y:O.clientY}},W=()=>{window.removeEventListener(_a.POINTER_MOVE,z,!1),d.syncActionResult({captureUpdate:cS.IMMEDIATELY}),p?.({app:d,setAppState:u,originalElements:L,originalAppState:_}),A=null,M=0,D=0,L=null,k=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(_a.POINTER_UP,W,!1)};w.current.onPointerMove=z,w.current.onPointerUp=W,window.addEventListener(_a.POINTER_MOVE,z,!1),window.addEventListener(_a.POINTER_UP,W,!1)}},onPointerEnter:()=>{g.current&&(g.current.style.cursor="ew-resize")},children:o?Yf(Mi,{icon:o}):e}),Yf("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:I=>{if(i){let C=I.target;C instanceof HTMLInputElement&&I.key===xz.ENTER&&(x(C.value,r,c),d.focusContainer())}},ref:b,value:E,onChange:I=>{v.current.updatePending=!0,y(I.target.value)},onFocus:I=>{I.target.select(),v.current.originalElements=r,v.current.originalAppState=Wf(c)},onBlur:I=>{E?i&&x(I.target.value,v.current.originalElements,v.current.originalAppState):y(n.toString())},disabled:!i})]}):null},st=wz;import{jsx as kz}from"react/jsx-runtime";var Tz=15,Sz=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,scene:r,app:i})=>{let a=r.getNonDeletedElementsMap(),l=o[0];if(l&&!Iz(l)){let s=a.get(l.id);if(!s)return;if(n!==void 0){let b=dS(n);r.mutateElement(s,{angle:b}),uS(s,r,i.state);let g=mS(s,a);g&&!pS(s)&&r.mutateElement(g,{angle:b});return}let c=Math.round(hS(l.angle)*100)/100,m=Math.round(e),p=(c+m)%360;t&&(p=Ue(p,Tz)),p=p<0?p+360:p;let d=dS(p);r.mutateElement(s,{angle:d}),uS(s,r,i.state);let u=mS(s,a);u&&!pS(s)&&r.mutateElement(u,{angle:d})}},Cz=({element:e,scene:o,appState:t,property:n})=>kz(st,{label:"A",icon:xc,value:Math.round(hS(e.angle)%360*100)/100,elements:[e],dragInputCallback:Sz,editable:Ft(e,"angle"),scene:o,appState:t,property:n}),gS=Cz;import{jsx as Mz}from"react/jsx-runtime";var fS=5,Pz=({property:e,scene:o,appState:t,setAppState:n})=>Mz(st,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:r,instantChange:i,shouldChangeByStepSize:a,setInputValue:l})=>{n(s=>{let c;return r?c=r:i&&(c=a?Ue(s.gridStep+fS*Math.sign(i),fS):s.gridStep+i),c?(c=kb(c),l(c),{gridStep:c}):(l(s.gridStep),null)})},scene:o,value:t.gridStep,property:e,appState:t}),bS=Pz;import{clamp as Um,round as Vf}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as Wm}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as ES,getUncroppedWidthAndHeight as wS}from"@excalidraw/element";import{resizeSingleElement as xS}from"@excalidraw/element";import{isImageElement as vS}from"@excalidraw/element";import{isFrameLikeElement as Xf}from"@excalidraw/element";import{getElementsInResizingFrame as Kf}from"@excalidraw/element";import{replaceAllElementsInFrame as IS}from"@excalidraw/element";import{jsx as Rz}from"react/jsx-runtime";var yS=10,Az=e=>e.type==="image",Lz=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldKeepAspectRatio:n,shouldChangeByStepSize:r,nextValue:i,property:a,originalAppState:l,instantChange:s,scene:c,app:m,setAppState:p})=>{let d=c.getNonDeletedElementsMap(),u=o[0],b=d.get(u.id);if(u&&b){let g=n||Az(u),E=u.width/u.height;if(l.croppingElementId===u.id){let y=d.get(u.id);if(!y||!vS(y)||!y.crop)return;let v=y.crop,x={...v},w=y.scale[0]===-1,I=y.scale[1]===-1,{width:C,height:A}=wS(y),k=v.naturalWidth/C,L=v.naturalHeight/A,_=w?v.width+v.x:v.naturalWidth-v.x,M=I?v.height+v.y:v.naturalHeight-v.y,D=ES*k,z=ES*L;if(i!==void 0){if(a==="width"){let q=i*k,ne=Um(q,D,_);x={...x,width:ne,x:w?v.x+v.width-ne:v.x}}else if(a==="height"){let q=i*L,ne=Um(q,z,M);x={...x,height:ne,y:I?v.y+v.height-ne:v.y}}c.mutateElement(y,{crop:x,width:x.width/(v.naturalWidth/C),height:x.height/(v.naturalHeight/A)});return}let W=a==="width"?s:0,O=a==="height"?s:0,K=Um(v.width+W,D,_),Y=Um(v.height+O,D,M);x={...v,x:w?v.x+v.width-K:v.x,y:I?v.y+v.height-Y:v.y,width:K,height:Y},c.mutateElement(y,{crop:x,width:x.width/(v.naturalWidth/C),height:x.height/(v.naturalHeight/A)});return}if(i!==void 0){let y=Math.max(a==="width"?i:g?i*E:u.width,Wm),v=Math.max(a==="height"?i:g?i/E:u.height,Wm);if(xS(y,v,b,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),Xf(b)){let x=Kf(c.getElementsIncludingDeleted(),b,l,c.getNonDeletedElementsMap()),w=IS(c.getElementsIncludingDeleted(),x,b);c.replaceAllElements(w)}return}{let y=a==="width"?e:0,v=a==="height"?e:0,x=Math.max(0,u.width+y);a==="width"&&(r?x=Ue(x,yS):x=Math.round(x));let w=Math.max(0,u.height+v);if(a==="height"&&(r?w=Ue(w,yS):w=Math.round(w)),g&&(a==="width"?w=Math.round(x/E*100)/100:x=Math.round(w*E*100)/100),w=Math.max(Wm,w),x=Math.max(Wm,x),xS(x,w,b,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),Xf(b)){let I=Kf(c.getElementsIncludingDeleted(),b,l,c.getNonDeletedElementsMap());p({elementsToHighlight:I})}}}},_z=({setAppState:e,app:o,originalElements:t,originalAppState:n})=>{let r=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&Xf(a)){let l=Kf(o.scene.getElementsIncludingDeleted(),a,n,o.scene.getNonDeletedElementsMap()),s=IS(o.scene.getElementsIncludingDeleted(),l,a);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},Dz=({property:e,element:o,scene:t,appState:n})=>{let r=Vf(e==="width"?o.width:o.height,2);if(n.croppingElementId&&n.croppingElementId===o.id&&vS(o)&&o.crop){let{width:i,height:a}=wS(o);if(e==="width"){let l=i/o.crop.naturalWidth;r=Vf(o.crop.width*l,2)}if(e==="height"){let l=a/o.crop.naturalHeight;r=Vf(o.crop.height*l,2)}}return Rz(st,{label:e==="width"?"W":"H",elements:[o],dragInputCallback:Lz,value:r,editable:Ft(o,e),scene:t,appState:n,property:e,dragFinishedCallback:_z})},Zf=Dz;import{getBoundTextElement as Nz,redrawTextBoundingBox as Bz}from"@excalidraw/element";import{hasBoundTextElement as Fz,isTextElement as SS}from"@excalidraw/element";import{jsx as Gz}from"react/jsx-runtime";var TS=4,Oz=4,zz=({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||!SS(l))return;let s;if(n!==void 0)s=Math.max(Math.round(n),TS);else if(a.type==="text"){let c=Math.round(a.fontSize),m=Math.round(e);s=Math.max(c+m,TS),t&&(s=Ue(s,Oz))}s&&(r.mutateElement(l,{fontSize:s}),Bz(l,r.getContainerElement(l),r))}},Hz=({element:e,scene:o,appState:t,property:n})=>{let r=SS(e)?e:Fz(e)?Nz(e,o.getNonDeletedElementsMap()):null;return r?Gz(st,{label:"F",value:Math.round(r.fontSize*10)/10,elements:[r],dragInputCallback:zz,icon:Tr,appState:t,scene:o,property:n}):null},CS=Hz;import{degreesToRadians as kS,radiansToDegrees as AS}from"@excalidraw/math";import{getBoundTextElement as PS}from"@excalidraw/element";import{isArrowElement as MS}from"@excalidraw/element";import{isInGroup as $f}from"@excalidraw/element";import{jsx as Vz}from"react/jsx-runtime";var Uz=15,Wz=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,property:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),l=o.map(c=>a.get(c.id)).filter(c=>c&&!$f(c)&&Ft(c,r)),s=o.filter(c=>!$f(c)&&Ft(c,r));if(n!==void 0){let c=kS(n);for(let m of l){if(!m)continue;i.mutateElement(m,{angle:c});let p=PS(m,a);p&&!MS(m)&&i.mutateElement(p,{angle:c})}i.triggerUpdate();return}for(let c=0;c<l.length;c++){let m=l[c];if(!m)continue;let p=s[c],d=Math.round(AS(p.angle)*100)/100,u=Math.round(e),b=(d+u)%360;t&&(b=Ue(b,Uz)),b=b<0?b+360:b;let g=kS(b);i.mutateElement(m,{angle:g});let E=PS(m,a);E&&!MS(m)&&i.mutateElement(E,{angle:g})}i.triggerUpdate()},Yz=({elements:e,scene:o,appState:t,property:n})=>{let r=e.filter(s=>!$f(s)&&Ft(s,"angle")),i=r.map(s=>Math.round(AS(s.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",l=r.some(s=>Ft(s,"angle"));return Vz(st,{label:"A",icon:xc,value:a,elements:e,dragInputCallback:Wz,editable:l,appState:t,scene:o,property:n})},LS=Yz;import{pointFrom as NS}from"@excalidraw/math";import{useMemo as nH}from"react";import{MIN_WIDTH_OR_HEIGHT as cr}from"@excalidraw/common";import{getElementsInResizingFrame as qf,isFrameLikeElement as Jf,replaceAllElementsInFrame as OS,updateBoundElements as rH}from"@excalidraw/element";import{rescalePointsInElement as iH,resizeSingleElement as BS}from"@excalidraw/element";import{getBoundTextElement as aH,handleBindTextResize as lH}from"@excalidraw/element";import{isTextElement as zS}from"@excalidraw/element";import{arrayToMap as Xz}from"@excalidraw/common";import{getElementBounds as Kz}from"@excalidraw/element";import{isArrowElement as Zz,isExcalidrawElement as $z,isFreeDrawElement as jz,isLinearElement as qz,isTextElement as Jz}from"@excalidraw/element";import{rangeIncludesValue as Ym,pointFrom as vn,pointRotateRads as Qz,rangeInclusive as Vm}from"@excalidraw/math";var eH=e=>e.type==="diamond"?[vn(e.width/2,0),vn(e.width,e.height/2),vn(e.width/2,e.height),vn(0,e.height/2)]:[vn(0,0),vn(0+e.width,0),vn(0+e.width,e.height),vn(0,e.height)],tH=e=>qz(e)||jz(e)?e.points:eH(e),_S=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},DS=e=>{let o=tH(e),{cx:t,cy:n}=_S(o),r=vn(t,n),i=o.map(m=>Qz(m,r,e.angle)),{minX:a,minY:l,maxX:s,maxY:c}=_S(i);return[a+e.x,l+e.y,s+e.x,c+e.y]},jf=(e,o,t=!1)=>{let n=DS(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},RS=(e,o)=>{let t=DS(e);return(Ym(t[0],Vm(o[0],o[2]))||Ym(o[0],Vm(t[0],t[2])))&&(Ym(t[1],Vm(o[1],o[3]))||Ym(o[1],Vm(t[1],t[3])))},oH=({elements:e,bounds:o,type:t,errorMargin:n=0})=>{$z(o)&&(o=Kz(o,Xz(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"?RS(a,r):t==="inside"?jf(a,r):jf(a,r,!0)){if(i.add(a.id),a.boundElements)for(let s of a.boundElements)i.add(s.id);Jz(a)&&a.containerId&&i.add(a.containerId),Zz(a)&&(a.startBinding&&i.add(a.startBinding.elementId),a.endBinding&&i.add(a.endBinding?.elementId))}}return e.filter(a=>i.has(a.id))};import{getCommonBounds as Xm}from"@excalidraw/element";import{jsx as uH}from"react/jsx-runtime";var Da=10,sH=(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,c=o+i*t;return{width:a,height:l,x:s,y:c,...iH(n,a,l,!1),...zS(n)?{fontSize:n.fontSize*t}:{}}},cH=(e,o,t,n,r,i,a,l)=>{let s=l.getNonDeletedElementsMap(),c=sH(e,o,n,i);l.mutateElement(r,c);let m=aH(i,a);if(m){let p=m.fontSize*n;rH(r,l);let d=s.get(m.id);d&&zS(d)&&(l.mutateElement(d,{fontSize:p}),lH(r,l,t==="width"?"e":"s",!0))}},FS=(e,o,t,n,r,i,a,l,s,c)=>{i==="width"?o=Math.round(e/n*100)/100:e=Math.round(o*n*100)/100;let m=o/t;for(let p=0;p<l.length;p++){let d=l[p],u=a[p];cH(r[0],r[1],i,m,u,d,s,c)}},dH=({accumulatedChange:e,originalElements:o,originalElementsMap:t,originalAppState:n,shouldChangeByStepSize:r,nextValue:i,scene:a,property:l,setAppState:s,app:c})=>{let m=a.getNonDeletedElementsMap(),p=La(o,n);if(i!==void 0){for(let g of p){let E=Aa(g,m,t);if(E.length>1){let y=E.map(D=>D.latest),v=E.map(D=>D.original),[x,w,I,C]=Xm(v),A=I-x,k=C-w,L=A/k,_=Math.max(cr,l==="width"?Math.max(0,i):A),M=Math.max(cr,l==="height"?Math.max(0,i):k);FS(_,M,k,L,NS(x,w),l,y,v,t,a)}else{let[y]=E,v=y?.latest,x=y?.original;if(v&&x&&Ft(v,l)){let w=l==="width"?Math.max(0,i):v.width;l==="width"&&(r?w=Ue(w,Da):w=Math.round(w));let I=l==="height"?Math.max(0,i):v.height;if(l==="height"&&(r?I=Ue(I,Da):I=Math.round(I)),w=Math.max(cr,w),I=Math.max(cr,I),BS(w,I,v,x,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),Jf(v)){let C=qf(a.getElementsIncludingDeleted(),v,n,a.getNonDeletedElementsMap()),A=OS(a.getElementsIncludingDeleted(),C,v);a.replaceAllElements(A)}}}}a.triggerUpdate();return}let d=l==="width"?e:0,u=l==="height"?e:0,b=[];for(let g of p){let E=Aa(g,m,t);if(E.length>1){let y=E.map(D=>D.latest),v=E.map(D=>D.original),[x,w,I,C]=Xm(v),A=I-x,k=C-w,L=A/k,_=Math.max(0,A+d);l==="width"&&(r?_=Ue(_,Da):_=Math.round(_));let M=Math.max(0,k+u);l==="height"&&(r?M=Ue(M,Da):M=Math.round(M)),_=Math.max(cr,_),M=Math.max(cr,M),FS(_,M,k,L,NS(x,w),l,y,v,t,a)}else{let[y]=E,v=y?.latest,x=y?.original;if(v&&x&&Ft(v,l)){let w=Math.max(0,x.width+d);l==="width"&&(r?w=Ue(w,Da):w=Math.round(w));let I=Math.max(0,x.height+u);if(l==="height"&&(r?I=Ue(I,Da):I=Math.round(I)),w=Math.max(cr,w),I=Math.max(cr,I),BS(w,I,v,x,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),Jf(v)){let C=qf(a.getElementsIncludingDeleted(),v,n,a.getNonDeletedElementsMap());b.push(...C)}}}}s({elementsToHighlight:b}),a.triggerUpdate()},mH=({setAppState:e,app:o,originalElements:t,originalAppState:n})=>{let r=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&Jf(a)){let l=qf(o.scene.getElementsIncludingDeleted(),a,n,o.scene.getNonDeletedElementsMap()),s=OS(o.scene.getElementsIncludingDeleted(),l,a);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},pH=({property:e,elements:o,elementsMap:t,atomicUnits:n,scene:r,appState:i})=>{let a=nH(()=>n.map(c=>{let m=Aa(c,t);if(m.length>1){let[d,u,b,g]=Xm(m.map(E=>E.latest));return Math.round((e==="width"?b-d:g-u)*100)/100}let[p]=m;return Math.round((e==="width"?p.latest.width:p.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 uH(st,{label:e==="width"?"W":"H",elements:o,dragInputCallback:dH,value:l,editable:s,appState:i,property:e,scene:r,dragFinishedCallback:mH})},Qf=pH;import{getBoundTextElement as hH,redrawTextBoundingBox as HS}from"@excalidraw/element";import{hasBoundTextElement as gH,isTextElement as fH}from"@excalidraw/element";import{isInGroup as bH}from"@excalidraw/element";import{jsx as vH}from"react/jsx-runtime";var GS=4,EH=4,xH=(e,o)=>e.reduce((t,n)=>{if(!n||bH(n))return t;if(fH(n))return t.push(n),t;if(gH(n)){let r=hH(n,o);if(r)return t.push(r),t}return t},[]),yH=({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),GS);for(let s of a)r.mutateElement(s,{fontSize:l}),HS(s,r.getContainerElement(s),r);r.triggerUpdate()}else{let s=o;for(let c=0;c<a.length;c++){let m=a[c],p=s[c],d=Math.round(p.fontSize),u=Math.round(e),b=Math.max(d+u,GS);t&&(b=Ue(b,EH)),r.mutateElement(m,{fontSize:b}),HS(m,r.getContainerElement(m),r)}r.triggerUpdate()}},wH=({elements:e,scene:o,appState:t,property:n,elementsMap:r})=>{let i=xH(e,r);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 vH(st,{label:"F",icon:Tr,elements:i,dragInputCallback:yH,value:l,editable:s,scene:o,property:n,appState:t})},US=wH;import{pointFrom as dr,pointRotateRads as Km}from"@excalidraw/math";import{useMemo as IH}from"react";import{isTextElement as TH}from"@excalidraw/element";import{getCommonBounds as e1}from"@excalidraw/element";import{jsx as MH}from"react/jsx-runtime";var SH=(e,o,t,n,r,i,a)=>{for(let l=0;l<n.length;l++){let s=n[l],[c,m]=[s.x+s.width/2,s.y+s.height/2],[p,d]=Km(dr(s.x,s.y),dr(c,m),s.angle),u=e==="x"?Math.round(p+o):p,b=e==="y"?Math.round(d+t):d;Xr(u,b,s,i,a,r,!1)}},CH=(e,o,t,n,r,i)=>{let a=r.getNonDeletedElementsMap(),[l,s,,]=e1(t),c=e-l,m=o-s;for(let p=0;p<t.length;p++){let d=t[p],u=a.get(d.id);if(u&&(!TH(u)||!u.containerId)){let[b,g]=[u.x+u.width/2,u.y+u.height/2],[E,y]=Km(dr(u.x,u.y),dr(b,g),u.angle);Xr(E+c,y+m,d,r,i,n,!1)}}},kH=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldChangeByStepSize:n,nextValue:r,property:i,scene:a,originalAppState:l,app:s})=>{let c=a.getNonDeletedElementsMap();if(r!==void 0){for(let u of La(o,l)){let b=Aa(u,c,t);if(b.length>1){let[g,E,,]=e1(b.map(x=>x.latest));CH(i==="x"?r:g,i==="y"?r:E,b.map(x=>x.original),t,a,s.state)}else{let g=b[0]?.original,E=b[0]?.latest;if(g&&E&&Ft(E,i)){let[y,v]=[g.x+g.width/2,g.y+g.height/2],[x,w]=Km(dr(g.x,g.y),dr(y,v),g.angle);Xr(i==="x"?r:x,i==="y"?r:w,g,a,s.state,t,!1)}}}a.triggerUpdate();return}let m=n?Ue(e,Ss):e;SH(i,i==="x"?m:0,i==="y"?m:0,o,t,a,s.state),a.triggerUpdate()},PH=({property:e,elements:o,elementsMap:t,atomicUnits:n,scene:r,appState:i})=>{let a=IH(()=>n.map(s=>{let c=Object.keys(s).map(g=>t.get(g)).filter(g=>g!==void 0);if(c.length>1){let[g,E]=e1(c);return Math.round((e==="x"?g:E)*100)/100}let[m]=c,[p,d]=[m.x+m.width/2,m.y+m.height/2],[u,b]=Km(dr(m.x,m.y),dr(p,d),m.angle);return Math.round((e==="x"?u:b)*100)/100}),[n,t,e]),l=new Set(a).size===1?a[0]:"Mixed";return MH(st,{label:e==="x"?"X":"Y",elements:o,dragInputCallback:kH,value:l,property:e,scene:r,appState:i})},t1=PH;import{clamp as Cs,pointFrom as Zm,pointRotateRads as YS,round as WS}from"@excalidraw/math";import{getFlipAdjustedCropPosition as AH,getUncroppedWidthAndHeight as LH}from"@excalidraw/element";import{isImageElement as VS}from"@excalidraw/element";import{jsx as RH}from"react/jsx-runtime";var _H=({accumulatedChange:e,instantChange:o,originalElements:t,originalElementsMap:n,shouldChangeByStepSize:r,nextValue:i,property:a,scene:l,originalAppState:s,app:c})=>{let m=l.getNonDeletedElementsMap(),p=t[0],[d,u]=[p.x+p.width/2,p.y+p.height/2],[b,g]=YS(Zm(p.x,p.y),Zm(d,u),p.angle);if(s.croppingElementId===p.id){let w=m.get(p.id);if(!w||!VS(w)||!w.crop)return;let I=w.crop,C=I,A=w.scale[0]===-1,k=w.scale[1]===-1,{width:L,height:_}=LH(w);if(i!==void 0){if(a==="x"){let z=i*(I.naturalWidth/L);A?C={...I,x:Cs(I.naturalWidth-z-I.width,0,I.naturalWidth-I.width)}:C={...I,x:Cs(i*(I.naturalWidth/L),0,I.naturalWidth-I.width)}}a==="y"&&(C={...I,y:Cs(i*(I.naturalHeight/_),0,I.naturalHeight-I.height)}),l.mutateElement(w,{crop:C});return}let M=(a==="x"?o:0)*(A?-1:1),D=(a==="y"?o:0)*(k?-1:1);C={...I,x:Cs(I.x+M,0,I.naturalWidth-I.width),y:Cs(I.y+D,0,I.naturalHeight-I.height)},l.mutateElement(w,{crop:C});return}if(i!==void 0){Xr(a==="x"?i:b,a==="y"?i:g,p,l,c.state,n);return}let E=a==="x"?e:0,y=a==="y"?e:0,v=a==="x"?Math.round(r?Ue(p.x+E,Ss):b+E):b,x=a==="y"?Math.round(r?Ue(p.y+y,Ss):g+y):g;Xr(v,x,p,l,c.state,n)},DH=({property:e,element:o,elementsMap:t,scene:n,appState:r})=>{let[i,a]=YS(Zm(o.x,o.y),Zm(o.x+o.width/2,o.y+o.height/2),o.angle),l=WS(e==="x"?i:a,2);if(r.croppingElementId===o.id&&VS(o)&&o.crop){let s=AH(o);s&&(l=WS(e==="x"?s.x:s.y,2))}return RH(st,{label:e==="x"?"X":"Y",elements:[o],dragInputCallback:_H,scene:n,value:l,property:e,appState:r})},o1=DH;import{Fragment as i1,jsx as re,jsxs as Ot}from"react/jsx-runtime";var WH=50,ks=e=>{let o=Do(),t=e.app.scene.getSceneNonce()||1,n=e.app.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}),r=or(e.app);return re(YH,{...e,appState:o,sceneNonce:t,selectedElements:n,gridModeEnabled:r})},Fe=({children:e,columns:o=1,heading:t,style:n,...r})=>re("div",{className:NH("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${o}, 1fr)`,...n},...r,children:e});Fe.displayName="StatsRow";var jm=({children:e,order:o,style:t,...n})=>re("div",{className:"exc-stats__rows",style:{order:o,...t},...n,children:e});jm.displayName="StatsRows";ks.StatsRow=Fe;ks.StatsRows=jm;var YH=OH(({app:e,onClose:o,renderCustomStats:t,selectedElements:n,appState:r,sceneNonce:i,gridModeEnabled:a})=>{let l=e.scene,s=l.getNonDeletedElements(),c=l.getNonDeletedElementsMap(),m=be(),p=n.length===1?n[0]:null,d=n.length>1?n:null,u=r.croppingElementId&&r1(p),b=u?HH(p):null,[g,E]=FH({width:0,height:0}),y=n1(()=>BH(w=>{let I=zH(w);E({width:Math.round(I[2])-Math.round(I[0]),height:Math.round(I[3])-Math.round(I[1])})},WH),[]);KS(()=>{y(s)},[i,s,y]),KS(()=>()=>y.cancel(),[y]);let v=n1(()=>La(n,r),[n,r]),x=n1(()=>GH(n),[n]);return re("div",{className:"exc-stats",children:Ot(We,{padding:3,children:[Ot("div",{className:"title",children:[re("h2",{children:f("stats.title")}),re("div",{className:"close",onClick:o,children:Qt})]}),Ot(wl,{label:re("h3",{children:f("stats.generalStats")}),open:!!(r.stats.panels&$m.generalStats),openTrigger:()=>m(w=>({stats:{open:!0,panels:w.stats.panels^$m.generalStats}})),children:[Ot(jm,{children:[re(Fe,{heading:!0,children:f("stats.scene")}),Ot(Fe,{columns:2,children:[re("div",{children:f("stats.shapes")}),re("div",{children:s.length})]}),Ot(Fe,{columns:2,children:[re("div",{children:f("stats.width")}),re("div",{children:g.width})]}),Ot(Fe,{columns:2,children:[re("div",{children:f("stats.height")}),re("div",{children:g.height})]}),a&&Ot(i1,{children:[re(Fe,{heading:!0,children:"Canvas"}),re(Fe,{children:re(bS,{property:"gridStep",scene:l,appState:r,setAppState:m})})]})]}),t?.(s,r)]}),!x&&n.length>0&&re("div",{id:"elementStats",style:{marginTop:12},children:re(wl,{label:re("h3",{children:f("stats.elementProperties")}),open:!!(r.stats.panels&$m.elementProperties),openTrigger:()=>m(w=>({stats:{open:!0,panels:w.stats.panels^$m.elementProperties}})),children:Ot(jm,{children:[p&&Ot(i1,{children:[u&&re(Fe,{heading:!0,children:f("labels.unCroppedDimension")}),r.croppingElementId&&r1(p)&&b&&Ot(Fe,{columns:2,children:[re("div",{children:f("stats.width")}),re("div",{children:XS(b.width,2)})]}),r.croppingElementId&&r1(p)&&b&&Ot(Fe,{columns:2,children:[re("div",{children:f("stats.height")}),re("div",{children:XS(b.height,2)})]}),re(Fe,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:r.croppingElementId?f("labels.imageCropping"):f(`element.${p.type}`)}),re(Fe,{children:re(o1,{element:p,property:"x",elementsMap:c,scene:l,appState:r})}),re(Fe,{children:re(o1,{element:p,property:"y",elementsMap:c,scene:l,appState:r})}),re(Fe,{children:re(Zf,{property:"width",element:p,scene:l,appState:r})}),re(Fe,{children:re(Zf,{property:"height",element:p,scene:l,appState:r})}),re(Fe,{children:re(gS,{property:"angle",element:p,scene:l,appState:r})}),re(Fe,{children:re(CS,{property:"fontSize",element:p,scene:l,appState:r})})]}),d&&Ot(i1,{children:[UH(d)&&re(Fe,{heading:!0,children:f("element.group")}),Ot(Fe,{columns:2,style:{margin:"0.3125rem 0"},children:[re("div",{children:f("stats.shapes")}),re("div",{children:n.length})]}),re(Fe,{children:re(t1,{property:"x",elements:d,elementsMap:c,atomicUnits:v,scene:l,appState:r})}),re(Fe,{children:re(t1,{property:"y",elements:d,elementsMap:c,atomicUnits:v,scene:l,appState:r})}),re(Fe,{children:re(Qf,{property:"width",elements:d,elementsMap:c,atomicUnits:v,scene:l,appState:r})}),re(Fe,{children:re(Qf,{property:"height",elements:d,elementsMap:c,atomicUnits:v,scene:l,appState:r})}),re(Fe,{children:re(LS,{property:"angle",elements:d,scene:l,appState:r})}),re(Fe,{children:re(US,{property:"fontSize",elements:d,scene:l,appState:r,elementsMap:c})})]})]})})})]})})},(e,o)=>e.sceneNonce===o.sceneNonce&&e.selectedElements===o.selectedElements&&e.appState.stats.panels===o.appState.stats.panels&&e.gridModeEnabled===o.gridModeEnabled&&e.appState.gridStep===o.appState.gridStep&&e.appState.croppingElementId===o.appState.croppingElementId);import{useCallback as VH,useEffect as ZS,useState as $S}from"react";import{normalizeLink as XH,KEYS as a1}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as KH,getLinkIdAndTypeFromSelection as ZH}from"@excalidraw/element";import{jsx as Ra,jsxs as qm}from"react/jsx-runtime";var $H=({sourceElementId:e,onClose:o,appState:t,scene:n,generateLinkForSelection:r=KH})=>{let i=n.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[l,s]=$S(a),[c,m]=$S(!1);ZS(()=>{let d=ee(i,t),u=a;if(d.length>0&&r){let b=ZH(d,t);b&&(u=XH(r(b.id,b.type)))}s(u)},[i,t,t.selectedElementIds,a,r]);let p=VH(()=>{if(l&&l!==i.get(e)?.link){let d=i.get(e);d&&n.mutateElement(d,{link:l})}if(!l&&c&&e){let d=i.get(e);d&&n.mutateElement(d,{link:null})}o?.()},[e,l,i,c,n,o]);return ZS(()=>{let d=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===a1.ENTER&&p(),t.openDialog?.name==="elementLinkSelector"&&u.key===a1.ESCAPE&&o?.()};return window.addEventListener("keydown",d),()=>{window.removeEventListener("keydown",d)}},[t,o,p]),qm("div",{className:"ElementLinkDialog",children:[qm("div",{className:"ElementLinkDialog__header",children:[Ra("h2",{children:f("elementLink.title")}),Ra("p",{children:f("elementLink.desc")})]}),qm("div",{className:"ElementLinkDialog__input",children:[Ra(qn,{value:l??"",onChange:d=>{c||m(!0),s(d)},onKeyDown:d=>{d.key===a1.ENTER&&p()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&l&&Ra(Z,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:()=>{s(null),m(!0)},className:"ElementLinkDialog__remove",icon:ln})]}),qm("div",{className:"ElementLinkDialog__actions",children:[Ra(un,{label:f("buttons.cancel"),onClick:()=>{o?.()},style:{marginRight:10}}),Ra(un,{label:f("buttons.confirm"),onClick:p,actionType:"primary"})]})]})},jS=$H;import jH,{useState as qH}from"react";import{Fragment as JH,jsx as l1}from"react/jsx-runtime";var qS=({children:e,onClose:o})=>{let[t,n]=qH(!!e),{container:r}=Ne(),i=jH.useCallback(()=>{n(!1),o&&o(),r?.focus()},[o,r]);return l1(JH,{children:t&&l1(qe,{size:"small",onCloseRequest:i,title:f("errorDialog.title"),children:l1("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import QH from"clsx";import{jsx as eG}from"react/jsx-runtime";var JS=({children:e,side:o,className:t})=>eG("div",{className:QH("FixedSideContainer",`FixedSideContainer_side_${o}`,t),children:e});import eC,{useMemo as lG}from"react";import tC from"clsx";import{isDarwin as oC,isFirefox as nC,isWindows as sG}from"@excalidraw/common";import{KEYS as Zr}from"@excalidraw/common";import{SHAPES as cG}from"@excalidraw/element/shapes";import{isFirefox as QS,KEYS as s1}from"@excalidraw/common";import{SHAPES as tG}from"@excalidraw/element/shapes";import{Fragment as aG,jsx as Oe,jsxs as Kr}from"react/jsx-runtime";var oG=e=>Kr(aG,{children:[Oe("h3",{children:e.title}),Oe("div",{className:"HelpDialog__islands-container",children:e.children})]}),c1=e=>Kr("div",{className:`HelpDialog__island ${e.className}`,children:[Oe("h4",{className:"HelpDialog__island-title",children:e.caption}),Oe("div",{className:"HelpDialog__island-content",children:e.children})]});function*nG(e,o){let t=!0;for(let n of e)t||(yield o),t=!1,yield n}var rG=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),ct=({label:e,shortcuts:o,isOr:t=!0})=>{let n=o.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>Oe(iG,{children:rG(a)},a)));return Kr("div",{className:"HelpDialog__shortcut",children:[Oe("div",{children:e}),Oe("div",{className:"HelpDialog__key-container",children:[...nG(n,t?f("helpDialog.or"):null)]})]})},iG=e=>Oe("kbd",{className:"HelpDialog__key",...e});function d1(){return Kr(oG,{title:f("helpDialog.shortcuts"),children:[Kr(c1,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[Oe(ct,{label:f("toolBar.hand"),shortcuts:[s1.H]}),tG.filter(({myocSimplifiedMode:e})=>e).map(({value:e,key:o})=>Oe(ct,{label:f(`toolBar.${e}`),shortcuts:[...o]},e)),Oe(ct,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),Oe(ct,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0})]}),Kr(c1,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[Oe(ct,{label:f("helpDialog.smartZoom"),shortcuts:[s1.F]}),Oe(ct,{label:f("helpDialog.dragToZoom"),shortcuts:[`${s1.Z}+${f("helpDialog.drag")}`]}),Oe(ct,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]}),Oe(ct,{label:f("commandPalette.title"),shortcuts:QS?[Se("commandPalette")]:[Se("commandPalette"),Se("commandPalette",1)]})]}),Kr(c1,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[Oe(ct,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),Oe(ct,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),Oe(ct,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),Oe(ct,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(Vn||QS)&&Oe(ct,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),Oe(ct,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),Oe(ct,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),Oe(ct,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),Oe(ct,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),Oe(ct,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]})]})]})}import{Fragment as iC,jsx as V,jsxs as $r}from"react/jsx-runtime";var dG=e=>$r(iC,{children:[V("h3",{children:e.title}),V("div",{className:"HelpDialog__islands-container",children:e.children})]}),m1=e=>$r("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*mG(e,o){let t=!0;for(let n of e)t||(yield o),t=!1,yield n}var pG=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),j=({label:e,shortcuts:o,isOr:t=!0})=>{let n=o.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>V(uG,{children:pG(a)},a)));return $r("div",{className:"HelpDialog__shortcut",children:[V("div",{children:e}),V("div",{className:"HelpDialog__key-container",children:[...mG(n,t?f("helpDialog.or"):null)]})]})},uG=e=>V("kbd",{className:"HelpDialog__key",...e}),rC=({onClose:e})=>{let[o,t]=eC.useState(!1),n=eC.useCallback(()=>{e&&e()},[e]),r=lG(()=>o?V("button",{className:tC("toggle-button",{}),onClick:()=>t(!1),children:f("helpDialog.myoc.showingAll")}):V("button",{className:tC("toggle-button",{}),onClick:()=>t(!0),children:f("helpDialog.myoc.showingBasic")}),[o]);return V(iC,{children:V(qe,{onCloseRequest:n,title:f("helpDialog.title"),className:"HelpDialog",titleButton:r,portalContainerClassName:"HelpDialog__modalContainer",children:o?$r(dG,{title:f("helpDialog.shortcuts"),children:[$r(m1,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[V(j,{label:f("toolBar.hand"),shortcuts:[Zr.H]}),cG.map(({value:i,key:a})=>V(j,{label:f(`toolBar.${i}`),shortcuts:[...a]},i)),V(j,{label:f("toolBar.frame"),shortcuts:[Zr.F]}),V(j,{label:f("toolBar.laser"),shortcuts:[Zr.K]}),V(j,{label:f("labels.eyeDropper"),shortcuts:[Zr.I,"Shift+S","Shift+G"]}),V(j,{label:f("helpDialog.editLineArrowPoints"),shortcuts:[N("CtrlOrCmd+Enter")]}),V(j,{label:f("helpDialog.editText"),shortcuts:[N("Enter")]}),V(j,{label:f("helpDialog.textNewLine"),shortcuts:[N("Enter"),N("Shift+Enter")]}),V(j,{label:f("helpDialog.textFinish"),shortcuts:[N("Esc"),N("CtrlOrCmd+Enter")]}),V(j,{label:f("helpDialog.curvedArrow"),shortcuts:["A",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),V(j,{label:f("helpDialog.curvedLine"),shortcuts:["L",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),V(j,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),V(j,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0}),V(j,{label:f("toolBar.lock"),shortcuts:[Zr.Q]}),V(j,{label:f("helpDialog.preventBinding"),shortcuts:[N("CtrlOrCmd")]}),V(j,{label:f("toolBar.link"),shortcuts:[N("CtrlOrCmd+K")]}),V(j,{label:f("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),$r(m1,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[V(j,{label:f("helpDialog.smartZoom"),shortcuts:[Zr.F]}),V(j,{label:f("helpDialog.dragToZoom"),shortcuts:[`${Zr.Z}+${f("helpDialog.drag")}`]}),V(j,{label:f("buttons.zoomIn"),shortcuts:[N("CtrlOrCmd++")]}),V(j,{label:f("buttons.zoomOut"),shortcuts:[N("CtrlOrCmd+-")]}),V(j,{label:f("buttons.resetZoom"),shortcuts:[N("CtrlOrCmd+0")]}),V(j,{label:f("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),V(j,{label:f("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),V(j,{label:f("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),V(j,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]}),V(j,{label:f("labels.toggleGrid"),shortcuts:[N("CtrlOrCmd+'")]}),V(j,{label:f("labels.viewMode"),shortcuts:[N("Alt+R")]}),V(j,{label:f("stats.fullTitle"),shortcuts:[N("Alt+/")]}),V(j,{label:f("search.title"),shortcuts:[Se("searchMenu")]}),V(j,{label:f("commandPalette.title"),shortcuts:nC?[Se("commandPalette")]:[Se("commandPalette"),Se("commandPalette",1)]})]}),$r(m1,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[V(j,{label:f("labels.moveCanvas"),shortcuts:[N(`Space+${f("helpDialog.drag")}`),N(`Wheel+${f("helpDialog.drag")}`)],isOr:!0}),V(j,{label:f("labels.delete"),shortcuts:[N("Delete")]}),V(j,{label:f("labels.cut"),shortcuts:[N("CtrlOrCmd+X")]}),V(j,{label:f("labels.copy"),shortcuts:[N("CtrlOrCmd+C")]}),V(j,{label:f("labels.paste"),shortcuts:[N("CtrlOrCmd+V")]}),V(j,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),V(j,{label:f("labels.selectAll"),shortcuts:[N("CtrlOrCmd+A")]}),V(j,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),V(j,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),V(j,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(Vn||nC)&&V(j,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),V(j,{label:f("labels.sendToBack"),shortcuts:[oC?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")]}),V(j,{label:f("labels.bringToFront"),shortcuts:[oC?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")]}),V(j,{label:f("labels.sendBackward"),shortcuts:[N("CtrlOrCmd+[")]}),V(j,{label:f("labels.bringForward"),shortcuts:[N("CtrlOrCmd+]")]}),V(j,{label:f("labels.alignTop"),shortcuts:[N("CtrlOrCmd+Shift+Up")]}),V(j,{label:f("labels.alignBottom"),shortcuts:[N("CtrlOrCmd+Shift+Down")]}),V(j,{label:f("labels.alignLeft"),shortcuts:[N("CtrlOrCmd+Shift+Left")]}),V(j,{label:f("labels.alignRight"),shortcuts:[N("CtrlOrCmd+Shift+Right")]}),V(j,{label:f("labels.arrangeElements"),shortcuts:[N("Shift+R")]}),V(j,{label:f("labels.duplicateSelection"),shortcuts:[N("CtrlOrCmd+D"),N(`Alt+${f("helpDialog.drag")}`)]}),V(j,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),V(j,{label:f("buttons.undo"),shortcuts:[N("CtrlOrCmd+Z")]}),V(j,{label:f("buttons.redo"),shortcuts:sG?[N("CtrlOrCmd+Y"),N("CtrlOrCmd+Shift+Z")]:[N("CtrlOrCmd+Shift+Z")]}),V(j,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),V(j,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),V(j,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),V(j,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]}),V(j,{label:f("labels.showStroke"),shortcuts:[N("S")]}),V(j,{label:f("labels.showBackground"),shortcuts:[N("G")]}),V(j,{label:f("labels.showFonts"),shortcuts:[N("Shift+F")]}),V(j,{label:f("labels.decreaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+<")]}),V(j,{label:f("labels.increaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+>")]})]})]}):V(d1,{})})})};import{CANVAS_SEARCH_TAB as hG,DEFAULT_SIDEBAR as gG}from"@excalidraw/common";import{isFlowchartNodeElement as fG,isImageElement as aC,isLinearElement as lC,isLineElement as bG,isTextBindableContainer as EG,isTextElement as xG}from"@excalidraw/element";import{isNodeInFlowchart as yG}from"@excalidraw/element";import{jsx as p1}from"react/jsx-runtime";var Ie=e=>Array.isArray(e)?`<kbd>${e.map(N).join(" + ")}</kbd>`:`<kbd>${N(e)}</kbd>`,wG=({appState:e,isMobile:o,editorInterface:t,app:n})=>{let{activeTool:r,isResizing:i,isRotating:a,lastPointerDownWith:l}=e,s=e.multiElement!==null;if(e.openSidebar?.name===gG.name&&e.openSidebar.tab===hG&&e.searchMatches?.matches.length)return f("hints.dismissSearch",{shortcut:Ie("Escape")});if(e.openSidebar&&!t.canFitSidebar)return null;if(Mt(e))return f("hints.eraserRevert",{shortcut:Ie("Alt")});let c=n.scene.getSelectedElements(e);if(e.selectedLinearElement?.isDragging&&c[0]?.type==="arrow")return f("hints.arrowBindModifiers",{shortcut_1:Ie("Ctrl"),shortcut_2:Ie("Alt")});if(r.type==="arrow"||r.type==="line")return s?f("hints.linearElementMulti",{shortcut_1:Ie("Escape"),shortcut_2:Ie("Enter")}):r.type==="arrow"?f("hints.arrowTool",{shortcut:Ie("A")}):f("hints.linearElement");if(r.type==="freedraw")return f("hints.freeDraw");if(r.type==="text")return f("hints.text");if(r.type==="embeddable")return f("hints.embeddable");if(i&&l==="mouse"&&c.length===1){let m=c[0];return lC(m)&&m.points.length===2?f("hints.lockAngle",{shortcut:Ie("Shift")}):aC(m)?f("hints.resizeImage",{shortcut_1:Ie("Shift"),shortcut_2:Ie("Alt")}):f("hints.resize",{shortcut_1:Ie("Shift"),shortcut_2:Ie("Alt")})}if(a&&l==="mouse")return f("hints.rotate",{shortcut:Ie("Shift")});if(c.length===1&&xG(c[0]))return f("hints.text_selected",{shortcut:Ie("Enter")});if(e.editingTextElement)return f("hints.text_editing",{shortcut_1:Ie("Escape"),shortcut_2:Ie(["CtrlOrCmd","Enter"])});if(e.croppingElementId)return f("hints.leaveCropEditor",{shortcut_1:Ie("Enter"),shortcut_2:Ie("Escape")});if(c.length===1&&aC(c[0]))return f("hints.enterCropEditor",{shortcut:Ie("Enter")});if(r.type==="selection"){if(e.selectionElement&&!c.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return f("hints.deepBoxSelect",{shortcut:Ie("CtrlOrCmd")});if(or(n)&&e.selectedElementsAreBeingDragged)return f("hints.disableSnapping",{shortcut:Ie("CtrlOrCmd")});if(!c.length&&!o)return f("hints.canvasPanning",{shortcut_1:Ie(f("keys.mmb")),shortcut_2:Ie("Space")});if(c.length===1){if(lC(c[0]))return e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?f("hints.lineEditor_pointSelected",{shortcut_1:Ie("Delete"),shortcut_2:Ie(["CtrlOrCmd","D"])}):f("hints.lineEditor_nothingSelected",{shortcut_1:Ie("Shift"),shortcut_2:Ie("Alt")}):bG(c[0])?f("hints.lineEditor_line_info",{shortcut:Ie("Enter")}):f("hints.lineEditor_info",{shortcut_1:Ie("CtrlOrCmd"),shortcut_2:Ie(["CtrlOrCmd","Enter"])});if(!e.newElement&&!e.selectedElementsAreBeingDragged&&EG(c[0])){let m=f("hints.bindTextToElement",{shortcut:Ie("Enter")}),p=f("hints.createFlowchart",{shortcut:Ie(["CtrlOrCmd","\u2191\u2193"])});return fG(c[0])?yG(c[0],n.scene.getNonDeletedElementsMap())?[m,p]:[m,p]:m}}}return null},sC=({appState:e,isMobile:o,editorInterface:t,app:n})=>{let r=wG({appState:e,isMobile:o,editorInterface:t,app:n});if(!r)return null;let a=(Array.isArray(r)?r.map(l=>l.replace(/\. ?$/,"")).join(", "):r).split(/(<kbd>[^<]+<\/kbd>)/g).map((l,s)=>{if(s%2===1){let c=l[0]==="<"&&l.match(/^<kbd>([^<]+)<\/kbd>$/);return p1("kbd",{children:c?c[1]:l},s)}return l});return p1("div",{className:"HintViewer",children:p1("span",{children:a})})};import{useEffect as mC,useRef as pC,useState as jr}from"react";import{DEFAULT_EXPORT_PADDING as kG,EXPORT_IMAGE_TYPES as u1,isFirefox as PG,EXPORT_SCALES as MG,cloneJSON as uC}from"@excalidraw/common";import{useCallback as vG,useRef as IG,useState as TG}from"react";var SG=2e3,cC=()=>{let[e,o]=TG(null),t=IG(0),n=()=>{clearTimeout(t.current),o("success"),t.current=window.setTimeout(()=>{o(null)},SG)},r=vG(()=>{o(null)},[]);return{copyStatus:e,resetCopyStatus:r,onCopy:n}};import CG from"clsx";import{jsx as dC}from"react/jsx-runtime";var Ps=({title:e,name:o,checked:t,onChange:n,disabled:r=!1})=>dC("div",{className:CG("Switch",{toggled:t,disabled:r}),children:dC("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 ze,jsxs as mr}from"react/jsx-runtime";var AG=()=>mr("div",{children:[ze("h3",{children:f("canvasError.cannotShowPreview")}),ze("p",{children:ze("span",{children:f("canvasError.canvasTooBig")})}),mr("em",{children:["(",f("canvasError.canvasTooBigTip"),")"]})]}),LG=({appStateSnapshot:e,elementsSnapshot:o,files:t,actionManager:n,onExportImage:r,name:i,exportWithDarkMode:a})=>{let l=Pe(o,e),[s,c]=jr(i),[m,p]=jr(l),[d,u]=jr(e.exportBackground),[b,g]=jr(e.exportEmbedScene),[E,y]=jr(e.exportScale),v=pC(null),x=pC(0),[w,I]=jr(null),{onCopy:C,copyStatus:A,resetCopyStatus:k}=cC();mC(()=>{k()},[s,d,a,E,b,k]);let{exportedElements:L,exportingFrame:_}=Mr(o,e,m);return mC(()=>{let M=v.current;if(!M)return;let D=M.offsetWidth,z=M.offsetHeight;if(!D)return;let W=++x.current,O=()=>W!==x.current;return qi({elements:L,appState:{...e,name:s,exportBackground:d,exportWithDarkMode:a,exportScale:E,exportEmbedScene:b},files:t,exportPadding:kG,maxWidthOrHeight:Math.max(D,z),exportingFrame:_}).then(async K=>{if(!O()){try{await vr(K)}catch(Y){throw Y.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):Y}O()||(I(null),M.replaceChildren(K))}}).catch(K=>{O()||(console.error(K),I(K))}),()=>{x.current+=1}},[e,t,L,_,s,d,a,E,b]),mr("div",{className:"ImageExportModal",children:[ze("h3",{children:f("imageExportDialog.header")}),mr("div",{className:"ImageExportModal__preview",children:[ze("div",{className:"ImageExportModal__preview__canvas",ref:v,children:w&&ze(AG,{})}),ze("div",{className:"ImageExportModal__preview__filename",children:!ai&&ze("input",{type:"text",className:"TextInput",value:s,style:{width:"30ch"},onChange:M=>{c(M.target.value),n.executeAction(Ju,"ui",M.target.value)}})})]}),mr("div",{className:"ImageExportModal__settings",children:[ze("h3",{children:f("imageExportDialog.header")}),l&&ze(Ms,{label:f("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:ze(Ps,{name:"exportOnlySelected",checked:m,onChange:M=>{p(M)}})}),ze(Ms,{label:f("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:ze(Ps,{name:"exportBackgroundSwitch",checked:d,onChange:M=>{u(M),n.executeAction(Qu,"ui",M)}})}),ze(Ms,{label:f("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:ze(Ps,{name:"exportDarkModeSwitch",checked:a,onChange:M=>{n.executeAction(Ly,"ui",M)}})}),ze(Ms,{label:f("imageExportDialog.label.embedScene"),tooltip:f("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:ze(Ps,{name:"exportEmbedSwitch",checked:b,onChange:M=>{g(M),n.executeAction(dd,"ui",M)}})}),ze(Ms,{label:f("imageExportDialog.label.scale"),name:"exportScale",children:ze(_m,{name:"exportScale",value:E,onChange:M=>{y(M),n.executeAction(My,"ui",M)},choices:MG.map(M=>({value:M,label:`${M}\xD7`}))})}),mr("div",{className:"ImageExportModal__settings__buttons",children:[ze(ar,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToPng"),onClick:()=>r(u1.png,L,{exportingFrame:_}),icon:Kp,children:f("imageExportDialog.button.exportToPng")}),ze(ar,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToSvg"),onClick:()=>r(u1.svg,L,{exportingFrame:_}),icon:Kp,children:f("imageExportDialog.button.exportToSvg")}),(Vn||PG)&&ze(ar,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.copyPngToClipboard"),status:A,onClick:async()=>{await r(u1.clipboard,L,{exportingFrame:_}),C()},icon:hi,children:f("imageExportDialog.button.copyPngToClipboard")})]})]})]})},Ms=({label:e,children:o,tooltip:t,name:n})=>mr("div",{className:"ImageExportModal__settings__setting",title:e,children:[mr("label",{htmlFor:n,className:"ImageExportModal__settings__setting__label",children:[e,t&&ze(gt,{label:t,long:!0,children:h0})]}),ze("div",{className:"ImageExportModal__settings__setting__content",children:o})]}),hC=({elements:e,appState:o,files:t,actionManager:n,onExportImage:r,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:l,elementsSnapshot:s}]=jr(()=>({appStateSnapshot:uC(o),elementsSnapshot:uC(e)}));return ze(qe,{onCloseRequest:i,size:"wide",title:!1,children:ze(LG,{elementsSnapshot:s,appStateSnapshot:l,files:t,actionManager:n,onExportImage:r,name:a,exportWithDarkMode:o.exportWithDarkMode})})};import DG from"react";import{getFrame as RG}from"@excalidraw/common";import{jsx as _G}from"react/jsx-runtime";var h1={primary:{base:"var(--color-primary)",darker:"var(--color-primary-darker)",darkest:"var(--color-primary-darkest)"},lime:{base:"#74b816",darker:"#66a80f",darkest:"#5c940d"},pink:{base:"#d6336c",darker:"#c2255c",darkest:"#a61e4d"}},g1=({children:e,color:o})=>_G("div",{className:"Card",style:{"--card-color":h1[o].base,"--card-color-darker":h1[o].darker,"--card-color-darkest":h1[o].darkest},children:e});import{Fragment as BG,jsx as Po,jsxs as Jm}from"react/jsx-runtime";var NG=({elements:e,appState:o,setAppState:t,files:n,actionManager:r,exportOpts:i,canvas:a,onCloseRequest:l})=>{let{onExportToBackend:s}=i;return Po("div",{className:"ExportDialog ExportDialog--json",children:Jm("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&Jm(g1,{color:"lime",children:[Po("div",{className:"Card-icon",children:xE}),Po("h2",{children:f("exportDialog.disk_title")}),Jm("div",{className:"Card-details",children:[f("exportDialog.disk_details"),!ai&&r.renderAction("changeProjectName")]}),Po(Z,{className:"Card-button",type:"button",title:f("exportDialog.disk_button"),"aria-label":f("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{r.executeAction(Al,"ui")}})]}),s&&Jm(g1,{color:"pink",children:[Po("div",{className:"Card-icon",children:al}),Po("h2",{children:f("exportDialog.link_title")}),Po("div",{className:"Card-details",children:f("exportDialog.link_details")}),Po(Z,{className:"Card-button",type:"button",title:f("exportDialog.link_button"),"aria-label":f("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{ce("export","link",`ui (${RG()})`),await s(e,o,n),l()}catch(c){t({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,o,n,a)]})})},gC=({elements:e,appState:o,files:t,actionManager:n,exportOpts:r,canvas:i,setAppState:a})=>{let l=DG.useCallback(()=>{a({openDialog:null})},[a]);return Po(BG,{children:o.openDialog?.name==="jsonExport"&&Po(qe,{onCloseRequest:l,title:f("buttons.export"),children:Po(NG,{elements:e,appState:o,setAppState:a,files:t,actionManager:n,onCloseRequest:l,exportOpts:r,canvas:i})})})};import FG from"clsx";import{jsx as fC,jsxs as zG}from"react/jsx-runtime";var OG="small",bC=e=>zG("label",{className:FG("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${OG}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[fC("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),fC("div",{className:"ToolIcon__icon",children:fi})]});import{Fragment as yC,jsx as J,jsxs as zt}from"react/jsx-runtime";var KG=({UIOptions:e})=>zt(Ct,{__fallback:!0,children:[J(Ct.DefaultItems.LoadScene,{}),J(Ct.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&J(Ct.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&J(Ct.DefaultItems.SaveAsImage,{}),J(Ct.DefaultItems.SearchMenu,{}),J(Ct.DefaultItems.Help,{}),J(Ct.Separator,{}),J(Ct.Group,{title:"Excalidraw links",children:J(Ct.DefaultItems.Socials,{})}),J(Ct.Separator,{}),J(Ct.DefaultItems.ToggleTheme,{}),J(Ct.DefaultItems.ChangeCanvasBackground,{})]}),ZG=()=>zt(Bm,{__fallback:!0,children:[J(Bm.Actions.SaveToDisk,{}),J(Bm.Actions.ExportToImage,{})]}),$G=({actionManager:e,appState:o,files:t,setAppState:n,elements:r,canvas:i,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,showExitZenModeBtn:c,renderTopLeftUI:m,renderTopRightUI:p,renderCustomStats:d,UIOptions:u,onExportImage:b,renderWelcomeScreen:g,children:E,app:y,isCollaborating:v,generateLinkForSelection:x})=>{let w=pe(),C=nt()==="compact",A=Y3(),k=C?{menuTopGap:4,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:.5,islandPadding:1,collabMarginLeft:8}:{menuTopGap:6,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:1,islandPadding:1,collabMarginLeft:8},L=A.tunnelsJotai.Provider,[_,M]=fe(Bn),D=()=>u.canvasActions.export?J(gC,{elements:r,appState:o,files:t,actionManager:e,exportOpts:u.canvasActions.export,canvas:i,setAppState:n}):null,z=()=>!u.canvasActions.saveAsImage||o.openDialog?.name!=="imageExport"?null:J(hC,{elements:r,appState:o,files:t,actionManager:e,onExportImage:b,onCloseRequest:()=>n({openDialog:null}),name:y.getName()}),W=()=>zt("div",{style:{position:"relative"},children:[J(A.MainMenuTunnel.Out,{}),g&&J(A.WelcomeScreenMenuHintTunnel.Out,{})]}),O=()=>{let ae=C;return J(Es,{heading:"selectedShapeActions",className:qr("selected-shape-actions zen-mode-transition",{"transition-left":o.zenModeEnabled}),children:ae?J(We,{className:qr("compact-shape-actions-island"),padding:0,style:{maxHeight:`${o.height-166}px`},children:J(fv,{appState:o,elementsMap:y.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:y,setAppState:n})}):J(We,{className:GG.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${o.height-166}px`},children:J(mv,{appState:o,elementsMap:y.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:y})})})},K=()=>{let ae=VG(o,r),R=o.stats.open&&!o.zenModeEnabled&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector";return J(JS,{side:"top",children:zt("div",{className:"App-menu App-menu_top",children:[zt(bt.Col,{gap:k.menuTopGap,className:qr("App-menu_top__left"),children:[W(),J("div",{className:qr("selected-shape-actions-container",{"selected-shape-actions-container--compact":C}),children:ae&&O()})]}),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&J(Es,{heading:"shapes",className:"shapes-section",children:G=>zt("div",{style:{position:"relative"},children:[g&&J(A.WelcomeScreenToolbarHintTunnel.Out,{}),J(bt.Col,{gap:k.toolbarColGap,align:"start",children:zt(bt.Row,{gap:k.toolbarRowGap,className:qr("App-toolbar-container",{"zen-mode":o.zenModeEnabled}),children:[zt(We,{padding:k.islandPadding,className:qr("App-toolbar",{"zen-mode":o.zenModeEnabled,"App-toolbar--compact":C}),children:[J(sC,{appState:o,isMobile:w.formFactor==="phone",editorInterface:w,app:y}),G,zt(bt.Row,{gap:k.toolbarInnerRowGap,children:[J(iT,{zenModeEnabled:o.zenModeEnabled,checked:o.penMode,onChange:()=>s(null),title:f("toolBar.penMode"),penDetected:o.penDetected}),J(Sm,{checked:bo(o),onChange:l,title:f("toolBar.hand")}),J(Ev,{setAppState:n,activeTool:o.activeTool,UIOptions:u,app:y})]})]}),v&&J(We,{style:{marginLeft:k.collabMarginLeft,alignSelf:"center",height:"fit-content"},children:J(bC,{title:f("toolBar.laser"),checked:o.activeTool.type===EC.laser,onChange:()=>y.setActiveTool({type:EC.laser}),isMobile:!0})})]})})]})}),zt("div",{className:qr("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":o.zenModeEnabled,"layer-ui__wrapper__top-right--compact":C}),children:[o.collaborators.size>0&&J(Am,{collaborators:o.collaborators,userToFollow:o.userToFollow?.socketId||null}),p?.(w.formFactor==="phone",o),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&(!q||o.openSidebar?.name!==f1.name)&&J(A.DefaultSidebarTriggerTunnel.Out,{}),R&&J(ks,{app:y,onClose:()=>{e.executeAction(Kn)},renderCustomStats:d})]})]})})},Y=()=>J(zm,{__fallback:!0,onDock:ae=>{ce("sidebar",`toggleDock (${ae?"dock":"undock"})`,`(${w.formFactor==="phone"?"mobile":"desktop"})`)}}),q=nc(ys),ne=zt(yC,{children:[E,J(KG,{UIOptions:u}),J(zm.Trigger,{__fallback:!0,icon:z0,title:WG(f("toolBar.library")),onToggle:ae=>{ae&&ce("sidebar",`${f1.name} (open)`,`button (${w.formFactor==="phone"?"mobile":"desktop"})`)},tab:f1.defaultTab}),J(ZG,{}),o.isLoading&&J(Tm,{delay:250}),o.errorMessage&&J(qS,{onClose:()=>n({errorMessage:null}),children:o.errorMessage}),_&&w.formFactor!=="phone"&&J(ox,{colorPickerType:_.colorPickerType,onCancel:()=>{M(null)},onChange:(ae,R,G,{altKey:ie})=>{if(!(ae!=="elementBackground"&&ae!=="elementStroke"))if(G.length){for(let ge of G)YG(ge,UG(r),{[ie&&_.swapPreviewOnAlt?ae==="elementBackground"?"strokeColor":"backgroundColor":ae==="elementBackground"?"backgroundColor":"strokeColor"]:R}),XG.delete(ge);y.scene.triggerUpdate()}else n(ae==="elementBackground"?{currentItemBackgroundColor:R}:{currentItemStrokeColor:R})},onSelect:(ae,R)=>{M(G=>G?.keepOpenOnAlt&&R.altKey?G:null),_?.onSelect?.(ae,R)}}),o.openDialog?.name==="help"&&J(rC,{onClose:()=>{n({openDialog:null})}}),o.openDialog?.name==="elementLinkSelector"&&J(jS,{sourceElementId:o.openDialog.sourceElementId,onClose:()=>{n({openDialog:null})},scene:y.scene,appState:o,generateLinkForSelection:x}),J(A.OverwriteConfirmDialogTunnel.Out,{}),z(),D(),o.openDialog?.name==="charts"&&J(tT,{data:o.openDialog.data,rawText:o.openDialog.rawText,onClose:()=>n({openDialog:null})}),w.formFactor==="phone"&&J($3,{app:y,appState:o,elements:r,actionManager:e,renderJSONExportDialog:D,renderImageExportDialog:z,setAppState:n,onHandToolToggle:l,onPenModeToggle:s,renderTopLeftUI:m,renderTopRightUI:p,renderSidebars:Y,renderWelcomeScreen:g,UIOptions:u}),w.formFactor!=="phone"&&zt(yC,{children:[zt("div",{className:"layer-ui__wrapper",style:o.openSidebar&&q&&w.canFitSidebar?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[g&&J(A.WelcomeScreenCenterTunnel.Out,{}),K(),J(sT,{appState:o,actionManager:e,showExitZenModeBtn:c,renderWelcomeScreen:g}),(o.toast||o.scrolledOutside)&&zt("div",{className:"floating-status-stack",children:[o.toast&&J(Ri,{message:o.toast.message,onClose:()=>n({toast:null}),duration:o.toast.duration,closable:o.toast.closable}),!o.toast&&o.scrolledOutside&&J("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{n(ae=>({...xr(r,ae)}))},children:f("buttons.scrollBackToContent")})]})]}),Y()]})]});return J(mu.Provider,{value:o,children:J(L,{children:J(bf.Provider,{value:A,children:ne})})})},xC=e=>{let{cursorButton:o,scrollX:t,scrollY:n,...r}=e;return r},jG=(e,o)=>{if(e.children!==o.children)return!1;let{canvas:t,appState:n,...r}=e,{canvas:i,appState:a,...l}=o;return Qm(xC(n),xC(a),{selectedElementIds:Qm,selectedGroupIds:Qm})&&Qm(r,l)},wC=HG.memo($G,jG);import qG from"clsx";import{jsx as vC,jsxs as QG}from"react/jsx-runtime";var JG="small",b1=e=>QG("label",{className:qG("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${JG}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[vC("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),vC("div",{className:"ToolIcon__icon",children:e.icon})]});import{useEffect as eU,useRef as tU}from"react";import{jsx as IC}from"react/jsx-runtime";var TC=({trails:e})=>{let o=tU(null);return eU(()=>{if(o.current)for(let t of e)t.start(o.current);return()=>{for(let t of e)t.stop()}},e),IC("div",{className:"SVGLayer",children:IC("svg",{ref:o})})};import UU,{useEffect as WU,useRef as GC}from"react";import{CURSOR_TYPE as UC,isShallowEqual as YU,sceneCoordsToViewportCoords as VU}from"@excalidraw/common";import{clamp as w1,pointFrom as Na,pointsEqual as sU,bezierEquation as NC,pointRotateRads as ep,pointDistance as cU}from"@excalidraw/math";import{arrayToMap as dU,BIND_MODE_TIMEOUT as As,DEFAULT_TRANSFORM_HANDLE_SPACING as BC,FRAME_STYLE as uo,getFeatureFlag as mU,invariant as MC,THEME as pr}from"@excalidraw/common";import{deconstructDiamondElement as v1,deconstructRectanguloidElement as FC,elementCenterPoint as Ba,getDiamondBaseCorners as pU,FOCUS_POINT_SIZE as uU,getOmitSidesForEditorInterface as E1,getTransformHandles as hU,getTransformHandlesFromCoords as gU,hasBoundingBox as fU,hitElementItself as bU,isArrowElement as EU,isBindableElement as OC,isElbowArrow as Fa,isFrameLikeElement as Oa,isImageElement as AC,isLinearElement as xU,isLineElement as yU,maxBindingDistance_simple as wU,isTextElement as vU,getActiveTextElement as IU}from"@excalidraw/element";import{LinearElementEditor as Zo}from"@excalidraw/element/linearElementEditor";import{renderSelectionElement as TU}from"@excalidraw/element";import{getElementsInGroup as I1,getSelectedGroupIds as SU,isSelectedViaGroup as CU,selectGroupsFromGivenElements as kU}from"@excalidraw/element";import{getCommonBounds as T1,getElementAbsoluteCoords as tp}from"@excalidraw/element";import{getGlobalFixedPointForBindableElement as LC,isFocusPointVisible as PU}from"@excalidraw/element";import{pointFrom as Et}from"@excalidraw/math";import{THEME as oU}from"@excalidraw/common";var nU="#ff6b6b",rU="#ff0000",SC=1,CC=2,kC=(e,o)=>{if(!o.snapLines.length)return;let t=o.theme===oU.LIGHT||o.zenModeEnabled?nU:rU,n=(o.zenModeEnabled?SC*1.5:SC)/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,aU(r,e,o)):r.type==="gap"?(e.lineWidth=n,e.strokeStyle=t,lU(r.points[0],r.points[1],r.direction,o,e)):r.type==="points"&&(e.lineWidth=n,e.strokeStyle=t,iU(r,e,o));e.restore()},iU=(e,o,t)=>{if(!t.zenModeEnabled){let n=e.points[0],r=e.points[e.points.length-1];po(n,r,o)}for(let n of e.points)PC(n,t,o)},aU=(e,o,t)=>{PC(e.points[0],t,o),t.zenModeEnabled||po(e.points[0],e.points[1],o)},PC=([e,o],t,n)=>{n.save();let r=(t.zenModeEnabled?CC*1.5:CC)/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()},po=(e,o,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(o[0],o[1]),t.stroke()},lU=(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||po(Et(e[0],e[1]-i),Et(e[0],e[1]+i),r),po(Et(s[0]-l,s[1]-a),Et(s[0]-l,s[1]+a),r),po(Et(s[0]+l,s[1]-a),Et(s[0]+l,s[1]+a),r),n.zenModeEnabled||(po(Et(o[0],o[1]-i),Et(o[0],o[1]+i),r),po(e,o,r))}else{let s=[e[0],(e[1]+o[1])/2];n.zenModeEnabled||po(Et(e[0]-i,e[1]),Et(e[0]+i,e[1]),r),po(Et(s[0]-a,s[1]-l),Et(s[0]+a,s[1]-l),r),po(Et(s[0]-a,s[1]+l),Et(s[0]+a,s[1]+l),r),n.zenModeEnabled||(po(Et(o[0]-i,o[1]),Et(o[0]+i,o[1]),r),po(e,o,r))}};var MU=(e,o)=>{MC(o.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=o.selectedLinearElement;MC(t,"midPointCoords is null"),e.save(),e.translate(o.scrollX,o.scrollY),S1(t,e,o),e.restore()},AU=(e,o,t)=>{let{elementId:n,hoverPointIndex:r}=o.selectedLinearElement;if(o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(r)||o.selectedLinearElement?.isDragging)return;let i=Zo.getElement(n,t);if(!i)return;let a=Zo.getPointAtIndexGlobalCoordinates(i,r,t);e.save(),e.translate(o.scrollX,o.scrollY),S1(a,e,o),e.restore()},S1=(e,o,t)=>{o.fillStyle="rgba(105, 101, 219, 0.4)",Qa(o,e[0],e[1],Zo.POINT_HANDLE_SIZE/t.zoom.value,!1)},LU=(e,o,t)=>{e.save(),e.translate(o.scrollX,o.scrollY),S1(t,e,o),e.restore()},x1=(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)"),Qa(e,t[0],t[1],(a?n*(o.selectedLinearElement?.isEditing?1.5:2):n)/o.zoom.value,!i,!a||r)},_U=(e,o,t,n,r)=>{let i=o.element.frameId&&t.get(o.element.frameId);switch(i&&Oa(i)&&(e.translate(i.x,i.y),e.beginPath(),uo.radius&&e.roundRect?e.roundRect(-1,-1,i.width+1,i.height+1,uo.radius/n.zoom.value):e.rect(-1,-1,i.width+1,i.height+1),e.clip(),e.translate(-i.x,-i.y)),o.element.type){case"magicframe":case"frame":e.save(),e.translate(o.element.x,o.element.y),e.lineWidth=uo.strokeWidth/n.zoom.value,e.strokeStyle=n.theme===pr.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",uo.radius&&e.roundRect?(e.beginPath(),e.roundRect(0,0,o.element.width,o.element.height,uo.radius/n.zoom.value),e.stroke(),e.closePath()):e.strokeRect(0,0,o.element.width,o.element.height),e.restore();break;default:e.save();let a=Ba(o.element,t);switch(e.translate(a[0],a[1]),e.rotate(o.element.angle),e.translate(-a[0],-a[1]),e.translate(o.element.x,o.element.y),e.lineWidth=w1(1.75,o.element.strokeWidth,4)/Math.max(.25,n.zoom.value),e.strokeStyle=n.theme===pr.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",o.element.type){case"ellipse":e.beginPath(),e.ellipse(o.element.width/2,o.element.height/2,o.element.width/2,o.element.height/2,0,0,2*Math.PI),e.closePath(),e.stroke();break;case"diamond":{let[l,s]=v1(o.element);l.forEach(c=>{e.beginPath(),e.moveTo(c[0][0]-o.element.x,c[0][1]-o.element.y),e.lineTo(c[1][0]-o.element.x,c[1][1]-o.element.y),e.stroke()}),s.forEach(c=>{let[m,p,d,u]=c;e.beginPath(),e.moveTo(m[0]-o.element.x,m[1]-o.element.y),e.bezierCurveTo(p[0]-o.element.x,p[1]-o.element.y,d[0]-o.element.x,d[1]-o.element.y,u[0]-o.element.x,u[1]-o.element.y),e.stroke()})}break;default:{let[l,s]=FC(o.element);l.forEach(c=>{e.beginPath(),e.moveTo(c[0][0]-o.element.x,c[0][1]-o.element.y),e.lineTo(c[1][0]-o.element.x,c[1][1]-o.element.y),e.stroke()}),s.forEach(c=>{let[m,p,d,u]=c;e.beginPath(),e.moveTo(m[0]-o.element.x,m[1]-o.element.y),e.bezierCurveTo(p[0]-o.element.x,p[1]-o.element.y,d[0]-o.element.x,d[1]-o.element.y,u[0]-o.element.x,u[1]-o.element.y),e.stroke()})}break}e.restore();break}if(n.isMidpointSnappingEnabled&&(Oa(o.element)||OC(o.element))){let a=n.selectedLinearElement,l=a?.elementId&&Zo.getElement(a?.elementId,t),s=r&&bU({point:r,element:o.element,elementsMap:t,threshold:0,overrideShouldTestInside:!0}),c=l&&Fa(l)||n.activeTool.type==="arrow"&&n.currentItemArrowType==="elbow";if(!s||c){e.save();let m=Ba(o.element,t),p;if(o.element.type==="diamond"){let g=Ba(o.element,t);p=pU(o.element).map(E=>{let y=NC(E,.5),v=ep(y,g,o.element.angle);return Na(v[0],v[1])})}else p=[{x:o.element.width,y:o.element.height/2},{x:o.element.width/2,y:o.element.height},{x:0,y:o.element.height/2},{x:o.element.width/2,y:0}].map(E=>{let y=Na(E.x+o.element.x,E.y+o.element.y),v=ep(y,m,o.element.angle);return Na(v[0],v[1])});let d=r&&p.reduce((g,E,y)=>{let v=cU(E,r);return y===-1||v<g.distance?{idx:y,distance:v}:g},{idx:-1,distance:1/0}),u=4/n.zoom.value,b=wU(n.zoom)+o.element.strokeWidth/2;p.forEach((g,E)=>{let y=(!s||c)&&d?.idx===E&&d.distance<=b,v=!y&&(c||E===d?.idx&&d.distance<=b*2);y?(e.fillStyle=n.theme===pr.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",e.beginPath(),e.arc(g[0],g[1],u,0,2*Math.PI),e.fill()):v&&(e.fillStyle=n.theme===pr.DARK?"rgba(0, 0, 0, 0.8)":"rgba(65, 65, 65, 0.5)",e.beginPath(),e.arc(g[0],g[1],u,0,2*Math.PI),e.fill())}),e.restore()}}},DU=(e,o,t,n,r,i,a)=>{let l=e.state.bindMode==="orbit"&&e.bindModeHandler!==null,s=As-(a?.runtime??(l?0:As)),c=w1(1/As*s,1e-4,1),m=t.strokeWidth/2,p=t.frameId&&n.get(t.frameId);switch(p&&Oa(p)&&(o.translate(p.x,p.y),o.beginPath(),uo.radius&&o.roundRect?o.roundRect(-1,-1,p.width+1,p.height+1,uo.radius/r.zoom.value):o.rect(-1,-1,p.width+1,p.height+1),o.clip(),o.translate(-p.x,-p.y)),t.type){case"magicframe":case"frame":o.save(),o.translate(t.x,t.y),o.lineWidth=uo.strokeWidth/r.zoom.value,o.strokeStyle=r.theme===pr.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,uo.radius&&o.roundRect?(o.beginPath(),o.roundRect(0,0,t.width,t.height,uo.radius/r.zoom.value),o.stroke(),o.closePath()):o.strokeRect(0,0,t.width,t.height),o.restore();break;default:o.save();let u=Ba(t,n),b=u[0]+r.scrollX,g=u[1]+r.scrollY;switch(o.translate(b,g),o.rotate(t.angle),o.translate(-b,-g),o.translate(t.x+r.scrollX-m,t.y+r.scrollY-m),o.lineWidth=w1(2.5,t.strokeWidth*1.75,4)/Math.max(.25,r.zoom.value),o.strokeStyle=r.theme===pr.DARK?`rgba(3, 93, 161, ${c/2})`:`rgba(106, 189, 252, ${c/2})`,t.type){case"ellipse":o.beginPath(),o.ellipse((t.width+m*2)/2,(t.height+m*2)/2,(t.width+m*2)/2,(t.height+m*2)/2,0,0,2*Math.PI),o.closePath(),o.stroke();break;case"diamond":{let[E,y]=v1(t,m);E.forEach(v=>{o.beginPath(),o.moveTo(v[0][0]-t.x+m,v[0][1]-t.y+m),o.lineTo(v[1][0]-t.x+m,v[1][1]-t.y+m),o.stroke()}),y.forEach(v=>{let[x,w,I,C]=v;o.beginPath(),o.moveTo(x[0]-t.x+m,x[1]-t.y+m),o.bezierCurveTo(w[0]-t.x+m,w[1]-t.y+m,I[0]-t.x+m,I[1]-t.y+m,C[0]-t.x+m,C[1]-t.y+m),o.stroke()})}break;default:{let[E,y]=FC(t,m);E.forEach(v=>{o.beginPath(),o.moveTo(v[0][0]-t.x+m,v[0][1]-t.y+m),o.lineTo(v[1][0]-t.x+m,v[1][1]-t.y+m),o.stroke()}),y.forEach(v=>{let[x,w,I,C]=v;o.beginPath(),o.moveTo(x[0]-t.x+m,x[1]-t.y+m),o.bezierCurveTo(w[0]-t.x+m,w[1]-t.y+m,I[0]-t.x+m,I[1]-t.y+m,C[0]-t.x+m,C[1]-t.y+m),o.stroke()})}break}o.restore();break}if(!l||(a?.runtime??0)>As)return;let d=.5*(Math.min(t.width,t.height)/2);if(!Oa(t)){o.save(),o.translate(t.x+r.scrollX,t.y+r.scrollY);let u=1/As*s;if(o.strokeStyle="rgba(0, 0, 0, 0.2)",o.lineWidth=1/r.zoom.value,o.setLineDash([4/r.zoom.value,4/r.zoom.value]),o.lineDashOffset=-u*10/r.zoom.value,o.beginPath(),o.ellipse(t.width/2,t.height/2,d,d,0,0,2*Math.PI),o.stroke(),o.fillStyle="rgba(0, 0, 0, 0.04)",o.beginPath(),o.ellipse(t.width/2,t.height/2,d*(1-c),d*(1-c),0,0,2*Math.PI),o.fill(),o.restore(),r.isMidpointSnappingEnabled){o.save(),o.translate(t.x+r.scrollX,t.y+r.scrollY);let b=5/r.zoom.value,g=5/r.zoom.value,E=b+g,y;if(t.type==="diamond"){let[,v]=v1(t),x=Ba(t,n);y=v.map(w=>{let I=NC(w,.5),C=ep(I,x,t.angle);return{x:C[0]-t.x,y:C[1]-t.y}})}else{let v=Ba(t,n);y=[{x:t.width/2,y:0},{x:t.width,y:t.height/2},{x:t.width/2,y:t.height},{x:0,y:t.height/2}].map(w=>{let I=Na(w.x+t.x,w.y+t.y),C=ep(I,v,t.angle);return{x:C[0]-t.x,y:C[1]-t.y}})}y.forEach(v=>{o.clearRect(v.x-E,v.y-E,E*2,E*2)}),o.fillStyle=r.theme===pr.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,y.forEach(v=>{o.beginPath(),o.arc(v.x,v.y,b,0,2*Math.PI),o.fill()}),o.restore()}}return{runtime:(a?.runtime??0)+i}},RU=(e,o,t,n,r,i,a)=>{if(t===null)return;if(mU("COMPLEX_BINDINGS"))return DU(e,o,t.element,n,r,i,a);o.save(),o.translate(r.scrollX,r.scrollY);let l=e.lastPointerMoveCoords?Na(e.lastPointerMoveCoords.x,e.lastPointerMoveCoords.y):null;_U(o,t,n,r,l),o.restore()},zC=(e,o,t)=>{let{angle:n,x1:r,y1:i,x2:a,y2:l,selectionColors:s,cx:c,cy:m,dashed:p,activeEmbeddable:d}=t,u=a-r,b=l-i,E=(t.padding??BC*2)/o.zoom.value,y=8/o.zoom.value,v=4/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=(d?4:1)/o.zoom.value;let x=s.length;for(let w=0;w<x;++w)e.strokeStyle=s[w],p&&e.setLineDash([y,v+(y+v)*(x-1)]),e.lineDashOffset=(y+v)*w,el(e,r-E,i-E,u+E*2,b+E*2,c,m,n);e.restore()},NU=(e,o,t,n)=>{let[r,i,a,l]=tp(t,n),s=a-r,c=l-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=uo.strokeWidth/o.zoom.value,e.save(),e.translate(o.scrollX,o.scrollY),el(e,r,i,s,c,r+s/2,i+c/2,t.angle,!1,uo.radius/o.zoom.value),e.restore()},_C=(e,o,t,n)=>{let{colors:r=["rgb(0,118,255)"],dashed:i=!1}=n||{},a=t.filter(m=>m.groupIds.length===0),l=t.filter(m=>m.groupIds.length>0),s=m=>{let[p,d,u,b]=T1(m);return{angle:0,x1:p,x2:u,y1:d,y2:b,selectionColors:r,dashed:i,cx:p+(u-p)/2,cy:d+(b-d)/2,activeEmbeddable:!1}},c=m=>{let p=I1(t,m);return s(p)};Object.entries(kU(l,o)).filter(([m,p])=>p).map(([m,p])=>m).map(m=>c(m)).concat(a.map(m=>s([m]))).forEach(m=>zC(e,o,m))},y1=(e,o,t,n)=>{if(!o.selectedLinearElement)return;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=1/o.zoom.value;let r=Zo.getPointsGlobalCoordinates(t,n),{POINT_HANDLE_SIZE:i}=Zo,a=o.selectedLinearElement?.isEditing?i:i/2,l=Fa(t),s=yU(t);if(r.forEach((c,m)=>{if(l&&m!==0&&m!==r.length-1)return;let p=m>0&&(m!==r.length-1||!s||!t.polygon)&&sU(c,m===r.length-1?r[0]:r[m-1],2/o.zoom.value),d=!!o.selectedLinearElement?.isEditing&&!!o.selectedLinearElement?.selectedPointsIndices?.includes(m);s&&t.polygon&&!d&&m===t.points.length-1&&o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(d=!0),x1(e,o,c,a,d,!1,p)}),Fa(t)){let c=t.fixedSegments?.map(m=>m.index)||[];r.slice(0,-1).forEach((m,p)=>{Zo.isSegmentTooShort(t,r[p+1],r[p],p,o.zoom,n)||x1(e,o,Na((m[0]+r[p+1][0])/2,(m[1]+r[p+1][1])/2),i/2,!1,!c.includes(p+1),!1)})}else Zo.getEditorMidPoints(t,n,o).filter((m,p,d)=>m!==null&&!(Fa(t)&&(p===0||p===d.length-1))).forEach(m=>{(o.selectedLinearElement?.isEditing||r.length===2)&&x1(e,o,m,i/2,!1,!0,!1)});e.restore()},BU=(e,o,t,n)=>{e.save(),e.translate(o.scrollX,o.scrollY),e.strokeStyle="rgba(134, 131, 226, 0.6)",e.lineWidth=1/o.zoom.value,e.setLineDash([4/o.zoom.value,4/o.zoom.value]),e.beginPath(),e.moveTo(t[0],t[1]),e.lineTo(n[0],n[1]),e.stroke(),e.restore()},FU=(e,o,t,n,r)=>{e.save(),e.translate(o.scrollX,o.scrollY),e.strokeStyle="rgba(134, 131, 226, 0.6)",e.lineWidth=1/o.zoom.value,e.setLineDash([]),e.fillStyle=r?"rgba(134, 131, 226, 0.9)":"rgba(255, 255, 255, 0.9)",Qa(e,t[0],t[1],n/o.zoom.value,!0,!0),e.restore()},DC=({arrow:e,appState:o,type:t,context:n,elementsMap:r})=>{let i=t==="start"?e.startBinding:e.endBinding,a=i?.elementId&&r.get(i.elementId);if(!a||!OC(a)||a.isDeleted)return;let l=LC(i.fixedPoint,a,r);if(!PU(l,e,a,r,o,t))return;let s=o.selectedLinearElement,c=!!s?.isDragging,m=t==="start"?0:e.points.length-1,p=!!s?.selectedPointsIndices?.includes(m);if(s?.hoveredFocusPointBinding===t&&!s.draggedFocusPointBinding&&LU(n,o,l),!(p&&c)){let d=LC(i.fixedPoint,a,r),u=s?.hoveredFocusPointBinding===t,b=Zo.getPointAtIndexGlobalCoordinates(e,m,r);BU(n,o,b,d),FU(n,o,d,uU/1.5,u)}},RC=(e,o,t,n,r)=>{Object.keys(n).forEach(i=>{let a=n[i];if(a!==void 0){let[l,s,c,m]=a;e.save(),e.lineWidth=1/t.zoom.value,o.selectionColor&&(e.strokeStyle=o.selectionColor),i==="rotation"?Qa(e,l+c/2,s+m/2,c/2,!0):e.roundRect?(e.beginPath(),e.roundRect(l,s,c,m,2/t.zoom.value),e.fill(),e.stroke()):el(e,l,s,c,m,l+c/2,s+m/2,r,!0),e.restore()}})},OU=(e,o,t,n,r)=>{let[i,a,,,l,s]=tp(n,r),c=3,m=20,p=c/t.zoom.value,d=p/2,u=l-i+p,b=s-a+p,g=Math.min(m/t.zoom.value,u),E=Math.min(m/t.zoom.value,b);e.save(),e.fillStyle=o.selectionColor,e.strokeStyle=o.selectionColor,e.lineWidth=p,[[[-u,-b],[0,d],[g,d],[d,0],[d,E]],[[u-d,-b],[d,d],[-g+d,d],[0,0],[0,E]],[[-u,b],[0,-d],[g,-d],[d,0],[d,-E]],[[u-d,b],[d,-d],[-g+d,-d],[0,0],[0,-E]]].forEach(v=>{let[[x,w],[I,C],[A,k],[L,_],[M,D]]=v;e.save(),e.translate(l,s),e.rotate(n.angle),e.beginPath(),e.moveTo(x+I,w+C),e.lineTo(x+A,w+k),e.stroke(),e.beginPath(),e.moveTo(x+L,w+_),e.lineTo(x+M,w+D),e.stroke(),e.restore()}),e.restore()},zU=(e,o,t,n)=>{o.save();let r=Xg(t.zoom.value),i=e.width+r*2,a=e.height+r*2,l=e.x+e.width/2,s=e.y+e.height/2,c=-(e.width/2+r),m=-(e.height/2+r);o.translate(l+t.scrollX,s+t.scrollY),o.rotate(e.angle),o.lineWidth=1/t.zoom.value,o.strokeStyle=n,o.globalAlpha=.5,o.setLineDash([6/t.zoom.value,4/t.zoom.value]),o.strokeRect(c,m,i,a),o.restore()},HU=(e,o,t,n,r)=>{let i=Kg(e,t.zoom.value,r);i&&(o.save(),o.globalAlpha=.5,o.lineWidth=1.5/t.zoom.value,o.lineCap="round",o.strokeStyle=n,o.beginPath(),o.moveTo(i.start[0]+t.scrollX,i.start[1]+t.scrollY),o.lineTo(i.end[0]+t.scrollX,i.end[1]+t.scrollY),o.stroke(),o.restore())},GU=({app:e,canvas:o,elementsMap:t,visibleElements:n,selectedElements:r,allElementsMap:i,scale:a,appState:l,renderConfig:s,editorInterface:c,animationState:m,deltaTime:p})=>{if(o===null)return{atLeastOneVisibleElement:!1,elementsMap:t};let[d,u]=Js(o,a),b=m,g=Qs({canvas:o,scale:a,normalizedWidth:d,normalizedHeight:u});g.save(),g.scale(l.zoom.value,l.zoom.value);let E;if(n.forEach(C=>{l.selectedLinearElement?.isEditing&&l.selectedLinearElement.elementId===C.id&&C&&(E=C)}),E&&y1(g,l,E,t),l.selectionElement&&!l.isCropping)try{TU(l.selectionElement,g,l,s.selectionColor)}catch(C){console.error(C)}let y=IU(r,l);if(y&&!y.autoResize&&HU(y,g,l,s.selectionColor,c.formFactor),l.editingTextElement){let C=i.get(l.editingTextElement.id);C&&!C.autoResize&&zU(C,g,l,s.selectionColor)}if(l.isBindingEnabled&&l.suggestedBinding?b={...m,bindingHighlight:RU(e,g,l.suggestedBinding,i,l,p,m?.bindingHighlight)}:b={...m,bindingHighlight:void 0},l.frameToHighlight&&NU(g,l,l.frameToHighlight,t),l.elementsToHighlight&&_C(g,l,l.elementsToHighlight),l.activeLockedId){let C=i.get(l.activeLockedId),A=C?[C]:I1(i,l.activeLockedId);_C(g,l,A,{colors:["#ced4da"],dashed:!0})}let v=r.some(C=>Oa(C));r.length===1&&l.selectedLinearElement?.isEditing&&l.selectedLinearElement.elementId===r[0].id&&y1(g,l,r[0],t);let x=l.selectedLinearElement,w=x&&Zo.getElement(x.elementId,i);if(w&&(l.selectedLinearElement.isDragging||(x.segmentMidPointHoveredCoords?MU(g,l):(Fa(w)?x.hoverPointIndex===0||x.hoverPointIndex===w.points.length-1:x.hoverPointIndex>=0)&&AU(g,l,t)),EU(w)&&(DC({arrow:w,elementsMap:i,appState:l,context:g,type:"start"}),DC({arrow:w,elementsMap:i,appState:l,context:g,type:"end"}))),!l.multiElement&&!l.newElement&&!l.selectedLinearElement?.isEditing){let C=fU(r,l,c),A=r.length===1&&xU(r[0]);A&&l.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&y1(g,l,r[0],t);let k=s.selectionColor||"#000";if(C){let L=dU(r),_=[];for(let D of t.values()){let z=[],W=s.remoteSelectedElementIds.get(D.id);if(A&&Fa(D)&&(D.startBinding||D.endBinding)||(L.has(D.id)&&!CU(l,D)&&z.push(k),W&&z.push(...W.map(O=>Dr(O,l.collaborators.get(O))))),z.length){let[O,K,Y,q,ne,ae]=tp(D,t,!0);_.push({angle:D.angle,x1:O,y1:K,x2:Y,y2:q,selectionColors:D.locked?["#ced4da"]:z,dashed:!!W||D.locked,cx:ne,cy:ae,activeEmbeddable:l.activeEmbeddable?.element===D&&l.activeEmbeddable.state==="active",padding:D.id===l.croppingElementId||AC(D)?0:void 0})}}let M=D=>{let z=I1(t,D),[W,O,K,Y]=T1(z);_.push({angle:0,x1:W,x2:K,y1:O,y2:Y,selectionColors:z.some(q=>q.locked)?["#ced4da"]:["#000"],dashed:!0,cx:W+(K-W)/2,cy:O+(Y-O)/2,activeEmbeddable:!1})};for(let D of SU(l))M(D);l.editingGroupId&&M(l.editingGroupId),_.forEach(D=>zC(g,l,D))}if(g.save(),g.translate(l.scrollX,l.scrollY),r.length===1){g.fillStyle="#fff";let L=hU(r[0],l.zoom,t,"mouse",E1(c));if(!l.viewModeEnabled&&C&&!vU(l.editingTextElement)&&!l.croppingElementId&&RC(g,s,l,L,r[0].angle),l.croppingElementId&&!l.isCropping){let _=t.get(l.croppingElementId);_&&AC(_)&&OU(g,s,l,_,t)}}else if(r.length>1&&!l.isRotating&&!r.some(L=>L.locked)){let L=BC*2/l.zoom.value;g.fillStyle="#fff";let[_,M,D,z]=T1(r,t),W=g.getLineDash();g.setLineDash([2/l.zoom.value]);let O=g.lineWidth;g.lineWidth=1/l.zoom.value,g.strokeStyle=k,el(g,_-L,M-L,D-_+L*2,z-M+L*2,(_+D)/2,(M+z)/2,0),g.lineWidth=O,g.setLineDash(W);let K=gU([_,M,D,z,(_+D)/2,(M+z)/2],0,l.zoom,"mouse",v?{...E1(c),rotation:!0}:E1(c));r.some(Y=>!Y.locked)&&RC(g,s,l,K,0)}g.restore()}l.searchMatches?.matches.forEach(({id:C,focus:A,matchedLines:k})=>{let L=t.get(C);if(L){let[_,M,,,D,z]=tp(L,t,!0);g.save(),l.theme===pr.LIGHT?A?g.fillStyle="rgba(255, 124, 0, 0.4)":g.fillStyle="rgba(255, 226, 0, 0.4)":A?g.fillStyle="rgba(229, 82, 0, 0.4)":g.fillStyle="rgba(99, 52, 0, 0.4)";let W=Oa(L)?l.zoom.value:1;g.translate(l.scrollX,l.scrollY),g.translate(D,z),g.rotate(L.angle),k.forEach(O=>{(O.showOnCanvas||A)&&g.fillRect(_+O.offsetX/W-D,M+O.offsetY/W-z,O.width/W,O.height/W)}),g.restore()}}),kC(g,l),g.restore(),Gy({context:g,renderConfig:s,appState:l,normalizedWidth:d,normalizedHeight:u});let I;return s.renderScrollbars&&(I=YI(t,d,u,l),g.save(),g.fillStyle=WI,g.strokeStyle="rgba(255,255,255,0.8)",[I.horizontal,I.vertical].forEach(C=>{C&&gd(g,C.x,C.y,C.width,C.height,lo/2)}),g.restore()),{scrollBars:I,atLeastOneVisibleElement:n.length>0,elementsMap:t,animationState:b}},HC=e=>{let o=GU(e);return e.callback(o),o};var dt=class dt{static start(o,t){let n=t({deltaTime:0,state:void 0});n&&(dt.animations.set(o,{animation:t,lastTime:0,state:n}),dt.isRunning||(dt.isRunning=!0,Gr()?requestAnimationFrame(dt.tick):setTimeout(dt.tick,0)))}static tick(){if(dt.animations.size>0){for(let[o,t]of dt.animations){let n=performance.now(),r=t.lastTime===0?0:n-t.lastTime,i=t.animation({deltaTime:r,state:t.state});if(i)t.lastTime=n,t.state=i;else if(dt.animations.delete(o),dt.animations.size===0){dt.isRunning=!1;return}}Gr()?requestAnimationFrame(dt.tick):setTimeout(dt.tick,0)}}static running(o){return dt.animations.has(o)}static cancel(o){dt.animations.delete(o)}};S(dt,"isRunning",!1),S(dt,"animations",new Map);var Ls=dt;import{jsx as ZU}from"react/jsx-runtime";var WC="animateInteractiveScene",XU=e=>{let o=GC(!1),t=GC(null);return WU(()=>{if(!o.current){o.current=!0;return}let n=new Map,r=new Map,i=new Map,a=new Map,l=new Map;e.appState.collaborators.forEach((c,m)=>{if(c.selectedElementIds)for(let p of Object.keys(c.selectedElementIds))i.has(p)||i.set(p,[]),i.get(p).push(m);!c.pointer||c.pointer.renderCursor===!1||(c.username&&a.set(m,c.username),c.userState&&l.set(m,c.userState),r.set(m,VU({sceneX:c.pointer.x,sceneY:c.pointer.y},e.appState)),n.set(m,c.button))});let s=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";t.current={app:e.app,canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:r,remotePointerButton:n,remoteSelectedElementIds:i,remotePointerUsernames:a,remotePointerUserStates:l,selectionColor:s,renderScrollbars:e.renderScrollbars,lastViewportPosition:e.app.lastViewportPosition},editorInterface:e.editorInterface,callback:e.renderInteractiveSceneCallback,animationState:{bindingHighlight:void 0},deltaTime:0},Ls.running(WC)||Ls.start(WC,({deltaTime:c,state:m})=>{let p=HC({...t.current,deltaTime:c,animationState:m}).animationState;if(p){for(let d in p)if(p[d]!==void 0)return p}})}),ZU("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled&&e.appState.activeTool.type!=="laser"?UC.GRAB:UC.AUTO},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onClick:e.onClick,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.appState.viewModeEnabled?void 0:e.onDoubleClick,children:f("labels.drawingCanvas")})},YC=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,activeTool:e.activeTool,openDialog:e.openDialog,editingGroupId:e.editingGroupId,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,newElement:e.newElement,isBindingEnabled:e.isBindingEnabled,isMidpointSnappingEnabled:e.isMidpointSnappingEnabled,suggestedBinding:e.suggestedBinding,isRotating:e.isRotating,elementsToHighlight:e.elementsToHighlight,collaborators:e.collaborators,activeEmbeddable:e.activeEmbeddable,snapLines:e.snapLines,zenModeEnabled:e.zenModeEnabled,editingTextElement:e.editingTextElement,isCropping:e.isCropping,croppingElementId:e.croppingElementId,searchMatches:e.searchMatches,activeLockedId:e.activeLockedId,hoveredElementIds:e.hoveredElementIds,frameRendering:e.frameRendering,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,exportScale:e.exportScale,currentItemArrowType:e.currentItemArrowType}),KU=(e,o)=>e.selectionNonce!==o.selectionNonce||e.canvasNonce!==o.canvasNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements||e.selectedElements!==o.selectedElements||e.renderScrollbars!==o.renderScrollbars?!1:YU(YC(e.appState),YC(o.appState)),C1=UU.memo(XU,KU);import $U,{useEffect as VC,useRef as XC}from"react";import{isShallowEqual as KC}from"@excalidraw/common";import{jsx as JU}from"react/jsx-runtime";var jU=e=>{let o=XC(null),t=XC(!1);return VC(()=>{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]),VC(()=>{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"));let i=getComputedStyle(n).getPropertyValue("--color-grid-bold").trim(),a=getComputedStyle(n).getPropertyValue("--color-grid-regular").trim();Rb({canvas:r,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:{...e.renderConfig,gridColorBold:i,gridColorRegular:a}},Gr())}),JU("div",{className:"excalidraw__canvas-wrapper",ref:o})},ZC=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,openDialog:e.openDialog,hoveredElementIds:e.hoveredElementIds,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,viewBackgroundColor:e.viewBackgroundColor,exportScale:e.exportScale,selectedElementsAreBeingDragged:e.selectedElementsAreBeingDragged,gridSize:e.gridSize,gridStep:e.gridStep,frameRendering:e.frameRendering,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,editingGroupId:e.editingGroupId,currentHoveredFontFamily:e.currentHoveredFontFamily,croppingElementId:e.croppingElementId,suggestedBinding:e.suggestedBinding}),qU=(e,o)=>e.canvasNonce!==o.canvasNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements?!1:KC(ZC(e.appState),ZC(o.appState))&&KC(e.renderConfig,o.renderConfig),k1=$U.memo(jU,qU);import{useEffect as iW,useRef as aW}from"react";import{throttleRAF as QU}from"@excalidraw/common";import{getTargetFrame as eW,isInvisiblySmallElement as tW,renderElement as oW,shouldApplyFrameClip as nW}from"@excalidraw/element";var $C=({canvas:e,rc:o,newElement:t,elementsMap:n,allElementsMap:r,scale:i,appState:a,renderConfig:l})=>{if(e){let[s,c]=Js(e,i),m=Qs({canvas:e,scale:i,normalizedWidth:s,normalizedHeight:c});if(m.save(),m.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"){if(tW(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let d=eW(t,n,a);d&&nW(t,d,a,n)&&_b(d,m,l,a)}oW(t,n,r,o,m,l,a)}else m.clearRect(0,0,s,c);m.restore()}},rW=QU(e=>{$C(e)}),jC=(e,o)=>{if(o){rW(e);return}$C(e)};import{jsx as sW}from"react/jsx-runtime";var lW=e=>{let o=aW(null);return iW(()=>{o.current&&jC({canvas:o.current,scale:e.scale,newElement:e.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},Gr())}),sW("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})},qC=lW;var op=class{constructor(o){this.getState=o;S(this,"listeners",[]);S(this,"onStateChange",(o,t,n)=>{let{predicate:r,getValue:i,callback:a,once:l,matchesImmediately:s}=this.normalize(o,t,n);return a?s&&(queueMicrotask(()=>{let c=this.getState();a(i(c),c)}),l)?()=>{}:this.subscribe({predicate:r,getValue:i,callback:a,once:l}):s?Promise.resolve(i(this.getState())):new Promise(c=>{this.subscribe({predicate:r,getValue:i,callback:m=>c(m),once:!0})})})}isStateChangePredicateOptions(o){return typeof o=="object"&&!Array.isArray(o)&&"predicate"in o}subscribe(o){return this.listeners.push(o),()=>{this.listeners=this.listeners.filter(t=>t!==o)}}normalize(o,t,n){let r,i,a=t,l=n?.once??!1,s=!1;if(this.isStateChangePredicateOptions(o)){let{predicate:c,callback:m,once:p}=o;r=c,i=d=>d,a=m?(d,u)=>m(u):void 0,l=p??!1,s=c(this.getState())}else if(typeof o=="function"){let c=o;r=(m,p)=>c(m)!==c(p),i=m=>c(m)}else if(Array.isArray(o)){let c=o;r=(m,p)=>c.some(d=>m[d]!==p[d]),i=m=>m}else{let c=o;r=(m,p)=>m[c]!==p[c],i=m=>m[c]}return{predicate:r,getValue:i,callback:a,once:l,matchesImmediately:s}}flush(o){if(!this.listeners.length)return;let t=this.getState(),n=[];for(let r of this.listeners)r.predicate(t,o)?(r.callback(r.getValue(t),t),r.once||n.push(r)):n.push(r);this.listeners=n}clear(){this.listeners=[]}};import{getCommonBounds as cW,getElementsInGroup as dW,selectGroupsFromGivenElements as mW}from"@excalidraw/element";import{sceneCoordsToViewportCoords as pW}from"@excalidraw/common";import{flushSync as uW}from"react-dom";import{jsx as gW}from"react/jsx-runtime";var hW=({app:e,activeLockedId:o})=>{let t=e.scene.getElement(o),n=t?[t]:dW(e.scene.getNonDeletedElementsMap(),o);if(n.length===0)return null;let[r,i]=cW(n),{x:a,y:l}=pW({sceneX:r,sceneY:i},e.state);return gW("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${a-e.state.offsetLeft}px`},onClick:()=>{uW(()=>{let s=mW(n,e.state);e.setState({selectedElementIds:n.reduce((c,m)=>({...c,[m.id]:!0}),{}),selectedGroupIds:s,activeLockedId:null})}),e.actionManager.executeAction(zl)},title:f("labels.elementLock.unlock"),children:oE})},JC=hW;import{Fragment as yV,jsx as ve,jsxs as pp}from"react/jsx-runtime";var sk=go.createContext(null),ck=go.createContext(null),rb={formFactor:"desktop",desktopUIMode:"full",userAgent:ak(typeof navigator<"u"?navigator.userAgent:""),isTouchScreen:!1,canFitSidebar:!1,isLandscape:!0},ab=go.createContext(rb);ab.displayName="EditorInterfaceContext";var fV={"editor:mount":{cardinality:"once",replay:"last"},"editor:initialize":{cardinality:"once",replay:"last"},"editor:unmount":{cardinality:"once",replay:"last"}},lb=go.createContext({container:null,id:null});lb.displayName="ExcalidrawContainerContext";var sb=go.createContext([]);sb.displayName="ExcalidrawElementsContext";var cb=go.createContext({...Pn(),width:0,height:0,offsetLeft:0,offsetTop:0});cb.displayName="ExcalidrawAppStateContext";var db=go.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});db.displayName="ExcalidrawSetAppStateContext";var mb=go.createContext(null);mb.displayName="ExcalidrawActionManagerContext";var Xa=go.createContext(null);Xa.displayName="ExcalidrawAPIContext";var hp=go.createContext(null);hp.displayName="ExcalidrawAPISetContext";var je=()=>Cn(sk),no=()=>Cn(ck),pe=()=>Cn(ab),nt=()=>up(pe()),Ne=()=>Cn(lb),Fn=()=>Cn(sb),Do=()=>Cn(cb),be=()=>Cn(db),Ye=()=>Cn(mb),gp=()=>Cn(Xa),Hs=!1,eb=0,Gs=null,gr=!1,Va=!1,Us=!1,Ws=!1,tb=!1,Ys={horizontal:null,vertical:null},fr=0,Vs=!1,ob=new Map,bV=4,nb=!1,ok=0,nk=!1,ti=null,EV="zoom-in",ye={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},ib=class e extends go.Component{constructor(t){super(t);S(this,"canvas");S(this,"interactiveCanvas",null);S(this,"sessionExportThemeOverride");S(this,"rc");S(this,"unmounted",!1);S(this,"actionManager");S(this,"editorInterface",rb);S(this,"stylesPanelMode",up(rb));S(this,"excalidrawContainerRef",go.createRef());S(this,"scene");S(this,"fonts");S(this,"renderer");S(this,"visibleElements");S(this,"resizeObserver");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,"_initialized",!1);S(this,"editorLifecycleEvents",new XW(fV));S(this,"onEvent",this.editorLifecycleEvents.on.bind(this.editorLifecycleEvents));S(this,"appStateObserver",new op(()=>this.state));S(this,"onStateChange",this.appStateObserver.onStateChange);S(this,"flowChartCreator",new NY);S(this,"flowChartNavigator",new BY);S(this,"bindModeHandler",null);S(this,"hitLinkElement");S(this,"lastPointerDownEvent",null);S(this,"lastPointerUpEvent",null);S(this,"lastPointerUpIsDoubleClick",!1);S(this,"lastPointerMoveEvent",null);S(this,"lastPointerMoveCoords",null);S(this,"lastCompletedCanvasClicks",[]);S(this,"previousPointerMoveCoords",null);S(this,"lastViewportPosition",{x:0,y:0});S(this,"animationFrameHandler",new lm);S(this,"laserTrails",new mm(this.animationFrameHandler,this));S(this,"eraserTrail",new fm(this.animationFrameHandler,this));S(this,"lassoTrail",new gm(this.animationFrameHandler,this));S(this,"onChangeEmitter",new Jr);S(this,"onPointerDownEmitter",new Jr);S(this,"onPointerUpEmitter",new Jr);S(this,"onUserFollowEmitter",new Jr);S(this,"onScrollChangeEmitter",new Jr);S(this,"missingPointerEventCleanupEmitter",new Jr);S(this,"onRemoveEventListenersEmitter",new Jr);S(this,"api");S(this,"addImageElementsToScene",async(t,n,r)=>{await this.insertImages(t,n,r)});S(this,"updateEditorAtom",(t,...n)=>{let r=ot.set(t,...n);return this.triggerRender(),r});S(this,"previousHoveredBindableElement",null);S(this,"getEffectiveGridSize",()=>or(this)?this.state.gridSize:null);S(this,"getTextCreationGridPoint",(t,n)=>{let r=this.getEffectiveGridSize();if(r===null)return null;let i=a=>Math.floor(a/r)*r;return{x:i(t),y:i(n)}});S(this,"handleIframeLikeElementHover",({hitElement:t,scenePointer:n,moveEvent:r})=>t&&z1(t)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(t,r,n.x,n.y))?(Ee(this.interactiveCanvas,Re.POINTER),this.setState({activeEmbeddable:{element:t,state:"hover"}}),!0):(this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null}),!1));S(this,"isDoubleClick",(t,n)=>t!=null&&n.timeStamp-t.timeStamp<=m5);S(this,"updateEmbedValidationStatus",(t,n)=>{this.embedsValidationStatus.set(t.id,n),zs.delete(t)});S(this,"updateEmbeddables",()=>{let t=new Set,n=!1;this.scene.getNonDeletedElements().filter(r=>{if(Sn(r)){if(t.add(r.id),!this.embedsValidationStatus.has(r.id)){n=!0;let i=U1(r.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(r,i)}}else Ya(r)&&t.add(r.id);return!1}),n&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((r,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});S(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);S(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});S(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.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 t=this.state.theme===za.DARK,n=this.scene.getNonDeletedFramesLikes(),r=n.length>0&&this.state.searchMatches?.focusedId&&ht(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return n.map(i=>{if(!M5(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}=ap({sceneX:i.x,sceneY:i.y},this.state),s=6,c,m=MY(i);if(i.id===this.state.editingFrame){let p=m;c=ve("input",{autoFocus:!0,value:p,onChange:d=>{this.scene.mutateElement(i,{name:d.target.value})},onFocus:d=>d.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:d=>{(d.key===X.ESCAPE||d.key===X.ENTER)&&this.resetEditingFrame(i)},style:{background:t?VW(this.state.viewBackgroundColor):this.state.viewBackgroundColor,zIndex:2,border:"none",display:"block",padding:`${s}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${$o.nameFontSize}px`,transform:`translate(-${s}px, ${s}px)`,color:t?$o.nameColorDarkTheme:$o.nameColorLightTheme,overflow:"hidden",maxWidth:`${document.body.clientWidth-a-s}px`},size:p.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else c=m;return ve("div",{id:this.getFrameNameDOMId(i),className:B1.FRAME_NAME,style:{position:"absolute",bottom:`${this.state.height+$o.nameOffsetY-l+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:$o.nameFontSize,color:t?$o.nameColorDarkTheme:$o.nameColorLightTheme,lineHeight:$o.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:Re.MOVE,pointerEvents:this.state.viewModeEnabled?Ha.disabled:Ha.enabled},onPointerDown:p=>this.handleCanvasPointerDown(p),onWheel:p=>this.handleWheel(p),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",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});S(this,"onExportImage",async(t,n,r)=>{ce("export",t,"ui");let i=await Ar(t,n,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:r.exportingFrame}).catch(UW).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&tc(i)&&this.setState({fileHandle:i})});S(this,"magicGenerations",new Map);S(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()});S(this,"plugins",{});S(this,"onMagicframeToolSelect",()=>{let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(t.length===0)this.setActiveTool({type:Jo.magicframe}),ce("ai","tool-select (empty-selection)","d2c");else{let n=t.length===1&&k5(t[0])&&t[0];if(!n&&t.some(i=>ht(i)||i.frameId)){this.setActiveTool({type:Jo.magicframe});return}ce("ai","tool-select (existing selection)","d2c");let r;if(n)r=n;else{let[i,a,l,s]=Ua(t),c=50;r=I5({...$o,x:i-c,y:a-c,width:l-i+c*2,height:s-a+c*2,opacity:100,locked:!1}),this.insertNewElement(r);for(let m of t)this.scene.mutateElement(m,{frameId:r.id});this.setState({selectedElementIds:{[r.id]:!0}})}this.onMagicFrameGenerate(r,"upstream")}});S(this,"openEyeDropper",({type:t})=>{this.updateEditorAtom(Bn,{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:Pt.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:n},captureUpdate:Pt.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?hr(l,{[i?"strokeColor":"backgroundColor"]:n}):l),captureUpdate:Pt.IMMEDIATELY})},keepOpenOnAlt:!1})});S(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});S(this,"syncActionResult",Ge(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||za.LIGHT,s=t?.appState?.name??this.state.name,c=t?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(a=this.props.zenModeEnabled),r=t.appState?.editingTextElement||null,t.elements&&r&&t.elements.forEach(m=>{r?.id===m.id&&r!==m&&$5(m)&&jt(m)&&(r=m)}),r?.isDeleted&&(r=null),this.setState(m=>{let p=t.appState||{};return{...m,...p,contextMenu:null,editingTextElement:r,viewModeEnabled:i,zenModeEnabled:a,theme:l,name:s,errorMessage:c}}),n=!0}n||this.scene.triggerUpdate()}));S(this,"onBlur",Ge(()=>{gr=!1,Va=!1,Ws=!1,this.restoreCursorAfterZoomKey(),this.setState({isBindingEnabled:this.state.bindingPreference==="enabled"})}));S(this,"onUnload",()=>{this.onBlur()});S(this,"disableEvent",t=>{t.preventDefault()});S(this,"resetHistory",()=>{this.history.clear()});S(this,"resetStore",()=>{this.store.clear()});S(this,"resetScene",Ge(t=>{this.scene.replaceAllElements([]),this.setState(n=>({...Pn(),isLoading:t?.resetLoadingState?!1:n.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));S(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async a=>{if(!a.files.length)return;let l=a.files[0],s=await l.getFile();this.loadFileToCanvas(new File([s],s.name||"",{type:s.type}),l)}),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(a=>{console.error(a)})}catch(a){console.error(a),t={appState:{errorMessage:a.message||"Encountered an error during importing or restoring scene data"}}}let n=wr(t?.elements,null,{repairBindings:!0,deleteInvisibleElements:!0}),r=li(t?.appState,null),i=r.activeTool;r.preferredSelectionTool.initialized||(r.preferredSelectionTool={type:this.editorInterface.formFactor==="phone"?"lasso":"selection",initialized:!0}),r={...r,theme:this.props.theme||r.theme,openSidebar:r?.openSidebar||this.state.openSidebar,activeTool:i.type==="image"||i.type==="lasso"||i.type==="selection"?{...i,type:r.preferredSelectionTool.type}:r.activeTool,isLoading:!1,toast:this.state.toast},t?.scrollToContent&&(r={...r,...xr(n,{...r,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})}),this.resetStore(),this.resetHistory(),this.syncActionResult({elements:n,appState:r,files:t?.files,captureUpdate:Pt.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(a=>{this.fonts.onLoaded(a)}),$1(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})});S(this,"getFormFactor",(t,n)=>this.props.UIOptions.getFormFactor?.(t,n)??jW(t,n));S(this,"refreshEditorInterface",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:n,height:r}=t.getBoundingClientRect(),i=eY(),a=ak(typeof navigator<"u"?navigator.userAgent:""),l=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:CW,s=N1(this.editorInterface,{desktopUIMode:i??this.editorInterface.desktopUIMode,formFactor:this.getFormFactor(n,r),userAgent:a,canFitSidebar:n>l,isLandscape:n>r});this.editorInterface=s,this.reconcileStylesPanelMode(s)});S(this,"reconcileStylesPanelMode",t=>{let n=up(t);if(n===this.stylesPanelMode)return;let r=this.stylesPanelMode;this.stylesPanelMode=n,r!=="full"&&n==="full"&&this.setState(i=>({preferredSelectionTool:{type:"selection",initialized:!0}}))});S(this,"setDesktopUIMode",t=>{let n=tY(t);this.editorInterface=N1(this.editorInterface,{desktopUIMode:n}),this.reconcileStylesPanelMode(this.editorInterface)});S(this,"onResize",Ge(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>zs.delete(t)),this.refreshEditorInterface(),this.updateDOMRect(),this.setState({})}));S(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});S(this,"renderInteractiveSceneCallback",({atLeastOneVisibleElement:t,scrollBars:n,elementsMap:r})=>{n&&(Ys=n);let i=this.state.editingTextElement?!1:!t&&r.size>0;this.state.scrolledOutside!==i&&this.setState({scrolledOutside:i}),this.scheduleImageRefresh()});S(this,"onScroll",h5(()=>{let{offsetTop:t,offsetLeft:n}=this.getCanvasOffsets();this.setState(r=>r.offsetLeft===n&&r.offsetTop===t?null:{offsetTop:t,offsetLeft:n})},kW));S(this,"onCut",Ge(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||Ds(t.target)||(this.actionManager.executeAction(Ed,"keyboard",t),t.preventDefault(),t.stopPropagation())}));S(this,"onCopy",Ge(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||Ds(t.target)||(this.actionManager.executeAction(Yi,"keyboard",t),t.preventDefault(),t.stopPropagation())}));S(this,"onTouchStart",t=>{if(qW&&t.preventDefault(),!Hs){Hs=!0,t.touches.length===1&&(Gs={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(eb),eb=window.setTimeout(e.resetTapTwice,m5);return}if(Hs&&t.touches.length===1&&Gs){let n=t.touches[0];In(oe(n.clientX,n.clientY),oe(Gs.x,Gs.y))<=E5&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:n.clientX,clientY:n.clientY,type:"touch",altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1})),Hs=!1,clearTimeout(eb)}t.touches.length===2&&this.setState({selectedElementIds:Ce({},this.state),activeEmbeddable:null})});S(this,"onTouchEnd",t=>{this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:Ce(this.state.previousSelectedElementIds,this.state)}):ye.pointers.clear()});S(this,"pasteFromClipboard",Ge(async t=>{let n=!!nb,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)||Ds(r)))return;let l=await Ni(t),s=l.getFiles(),c=await ld(l,n);if(this.props.onPaste)try{if(await this.props.onPaste(c,t)===!1)return}catch(m){console.error(m)}await this.insertClipboardContent(c,s,n),this.setActiveTool({type:this.state.preferredSelectionTool.type},!0),t?.preventDefault()}));S(this,"addElementsFromPasteOrLibrary",t=>{let n=wr(t.elements,null,{deleteInvisibleElements:!0}),[r,i,a,l]=Ua(n),s=Ga(r,a)/2,c=Ga(i,l)/2,m=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,p=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop,{x:d,y:u}=He({clientX:m,clientY:p},this.state),b=d-s,g=u-c,[E,y]=xt(b,g,this.getEffectiveGridSize()),{duplicatedElements:v}=F1({type:"everything",elements:n.map(k=>hr(k,{x:k.x+E-r,y:k.y+y-i})),randomizeSeed:!t.retainSeed,preserveFrameChildrenOrder:t.preserveFrameChildrenOrder}),x=this.scene.getElementsIncludingDeleted(),w=[...x,...v];w=this.props.onDuplicate?.(w,x)||w,Y5(w,lp(v));let C=this.getTopLayerFrameAtSceneCoords({x:d,y:u});if(C){let k=LY(v,C);w=X1(w,k,C)}this.scene.replaceAllElements(w),v.forEach(k=>{if(jt(k)&&O1(k)){let L=R5(k,this.scene.getElementsMapIncludingDeleted());vY(k,L,this.scene)}}),QW&&nn.loadElementsFonts(v).then(k=>{this.fonts.onLoaded(k)}),t.files&&this.addMissingFiles(t.files);let A=jY(v);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.editorInterface.canFitSidebar&&ot.get(ys)?this.state.openSidebar:null,...ho({editingGroupId:null,selectedElementIds:A.reduce((k,L)=>(O1(L)||(k[L.id]=!0),k),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:this.state.preferredSelectionTool.type},!0),t.fitToContent&&this.scrollToContent(v,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})});S(this,"setAppState",(t,n)=>{this.setState(t,n)});S(this,"removePointer",t=>{fr&&this.resetContextMenuTimer(),ye.pointers.delete(t.pointerId)});S(this,"toggleLock",(t="ui")=>{this.state.activeTool.locked||ce("toolbar","toggleLock",`${t} (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),this.setState(n=>({activeTool:{...n.activeTool,...Qo(this.state,n.activeTool.locked?{type:this.state.preferredSelectionTool.type}:n.activeTool),locked:!n.activeTool.locked}}))});S(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}}})});S(this,"togglePenMode",t=>{this.setState(n=>({penMode:t??!n.penMode,penDetected:!0}))});S(this,"onHandToolToggle",()=>{this.actionManager.executeAction(ny)});S(this,"zoomCanvas",t=>{this.setState({...Bo({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:Jt(t)},this.state)})});S(this,"cancelInProgressAnimation",null);S(this,"scrollToViewport",(t,n)=>{this.cancelInProgressAnimation?.();let r={value:Jt(t.zoom)},i=n?.duration??500;if(n?.animate&&i>0){let a=this.state.scrollX,l=this.state.scrollY,s=this.state.zoom.value,c=GW({fromValues:{scrollX:a,scrollY:l,zoom:s},toValues:{scrollX:t.scrollX,scrollY:t.scrollY,zoom:r.value},interpolateValue:(m,p,d,u)=>{if(u==="zoom")return m*Math.pow(p/m,WW(d))},onStep:({scrollX:m,scrollY:p,zoom:d})=>{this.setState({scrollX:m,scrollY:p,zoom:{value:d}})},onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.cancelInProgressAnimation=null,this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.cancelInProgressAnimation=null,this.setState({shouldCacheIgnoreZoom:!1})},duration:i});this.cancelInProgressAnimation=()=>{c(),this.cancelInProgressAnimation=null}}else this.setState({scrollX:t.scrollX,scrollY:t.scrollY,zoom:r})});S(this,"scrollToContent",(t=this.scene.getNonDeletedElements(),n)=>{if(typeof t=="string"){let s;if($1(t)?s=zY(t):s=t,s){let c=this.scene.getElementsFromId(s);c?.length?this.scrollToContent(c,{fitToContent:n?.fitToContent??!0,animate:n?.animate??!0}):$1(t)&&this.setState({toast:{message:f("elementLink.notFound"),duration:3e3,closable:!0}})}return}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}=Tl({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=xr(r,this.state);a=s.scrollX,l=s.scrollY}this.scrollToViewport({scrollX:a,scrollY:l,zoom:i.value},{animate:n?.animate,duration:n?.duration})});S(this,"maybeUnfollowRemoteUser",()=>{this.state.userToFollow&&this.setState({userToFollow:null})});S(this,"translateCanvas",t=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(t)});S(this,"setToast",t=>{this.setState({toast:t})});S(this,"handleToastClose",()=>{this.setToast(null)});S(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,yW,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});S(this,"addFiles",Ge(t=>{let{addedFiles:n}=this.addMissingFiles(t);this.clearImageShapeCache(n),this.scene.triggerUpdate(),this.addNewImagesToImageCache()}));S(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===jo.svg))try{let s=Ub(D5(Wb(l.dataURL)),jo.svg);l.dataURL!==s&&(l.version=(l.version??1)+1,l.dataURL=s)}catch(s){console.error(s)}return this.files=r,{addedFiles:i}});S(this,"updateScene",Ge(t=>{let{elements:n,appState:r,collaborators:i,captureUpdate:a}=t;if(a){let l=n||void 0,s=r?nY({...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})}));S(this,"applyDeltas",(t,n)=>{let r=q5.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return q5.applyTo(r,a,i,n)});S(this,"mutateElement",(t,n,r=!0)=>this.scene.mutateElement(t,n,{informMutation:r,isDragging:!1}));S(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});S(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});S(this,"updateCurrentCursorPosition",Ge(t=>{this.lastViewportPosition.x=t.clientX,this.lastViewportPosition.y=t.clientY}));S(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 rn().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}});S(this,"onKeyDown",Ge(t=>{if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(l,s){let c=l[s];return typeof c=="function"?c.bind(l):s==="key"?t.shiftKey?l.key.toUpperCase():l.key.toLowerCase():c}})),!g5(t.target)){if((t.key===X.ESCAPE||t.key===X.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let l=ee(this.scene.getNonDeletedElementsMap(),this.state);if(l.length===1&&Qr(l[0])&&t.key===X.ENTER){this.startImageCropping(l[0]);return}if(t.key===X.ESCAPE)this.updateEditorAtom(wo,null);else if(t.key===X.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(B1.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let c=ji(l);ot.get(wo)?.type==="panel"&&Fh(this,{conversionType:c,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),c&&this.updateEditorAtom(wo,{type:"panel"})}if(t.key===X.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let s=np(t.key);if(t[X.CTRL_OR_CMD]&&s&&!t.shiftKey){t.preventDefault();let c=ee(this.scene.getNonDeletedElementsMap(),this.state);c.length===1&&fY(c[0])&&this.flowChartCreator.createNodes(c[0],this.state,H5(t.key),this.scene),this.flowChartCreator.pendingNodes?.length&&!G1(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 c=ee(this.scene.getNonDeletedElementsMap(),this.state);if(c.length===1&&s){t.preventDefault();let m=this.flowChartNavigator.exploreByDirection(c[0],this.scene.getNonDeletedElementsMap(),H5(t.key));if(m){this.setState(d=>({selectedElementIds:Ce({[m]:!0},d)}));let p=this.scene.getNonDeletedElementsMap().get(m);p&&!G1([p],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(p,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})}return}}}if(t[X.CTRL_OR_CMD]&&t.key===X.P&&!t.shiftKey&&!t.altKey){this.setToast({message:f("commandPalette.shortcutHint",{shortcut:Se("commandPalette")})}),t.preventDefault();return}if(t[X.CTRL_OR_CMD]&&t.key.toLowerCase()===X.V&&(nb=t.shiftKey,clearTimeout(ok),ok=window.setTimeout(()=>{nb=!1},100)),t[X.CTRL_OR_CMD]&&Ds(t.target)&&(t.code===r5.MINUS||t.code===r5.EQUAL)){t.preventDefault();return}if(Ds(t.target)&&t.key!==X.ESCAPE||np(t.key)&&g5(t.target))return;if(t.key===X.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===X.E&&t.shiftKey&&t[X.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(t.key===X.PAGE_UP||t.key===X.PAGE_DOWN){let l=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;t.key===X.PAGE_DOWN&&(l=-l),t.shiftKey?this.translateCanvas(s=>({scrollX:s.scrollX+l})):this.translateCanvas(s=>({scrollY:s.scrollY+l}))}if(this.state.openDialog?.name==="elementLinkSelector"||(t.key===X.ALT&&(Tn("COMPLEX_BINDINGS")?this.handleSkipBindMode():mp({app:this,event:t})),this.actionManager.handleKeyDown(t)))return;if(!t.altKey&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey&&x5(t,X.Z)){Va=!0,Ee(this.interactiveCanvas,EV),t.preventDefault();return}let n=this.props.viewModeEnabled===!0;if(!n&&this.state.viewModeEnabled&&t.key===X.ESCAPE){this.setActiveTool({type:"selection"});return}if(!n&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let l=gV(t.key,this);if(this.state.viewModeEnabled&&l)return;if(l){this.state.activeTool.type!==l&&ce("toolbar",l,`keyboard (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),l==="arrow"&&this.state.activeTool.type==="arrow"&&this.setState(s=>({currentItemArrowType:s.currentItemArrowType===ur.sharp?ur.round:s.currentItemArrowType===ur.round?ur.elbow:ur.sharp})),l==="lasso"&&this.state.activeTool.type==="laser"?this.setActiveTool({type:this.state.preferredSelectionTool.type}):this.setActiveTool({type:l}),t.stopPropagation();return}else if(t.key===X.Q){this.toggleLock("keyboard"),t.stopPropagation();return}}if(this.state.viewModeEnabled)return;if(t[X.CTRL_OR_CMD]&&!t.repeat&&(Tn("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),$t(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),mp({app:this,event:t})),np(t.key)){let l=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),s=new Set;l.filter(d=>on(d)).filter(d=>{let u=d.startBinding&&!l.some(g=>g.id===d.startBinding?.elementId),b=d.endBinding&&!l.some(g=>g.id===d.endBinding?.elementId);return u||b}).forEach(d=>s.add(d.id)),l=l.filter(d=>!s.has(d.id));let c=this.getEffectiveGridSize()&&(t.shiftKey?c5:this.getEffectiveGridSize())||(t.shiftKey?IW:c5),m=0,p=0;t.key===X.ARROW_LEFT?m=-c:t.key===X.ARROW_RIGHT?m=c:t.key===X.ARROW_UP?p=-c:t.key===X.ARROW_DOWN&&(p=c),l.forEach(d=>{this.scene.mutateElement(d,{x:d.x+m,y:d.y+p},{informMutation:!1,isDragging:!1}),sp(d,this.scene,{simultaneouslyUpdated:l})}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===X.ENTER){let l=this.scene.getSelectedElements(this.state);if(l.length===1){let s=l[0];if(t[X.CTRL_OR_CMD]||j1(s))kt(s)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==s.id)&&(this.store.scheduleCapture(),Ht(s)||this.actionManager.executeAction(pa));else if(jt(s)||N5(s)){let c;jt(s)||(c=s);let m=Y1(s,this.state,this.scene.getNonDeletedElementsMap()),p=m.x,d=m.y;this.startTextEditing({sceneX:p,sceneY:d,container:c}),t.preventDefault();return}else ht(s)&&this.setState({editingFrame:s.id})}}if(t.key===X.SPACE&&ye.pointers.size===0&&(gr=!0,Ee(this.interactiveCanvas,Re.GRAB),t.preventDefault()),(t.key===X.G||t.key===X.S)&&!t.altKey&&!t[X.CTRL_OR_CMD]){let l=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!l.length)return;t.key===X.G&&(Lo(this.state.activeTool.type)||l.some(s=>Lo(s.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===X.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[X.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===X.F){let l=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!l.length)return;(this.state.activeTool.type==="text"||l.find(s=>jt(s)||W1(s,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}let r=t.key.toLocaleLowerCase(),i=r===X.S&&t.shiftKey&&!t[X.CTRL_OR_CMD],a=t.key===X.I||r===X.G&&t.shiftKey;(i||a)&&this.openEyeDropper({type:i?"stroke":"background"})}));S(this,"onKeyUp",Ge(t=>{if(t.key===X.SPACE&&(this.state.viewModeEnabled&&this.state.activeTool.type!=="laser"||this.state.openDialog?.name==="elementLinkSelector"?Ee(this.interactiveCanvas,Re.GRAB):Ns(this.state.activeTool.type)?_t(this.interactiveCanvas):(Dt(this.interactiveCanvas,this.state),this.setState({selectedElementIds:Ce({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),gr=!1),x5(t,X.Z)&&(Va=!1,this.restoreCursorAfterZoomKey()),t.key===X.ALT&&mp({app:this,event:t}),(t.key===X.ALT&&this.state.bindMode==="skip"||!t[X.CTRL_OR_CMD]&&!Bs(this.state))&&(this.setState({bindMode:"orbit"}),this.lastPointerMoveEvent&&Tn("COMPLEX_BINDINGS"))){let n=He({clientX:this.lastPointerMoveEvent.clientX,clientY:this.lastPointerMoveEvent.clientY},this.state),r=tn(oe(n.x,n.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(this.state.selectedLinearElement){let i=he.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());on(i)&&this.handleDelayedBindModeChange(i,r)}}if(!t[X.CTRL_OR_CMD]){let n=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==n&&$t(()=>{this.setState({isBindingEnabled:n})}),mp({app:this,event:t})}if(np(t.key)){w5(this.scene.getSelectedElements(this.state).filter(Wa),this.scene,this.state);let n=this.scene.getNonDeletedElementsMap();this.scene.getSelectedElements(this.state).filter(q1).forEach(r=>{r.startBinding&&this.scene.mutateElement(r,{startBinding:{...r.startBinding,...Q5(r,n.get(r.startBinding.elementId),"start",n)}}),r.endBinding&&this.scene.mutateElement(r,{endBinding:{...r.endBinding,...Q5(r,n.get(r.endBinding.elementId),"end",n)}})}),this.setState({suggestedBinding:null})}if(t.altKey||this.flowChartNavigator.isExploring&&(this.flowChartNavigator.clear(),this.syncActionResult({captureUpdate:Pt.IMMEDIATELY})),!t[X.CTRL_OR_CMD]&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.pendingNodes?.length&&this.insertNewElements(this.flowChartCreator.pendingNodes);let n=this.flowChartCreator.pendingNodes?.[0];n&&(this.setState(r=>({selectedElementIds:Ce({[n.id]:!0},r)})),G1([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:Pt.IMMEDIATELY})}}));S(this,"isToolSupported",t=>this.props.UIOptions.tools?.[t]!==!1);S(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=Qo(this.state,t);r.type==="hand"?Ee(this.interactiveCanvas,Re.GRAB):gr||Dt(this.interactiveCanvas,{...this.state,activeTool:r}),OW(document.activeElement)&&this.focusContainer(),hY(r.type)||this.setState({suggestedBinding:null}),r.type==="image"&&this.onImageToolbarButtonClick(),this.setState(i=>{let a={snapLines:i.snapLines.length?[]:i.snapLines,originSnapOffset:null,activeEmbeddable:null,selectedLinearElement:Ns(r.type)?i.selectedLinearElement:null,frameToHighlight:null};return r.type==="freedraw"&&this.store.scheduleCapture(),r.type==="lasso"?{...i,...a,activeTool:r,...n?{}:{selectedElementIds:Ce({},i),selectedGroupIds:Ce({},i),editingGroupId:null,multiElement:null}}:r.type!=="selection"?{...i,...a,activeTool:r,selectedElementIds:Ce({},i),selectedGroupIds:Ce({},i),editingGroupId:null,multiElement:null}:{...i,...a,activeTool:r}})});S(this,"setOpenDialog",t=>{this.setState({openDialog:t})});S(this,"setCursor",t=>{Ee(this.interactiveCanvas,t)});S(this,"resetCursor",()=>{_t(this.interactiveCanvas)});S(this,"isTouchScreenMultiTouchGesture",()=>ye.pointers.size>=2);S(this,"getName",()=>this.state.name||this.props.name||`${f("labels.untitled")}-${f5()}`);S(this,"onGestureStart",Ge(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:Ce({},this.state),activeEmbeddable:null}),ye.initialScale=this.state.zoom.value}));S(this,"onGestureChange",Ge(t=>{if(t.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let n=ye.initialScale;n&&this.setState(r=>({...Bo({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:Jt(n*t.scale)},r)}))}));S(this,"onGestureEnd",Ge(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:Ce(this.state.previousSelectedElementIds,this.state)}),ye.initialScale=null}));S(this,"isHittingTextAutoResizeHandle",(t,n)=>{let r=tk(t,this.state);return!!(r&&!r.isDeleted&&!r.autoResize&&LI(n,r,this.state.zoom.value,this.editorInterface.formFactor))});S(this,"handleTextAutoResizeHandlePointerDown",(t,n)=>{let r=tk(t,this.state);return!r||!this.isHittingTextAutoResizeHandle(t,n)?!1:(this.actionManager.executeAction(Fg,"ui",r),this.resetCursor(),!0)});S(this,"startTextEditing",({sceneX:t,sceneY:n,insertAtParentCenter:r=!0,container:i,autoEdit:a=!0,initialCaretSceneCoords:l})=>{let s=!1,c=r&&this.getTextWysiwygSnappedToCenterPosition(t,n,this.state,i);i&&c&&(W1(i,this.scene.getNonDeletedElementsMap())||(s=!0));let m=this.getSelectedTextElement(i)||this.getTextElementAtPosition(t,n),p=m?.fontFamily||this.state.currentItemFontFamily,d=m?.lineHeight||u5(p),u=this.state.currentItemFontSize;if(!m&&s&&i&&!Wa(i)){let w=UY(D1({fontSize:u,fontFamily:p}),d),I=WY(u,d),C=Math.max(i.height,I),A=Math.max(i.width,w);this.scene.mutateElement(i,{height:C,width:A}),t=i.x+A/2,n=i.y+C/2,c&&(c=this.getTextWysiwygSnappedToCenterPosition(t,n,this.state,i))}let b=this.getTextCreationGridPoint(t,n),g=c?{x:c.elementCenterX,y:c.elementCenterY}:m?{x:t,y:n}:{x:b?.x??t,y:b===null?n-U5(u,d)/2:b.y},E=this.getTopLayerFrameAtSceneCoords({x:g.x,y:g.y}),y=E&&(!s||!i||i.frameId===E.id)?E.id:null,v=m||T5({x:g.x,y:g.y,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:p,textAlign:c?"center":this.state.currentItemTextAlign,verticalAlign:c?AW.MIDDLE:l5,containerId:s?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:d,angle:i?Wa(i)?0:i.angle:0,frameId:y});if(!m&&s&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:v.id})}),this.setState({editingTextElement:v}),!m)if(i&&s){let x=this.scene.getElementIndex(i.id);this.scene.insertElementsAtIndex([v],x+1)}else this.insertNewElement(v);a||m||i?this.handleTextWysiwyg(v,{isExistingElement:!!m,initialCaretSceneCoords:m?l:null}):this.setState({newElement:v,multiElement:null})});S(this,"startImageCropping",t=>{this.store.scheduleCapture(),this.setState({croppingElementId:t.id})});S(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});S(this,"shouldHandleBrowserCanvasDoubleClick",t=>{if(t==="touch"||this.lastCompletedCanvasClicks.length===0)return!0;if(this.lastCompletedCanvasClicks.length<2)return!1;let[n,r]=this.lastCompletedCanvasClicks;return In(oe(n.x,n.y),oe(r.x,r.y))<=E5});S(this,"handleCanvasDoubleClick",t=>{if(this.state.editingTextElement||!this.shouldHandleBrowserCanvasDoubleClick(t.type)||this.state.multiElement||this.state.activeTool.type!==this.state.preferredSelectionTool.type)return;let n=this.scene.getSelectedElements(this.state),{x:r,y:i}=He(t,this.state);if(n.length===1&&kt(n[0])){let l=n[0];if((t[X.CTRL_OR_CMD]&&q1(l)||j1(l))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)){this.actionManager.executeAction(pa);return}else if(this.state.selectedLinearElement&&Ht(n[0])){let s=he.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),c=s?he.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,s,this.scene.getNonDeletedElementsMap()):-1;if(c&&c>-1){this.store.scheduleCapture(),he.deleteFixedSegment(n[0],this.scene,c);let m=he.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),p=m?he.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,m,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,segmentMidpoint:{index:p,value:s,added:!1}},segmentMidPointHoveredCoords:m}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===l.id&&j1(l))return}if(n.length===1&&Qr(n[0])){this.startImageCropping(n[0]);return}if(_t(this.interactiveCanvas),ZY(this.state).length>0){let l=this.getElementAtPosition(r,i),s=l&&KY(l,this.state.selectedGroupIds);if(s){this.store.scheduleCapture(),this.setState(c=>({...c,...ho({editingGroupId:s,selectedElementIds:{[l.id]:!0}},this.scene.getNonDeletedElements(),c,this)}));return}}if(_t(this.interactiveCanvas),!t[X.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let l=this.getElementAtPosition(r,i);if(z1(l)){this.setState({activeEmbeddable:{element:l,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){let s=this.getTextBindableContainerAtPosition(r,i);if(s&&(C5(s)||!HW(s.backgroundColor)||Os({point:oe(r,i),element:s,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(s)}))){let c=Y1(s,this.state,this.scene.getNonDeletedElementsMap());r=c.x,i=c.y}this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:s})}}});S(this,"handleCanvasClick",t=>{if(t.button!==qo.MAIN){this.lastCompletedCanvasClicks=[];return}this.lastCompletedCanvasClicks=[...this.lastCompletedCanvasClicks.slice(-1),{x:t.clientX,y:t.clientY}]});S(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&&qs(l,this.scene.getNonDeletedElementsMap(),this.state,oe(t.x,t.y),this.editorInterface.formFactor==="phone"))return l}});S(this,"handleElementLinkClick",t=>{let n=In(oe(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),oe(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||n>s5)return;let r=He(this.lastPointerDownEvent,this.state),i=this.scene.getNonDeletedElementsMap(),a=qs(this.hitLinkElement,i,this.state,oe(r.x,r.y),this.editorInterface.formFactor==="phone"),l=He(this.lastPointerUpEvent,this.state),s=qs(this.hitLinkElement,i,this.state,oe(l.x,l.y),this.editorInterface.formFactor==="phone");if(a&&s){Th();let c=this.hitLinkElement.link;if(c){c=_1(c);let m;if(this.props.onLinkOpen&&(m=zW(Q.EXCALIDRAW_LINK,t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:c},m)),!m?.defaultPrevented){let p=NW(c)?"_self":"_blank",d=window.open(void 0,p);d&&(d.opener=null,d.location=c)}}}});S(this,"getTopLayerFrameAtSceneCoords",(t,n)=>{let r=this.scene.getNonDeletedElementsMap(),i=this.scene.getNonDeletedFramesLikes().filter(s=>!s.locked&&F5(t,s,r));if(!i.length)return null;let a=i.at(-1),l=this.getElementsAtPosition(t.x,t.y,{includeLockedElements:!0}).findLast(s=>!n?.excludeElementIds?.[s.id]);if(l){if(ht(l)&&!l.locked)return a;let s=this.scene.getElementIndex(l.id),c=this.scene.getElementIndex(a.id);if(s!==-1&&c!==-1&&s<=c)return a;let m=n?.currentFrameId?i.find(p=>p.id===n.currentFrameId)??null:null;return m||(l.frameId?i.find(p=>p.id===l.frameId)??null:null)}return a});S(this,"updateFrameToHighlight",t=>{this.state.frameToHighlight!==t&&this.setState({frameToHighlight:t})});S(this,"maybeUpdateFrameToHighlightOnPointerMove",(t,n)=>{this.state.newElement||this.state.multiElement||this.state.selectionElement||this.state.selectedElementsAreBeingDragged||this.updateFrameToHighlight(!n&&hV(this.state.activeTool.type)?this.getTopLayerFrameAtSceneCoords(t):null)});S(this,"insertNewElements",t=>{if(!t.length)return;let n=[];for(let r of t){let i=n[n.length-1];i?.[0].frameId===r.frameId?i.push(r):n.push([r])}for(let r of n){let i=r[0].frameId,a=i?TY(this.scene.getElementsIncludingDeleted(),i):null;this.scene.insertElementsAtIndex(r,a)}});S(this,"insertNewElement",t=>{this.insertNewElements([t]);let n=t.frameId?this.scene.getNonDeletedElement(t.frameId):null;this.updateFrameToHighlight(n&&ht(n)?n:null)});S(this,"handleCanvasPointerMove",t=>{this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent;let n=He(t,this.state),{x:r,y:i}=n;this.lastPointerMoveCoords={x:r,y:i},ye.pointers.has(t.pointerId)&&ye.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let a=ye.initialScale;if(ye.pointers.size===2&&ye.lastCenter&&a&&ye.initialDistance){let g=zg(ye.pointers),E=g.x-ye.lastCenter.x,y=g.y-ye.lastCenter.y;ye.lastCenter=g;let v=Hg(Array.from(ye.pointers.values())),x=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:v/ye.initialDistance,w=x?Jt(a*x):this.state.zoom.value;this.setState(I=>{let C=Bo({viewportX:g.x,viewportY:g.y,nextZoom:w},I);return this.translateCanvas({zoom:C.zoom,scrollX:C.scrollX+2*(E/w),scrollY:C.scrollY+2*(y/w),shouldCacheIgnoreZoom:!0}),null}),this.resetShouldCacheIgnoreZoomDebounced()}else ye.lastCenter=ye.initialDistance=ye.initialScale=null;if(gr||Va||Us||Ws||tb||bo(this.state))return;let s=Jg(Ys,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;if(!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(s?_t(this.interactiveCanvas):Dt(this.interactiveCanvas,this.state)),this.maybeUpdateFrameToHighlightOnPointerMove({x:r,y:i},s),!this.state.newElement&&CI(this.state.activeTool.type)){let{originOffset:g,snapLines:E}=SI(this.scene.getNonDeletedElements(),this,{x:r,y:i},t,this.scene.getNonDeletedElementsMap());this.setState(y=>{let v=Rs(y.snapLines,E),x=y.originSnapOffset?Rs(y.originSnapOffset,g):g;return y.snapLines===v&&y.originSnapOffset===x?null:{snapLines:v,originSnapOffset:x}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(g=>g.snapLines.length?{snapLines:[]}:null);if(this.state.selectedLinearElement?.isEditing&&!this.state.selectedLinearElement.isDragging){let g=this.state.newElement?null:he.handlePointerMoveInEditMode(t,r,i,this);g&&g!==this.state.selectedLinearElement&&$t(()=>{this.setState({selectedLinearElement:g})})}if(uY(this.state.activeTool.type)){let{newElement:g}=this.state;if(!g&&Bs(this.state)){let E=oe(r,i),y=this.scene.getNonDeletedElementsMap(),v=tn(E,this.scene.getNonDeletedElements(),y,J1(this.state.zoom));v?this.setState({suggestedBinding:{element:v,midPoint:Q1(E,v,y,this.state.zoom)}}):this.state.suggestedBinding&&this.setState({suggestedBinding:null})}}if(this.state.multiElement&&this.state.selectedLinearElement){let{multiElement:g,selectedLinearElement:E}=this.state,{x:y,y:v,points:x}=g,w=x[x.length-1],{lastCommittedPoint:I}=E;if(Dt(this.interactiveCanvas,this.state),w===I)Wa(this.state.newElement)&&Bs(this.state)&&tn(oe(r,i),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),J1(this.state.zoom))?(this.actionManager.executeAction(It,"ui",{event:t.nativeEvent,sceneCoords:{x:r,y:i}}),this.setState({suggestedBinding:null}),this.state.activeTool.locked||(_t(this.interactiveCanvas),this.setState(A=>({newElement:null,activeTool:Qo(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:Ce({...A.selectedElementIds,[g.id]:!0},A),selectedLinearElement:new he(g,this.scene.getNonDeletedElementsMap())})))):In(oe(r-y,i-v),w)>=L1?(this.scene.mutateElement(g,{points:[...x,oe(r-y,i-v)]},{informMutation:!1,isDragging:!1}),en(this.state.selectedLinearElement?.initialState,"initialState must be set"),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:x[x.length-1],selectedPointsIndices:[g.points.length-1],initialState:{...this.state.selectedLinearElement.initialState,lastClickedPoint:g.points.length-1}}})):Ee(this.interactiveCanvas,Re.POINTER);else if(x.length>2&&I&&In(oe(r-y,i-v),I)<L1){Ee(this.interactiveCanvas,Re.POINTER),this.scene.mutateElement(g,{points:x.slice(0,-1)},{informMutation:!1,isDragging:!1});let C=g.points.length-1;this.setState({selectedLinearElement:{...E,selectedPointsIndices:E.selectedPointsIndices?[...new Set(E.selectedPointsIndices.map(A=>Math.min(A,C)))]:E.selectedPointsIndices,lastCommittedPoint:g.points[C],initialState:{...E.initialState,lastClickedPoint:C}}})}else{L5(x,this.state.zoom.value)&&Ee(this.interactiveCanvas,Re.POINTER);let C=this.scene.getNonDeletedElementsMap();if(q1(g)){let k=tn(oe(r,i),this.scene.getNonDeletedElements(),C);Tn("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(g,k)}en(this.state.selectedLinearElement,"Expected selectedLinearElement to be set to operate on a linear element");let A=he.handlePointerMove(t.nativeEvent,this,r,i,this.state.selectedLinearElement);A&&this.setState(A)}return}if(this.state.activeTool.type==="arrow"){let g=tn(oe(r,i),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),J1(this.state.zoom)),E=oe(r,i),y=this.scene.getNonDeletedElementsMap();g&&!lV(E,g,y)&&this.setState({suggestedBinding:{element:g,midPoint:Q1(E,g,y,this.state.zoom)}})}let c=!!t.buttons,m=this.state.activeTool.type==="laser";if(c||!m&&this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let p=this.scene.getNonDeletedElements(),d=this.scene.getSelectedElements(this.state);if(this.isHittingTextAutoResizeHandle(d,n)){Ee(this.interactiveCanvas,Re.POINTER);return}if(d.length===1&&!s&&!this.state.selectedLinearElement?.isEditing){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&this.state.openDialog?.name!=="elementLinkSelector"&&!(d.length===1&&Ht(d[0]))&&!(kt(d[0])&&(this.editorInterface.userAgent.isMobileDevice||d[0].points.length===2))){let g=X5(p,this.state,r,i,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);if(g&&g.transformHandleType){Ee(this.interactiveCanvas,V5(g));return}}}else if(d.length>1&&!s&&this.state.openDialog?.name!=="elementLinkSelector"){let g=K5(Ua(d),r,i,this.state.zoom,t.pointerType,this.editorInterface);if(g){Ee(this.interactiveCanvas,V5({transformHandleType:g}));return}}if(Mt(this.state))return;let u=this.getElementAtPosition(r,i,{preferSelected:!0,includeLockedElements:!0}),b=null;if(u&&u.locked?b=null:b=u,this.handleIframeLikeElementHover({hitElement:b,scenePointer:n,moveEvent:t})||(this.hitLinkElement=this.getElementLinkAtPosition(n,u)),this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id])Ee(this.interactiveCanvas,Re.POINTER),Sw(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap());else{if(Th(),m)return;b&&(b.link||Sn(b))&&this.state.selectedElementIds[b.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?Ee(this.interactiveCanvas,jt(b)?Re.TEXT:Re.CROSSHAIR):!t[X.CTRL_OR_CMD]&&this.isHittingCommonBoundingBoxOfSelectedElements(n,d)?Ee(this.interactiveCanvas,Re.MOVE):this.state.viewModeEnabled?Ee(this.interactiveCanvas,Re.GRAB):this.state.openDialog?.name==="elementLinkSelector"?Ee(this.interactiveCanvas,Re.AUTO):s?Ee(this.interactiveCanvas,Re.AUTO):!t[X.CTRL_OR_CMD]&&b?.id!==this.state.editingTextElement?.id?(b||this.isHittingCommonBoundingBoxOfSelectedElements(n,d))&&!b?.locked&&(!b||!Ht(b)||!(b.startBinding||b.endBinding))&&(this.state.activeTool.type!=="lasso"||d.length>0)&&Ee(this.interactiveCanvas,Re.MOVE):Ee(this.interactiveCanvas,Re.AUTO),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i)}this.state.openDialog?.name==="elementLinkSelector"&&b?this.setState(g=>({hoveredElementIds:Rs(g.hoveredElementIds,ho({editingGroupId:g.editingGroupId,selectedElementIds:{[b.id]:!0}},this.scene.getNonDeletedElements(),g,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!b&&this.setState(g=>({hoveredElementIds:Rs(g.hoveredElementIds,{})}))});S(this,"handleEraser",(t,n)=>{let r=this.eraserTrail.addPointToPath(n.x,n.y,t.altKey);this.elementsPendingErasure=new Set(r),this.triggerRender()});S(this,"handleTouchMove",t=>{Vs=!0});S(this,"handleCanvasPointerDown",t=>{let n=this.scene.getSelectedElements(this.state);if(!t.ctrlKey){let g=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==g&&this.setState({isBindingEnabled:g})}let r=He(t,this.state),{x:i,y:a}=r;this.lastPointerMoveCoords={x:i,y:a};let l=t.target;if(l.setPointerCapture&&l.setPointerCapture(t.pointerId),this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.searchMatches&&(this.setState(g=>({searchMatches:g.searchMatches&&{focusedId:null,matches:g.searchMatches.matches.map(E=>({...E,focus:!1}))}})),this.updateEditorAtom(Gf,null)),ot.get(wo)&&this.updateEditorAtom(wo,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.state.openPopup&&this.setState({openPopup:null}),this.updateGestureOnPointerDown(t),t.pointerType==="touch"&&this.state.newElement&&this.state.newElement.type==="freedraw"){let g=this.state.newElement;this.updateScene({...g.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==g.id)}:{},appState:{newElement:null,editingTextElement:null,suggestedBinding:null,selectedElementIds:Ce(Object.keys(this.state.selectedElementIds).filter(E=>E!==g.id).reduce((E,y)=>(E[y]=this.state.selectedElementIds[y],E),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?Pt.EVENTUALLY:Pt.NEVER});return}let s=document.getSelection();if(s?.anchorNode&&s.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(g=>({penMode:!0,penDetected:!0})),!this.editorInterface.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.editorInterface=N1(this.editorInterface,{isTouchScreen:!0})),Us||Ws||(this.lastPointerDownEvent=t,this.handleCanvasZoomUsingZDrag(t)||this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===qo.ERASER&&this.state.activeTool.type!==Jo.eraser){this.setState({activeTool:Qo(this.state,{type:Jo.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let g=()=>{E(),y?.(),Mt(this.state)&&this.setState({activeTool:Qo(this.state,{...this.state.activeTool.lastActiveTool||{type:Jo.selection},lastActiveToolBeforeEraser:null})})},E=Xe(window,Q.POINTER_UP,g,{once:!0}),y;requestAnimationFrame(()=>{y=this.missingPointerEventCleanupEmitter.once(g)})});return}if(t.button!==qo.MAIN&&t.button!==qo.TOUCH&&t.button!==qo.ERASER||ye.pointers.size>1)return;let c=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleTextAutoResizeHandlePointerDown(n,c.origin)||this.handleDraggingScrollBar(t,c)||(this.clearSelectionIfNotUsingSelection(),this.handleSelectionOnPointerDown(t,c))||!(!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 g=c.hit.element&&this.isASelectedElement(c.hit.element);(t.altKey&&t[X.CTRL_OR_CMD]&&!c.resize.handleType||!c.hit.hasHitCommonBoundingBoxOfSelectedElements&&!c.resize.handleType&&!g)&&(this.lassoTrail.hasCurrentTrail||this.lassoTrail.startPath(c.origin.x,c.origin.y,t.shiftKey),c.drag.blockDragging=this.editorInterface.formFactor==="desktop"),this.editorInterface.formFactor!=="desktop"&&c.hit.element&&!g&&(this.setState(v=>{let x={...v.selectedElementIds,[c.hit.element.id]:!0},w=[];Object.keys(v.selectedElementIds).forEach(C=>{let A=this.scene.getElement(C);A&&w.push(A)});let I=c.hit.element;if(ht(I))V1(w,I.id).forEach(C=>{delete x[C.id]});else if(I.frameId)x[I.frameId]&&delete x[I.id];else{let C=I.groupIds,A=new Set(C.flatMap(k=>ei(this.scene.getNonDeletedElements(),k)).filter(k=>ht(k)).map(k=>k.id));A.size>0&&w.forEach(k=>{k.frameId&&A.has(k.frameId)&&(delete x[k.id],k.groupIds.flatMap(L=>ei(this.scene.getNonDeletedElements(),L)).forEach(L=>{delete x[L.id]}))})}return{...ho({editingGroupId:v.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),v,this),showHyperlinkPopup:I.link||Sn(I)?"info":!1}}),c.hit.wasAddedToSelection=!0)}else this.state.activeTool.type==="text"?this.handleTextOnPointerDown(t,c):this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line"?this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,c):this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,c):this.state.activeTool.type==="custom"?Dt(this.interactiveCanvas,this.state):this.state.activeTool.type===Jo.frame||this.state.activeTool.type===Jo.magicframe?this.createFrameElementOnPointerDown(c,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(c.lastCoords.x,c.lastCoords.y):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.state.activeTool.type!=="image"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,c);this.props?.onPointerDown?.(this.state.activeTool,c),this.onPointerDownEmitter.trigger(this.state.activeTool,c,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(c.lastCoords.x,c.lastCoords.y);let p=this.onPointerMoveFromPointerDownHandler(c),d=this.onPointerUpFromPointerDownHandler(c),u=this.onKeyDownFromPointerDownHandler(c),b=this.onKeyUpFromPointerDownHandler(c);this.missingPointerEventCleanupEmitter.once(g=>d(g||t.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener(Q.POINTER_MOVE,p),window.addEventListener(Q.POINTER_UP,d),window.addEventListener(Q.KEYDOWN,u),window.addEventListener(Q.KEYUP,b),c.eventListeners.onMove=p,c.eventListeners.onUp=d,c.eventListeners.onKeyUp=b,c.eventListeners.onKeyDown=u)});S(this,"handleCanvasPointerUp",t=>{if(Tn("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.removePointer(t),this.lastPointerUpIsDoubleClick=this.isDoubleClick(this.lastPointerUpEvent,t),this.lastPointerUpEvent=t,!t.ctrlKey){let a=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==a&&this.setState({isBindingEnabled:a})}let n=He({clientX:t.clientX,clientY:t.clientY},this.state),{x:r,y:i}=n;if(this.lastPointerMoveCoords={x:r,y:i},!this.handleIframeLikeCenterClick()){if(this.editorInterface.isTouchScreen){let a=this.getElementAtPosition(n.x,n.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(n,a)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?this.handleElementLinkClick(t):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})}});S(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(Vs=!1,fr?Vs=!0:fr=window.setTimeout(()=>{fr=0,Vs||this.handleCanvasContextMenu(t)},MW))});S(this,"resetContextMenuTimer",()=>{clearTimeout(fr),fr=0,Vs=!1});S(this,"maybeCleanupAfterMissingPointerUp",t=>{ti?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});S(this,"handleCanvasZoomUsingZDrag",t=>{if(!(Va&&ye.pointers.size<=1&&t.button===qo.MAIN))return!1;Ws=!0,this.focusContainer(),t.preventDefault();let n=t.clientX,r=t.clientY,i=t.clientX,a=this.state.zoom.value,l=200,s=ds(m=>{let p=Jt(a*2**((m.clientX-i)/l));this.translateCanvas(d=>({...Bo({viewportX:n,viewportY:r,nextZoom:p},d),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced()}),c=Ge(ti=()=>{ti=null,Ws=!1,Va||this.restoreCursorAfterZoomKey(),window.removeEventListener(Q.POINTER_MOVE,s),window.removeEventListener(Q.POINTER_UP,c),window.removeEventListener(Q.BLUR,c),s.flush()});return window.addEventListener(Q.BLUR,c),window.addEventListener(Q.POINTER_MOVE,s,{passive:!0}),window.addEventListener(Q.POINTER_UP,c),!0});S(this,"restoreCursorAfterZoomKey",()=>{this.state.viewModeEnabled&&this.state.activeTool.type!=="laser"?Ee(this.interactiveCanvas,Re.GRAB):Ns(this.state.activeTool.type)?_t(this.interactiveCanvas):Dt(this.interactiveCanvas,this.state)});S(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(ye.pointers.size<=1&&(t.button===qo.WHEEL||t.button===qo.MAIN&&gr||bo(this.state)||this.state.viewModeEnabled&&this.state.activeTool.type!=="laser")))return!1;Us=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let n=!1,r=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);Ee(this.interactiveCanvas,Re.GRABBING);let{clientX:i,clientY:a}=t,l=ds(c=>{let m=i-c.clientX,p=a-c.clientY;if(i=c.clientX,a=c.clientY,r&&!n&&(Math.abs(m)>1||Math.abs(p)>1)){n=!0;let d=b=>{document.body.removeEventListener(Q.PASTE,d),b.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener(Q.PASTE,d),window.removeEventListener(Q.POINTER_UP,u)},100)};document.body.addEventListener(Q.PASTE,d),window.addEventListener(Q.POINTER_UP,u)}this.translateCanvas({scrollX:this.state.scrollX-m/this.state.zoom.value,scrollY:this.state.scrollY-p/this.state.zoom.value})}),s=Ge(ti=()=>{ti=null,Us=!1,gr||(this.state.viewModeEnabled&&this.state.activeTool.type!=="laser"?Ee(this.interactiveCanvas,Re.GRAB):Dt(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(Q.POINTER_MOVE,l),window.removeEventListener(Q.POINTER_UP,s),window.removeEventListener(Q.BLUR,s),l.flush()});return window.addEventListener(Q.BLUR,s),window.addEventListener(Q.POINTER_MOVE,l,{passive:!0}),window.addEventListener(Q.POINTER_UP,s),!0});S(this,"clearSelectionIfNotUsingSelection",()=>{Ns(this.state.activeTool.type)||this.setState({selectedElementIds:Ce({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});S(this,"handleSelectionOnPointerDown",(t,n)=>{if(Ns(this.state.activeTool.type)){let r=this.scene.getNonDeletedElements(),i=this.scene.getNonDeletedElementsMap(),a=this.scene.getSelectedElements(this.state);if(a.length===1&&!this.state.selectedLinearElement?.isEditing&&!Ht(a[0])&&!(kt(a[0])&&(this.editorInterface.userAgent.isMobileDevice||a[0].points.length===2))&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let l=X5(r,this.state,n.origin.x,n.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);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=K5(Ua(a),n.origin.x,n.origin.y,this.state.zoom,t.pointerType,this.editorInterface));if(n.resize.handleType)n.resize.isResizing=!0,n.resize.offset=R1(JY(n.resize.handleType,a,i,n.origin.x,n.origin.y)),a.length===1&&kt(a[0])&&a[0].points.length===2&&(n.resize.arrowDirection=QY(n.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let d=this.state.selectedLinearElement,u=he.handlePointerDown(t,this,this.store,n.origin,d,this.scene);if(u.hitElement&&(n.hit.element=u.hitElement),u.linearElementEditor&&this.setState({selectedLinearElement:u.linearElementEditor}),u.didAddPoint)return!0;let b=this.scene.getNonDeletedElementsMap(),g=he.getElement(d.elementId,b);if(g&&on(g)){let{hitFocusPoint:E,pointerOffset:y}=mV(g,n,b,this.state);if(E)return this.setState({selectedLinearElement:{...d,hoveredFocusPointBinding:E,draggedFocusPointBinding:E,pointerOffset:y}}),!1}}let l=this.getElementsAtPosition(n.origin.x,n.origin.y,{includeLockedElements:!0}),s=l.filter(d=>!d.locked),c=this.getElementAtPosition(n.origin.x,n.origin.y,{allHitElements:l});if((!c||c.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),c&&c.locked&&!s.some(d=>this.state.selectedElementIds[d.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,c),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 m=n.hit.element,p=n.hit.allHitElements.some(d=>this.isASelectedElement(d));if((m===null||!p)&&!t.shiftKey&&!n.hit.hasHitCommonBoundingBoxOfSelectedElements&&(!this.state.selectedLinearElement?.isEditing||m&&m?.id!==this.state.selectedLinearElement?.elementId)&&this.clearSelection(m),this.state.selectedLinearElement?.isEditing)this.setState(d=>({selectedLinearElement:d.selectedLinearElement?{...d.selectedLinearElement,isEditing:!!m&&m.id===this.state.selectedLinearElement?.elementId}:null,selectedElementIds:d.selectedLinearElement?Ce({[d.selectedLinearElement.elementId]:!0},this.state):Ce({},d)}));else if(m!=null){if(t[X.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[m.id]||(n.hit.wasAddedToSelection=!0),this.setState(d=>({...XY(d,m),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[m.id]||(this.state.editingGroupId&&!W5(m,this.state.editingGroupId)&&this.setState({selectedElementIds:Ce({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!p&&!n.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(d=>{let u={...d.selectedElementIds,[m.id]:!0},b=[];if(Object.keys(d.selectedElementIds).forEach(g=>{let E=this.scene.getElement(g);E&&b.push(E)}),ht(m))V1(b,m.id).forEach(g=>{delete u[g.id]});else if(m.frameId)u[m.frameId]&&delete u[m.id];else{let g=m.groupIds,E=new Set(g.flatMap(y=>ei(this.scene.getNonDeletedElements(),y)).filter(y=>ht(y)).map(y=>y.id));E.size>0&&b.forEach(y=>{y.frameId&&E.has(y.frameId)&&(delete u[y.id],y.groupIds.flatMap(v=>ei(this.scene.getNonDeletedElements(),v)).forEach(v=>{delete u[v.id]}))})}return d.openDialog?.name==="elementLinkSelector"&&(m.groupIds.some(g=>d.selectedGroupIds[g])||(u={[m.id]:!0})),{...ho({editingGroupId:d.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),d,this),showHyperlinkPopup:m.link||Sn(m)?"info":!1}}),n.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});S(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);C5(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,initialCaretSceneCoords:{x:r,y:i}}),_t(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:Qo(this.state,{type:this.state.preferredSelectionTool.type})})});S(this,"handleFreeDrawElementOnPointerDown",(t,n,r)=>{let[i,a]=xt(r.origin.x,r.origin.y,null),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),s=t.pressure===.5,c=aY({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:[oe(0,0)],pressures:s?[]:[t.pressure]});this.insertNewElement(c),this.setState(m=>{let p={...m.selectedElementIds};return delete p[c.id],{selectedElementIds:Ce(p,m)}}),this.setState({newElement:c,suggestedBinding:null})});S(this,"insertIframeElement",({sceneX:t,sceneY:n,width:r,height:i})=>{let[a,l]=xt(t,n,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=lY({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.insertNewElement(s),s});S(this,"insertEmbeddableElement",({sceneX:t,sceneY:n,link:r})=>{let[i,a]=xt(t,n,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=cp(r);if(!l)return;l.error instanceof URIError&&this.setToast({message:f("toast.unrecognizedLinkFormat"),closable:!0});let s=v5({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.insertNewElement(s),s});S(this,"newImagePlaceholder",({sceneX:t,sceneY:n,addToFrameUnderCursor:r=!0})=>{let[i,a]=xt(t,n,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=r?this.getTopLayerFrameAtSceneCoords({x:i,y:a}):null,s=100/this.state.zoom.value;return dY({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})});S(this,"handleLinearElementOnPointerDown",(t,n,r)=>{if(t.ctrlKey&&$t(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.state.multiElement){let{multiElement:i,selectedLinearElement:a}=this.state;if(en(a,"selectedLinearElement is expected to be set"),i.type==="line"&&L5(i.points,this.state.zoom.value)){$t(()=>{this.setState({selectedLinearElement:{...a,lastCommittedPoint:i.points[i.points.length-1],initialState:{...a.initialState,lastClickedPoint:-1}}})}),this.actionManager.executeAction(It);return}if(Ht(i)&&i.points.length>1){this.actionManager.executeAction(It,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}let{x:l,y:s}=i,{lastCommittedPoint:c}=a,m=Bs(this.state)&&tn(oe(this.lastPointerMoveCoords?.x??l+i.points[i.points.length-1][0],this.lastPointerMoveCoords?.y??s+i.points[i.points.length-1][1]),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(on(i)&&m||i.points.length>1&&c&&In(oe(r.origin.x-l,r.origin.y-s),c)<L1){this.actionManager.executeAction(It,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}this.setState(p=>({selectedElementIds:Ce({...p.selectedElementIds,[i.id]:!0},p)})),Ee(this.interactiveCanvas,Re.POINTER)}else{let[i,a]=xt(r.origin.x,r.origin.y,t[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:s,currentItemEndArrowhead:c}=this.state,[m,p]=n==="arrow"?[s,c]:[null,null],d=n==="arrow"?sY({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===ur.round?{type:rp.PROPORTIONAL_RADIUS}:null,startArrowhead:m,endArrowhead:p,locked:!1,frameId:l?l.id:null,elbowed:this.state.currentItemArrowType===ur.elbow,fixedSegments:this.state.currentItemArrowType===ur.elbow?[]:null}):mY({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:rp.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:l?l.id:null}),u=oe(r.origin.x,r.origin.y),b=this.scene.getNonDeletedElementsMap(),g=Bs(this.state)?tn(u,this.scene.getNonDeletedElements(),b):null;this.scene.mutateElement(d,{points:[oe(0,0),oe(0,0)]}),this.insertNewElement(d),on(d)&&iV(d,new Map([[0,{point:oe(0,0),isDragging:!1}]]),u[0],u[1],this.scene,this.state,{newArrow:!0,altKey:t.altKey,initialBinding:!0,angleLocked:a5(t.nativeEvent)}),$t(()=>{this.setState(E=>{let y=null,v=E.selectedElementIds;if(kt(d)){y=new he(d,this.scene.getNonDeletedElementsMap());let x=d.points.length-1;y={...y,selectedPointsIndices:[x],initialState:{...y.initialState,arrowStartIsInside:t.altKey,lastClickedPoint:x,origin:oe(r.origin.x,r.origin.y)}}}return v=this.state.activeTool.locked?E.selectedElementIds:Ce({[d.id]:!0},E),{...E,bindMode:"orbit",newElement:d,startBoundElement:g,suggestedBinding:g&&on(d)?{element:g,midPoint:Q1(u,g,b,this.state.zoom)}:null,selectedElementIds:v,selectedLinearElement:y}})}),on(d)&&Tn("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(d,g)}});S(this,"createGenericElementOnPointerDown",(t,n)=>{let[r,i]=xt(n.origin.x,n.origin.y,this.lastPointerDownEvent?.[X.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=v5({type:"embeddable",...l}):s=cY({type:t,...l}),s.type==="selection"?this.setState({selectionElement:s}):(this.insertNewElement(s),this.setState({multiElement:null,newElement:s}))});S(this,"createFrameElementOnPointerDown",(t,n)=>{let[r,i]=xt(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:r,y:i,opacity:this.state.currentItemOpacity,locked:!1,...$o},l=n===Jo.magicframe?I5(a):iY(a);this.insertNewElement(l),this.setState({multiElement:null,newElement:l})});S(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});S(this,"eraseElements",()=>{let t=!1;this.elementsPendingErasure.forEach(r=>{let i=this.scene.getElement(r);if(on(i)){if(i.startBinding){let a=this.scene.getElement(i.startBinding.elementId);dp(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(l=>l.id!==i.id)})}if(i.endBinding){let a=this.scene.getElement(i.endBinding.elementId);dp(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(l=>l.id!==i.id)})}}else H1(i)&&i.boundElements?.forEach(a=>{if(a.type==="arrow"){let l=this.scene.getElement(a.id);l?.startBinding?.elementId===i.id&&dp(l,this.scene.getElementsMapIncludingDeleted(),{startBinding:null}),l?.endBinding?.elementId===i.id&&dp(l,this.scene.getElementsMapIncludingDeleted(),{endBinding:null})}})});let n=this.scene.getElementsIncludingDeleted().map(r=>this.elementsPendingErasure.has(r.id)||r.frameId&&this.elementsPendingErasure.has(r.frameId)||O1(r)&&this.elementsPendingErasure.has(r.containerId)?(t=!0,hr(r,{isDeleted:!0})):r);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(n))});S(this,"initializeImage",async(t,n)=>{if(!Tp(n))throw new Error(f("errors.unsupportedFileType"));let r=n.type,i=n.size>=this.state.dontResizeLimitMBs*1024*1024;if(Ee(this.interactiveCanvas,"wait"),r===jo.svg)try{n=Pp(D5(await n.text()),n.name)}catch(s){throw console.warn(s),new Error(f("errors.svgImageInsertError"))}else if(i)try{n=await this.props.compressImageFile(n,{maxWidthOrHeight:vW}),console.info("Excalidraw: image resized")}catch(s){console.error("Error trying to resizing image file on insertion",s)}if(n.size>d5)throw new Error(f("errors.fileTooBig",{maxSize:`${Math.trunc(d5/1024/1024)}MB`}));let a=await(this.props.generateIdForFile?.(n)||Gb(n));if(console.info("Excalidraw File ID:",a),!a)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(f("errors.imageInsertError"));let l=this.files[a]?.dataURL||await kp(n);return new Promise(async(s,c)=>{try{let m=this.getLatestInitializedImageElement(t,a);if(this.addMissingFiles([{mimeType:r,id:a,dataURL:l,created:Date.now(),lastRetrieved:Date.now()}]),!this.imageCache.get(a)){this.addNewImagesToImageCache();let{erroredFiles:d}=await this.updateImageCache([m]);if(d.size)throw new Error("Image cache update resulted with an error.")}let p=await this.imageCache.get(a)?.image;if(p&&this.state.newElement?.id!==m.id){m=this.getLatestInitializedImageElement(t,a);let d=this.getImageNaturalDimensions(m,p);Object.assign(m,d)}s(m)}catch(m){console.error(m),c(new Error(f("errors.imageInsertError")))}})});S(this,"getLatestInitializedImageElement",(t,n)=>{let r=this.scene.getElement(t.id)??t;return hr(r,{fileId:n})});S(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 $s({description:"Image",extensions:Object.keys(TW),multiple:!0});this.insertImages(a,r,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:Qo(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction(It)})}});S(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,c=t.y+t.height/2-a/2;return{x:s,y:c,width:l,height:a,crop:null}});S(this,"updateImageCache",async(t,n=this.files)=>{let{updatedFiles:r,erroredFiles:i}=await wY({imageCache:this.imageCache,fileIds:t.map(a=>a.fileId),files:n});return i.size&&(this.store.scheduleAction(Pt.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(a=>Fs(a)&&i.has(a.fileId)?hr(a,{status:"error"}):a))),{updatedFiles:r,erroredFiles:i}});S(this,"addNewImagesToImageCache",async(t=yY(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)&&zs.delete(a);i.size&&this.scene.triggerUpdate()}});S(this,"scheduleImageRefresh",fW(()=>{this.addNewImagesToImageCache()},SW));S(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.interactiveCanvas.addEventListener(Q.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(Q.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener(Q.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(Q.TOUCH_END,this.onTouchEnd))});S(this,"insertImages",async(t,n,r)=>{let i=50/this.state.zoom.value,a=J5(t.map(()=>this.newImagePlaceholder({sceneX:n,sceneY:r})),n,r,i);this.insertNewElements(a);let l=await Promise.all(a.map(async(d,u)=>{try{return await this.initializeImage(d,await ol(t[u]))}catch(b){return this.setState({errorMessage:b.message||f("errors.imageInsertError")}),hr(d,{isDeleted:!0})}})),s=lp(l),c=J5(l.filter(d=>!d.isDeleted),n,r,i),m=lp(c),p=this.scene.getElementsIncludingDeleted().map(d=>m.get(d.id)??s.get(d.id)??d);this.updateScene({appState:{selectedElementIds:Ce(Object.fromEntries(c.map(d=>[d.id,!0])),this.state)},elements:p,captureUpdate:Pt.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(It)})});S(this,"handleAppOnDrop",async t=>{let{x:n,y:r}=He(t,this.state),i=await Ni(t),a=i.getFiles();if(a.length===1){let{file:p,fileHandle:d}=a[0];if(p&&(p.type===jo.png||p.type===jo.svg))try{let u=await oc(p,this.state,this.scene.getElementsIncludingDeleted(),d);this.syncActionResult({...u,appState:{...u.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:Pt.IMMEDIATELY});return}catch(u){if(u.name!=="EncodingError")throw new Error(f("alerts.couldNotLoadInvalidFile"))}}let l=a.map(p=>p.file).filter(p=>Tp(p));if(l.length>0&&this.isToolSupported("image"))return this.insertImages(l,n,r);let s=i.getData(jo.excalidrawlibIds),c=i.getData(jo.excalidrawlib);if(s||c){try{let p=null;if(s){let{itemIds:d}=JSON.parse(s);p=(await this.library.getLatestLibrary()).filter(b=>d.includes(b.id))}else c&&(p=Hb(c));p?.length&&(p=p.map(d=>({...d,elements:F1({type:"everything",elements:d.elements,randomizeSeed:!0,preserveFrameChildrenOrder:!0}).duplicatedElements})),this.addElementsFromPasteOrLibrary({elements:ta(p),position:t,files:null}))}catch(p){this.setState({errorMessage:p.message})}return}if(a.length>0){let{file:p,fileHandle:d}=a[0];p&&await this.loadFileToCanvas(p,d)}let m=i.findByType(jo.text);if(m){let p=m.value;if(p&&U1(p,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(p)||cp(p)?.type==="video")){let d=this.insertEmbeddableElement({sceneX:n,sceneY:r,link:_1(p)});d&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[d.id]:!0}}))}}});S(this,"loadFileToCanvas",async(t,n)=>{t=await ol(t);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await Sp(t,this.state,r,n)}catch(a){let l=a instanceof Mb;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===jo.excalidraw?(lk(r.concat(i.data.elements)),this.store.scheduleMicroAction({action:Pt.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:Pt.IMMEDIATELY})):i.type===jo.excalidrawlib&&await this.library.updateLibrary({libraryItems:t,merge:!0,openLibraryMenu:!0}).catch(a=>{console.error(a),this.setState({errorMessage:f("errors.importLibraryError")})})}catch(r){this.setState({isLoading:!1,errorMessage:r.message})}});S(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==qo.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type)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",c=this.excalidrawContainerRef.current,{top:m,left:p}=c.getBoundingClientRect(),d=t.clientX-p,u=t.clientY-m;ce("contextMenu","openContextMenu",s),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,...ho({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:kt(i)?new he(i,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:d,items:this.getContextMenuItems(s)}})})});S(this,"maybeDragNewGenericElement",(t,n,r=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&t.boxSelection.hasOccurred&&this.state.activeTool.type!=="eraser"){Z5({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:Ga(t.origin.x,a.x),height:Ga(t.origin.y,a.y),shouldMaintainAspectRatio:_s(n),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let l=this.state.newElement;if(!l)return;let[s,c]=xt(a.x,a.y,n[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=Fs(l)&&this.imageCache.get(l.fileId)?.image,p=m&&!(m instanceof Promise)?m.width/m.height:null;this.maybeCacheReferenceSnapPoints(n,[l]);let{snapOffset:d,snapLines:u}=TI(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:c-t.originInGrid.y},this.scene.getNonDeletedElementsMap());s+=d.x,c+=d.y,this.setState({snapLines:u}),on(l)||Z5({newElement:l,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:s,y:c,width:Ga(t.originInGrid.x,s),height:Ga(t.originInGrid.y,c),shouldMaintainAspectRatio:Qr(l)?!_s(n):_s(n),shouldResizeFromCenter:i5(n),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:p,originOffset:this.state.originSnapOffset,informMutation:r}),this.setState({newElement:l}),(this.state.activeTool.type===Jo.frame||this.state.activeTool.type===Jo.magicframe)&&this.setState({elementsToHighlight:K1(this.scene.getNonDeletedElements(),l,this.state,this.scene.getNonDeletedElementsMap())})});S(this,"maybeHandleCrop",(t,n)=>{if(!this.state.croppingElementId)return!1;let r=t.resize.handleType,i=t.lastCoords,[a,l]=xt(i.x-t.resize.offset.x,i.y-t.resize.offset.y,n[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(r&&s&&Qr(s)){let c=t.originalElements.get(s.id),m=Fs(s)&&this.imageCache.get(s.fileId)?.image;if(c&&Qr(c)&&m&&!(m instanceof Promise)){let[p,d]=xt(i.x,i.y,n[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:p-t.originInGrid.x,y:d-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(n,[s]);let{snapOffset:b,snapLines:g}=Yg([s],[c],this,n,u,r);this.scene.mutateElement(s,FY(s,this.scene.getNonDeletedElementsMap(),r,m.naturalWidth,m.naturalHeight,a+b.x,l+b.y,n.shiftKey?c.width/c.height:void 0)),sp(s,this.scene),this.setState({isCropping:r&&r!=="rotation",snapLines:g})}return!0}return!1});S(this,"maybeHandleResize",(t,n)=>{let r=this.scene.getSelectedElements(this.state),i=r.filter(p=>ht(p)),a=t.resize.handleType;if(i.length>0&&a==="rotation"||r.length===1&&Ht(r[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let l=t.lastCoords,[s,c]=xt(l.x-t.resize.offset.x,l.y-t.resize.offset.y,n[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=new Map;if(i.forEach(p=>{V1(this.scene.getNonDeletedElements(),p.id).forEach(u=>{m.set(p.id+u.id,{x:u.x-p.x,y:u.y-p.y})})}),!this.state.selectedElementsAreBeingDragged){let[p,d]=xt(l.x,l.y,n[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:p-t.originInGrid.x,y:d-t.originInGrid.y},b=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(n,r);let{snapOffset:g,snapLines:E}=Yg(r,ee(b,this.state),this,n,u,a);s+=g.x,c+=g.y,this.setState({snapLines:E})}if(eV(t.originalElements,a,r,this.scene,a5(n),i5(n),r.some(p=>Qr(p))?!_s(n):_s(n),s,c,t.resize.center.x,t.resize.center.y)){let p=new Set;return i.forEach(d=>{K1(this.scene.getNonDeletedElements(),d,this.state,this.scene.getNonDeletedElementsMap()).forEach(u=>p.add(u))}),this.setState({elementsToHighlight:[...p]}),!0}return!1});S(this,"getContextMenuItems",t=>{let n=[];if(t==="canvas")return this.state.viewModeEnabled?[Vi,ia,Kn]:[mh,at,xd,at,su,Lw,at,Vi,Dl,Rl,Nl,ia,Kn];if(n.push(xd),this.state.viewModeEnabled)return[Yi,...n];let r=this.editorInterface.formFactor==="desktop"?[at,ru,iu,au,lu]:[];return[at,Ed,Yi,mh,at,nI,rI,iI,at,_g,lh,sh,at,...n,at,nh,Fg,hh,gh,fw,rh,...r,at,ch,dh,at,pa,at,Ol,Sd,at,$I,cu,zl,at,ml]});S(this,"handleWheel",Ge(t=>{if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement||t.target instanceof HTMLElement&&t.target.classList.contains(B1.FRAME_NAME))){t[X.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),Us)return;let{deltaX:n,deltaY:r}=t;if(t.metaKey||t.ctrlKey||this.state.wheelZoomsOnDefault){let i=Math.sign(r),a=LW*100,l=Math.abs(r),s=r;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=>({...Bo({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:Jt(c)},m),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}))}));S(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:ye.pointers})});S(this,"resetShouldCacheIgnoreZoomDebounced",h5(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));S(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:c,offsetTop:m,offsetLeft:p}=this.state;if(r===s&&i===c&&a===p&&l===m){t&&t();return}this.setState({width:r,height:i,offsetLeft:a,offsetTop:l},()=>{t&&t()})}});S(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});S(this,"watchState",()=>{});let n=Pn(),{viewModeEnabled:r=!1,zenModeEnabled:i=!1,gridModeEnabled:a=!1,objectsSnapModeEnabled:l=!1,theme:s=n.theme,name:c=`${f("labels.untitled")}-${f5()}`,wheelZoomsOnDefault:m=!1}=t;this.state={...n,theme:s,exportWithDarkMode:s===za.DARK,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:r,zenModeEnabled:i,objectsSnapModeEnabled:l,gridModeEnabled:a??n.gridModeEnabled,name:c,width:window.innerWidth,height:window.innerHeight,wheelZoomsOnDefault:m},this.refreshEditorInterface(),this.stylesPanelMode=up(this.editorInterface),this.id=EW(),this.library=new o2(this),this.actionManager=new am(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new j5,this.canvas=document.createElement("canvas"),this.rc=bW.canvas(this.canvas),this.renderer=new cs(this.scene),this.visibleElements=[],this.store=new nV(this),this.history=new ls(this.store),this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new nn(this.scene),this.history=new ls(this.store),this.actionManager.registerAll(Sc),this.actionManager.registerAction(cI(this.history)),this.actionManager.registerAction(dI(this.history)),this.api=this.createExcalidrawAPI()}createExcalidrawAPI(){return{isDestroyed:!1,updateScene:this.updateScene,applyDeltas:this.applyDeltas,mutateElement:this.mutateElement,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,addImageElementsToScene:this.addImageElementsToScene,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},scrollToViewport:this.scrollToViewport,scrollToContent:this.scrollToContent,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:n=>{this.actionManager.registerAction(n)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.setCursor,resetCursor:this.resetCursor,getEditorInterface:()=>this.editorInterface,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:n=>this.onChangeEmitter.on(n),onIncrement:n=>this.store.onStoreIncrementEmitter.on(n),onPointerDown:n=>this.onPointerDownEmitter.on(n),onPointerUp:n=>this.onPointerUpEmitter.on(n),onScrollChange:n=>this.onScrollChangeEmitter.on(n),onUserFollow:n=>this.onUserFollowEmitter.on(n),onStateChange:this.onStateChange,onEvent:this.onEvent}}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(ip).includes(i)&&ob.set(r,i)}break}}handleSkipBindMode(){if(this.state.selectedLinearElement?.initialState&&!this.state.selectedLinearElement.initialState.arrowStartIsInside){en(this.lastPointerMoveCoords,"Missing last pointer move coords when changing bind skip mode for arrow start");let t=this.scene.getNonDeletedElementsMap(),n=tn(oe(this.lastPointerMoveCoords.x,this.lastPointerMoveCoords.y),this.scene.getNonDeletedElements(),t),r=he.getElement(this.state.selectedLinearElement.elementId,t);r?.startBinding&&n?.id===r.startBinding.elementId&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:!0}}})}if(this.state.bindMode==="orbit"&&(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),$t(()=>{this.setState({bindMode:"skip"})}),this.lastPointerMoveCoords&&this.state.selectedLinearElement?.selectedPointsIndices&&this.state.selectedLinearElement?.selectedPointsIndices.length)){let{x:t,y:n}=this.lastPointerMoveCoords,r=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;en(r,"Last event must exist");let i=t-this.state.selectedLinearElement.pointerOffset.x,a=n-this.state.selectedLinearElement.pointerOffset.y,l=this.state.multiElement?he.handlePointerMove(r,this,i,a,this.state.selectedLinearElement):he.handlePointDragging(r,this,i,a,this.state.selectedLinearElement);l&&this.setState(l)}}resetDelayedBindMode(){this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode!=="orbit"&&setTimeout(()=>this.setState({bindMode:"orbit"}))}handleDelayedBindModeChange(t,n){if(t.isDeleted||Ht(t))return;let r=()=>{if(this.bindModeHandler=null,en(this.lastPointerMoveCoords,"Expected lastPointerMoveCoords to be set"),!this.state.multiElement){if(!this.state.selectedLinearElement||!this.state.selectedLinearElement.selectedPointsIndices||!this.state.selectedLinearElement.selectedPointsIndices.length)return;let b=this.state.selectedLinearElement.selectedPointsIndices.includes(0),g=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1);if(!b&&!g||b&&g)return}let{x:p,y:d}=this.lastPointerMoveCoords,u=tn(oe(p,d),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(u&&this.state.bindMode!=="skip"){en(this.state.selectedLinearElement?.elementId===t.id,"The selectedLinearElement is expected to not change while a bind mode timeout is ticking");let b=this.state.selectedLinearElement.initialState.arrowStartIsInside||t.startBinding?.elementId===u.id;$t(()=>{en(this.state.selectedLinearElement,"this.state.selectedLinearElement must exist"),this.setState({bindMode:"inside",selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:b}}})});let g=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;en(g,"Last event must exist");let E=p-this.state.selectedLinearElement.pointerOffset.x,y=d-this.state.selectedLinearElement.pointerOffset.y,v=this.state.multiElement?he.handlePointerMove(g,this,E,y,this.state.selectedLinearElement):he.handlePointDragging(g,this,E,y,this.state.selectedLinearElement);v&&this.setState(v)}},i=!1;if(this.state.selectedLinearElement?.selectedPointsIndices){let p=this.scene.getNonDeletedElementsMap(),d=this.state.selectedLinearElement.selectedPointsIndices.includes(0),u=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1),b=d?n:t.startBinding&&p.get(t.startBinding.elementId),g=u?n:t.endBinding&&p.get(t.endBinding.elementId),E=b&&ek(b,p),y=g&&ek(g,p);i=!!(E&&y&&b.id!==g.id&&aV(E,y))}let a=this.state.selectedLinearElement?.selectedPointsIndices?.includes(0),l=this.state.selectedLinearElement?.selectedPointsIndices?.includes(t.points.length-1),s=a?"startBinding":l?"endBinding":null,c=a?"endBinding":l?"startBinding":null,m=c&&t[c]?.mode==="inside"&&t[c]?.elementId===n?.id||s&&t[s]?.mode==="inside"&&n?.id===t[s]?.elementId;s&&c&&t[s]?.mode==="inside"&&n?.id!==t[s]?.elementId&&t[c]?.elementId!==t[s]?.elementId&&this.scene.mutateElement(t,{[s]:{...t[s],mode:"orbit"}},{informMutation:!1,isDragging:!0}),!n||this.previousHoveredBindableElement&&n.id!==this.previousHoveredBindableElement.id?(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode==="inside"&&$t(()=>{this.setState({bindMode:"orbit"})}),this.previousHoveredBindableElement=null):!this.bindModeHandler&&(!this.state.newElement||!t.startBinding||i)&&!m&&(this.bindModeHandler=setTimeout(r,$W)),this.previousHoveredBindableElement=n}cacheEmbeddableRef(t,n){n&&this.iFrameRefs.set(t.id,n)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleIframeLikeCenterClick(){if(!this.lastPointerDownEvent||!this.lastPointerUpEvent||this.lastPointerDownEvent.button!==qo.MAIN||gr||!oY(this.state.activeTool.type,["laser","selection","lasso"]))return!1;let t=oe(He({clientX:this.lastPointerDownEvent.clientX,clientY:this.lastPointerDownEvent.clientY},this.state)),n=oe(He({clientX:this.lastPointerUpEvent.clientX,clientY:this.lastPointerUpEvent.clientY},this.state));if(In(t,n)>s5)return!1;let i=this.getElementAtPosition(t[0],t[1]);if(!(i&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<=300&&ye.pointers.size<2&&z1(i)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(i,this.lastPointerUpEvent,n[0],n[1]))))return!1;let l=i;if(this.state.activeEmbeddable?.element===l&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:l,state:"active"},selectedElementIds:{[l.id]:!0},newElement:null,selectionElement:null})},100),Ya(l)))return!0;let s=this.getHTMLIFrameElement(l);if(!s?.contentWindow)return!0;if(s.src.includes("youtube")){let c=ob.get(l.id);switch(c||(ob.set(l.id,ip.UNSTARTED),s.contentWindow.postMessage(JSON.stringify({event:"listening",id:l.id}),"*")),c){case ip.PLAYING:case ip.BUFFERING:s.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:s.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}return s.src.includes("player.vimeo.com")&&s.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*"),!0}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=>Sn(a)&&this.embedsValidationStatus.get(a.id)===!0||Ya(a));return ve(yV,{children:i.map(a=>{let{x:l,y:s}=ap({sceneX:a.x,sceneY:a.y},this.state),c=M5(a,n,r,this.state,this.scene.getNonDeletedElementsMap()),m=this.initializedEmbeds.has(a.id);if(c&&!m&&this.initializedEmbeds.add(a.id),!(c||m))return null;let d;if(Ya(a)){d=null;let y=(a.customData?.generationData??this.magicGenerations.get(a.id))||{status:"error",message:"No generation data",code:"ERR_NO_GENERATION_DATA"};if(y.status==="done"){let v=y.html;d={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>v}}else if(y.status==="pending")d={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>_5(`
22
22
  <style>
23
23
  html, body {
24
24
  width: 100%;