@myoc/excalidraw 0.19.533 → 0.19.535

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,24 +1,24 @@
1
- import{$ as Si,A as ix,B as xu,C as us,D as vc,E as yu,F as ax,G as sx,H as Ic,I as hs,J as Tc,K as Sc,L as gs,M as lx,N as cx,O as dx,P as Cc,Q as Ar,R as v3,S as Dr,T as Ti,V as mx,X as px,Y as ux,Z as Pc,_ as hx,a as gu,aa as fs,b as Vn,ba as Es,c as ho,ca as gx,d as Mr,da as kc,e as wi,ea as fx,f as Yn,fa as Ex,g as Qb,ga as bx,h as De,ha as wu,i as ex,ia as xx,j as ce,ja as yx,k as vi,ka as wx,l as Go,la as Lr,m as tx,n as fu,o as nx,p as ms,q as ox,r as wc,s as rx,t as Eu,u as bu,v as go,w as Ho,x as on,y as ps,z as Ii}from"./chunk-AS35EYHE.js";import{a as S}from"./chunk-6D6KWUBN.js";import{G as hu}from"./chunk-DARW3V66.js";import{c as Jb}from"./chunk-5XKZK2GL.js";import{b as qb,c as w3,d as v}from"./chunk-SRAX5OIU.js";import mK,{useCallback as pK,useContext as uK,useEffect as hK,useRef as gK,useState as fK}from"react";import{applyDarkModeFilter as DVe,DEFAULT_IMAGE_OPTIONS as Tn,DEFAULT_UI_OPTIONS as E3,getStrokeWidthByKey as LVe,isShallowEqual as EK}from"@excalidraw/common";import Kk from"clsx";import YV from"lodash.throttle";import vn,{useContext as Oo}from"react";import{flushSync as Ft}from"react-dom";import XV from"roughjs/bin/rough";import{nanoid as KV}from"nanoid";import{clamp as oc,pointFrom as oe,pointDistance as so,vector as $k,pointRotateRads as lb,vectorFromPoint as cb,vectorSubtract as Zk,vectorDot as jk,vectorNormalize as qk}from"@excalidraw/math";import{CODES as Tr,shouldResizeFromCenter as Jk,shouldMaintainAspectRatio as rc,shouldRotateWithDiscreteAngle as Qk,isArrowKey as db,KEYS as X,APP_NAME as $V,CURSOR_TYPE as Me,DEFAULT_STROKE_STREAMLINE as ZV,DEFAULT_STROKE_STREAMLINE_PRECISE as jV,DEFAULT_TRANSFORM_HANDLE_SPACING as qV,DEFAULT_VERTICAL_ALIGN as eM,DRAGGING_THRESHOLD as tM,ELEMENT_SHIFT_TRANSLATE_AMOUNT as JV,ELEMENT_TRANSLATE_AMOUNT as nM,EVENT as J,FRAME_STYLE as _o,IMAGE_MIME_TYPES as QV,IMAGE_RENDER_TIMEOUT as eY,LINE_CONFIRM_THRESHOLD as mb,MIME_TYPES as lo,MQ_RIGHT_SIDEBAR_MIN_WIDTH as tY,POINTER_BUTTON as zn,ROUNDNESS as Vp,SCROLL_TIMEOUT as nY,TAP_TWICE_TIMEOUT as oM,TEXT_TO_CENTER_SNAP_THRESHOLD as oY,THEME as ic,TOUCH_CTX_MENU_TIMEOUT as rY,VERTICAL_ALIGN as iY,YOUTUBE_STATES as Yp,ZOOM_STEP as aY,MIN_ZOOM as sY,POINTER_EVENTS as is,TOOL_TYPE as Gn,supportsResizeObserver as lY,DEFAULT_COLLISION_THRESHOLD as rM,DEFAULT_TEXT_ALIGN as cY,ARROW_TYPE as Sr,DEFAULT_REDUCED_GLOBAL_ALPHA as dY,isLocalLink as mY,normalizeLink as Xp,toValidURL as pY,getGridPoint as Mt,getLineHeight as iM,debounce as aM,distance as as,getFontString as pb,getNearestScrollableContainer as uY,isInputLike as sM,isToolIcon as hY,isWritableElement as ac,sceneCoordsToViewportCoords as Kp,tupleToCoors as ub,viewportCoordsToSceneCoords as ke,wrapEvent as gY,updateObject as hb,updateActiveTool as tn,isTransparent as fY,muteFSAbortError as EY,isTestEnv as jM,isDevEnv as qM,updateStable as sc,addEventListener as ye,normalizeEOL as bY,getDateTime as lM,isShallowEqual as cM,arrayToMap as lc,applyDarkModeFilter as xY,AppEventBus as yY,randomInteger as wY,CLASSES as gb,Emitter as co,MINIMUM_ARROW_SIZE as vY,DOUBLE_TAP_POSITION_THRESHOLD as dM,BIND_MODE_TIMEOUT as IY,invariant as mo,getFeatureFlag as Ro,createUserAgentDescriptor as JM,getFormFactor as TY,deriveStylesPanelMode as iu,isIOS as SY,isBrave as CY,isSafari as PY,loadDesktopUIModePreference as kY,setDesktopUIMode as MY,isSelectionLikeTool as $p,oneOf as mM,getStrokeWidthByKey as AY}from"@excalidraw/common";import{getObservedAppState as DY,getCommonBounds as ss,getElementAbsoluteCoords as pM,bindOrUnbindBindingElements as uM,fixBindingsAfterDeletion as LY,getHoveredElementForBinding as Cr,isBindingEnabled as Zp,updateBoundElements as jp,LinearElementEditor as ge,newElementWith as po,newFrameElement as _Y,newFreeDrawElement as RY,newEmbeddableElement as hM,newMagicFrameElement as NY,newIframeElement as BY,newArrowElement as FY,newElement as OY,newImageElement as zY,newLinearElement as GY,newTextElement as gM,refreshTextDimensions as HY,deepCopyElement as fM,duplicateElements as EM,hasBoundTextElement as bM,isArrowElement as cc,isBindingElement as uo,isBindingElementType as UY,isBoundToContainer as xM,isFrameLikeElement as Tt,isImageElement as Hn,isEmbeddableElement as No,isInitializedImageElement as fi,isLinearElement as Ot,isLinearElementType as WY,isUsingAdaptiveRadius as VY,isIframeElement as fb,isIframeLikeElement as dc,isTextBindableContainer as yM,isElbowArrow as Yt,isBindableElement as Eb,isTextElement as Xt,getNormalizedDimensions as YY,isElementCompletelyInViewport as XY,isElementInViewport as wM,isInvisiblySmallElement as vM,generateThumbHash as KY,getCornerRadius as $Y,isPathALoop as IM,embeddableURLValidator as bb,maybeParseEmbedSrc as ZY,getEmbedLink as qp,getInitializedImageElements as jY,normalizeSVG as TM,updateImageCache as xb,getBoundTextElement as yb,getContainerCenter as wb,getContainerElement as SM,isValidTextContainer as CM,redrawTextBoundingBox as qY,hasBoundingBox as JY,getCommonFrameId as PM,getFrameChildren as vb,getFrameChildrenInsertionIndex as QY,isCursorInFrame as kM,addElementsToFrame as Ib,replaceAllElementsInFrame as eX,removeElementsFromFrame as tX,getElementsInResizingFrame as Tb,getElementsInNewFrame as nX,getContainingFrame as Sb,elementOverlapsWithFrame as oX,updateFrameMembershipOfSelectedElements as MM,isElementInFrame as AM,getFrameLikeTitle as rX,filterElementsEligibleAsFrameChildren as iX,hitElementBoundText as aX,hitElementBoundingBoxOnly as sX,hitElementItself as mc,getVisibleSceneBounds as lX,cropElement as cX,wrapText as dX,isElementLink as DM,isMeasureTextSupported as mX,normalizeText as pX,measureText as LM,getLineHeightInPx as _M,getApproxMinLineWidth as uX,getApproxMinLineHeight as hX,getMinTextElementWidth as gX,ShapeCache as Ei,getRenderOpacity as fX,editGroupForSelectedElement as EX,getElementsInGroup as bi,getSelectedGroupIdForElement as bX,getSelectedGroupIds as xX,isElementInGroup as RM,isSelectedViaGroup as yX,selectGroupsForSelectedElements as Un,syncInvalidIndices as QM,syncMovedIndices as NM,excludeElementsInFramesFromSelection as wX,getSelectionStateForElements as BM,makeNextSelectedElementIds as Ae,getResizeOffsetXY as vX,getResizeArrowDirection as IX,transformElements as TX,getCursorForResizingElement as FM,getElementWithTransformHandleType as OM,getTransformHandleTypeFromCoords as zM,dragNewElement as GM,dragSelectedElements as SX,getDragOffsetXY as CX,Scene as HM,Store as PX,CaptureUpdateAction as Kt,hitElementBoundingBox as kX,isLineElement as Cb,isSimpleArrow as Pb,StoreDelta as UM,positionElementsOnGrid as WM,calculateFixedPointForNonElbowArrowBinding as VM,bindOrUnbindBindingElement as MX,mutateElement as Jp,getElementBounds as YM,doBoundsIntersect as AX,isPointInElement as XM,maxBindingDistance_simple as KM,convertToExcalidrawElements as DX,getSnapOutlineMidPoint as kb,handleFocusPointDrag as LX,handleFocusPointHover as _X,handleFocusPointPointerDown as RX,handleFocusPointPointerUp as NX,maybeHandleArrowPointlikeDrag as Qp,getUncroppedWidthAndHeight as BX,getActiveTextElement as $M,isEligibleFrameChildType as FX,getBindingStrategyForDraggingBindingElementEndpoints as OX,isNonDeletedElement as eu}from"@excalidraw/element";import{KEYS as Qu,MOBILE_ACTION_BUTTON_BG as B3,updateActiveTool as F3}from"@excalidraw/common";import{getNonDeletedElements as $c}from"@excalidraw/element";import{fixBindingsAfterDeletion as O3}from"@excalidraw/element";import{LinearElementEditor as b0}from"@excalidraw/element/linearElementEditor";import{newElementWith as Kc}from"@excalidraw/element";import{getContainerElement as x0}from"@excalidraw/element";import{isBoundToContainer as Yc,isElbowArrow as z3,isFrameLikeElement as G3}from"@excalidraw/element";import{getFrameChildren as H3}from"@excalidraw/element";import{getElementsInGroup as eh,selectGroupsForSelectedElements as U3}from"@excalidraw/element";import{CaptureUpdateAction as Xc}from"@excalidraw/element";import{isDevEnv as C3}from"@excalidraw/common";import{atom as Je,createStore as I3}from"jotai";import{createIsolation as T3}from"jotai-scope";var vx=T3();var{useAtom:He,useSetAtom:Ix,useAtomValue:Tx,useStore:IK}=vx,Sx=vx.Provider,Et=I3();var S3=qb({"./locales/ar-SA.json":()=>import("./locales/ar-SA-E6E2KRZ5.js"),"./locales/az-AZ.json":()=>import("./locales/az-AZ-RDMGQYMZ.js"),"./locales/bg-BG.json":()=>import("./locales/bg-BG-CHUVCTEA.js"),"./locales/bn-BD.json":()=>import("./locales/bn-BD-ZMOEPIQW.js"),"./locales/bn-IN.json":()=>import("./locales/bn-IN-OHZAWF5C.js"),"./locales/ca-ES.json":()=>import("./locales/ca-ES-K4A7PUP4.js"),"./locales/cs-CZ.json":()=>import("./locales/cs-CZ-RVP6YORC.js"),"./locales/da-DK.json":()=>import("./locales/da-DK-ENJX4GIQ.js"),"./locales/de-CH.json":()=>import("./locales/de-CH-VYBKDWRU.js"),"./locales/de-DE.json":()=>import("./locales/de-DE-6MCXRRVA.js"),"./locales/el-GR.json":()=>import("./locales/el-GR-WEDZAIPA.js"),"./locales/en.json":()=>import("./locales/en-RNZ7CUK6.js"),"./locales/es-ES.json":()=>import("./locales/es-ES-LLEALNRO.js"),"./locales/eu-ES.json":()=>import("./locales/eu-ES-M4Y34NOW.js"),"./locales/fa-IR.json":()=>import("./locales/fa-IR-XSMVGGRV.js"),"./locales/fi-FI.json":()=>import("./locales/fi-FI-K2D3DDUS.js"),"./locales/fr-FR.json":()=>import("./locales/fr-FR-EQKMVJSO.js"),"./locales/gl-ES.json":()=>import("./locales/gl-ES-RCPQTYJV.js"),"./locales/he-IL.json":()=>import("./locales/he-IL-RHAGKYKH.js"),"./locales/hi-IN.json":()=>import("./locales/hi-IN-3UDCLKHN.js"),"./locales/hu-HU.json":()=>import("./locales/hu-HU-T3REA7IL.js"),"./locales/id-ID.json":()=>import("./locales/id-ID-KW4N25IN.js"),"./locales/it-IT.json":()=>import("./locales/it-IT-LJVXK4LO.js"),"./locales/ja-JP.json":()=>import("./locales/ja-JP-GGGK3KPX.js"),"./locales/kaa.json":()=>import("./locales/kaa-TSEHAWJR.js"),"./locales/kab-KAB.json":()=>import("./locales/kab-KAB-IWXTEINV.js"),"./locales/kk-KZ.json":()=>import("./locales/kk-KZ-6GNYSAU7.js"),"./locales/km-KH.json":()=>import("./locales/km-KH-ILUXSOEW.js"),"./locales/ko-KR.json":()=>import("./locales/ko-KR-FJWHM3OT.js"),"./locales/ku-TR.json":()=>import("./locales/ku-TR-DRDDAECA.js"),"./locales/lt-LT.json":()=>import("./locales/lt-LT-IYFIPPJI.js"),"./locales/lv-LV.json":()=>import("./locales/lv-LV-7F754RSS.js"),"./locales/mr-IN.json":()=>import("./locales/mr-IN-BYRIZ3PC.js"),"./locales/my-MM.json":()=>import("./locales/my-MM-RBYJSIJ6.js"),"./locales/nb-NO.json":()=>import("./locales/nb-NO-EKTZIYSK.js"),"./locales/nl-NL.json":()=>import("./locales/nl-NL-UECYYIUK.js"),"./locales/nn-NO.json":()=>import("./locales/nn-NO-JPXGIDBA.js"),"./locales/oc-FR.json":()=>import("./locales/oc-FR-4RSIVDPZ.js"),"./locales/pa-IN.json":()=>import("./locales/pa-IN-GPHFXISR.js"),"./locales/percentages.json":()=>import("./locales/percentages-Q7USCRWZ.js"),"./locales/pl-PL.json":()=>import("./locales/pl-PL-HKHPAEVK.js"),"./locales/pt-BR.json":()=>import("./locales/pt-BR-UBWN6CKP.js"),"./locales/pt-PT.json":()=>import("./locales/pt-PT-XDY4S4SD.js"),"./locales/ro-RO.json":()=>import("./locales/ro-RO-2B3UXAQO.js"),"./locales/ru-RU.json":()=>import("./locales/ru-RU-EW52HAV3.js"),"./locales/si-LK.json":()=>import("./locales/si-LK-PIEHI4JX.js"),"./locales/sk-SK.json":()=>import("./locales/sk-SK-TZXYYIFD.js"),"./locales/sl-SI.json":()=>import("./locales/sl-SI-VUDQNDF3.js"),"./locales/sv-SE.json":()=>import("./locales/sv-SE-IJTJRA7S.js"),"./locales/ta-IN.json":()=>import("./locales/ta-IN-Q5PXZT3U.js"),"./locales/th-TH.json":()=>import("./locales/th-TH-HK66ZQXE.js"),"./locales/tr-TR.json":()=>import("./locales/tr-TR-CLYYPVPL.js"),"./locales/uk-UA.json":()=>import("./locales/uk-UA-YR4OMRYF.js"),"./locales/uz-UZ.json":()=>import("./locales/uz-UZ-CY4LSY5Y.js"),"./locales/vi-VN.json":()=>import("./locales/vi-VN-UDAEMEBG.js"),"./locales/zh-CN.json":()=>import("./locales/zh-CN-EGBL23FT.js"),"./locales/zh-HK.json":()=>import("./locales/zh-HK-ZOJEG32A.js"),"./locales/zh-TW.json":()=>import("./locales/zh-TW-TM5HZP7M.js")});var P3=85,Xn={code:"en",label:"English"},Pi=[Xn,...[{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=>Jb[e.code]>=P3).sort((e,n)=>e.label>n.label?1:-1)],Ac="__test__";C3()&&Pi.unshift({code:Ac,label:"test language"},{code:`${Ac}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var Ci=Xn,Mc={},Dc=async e=>{if(Ci=e,document.documentElement.dir=Ci.rtl?"rtl":"ltr",document.documentElement.lang=Ci.code,e.code.startsWith(Ac))Mc={};else try{Mc=await S3(`./locales/${Ci.code}.json`)}catch(n){console.error(`Failed to load language ${e.code}:`,n.message),Mc=hu}Et.set(Px,e.code)},Kn=()=>Ci,Cx=(e,n)=>{for(let t=0;t<n.length;++t){let o=n[t];if(e[o]===void 0)return;e=e[o]}if(typeof e=="string")return e},f=(e,n,t)=>{if(Ci.code.startsWith(Ac))return`\u202A[[${n?`${e}(${JSON.stringify(n).slice(1,-1)})`:e}]]\u202C`;let o=e.split("."),r=Cx(Mc,o)||Cx(hu,o)||t;if(r===void 0){let i=`Can't find translation for ${e}`;if(S.PROD)return console.warn(i),"";throw new Error(i)}if(n)for(let i in n)r=r.replace(`{{${i}}}`,String(n[i]));return r},Px=Je(Xn.code),Le=()=>{let e=Tx(Px);return{t:f,langCode:e}};import k3 from"clsx";import Qe from"react";import{THEME as M3}from"@excalidraw/common";import{Fragment as Ie,jsx as h,jsxs as R}from"react/jsx-runtime";var Cn=e=>"var(--icon-fill-color)",kx=e=>e===M3.LIGHT?"#fff":"#1e1e1e",M=(e,n=512)=>{let{width:t=512,height:o=t,mirror:r,style:i,...a}=typeof n=="number"?{width:n}:n;return h("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${t} ${o}`,className:k3({"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"},se={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},At={width:40,height:20},OK=M(R("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),zK=M(R("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),Mx=M("M320 112C434.9 112 528 205.1 528 320C528 434.9 434.9 528 320 528C205.1 528 112 434.9 112 320C112 205.1 205.1 112 320 112zM320 576C461.4 576 576 461.4 576 320C576 178.6 461.4 64 320 64C178.6 64 64 178.6 64 320C64 461.4 178.6 576 320 576zM288 248C288 234.7 277.3 224 264 224C250.7 224 240 234.7 240 248L240 392C240 405.3 250.7 416 264 416C277.3 416 288 405.3 288 392L288 248zM400 248C400 234.7 389.3 224 376 224C362.7 224 352 234.7 352 248L352 392C352 405.3 362.7 416 376 416C389.3 416 400 405.3 400 392L400 248z",640),bs=M(R("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),Ax=M(R("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),Dx=M(R("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),vu=M(R("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),fo=M(R("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"})})]}),se),Uo=M(R("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"})]}),se),Lx=M(h("g",{fill:"currentColor",children:h("path",{d:"M12 2a5 5 0 0 1 5 5v3a3 3 0 0 1 3 3v6a3 3 0 0 1 -3 3h-10a3 3 0 0 1 -3 -3v-6a3 3 0 0 1 3 -3v-3a5 5 0 0 1 5 -5m0 12a2 2 0 0 0 -1.995 1.85l-.005 .15a2 2 0 1 0 2 -2m0 -10a3 3 0 0 0 -3 3v3h6v-3a3 3 0 0 0 -3 -3"})}),{width:24,height:24}),_x=M(R(Ie,{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"}),Rx=M(R(Ie,{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"}),Nx=M(R(Ie,{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"}),GK=M(h("g",{fill:"currentColor",children:h("path",{d:"M39.9 32.889a.326.326 0 0 0-.279-.056c-2.094-3.083-4.774-6-7.343-8.833l-.419-.472a.212.212 0 0 0-.056-.139.586.586 0 0 0-.167-.111l-.084-.083-.056-.056c-.084-.167-.28-.278-.475-.167-.782.39-1.507.973-2.206 1.528-.92.722-1.842 1.445-2.708 2.25a8.405 8.405 0 0 0-.977 1.028c-.14.194-.028.361.14.444-.615.611-1.23 1.223-1.843 1.861a.315.315 0 0 0-.084.223c0 .083.056.166.111.194l1.09.833v.028c1.535 1.528 4.244 3.611 7.12 5.861.418.334.865.667 1.284 1 .195.223.39.473.558.695.084.11.28.139.391.055.056.056.14.111.196.167a.398.398 0 0 0 .167.056.255.255 0 0 0 .224-.111.394.394 0 0 0 .055-.167c.029 0 .028.028.056.028a.318.318 0 0 0 .224-.084l5.082-5.528a.309.309 0 0 0 0-.444Zm-14.63-1.917a.485.485 0 0 0 .111.14c.586.5 1.2 1 1.843 1.555l-2.569-1.945-.251-.166c-.056-.028-.112-.084-.168-.111l-.195-.167.056-.056.055-.055.112-.111c.866-.861 2.346-2.306 3.1-3.028-.81.805-2.43 3.167-2.095 3.944Zm8.767 6.89-2.122-1.612a44.713 44.713 0 0 0-2.625-2.5c1.145.861 2.122 1.611 2.262 1.75 1.117.972 1.06.806 1.815 1.445l.921.666a1.06 1.06 0 0 1-.251.25Zm.558.416-.056-.028c.084-.055.168-.111.252-.194l-.196.222ZM1.089 5.75c.055.361.14.722.195 1.056.335 1.833.67 3.5 1.284 4.75l.252.944c.084.361.223.806.363.917 1.424 1.25 3.602 3.11 5.947 4.889a.295.295 0 0 0 .363 0s0 .027.028.027a.254.254 0 0 0 .196.084.318.318 0 0 0 .223-.084c2.988-3.305 5.221-6.027 6.813-8.305.112-.111.14-.278.14-.417.111-.111.195-.25.307-.333.111-.111.111-.306 0-.39l-.028-.027c0-.055-.028-.139-.084-.167-.698-.666-1.2-1.138-1.731-1.638-.922-.862-1.871-1.75-3.881-3.75l-.028-.028c-.028-.028-.056-.056-.112-.056-.558-.194-1.703-.389-3.127-.639C6.087 2.223 3.21 1.723.614.944c0 0-.168 0-.196.028l-.083.084c-.028.027-.056.055-.224.11h.056-.056c.028.167.028.278.084.473 0 .055.112.5.112.555l.782 3.556Zm15.496 3.278-.335-.334c.084.112.196.195.335.334Zm-3.546 4.666-.056.056c0-.028.028-.056.056-.056Zm-2.038-10c.168.167.866.834 1.033.973-.726-.334-2.54-1.167-3.379-1.445.838.167 1.983.334 2.346.472ZM1.424 2.306c.419.722.754 3.222 1.089 5.666-.196-.778-.335-1.555-.503-2.278-.251-1.277-.503-2.416-.838-3.416.056 0 .14 0 .252.028Zm-.168-.584c-.112 0-.223-.028-.307-.028 0-.027 0-.055-.028-.055.14 0 .223.028.335.083Zm-1.089.222c0-.027 0-.027 0 0ZM39.453 1.333c.028-.11-.558-.61-.363-.639.42-.027.42-.666 0-.666-.558.028-1.144.166-1.675.25-.977.194-1.982.389-2.96.61-2.205.473-4.383.973-6.561 1.557-.67.194-1.424.333-2.066.666-.224.111-.196.333-.084.472-.056.028-.084.028-.14.056-.195.028-.363.056-.558.083-.168.028-.252.167-.224.334 0 .027.028.083.028.11-1.173 1.556-2.485 3.195-3.909 4.945-1.396 1.611-2.876 3.306-4.356 5.056-4.719 5.5-10.052 11.75-15.943 17.25a.268.268 0 0 0 0 .389c.028.027.056.055.084.055-.084.084-.168.14-.252.222-.056.056-.084.111-.084.167a.605.605 0 0 0-.111.139c-.112.111-.112.305.028.389.111.11.307.11.39-.028.029-.028.029-.056.056-.056a.44.44 0 0 1 .615 0c.335.362.67.723.977 1.028l-.698-.583c-.112-.111-.307-.083-.39.028-.113.11-.085.305.027.389l7.427 6.194c.056.056.112.056.196.056s.14-.028.195-.084l.168-.166c.028.027.083.027.111.027.084 0 .14-.027.196-.083 10.052-10.055 18.15-17.639 27.42-24.417.083-.055.111-.166.111-.25.112 0 .196-.083.251-.194 1.704-5.194 2.039-9.806 2.15-12.083v-.028c0-.028.028-.056.028-.083.028-.056.028-.084.028-.084a1.626 1.626 0 0 0-.111-1.028ZM21.472 9.5c.446-.5.893-1.028 1.34-1.5-2.876 3.778-7.65 9.583-14.408 16.5 4.607-5.083 9.242-10.333 13.068-15ZM5.193 35.778h.084-.084Zm3.462 3.194c-.027-.028-.027-.028 0-.028v.028Zm4.16-3.583c.224-.25.448-.472.699-.722 0 0 0 .027.028.027-.252.223-.475.445-.726.695Zm1.146-1.111c.14-.14.279-.334.446-.5l.028-.028c1.648-1.694 3.351-3.389 5.082-5.111l.028-.028c.419-.333.921-.694 1.368-1.028a379.003 379.003 0 0 0-6.952 6.695ZM24.794 6.472c-.921 1.195-1.954 2.778-2.82 4.028-2.736 3.944-11.532 13.583-11.727 13.75a1976.983 1976.983 0 0 1-8.042 7.639l-.167.167c-.14-.167-.14-.417.028-.556C14.49 19.861 22.03 10.167 25.074 5.917c-.084.194-.14.36-.28.555Zm4.83 5.695c-1.116-.64-1.646-1.64-1.34-2.611l.084-.334c.028-.083.084-.194.14-.277.307-.5.754-.917 1.257-1.167.027 0 .055 0 .083-.028-.028-.056-.028-.139-.028-.222.028-.167.14-.278.335-.278.335 0 1.369.306 1.76.639.111.083.223.194.335.305.14.167.363.445.474.667.056.028.112.306.196.445.056.222.111.472.084.694-.028.028 0 .194-.028.194a2.668 2.668 0 0 1-.363 1.028c-.028.028-.028.056-.056.084l-.028.027c-.14.223-.335.417-.53.556-.643.444-1.369.583-2.095.389 0 0-.195-.084-.28-.111Zm8.154-.834a39.098 39.098 0 0 1-.893 3.167c0 .028-.028.083 0 .111-.056 0-.084.028-.14.056-2.206 1.61-4.356 3.305-6.506 5.028 1.843-1.64 3.686-3.306 5.613-4.945.558-.5.949-1.139 1.06-1.861l.28-1.667v-.055c.14-.334.67-.195.586.166Z",fill:"currentColor"})}),{width:40,height:40,fill:"none"}),Lc=M(R("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}),ki=M(R("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}),Mi=M(R("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),Ai=M(R("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),Di=M(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"})]}),H),_c=M(R("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),Wo=M(h("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),se),Bx=M(R("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),$n=M(R("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"})]}),se),Pn=M(R("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),Fx=M(R("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),_r=M(R("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"})]}),se),Rc=M(R("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),Iu=M(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),se),Tu=M(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),se),Ox=M(R("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),Rr=M(h("path",{strokeWidth:"1.25",d:"M3.333 5.833h13.334M8.333 9.167v5M11.667 9.167v5M4.167 5.833l.833 10c0 .92.746 1.667 1.667 1.667h6.666c.92 0 1.667-.746 1.667-1.667l.833-10M7.5 5.833v-2.5c0-.46.373-.833.833-.833h3.334c.46 0 .833.373.833.833v2.5"}),se),Vo=M(R("g",{strokeWidth:"1.5",children:[h("polyline",{points:"12 16 18 10 12 4"}),h("polyline",{points:"8 4 2 10 8 16"})]}),se),xs=M(R("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"})]}),se),ys=M(h("path",{clipRule:"evenodd",d:"M10 2.5h.328a6.25 6.25 0 0 0 6.6 10.372A7.5 7.5 0 1 1 10 2.493V2.5Z",stroke:"currentColor"}),se),ws=M(h("g",{stroke:"currentColor",strokeLinejoin:"round",children:h("path",{d:"M10 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM10 4.167V2.5M14.167 5.833l1.166-1.166M15.833 10H17.5M14.167 14.167l1.166 1.166M10 15.833V17.5M5.833 14.167l-1.166 1.166M5 10H3.333M5.833 5.833 4.667 4.667"})}),{...se,strokeWidth:1.5}),zx=M(R("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),vs=M(h("path",{strokeWidth:"1.25",d:"M3.333 14.167v1.666c0 .92.747 1.667 1.667 1.667h10c.92 0 1.667-.746 1.667-1.667v-1.666M5.833 9.167 10 13.333l4.167-4.166M10 3.333v10"}),se),Li=M(R("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),Gx=M(R("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),HK=M(h("path",{strokeWidth:"1.25",d:"M9.167 5.833H5.833c-1.254 0-2.5 1.282-2.5 2.5v5.834c0 1.283 1.252 2.5 2.5 2.5h5.834c1.251 0 2.5-1.25 2.5-2.5v-3.334M8.333 11.667l8.334-8.334M12.5 3.333h4.167V7.5"}),se),Hx=M(h("path",{d:"M7.5 15.833c-3.583 1.167-3.583-2.083-5-2.5m10 4.167v-2.917c0-.833.083-1.166-.417-1.666 2.334-.25 4.584-1.167 4.584-5a3.833 3.833 0 0 0-1.084-2.667 3.5 3.5 0 0 0-.083-2.667s-.917-.25-2.917 1.084a10.25 10.25 0 0 0-5.166 0C5.417 2.333 4.5 2.583 4.5 2.583a3.5 3.5 0 0 0-.083 2.667 3.833 3.833 0 0 0-1.084 2.667c0 3.833 2.25 4.75 4.584 5-.5.5-.5 1-.417 1.666V17.5",strokeWidth:"1.25"}),se),Ux=M(R("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"})]}),se),Wx=M(R("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),Nc=M(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),Is=M(R("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"})]}),se),Vx=M("M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z",{width:448,height:512}),Yx=M("M252 54L203 8a28 27 0 00-20-8H28C12 0 0 12 0 27v195c0 15 12 26 28 26h204c15 0 28-11 28-26V73a28 27 0 00-8-19zM130 213c-21 0-37-16-37-36 0-19 16-35 37-35 20 0 37 16 37 35 0 20-17 36-37 36zm56-169v56c0 4-4 6-7 6H44c-4 0-7-2-7-6V42c0-4 3-7 7-7h133l4 2 3 2a7 7 0 012 5z M296 201l87 95-188 205-78 9c-10 1-19-8-18-20l9-84zm141-14l-41-44a31 31 0 00-46 0l-38 41 87 95 38-42c13-14 13-36 0-50z",{width:448,height:512}),Bc=M(h("path",{d:"m9.257 6.351.183.183H15.819c.34 0 .727.182 1.051.506.323.323.505.708.505 1.05v5.819c0 .316-.183.7-.52 1.035-.337.338-.723.522-1.037.522H4.182c-.352 0-.74-.181-1.058-.5-.318-.318-.499-.705-.499-1.057V5.182c0-.351.181-.736.5-1.054.32-.321.71-.503 1.057-.503H6.53l2.726 2.726Z",strokeWidth:"1.25"}),se),UK=M("M384 112v352c0 26.51-21.49 48-48 48H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h80c0-35.29 28.71-64 64-64s64 28.71 64 64h80c26.51 0 48 21.49 48 48zM192 40c-13.255 0-24 10.745-24 24s10.745 24 24 24 24-10.745 24-24-10.745-24-24-24m96 114v-20a6 6 0 0 0-6-6H102a6 6 0 0 0-6 6v20a6 6 0 0 0 6 6h180a6 6 0 0 0 6-6z",{width:384,height:512}),WK=M("M204.3 5C104.9 24.4 24.8 104.3 5.2 203.4c-37 187 131.7 326.4 258.8 306.7 41.2-6.4 61.4-54.6 42.5-91.7-23.1-45.4 9.9-98.4 60.9-98.4h79.7c35.8 0 64.8-29.6 64.9-65.3C511.5 97.1 368.1-26.9 204.3 5zM96 320c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm32-128c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128-64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128 64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32z"),Su=["M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z","M13.737 9.737c2.299 -2.3 3.23 -5.095 2.081 -6.245c-1.15 -1.15 -3.945 -.217 -6.244 2.082c-2.3 2.299 -3.231 5.095 -2.082 6.244c1.15 1.15 3.946 .218 6.245 -2.081z","M7.492 11.818c.362 .362 .768 .676 1.208 .934l6.895 4.047c1.078 .557 2.255 -.075 3.692 -1.512c1.437 -1.437 2.07 -2.614 1.512 -3.692c-.372 -.718 -1.72 -3.017 -4.047 -6.895a6.015 6.015 0 0 0 -.934 -1.208"],Zn=M(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Su.map(e=>h("path",{d:e},e))]}),H),Xx=M(h("g",{strokeWidth:1.5,children:h("path",{d:"M6 18l12 -12"})}),H),Kx=M(R("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),$x=M("M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z",{width:512,height:512}),VK=M("M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),YK=M("M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),Zx=M("M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"),XK=M("M16 132h416c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H16C7.163 60 0 67.163 0 76v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"),Cu=M(h("path",{d:"M7.5 10.833 4.167 7.5 7.5 4.167M4.167 7.5h9.166a3.333 3.333 0 0 1 0 6.667H12.5",strokeWidth:"1.25"}),se),Pu=M(h("path",{d:"M12.5 10.833 15.833 7.5 12.5 4.167M15.833 7.5H6.667a3.333 3.333 0 1 0 0 6.667H7.5",strokeWidth:"1.25"}),se),jx=M("M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zM262.655 90c-54.497 0-89.255 22.957-116.549 63.758-3.536 5.286-2.353 12.415 2.715 16.258l34.699 26.31c5.205 3.947 12.621 3.008 16.665-2.122 17.864-22.658 30.113-35.797 57.303-35.797 20.429 0 45.698 13.148 45.698 32.958 0 14.976-12.363 22.667-32.534 33.976C247.128 238.528 216 254.941 216 296v4c0 6.627 5.373 12 12 12h56c6.627 0 12-5.373 12-12v-1.333c0-28.462 83.186-29.647 83.186-106.667 0-58.002-60.165-102-116.531-102zM256 338c-25.365 0-46 20.635-46 46 0 25.364 20.635 46 46 46s46-20.636 46-46c0-25.365-20.635-46-46-46z",{mirror:!0}),qx=M(h("path",{d:"M5 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 7.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 17.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM7.25 8.917l5.5-2.834M7.25 11.083l5.5 2.834",strokeWidth:"1.5"}),se),KK=M("M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"),$K=M("M16 5l-1.42 1.42-1.59-1.59V16h-1.98V4.83L9.42 6.42 8 5l4-4 4 4zm4 5v11c0 1.1-.9 2-2 2H6c-1.11 0-2-.9-2-2V10c0-1.11.89-2 2-2h3v2H6v11h12V10h-3V8h3c1.1 0 2 .89 2 2z",{width:24,height:24}),ZK=M(R("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),jK=M(R(Ie,{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}),qK=M(h("path",{stroke:"currentColor",strokeWidth:"40",fill:"currentColor",d:"M148 560a318 318 0 0 0 522 110 316 316 0 0 0 0-450 316 316 0 0 0-450 0c-11 11-21 22-30 34v4h47c25 0 46 21 46 46s-21 45-46 45H90c-13 0-25-6-33-14-9-9-14-20-14-33V156c0-25 20-45 45-45s45 20 45 45v32l1 1a401 401 0 0 1 623 509l212 212a42 42 0 0 1-59 59L698 757A401 401 0 0 1 65 570a42 42 0 0 1 83-10z"}),{width:1024}),Jx=R("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"})]}),Qx=R("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"})]}),ku=M(Qx,H),Mu=M(Qx,{...H,style:{transform:"rotate(180deg)"}}),Au=M(Jx,H),Du=M(Jx,{...H,style:{transform:"rotate(180deg)"}}),Lu=M(R(Ie,{children:[R("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"})})})]}),se),_u=M(R(Ie,{children:[R("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"})})})]}),se),Ru=M(R(Ie,{children:[R("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"})})})]}),se),Nu=M(R(Ie,{children:[R("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"})})})]}),se),e1=M(R(Ie,{children:[R("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"})})})]}),se),t1=M(R(Ie,{children:[R("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"})})})]}),se),Bu=M(R("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"})]}),se),Fu=M(R("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"})]}),se),Fc=M(R("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),JK=M("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm115.7 272l-176 101c-15.8 8.8-35.7-2.5-35.7-21V152c0-18.4 19.8-29.8 35.7-21l176 107c16.4 9.2 16.4 32.9 0 42z"),QK=M("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm96 328c0 8.8-7.2 16-16 16H176c-8.8 0-16-7.2-16-16V176c0-8.8 7.2-16 16-16h160c8.8 0 16 7.2 16 16v160z"),rn=M(R(Ie,{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"})})})]}),se),e$=M("M464 0c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48H176c-26.51 0-48-21.49-48-48V48c0-26.51 21.49-48 48-48h288M176 416c-44.112 0-80-35.888-80-80V128H48c-26.51 0-48 21.49-48 48v288c0 26.51 21.49 48 48 48h288c26.51 0 48-21.49 48-48v-48H176z",{mirror:!0}),t$=M("M11.553 22.894a.998.998 0 00.894 0s3.037-1.516 5.465-4.097C19.616 16.987 21 14.663 21 12V5a1 1 0 00-.649-.936l-8-3a.998.998 0 00-.702 0l-8 3A1 1 0 003 5v7c0 2.663 1.384 4.987 3.088 6.797 2.428 2.581 5.465 4.097 5.465 4.097zm-1.303-8.481l6.644-6.644a.856.856 0 111.212 1.212l-7.25 7.25a.856.856 0 01-1.212 0l-3.75-3.75a.856.856 0 111.212-1.212l3.144 3.144z",{width:24}),n$=M("M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48zm32-48h224V288l-23.5-23.5c-4.7-4.7-12.3-4.7-17 0L176 352l-39.5-39.5c-4.7-4.7-12.3-4.7-17 0L80 352v64zm48-240c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48z",{width:384,height:512}),Ou=Qe.memo(({theme:e})=>M(R(Ie,{children:[h("path",{d:"M25 26H111V111H25",fill:Cn(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:Cn(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:Cn(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:Cn(e),strokeWidth:"2"}),R("g",{fill:kx(e),stroke:Cn(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})),zu=Qe.memo(({theme:e})=>M(R(Ie,{children:[h("path",{d:"M25 26H111V111H25",fill:Cn(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:Cn(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:Cn(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:Cn(e),strokeWidth:"2"}),R("g",{fill:kx(e),stroke:Cn(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})),n1=M(h("g",{strokeWidth:1.25,children:h("path",{d:"M5.879 2.625h8.242a3.27 3.27 0 0 1 3.254 3.254v8.242a3.27 3.27 0 0 1-3.254 3.254H5.88a3.27 3.27 0 0 1-3.254-3.254V5.88A3.27 3.27 0 0 1 5.88 2.626l-.001-.001ZM4.518 16.118l7.608-12.83m.198 13.934 5.051-9.897M2.778 9.675l9.348-6.387m-7.608 12.83 12.857-8.793"})}),se),o1=M(R(Ie,{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"})})]}),se),r1=M(R(Ie,{children:[R("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"})})})]}),se),i1=M(R(Ie,{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"})})})]}),{...se,fill:"currentColor"}),Gu=M(h(Ie,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),se),a1=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),se),s1=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),se),o$=Qe.memo(({theme:e})=>M(h("path",{d:"M6 10H34",stroke:Cn(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),l1=M(R("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),c1=M(R("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),d1=M(h("path",{d:"M2.5 12.038c1.655-.885 5.9-3.292 8.568-4.354 2.668-1.063.101 2.821 1.32 3.104 1.218.283 5.112-1.814 5.112-1.814",strokeWidth:"1.25"}),se),m1=M(h("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43",strokeWidth:"1.25"}),se),p1=M(h("path",{d:"M2.5 11.936c1.737-.879 8.627-5.346 10.42-5.268 1.795.078-.418 5.138.345 5.736.763.598 3.53-1.789 4.235-2.147M2.929 9.788c1.164-.519 5.47-3.28 6.987-3.114 1.519.165 1 3.827 2.121 4.109 1.122.281 3.839-2.016 4.606-2.42",strokeWidth:"1.25"}),se),Hu=M(R("g",{children:[h("path",{d:"M4 12 C 5 8, 6 8, 8 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8 12 C 9 16, 10 16, 12 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M12 12 C 14 8, 15 8, 16 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M16 12 C 17 16, 18 16, 19 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]}),H),Uu=M(R("g",{children:[h("path",{d:"M4 12 C 5 8, 6 8, 8 12",fill:"none",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8 12 C 9 16, 10 16, 12 12",fill:"none",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M12 12 C 14 8, 15 8, 16 12",fill:"none",strokeWidth:"2.75",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M16 12 C 17 16, 18 16, 19 12",fill:"none",strokeWidth:"3.25",strokeLinecap:"round",strokeLinejoin:"round"})]}),H),u1=M(R("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"})]}),se),h1=M(R("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),g1=Qe.memo(({flip:e=!1})=>M(R("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"})]}),At)),f1=Qe.memo(({flip:e=!1})=>M(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"})}),At)),E1=Qe.memo(({flip:e=!1})=>M(R("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"})]}),At)),b1=Qe.memo(({flip:e=!1})=>M(R("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"})]}),At)),x1=Qe.memo(({flip:e=!1})=>M(R("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"})]}),At)),y1=Qe.memo(({flip:e=!1})=>M(R("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"})]}),At)),w1=Qe.memo(({flip:e=!1})=>M(R("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"})]}),At)),v1=Qe.memo(({flip:e=!1})=>M(R("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"})]}),At)),I1=Qe.memo(({flip:e=!1})=>M(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"})}),At)),T1=Qe.memo(({flip:e=!1})=>M(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M15,5 V17"})}),At)),S1=Qe.memo(({flip:e=!1})=>M(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M15,11 L7,5 M15,11 L7,17"})}),At)),C1=Qe.memo(({flip:e=!1})=>M(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M23,5 V17 M15,11 L7,5 M15,11 L7,17"})}),At)),P1=Qe.memo(({flip:e=!1})=>M(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M15,5 V17 M7,5 V17"})}),At)),k1=Qe.memo(({flip:e=!1})=>M(R("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"})]}),At)),M1=Qe.memo(({flip:e=!1})=>M(R("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"})]}),At)),A1=M(R(Ie,{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"})})})]}),se),D1=M(R(Ie,{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"})})})]}),se),L1=M(R(Ie,{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"})})})]}),se),_1=M(h(Ie,{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"})}),se),Nr=M(R("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),R1=M(h(Ie,{children:R("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),Ts=M(h(Ie,{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"})})}),se),A3=M(R("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),Oc=A3,N1=M(R("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),B1=M(R("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),F1=M(R("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),O1=Qe.memo(({theme:e})=>M(R("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)),z1=Qe.memo(({theme:e})=>M(R("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)),G1=Qe.memo(({theme:e})=>M(R("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)),zc=M(R("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),r$=M(h("path",{d:"M537.6 226.6c4.1-10.7 6.4-22.4 6.4-34.6 0-53-43-96-96-96-19.7 0-38.1 6-53.3 16.2C367 64.2 315.3 32 256 32c-88.4 0-160 71.6-160 160 0 2.7.1 5.4.2 8.1C40.2 219.8 0 273.2 0 336c0 79.5 64.5 144 144 144h368c70.7 0 128-57.3 128-128 0-61.9-44-113.6-102.4-125.4zM393.4 288H328v112c0 8.8-7.2 16-16 16h-48c-8.8 0-16-7.2-16-16V288h-65.4c-14.3 0-21.4-17.2-11.3-27.3l105.4-105.4c6.2-6.2 16.4-6.2 22.6 0l105.4 105.4c10.1 10.1 2.9 27.3-11.3 27.3z",fill:"currentColor"}),{width:640,height:512}),i$=M(h("path",{d:"M480 416C497.7 416 512 430.3 512 448C512 465.7 497.7 480 480 480H150.6C133.7 480 117.4 473.3 105.4 461.3L25.37 381.3C.3786 356.3 .3786 315.7 25.37 290.7L258.7 57.37C283.7 32.38 324.3 32.38 349.3 57.37L486.6 194.7C511.6 219.7 511.6 260.3 486.6 285.3L355.9 416H480zM265.4 416L332.7 348.7L195.3 211.3L70.63 336L150.6 416L265.4 416z"})),H1=M(R("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),Wu=M(R(Ie,{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),U1=M(R(Ie,{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),W1=M(R("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),V1=M(R(Ie,{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),a$=M(R(Ie,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),H),s$=M(R(Ie,{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),Y1=M(R(Ie,{children:[h("path",{d:"M7 5v14"}),h("path",{d:"M19 6l-9 6l9 6z"})]}),H),X1=M(R(Ie,{children:[h("path",{d:"M17 5v14"}),h("path",{d:"M5 6l9 6l-9 6z"})]}),H),K1=M(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 6h16a1 1 0 0 1 1 1v10a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1 -1v-10a1 1 0 0 1 1 -1z"}),h("path",{d:"M7 6v12"}),h("path",{d:"M17 6v12"}),h("path",{d:"M3 10h4"}),h("path",{d:"M3 14h4"}),h("path",{d:"M17 10h4"}),h("path",{d:"M17 14h4"})]}),H),$1=M(R(Ie,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),H),Z1=M(R(Ie,{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),Vu=["M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z","M11 7l6 6"],_i=M(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Vu.map(e=>h("path",{d:e},e))]}),H),jn=M(R("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),l$=M(R("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),c$=M(R("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),d$=M(R("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"})]}),se),Br=M(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 9.5a6.5 6.5 0 1 0 13 0a6.5 6.5 0 1 0 -13 0"}),h("path",{d:"M10 12a2 2 0 0 1 2 -2h7a2 2 0 0 1 2 2v7a2 2 0 0 1 -2 2h-7a2 2 0 0 1 -2 -2l0 -7"})]}),H),qn=M(R("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),m$=M(R("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),p$=M(R("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),u$=M(R("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),h$=M(R("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),Fr=M(R("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),j1=M(R("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),g$=M(R("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),f$=M(R("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),Jn=M(R("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),E$=M(R("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),b$=M(R("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),q1=M(R("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),J1=M(R("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),x$=M(R("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),Q1=M(R("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),e0=M(R("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),t0=M(R("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),n0=M(R("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),Yu=M(R("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),Gc=M(R("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),o0=M(R("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),r0=M(R("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),Yo=M(R("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),y$=M(R("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),i0=M(R("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}),w$=M(R("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),v$=M(R("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),a0=M(R("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),s0=M(R("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),Xo=M(R("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),Ko=M(R("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),$o=M(R("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),H),Hc=M(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),H),l0=M(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),H),c0=M(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),H),Xu=M(R("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),d0=M(R("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),Ku=M(R("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),$u=M(R("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),I$=M(R("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),Zu=M(h("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:.5,viewBox:"0 0 640 512",children:h("path",{d:"M15 15C24.4 5.7 39.6 5.7 49 15l63 63L112 40c0-13.3 10.7-24 24-24s24 10.7 24 24l0 96c0 13.3-10.7 24-24 24l-96 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l38.1 0L15 49C5.7 39.6 5.7 24.4 15 15zM133.5 243.9C158.6 193.6 222.7 112 320 112s161.4 81.6 186.5 131.9c3.8 7.6 3.8 16.5 0 24.2C481.4 318.4 417.3 400 320 400s-161.4-81.6-186.5-131.9c-3.8-7.6-3.8-16.5 0-24.2zM320 320a64 64 0 1 0 0-128 64 64 0 1 0 0 128zM591 15c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-63 63 38.1 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-96 0c-13.3 0-24-10.7-24-24l0-96c0-13.3 10.7-24 24-24s24 10.7 24 24l0 38.1 63-63zM15 497c-9.4-9.4-9.4-24.6 0-33.9l63-63L40 400c-13.3 0-24-10.7-24-24s10.7-24 24-24l96 0c13.3 0 24 10.7 24 24l0 96c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-38.1L49 497c-9.4 9.4-24.6 9.4-33.9 0zm576 0l-63-63 0 38.1c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-96c0-13.3 10.7-24 24-24l96 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-38.1 0 63 63c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0z"})})),m0=M(R("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),p0=M(R("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),ju=M(R("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),T$=M(R("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),S$=M(R("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),C$=M(R("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),P$=M(R("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),Uc=h("div",{style:{width:"1rem",height:"1rem"}}),u0=M(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("polyline",{points:"6 9 12 15 18 9"})]}),H),h0=M(R("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=M(R("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 f0 from"clsx";import Ju,{useEffect as _3,useRef as E0,useState as R3}from"react";import{isPromiseLike as N3}from"@excalidraw/common";import D3 from"react";import{jsx as qu}from"react/jsx-runtime";var L3=({size:e="1em",circleWidth:n=8,synchronized:t=!1,className:o=""})=>{let i=-(D3.useRef(Date.now()).current%1600);return qu("div",{className:`Spinner ${o}`,children:qu("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:qu("circle",{cx:"50",cy:"50",r:50-n/2,strokeWidth:n,fill:"none",strokeMiterlimit:"10"})})})},Eo=L3;import{jsx as Ss,jsxs as Wc}from"react/jsx-runtime";var $=Ju.forwardRef(({size:e="medium",visible:n=!0,className:t="",...o},r)=>{let i=Ju.useRef(null);Ju.useImperativeHandle(r,()=>i.current);let a=`ToolIcon_size_${e}`,[s,l]=R3(!1),c=E0(!0),d=async p=>{let u="onClick"in o&&o.onClick?.(p);if(N3(u))try{l(!0),await u}catch(E){if(E instanceof wc)console.warn(E);else throw E}finally{c.current&&l(!1)}};_3(()=>(c.current=!0,()=>{c.current=!1}),[]);let m=E0(null);return o.type==="button"||o.type==="icon"?Wc("button",{className:f0("ToolIcon_type_button",a,t,n&&!o.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!o.hidden,"ToolIcon--plain":o.type==="icon"}),style:o.style,"data-testid":o["data-testid"],hidden:o.hidden,title:o.title,"aria-label":o["aria-label"],type:"button",onClick:d,ref:i,disabled:s||o.isLoading||!!o.disabled,children:[(o.icon||o.label)&&Wc("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!o.disabled,children:[o.icon||o.label,o.keyBindingLabel&&Ss("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel}),o.isLoading&&Ss(Eo,{})]}),o.showAriaLabel&&Wc("div",{className:"ToolIcon__label",children:[o["aria-label"]," ",s&&Ss(Eo,{})]}),o.children]}):Ss("button",{className:f0("ToolIcon","ToolIcon_type_toggle",a,t,{"ToolIcon--checked":o.checked}),type:"button",style:o.style,title:o.title,"aria-label":o["aria-label"],"aria-keyshortcuts":o["aria-keyshortcuts"],"aria-pressed":o.checked,"data-testid":o["data-testid"],disabled:!!o.disabled,"aria-disabled":!!o.disabled,onPointerDown:p=>{m.current=p.pointerType||null},onPointerUp:()=>{requestAnimationFrame(()=>{m.current=null})},onClick:()=>{o.onSelect?.({pointerType:m.current})},ref:i,children:Wc("div",{className:"ToolIcon__icon",children:[o.icon,o.keyBindingLabel&&Ss("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel})]})})});$.displayName="IconButton";var Vc=[],O=e=>(Vc=Vc.concat(e),e);import{jsx as V3}from"react/jsx-runtime";var W3=(e,n,t)=>{let o=new Set(ce(e.filter(d=>G3(d)),n).map(d=>d.id)),r={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let d of o){let m=H3(e,d);for(let p of m)if(!a.has(p.id)){if(Yc(p)){let u=x0(p,i);u&&(r[u.id]=!0)}else r[p.id]=!0;a.add(p.id)}}let s=!0,l=e.map(d=>{if(n.selectedElementIds[d.id]){let m=Yc(d)?x0(d,i):null;return d.frameId&&o.has(d.frameId)?(s=!1,r[d.id]=!0,d):m?.frameId&&o.has(m?.frameId)?d:(d.boundElements&&d.boundElements.forEach(p=>{let u=t.scene.getNonDeletedElementsMap().get(p.id);u&&z3(u)&&t.scene.mutateElement(u,{startBinding:d.id===u.startBinding?.elementId?null:u.startBinding,endBinding:d.id===u.endBinding?.elementId?null:u.endBinding})}),Kc(d,{isDeleted:!0}))}return d.frameId&&o.has(d.frameId)?(s=!1,Yc(d)||(r[d.id]=!0),Kc(d,{frameId:null})):Yc(d)&&n.selectedElementIds[d.containerId]?Kc(d,{isDeleted:!0}):d}),c=n.editingGroupId;if(s&&n.editingGroupId){let d=eh(l,n.editingGroupId).filter(m=>!m.isDeleted);if(d.length>1)d[0]&&(r[d[0].id]=!0);else{c=null,d[0]&&(r[d[0].id]=!0);let m=d[0];if(m){let p=m.groupIds.findIndex(E=>E===n.editingGroupId),u=m.groupIds[p+1];if(u){let E=eh(l,u).filter(g=>!g.isDeleted);E.length>1&&(c=u,E.forEach(g=>{r[g.id]=!0}))}}}}return{elements:l,appState:{...n,...U3({selectedElementIds:r,editingGroupId:c},$c(l),n,null)}}},y0=(e,n)=>{if(e.editingGroupId){let t=eh($c(n),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},Cs=O({name:"deleteSelectedElements",label:"labels.delete",icon:Rr,trackEvent:{category:"element",action:"delete"},perform:(e,n,t,o)=>{if(n.selectedLinearElement?.isEditing){let{elementId:a,selectedPointsIndices:s}=n.selectedLinearElement,l=o.scene.getNonDeletedElementsMap(),c=b0.getElement(a,l);if(!c||s==null)return!1;if(s.length>=c.points.length){let d=e.map(p=>p.id===c.id?Kc(p,{isDeleted:!0}):p),m=y0(n,d);return{elements:d,appState:{...m,selectedLinearElement:null},captureUpdate:Xc.IMMEDIATELY}}return b0.deletePoints(c,o,s),{elements:e,appState:{...n,selectedLinearElement:{...n.selectedLinearElement,selectedPointsIndices:s?.[0]>0?[s[0]-1]:[0]}},captureUpdate:Xc.IMMEDIATELY}}let{elements:r,appState:i}=W3(e,n,o);return O3(r,r.filter(a=>a.isDeleted)),i=y0(i,r),{elements:r,appState:{...i,activeTool:F3(n,{type:o.state.preferredSelectionTool.type}),multiElement:null,newElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:De($c(e),n)?Xc.IMMEDIATELY:Xc.EVENTUALLY}},keyTest:(e,n,t)=>(e.key===Qu.BACKSPACE||e.key===Qu.DELETE)&&!e[Qu.CTRL_OR_CMD],PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=ct()==="mobile";return V3($,{type:"button",icon:Rr,title:f("labels.delete"),"aria-label":f("labels.delete"),onClick:()=>t(null),disabled:!De($c(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?B3:{}}})}});import{KEYS as Ri,CODES as Ni,isDarwin as Zc}from"@excalidraw/common";import{moveOneLeft as Y3,moveOneRight as X3,moveAllLeft as K3,moveAllRight as $3}from"@excalidraw/element";import{CaptureUpdateAction as jc}from"@excalidraw/element";import{isDarwin as w0}from"@excalidraw/common";var N=e=>e.replace(/\b(Opt(?:ion)?|Alt)\b/i,w0?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,w0?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 qc}from"react/jsx-runtime";var th=O({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:Mu,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Y3(e,n,o.scene),appState:n,captureUpdate:jc.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Ri.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Ni.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>qc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendBackward")} \u2014 ${N("CtrlOrCmd+[")}`,children:Mu})}),nh=O({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:ku,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:X3(e,n,o.scene),appState:n,captureUpdate:jc.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Ri.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Ni.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>qc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.bringForward")} \u2014 ${N("CtrlOrCmd+]")}`,children:ku})}),oh=O({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:Du,trackEvent:{category:"element"},perform:(e,n)=>({elements:K3(e,n),appState:n,captureUpdate:jc.IMMEDIATELY}),keyTest:e=>Zc?e[Ri.CTRL_OR_CMD]&&e.altKey&&e.code===Ni.BRACKET_LEFT:e[Ri.CTRL_OR_CMD]&&e.shiftKey&&e.code===Ni.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>qc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendToBack")} \u2014 ${Zc?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")}`,children:Du})}),rh=O({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:Au,trackEvent:{category:"element"},perform:(e,n)=>({elements:$3(e,n),appState:n,captureUpdate:jc.IMMEDIATELY}),keyTest:e=>Zc?e[Ri.CTRL_OR_CMD]&&e.altKey&&e.code===Ni.BRACKET_RIGHT:e[Ri.CTRL_OR_CMD]&&e.shiftKey&&e.code===Ni.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>qc("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${f("labels.bringToFront")} \u2014 ${Zc?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")}`,children:Au})});import{getNonDeletedElements as Z3}from"@excalidraw/element";import{LinearElementEditor as j3}from"@excalidraw/element/linearElementEditor";import{isLinearElement as q3,isTextElement as J3}from"@excalidraw/element";import{arrayToMap as Q3,KEYS as v0}from"@excalidraw/common";import{selectGroupsForSelectedElements as eA}from"@excalidraw/element";import{CaptureUpdateAction as tA}from"@excalidraw/element";var ih=O({name:"selectAll",label:"labels.selectAll",icon:Q1,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,n,t,o)=>{if(n.selectedLinearElement?.isEditing)return!1;let r=e.filter(i=>!i.isDeleted&&!(J3(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...n,...eA({editingGroupId:null,selectedElementIds:r},Z3(e),n,o),selectedLinearElement:Object.keys(r).length===1&&q3(e[0])?new j3(e[0],Q3(e)):null},captureUpdate:tA.IMMEDIATELY}},keyTest:e=>e[v0.CTRL_OR_CMD]&&e.key===v0.A});import{DEFAULT_GRID_SIZE as I0,KEYS as T0,MOBILE_ACTION_BUTTON_BG as nA,arrayToMap as S0}from"@excalidraw/common";import{getNonDeletedElements as C0}from"@excalidraw/element";import{LinearElementEditor as oA}from"@excalidraw/element/linearElementEditor";import{getSelectedElements as rA,getSelectionStateForElements as iA}from"@excalidraw/element";import{syncMovedIndices as aA}from"@excalidraw/element";import{duplicateElements as sA}from"@excalidraw/element";import{CaptureUpdateAction as P0}from"@excalidraw/element";import{jsx as lA}from"react/jsx-runtime";var ah=O({name:"duplicateSelection",label:"labels.duplicateSelection",icon:xs,trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(n.selectedElementsAreBeingDragged)return!1;if(n.selectedLinearElement?.isEditing)try{let a=oA.duplicateSelectedPoints(n,o.scene);return{elements:e,appState:a,captureUpdate:P0.IMMEDIATELY}}catch{return!1}let{duplicatedElements:r,elementsWithDuplicates:i}=sA({type:"in-place",elements:e,idsOfElementsToDuplicate:S0(rA(e,n,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:n,randomizeSeed:!0,overrides:({origElement:a,origIdToDuplicateId:s})=>{let l=a.frameId&&s.get(a.frameId);return{x:a.x+I0/2,y:a.y+I0/2,frameId:l??a.frameId}}});if(o.props.onDuplicate&&i){let a=o.props.onDuplicate(i,e);a&&(i=a)}return{elements:aA(i,S0(r)),appState:{...n,...iA(r,C0(i),n)},captureUpdate:P0.IMMEDIATELY}},keyTest:e=>e[T0.CTRL_OR_CMD]&&e.key===T0.D,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=ct()==="mobile";return lA($,{type:"button",icon:xs,title:`${f("labels.duplicateSelection")} \u2014 ${N("CtrlOrCmd+D")}`,"aria-label":f("labels.duplicateSelection"),onClick:()=>t(null),disabled:!De(C0(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?nA:{}}})}});import{pointFrom as H4}from"@excalidraw/math";import{useEffect as Ph,useMemo as Ah,useRef as kh,useState as U4}from"react";import{BUCKET_FILL_BACKGROUND_PICKS as W4,COLOR_PALETTE as V4,DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as Ry,DEFAULT_ELEMENT_BACKGROUND_PICKS as Y4,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as X4,DEFAULT_ELEMENT_STROKE_PICKS as K4,ARROW_TYPE as cn,DEFAULT_FONT_FAMILY as $4,DEFAULT_FONT_SIZE as Z4,FONT_FAMILY as j4,ROUNDNESS as bd,STROKE_WIDTH_KEYS as q4,VERTICAL_ALIGN as fd,KEYS as Yi,randomInteger as J4,arrayToMap as Dh,getFontFamilyString as Q4,getLineHeight as e6,isTransparent as t6,getStrokeWidthByKey as Ny,reduceToCommonValue as n6,invariant as yd,FONT_SIZES as Ed}from"@excalidraw/common";import{canBecomePolygon as o6,getNonDeletedElements as By,isNonDeletedElement as r6}from"@excalidraw/element";import{bindBindingElement as My,calculateFixedPointForElbowArrowBinding as Ay,updateBoundElements as i6}from"@excalidraw/element";import{LinearElementEditor as zr}from"@excalidraw/element/linearElementEditor";import{newElementWith as it}from"@excalidraw/element";import{getArrowheadForPicker as Dy}from"@excalidraw/element";import{getBoundTextElement as nr,redrawTextBoundingBox as zs}from"@excalidraw/element";import{isArrowElement as xd,isBoundToContainer as a6,isElbowArrow as Fy,isLinearElement as Mh,isLineElement as Ly,isTextElement as Gt,isUsingAdaptiveRadius as s6}from"@excalidraw/element";import{hasStrokeColor as l6}from"@excalidraw/element";import{updateElbowArrowPoints as c6,CaptureUpdateAction as et,toggleLinePolygonState as d6}from"@excalidraw/element";import{deriveStylesPanelMode as m6}from"@excalidraw/common";import{isDevEnv as cA}from"@excalidraw/common";var dA=new Set(["command_palette","export"]),Be=(e,n,t,o)=>{try{if(typeof window>"u"||S.VITE_WORKER_ID||S.VITE_APP_ENABLE_TRACKING!=="true"||!dA.has(e)||cA())return;S.PROD||console.info("trackEvent",{category:e,action:n,label:t,value:o}),window.sa_event&&window.sa_event(n,{category:e,label:t,value:o})}catch(r){console.error("error during analytics",r)}};import hA from"clsx";import mA from"clsx";import{forwardRef as pA}from"react";import{jsx as uA}from"react/jsx-runtime";var k0=pA((e,n)=>{let{title:t,className:o,testId:r,active:i,icon:a,onClick:s}=e;return uA("button",{type:"button",ref:n,title:t,"data-testid":r,className:mA(o,{active:i}),onClick:s,style:e.style,children:a},t)});import{Fragment as fA,jsx as sh,jsxs as gA}from"react/jsx-runtime";var Zt=e=>sh(fA,{children:e.options.map(n=>e.type==="button"?sh(k0,{icon:n.icon,title:n.text,testId:n.testId,active:n.active??e.value===n.value,onClick:t=>e.onClick(n.value,t)},n.text):gA("label",{className:hA({active:e.value===n.value}),title:n.text,children:[sh("input",{type:"radio",name:e.group,onChange:()=>e.onChange(n.value),checked:e.value===n.value,"data-testid":n.testId}),n.icon]},n.text))});import{Popover as sy}from"radix-ui";import ly from"clsx";import{memo as F5,useRef as cy,useEffect as O5}from"react";import{applyDarkModeFilter as z5,COLOR_OUTLINE_CONTRAST_THRESHOLD as iy,COLOR_PALETTE as dy,DEFAULT_ELEMENT_BACKGROUND_PICKS as G5,DEFAULT_ELEMENT_STROKE_PICKS as H5,isColorDark as ay,isWritableElement as U5,THEME as W5}from"@excalidraw/common";import{jsx as EA}from"react/jsx-runtime";var Jc=()=>EA("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as IA,useLayoutEffect as TA,useRef as SA}from"react";import{createPortal as CA}from"react-dom";import{EVENT as Zo,isColorDark as PA,KEYS as kA,MIME_TYPES as MA,THEME as AA,removeDarkModeFilter as DA,rgbToHex as LA}from"@excalidraw/common";import M0 from"react";var lh=M0.createContext(null),be=()=>M0.useContext(lh);import{useState as bA,useLayoutEffect as A0}from"react";import{THEME as xA}from"@excalidraw/common";var Qc=e=>{let[n,t]=bA(null),o=Ee(),{theme:r}=be(),{container:i}=Re();return A0(()=>{n&&(n.className="",n.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),n.classList.toggle("excalidraw--mobile",o.formFactor==="phone"),n.classList.toggle("theme--dark",r===xA.DARK))},[n,r,o.formFactor,e?.className]),A0(()=>{let a=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!a)return;let s=document.createElement("div");return a.appendChild(s),t(s),()=>{a.removeChild(s)}},[i,e?.parentSelector]),n};import{useEffect as yA}from"react";import{EVENT as ed}from"@excalidraw/common";function Bi(e,n,t){yA(()=>{function o(r){let i=r;if(!e.current)return;let a=t?.(i,e.current);if(a===!0)return;if(a===!1)return n(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]")||n(i)}return document.addEventListener(ed.POINTER_DOWN,o),document.addEventListener(ed.TOUCH_START,o),()=>{document.removeEventListener(ed.POINTER_DOWN,o),document.removeEventListener(ed.TOUCH_START,o)}},[e,n,t])}import{useRef as wA}from"react";var Fi=e=>{let n=wA(e);return Object.assign(n.current,e),n.current};import{clamp as vA}from"@excalidraw/math";var D0=({cursorPosition:e,elementSize:n,containerSize:t,gap:o})=>{let r=e+o+n>t?e-o-n:e+o;return vA(r,0,Math.max(0,t-n))},td=({cursor:e,element:n,container:t,gap:o})=>({left:D0({cursorPosition:e.x-t.left,elementSize:n.width,containerSize:t.width,gap:o}),top:D0({cursorPosition:e.y-t.top,elementSize:n.height,containerSize:t.height,gap:o})});import{jsx as RA}from"react/jsx-runtime";var L0=Vu.map((e,n)=>`<path fill="${n===0?"#fff":""}" d="${e}" />`).join(""),_A=`url(data:${MA.svg},${encodeURIComponent(`<svg viewBox="0 0 24 24" width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke-linecap="round" stroke-linejoin="round"><g stroke="#fff" stroke-width="5">${L0}</g><g stroke="#1b1b1f" stroke-width="1.25">${L0}</g></svg>`)}) 2 21, auto`,zt=Je(null),_0=({onCancel:e,onChange:n,onSelect:t,colorPickerType:o})=>{let r=Qc({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=be(),a=Oi(),s=St(),l=ce(a,i),c=Fi({app:s,onCancel:e,onChange:n,onSelect:t,selectedElements:l}),{container:d}=Re();TA(()=>{if(r)return r.style.cursor=_A,()=>{r.style.cursor=""}},[r]),IA(()=>{let p=m.current;if(!p||!s.canvas||!r)return;let u=!1,E=s.canvas.getContext("2d"),g=({clientX:P,clientY:A})=>{let D=E.getImageData((P-i.offsetLeft)*window.devicePixelRatio,(A-i.offsetTop)*window.devicePixelRatio,1,1).data;return LA(D[0],D[1],D[2])},b=P=>i.theme===AA.DARK?DA(P):P,y=({clientX:P,clientY:A,altKey:D})=>{let{top:_,left:k}=td({cursor:{x:P,y:A},element:{width:p.offsetWidth,height:p.offsetHeight},container:r.getBoundingClientRect(),gap:7});p.style.top=`${_}px`,p.style.left=`${k}px`;let L=g({clientX:P,clientY:A});u&&c.onChange(o,b(L),c.selectedElements,{altKey:D}),p.style.background=L,p.style.setProperty("--eye-dropper-preview-border-color",PA(L)?"#fff":"#222")},w=()=>{c.onCancel()},x=(P,A)=>{c.onSelect(P,A)},I=P=>{u=!0,P.stopImmediatePropagation()},T=P=>{u=!1,d?.focus(),P.stopImmediatePropagation(),P.preventDefault(),x(b(g(P)),P)},C=P=>{P.key===kA.ESCAPE&&(P.preventDefault(),P.stopImmediatePropagation(),w())};return r.tabIndex=-1,r.focus(),y({clientX:c.app.viewport.lastPosition.x,clientY:c.app.viewport.lastPosition.y,altKey:!1}),r.addEventListener(Zo.KEYDOWN,C),r.addEventListener(Zo.POINTER_DOWN,I),r.addEventListener(Zo.POINTER_UP,T),window.addEventListener("pointermove",y,{passive:!0}),window.addEventListener(Zo.BLUR,w),()=>{u=!1,r.removeEventListener(Zo.KEYDOWN,C),r.removeEventListener(Zo.POINTER_DOWN,I),r.removeEventListener(Zo.POINTER_UP,T),window.removeEventListener("pointermove",y),window.removeEventListener(Zo.BLUR,w)}},[c,s.canvas,r,o,d,i.offsetLeft,i.offsetTop,i.theme]);let m=SA(null);return Bi(m,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),r?CA(RA("div",{ref:m,className:"excalidraw-eye-dropper-preview"}),r):null};import{Popover as ch}from"radix-ui";import OA from"clsx";import zA from"react";import{isInteractive as GA}from"@excalidraw/common";import NA from"react";import BA from"clsx";import{jsx as FA}from"react/jsx-runtime";var Ue=NA.forwardRef(({children:e,padding:n,className:t,style:o,"data-viewport-ui":r,"data-viewport-ui-name":i},a)=>FA("div",{className:BA("Island",t),style:{"--padding":n,...o},"data-viewport-ui":r,"data-viewport-ui-name":i,ref:a,children:e}));import{jsx as dh,jsxs as HA}from"react/jsx-runtime";var bo=zA.forwardRef(({className:e,container:n,children:t,style:o,onClose:r,onKeyDown:i,onFocusOutside:a,onPointerLeave:s,onPointerDownOutside:l,preventAutoFocusOnTouch:c=!1},d)=>{let m=Ee(),p=m.formFactor==="phone"&&!m.isLandscape;return dh(ch.Portal,{container:n,children:HA(ch.Content,{ref:d,className:OA("focus-visible-none",e),"data-prevent-outside-click":!0,side:p?"bottom":"right",align:p?"center":"start",alignOffset:-16,sideOffset:20,collisionBoundary:n??void 0,style:{zIndex:"var(--zIndex-ui-styles-popup)",marginLeft:m.formFactor==="phone"?"0.5rem":void 0},onPointerLeave:s,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:l,onOpenAutoFocus:u=>{c&&m.isTouchScreen&&u.preventDefault()},onCloseAutoFocus:u=>{u.stopPropagation(),u.preventDefault(),n&&!GA(document.activeElement)&&n.focus(),r()},children:[dh(Ue,{padding:3,style:o,children:t}),dh(ch.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 UA,useCallback as mh}from"react";var nd=()=>document.querySelector(".excalidraw-wysiwyg"),od=()=>{let e=nd();return e?{start:e.selectionStart,end:e.selectionEnd}:null},Ps=e=>{setTimeout(()=>{let n=nd();n&&(n.focus(),e&&(n.selectionStart=e.start,n.selectionEnd=e.end))},0)},ks=(e,n,t,o)=>{n&&o&&o();let r=n&&t?od():null;e(),n&&t&&Ps(r)},R0=()=>{let[e,n]=UA(null),t=mh(()=>{let i=od();n(i)},[]),o=mh(()=>{setTimeout(()=>{let i=nd();i&&(i.focus(),e&&(i.selectionStart=e.start,i.selectionEnd=e.end,n(null)))},0)},[e]),r=mh(()=>{n(null)},[]);return{saveCaretPosition:t,restoreCaretPosition:o,clearSavedPosition:r,hasSavedPosition:!!e}},N0=(e=100)=>{let n=nd();if(n){let t=n.onblur;n.onblur=null,setTimeout(()=>{n.onblur=t},e)}};import F0 from"clsx";import{useCallback as YA,useEffect as uh,useRef as O0,useState as z0}from"react";import{KEYS as hh,normalizeInputColor as XA}from"@excalidraw/common";import{isTransparent as WA,MAX_CUSTOM_COLORS_USED_IN_CANVAS as VA}from"@excalidraw/common";var jo=({palette:e,color:n})=>{if(!n)return null;for(let[t,o]of Object.entries(e))if(Array.isArray(o)){let r=o.indexOf(n);if(r>-1)return{colorName:t,shade:r}}else if(o===n)return{colorName:t,shade:null};return null},Ms=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),ph=({color:e,palette:n})=>!Object.values(n).flat().includes(e),B0=(e,n,t)=>{let o={elementBackground:"backgroundColor",elementStroke:"strokeColor"},r=e.filter(a=>{if(a.isDeleted)return!1;let s=a[o[n]];return!WA(s)&&ph({color:s,palette:t})}),i=new Map;return r.forEach(a=>{let s=a[o[n]];i.has(s)?i.set(s,i.get(s)+1):i.set(s,1)}),[...i.entries()].sort((a,s)=>s[1]-a[1]).map(a=>a[0]).slice(0,VA)},an=Je(null);import{Fragment as KA,jsx as As,jsxs as gh}from"react/jsx-runtime";var G0=({color:e,onChange:n,label:t,colorPickerType:o,placeholder:r})=>{let i=Ee(),[a,s]=z0(e),[l,c]=z0(null),[d,m]=He(an);uh(()=>{s(e)},[e]);let p=YA(y=>{let w=y.toLowerCase().trim(),x=XA(w);x?(n(x),c(null)):w.length===0?c(null):/^#?[0-9a-f]+$/.test(w)?c(f("colorPicker.invalidHexLength")):c(f("colorPicker.invalidColor")),s(w)},[n]),u=O0(null),E=O0(null);uh(()=>{u.current&&u.current.focus()},[d]);let[g,b]=He(zt);return uh(()=>()=>{b(null)},[b]),gh("div",{className:"color-picker__input-label-container",children:[gh("div",{className:F0("color-picker__input-label",{"has-error":l}),children:[As("div",{className:"color-picker__input-hash",children:"#"}),As("input",{ref:d==="hex"?u:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,"aria-invalid":!!l,onChange:y=>{p(y.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{s(e),c(null)},tabIndex:-1,onFocus:()=>m("hex"),onKeyDown:y=>{y.key!==hh.TAB&&(y.key===hh.ESCAPE&&E.current?.focus(),y.stopPropagation())},placeholder:r}),i.formFactor!=="phone"&&gh(KA,{children:[As("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),As("div",{ref:E,className:F0("excalidraw-eye-dropper-trigger",{selected:g}),onClick:()=>b(y=>y?null:{keepOpenOnAlt:!1,onSelect:w=>n(w),colorPickerType:o}),title:`${f("labels.eyeDropper")} \u2014 ${hh.I.toLocaleUpperCase()} or ${N("Alt")} `,children:_i})]})]}),l&&As("div",{className:"color-picker__error-message",role:"alert",children:l})]})};import bh,{useEffect as xh,useImperativeHandle as S5,useState as C5}from"react";import{EVENT as ey}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as P5,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as k5,KEYS as M5}from"@excalidraw/common";import n5 from"clsx";import{useEffect as o5,useRef as r5}from"react";import{applyDarkModeFilter as i5,THEME as a5}from"@excalidraw/common";import{isColorDark as $A}from"@excalidraw/common";import{jsxs as jA}from"react/jsx-runtime";var ZA=({color:e,keyLabel:n,isShade:t=!1})=>jA("div",{className:"color-picker__button__hotkey-label",style:{color:$A(e)?"#fff":"#000"},children:[t&&"\u21E7",n]}),zi=ZA;import{createContext as qA,useContext as JA,useEffect as QA,useMemo as H0,useRef as U0,useState as e5}from"react";import{colorToHex as W0,isTransparent as t5}from"@excalidraw/common";var Or="excalidraw-color-dnd-ghost",V0="excalidraw-color-dnd-active",Y0=10,X0=100,K0=(e,n)=>{if(e.toLowerCase()===n.toLowerCase())return!0;let t=W0(e);return t!==null&&t===W0(n)},fh=qA(null),sn=()=>JA(fh),$0=({enabled:e,picks:n,onPicksChange:t})=>{let[o,r]=e5(null),i=U0(null),a=U0({enabled:e,picks:n,onPicksChange:t});a.current={enabled:e,picks:n,onPicksChange:t};let s=H0(()=>{let l=null,c=()=>{l?.activated?r({color:l.color,origin:l.origin,overIndex:l.overIndex,duplicateIndex:l.duplicateIndex,slotSpan:l.slotSpan}):r(null)},d=()=>{let k=i.current;if(!k||!l)return!1;let L=Array.from(k.querySelectorAll("[data-top-pick-index]")).sort((K,G)=>Number(K.dataset.topPickIndex)-Number(G.dataset.topPickIndex));if(!L.length)return!1;l.slotRects=L.map(K=>K.getBoundingClientRect());let[B,V]=l.slotRects;l.slotSpan=V?V.left-B.left:B.width+4;let z=k.getBoundingClientRect(),U=Math.max(Math.abs(l.slotSpan)/2,10);return l.hitRect={left:z.left-U,right:z.right+U,top:z.top-14,bottom:z.bottom+14},!0},m=(k,L)=>{l?.ghost&&(l.ghost.style.transform=`translate(${k-l.ghostW/2}px, ${L-l.ghostH/2}px)`)},p=(k,L,B,V)=>{l?.ghost&&(l.ghostW!==k||l.ghostH!==L)&&(l.ghostW=k,l.ghostH=L,l.ghost.style.width=`${k}px`,l.ghost.style.height=`${L}px`,m(B,V))},u=(k,L)=>{if(!l)return;let{sourceRect:B,sourceEl:V,color:z}=l,U=document.createElement("div");U.className=Or;let K=document.createElement("div");if(K.className=`${Or}__swatch`,t5(z))K.classList.add("is-transparent");else{let G=getComputedStyle(V).backgroundColor;K.style.backgroundColor=G&&G!=="rgba(0, 0, 0, 0)"?G:z}U.appendChild(K),document.body.appendChild(U),l.ghost=U,l.ghostW=B.width,l.ghostH=B.height,U.style.width=`${B.width}px`,U.style.height=`${B.height}px`,m(k,L),requestAnimationFrame(()=>{l?.ghost===U&&U.classList.add(`${Or}--lifted`)}),document.body.classList.add(V0),l.activated=!0,c()},E=(k,L)=>{if(!l?.hitRect)return;let{hitRect:B,slotRects:V}=l,z=null,U=null;if(k>=B.left&&k<=B.right&&L>=B.top&&L<=B.bottom){let K=0,G=1/0;if(V.forEach((te,F)=>{let W=Math.abs(k-(te.left+te.width/2));W<G&&(G=W,K=F)}),l.origin.kind==="swatch"){let te=a.current.picks.findIndex(F=>K0(F,l.color));te!==-1?U=te:z=K}else z=K}if(z!==l.overIndex||U!==l.duplicateIndex){l.overIndex=z,l.duplicateIndex=U;let{ghost:K}=l;K&&(K.classList.toggle(`${Or}--over`,z!==null),K.classList.toggle(`${Or}--blocked`,U!==null)),c()}if(z!==null){let K=l.slotRects[z];p(K.width,K.height,k,L)}else p(l.sourceRect.width,l.sourceRect.height,k,L)},g=k=>{if(!l?.ghost)return;let{ghost:L}=l;l.ghost=null,L.classList.add(`${Or}--dropping`);let B=k.rect;B&&(L.style.width=`${B.width}px`,L.style.height=`${B.height}px`,L.style.transform=`translate(${B.left}px, ${B.top}px)`),window.setTimeout(()=>{L.classList.add(`${Or}--fade`)},160),window.setTimeout(()=>{L.remove()},340)},b=()=>{let k=i.current;if(!k||!l?.activated)return;let L=Array.from(k.querySelectorAll("[data-top-pick-index]"));for(let B of L)B.style.transition="none",B.style.transform="none";k.offsetWidth;for(let B of L)B.style.transition=""},y=()=>{let k=L=>{L.preventDefault(),L.stopPropagation()};window.addEventListener("click",k,{capture:!0,once:!0}),window.setTimeout(()=>{window.removeEventListener("click",k,{capture:!0})},100)},w=()=>{window.removeEventListener("pointermove",C,!0),window.removeEventListener("pointerup",P,!0),window.removeEventListener("pointercancel",A,!0),window.removeEventListener("keydown",D,!0)},x=()=>{w(),document.body.classList.remove(V0),l?.activationTimer!=null&&window.clearTimeout(l.activationTimer),l=null,r(null)},I=k=>{l&&(b(),l.ghost&&(k?g({rect:l.sourceRect}):(l.ghost.remove(),l.ghost=null)),x())},T=(k,L)=>{if(!(!l||l.activated)){if(!d()){x();return}u(k,L),E(k,L)}},C=k=>{if(!(!l||k.pointerId!==l.pointerId)){if(l.lastX=k.clientX,l.lastY=k.clientY,!l.activated){if(Math.hypot(k.clientX-l.startX,k.clientY-l.startY)<Y0){l.activationTimer!==null&&(window.clearTimeout(l.activationTimer),l.activationTimer=null);return}let L=performance.now()-l.startTime;if(L<X0){l.activationTimer===null&&(l.activationTimer=window.setTimeout(()=>{l&&(l.activationTimer=null,Math.hypot(l.lastX-l.startX,l.lastY-l.startY)>=Y0&&T(l.lastX,l.lastY))},X0-L));return}if(T(k.clientX,k.clientY),!l?.activated)return}k.preventDefault(),m(k.clientX,k.clientY),E(k.clientX,k.clientY)}},P=k=>{if(!l||k.pointerId!==l.pointerId)return;if(!l.activated){x();return}k.preventDefault(),k.stopPropagation(),y();let{overIndex:L,origin:B,color:V,slotRects:z}=l,{picks:U,onPicksChange:K}=a.current;if(b(),L!==null){if(B.kind==="swatch"){if(!U.some(G=>K0(G,V))){let G=[...U];G[L]=V,K(G)}}else if(B.index!==L){let G=[...U],[te]=G.splice(B.index,1);G.splice(L,0,te),K(G)}g({rect:z[L]})}else g({rect:l.sourceRect});x()},A=k=>{l&&k.pointerId===l.pointerId&&I(!0)},D=k=>{l?.activated&&k.key==="Escape"&&(k.preventDefault(),k.stopPropagation(),I(!0))};return{begin:(k,L,B)=>{!a.current.enabled||l||k.button!==0||!L||(l={pointerId:k.pointerId,startX:k.clientX,startY:k.clientY,startTime:performance.now(),lastX:k.clientX,lastY:k.clientY,activationTimer:null,color:L,origin:B,sourceEl:k.currentTarget,sourceRect:k.currentTarget.getBoundingClientRect(),activated:!1,ghost:null,ghostW:0,ghostH:0,slotRects:[],slotSpan:0,hitRect:null,overIndex:null,duplicateIndex:null},window.addEventListener("pointermove",C,!0),window.addEventListener("pointerup",P,!0),window.addEventListener("pointercancel",A,!0),window.addEventListener("keydown",D,!0))},destroy:()=>I(!1)}},[]);return QA(()=>()=>s.destroy(),[s]),H0(()=>({dragState:o,startSwatchDrag:(l,c)=>s.begin(l,c,{kind:"swatch"}),startPickDrag:(l,c,d)=>s.begin(l,d,{kind:"pick",index:c}),setStripEl:l=>{i.current=l}}),[o,s])};import{jsx as Eh,jsxs as s5}from"react/jsx-runtime";var Z0=({theme:e,colors:n,color:t,onChange:o,label:r})=>{let[i,a]=He(an),s=sn(),l=r5(null);return o5(()=>{l.current&&l.current.focus()},[t,i]),Eh("div",{className:"color-picker-content--default",children:n.map((c,d)=>{let m=i5(c,e===a5.DARK);return s5("button",{ref:t===c?l:void 0,tabIndex:-1,type:"button",className:n5("color-picker__button color-picker__button--large has-outline",{active:t===c,"is-transparent":c==="transparent"||!c}),onClick:()=>{o(c),a("custom")},onPointerDown:s?p=>s.startSwatchDrag(p,c):void 0,title:c,"aria-label":r,style:{"--swatch-color":m},children:[Eh("div",{className:"color-picker__button-outline"}),Eh(zi,{color:m,keyLabel:d+1})]},d)})})};import l5 from"clsx";import{useEffect as c5,useRef as d5}from"react";import{applyDarkModeFilter as m5,isColorDark as p5,THEME as u5}from"@excalidraw/common";import{jsx as rd,jsxs as g5}from"react/jsx-runtime";var h5=({theme:e,palette:n,color:t,onChange:o,activeShade:r,showHotKey:i=!0,excludedColors:a})=>{let s=jo({color:t,palette:n}),[l,c]=He(an),d=sn(),m=d5(null);return c5(()=>{m.current&&l==="baseColors"&&m.current.focus()},[s?.colorName,l]),rd("div",{className:"color-picker-content--default",children:Object.entries(n).map(([p,u],E)=>{let g=(Array.isArray(u)?u[r]:u)||"transparent";if(a?.includes(g))return rd("div",{className:"color-picker__button color-picker__button--large",style:{visibility:"hidden"},"aria-hidden":"true"},p);let b=Ms[E],y=m5(g,e===u5.DARK),w=f(`colors.${p.replace(/\d+/,"")}`,null,"");return g5("button",{ref:s?.colorName===p?m:void 0,tabIndex:-1,type:"button",className:l5("color-picker__button color-picker__button--large",{"has-outline":!p5(g,255),active:s?.colorName===p,"is-transparent":g==="transparent"||!g}),onClick:()=>{o(g),c("baseColors")},onPointerDown:d?x=>d.startSwatchDrag(x,g):void 0,title:`${w}${g.startsWith("#")?` ${g}`:""} \u2014 ${b}`,"aria-label":`${w} \u2014 ${b}`,style:g?{"--swatch-color":y}:void 0,"data-testid":`color-${p}`,children:[rd("div",{className:"color-picker__button-outline"}),i&&rd(zi,{color:y,keyLabel:b})]},p)})})},j0=h5;import{jsx as E5}from"react/jsx-runtime";var f5=({children:e})=>E5("div",{className:"color-picker__heading",children:e}),Gi=f5;import b5 from"clsx";import{useEffect as x5,useRef as y5}from"react";import{applyDarkModeFilter as w5,THEME as v5}from"@excalidraw/common";import{jsx as Ds,jsxs as q0}from"react/jsx-runtime";var J0=({theme:e,color:n,onChange:t,palette:o,showHotKey:r})=>{let i=jo({color:n||"transparent",palette:o}),[a,s]=He(an),l=sn(),c=y5(null);if(x5(()=>{c.current&&a==="shades"&&c.current.focus()},[i,a]),i){let{colorName:d,shade:m}=i,p=o[d];if(Array.isArray(p))return Ds("div",{className:"color-picker-content--default shades",children:p.map((u,E)=>{let g=w5(u,e===v5.DARK);return q0("button",{ref:E===m&&a==="shades"?c:void 0,tabIndex:-1,type:"button",className:b5("color-picker__button color-picker__button--large",{active:E===m}),"aria-label":"Shade",title:`${d} - ${E+1}`,style:u?{"--swatch-color":g}:void 0,onClick:()=>{t(u),s("shades")},onPointerDown:l?b=>l.startSwatchDrag(b,u):void 0,children:[Ds("div",{className:"color-picker__button-outline"}),r&&Ds(zi,{color:g,keyLabel:E+1,isShade:!0})]},E)})})}return q0("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Ds("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Ds("div",{tabIndex:-1,style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center",fontSize:"0.75rem"},children:f("colorPicker.noShades")})]})};import{COLORS_PER_ROW as Hi,COLOR_PALETTE as I5,KEYS as Ls}from"@excalidraw/common";var id=(e,n,t)=>{let o=Math.ceil(t/Hi);switch(n=n??-1,e){case"ArrowLeft":{let r=n-1;return r<0?t-1:r}case"ArrowRight":return(n+1)%t;case"ArrowDown":{let r=n+Hi;return r>=t?n%Hi:r}case"ArrowUp":{let r=n-Hi,i=r<0?Hi*o+r:r;return i>=t?void 0:i}}},T5=({e,colorObj:n,onChange:t,palette:o,customColors:r,setActiveColorPickerSection:i,activeShade:a,excludedColors:s})=>{if(n?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let l=Number(e.code.slice(-1))-1;return t(o[n.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(Ms.includes(e.key)){let l=Ms.indexOf(e.key),c=Object.keys(o)[l],d=o[c],m=Array.isArray(d)?d[a]:d;return m==null||s?.includes(m)||(t(m),i("baseColors")),!0}return!1},Q0=({event:e,activeColorPickerSection:n,palette:t,color:o,onChange:r,customColors:i,setActiveColorPickerSection:a,updateData:s,activeShade:l,onEyeDropperToggle:c,onEscape:d,excludedColors:m})=>{if(e[Ls.CTRL_OR_CMD])return!1;if(e.key===Ls.ESCAPE)return d(e),!0;if(e.key===Ls.ALT)return c(!0),!0;if(e.key===Ls.I)return c(),!0;let p=jo({color:o,palette:t});if(e.key===Ls.TAB){let u={custom:!!i.length,baseColors:!0,shades:p?.shade!=null,hex:!0},E=Object.entries(u).reduce((x,[I,T])=>(T&&x.push(I),x),[]),g=E.indexOf(n),b=e.shiftKey?-1:1,y=g+b>E.length-1?0:g+b<0?E.length-1:g+b,w=E[y];return w&&a(w),w==="custom"?r(i[0]):w==="baseColors"&&(Object.entries(t).find(([I,T])=>Array.isArray(T)?T.includes(o):T===o?I:null)||r(I5.black)),e.preventDefault(),e.stopPropagation(),!0}if(T5({e,colorObj:p,onChange:r,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:l,excludedColors:m}))return!0;if(n==="shades"&&p){let{shade:u}=p,E=id(e.key,u,Hi);if(E!==void 0)return r(t[p.colorName][E]),!0}if(n==="baseColors"&&p){let{colorName:u}=p,E=Object.keys(t),g=E.indexOf(u),b=id(e.key,g,E.length),y=0;for(;b!==void 0&&y++<E.length;){let w=t[E[b]],x=Array.isArray(w)?w[l]:w;if(!m?.includes(x))break;b=id(e.key,b,E.length)}if(b!==void 0){let w=E[b],x=t[w];return r(Array.isArray(x)?x[l]:x),!0}}if(n==="custom"){let u=o!=null?i.indexOf(o):0,E=id(e.key,u,i.length);if(E!==void 0){let g=i[E];return r(g),!0}}return!1};import{jsx as xo,jsxs as ad}from"react/jsx-runtime";var ty=bh.forwardRef(({theme:e,color:n,onChange:t,type:o,elements:r,palette:i,updateData:a,children:s,showTitle:l,onEyeDropperToggle:c,onEscape:d,showHotKey:m=!0,excludedColors:p},u)=>{let E=l?o==="elementStroke"?f("labels.stroke"):o==="elementBackground"?f("labels.background"):null:null,[g]=bh.useState(()=>o==="canvasBackground"?[]:B0(r,o,i)),[b,y]=He(an),w=sn(),x=jo({color:n,palette:i});xh(()=>{if(!b){let P=!!n&&ph({color:n,palette:i}),A=P&&!g.includes(n);y(A?null:P?"custom":x?.shade!=null?"shades":"baseColors")}},[b,n,i,y,x,g]);let[I,T]=C5(x?.shade??(o==="elementBackground"?P5:k5));xh(()=>{x?.shade!=null&&T(x.shade);let P=A=>{A.key===M5.ALT&&c(!1)};return document.addEventListener(ey.KEYUP,P,{capture:!0}),()=>{document.removeEventListener(ey.KEYUP,P,{capture:!0})}},[x,c]);let C=bh.useRef(null);return S5(u,()=>C.current),xh(()=>{C?.current?.focus()},[]),xo("div",{role:"dialog","aria-modal":"true","aria-label":f("labels.colorPicker"),children:ad("div",{ref:C,onKeyDown:P=>{Q0({event:P,activeColorPickerSection:b,palette:i,color:n,onChange:t,onEyeDropperToggle:c,customColors:g,setActiveColorPickerSection:y,updateData:a,activeShade:I,onEscape:d,excludedColors:p})&&(P.preventDefault(),P.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[E&&xo("div",{className:"color-picker__title",children:E}),!!g.length&&ad("div",{children:[xo(Gi,{children:f("colorPicker.mostUsedCustomColors")}),xo(Z0,{theme:e,colors:g,color:n,label:f("colorPicker.mostUsedCustomColors"),onChange:t})]}),ad("div",{children:[xo(Gi,{children:f("colorPicker.colors")}),xo(j0,{theme:e,color:n,palette:i,onChange:t,activeShade:I,showHotKey:m,excludedColors:p})]}),ad("div",{children:[xo(Gi,{children:f("colorPicker.shades")}),xo(J0,{theme:e,color:n,onChange:t,palette:i,showHotKey:m})]}),s,w&&xo("div",{className:"color-picker__tip",children:f("colorPicker.topPicksTip")})]})})});import ny from"clsx";import{ContextMenu as _s}from"radix-ui";import{applyDarkModeFilter as A5,COLOR_OUTLINE_CONTRAST_THRESHOLD as D5,DEFAULT_CANVAS_BACKGROUND_PICKS as L5,DEFAULT_ELEMENT_BACKGROUND_PICKS as _5,DEFAULT_ELEMENT_STROKE_PICKS as R5,isColorDark as N5,THEME as B5}from"@excalidraw/common";import{jsx as qo,jsxs as oy}from"react/jsx-runtime";var ry=({theme:e,onChange:n,type:t,activeColor:o,topPicks:r,onReset:i,isCustomized:a})=>{let s=sn(),l=s?.dragState??null,{container:c}=Re(),d;if(t==="elementStroke"&&(d=R5),t==="elementBackground"&&(d=_5),t==="canvasBackground"&&(d=L5),r&&(d=r),!d)return console.error("Invalid type for TopPicks"),null;let m=u=>{if(!l||l.origin.kind!=="pick"||l.overIndex===null)return 0;let E=l.origin.index,g=l.overIndex;if(E===g)return 0;let b=u;return u===E?b=g:(u>E&&(b-=1),b>=g&&(b+=1)),(b-u)*l.slotSpan},p=oy("div",{className:ny("color-picker__top-picks",{"is-dnd-active":!!l}),ref:s?.setStripEl,children:[l&&qo("svg",{className:"color-picker__top-picks__dnd-outline","aria-hidden":"true",children:qo("rect",{})}),d.map((u,E)=>{let g=m(E),b=A5(u,e===B5.DARK);return qo("button",{className:ny("color-picker__button",{active:u===o,"is-transparent":u==="transparent"||!u,"has-outline":!N5(u,D5),"is-dnd-source":l?.origin.kind==="pick"&&l.origin.index===E,"is-dnd-target":l?.origin.kind==="swatch"&&l.overIndex===E,"is-dnd-duplicate":l?.duplicateIndex===E}),style:{"--swatch-color":b,transform:g?`translateX(${g}px)`:void 0},type:"button",title:u,onClick:()=>n(u),onPointerDown:s?y=>s.startPickDrag(y,E,u):void 0,"data-testid":`color-top-pick-${u}`,"data-top-pick-index":E,children:qo("div",{className:"color-picker__button-outline"})},u)})]});return i?oy(_s.Root,{children:[qo(_s.Trigger,{asChild:!0,children:p}),qo(_s.Portal,{container:c,children:qo(_s.Content,{className:"color-picker__context-menu",style:{zIndex:"var(--zIndex-ui-styles-popup)"},children:qo(_s.Item,{className:"color-picker__context-menu-item",disabled:!a,onSelect:i,children:f("colorPicker.resetTopPicks")})})})]}):p};import{jsx as ln,jsxs as sd}from"react/jsx-runtime";var V5=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=dy,updateData:a,getOpenPopup:s,appState:l,excludedColors:c})=>{let{container:d}=Re(),m=ct(),p=m!=="full",u=m==="mobile",[,E]=He(an),[g,b]=He(zt),y=sd("div",{children:[ln(Gi,{children:f("colorPicker.hexCode")}),ln(G0,{color:n||"",label:o,onChange:I=>{t(I)},colorPickerType:e,placeholder:f("colorPicker.color")})]}),w=cy(null),x=()=>{w.current?.focus()};return ln(bo,{container:d,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!l.editingTextElement,onFocusOutside:I=>{if(I.target instanceof HTMLElement&&I.target.closest(".color-picker__context-menu")){I.preventDefault();return}U5(I.target)||(I.target instanceof HTMLElement&&I.target.matches(":active")?window.addEventListener("pointerup",x,{once:!0}):x()),I.preventDefault()},onPointerDownOutside:I=>{g&&I.preventDefault()},onClose:()=>{s()===e&&a({openPopup:null}),E(null),l.editingTextElement&&setTimeout(()=>{let I=document.querySelector(".excalidraw-wysiwyg");I&&I.focus()},0)},children:i?ln(ty,{ref:w,palette:i,excludedColors:c,color:n,theme:l.theme,onChange:I=>{let T=l.editingTextElement?od():null;t(I),l.editingTextElement&&T&&Ps(T)},onEyeDropperToggle:I=>{b(T=>I?(T=T||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},T.keepOpenOnAlt=!0,T):I===!1||T?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:I=>{g?b(null):a({openPopup:null})},type:e,elements:r,updateData:a,showTitle:p,showHotKey:!u,children:y}):y})},Y5=e=>e==="elementStroke"||e==="elementBackground"||e==="canvasBackground",X5=({label:e,color:n,type:t,theme:o,mode:r="background",onToggle:i,editingTextElement:a})=>{let s=ct(),l=s!=="full",c=s==="mobile",d=sn(),m=n?z5(n,o===W5.DARK):null,p=u=>{u.preventDefault(),u.stopPropagation(),a&&N0(),i()};return sd(sy.Trigger,{type:"button",className:ly("color-picker__button active-color properties-trigger",{"is-transparent":!n||n==="transparent","has-outline":!n||!ay(n,iy),"compact-sizing":l,"mobile-border":c}),"aria-label":e,style:m?{"--swatch-color":m}:void 0,title:t==="elementStroke"?f("labels.showStroke"):f("labels.showBackground"),"data-openpopup":t,onClick:p,onPointerDown:d?u=>d.startSwatchDrag(u,n):void 0,children:[ln("div",{className:"color-picker__button-outline",children:!n&&Xx}),l&&n&&r==="stroke"&&ln("div",{className:"color-picker__button-background",children:ln("span",{style:{color:m&&ay(m,iy)?"#fff":"#111"},children:p0})})]})},K5=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=dy,topPicks:a,updateData:s,appState:l,excludedColors:c,customizableTopPicks:d})=>{let m=cy(l.openPopup);O5(()=>{m.current=l.openPopup},[l.openPopup]);let u=ct()!=="full",E=!!d&&!u,g=E&&d?l.colorTopPicks?.[d]:null,b=g?.length?g:a??(e==="elementStroke"?H5:G5),y=$0({enabled:E,picks:b,onPicksChange:w=>{d&&s({colorTopPicks:{...l.colorTopPicks,[d]:w}})}});return ln(fh.Provider,{value:E?y:null,children:sd("div",{role:"dialog","aria-modal":"true",className:ly("color-picker-container",{"color-picker-container--no-top-picks":u}),children:[!u&&ln(ry,{theme:l.theme,activeColor:n,onChange:w=>{t(w),Y5(l.openPopup)&&l.openPopup!==e&&setTimeout(()=>s({openPopup:e}),0)},type:e,topPicks:g?.length?g:a,isCustomized:!!g?.length,onReset:E&&d?()=>{s({colorTopPicks:{...l.colorTopPicks,[d]:null}})}:void 0}),!u&&ln(Jc,{}),sd(sy.Root,{open:l.openPopup===e,onOpenChange:w=>{w&&s({openPopup:e})},children:[ln(X5,{color:n,label:o,type:e,theme:l.theme,mode:e==="elementStroke"?"stroke":"background",editingTextElement:!!l.editingTextElement,onToggle:()=>{l.openPopup===e?s({openPopup:null}):l.openPopup?s({openPopup:e}):s({openPopup:e})}}),l.openPopup===e&&ln(V5,{type:e,color:n,onChange:t,label:o,elements:r,palette:i,excludedColors:c,updateData:s,getOpenPopup:()=>m.current,appState:l})]})]})})},$5=(e,n)=>e.appState.openPopup===e.type||n.appState.openPopup===n.type?!1:e.type===n.type&&e.color===n.color&&e.label===n.label&&e.appState.openPopup===n.appState.openPopup&&e.palette===n.palette&&e.topPicks===n.topPicks&&e.excludedColors===n.excludedColors&&e.customizableTopPicks===n.customizableTopPicks&&e.appState.theme===n.appState.theme&&e.appState.colorTopPicks===n.appState.colorTopPicks&&!!e.appState.editingTextElement==!!n.appState.editingTextElement,Ui=F5(K5,$5);import{Popover as v4}from"radix-ui";import I4 from"clsx";import T4,{useCallback as S4,useMemo as C4}from"react";import{FONT_FAMILY as Ih}from"@excalidraw/common";import p4,{useMemo as er,useState as u4,useRef as hy,useEffect as gy,useCallback as fy}from"react";import{arrayToList as h4,debounce as g4,FONT_FAMILY as tr,getFontFamilyString as f4}from"@excalidraw/common";import Z5 from"clsx";import j5 from"react";import{jsx as q5,jsxs as J5}from"react/jsx-runtime";var ld=j5.forwardRef(({className:e,placeholder:n,onChange:t},o)=>J5("div",{className:Z5("QuickSearch__wrapper",e),children:[Jn,q5("input",{ref:o,className:"QuickSearch__input",type:"text",placeholder:n,onChange:r=>t(r.target.value.trim().toLowerCase())})]}));import Q5 from"clsx";import{Children as e4}from"react";import{jsx as my}from"react/jsx-runtime";var cd=({className:e,placeholder:n,children:t})=>{let o=!e4.count(t);return my("div",{className:Q5("ScrollableList__wrapper",e),role:"menu",children:o?my("div",{className:"empty",children:n}):t})};import{jsx as t4,jsxs as n4}from"react/jsx-runtime";var py=({children:e,className:n="",style:t,title:o})=>n4("div",{className:`dropdown-menu-group ${n}`,style:t,children:[o&&t4("p",{className:"dropdown-menu-group-title",children:o}),e]}),Rs=py;py.displayName="DropdownMenuGroup";import{THEME as d4}from"@excalidraw/common";import{DropdownMenu as m4}from"radix-ui";import o4,{useContext as r4}from"react";import{composeEventHandlers as i4}from"@excalidraw/common";var yh=o4.createContext({}),Jo=(e="",n=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${n?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),dd=e=>{let n=r4(yh);return i4(e,t=>{n.onSelect?.(t)})};import{jsx as a4}from"react/jsx-runtime";var Ns=({children:e,...n})=>a4("span",{...n,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...n.style},children:e});import{Fragment as l4,jsx as Bs,jsxs as c4}from"react/jsx-runtime";var s4=({textStyle:e,icon:n,shortcut:t,children:o,badge:r})=>{let i=Ee();return c4(l4,{children:[n&&Bs("div",{className:"dropdown-menu-item__icon",children:n}),Bs("div",{style:e,className:"dropdown-menu-item__text",children:Bs(Ns,{children:o})}),r&&Bs("div",{className:"dropdown-menu-item__badge",children:r}),t&&i.formFactor!=="phone"&&Bs("div",{className:"dropdown-menu-item__shortcut",children:t})]})},Qo=s4;import{jsx as md}from"react/jsx-runtime";var wh=({icon:e,badge:n,value:t,children:o,shortcut:r,className:i,selected:a,onSelect:s,...l})=>{let c=dd(s);return md(m4.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:md("button",{...l,value:t,className:Jo(i,a),title:l.title??l["aria-label"],children:md(Qo,{icon:e,shortcut:r,badge:n,children:o})})})};wh.displayName="DropdownMenuItem";var Wi={GREEN:"green",RED:"red",BLUE:"blue"},pd=({type:e=Wi.BLUE,children:n})=>{let{theme:t}=Qn(),o={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===d4.LIGHT?"1.5px solid white":"none"};switch(e){case Wi.GREEN:Object.assign(o,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case Wi.RED:Object.assign(o,{backgroundColor:"pink",color:"darkred"});break;case Wi.BLUE:default:Object.assign(o,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return md("div",{className:"DropDownMenuItemBadge",style:o,children:n})};pd.displayName="DropdownMenuItemBadge";wh.Badge=pd;var jt=wh;import{KEYS as Vi}from"@excalidraw/common";var uy=({event:e,inputRef:n,hoveredFont:t,filteredFonts:o,onClose:r,onSelect:i,onHover:a})=>{if(!e[Vi.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===Vi.F)return n.current?.focus(),!0;if(e.key===Vi.ESCAPE)return r(),!0;if(e.key===Vi.ENTER)return t?.value&&i(t.value),!0;if(e.key===Vi.ARROW_DOWN)return t?.next?a(t.next.value):o[0]?.value&&a(o[0].value),!0;if(e.key===Vi.ARROW_UP)return t?.prev?a(t.prev.value):o[o.length-1]?.value&&a(o[o.length-1].value),!0};import{jsx as yo,jsxs as x4}from"react/jsx-runtime";var E4=e=>{switch(e){case tr.Excalifont:case tr.Virgil:return $n;case tr.Nunito:case tr.Helvetica:return Ts;case tr["Lilita One"]:return R1;case tr["Comic Shanns"]:case tr.Cascadia:return Oc;default:return Ts}},b4=(e,n)=>Object.entries(tr).find(([,t])=>t===e)?.[0]??n[0]?.fontFace?.family??"Unknown",Ey=p4.memo(({selectedFontFamily:e,hoveredFontFamily:n,onSelect:t,onHover:o,onLeave:r,onOpen:i,onClose:a})=>{let{container:s}=Re(),l=St(),{fonts:c}=l,{showDeprecatedFonts:d}=kn(),m=ct(),[p,u]=u4(""),E=hy(null),g=er(()=>Array.from(go.registered.entries()).filter(([k,{metadata:L}])=>!L.private&&!L.fallback).map(([k,{metadata:L,fontFaces:B}])=>{let V={value:k,icon:E4(k),text:b4(k,B)};return L.deprecated&&Object.assign(V,{deprecated:L.deprecated,badge:{type:Wi.RED,placeholder:f("fontList.badge.old")}}),V}).sort((k,L)=>k.text.toLowerCase()>L.text.toLowerCase()?1:-1),[]),b=er(()=>new Set(c.getSceneFamilies()),[e]),y=er(()=>g.filter(k=>b.has(k.value)),[g,b]),w=er(()=>g.filter(k=>!b.has(k.value)&&(d||!k.deprecated)),[g,b,d]),x=er(()=>h4([...y,...w].filter(k=>k.text?.toLowerCase().includes(p))),[y,w,p]),I=er(()=>{let k;return n?k=x.find(L=>L.value===n):e&&(k=x.find(L=>L.value===e)),!k&&p&&(x[0]?.value?o(x[0].value):r()),k},[n,e,p,x,o,r]),T=fy(k=>{let L=null;if(l.state.editingTextElement){let B=document.querySelector(".excalidraw-wysiwyg");B&&(L={start:B.selectionStart,end:B.selectionEnd})}t(k),l.state.editingTextElement&&L&&setTimeout(()=>{let B=document.querySelector(".excalidraw-wysiwyg");B&&L&&(B.focus(),B.selectionStart=L.start,B.selectionEnd=L.end)},0)},[t,l.state.editingTextElement]),C=fy(k=>{uy({event:k,inputRef:E,hoveredFont:I,filteredFonts:x,onSelect:T,onHover:o,onClose:a})&&(k.preventDefault(),k.stopPropagation())},[I,x,T,o,a]);gy(()=>(i(),()=>{a()}),[]);let P=er(()=>x.filter(k=>b.has(k.value)),[x,b]),A=er(()=>x.filter(k=>!b.has(k.value)),[x,b]),D=({font:k,order:L})=>{let B=hy(null),V=k.value===I?.value,z=k.value===e;return gy(()=>{V&&(L===0?B.current?.scrollIntoView?.({block:"end"}):B.current?.scrollIntoView?.({block:"nearest"}))},[V,L]),yo("button",{ref:B,type:"button",value:k.value,className:Jo("",z,V),title:k.text,tabIndex:z?0:-1,onClick:U=>{T(Number(U.currentTarget.value))},onMouseMove:()=>{I?.value!==k.value&&o(k.value)},children:yo(Qo,{icon:k.icon,badge:k.badge&&yo(pd,{type:k.badge.type,children:k.badge.placeholder}),textStyle:{fontFamily:f4({fontFamily:k.value})},children:k.text})})},_=[];return P.length&&_.push(yo(Rs,{title:f("fontList.sceneFonts"),children:P.map((k,L)=>yo(D,{font:k,order:L},k.value))},"group_1")),A.length&&_.push(yo(Rs,{title:f("fontList.availableFonts"),children:A.map((k,L)=>yo(D,{font:k,order:L+P.length},k.value))},"group_2")),x4(bo,{className:"properties-content",container:s,style:{width:"15rem"},onClose:()=>{a(),l.state.editingTextElement&&setTimeout(()=>{let k=document.querySelector(".excalidraw-wysiwyg");k&&k.focus()},0)},onPointerLeave:r,onKeyDown:C,preventAutoFocusOnTouch:!!l.state.editingTextElement,children:[m==="full"&&yo(ld,{ref:E,placeholder:f("quickSearch.placeholder"),onChange:g4(u,20)}),yo(cd,{className:"dropdown-menu fonts manual-hover",placeholder:f("fontList.empty"),children:_.length?_:null})]})},(e,n)=>e.selectedFontFamily===n.selectedFontFamily&&e.hoveredFontFamily===n.hoveredFontFamily);import{Popover as y4}from"radix-ui";import{MOBILE_ACTION_BUTTON_BG as w4}from"@excalidraw/common";import{jsx as vh}from"react/jsx-runtime";var by=({selectedFontFamily:e,isOpened:n=!1,compactMode:t=!1})=>{let o=Fe(),r=t?{...w4,width:"2rem",height:"2rem"}:{};return vh(y4.Trigger,{asChild:!0,children:vh("div",{"data-openpopup":"fontFamily",className:"properties-trigger",children:vh($,{type:"toggle",icon:Pn,title:f("labels.showFonts"),"aria-label":f("labels.showFonts"),className:"standalone properties-trigger","data-testid":"font-family-show-fonts",checked:n,onSelect:()=>{o(i=>({openPopup:i.openPopup==="fontFamily"?null:i.openPopup}))},style:{border:"none",...r}})})})};import{jsx as Fs,jsxs as xy}from"react/jsx-runtime";var yy=[{value:Ih.Excalifont,icon:$n,text:f("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:Ih.Nunito,icon:Ts,text:f("labels.normal"),testId:"font-family-normal"},{value:Ih["Comic Shanns"],icon:Oc,text:f("labels.code"),testId:"font-family-code"}],ete=new Set(yy.map(e=>e.value));var wy=T4.memo(({isOpened:e,selectedFontFamily:n,hoveredFontFamily:t,onSelect:o,onHover:r,onLeave:i,onPopupChange:a,compactMode:s=!1})=>{let l=C4(()=>yy,[]),c=S4(d=>{d&&o(d)},[o]);return xy("div",{role:"dialog","aria-modal":"true",className:I4("FontPicker__container",{"FontPicker__container--compact":s}),children:[!s&&Fs("div",{className:"buttonList",children:Fs(Zt,{type:"button",options:l,value:n,onClick:c})}),!s&&Fs(Jc,{}),xy(v4.Root,{open:e,onOpenChange:a,children:[Fs(by,{selectedFontFamily:n,isOpened:e,compactMode:s}),e&&Fs(Ey,{selectedFontFamily:n,hoveredFontFamily:t,onSelect:c,onHover:r,onLeave:i,onOpen:()=>a(!0),onClose:()=>a(!1)})]})]})},(e,n)=>e.isOpened===n.isOpened&&e.selectedFontFamily===n.selectedFontFamily&&e.hoveredFontFamily===n.hoveredFontFamily);import{Popover as Th}from"radix-ui";import A4 from"clsx";import Sy,{useEffect as D4,useMemo as L4}from"react";import{isArrowKey as _4,KEYS as wo}from"@excalidraw/common";import{jsx as P4}from"react/jsx-runtime";var ud=({className:e,icon:n,size:t="1em"})=>P4("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:n});import{Fragment as M4,jsx as vy,jsxs as Iy}from"react/jsx-runtime";var k4=({label:e,open:n,openTrigger:t,children:o,className:r,showCollapsedIcon:i=!0})=>Iy(M4,{children:[Iy("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:r,onClick:t,children:[e,i&&vy(ud,{icon:n?l0:Hc})]}),n&&vy("div",{style:{display:"flex",flexDirection:"column"},children:o})]}),Os=k4;import{jsx as eo,jsxs as gd}from"react/jsx-runtime";var R4=Je(!1),hd=4,N4="default",B4=e=>e.flatMap(n=>n.options),Ty=(e,n)=>{for(let t of e){let o=t.options.find(n);if(o)return o}return null},F4=(e,n)=>e.some(t=>t.options.some(n)),O4=e=>e.flatMap(n=>Array.from({length:Math.ceil(n.options.length/hd)},(t,o)=>n.options.slice(o*hd,o*hd+hd)));function z4({visibleSections:e,hiddenSections:n=[],value:t,label:o,onChange:r,onClose:i}){let{container:a}=Re(),[s,l]=He(R4),c=[...e,...n],d=B4(c),m=O4([...e,...s?n:[]]),p=g=>{let b=d.find(y=>y.keyBinding===g.key.toLowerCase());if(!(g.metaKey||g.altKey||g.ctrlKey)&&b)r(b.value),g.preventDefault();else if(g.key===wo.TAB){let y=d.findIndex(x=>x.value===t),w=g.shiftKey?(d.length+y-1)%d.length:(y+1)%d.length;r(d[w].value)}else if(_4(g.key)){let y=Kn().rtl,w=d.findIndex(x=>x.value===t);if(w!==-1){let x=d.length,I=w;switch(g.key){case(y?wo.ARROW_LEFT:wo.ARROW_RIGHT):I=(w+1)%x;break;case(y?wo.ARROW_RIGHT:wo.ARROW_LEFT):I=(x+w-1)%x;break;case wo.ARROW_DOWN:{let T=m.findIndex(P=>P.some(A=>A.value===t)),C=m[T];if(T!==-1&&C){let P=C.findIndex(_=>_.value===t),A=m[(T+1)%m.length],D=A[Math.min(P,A.length-1)]??d[w];r(D.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}case wo.ARROW_UP:{let T=m.findIndex(P=>P.some(A=>A.value===t)),C=m[T];if(T!==-1&&C){let P=C.findIndex(_=>_.value===t),A=m[(m.length+T-1)%m.length],D=A[Math.min(P,A.length-1)]??d[w];r(D.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}}r(d[I].value)}g.preventDefault()}else(g.key===wo.ESCAPE||g.key===wo.ENTER)&&(g.preventDefault(),i());g.nativeEvent.stopImmediatePropagation(),g.stopPropagation()};D4(()=>{F4(n,g=>g.value===t)&&l(!0)},[t,n,l]);let u=g=>eo("div",{className:"picker-content",children:g.map(b=>gd("button",{type:"button",className:A4("picker-option",{active:t===b.value}),onClick:()=>{r(b.value)},title:b.keyBinding?`${b.text} \u2014 ${b.keyBinding.toUpperCase()}`:b.text,"aria-label":b.text||"none","aria-keyshortcuts":b.keyBinding||void 0,ref:y=>{t===b.value&&setTimeout(()=>{y?.focus()},0)},children:[b.icon,b.keyBinding&&eo("span",{className:"picker-keybinding",children:b.keyBinding})]},b.text))}),E=g=>g.map((b,y)=>b.name===N4?eo(Sy.Fragment,{children:u(b.options)},`${b.name}-${y}`):gd("div",{className:"picker-section",children:[eo("div",{className:"picker-section-label",children:b.name}),u(b.options)]},`${b.name}-${y}`));return eo(Th.Content,{className:"picker",role:"dialog","aria-modal":"true","aria-label":o,side:"bottom",align:"start",sideOffset:12,alignOffset:12,style:{zIndex:"var(--zIndex-ui-styles-popup)"},onKeyDown:p,collisionBoundary:a??void 0,children:gd("div",{className:"picker-sections",children:[E(e),n.length>0&&eo(Os,{label:f("labels.more_options"),open:s,openTrigger:()=>{l(g=>!g)},className:"picker-collapsible",children:eo("div",{className:"picker-sections",children:E(n)})})]})})}function Sh({value:e,label:n,visibleSections:t,hiddenSections:o,onChange:r}){let[i,a]=Sy.useState(!1),s=L4(()=>Ty(t,l=>l.value===e)??Ty(o??[],l=>l.value===e),[t,o,e]);return eo("div",{children:gd(Th.Root,{open:i,onOpenChange:l=>a(l),children:[eo(Th.Trigger,{type:"button","aria-label":n,onClick:()=>a(!i),className:i?"active":"",children:s?.icon}),i&&eo(z4,{visibleSections:t,hiddenSections:o,value:e,label:n,onChange:r,onClose:()=>{a(!1)}})]})})}import Cy,{useEffect as G4}from"react";import{jsx as Ch,jsxs as Py}from"react/jsx-runtime";var ky=({label:e,value:n,onChange:t,min:o=0,max:r=100,step:i=10,minLabel:a=o,hasCommonValue:s=!0,testId:l})=>{let c=Cy.useRef(null),d=Cy.useRef(null);return G4(()=>{if(c.current&&d.current){let m=c.current,p=d.current,u=m.offsetWidth,E=parseFloat(getComputedStyle(m).getPropertyValue("--slider-thumb-size"))||16,g=(n-o)/(r-o||1)*100,b=g/100*(u-E)+E/2;p.style.left=`${b}px`,m.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,o,n]),Py("label",{className:"control-label",children:[e,Py("div",{className:"range-wrapper",children:[Ch("input",{style:{"--color-slider-track":s?void 0:"var(--button-bg)"},ref:c,type:"range",min:o,max:r,step:i,onChange:m=>{t(+m.target.value)},value:n,className:"range-input","data-testid":l}),Ch("div",{className:"value-bubble",ref:d,children:n!==o?n:null}),Ch("div",{className:"zero-label",children:a})]})]})};import{Fragment as vd,jsx as Q,jsxs as bt}from"react/jsx-runtime";var Oy=.1,Gr=e=>{let n=m6(e.editorInterface);return{stylesPanelMode:n,isCompact:n!=="full",isMobile:n==="mobile"}},Ct=(e,n,t,o=!1)=>{let r=Dh(ce(e,n,{includeBoundTextElement:o}));return e.map(i=>r.get(i.id)||i.id===n.editingTextElement?.id?(r6(i)||console.error("[NONDELETED][INVARIANT] changeProperty(): skipping deleted selected/editing element"),t(i)):i)},mt=function(e,n,t,o,r){let i=n.state.editingTextElement,a=By(e),s=null;if(i&&(s=t(i)),!s)if(De(a,n.state)){let c=n.scene.getSelectedElements(n.state),d=o===!0?c:c.filter(m=>o(m));s=n6(d,t)??(typeof r=="function"?r(!0):r)}else s=typeof r=="function"?r(!1):r;return s},p6=(e,n,t)=>a6(n)||!n.autoResize?n:t.mutateElement(n,{x:e.textAlign==="left"?e.x:e.x+(e.width-n.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-n.height)/2}),Lh=(e,n,t,o,r)=>{let i=new Set,a=Ct(e,n,s=>{if(Gt(s)){let l=o(s);i.add(l);let c=it(s,{fontSize:l});return zs(c,t.scene.getContainerElement(s),t.scene),c=p6(s,c,t.scene),c}return s},!0);return ce(e,n,{includeBoundTextElement:!0}).forEach(s=>{Gt(s)&&i6(s,t.scene)}),{elements:a,appState:{...n,currentItemFontSize:i.size===1?[...i][0]:r??n.currentItemFontSize},captureUpdate:et.IMMEDIATELY}},u6=O({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,n,t)=>({...t?.currentItemStrokeColor&&{elements:Ct(e,n,o=>l6(o.type)?it(o,{strokeColor:t.currentItemStrokeColor}):o,!0)},appState:{...n,...t},captureUpdate:t?.currentItemStrokeColor?et.IMMEDIATELY:et.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=Gr(o);return bt(vd,{children:[i==="full"&&Q("h3",{"aria-hidden":"true",children:f("labels.stroke")}),Q(Ui,{topPicks:K4,palette:X4,customizableTopPicks:"elementStroke",type:"elementStroke",label:f("labels.stroke"),color:mt(e,o,a=>a.strokeColor,!0,a=>a?null:n.currentItemStrokeColor),onChange:a=>t({currentItemStrokeColor:a}),elements:e,appState:n,updateData:t})]})}}),h6=O({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t,o)=>{if(!t?.currentItemBackgroundColor)return{appState:{...n,...t},captureUpdate:et.EVENTUALLY};let r,i=o.scene.getSelectedElements(n);if(!t6(t.currentItemBackgroundColor)&&i.every(s=>Ly(s)&&o6(s.points))){let s=Dh(i);r=e.map(l=>s.has(l.id)&&Ly(l)?it(l,{backgroundColor:t.currentItemBackgroundColor,...d6(l,!0)}):l)}else r=Ct(e,n,s=>it(s,{backgroundColor:t.currentItemBackgroundColor}));return{elements:r,appState:{...n,...t},captureUpdate:et.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=Gr(o);return bt(vd,{children:[i==="full"&&Q("h3",{"aria-hidden":"true",children:f("labels.background")}),Q(Ui,{topPicks:Y4,palette:Ry,customizableTopPicks:"elementBackground",type:"elementBackground",label:f("labels.background"),color:mt(e,o,a=>a.backgroundColor,!0,a=>a?null:n.currentItemBackgroundColor),onChange:a=>t({currentItemBackgroundColor:a}),elements:e,appState:n,updateData:t})]})}}),wd=O({name:"changeBucketFillBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,...t},captureUpdate:et.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let{stylesPanelMode:r}=Gr(o);return bt(vd,{children:[r==="full"&&Q("h3",{"aria-hidden":"true",children:f("labels.background")}),Q(Ui,{topPicks:W4,palette:Ry,excludedColors:[V4.transparent],customizableTopPicks:"bucketFill",type:"elementBackground",label:f("labels.background"),color:o.bucketFill.getBucketFillBackgroundColor(n.currentItemBackgroundColor),onChange:i=>t({currentItemBackgroundColor:i}),elements:e,appState:n,updateData:t})]})}}),g6=O({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,n,t,o)=>(Be("element","changeFillStyle",`${t} (${o.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),{elements:Ct(e,n,r=>it(r,{fillStyle:t})),appState:{...n,currentItemFillStyle:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=ce(e,n),i=r.length>0&&r.every(a=>a.fillStyle==="zigzag");return bt("fieldset",{children:[Q("legend",{children:f("labels.fill")}),Q("div",{className:"buttonList",children:Q(Zt,{type:"button",options:[{value:"hachure",text:`${i?f("labels.zigzag"):f("labels.hachure")} (${N("Alt-Click")})`,icon:i?n1:o1,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:f("labels.crossHatch"),icon:r1,testId:"fill-cross-hatch"},{value:"solid",text:f("labels.solid"),icon:i1,testId:"fill-solid"}],value:mt(e,o,a=>a.fillStyle,a=>a.hasOwnProperty("fillStyle"),a=>a?null:n.currentItemFillStyle),onClick:(a,s)=>{let l=s.altKey&&a==="hachure"&&r.every(c=>c.fillStyle==="hachure")?"zigzag":a;t(l)}})})]})}}),f6=e=>q4.find(n=>Ny(e.type,n)===e.strokeWidth)??null,E6=(e,n)=>Ny(e.type,n),b6=O({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,n,t)=>(yd(t,"actionChangeStrokeWidth: value must be defined"),{elements:Ct(e,n,o=>it(o,{strokeWidth:E6(o,t)})),appState:{...n,currentItemStrokeWidthKey:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>bt("fieldset",{children:[Q("legend",{children:f("labels.strokeWidth")}),Q("div",{className:"buttonList",children:Q(Zt,{group:"stroke-width",options:[{value:"thin",text:f("labels.thin"),icon:Gu,testId:"strokeWidth-thin"},{value:"medium",text:f("labels.medium"),icon:a1,testId:"strokeWidth-medium"},{value:"bold",text:f("labels.bold"),icon:s1,testId:"strokeWidth-bold"}],value:mt(e,o,f6,i=>i.hasOwnProperty("strokeWidth"),i=>i?null:n.currentItemStrokeWidthKey),onChange:i=>t(i)})})]})}),x6=O({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>it(o,{seed:J4(),roughness:t})),appState:{...n,currentItemRoughness:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>bt("fieldset",{children:[Q("legend",{children:f("labels.sloppiness")}),Q("div",{className:"buttonList",children:Q(Zt,{group:"sloppiness",options:[{value:0,text:f("labels.architect"),icon:d1},{value:1,text:f("labels.artist"),icon:m1},{value:2,text:f("labels.cartoonist"),icon:p1}],value:mt(e,o,i=>i.roughness,i=>i.hasOwnProperty("roughness"),i=>i?null:n.currentItemRoughness),onChange:i=>t(i)})})]})}),y6=O({name:"changeFreedrawMode",label:"labels.pressure",trackEvent:!1,perform:(e,n,t)=>{let o=t||"constant";return{elements:Ct(e,n,r=>r.type!=="freedraw"?r:it(r,{strokeOptions:{...r.strokeOptions,variability:o}})),appState:{...n,currentItemStrokeVariability:o},captureUpdate:et.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=mt(e,o,a=>a.strokeOptions?.variability,a=>a.type==="freedraw",a=>a?null:n.currentItemStrokeVariability)??n.currentItemStrokeVariability;if(r?.cycle){let a=i==="variable";return Q($,{type:"button",icon:a?Uu:Hu,title:f("labels.pressure"),"aria-label":f("labels.pressure"),onClick:()=>t(a?"constant":"variable")})}return bt("fieldset",{children:[Q("legend",{children:f("labels.pressure")}),Q("div",{className:"buttonList",children:Q(Zt,{group:"strokeOptions.variability",options:[{value:"constant",text:f("labels.pressure_constant"),icon:Hu},{value:"variable",text:f("labels.pressure_variable"),icon:Uu}],value:i,onChange:a=>t(a)})})]})}}),ane=O({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>it(o,{strokeStyle:t})),appState:{...n,currentItemStrokeStyle:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>bt("fieldset",{children:[Q("legend",{children:f("labels.strokeStyle")}),Q("div",{className:"buttonList",children:Q(Zt,{group:"strokeStyle",options:[{value:"solid",text:f("labels.strokeStyle_solid"),icon:Gu},{value:"dashed",text:f("labels.strokeStyle_dashed"),icon:l1},{value:"dotted",text:f("labels.strokeStyle_dotted"),icon:c1}],value:mt(e,o,i=>i.strokeStyle,i=>i.hasOwnProperty("strokeStyle"),i=>i?null:n.currentItemStrokeStyle),onChange:i=>t(i)})})]})}),w6=O({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>it(o,{opacity:t}),!0),appState:{...n,currentItemOpacity:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=mt(e,t,i=>i.opacity,!0,i=>i?null:n.currentItemOpacity);return Q(ky,{label:f("labels.opacity"),value:r??n.currentItemOpacity,hasCommonValue:r!==null,onChange:o,min:0,max:100,step:10,testId:"opacity"})}}),v6=O({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,n,t,o)=>Lh(e,n,o,()=>(yd(t,"actionChangeFontSize: Expected a font size value"),t),t),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=Gr(o);return bt("fieldset",{children:[Q("legend",{children:f("labels.fontSize")}),Q("div",{className:"buttonList",children:Q(Zt,{group:"font-size",options:[{value:Ed.sm,text:f("labels.small"),icon:A1,testId:"fontSize-small"},{value:Ed.md,text:f("labels.medium"),icon:D1,testId:"fontSize-medium"},{value:Ed.lg,text:f("labels.large"),icon:L1,testId:"fontSize-large"},{value:Ed.xl,text:f("labels.veryLarge"),icon:_1,testId:"fontSize-veryLarge"}],value:mt(e,o,a=>{if(Gt(a))return a.fontSize;let s=nr(a,o.scene.getNonDeletedElementsMap());return s?s.fontSize:null},a=>Gt(a)||nr(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:n.currentItemFontSize||Z4),onChange:a=>{ks(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),_h=O({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:Nr,trackEvent:!1,perform:(e,n,t,o)=>Lh(e,n,o,r=>Math.round(1/(1+Oy)*r.fontSize)),keyTest:e=>e[Yi.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Yi.CHEVRON_LEFT||e.key===Yi.COMMA)}),Rh=O({name:"increaseFontSize",label:"labels.increaseFontSize",icon:Nr,trackEvent:!1,perform:(e,n,t,o)=>Lh(e,n,o,r=>Math.round(r.fontSize*(1+Oy))),keyTest:e=>e[Yi.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Yi.CHEVRON_RIGHT||e.key===Yi.PERIOD)}),I6=O({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,n,t,o)=>{let{cachedElements:r,resetAll:i,resetContainers:a,...s}=t;if(i)return{elements:Ct(e,n,g=>{let b=r?.get(g.id);return b?it(g,{...b}):g},!0),appState:{...n,...s},captureUpdate:et.NEVER};yd(t,"actionChangeFontFamily: value must be defined");let{currentItemFontFamily:l,currentHoveredFontFamily:c}=t,d=et.EVENTUALLY,m,p=!1;if(l)m=l,d=et.IMMEDIATELY;else if(c){m=c,d=et.EVENTUALLY;let E=ce(e,n,{includeBoundTextElement:!0}).filter(g=>Gt(g));if(E.length>200)p=!0;else{let g=0,b=0;for(;g<E.length&&b<5e3;){let y=E[g];b+=y?.originalText.length||0,g++}b>5e3&&(p=!0)}}let u={appState:{...n,...s},captureUpdate:d};if(m&&!p){let E=new Map,g=new Set,b=!1,y=Array.from(go.loadedFontsCache.values()),w=Object.entries(j4).find(([T,C])=>C===m)?.[0];c&&w&&y.some(T=>T.startsWith(w))&&(b=!0),Object.assign(u,{elements:Ct(e,n,T=>{if(Gt(T)&&(T.fontFamily!==m||l)){let C=it(T,{fontFamily:m,lineHeight:e6(m)}),P=r?.get(T.containerId||"")||{},A=o.scene.getContainerElement(T);return a&&A&&P&&o.scene.mutateElement(A,{...P}),b||(g=new Set([...g,...Array.from(C.originalText)])),E.set(C,A),C}return T},!0)});let x=`10px ${Q4({fontFamily:m})}`,I=Array.from(g.values()).join();if(b||window.document.fonts.check(x,I))for(let[T,C]of E)zs(T,C,o.scene);else window.document.fonts.load(x,I).then(T=>{for(let[C,P]of E){let A=o.scene.getElement(C.id),D=P?o.scene.getElement(P.id):null;A&&zs(A,D,o.scene)}o.fonts.onLoaded(T)})}return u},PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=kh(new Map),i=kh(null),[a,s]=U4({}),l=kh(!0),{stylesPanelMode:c,isCompact:d}=Gr(t),m=Ah(()=>{let p=(u,E)=>mt(u,t,g=>{if(Gt(g))return g.fontFamily;let b=nr(g,E);return b?b.fontFamily:null},g=>Gt(g)||nr(g,E)!==null,g=>g?null:n.currentItemFontFamily||$4);return a.openPopup==="fontFamily"&&n.openPopup==="fontFamily"?p(Array.from(r.current?.values()??[]),r.current):!a.openPopup&&n.openPopup!=="fontFamily"?p(e,t.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,n,e,t]);return Ph(()=>{i.current=m},[m]),Ph(()=>{Object.keys(a).length&&(o(a),s({}))},[a]),Ph(()=>(l.current=!1,()=>{l.current=!0}),[]),bt(vd,{children:[c==="full"&&Q("legend",{children:f("labels.fontFamily")}),Q(wy,{isOpened:n.openPopup==="fontFamily",selectedFontFamily:m,hoveredFontFamily:n.currentHoveredFontFamily,compactMode:c!=="full",onSelect:p=>{ks(()=>{s({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:p}),r.current.clear()},d,!!n.editingTextElement)},onHover:p=>{s({currentHoveredFontFamily:p,cachedElements:new Map(r.current),resetContainers:!0})},onLeave:()=>{s({currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0})},onPopupChange:p=>{if(p){r.current.clear();let{editingTextElement:u}=n;if(u?.type==="text"){let E=t.scene.getElement(u.id);r.current.set(u.id,it(E||u,{},!0))}else{let E=ce(e,n,{includeBoundTextElement:!0});for(let g of E)r.current.set(g.id,it(g,{},!0))}s({...a,openPopup:"fontFamily"})}else{let u={currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0};s({...u}),r.current.clear(),d&&n.editingTextElement&&Ps(null)}}})]})}}),T6=O({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,n,t,o)=>({elements:Ct(e,n,r=>{if(Gt(r)){let i=it(r,{textAlign:t});return zs(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n,currentItemTextAlign:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=o.scene.getNonDeletedElementsMap(),{isCompact:a}=Gr(o);return bt("fieldset",{children:[Q("legend",{children:f("labels.textAlign")}),Q("div",{className:"buttonList",children:Q(Zt,{group:"text-align",options:[{value:"left",text:f("labels.left"),icon:N1,testId:"align-left"},{value:"center",text:f("labels.center"),icon:B1,testId:"align-horizontal-center"},{value:"right",text:f("labels.right"),icon:F1,testId:"align-right"}],value:mt(e,o,s=>{if(Gt(s))return s.textAlign;let l=nr(s,i);return l?l.textAlign:null},s=>Gt(s)||nr(s,i)!==null,s=>s?null:n.currentItemTextAlign),onChange:s=>{ks(()=>t(s),a,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),S6=O({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Ct(e,n,r=>{if(Gt(r)){let i=it(r,{verticalAlign:t});return zs(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=Gr(o);return Q("fieldset",{children:Q("div",{className:"buttonList",children:Q(Zt,{group:"text-align",options:[{value:fd.TOP,text:f("labels.alignTop"),icon:Q(O1,{theme:n.theme}),testId:"align-top"},{value:fd.MIDDLE,text:f("labels.centerVertically"),icon:Q(G1,{theme:n.theme}),testId:"align-middle"},{value:fd.BOTTOM,text:f("labels.alignBottom"),icon:Q(z1,{theme:n.theme}),testId:"align-bottom"}],value:mt(e,o,a=>{if(Gt(a)&&a.containerId)return a.verticalAlign;let s=nr(a,o.scene.getNonDeletedElementsMap());return s?s.verticalAlign:null},a=>Gt(a)||nr(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:fd.MIDDLE),onChange:a=>{ks(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})})}}),sne=O({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>Fy(o)?o:it(o,{roundness:t==="round"?{type:s6(o.type)?bd.ADAPTIVE_RADIUS:bd.PROPORTIONAL_RADIUS}:null})),appState:{...n,currentItemRoundness:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,renderAction:r})=>{let a=vi(By(e),n).some(s=>s.roundness?.type===bd.LEGACY);return bt("fieldset",{children:[Q("legend",{children:f("labels.edges")}),bt("div",{className:"buttonList",children:[Q(Zt,{group:"edges",options:[{value:"sharp",text:f("labels.sharp"),icon:u1},{value:"round",text:f("labels.round"),icon:h1}],value:mt(e,o,s=>a?null:s.roundness?"round":"sharp",s=>!xd(s)&&s.hasOwnProperty("roundness"),s=>s?null:n.currentItemRoundness),onChange:s=>t(s)}),r("togglePolygon")]})]})}}),_y=e=>({visibleSections:[{name:"default",options:[{value:null,text:f("labels.arrowhead_none"),keyBinding:"q",icon:Q(g1,{flip:e})},{value:"arrow",text:f("labels.arrowhead_arrow"),keyBinding:"w",icon:Q(f1,{flip:e})},{value:"triangle",text:f("labels.arrowhead_triangle"),icon:Q(E1,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:f("labels.arrowhead_triangle_outline"),icon:Q(b1,{flip:e}),keyBinding:"r"}]}],hiddenSections:[{name:"default",options:[{value:"circle",text:f("labels.arrowhead_circle"),keyBinding:"a",icon:Q(x1,{flip:e})},{value:"circle_outline",text:f("labels.arrowhead_circle_outline"),keyBinding:"s",icon:Q(y1,{flip:e})},{value:"diamond",text:f("labels.arrowhead_diamond"),icon:Q(w1,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:f("labels.arrowhead_diamond_outline"),icon:Q(v1,{flip:e}),keyBinding:"f"},{value:"bar",text:f("labels.arrowhead_bar"),keyBinding:"z",icon:Q(I1,{flip:e})}]},{name:f("labels.cardinality"),options:[{value:"cardinality_one",text:f("labels.arrowhead_cardinality_one"),icon:Q(T1,{flip:e}),keyBinding:"x"},{value:"cardinality_many",text:f("labels.arrowhead_cardinality_many"),icon:Q(S1,{flip:e}),keyBinding:"c"},{value:"cardinality_one_or_many",text:f("labels.arrowhead_cardinality_one_or_many"),icon:Q(C1,{flip:e}),keyBinding:"v"},{value:"cardinality_exactly_one",text:f("labels.arrowhead_cardinality_exactly_one"),icon:Q(P1,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_one",text:f("labels.arrowhead_cardinality_zero_or_one"),icon:Q(k1,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_many",text:f("labels.arrowhead_cardinality_zero_or_many"),icon:Q(M1,{flip:e}),keyBinding:null}]}]}),lne=O({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,n,t)=>(yd(t,"actionChangeArrowhead: value must be defined"),{elements:Ct(e,n,o=>{if(Mh(o)){let{position:r,type:i}=t;if(r==="start")return it(o,{startArrowhead:i});if(r==="end")return it(o,{endArrowhead:i})}return o}),appState:{...n,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=Kn().rtl,i=Ah(()=>_y(!r),[r]),a=Ah(()=>_y(!!r),[r]);return bt("fieldset",{children:[Q("legend",{children:f("labels.arrowheads")}),bt("div",{className:"iconSelectList buttonList",children:[Q(Sh,{visibleSections:i.visibleSections,hiddenSections:i.hiddenSections,label:"arrowhead_start",value:mt(e,o,s=>Mh(s)&&ms(s.type)?Dy(s.startArrowhead):n.currentItemStartArrowhead,!0,s=>s?null:n.currentItemStartArrowhead),onChange:s=>t({position:"start",type:s})}),Q(Sh,{visibleSections:a.visibleSections,hiddenSections:a.hiddenSections,label:"arrowhead_end",value:mt(e,o,s=>Mh(s)&&ms(s.type)?Dy(s.endArrowhead):n.currentItemEndArrowhead,!0,s=>s?null:n.currentItemEndArrowhead),onChange:s=>t({position:"end",type:s})})]})]})}}),C6=O({name:"changeArrowProperties",label:"Change arrow properties",trackEvent:!1,perform:(e,n,t,o)=>!1,PanelComponent:({elements:e,appState:n,updateData:t,app:o,renderAction:r})=>bt("div",{className:"selected-shape-actions",children:[r("changeArrowhead"),r("changeArrowType")]})}),cne=O({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,n,t,o)=>{let r=Ct(e,n,s=>{if(!xd(s))return s;let l=o.scene.getNonDeletedElementsMap(),c=zr.getPointAtIndexGlobalCoordinates(s,0,l),d=zr.getPointAtIndexGlobalCoordinates(s,-1,l),m=it(s,{x:t===cn.elbow?c[0]:s.x,y:t===cn.elbow?c[1]:s.y,roundness:t===cn.round?{type:bd.PROPORTIONAL_RADIUS}:null,elbowed:t===cn.elbow,angle:t===cn.elbow?0:s.angle,points:t===cn.elbow||s.elbowed?[zr.pointFromAbsoluteCoords({...s,x:c[0],y:c[1],angle:0},c,l),zr.pointFromAbsoluteCoords({...s,x:c[0],y:c[1],angle:0},d,l)]:s.points});if(Fy(m)){m.fixedSegments=null;let p=o.scene.getNonDeletedElementsMap();o.dismissLinearEditor();let u=zr.getPointAtIndexGlobalCoordinates(m,0,p),E=zr.getPointAtIndexGlobalCoordinates(m,-1,p),g=m.startBinding&&p.get(m.startBinding.elementId),b=m.endBinding&&p.get(m.endBinding.elementId),y=g&&m.startBinding?{...m.startBinding,...Ay(m,g,"start",p,n.isBindingEnabled)}:null,w=b&&m.endBinding?{...m.endBinding,...Ay(m,b,"end",p,n.isBindingEnabled)}:null;m={...m,startBinding:y,endBinding:w,...c6(m,p,{points:[u,E].map(x=>H4(x[0]-m.x,x[1]-m.y)),startBinding:y,endBinding:w,fixedSegments:null})}}else{let p=o.scene.getNonDeletedElementsMap();if(m.startBinding){let u=p.get(m.startBinding.elementId);u&&My(m,u,n.bindMode==="inside"?"inside":"orbit","start",o.scene)}if(m.endBinding){let u=p.get(m.endBinding.elementId);u&&My(m,u,n.bindMode==="inside"?"inside":"orbit","end",o.scene)}}return m}),i={...n,currentItemArrowType:t},a=n.selectedLinearElement?.elementId;if(a){let s=r.find(l=>l.id===a);s&&(i.selectedLinearElement=new zr(s,Dh(e)))}return{elements:r,appState:i,captureUpdate:et.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>bt("fieldset",{children:[Q("legend",{children:f("labels.arrowtypes")}),Q("div",{className:"buttonList",children:Q(Zt,{group:"arrowtypes",options:[{value:cn.sharp,text:f("labels.arrowtype_sharp"),icon:Xo,testId:"sharp-arrow"},{value:cn.round,text:f("labels.arrowtype_round"),icon:$o,testId:"round-arrow"},{value:cn.elbow,text:f("labels.arrowtype_elbowed"),icon:Ko,testId:"elbow-arrow"}],value:mt(e,o,r=>xd(r)?r.elbowed?cn.elbow:r.roundness?cn.round:cn.sharp:null,r=>xd(r),r=>r?null:n.currentItemArrowType),onChange:r=>t(r)})})]})});import{DEFAULT_CANVAS_BACKGROUND_PICKS as _6,MAX_ZOOM as R6,MIN_ZOOM as N6,THEME as Gs,ZOOM_STEP as Hy,CODES as Hr,KEYS as Td}from"@excalidraw/common";import{getNonDeletedElements as Hs}from"@excalidraw/element";import{getCommonBounds as Us}from"@excalidraw/element";import{CaptureUpdateAction as $i}from"@excalidraw/element";import{useEffect as P6}from"react";import{jsx as M6}from"react/jsx-runtime";var Xi=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let n=document.createElement("div");return document.body.appendChild(n),n.classList.add("excalidraw-tooltip"),n},Nh=(e,n,t="bottom")=>{let o=e.getBoundingClientRect(),r=window.innerWidth,i=window.innerHeight,a=5,s=n.left+n.width/2-o.width/2;s<0?s=a:s+o.width>=r&&(s=r-o.width-a);let l;t==="bottom"?(l=n.top+n.height+a,l+o.height>=i&&(l=n.top-o.height-a)):(l=n.top-o.height-a,l<0&&(l=n.top+n.height+a)),Object.assign(e.style,{top:`${l}px`,left:`${s}px`})},k6=(e,n,t,o)=>{n.classList.add("excalidraw-tooltip--visible"),n.style.minWidth=o?"50ch":"10ch",n.style.maxWidth=o?"50ch":"15ch",n.textContent=t;let r=e.getBoundingClientRect();Nh(n,r)},pt=({children:e,label:n,long:t=!1,style:o,disabled:r})=>(P6(()=>()=>Xi().classList.remove("excalidraw-tooltip--visible"),[]),r?null:M6("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>k6(i.currentTarget,Xi(),n,t),onPointerLeave:()=>Xi().classList.remove("excalidraw-tooltip--visible"),style:o,children:e}));import{useEffect as zy,useRef as Gy,useState as A6}from"react";var D6=(e,n)=>typeof n=="function"?n(e):Array.isArray(n)?e:e[n],Bh=(e,n,t)=>{if(e?.isDestroyed)return;let o=e?.getAppState();if(!o){if(!t)return;console.warn("useAppStateValue: excalidrawAPI not defined yet for internal component while it should always be defined. Are you sure you're rendering inside of <Excalidraw/> component tree?"),o=Object.assign({width:0,height:0,offsetLeft:0,offsetTop:0},Ho())}return D6(o,n)};function Ki(e,n=!0){let t=Id(),[,o]=A6(0),r=Gy(null);return r.current||(r.current={selector:e,isInitialized:!!t,latestValue:Bh(t,e,n)}),r.current.selector=e,!r.current.isInitialized&&t&&!t.isDestroyed&&(r.current.isInitialized=!0,r.current.latestValue=Bh(t,e,n)),zy(()=>{let i=r.current;if(!(!t||t.isDestroyed||!i))return t.onStateChange(i.selector,a=>{i.latestValue=a,o(s=>s+1)})},[t]),r.current.latestValue}function L6(e,n){let t=Id(),o=Gy({selector:e,callback:n});o.current.selector=e,o.current.callback=n,zy(()=>{if(!(!t||t.isDestroyed))return o.current.callback(Bh(t,o.current.selector,!0),t.getAppState()),t.onStateChange(o.current.selector,(r,i)=>{o.current.callback(r,i)})},[t])}import{jsx as Md,jsxs as O6}from"react/jsx-runtime";var B6=O({name:"changeViewBackgroundColor",label:"labels.canvasBackground",trackEvent:!1,predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.changeViewBackgroundColor&&!n.viewModeEnabled,perform:(e,n,t)=>({appState:{...n,...t},captureUpdate:t?.viewBackgroundColor?$i.IMMEDIATELY:$i.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,appProps:o,data:r})=>Md(Ui,{palette:null,topPicks:_6,label:f("labels.canvasBackground"),type:"canvasBackground",color:n.viewBackgroundColor,onChange:i=>t({viewBackgroundColor:i}),"data-testid":"canvas-background-picker",elements:e,appState:n,updateData:t})}),Sd=O({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,navigation:!0,icon:Iu,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...ho({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:Yn(n.zoom.value+Hy)},n)},captureUpdate:$i.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=Ki(t=>t.zoom.value);return Md($,{type:"button",className:"zoom-in-button zoom-button",icon:Iu,title:`${f("buttons.zoomIn")} \u2014 ${N("CtrlOrCmd++")}`,"aria-label":f("buttons.zoomIn"),disabled:n>=R6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===Hr.EQUAL||e.code===Hr.NUM_ADD)&&(e[Td.CTRL_OR_CMD]||e.shiftKey)}),Cd=O({name:"zoomOut",label:"buttons.zoomOut",icon:Tu,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...ho({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:Yn(n.zoom.value-Hy)},n)},captureUpdate:$i.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=Ki(t=>t.zoom.value);return Md($,{type:"button",className:"zoom-out-button zoom-button",icon:Tu,title:`${f("buttons.zoomOut")} \u2014 ${N("CtrlOrCmd+-")}`,"aria-label":f("buttons.zoomOut"),disabled:n<=N6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===Hr.MINUS||e.code===Hr.NUM_SUBTRACT)&&(e[Td.CTRL_OR_CMD]||e.shiftKey)}),Pd=O({name:"resetZoom",label:"buttons.resetZoom",icon:Ox,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=n.scrollConstraints?.lockZoom?n.scrollConstraints.zoom:1;return{appState:{...n,...ho({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:Yn(r)},n)},captureUpdate:$i.EVENTUALLY}},PanelComponent:({updateData:e})=>{let n=Ki(t=>t.zoom.value);return Md(pt,{label:f("buttons.resetZoom"),style:{height:"100%"},children:O6($,{type:"button",className:"reset-zoom-button zoom-button",title:f("buttons.resetZoom"),"aria-label":f("buttons.resetZoom"),onClick:()=>{e(null)},children:[(n*100).toFixed(0),"%"]})})},keyTest:e=>(e.code===Hr.ZERO||e.code===Hr.NUM_ZERO)&&(e[Td.CTRL_OR_CMD]||e.shiftKey)}),Fh=e=>[e.x,e.y,e.x+e.width,e.y+e.height],Gne=O({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:Gc,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=o.scene.getSelectedElements(n),i=r.length?Us(Hs(r)):n.scrollConstraints?Fh(n.scrollConstraints):Us(Hs(e)),a=Mr({bounds:i,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...Vn(a.appState)}}},keyTest:void 0}),Hne=O({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:Gc,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=o.scene.getSelectedElements(n),i=r.length?Us(Hs(r)):n.scrollConstraints?Fh(n.scrollConstraints):Us(Hs(e)),a=Mr({bounds:i,appState:n,fit:"contain",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...Vn(a.appState)}}},keyTest:void 0}),F6=O({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:Gc,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=n.scrollConstraints?Fh(n.scrollConstraints):Us(Hs(e)),i=Mr({bounds:r,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...i,appState:{...i.appState,...Vn(i.appState)}}},keyTest:void 0}),kd=O({name:"toggleTheme",label:(e,n)=>n.theme===Gs.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:(e,n)=>e.theme===Gs.LIGHT?ys:ws,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=t||(n.theme===Gs.LIGHT?Gs.DARK:Gs.LIGHT);return o.props.onThemeChange?(o.props.onThemeChange(r),!1):{appState:{...n,theme:r},captureUpdate:$i.EVENTUALLY}},keyTest:e=>!e[Td.CTRL_OR_CMD]&&e.altKey&&e.shiftKey&&e.code===Hr.D,predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.toggleTheme});import{pointFrom as K6}from"@excalidraw/math";import{bindOrUnbindBindingElement as Jy}from"@excalidraw/element/binding";import{isValidPolygon as Qy,newElementWith as Gh}from"@excalidraw/element";import{LinearElementEditor as Ks}from"@excalidraw/element/linearElementEditor";import{isBindingElement as Hh,isFreeDrawElement as ew,isLinearElement as tw,isLineElement as Bd}from"@excalidraw/element";import{KEYS as Fd,arrayToMap as $6,invariant as nw,shouldRotateWithDiscreteAngle as Z6,updateActiveTool as ow}from"@excalidraw/common";import{isPathALoop as j6}from"@excalidraw/element";import{isInvisiblySmallElement as Uh}from"@excalidraw/element";import{CaptureUpdateAction as Wh}from"@excalidraw/element";import U6 from"clsx";import{useEffect as W6,useState as V6}from"react";import{KEYS as dn,capitalizeString as Ur}from"@excalidraw/common";import{useEffect as z6,useState as G6}from"react";import Uy from"clsx";import{capitalizeString as Ad}from"@excalidraw/common";import{Popover as Oh}from"radix-ui";import{jsx as Dd,jsxs as H6}from"react/jsx-runtime";var Zi=({app:e,options:n,activeTool:t,defaultOption:o,"data-testid":r,onToolChange:i,displayedOption:a})=>{let[s,l]=G6(!1),c=t.type,d=a.type===c,m=16,{container:p}=Re();return!n.some(u=>u.type===c)&&s&&l(!1),z6(()=>{let u=e.onPointerDownEmitter.on(()=>{l(!1)});return()=>u?.()},[e]),H6(Oh.Root,{open:s,children:[Dd(Oh.Trigger,{asChild:!0,children:Dd($,{className:Uy({fillable:a.fillable}),type:"toggle",icon:a.icon,checked:d,disabled:n.every(u=>qe(e,u.type)),title:Ad(a.title),"aria-label":Ad(a.title),"data-testid":r,onSelect:()=>{l(u=>!u),i(o)}})}),Dd(Oh.Content,{className:"tool-popover-content",sideOffset:m,collisionBoundary:p??void 0,children:n.map(({type:u,icon:E,title:g,fillable:b})=>Dd($,{className:Uy({fillable:b}),type:"toggle",icon:E,checked:c===u,disabled:qe(e,u),title:Ad(u),"aria-label":Ad(u),"data-testid":`toolbar-${u}`,onSelect:()=>{e.state.activeTool.type!==u&&(Be("toolbar",u,"ui"),e.setActiveTool({type:u}),i?.(u))}},u))})]})};import{jsx as zh}from"react/jsx-runtime";var Y6=e=>e,Ye=Y6({hand:{icon:H1,letterKey:dn.H,toggle:!0},selection:{icon:Lc,letterKey:dn.V,fillable:!0},rectangle:{icon:Mi,letterKey:dn.R,fillable:!0},diamond:{icon:Ai,letterKey:dn.D,fillable:!0},ellipse:{icon:Di,letterKey:dn.O,fillable:!0},arrow:{icon:_c,letterKey:dn.A,fillable:!0},line:{icon:Wo,letterKey:dn.L,fillable:!0},freedraw:{icon:$n,letterKey:dn.P},text:{icon:Pn,letterKey:dn.T},image:{icon:_r},eraser:{icon:Rc,letterKey:dn.E,toggle:!0},frame:{icon:jn,letterKey:dn.F},autoshape:{icon:Br,letterKey:dn.X,fillable:!1},embeddable:{icon:Vo},laser:{icon:qn},bucketfill:{icon:Zn},lasso:{icon:ki,fillable:!1}});var ji=["autoshape","rectangle","diamond","ellipse","arrow","line"],qi=Object.keys(Ye).filter(e=>Ye[e].toggle),Ld=e=>{let{letterKey:n,shiftKey:t}=Ye[e];if(!n)return n;let o=Ur(typeof n=="string"?n:n[0]);return t?N(`Shift+${o}`):o},Ji=e=>Ld(e),X6=e=>{let n=Ld(e);return n?.length===1?n:void 0},Wy=(e,n,t=!1)=>{let o=e.toLowerCase();for(let r of Object.keys(Ye)){let{letterKey:i,shiftKey:a}=Ye[r];if(t===!!a&&i&&(typeof i=="string"?i===o:i.includes(o)))return r==="selection"?n.state.preferredSelectionTool.type:r}return null},qe=(e,n)=>e.props.activeTool!=null&&e.props.activeTool.type!==n,Ht=(e,n)=>{let t=Ye[e],o=n?.shortcutType??e,r=({app:i,activeTool:a,hideKeyBinding:s,hideShortcut:l})=>{let c=Ur(f(`toolBar.${e}`)),d=l?null:Ji(o);return zh($,{className:U6({fillable:t.fillable}),type:"toggle",icon:t.icon,checked:a.type===e,disabled:qe(i,e),title:d?`${c} \u2014 ${d}`:c,keyBindingLabel:s||l?void 0:X6(o),"aria-label":c,"aria-keyshortcuts":d??void 0,"data-testid":`toolbar-${e}`,onSelect:({pointerType:m})=>{if(!i.state.penDetected&&m==="pen"&&i.togglePenMode(!0),n?.onSelect){n.onSelect(i,{pointerType:m});return}i.state.activeTool.type!==e&&(Be("toolbar",e,"ui"),i.setActiveTool({type:e}))}})};return r.displayName=`${Ur(e)}IconButton`,r},_d=Ht("hand"),Vy=Ht("rectangle"),Yy=Ht("diamond"),Xy=Ht("ellipse"),Ky=Ht("arrow"),$y=Ht("line"),Ws=Ht("freedraw"),Vs=Ht("text"),Ys=Ht("image"),Xs=Ht("eraser"),Zy=Ht("frame"),goe=Ht("autoshape"),jy=Ht("selection",{onSelect:(e,{pointerType:n})=>{if(e.state.activeTool.type==="selection"&&n!==null){e.setActiveTool({type:"lasso"});return}e.state.activeTool.type!=="selection"&&(Be("toolbar","selection","ui"),e.setActiveTool({type:"selection"}))}}),qy=Ht("lasso",{shortcutType:"selection"}),Rd=({app:e,activeTool:n,setAppState:t})=>{let o=[{type:"selection",icon:Ye.selection.icon,fillable:Ye.selection.fillable,title:Ur(f("toolBar.selection"))},{type:"lasso",icon:Ye.lasso.icon,fillable:Ye.lasso.fillable,title:Ur(f("toolBar.lasso"))}],r=o.find(i=>i.type===e.state.preferredSelectionTool.type)||o[0];return zh(Zi,{app:e,options:o,activeTool:n,defaultOption:e.state.preferredSelectionTool.type,"data-testid":"toolbar-selection",onToolChange:i=>{(i==="selection"||i==="lasso")&&(e.setActiveTool({type:i}),t({preferredSelectionTool:{type:i,initialized:!0}}))},displayedOption:r})},Nd=({app:e,activeTool:n})=>{let t=[{type:"freedraw",icon:Ye.freedraw.icon,fillable:Ye.freedraw.fillable,title:Ur(f("toolBar.freedraw"))},{type:"autoshape",icon:Ye.autoshape.icon,fillable:Ye.autoshape.fillable,title:Ur(f("toolBar.autoshape"))}],[o,r]=V6(n.type==="autoshape"?"autoshape":"freedraw");W6(()=>{(n.type==="freedraw"||n.type==="autoshape")&&r(n.type)},[n.type]);let i=t.find(a=>a.type===o)||t[0];return zh(Zi,{app:e,options:t,activeTool:n,defaultOption:o,"data-testid":"toolbar-freedraw",onToolChange:a=>{(a==="freedraw"||a==="autoshape")&&(r(a),e.setActiveTool({type:a}))},displayedOption:i})};import{jsx as q6}from"react/jsx-runtime";var ut=O({name:"finalize",label:"",trackEvent:!1,perform:(e,n,t,o)=>{let r=!0,i=e,{focusContainer:a,scene:s}=o,l=s.getNonDeletedElementsMap(),c=n.activeTool.type==="autoshape";if(t&&n.selectedLinearElement){let{event:b,sceneCoords:y}=t,w=Ks.getElement(n.selectedLinearElement.elementId,l);nw(w,"Arrow element should exist if selectedLinearElement is set"),nw(y,"sceneCoords should be defined if actionFinalize is called with event");let x=Ks.handlePointerUp(b,n.selectedLinearElement,n,o.scene);if(Hh(w)&&!n.selectedLinearElement.segmentMidPointHoveredCoords){let I=!!n.newElement,T=I||!n.selectedLinearElement.selectedPointsIndices?[w.points.length-1]:n.selectedLinearElement.selectedPointsIndices,C=Z6(b),P=b[Fd.CTRL_OR_CMD]?null:o.getEffectiveGridSize(),A=T.reduce((D,_)=>(D.set(_,{point:C?w.points[_]:Ks.createPointAt(w,l,y.x-x.pointerOffset.x,y.y-x.pointerOffset.y,P)}),D),new Map)??new Map;Jy(w,A,y.x,y.y,s,n,{newArrow:I,altKey:b.altKey,angleLocked:C,gridSize:o.getEffectiveGridSize()})}else Bd(w)&&n.selectedLinearElement?.isEditing&&!n.newElement&&!Qy(w.points)&&s.mutateElement(w,{polygon:!1});if(x!==n.selectedLinearElement){w&&Uh(w)&&(i=i.map(T=>T.id===w.id?Gh(T,{isDeleted:!0}):T));let I=n.activeTool?.locked;return{elements:w.points.length<2||Uh(w)?e.map(T=>T.id===w.id?Gh(T,{isDeleted:!0}):T):i,appState:{...n,cursorButton:"up",selectedElementIds:c?{}:n.selectedElementIds,selectedLinearElement:I||c?null:{...x,selectedPointsIndices:null,isEditing:!1,initialState:{...x.initialState,lastClickedPoint:-1},pointerOffset:{x:0,y:0}},selectionElement:null,suggestedBinding:null,hoveredArrowTextAnchor:null,newElement:null,multiElement:null},captureUpdate:Wh.IMMEDIATELY}}}window.document.activeElement instanceof HTMLElement&&a();let d=o.drawShape.hasPendingGesture();(d||c)&&(o.drawShape.finalize(),d&&(i=o.scene.getElementsIncludingDeleted()));let m=null;if(n.multiElement)m=n.multiElement;else if(!c&&!d&&(n.newElement?.type==="freedraw"||Hh(n.newElement)))m=n.newElement;else if(Object.keys(n.selectedElementIds).length===1){let b=l.get(Object.keys(n.selectedElementIds)[0]);b&&(m=b)}if(m){if(n.selectedLinearElement&&n.multiElement&&m.type!=="freedraw"&&n.lastPointerDownWith!=="touch"){let{points:b}=m,{lastCommittedPoint:y}=n.selectedLinearElement;if((!y||b[b.length-1]!==y)&&(r=!1,s.mutateElement(m,{points:m.points.slice(0,-1)}),Hh(m)&&m.endBinding&&m.points.length>1)){let w=!!n.newElement,x=new Map([[m.points.length-1,{point:m.points[m.points.length-1],isDragging:!1}]]),I=Ks.getPointAtIndexGlobalCoordinates(m,-1,l);Jy(m,x,I[0],I[1],s,n,{newArrow:w})}}if(m&&Uh(m)&&(i=i.map(b=>b.id===m?.id?Gh(b,{isDeleted:!0}):b)),tw(m)||ew(m)){if(j6(m.points,n.zoom.value)&&(Bd(m)||ew(m))){let y=m.points,w=y[0],x=y.map((I,T)=>T===y.length-1?K6(w[0],w[1]):I);Bd(m)?s.mutateElement(m,{points:x,polygon:!0}):s.mutateElement(m,{points:x})}Bd(m)&&!Qy(m.points)&&s.mutateElement(m,{polygon:!1})}}let p;qi.includes(n.activeTool.type)?p=ow(n,{...n.activeTool.lastActiveTool||{type:o.state.preferredSelectionTool.type},lastActiveTool:null}):p=ow(n,{type:o.state.preferredSelectionTool.type});let u=o.isToolLocked(),E=n.activeTool.type==="autoshape"||(u||n.activeTool.type==="freedraw")&&!!m;E||o.cursor.applyForTool(p);let g=m&&tw(m)?new Ks(m,$6(i)):n.selectedLinearElement;return g=g&&{...g,isEditing:n.newElement?!1:g.isEditing,initialState:{...g.initialState,lastClickedPoint:-1,origin:null}},{elements:i,appState:{...n,cursorButton:"up",activeTool:E?n.activeTool:p,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null,selectedElementIds:c?{}:m&&!u&&n.activeTool.type!=="freedraw"?{...n.selectedElementIds,[m.id]:!0}:n.selectedElementIds,selectedLinearElement:c?null:g},captureUpdate:r?Wh.IMMEDIATELY:Wh.NEVER}},keyTest:(e,n)=>e.key===Fd.ESCAPE&&n.selectedLinearElement?.isEditing||(e.key===Fd.ESCAPE||e.key===Fd.ENTER)&&n.multiElement!==null,PanelComponent:({appState:e,updateData:n,data:t})=>q6($,{type:"button",icon:Zx,title:f("buttons.done"),"aria-label":f("buttons.done"),onClick:n,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import{getElementsInGroup as aw,isSomeElementSelected as J6,makeNextSelectedElementIds as Q6,selectGroupsForSelectedElements as eD}from"@excalidraw/element";import{CaptureUpdateAction as rw}from"@excalidraw/element";import{KEYS as tD,isWritableElement as nD,updateActiveTool as iw}from"@excalidraw/common";var oD=(e,n)=>qi.includes(e.activeTool.type)?iw(e,{...e.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveTool:null}):iw(e,{type:n.state.preferredSelectionTool.type}),rD=(e,n,t)=>{if(!e.editingGroupId)return null;let o=n.scene.getNonDeletedElements(),r=n.scene.getSelectedElements({selectedElementIds:t,elements:o}),i=r.length?r:aw(o,e.editingGroupId);for(let a of i){let s=a.groupIds.indexOf(e.editingGroupId);if(s!==-1&&a.groupIds[s+1])return a.groupIds[s+1]}return null},iD=O({name:"deselect",label:"",trackEvent:!1,perform:(e,n,t,o)=>{let r=oD(n,o);if(o.cursor.applyForTool(r),n.editingGroupId){let i=o.scene.getNonDeletedElements(),a=Object.keys(n.selectedElementIds).length>0?n.selectedElementIds:aw(i,n.editingGroupId).reduce((s,l)=>(s[l.id]=!0,s),{});return{appState:{...n,...eD({editingGroupId:rD(n,o,a),selectedElementIds:a},i,n,o),activeEmbeddable:null,activeTool:r,selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null},captureUpdate:rw.IMMEDIATELY}}return{appState:{...n,activeEmbeddable:null,activeTool:r,editingGroupId:null,selectedElementIds:Q6({},n),selectedGroupIds:{},selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null},captureUpdate:rw.IMMEDIATELY}},keyTest:(e,n,t,o)=>e.key!==tD.ESCAPE||nD(e.target)?!1:!n.newElement&&n.multiElement===null&&!n.selectedLinearElement?.isEditing&&(n.activeEmbeddable!==null||n.activeTool.type!==o.state.preferredSelectionTool.type||!!n.editingGroupId||!!n.selectedLinearElement||J6(o.scene.getNonDeletedElements(),n))});import{KEYS as Xd,THEME as qs}from"@excalidraw/common";import{CaptureUpdateAction as Mn}from"@excalidraw/element";import aD from"clsx";import{jsx as sw,jsxs as sD}from"react/jsx-runtime";var Vh=({children:e,checked:n,onChange:t,className:o})=>sD("div",{className:aD("Checkbox",o,{"is-checked":n}),onClick:r=>{t(!n,r),r.currentTarget.querySelector(".Checkbox-box").focus()},children:[sw("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":n,children:Nc}),sw("div",{className:"Checkbox-label",children:e})]});import{THEME as $s}from"@excalidraw/common";import{jsx as Zs}from"react/jsx-runtime";var cw=e=>{let n=e.title||(e.value===$s.DARK?f("buttons.lightMode"):f("buttons.darkMode"));return Zs($,{type:"icon",icon:e.value===$s.LIGHT?lw.MOON:lw.SUN,title:n,"aria-label":n,onClick:()=>e.onChange(e.value===$s.DARK?$s.LIGHT:$s.DARK),"data-testid":"toggle-dark-mode"})},lw={SUN:Zs("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Zs("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:Zs("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Zs("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 lD}from"react";import{focusNearestParent as cD,KEYS as dD}from"@excalidraw/common";import{jsx as dw,jsxs as mD}from"react/jsx-runtime";var mw=e=>{let{id:n}=Re(),[t,o]=lD(e.value),r=a=>{e.ignoreFocus||cD(a.target);let s=a.target.value;s!==e.value&&e.onChange(s)},i=a=>{if(a.key===dD.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return mD("div",{className:"ProjectName",children:[dw("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),dw("input",{type:"text",className:"TextInput",onBlur:r,onKeyDown:i,id:`${n}-filename`,value:t,onChange:a=>o(a.target.value)})]})};import{useCallback as pD,useEffect as uD,useRef as hD}from"react";import{jsx as Od,jsxs as bD}from"react/jsx-runtime";var gD=5e3,fD=({progress:e})=>Od("div",{className:"Toast__progress-bar",children:Od("div",{className:"Toast__progress-bar-fill",style:{width:`${Math.min(5,Math.round(e*100))}%`}})}),ED=({message:e,onClose:n,closable:t=!1,duration:o=gD,style:r})=>{let i=hD(0),a=o!==1/0,s=pD(()=>{a&&(i.current=window.setTimeout(()=>n(),o))},[n,o,a]);return uD(()=>{if(a)return s(),()=>clearTimeout(i.current)},[s,e,o,a]),bD("div",{className:"Toast",role:"status",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?s:void 0,style:r,children:[Od("div",{className:"Toast__message",children:e}),t&&Od($,{icon:rn,"aria-label":"close",type:"icon",onClick:n,className:"close"})]})},zd=Object.assign(ED,{ProgressBar:fD});import{DEFAULT_EXPORT_PADDING as BD,DEFAULT_FILENAME as FD,IMAGE_MIME_TYPES as Ew,isFirefox as OD,MIME_TYPES as zD,cloneJSON as GD,SVG_DOCUMENT_PREAMBLE as HD,arrayToMap as UD}from"@excalidraw/common";import{getNonDeletedElements as WD}from"@excalidraw/element";import{isFrameLikeElement as VD}from"@excalidraw/element";import{getElementsOverlappingFrame as YD}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as xD,EXPORT_DATA_TYPES as js,MIME_TYPES as ht,arrayToMap as yD,isMemberOf as wD,isPromiseLike as vD,EVENT as Gd}from"@excalidraw/common";import{mutateElement as ID}from"@excalidraw/element";import{deepCopyElement as TD}from"@excalidraw/element";import{isFrameLikeElement as SD,isInitializedImageElement as CD}from"@excalidraw/element";import{getContainingFrame as pw}from"@excalidraw/element";var _re="clipboard"in navigator&&"readText"in navigator.clipboard,Hd="clipboard"in navigator&&"writeText"in navigator.clipboard,or="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,PD=e=>!!([js.excalidraw,js.excalidrawClipboard,js.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),uw=({types:e,files:n})=>{!e&&!n&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent(Gd.PASTE,{clipboardData:new DataTransfer});if(e)for(let[o,r]of Object.entries(e)){if(typeof r!="string"){n=n||[],n.push(r);continue}try{if(t.clipboardData?.items.add(r,o),t.clipboardData?.getData(o)!==r)throw new Error(`Failed to set "${o}" as clipboardData item`)}catch(i){throw new Error(i.message)}}if(n){let o=-1;for(let r of n){o++;try{if(t.clipboardData?.items.add(r),t.clipboardData?.files[o]!==r)throw new Error(`Failed to set file "${r.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return t},kD=({elements:e,files:n})=>{let t=yD(e),o=new Set(e.filter(s=>SD(s))),r=!1,i=e.reduce((s,l)=>(CD(l)&&(r=!0,n&&n[l.fileId]&&(s[l.fileId]=n[l.fileId])),s),{});r&&!n&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:js.excalidrawClipboard,elements:e.map(s=>{if(pw(s,t)&&!o.has(pw(s,t))){let l=TD(s);return ID(l,t,{frameId:null}),l}return s}),files:n?i:void 0};return JSON.stringify(a)},Ud=async(e,n,t)=>{let o=kD({elements:e,files:n});await vo({[ht.excalidrawClipboard]:o,[ht.text]:o},t)};function hw(e){let n=[];for(let t of e.childNodes)if(t.nodeType===3){let o=t.textContent?.trim();o&&n.push({type:"text",value:o})}else if(t instanceof HTMLImageElement){let o=t.getAttribute("src");o&&o.startsWith("http")&&n.push({type:"imageUrl",value:o})}else n=n.concat(hw(t));return n}var MD=e=>{let n=e.value;try{let t=new DOMParser().parseFromString(n,ht.html),o=hw(t.body);if(o.length)return{type:"mixedContent",value:o}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},gw=async()=>{let e={},n;try{n=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 o=await navigator.clipboard?.readText();if(o)return{[ht.text]:o}}}catch(o){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${o.message}). Failling back to navigator.clipboard.read()`);else{if(o.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${o.message}`),e;throw o}}throw t}for(let t of n)for(let o of t.types)if(wD(xD,o))try{if(o===ht.text||o===ht.html)e[o]=await(await t.getType(o)).text();else if(hx(o)){let r=await t.getType(o),i=wx(r,o,void 0);e[o]=i}else throw new bu(`Unsupported clipboard type: ${o}`)}catch(r){console.warn(r instanceof bu?r.message:`Cannot retrieve ${o} from clipboardItem: ${r.message}`)}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},AD=async(e,n=!1)=>{try{let t=e.findByType(ht.html),o=!n&&t&&MD(t);return o?o.value.every(r=>r.type==="text")?{type:"text",value:e.getData(ht.text)??o.value.map(r=>r.value).join(`
2
- `).trim()}:o:{type:"text",value:(e.getData(ht.text)||"").trim()}}catch{return{type:"text",value:""}}},DD=function(e){return this.find(n=>n.type===e)||null},LD=function(e){return this.find(t=>t.type===e)?.value??null},_D=function(){return this.filter(e=>e.kind==="file")},Yh=e=>{let n=Xh(e)?e.clipboardData:e.dataTransfer,t=Array.from(n?.types??[]),o=Array.from(new Set([...t.filter(i=>i!=="Files"),ht.text,ht.html,"text/uri-list","public.url","public.plain-text","text/x-moz-url"])),r={};for(let i of o)try{let a=n?.getData(i);a&&(r[i]=a)}catch{}return{items:Array.from(n?.items??[]).map(i=>({kind:i.kind,type:i.type})),files:Array.from(n?.files??[]).map(i=>({name:i.name,type:i.type,size:i.size,lastModified:i.lastModified})),types:t,data:r}},RD=e=>e.map(n=>n.kind==="string"?{kind:n.kind,type:n.type,value:n.value}:{kind:n.kind,type:n.type,file:{name:n.file.name,type:n.file.type,size:n.file.size,lastModified:n.file.lastModified}}),Wd=(e,n,t)=>{let o=[],r=[],i=[],a=(u,E)=>{let g=E?.trim();g&&!u.includes(g)&&u.push(g)},s=(u,E)=>{E.split(/\r?\n/).map(g=>g.trim()).filter(g=>g&&!g.startsWith("#")).forEach(g=>a(u,g))};e.forEach(u=>{if(u.kind==="string")if(u.type===ht.html)try{let E=new DOMParser().parseFromString(u.value,ht.html);for(let g of Array.from(E.body.querySelectorAll("img")))a(o,g.getAttribute("src")),a(i,g.getAttribute("alt"))}catch{}else u.type===ht.text?a(r,u.value):u.type==="text/uri-list"&&s(r,u.value)});let l=[...o,...r.filter(u=>!o.includes(u))],c=Array.from({length:n},()=>({})),d={...t??{items:[],files:[],types:[],data:{}},parsedItems:RD(e)};c.forEach((u,E)=>{let g=l[E],b=i[E];g&&(u.src=g),b&&(u.alt=b),u.rawDragData=d});let m=l.slice(c.length),p=c[0];return p&&m.length>0&&m.forEach((u,E)=>{p[`additionalUrl${E+1}`]=u}),c},fw=e=>{let n;Xh(e)?n=e.clipboardData?.items:n=e.dataTransfer?.items;let t=new Set;for(let o of Array.from(n||[]))t.has(o.type)||t.add(o.type);return t},Wr=async e=>{let n;Xh(e)?n=e.clipboardData?.items:n=e.dataTransfer?.items;let t=(await Promise.all(Array.from(n||[]).map(async o=>{if(o.kind==="file"){let r=o.getAsFile();if(r){let i=await yx(o);return r=await Lr(r),{type:r.type,kind:"file",file:r,fileHandle:i}}}else if(o.kind==="string"){let{type:r}=o,i;return"clipboardData"in e&&e.clipboardData?i=e.clipboardData?.getData(r):i=await new Promise(a=>{o.getAsString(s=>a(s))}),{type:r,kind:"string",value:i}}return null}))).filter(o=>o!=null);return Object.assign(t,{findByType:DD,getData:LD,getFiles:_D})},Vd=async(e,n=!1)=>{let t=await AD(e,n);if(t.type==="mixedContent")return{mixedContent:t.value};try{let o=JSON.parse(t.value),r=o.type===js.excalidrawClipboardWithAPI;if(PD(o))return{elements:o.elements,files:o.files,text:n?JSON.stringify(o.elements,null,2):void 0,programmaticAPI:r}}catch{}return{text:t.value}},Yd=async e=>{try{await navigator.clipboard.write([new ClipboardItem({[ht.png]:e})])}catch(n){if(vD(e))await navigator.clipboard.write([new ClipboardItem({[ht.png]:await e})]);else throw n}},vo=async(e,n)=>{e=e||"";let t=Object.entries(typeof e=="string"?{[ht.text]:e}:e);try{if(n){for(let[r,i]of t)if(n.clipboardData?.setData(r,i),n.clipboardData?.getData(r)!==i)throw new Error("Failed to setData on clipboardEvent");return}}catch(r){console.error(r)}let o=t.find(([r])=>r===ht.text);if(Hd&&o)try{await navigator.clipboard.writeText(o[1]);return}catch(r){console.error(r)}if(o&&!ND(o[1]))throw new Error("Error copying to clipboard.")},ND=e=>{e||(e=" ");let n=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[n?"right":"left"]="-9999px";let o=window.pageYOffset||document.documentElement.scrollTop;t.style.top=`${o}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},Xh=e=>e.type===Gd.PASTE||e.type===Gd.COPY||e.type===Gd.CUT;var Vr=(e,{selectedElementIds:n},t)=>{let o=WD(e),r=UD(o),i=t&&De(o,{selectedElementIds:n}),a=null,s=i?ce(o,{selectedElementIds:n},{includeBoundTextElement:!0}):o;if(i){let l=s[0];s.length===1&&VD(l)?(a=l,s=YD(o,l,r)):s.length>1&&(s=ce(o,{selectedElementIds:n},{includeBoundTextElement:!0,includeElementsInFrames:!0}))}return{exportingFrame:a,exportedElements:GD(s)}},Yr=async(e,n,t,o,{exportBackground:r,exportPadding:i=BD,viewBackgroundColor:a,name:s=t.name||FD,fileHandle:l=null,exportingFrame:c=null})=>{if(n.length===0)throw new Error(f("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let m=Ar(n,{exportBackground:r,exportWithDarkMode:t.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:t.exportScale,exportEmbedScene:t.exportEmbedScene&&e==="svg"},o,{exportingFrame:c});if(e==="svg")return xu(m.then(p=>new Blob([HD+p.outerHTML],{type:zD.svg})),{description:"Export to SVG",name:s,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[Ew.svg],fileHandle:l});if(e==="clipboard-svg"){let p=await m.then(u=>u.outerHTML);try{await vo(p)}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return}}let d=Cc(n,t,o,{exportBackground:r,viewBackgroundColor:a,exportPadding:i,exportingFrame:c});if(e==="png"){let m=Es(d);return t.exportEmbedScene&&(m=m.then(p=>import("./data/image-6PNCNKLO.js").then(({encodePngMetadata:u})=>u({blob:p,metadata:us(n,t,o,"local")})))),xu(m,{description:"Export to PNG",name:s,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[Ew.png],fileHandle:l})}else if(e==="clipboard")try{let m=Es(d);await Yd(m)}catch(m){throw console.warn(m),m.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):OD&&m.name==="TypeError"?new Error(`${f("alerts.couldNotCopyToClipboard")}
1
+ import{$ as Mi,A as cx,B as Su,C as xs,D as kc,E as Cu,F as dx,G as mx,H as Mc,I as ys,J as Ac,K as Dc,L as ws,M as px,N as ux,O as hx,P as Lc,Q as Rr,R as v3,S as Nr,T as ki,V as gx,X as fx,Y as Ex,Z as _c,_ as bx,a as wu,aa as vs,b as Vn,ba as Is,c as fo,ca as xx,d as _r,da as Rc,e as Si,ea as yx,f as Yn,fa as wx,g as ox,ga as vx,h as Le,ha as Pu,i as rx,ia as Ix,j as ce,ja as Tx,k as Ci,ka as Sx,l as Yo,la as Br,m as ix,n as vu,o as ax,p as Es,q as sx,r as Pc,s as lx,t as Iu,u as Tu,v as Eo,w as Xo,x as rn,y as bs,z as Pi}from"./chunk-N4AOPKJK.js";import{a as S}from"./chunk-PLDSWNV5.js";import{G as yu}from"./chunk-DARW3V66.js";import{c as nx}from"./chunk-5XKZK2GL.js";import{b as tx,c as w3,d as v}from"./chunk-SRAX5OIU.js";import mK,{useCallback as pK,useContext as uK,useEffect as hK,useRef as gK,useState as fK}from"react";import{applyDarkModeFilter as DVe,DEFAULT_IMAGE_OPTIONS as Sn,DEFAULT_UI_OPTIONS as y3,getStrokeWidthByKey as LVe,isShallowEqual as EK}from"@excalidraw/common";import jk from"clsx";import YV from"lodash.throttle";import In,{useContext as Go}from"react";import{flushSync as Ot}from"react-dom";import XV from"roughjs/bin/rough";import{nanoid as KV}from"nanoid";import{clamp as cc,pointFrom as oe,pointDistance as so,vector as qk,pointRotateRads as gb,vectorFromPoint as fb,vectorSubtract as Jk,vectorDot as Qk,vectorNormalize as eM}from"@excalidraw/math";import{CODES as kr,shouldResizeFromCenter as tM,shouldMaintainAspectRatio as dc,shouldRotateWithDiscreteAngle as nM,isArrowKey as Eb,KEYS as $,APP_NAME as $V,CURSOR_TYPE as Ae,DEFAULT_STROKE_STREAMLINE as ZV,DEFAULT_STROKE_STREAMLINE_PRECISE as jV,DEFAULT_TRANSFORM_HANDLE_SPACING as qV,DEFAULT_VERTICAL_ALIGN as oM,DRAGGING_THRESHOLD as rM,ELEMENT_SHIFT_TRANSLATE_AMOUNT as JV,ELEMENT_TRANSLATE_AMOUNT as iM,EVENT as Q,FRAME_STYLE as No,IMAGE_MIME_TYPES as QV,IMAGE_RENDER_TIMEOUT as eY,LINE_CONFIRM_THRESHOLD as bb,MIME_TYPES as lo,MQ_RIGHT_SIDEBAR_MIN_WIDTH as tY,POINTER_BUTTON as Gn,ROUNDNESS as jp,SCROLL_TIMEOUT as nY,TAP_TWICE_TIMEOUT as aM,TEXT_TO_CENTER_SNAP_THRESHOLD as oY,THEME as mc,TOUCH_CTX_MENU_TIMEOUT as rY,VERTICAL_ALIGN as iY,YOUTUBE_STATES as qp,ZOOM_STEP as aY,MIN_ZOOM as sY,POINTER_EVENTS as cs,TOOL_TYPE as Hn,supportsResizeObserver as lY,DEFAULT_COLLISION_THRESHOLD as sM,DEFAULT_TEXT_ALIGN as cY,ARROW_TYPE as Mr,DEFAULT_REDUCED_GLOBAL_ALPHA as dY,isLocalLink as mY,normalizeLink as Jp,toValidURL as pY,getGridPoint as Mt,getLineHeight as lM,debounce as cM,distance as ds,getFontString as xb,getNearestScrollableContainer as uY,isInputLike as dM,isToolIcon as hY,isWritableElement as pc,sceneCoordsToViewportCoords as Qp,tupleToCoors as yb,viewportCoordsToSceneCoords as Me,wrapEvent as gY,updateObject as wb,updateActiveTool as nn,isTransparent as fY,muteFSAbortError as EY,isTestEnv as QM,isDevEnv as e3,updateStable as uc,addEventListener as ve,normalizeEOL as bY,getDateTime as mM,isShallowEqual as pM,arrayToMap as hc,applyDarkModeFilter as xY,AppEventBus as yY,randomInteger as wY,CLASSES as vb,Emitter as co,MINIMUM_ARROW_SIZE as vY,DOUBLE_TAP_POSITION_THRESHOLD as uM,BIND_MODE_TIMEOUT as IY,invariant as mo,getFeatureFlag as Bo,createUserAgentDescriptor as t3,getFormFactor as TY,deriveStylesPanelMode as mu,isIOS as SY,isBrave as CY,isSafari as PY,loadDesktopUIModePreference as kY,setDesktopUIMode as MY,isSelectionLikeTool as eu,oneOf as hM,getStrokeWidthByKey as AY}from"@excalidraw/common";import{getObservedAppState as DY,getCommonBounds as ms,getElementAbsoluteCoords as gM,bindOrUnbindBindingElements as fM,fixBindingsAfterDeletion as LY,getHoveredElementForBinding as Ar,isBindingEnabled as tu,updateBoundElements as nu,LinearElementEditor as fe,newElementWith as po,newFrameElement as _Y,newFreeDrawElement as RY,newEmbeddableElement as EM,newMagicFrameElement as NY,newIframeElement as BY,newArrowElement as FY,newElement as OY,newImageElement as zY,newLinearElement as GY,newTextElement as bM,refreshTextDimensions as HY,deepCopyElement as xM,duplicateElements as yM,hasBoundTextElement as wM,isArrowElement as gc,isBindingElement as uo,isBindingElementType as UY,isBoundToContainer as vM,isFrameLikeElement as Tt,isImageElement as Un,isEmbeddableElement as Fo,isInitializedImageElement as yi,isLinearElement as zt,isLinearElementType as WY,isUsingAdaptiveRadius as VY,isIframeElement as Ib,isIframeLikeElement as fc,isTextBindableContainer as IM,isElbowArrow as Xt,isBindableElement as Tb,isTextElement as Kt,getNormalizedDimensions as YY,isElementCompletelyInViewport as XY,isElementInViewport as TM,isInvisiblySmallElement as SM,generateThumbHash as KY,getCornerRadius as $Y,isPathALoop as CM,embeddableURLValidator as Sb,maybeParseEmbedSrc as ZY,getEmbedLink as ou,getInitializedImageElements as jY,normalizeSVG as PM,updateImageCache as Cb,getBoundTextElement as Pb,getContainerCenter as kb,getContainerElement as kM,isValidTextContainer as MM,redrawTextBoundingBox as qY,hasBoundingBox as JY,getCommonFrameId as AM,getFrameChildren as Mb,getFrameChildrenInsertionIndex as QY,isCursorInFrame as DM,addElementsToFrame as Ab,replaceAllElementsInFrame as eX,removeElementsFromFrame as tX,getElementsInResizingFrame as Db,getElementsInNewFrame as nX,getContainingFrame as Lb,elementOverlapsWithFrame as oX,updateFrameMembershipOfSelectedElements as LM,isElementInFrame as _M,getFrameLikeTitle as rX,filterElementsEligibleAsFrameChildren as iX,hitElementBoundText as aX,hitElementBoundingBoxOnly as sX,hitElementItself as Ec,getVisibleSceneBounds as lX,cropElement as cX,wrapText as dX,isElementLink as RM,isMeasureTextSupported as mX,normalizeText as pX,measureText as NM,getLineHeightInPx as BM,getApproxMinLineWidth as uX,getApproxMinLineHeight as hX,getMinTextElementWidth as gX,ShapeCache as wi,getRenderOpacity as fX,editGroupForSelectedElement as EX,getElementsInGroup as vi,getSelectedGroupIdForElement as bX,getSelectedGroupIds as xX,isElementInGroup as FM,isSelectedViaGroup as yX,selectGroupsForSelectedElements as Wn,syncInvalidIndices as n3,syncMovedIndices as OM,excludeElementsInFramesFromSelection as wX,getSelectionStateForElements as zM,makeNextSelectedElementIds as De,getResizeOffsetXY as vX,getResizeArrowDirection as IX,transformElements as TX,getCursorForResizingElement as GM,getElementWithTransformHandleType as HM,getTransformHandleTypeFromCoords as UM,dragNewElement as WM,dragSelectedElements as SX,getDragOffsetXY as CX,Scene as VM,Store as PX,CaptureUpdateAction as $t,hitElementBoundingBox as kX,isLineElement as _b,isSimpleArrow as Rb,StoreDelta as YM,positionElementsOnGrid as XM,calculateFixedPointForNonElbowArrowBinding as KM,bindOrUnbindBindingElement as MX,mutateElement as ru,getElementBounds as $M,doBoundsIntersect as AX,isPointInElement as ZM,maxBindingDistance_simple as jM,convertToExcalidrawElements as DX,getSnapOutlineMidPoint as Nb,handleFocusPointDrag as LX,handleFocusPointHover as _X,handleFocusPointPointerDown as RX,handleFocusPointPointerUp as NX,maybeHandleArrowPointlikeDrag as iu,getUncroppedWidthAndHeight as BX,getActiveTextElement as qM,isEligibleFrameChildType as FX,getBindingStrategyForDraggingBindingElementEndpoints as OX,isNonDeletedElement as au}from"@excalidraw/element";import{KEYS as ih,MOBILE_ACTION_BUTTON_BG as B3,updateActiveTool as F3}from"@excalidraw/common";import{getNonDeletedElements as ed}from"@excalidraw/element";import{fixBindingsAfterDeletion as O3}from"@excalidraw/element";import{LinearElementEditor as v0}from"@excalidraw/element/linearElementEditor";import{newElementWith as Qc}from"@excalidraw/element";import{getContainerElement as I0}from"@excalidraw/element";import{isBoundToContainer as qc,isElbowArrow as z3,isFrameLikeElement as G3}from"@excalidraw/element";import{getFrameChildren as H3}from"@excalidraw/element";import{getElementsInGroup as ah,selectGroupsForSelectedElements as U3}from"@excalidraw/element";import{CaptureUpdateAction as Jc}from"@excalidraw/element";import{isDevEnv as C3}from"@excalidraw/common";import{atom as Qe,createStore as I3}from"jotai";import{createIsolation as T3}from"jotai-scope";var Cx=T3();var{useAtom:He,useSetAtom:Px,useAtomValue:kx,useStore:IK}=Cx,Mx=Cx.Provider,Et=I3();var S3=tx({"./locales/ar-SA.json":()=>import("./locales/ar-SA-E6E2KRZ5.js"),"./locales/az-AZ.json":()=>import("./locales/az-AZ-RDMGQYMZ.js"),"./locales/bg-BG.json":()=>import("./locales/bg-BG-CHUVCTEA.js"),"./locales/bn-BD.json":()=>import("./locales/bn-BD-ZMOEPIQW.js"),"./locales/bn-IN.json":()=>import("./locales/bn-IN-OHZAWF5C.js"),"./locales/ca-ES.json":()=>import("./locales/ca-ES-K4A7PUP4.js"),"./locales/cs-CZ.json":()=>import("./locales/cs-CZ-RVP6YORC.js"),"./locales/da-DK.json":()=>import("./locales/da-DK-ENJX4GIQ.js"),"./locales/de-CH.json":()=>import("./locales/de-CH-VYBKDWRU.js"),"./locales/de-DE.json":()=>import("./locales/de-DE-6MCXRRVA.js"),"./locales/el-GR.json":()=>import("./locales/el-GR-WEDZAIPA.js"),"./locales/en.json":()=>import("./locales/en-RNZ7CUK6.js"),"./locales/es-ES.json":()=>import("./locales/es-ES-LLEALNRO.js"),"./locales/eu-ES.json":()=>import("./locales/eu-ES-M4Y34NOW.js"),"./locales/fa-IR.json":()=>import("./locales/fa-IR-XSMVGGRV.js"),"./locales/fi-FI.json":()=>import("./locales/fi-FI-K2D3DDUS.js"),"./locales/fr-FR.json":()=>import("./locales/fr-FR-EQKMVJSO.js"),"./locales/gl-ES.json":()=>import("./locales/gl-ES-RCPQTYJV.js"),"./locales/he-IL.json":()=>import("./locales/he-IL-RHAGKYKH.js"),"./locales/hi-IN.json":()=>import("./locales/hi-IN-3UDCLKHN.js"),"./locales/hu-HU.json":()=>import("./locales/hu-HU-T3REA7IL.js"),"./locales/id-ID.json":()=>import("./locales/id-ID-KW4N25IN.js"),"./locales/it-IT.json":()=>import("./locales/it-IT-LJVXK4LO.js"),"./locales/ja-JP.json":()=>import("./locales/ja-JP-GGGK3KPX.js"),"./locales/kaa.json":()=>import("./locales/kaa-TSEHAWJR.js"),"./locales/kab-KAB.json":()=>import("./locales/kab-KAB-IWXTEINV.js"),"./locales/kk-KZ.json":()=>import("./locales/kk-KZ-6GNYSAU7.js"),"./locales/km-KH.json":()=>import("./locales/km-KH-ILUXSOEW.js"),"./locales/ko-KR.json":()=>import("./locales/ko-KR-FJWHM3OT.js"),"./locales/ku-TR.json":()=>import("./locales/ku-TR-DRDDAECA.js"),"./locales/lt-LT.json":()=>import("./locales/lt-LT-IYFIPPJI.js"),"./locales/lv-LV.json":()=>import("./locales/lv-LV-7F754RSS.js"),"./locales/mr-IN.json":()=>import("./locales/mr-IN-BYRIZ3PC.js"),"./locales/my-MM.json":()=>import("./locales/my-MM-RBYJSIJ6.js"),"./locales/nb-NO.json":()=>import("./locales/nb-NO-EKTZIYSK.js"),"./locales/nl-NL.json":()=>import("./locales/nl-NL-UECYYIUK.js"),"./locales/nn-NO.json":()=>import("./locales/nn-NO-JPXGIDBA.js"),"./locales/oc-FR.json":()=>import("./locales/oc-FR-4RSIVDPZ.js"),"./locales/pa-IN.json":()=>import("./locales/pa-IN-GPHFXISR.js"),"./locales/percentages.json":()=>import("./locales/percentages-Q7USCRWZ.js"),"./locales/pl-PL.json":()=>import("./locales/pl-PL-HKHPAEVK.js"),"./locales/pt-BR.json":()=>import("./locales/pt-BR-UBWN6CKP.js"),"./locales/pt-PT.json":()=>import("./locales/pt-PT-XDY4S4SD.js"),"./locales/ro-RO.json":()=>import("./locales/ro-RO-2B3UXAQO.js"),"./locales/ru-RU.json":()=>import("./locales/ru-RU-EW52HAV3.js"),"./locales/si-LK.json":()=>import("./locales/si-LK-PIEHI4JX.js"),"./locales/sk-SK.json":()=>import("./locales/sk-SK-TZXYYIFD.js"),"./locales/sl-SI.json":()=>import("./locales/sl-SI-VUDQNDF3.js"),"./locales/sv-SE.json":()=>import("./locales/sv-SE-IJTJRA7S.js"),"./locales/ta-IN.json":()=>import("./locales/ta-IN-Q5PXZT3U.js"),"./locales/th-TH.json":()=>import("./locales/th-TH-HK66ZQXE.js"),"./locales/tr-TR.json":()=>import("./locales/tr-TR-CLYYPVPL.js"),"./locales/uk-UA.json":()=>import("./locales/uk-UA-YR4OMRYF.js"),"./locales/uz-UZ.json":()=>import("./locales/uz-UZ-CY4LSY5Y.js"),"./locales/vi-VN.json":()=>import("./locales/vi-VN-UDAEMEBG.js"),"./locales/zh-CN.json":()=>import("./locales/zh-CN-EGBL23FT.js"),"./locales/zh-HK.json":()=>import("./locales/zh-HK-ZOJEG32A.js"),"./locales/zh-TW.json":()=>import("./locales/zh-TW-TM5HZP7M.js")});var P3=85,Xn={code:"en",label:"English"},Di=[Xn,...[{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=>nx[e.code]>=P3).sort((e,n)=>e.label>n.label?1:-1)],Bc="__test__";C3()&&Di.unshift({code:Bc,label:"test language"},{code:`${Bc}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var Ai=Xn,Nc={},Fc=async e=>{if(Ai=e,document.documentElement.dir=Ai.rtl?"rtl":"ltr",document.documentElement.lang=Ai.code,e.code.startsWith(Bc))Nc={};else try{Nc=await S3(`./locales/${Ai.code}.json`)}catch(n){console.error(`Failed to load language ${e.code}:`,n.message),Nc=yu}Et.set(Dx,e.code)},Kn=()=>Ai,Ax=(e,n)=>{for(let t=0;t<n.length;++t){let o=n[t];if(e[o]===void 0)return;e=e[o]}if(typeof e=="string")return e},f=(e,n,t)=>{if(Ai.code.startsWith(Bc))return`\u202A[[${n?`${e}(${JSON.stringify(n).slice(1,-1)})`:e}]]\u202C`;let o=e.split("."),r=Ax(Nc,o)||Ax(yu,o)||t;if(r===void 0){let i=`Can't find translation for ${e}`;if(S.PROD)return console.warn(i),"";throw new Error(i)}if(n)for(let i in n)r=r.replace(`{{${i}}}`,String(n[i]));return r},Dx=Qe(Xn.code),_e=()=>{let e=kx(Dx);return{t:f,langCode:e}};import k3 from"clsx";import et from"react";import{THEME as M3}from"@excalidraw/common";import{Fragment as Te,jsx as h,jsxs as R}from"react/jsx-runtime";var Cn=e=>"var(--icon-fill-color)",Lx=e=>e===M3.LIGHT?"#fff":"#1e1e1e",A=(e,n=512)=>{let{width:t=512,height:o=t,mirror:r,style:i,...a}=typeof n=="number"?{width:n}:n;return h("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${t} ${o}`,className:k3({"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"},ae={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},Dt={width:40,height:20},OK=A(R("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),zK=A(R("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),_x=A("M320 112C434.9 112 528 205.1 528 320C528 434.9 434.9 528 320 528C205.1 528 112 434.9 112 320C112 205.1 205.1 112 320 112zM320 576C461.4 576 576 461.4 576 320C576 178.6 461.4 64 320 64C178.6 64 64 178.6 64 320C64 461.4 178.6 576 320 576zM288 248C288 234.7 277.3 224 264 224C250.7 224 240 234.7 240 248L240 392C240 405.3 250.7 416 264 416C277.3 416 288 405.3 288 392L288 248zM400 248C400 234.7 389.3 224 376 224C362.7 224 352 234.7 352 248L352 392C352 405.3 362.7 416 376 416C389.3 416 400 405.3 400 392L400 248z",640),Ts=A(R("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),Rx=A(R("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),Nx=A(R("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),ku=A(R("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),bo=A(R("g",{children:[h("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z",stroke:"currentColor",strokeWidth:"1.25"}),h("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:h("path",{stroke:"none",d:"M6.399 9.561V5.175c0-.93.401-1.823 1.116-2.48a3.981 3.981 0 0 1 2.693-1.028c1.01 0 1.98.37 2.694 1.027.715.658 1.116 1.55 1.116 2.481",fill:"#fff"})}),h("g",{mask:"url(#UnlockedIcon)",children:h("path",{stroke:"none",d:"M5.149 9.561v1.25h2.5v-1.25h-2.5Zm5.06-7.894V.417v1.25Zm2.559 3.508v1.25h2.5v-1.25h-2.5ZM7.648 8.51V5.175h-2.5V8.51h2.5Zm0-3.334c0-.564.243-1.128.713-1.561L6.668 1.775c-.959.883-1.52 2.104-1.52 3.4h2.5Zm.713-1.561a2.732 2.732 0 0 1 1.847-.697v-2.5c-1.31 0-2.585.478-3.54 1.358L8.36 3.614Zm1.847-.697c.71 0 1.374.26 1.847.697l1.694-1.839a5.231 5.231 0 0 0-3.54-1.358v2.5Zm1.847.697c.47.433.713.997.713 1.561h2.5c0-1.296-.56-2.517-1.52-3.4l-1.693 1.839Z",fill:"currentColor"})})]}),ae),Ko=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z"}),h("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),h("path",{d:"M6.667 8.333V5.417C6.667 3.806 8.159 2.5 10 2.5c1.841 0 3.333 1.306 3.333 2.917v2.916"})]}),ae),Bx=A(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}),Fx=A(R(Te,{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"}),Ox=A(R(Te,{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"}),zx=A(R(Te,{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"}),GK=A(h("g",{fill:"currentColor",children:h("path",{d:"M39.9 32.889a.326.326 0 0 0-.279-.056c-2.094-3.083-4.774-6-7.343-8.833l-.419-.472a.212.212 0 0 0-.056-.139.586.586 0 0 0-.167-.111l-.084-.083-.056-.056c-.084-.167-.28-.278-.475-.167-.782.39-1.507.973-2.206 1.528-.92.722-1.842 1.445-2.708 2.25a8.405 8.405 0 0 0-.977 1.028c-.14.194-.028.361.14.444-.615.611-1.23 1.223-1.843 1.861a.315.315 0 0 0-.084.223c0 .083.056.166.111.194l1.09.833v.028c1.535 1.528 4.244 3.611 7.12 5.861.418.334.865.667 1.284 1 .195.223.39.473.558.695.084.11.28.139.391.055.056.056.14.111.196.167a.398.398 0 0 0 .167.056.255.255 0 0 0 .224-.111.394.394 0 0 0 .055-.167c.029 0 .028.028.056.028a.318.318 0 0 0 .224-.084l5.082-5.528a.309.309 0 0 0 0-.444Zm-14.63-1.917a.485.485 0 0 0 .111.14c.586.5 1.2 1 1.843 1.555l-2.569-1.945-.251-.166c-.056-.028-.112-.084-.168-.111l-.195-.167.056-.056.055-.055.112-.111c.866-.861 2.346-2.306 3.1-3.028-.81.805-2.43 3.167-2.095 3.944Zm8.767 6.89-2.122-1.612a44.713 44.713 0 0 0-2.625-2.5c1.145.861 2.122 1.611 2.262 1.75 1.117.972 1.06.806 1.815 1.445l.921.666a1.06 1.06 0 0 1-.251.25Zm.558.416-.056-.028c.084-.055.168-.111.252-.194l-.196.222ZM1.089 5.75c.055.361.14.722.195 1.056.335 1.833.67 3.5 1.284 4.75l.252.944c.084.361.223.806.363.917 1.424 1.25 3.602 3.11 5.947 4.889a.295.295 0 0 0 .363 0s0 .027.028.027a.254.254 0 0 0 .196.084.318.318 0 0 0 .223-.084c2.988-3.305 5.221-6.027 6.813-8.305.112-.111.14-.278.14-.417.111-.111.195-.25.307-.333.111-.111.111-.306 0-.39l-.028-.027c0-.055-.028-.139-.084-.167-.698-.666-1.2-1.138-1.731-1.638-.922-.862-1.871-1.75-3.881-3.75l-.028-.028c-.028-.028-.056-.056-.112-.056-.558-.194-1.703-.389-3.127-.639C6.087 2.223 3.21 1.723.614.944c0 0-.168 0-.196.028l-.083.084c-.028.027-.056.055-.224.11h.056-.056c.028.167.028.278.084.473 0 .055.112.5.112.555l.782 3.556Zm15.496 3.278-.335-.334c.084.112.196.195.335.334Zm-3.546 4.666-.056.056c0-.028.028-.056.056-.056Zm-2.038-10c.168.167.866.834 1.033.973-.726-.334-2.54-1.167-3.379-1.445.838.167 1.983.334 2.346.472ZM1.424 2.306c.419.722.754 3.222 1.089 5.666-.196-.778-.335-1.555-.503-2.278-.251-1.277-.503-2.416-.838-3.416.056 0 .14 0 .252.028Zm-.168-.584c-.112 0-.223-.028-.307-.028 0-.027 0-.055-.028-.055.14 0 .223.028.335.083Zm-1.089.222c0-.027 0-.027 0 0ZM39.453 1.333c.028-.11-.558-.61-.363-.639.42-.027.42-.666 0-.666-.558.028-1.144.166-1.675.25-.977.194-1.982.389-2.96.61-2.205.473-4.383.973-6.561 1.557-.67.194-1.424.333-2.066.666-.224.111-.196.333-.084.472-.056.028-.084.028-.14.056-.195.028-.363.056-.558.083-.168.028-.252.167-.224.334 0 .027.028.083.028.11-1.173 1.556-2.485 3.195-3.909 4.945-1.396 1.611-2.876 3.306-4.356 5.056-4.719 5.5-10.052 11.75-15.943 17.25a.268.268 0 0 0 0 .389c.028.027.056.055.084.055-.084.084-.168.14-.252.222-.056.056-.084.111-.084.167a.605.605 0 0 0-.111.139c-.112.111-.112.305.028.389.111.11.307.11.39-.028.029-.028.029-.056.056-.056a.44.44 0 0 1 .615 0c.335.362.67.723.977 1.028l-.698-.583c-.112-.111-.307-.083-.39.028-.113.11-.085.305.027.389l7.427 6.194c.056.056.112.056.196.056s.14-.028.195-.084l.168-.166c.028.027.083.027.111.027.084 0 .14-.027.196-.083 10.052-10.055 18.15-17.639 27.42-24.417.083-.055.111-.166.111-.25.112 0 .196-.083.251-.194 1.704-5.194 2.039-9.806 2.15-12.083v-.028c0-.028.028-.056.028-.083.028-.056.028-.084.028-.084a1.626 1.626 0 0 0-.111-1.028ZM21.472 9.5c.446-.5.893-1.028 1.34-1.5-2.876 3.778-7.65 9.583-14.408 16.5 4.607-5.083 9.242-10.333 13.068-15ZM5.193 35.778h.084-.084Zm3.462 3.194c-.027-.028-.027-.028 0-.028v.028Zm4.16-3.583c.224-.25.448-.472.699-.722 0 0 0 .027.028.027-.252.223-.475.445-.726.695Zm1.146-1.111c.14-.14.279-.334.446-.5l.028-.028c1.648-1.694 3.351-3.389 5.082-5.111l.028-.028c.419-.333.921-.694 1.368-1.028a379.003 379.003 0 0 0-6.952 6.695ZM24.794 6.472c-.921 1.195-1.954 2.778-2.82 4.028-2.736 3.944-11.532 13.583-11.727 13.75a1976.983 1976.983 0 0 1-8.042 7.639l-.167.167c-.14-.167-.14-.417.028-.556C14.49 19.861 22.03 10.167 25.074 5.917c-.084.194-.14.36-.28.555Zm4.83 5.695c-1.116-.64-1.646-1.64-1.34-2.611l.084-.334c.028-.083.084-.194.14-.277.307-.5.754-.917 1.257-1.167.027 0 .055 0 .083-.028-.028-.056-.028-.139-.028-.222.028-.167.14-.278.335-.278.335 0 1.369.306 1.76.639.111.083.223.194.335.305.14.167.363.445.474.667.056.028.112.306.196.445.056.222.111.472.084.694-.028.028 0 .194-.028.194a2.668 2.668 0 0 1-.363 1.028c-.028.028-.028.056-.056.084l-.028.027c-.14.223-.335.417-.53.556-.643.444-1.369.583-2.095.389 0 0-.195-.084-.28-.111Zm8.154-.834a39.098 39.098 0 0 1-.893 3.167c0 .028-.028.083 0 .111-.056 0-.084.028-.14.056-2.206 1.61-4.356 3.305-6.506 5.028 1.843-1.64 3.686-3.306 5.613-4.945.558-.5.949-1.139 1.06-1.861l.28-1.667v-.055c.14-.334.67-.195.586.166Z",fill:"currentColor"})}),{width:40,height:40,fill:"none"}),Oc=A(R("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}),Li=A(R("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}),_i=A(R("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),Ri=A(R("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),Ni=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"})]}),H),zc=A(R("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),$o=A(h("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),ae),Gx=A(R("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),$n=A(R("g",{strokeWidth:"1.25",children:[h("path",{clipRule:"evenodd",d:"m7.643 15.69 7.774-7.773a2.357 2.357 0 1 0-3.334-3.334L4.31 12.357a3.333 3.333 0 0 0-.977 2.357v1.953h1.953c.884 0 1.732-.352 2.357-.977Z"}),h("path",{d:"m11.25 5.417 3.333 3.333"})]}),ae),Pn=A(R("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),Hx=A(R("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),Fr=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M12.5 6.667h.01"}),h("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z"}),h("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),h("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),ae),Gc=A(R("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),Mu=A(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),ae),Au=A(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),ae),Ux=A(R("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),Or=A(h("path",{strokeWidth:"1.25",d:"M3.333 5.833h13.334M8.333 9.167v5M11.667 9.167v5M4.167 5.833l.833 10c0 .92.746 1.667 1.667 1.667h6.666c.92 0 1.667-.746 1.667-1.667l.833-10M7.5 5.833v-2.5c0-.46.373-.833.833-.833h3.334c.46 0 .833.373.833.833v2.5"}),ae),Zo=A(R("g",{strokeWidth:"1.5",children:[h("polyline",{points:"12 16 18 10 12 4"}),h("polyline",{points:"8 4 2 10 8 16"})]}),ae),Ss=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M14.375 6.458H8.958a2.5 2.5 0 0 0-2.5 2.5v5.417a2.5 2.5 0 0 0 2.5 2.5h5.417a2.5 2.5 0 0 0 2.5-2.5V8.958a2.5 2.5 0 0 0-2.5-2.5Z"}),h("path",{clipRule:"evenodd",d:"M11.667 3.125c.517 0 .986.21 1.325.55.34.338.55.807.55 1.325v1.458H8.333c-.485 0-.927.185-1.26.487-.343.312-.57.75-.609 1.24l-.005 5.357H5a1.87 1.87 0 0 1-1.326-.55 1.87 1.87 0 0 1-.549-1.325V5c0-.518.21-.987.55-1.326.338-.34.807-.549 1.325-.549h6.667Z"})]}),ae),Cs=A(h("path",{clipRule:"evenodd",d:"M10 2.5h.328a6.25 6.25 0 0 0 6.6 10.372A7.5 7.5 0 1 1 10 2.493V2.5Z",stroke:"currentColor"}),ae),Ps=A(h("g",{stroke:"currentColor",strokeLinejoin:"round",children:h("path",{d:"M10 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM10 4.167V2.5M14.167 5.833l1.166-1.166M15.833 10H17.5M14.167 14.167l1.166 1.166M10 15.833V17.5M5.833 14.167l-1.166 1.166M5 10H3.333M5.833 5.833 4.667 4.667"})}),{...ae,strokeWidth:1.5}),Wx=A(R("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),ks=A(h("path",{strokeWidth:"1.25",d:"M3.333 14.167v1.666c0 .92.747 1.667 1.667 1.667h10c.92 0 1.667-.746 1.667-1.667v-1.666M5.833 9.167 10 13.333l4.167-4.166M10 3.333v10"}),ae),Bi=A(R("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),Vx=A(R("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),HK=A(h("path",{strokeWidth:"1.25",d:"M9.167 5.833H5.833c-1.254 0-2.5 1.282-2.5 2.5v5.834c0 1.283 1.252 2.5 2.5 2.5h5.834c1.251 0 2.5-1.25 2.5-2.5v-3.334M8.333 11.667l8.334-8.334M12.5 3.333h4.167V7.5"}),ae),Yx=A(h("path",{d:"M7.5 15.833c-3.583 1.167-3.583-2.083-5-2.5m10 4.167v-2.917c0-.833.083-1.166-.417-1.666 2.334-.25 4.584-1.167 4.584-5a3.833 3.833 0 0 0-1.084-2.667 3.5 3.5 0 0 0-.083-2.667s-.917-.25-2.917 1.084a10.25 10.25 0 0 0-5.166 0C5.417 2.333 4.5 2.583 4.5 2.583a3.5 3.5 0 0 0-.083 2.667 3.833 3.833 0 0 0-1.084 2.667c0 3.833 2.25 4.75 4.584 5-.5.5-.5 1-.417 1.666V17.5",strokeWidth:"1.25"}),ae),Xx=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M7.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM12.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM6.25 6.25c2.917-.833 4.583-.833 7.5 0M5.833 13.75c2.917.833 5.417.833 8.334 0"}),h("path",{d:"M12.917 14.167c0 .833 1.25 2.5 1.666 2.5 1.25 0 2.361-1.39 2.917-2.5.556-1.39.417-4.861-1.25-9.584-1.214-.846-2.5-1.116-3.75-1.25l-.833 2.084M7.083 14.167c0 .833-1.13 2.5-1.526 2.5-1.191 0-2.249-1.39-2.778-2.5-.529-1.39-.397-4.861 1.19-9.584 1.157-.846 2.318-1.116 3.531-1.25l.833 2.084"})]}),ae),Kx=A(R("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),Hc=A(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),Ms=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M8.333 11.667a2.917 2.917 0 0 0 4.167 0l3.333-3.334a2.946 2.946 0 1 0-4.166-4.166l-.417.416"}),h("path",{d:"M11.667 8.333a2.917 2.917 0 0 0-4.167 0l-3.333 3.334a2.946 2.946 0 0 0 4.166 4.166l.417-.416"})]}),ae),$x=A("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}),Zx=A("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}),Uc=A(h("path",{d:"m9.257 6.351.183.183H15.819c.34 0 .727.182 1.051.506.323.323.505.708.505 1.05v5.819c0 .316-.183.7-.52 1.035-.337.338-.723.522-1.037.522H4.182c-.352 0-.74-.181-1.058-.5-.318-.318-.499-.705-.499-1.057V5.182c0-.351.181-.736.5-1.054.32-.321.71-.503 1.057-.503H6.53l2.726 2.726Z",strokeWidth:"1.25"}),ae),UK=A("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}),WK=A("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"),Du=["M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z","M13.737 9.737c2.299 -2.3 3.23 -5.095 2.081 -6.245c-1.15 -1.15 -3.945 -.217 -6.244 2.082c-2.3 2.299 -3.231 5.095 -2.082 6.244c1.15 1.15 3.946 .218 6.245 -2.081z","M7.492 11.818c.362 .362 .768 .676 1.208 .934l6.895 4.047c1.078 .557 2.255 -.075 3.692 -1.512c1.437 -1.437 2.07 -2.614 1.512 -3.692c-.372 -.718 -1.72 -3.017 -4.047 -6.895a6.015 6.015 0 0 0 -.934 -1.208"],Zn=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Du.map(e=>h("path",{d:e},e))]}),H),jx=A(h("g",{strokeWidth:1.5,children:h("path",{d:"M6 18l12 -12"})}),H),qx=A(R("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),Jx=A("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}),VK=A("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}),YK=A("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}),Qx=A("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"),XK=A("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"),Lu=A(h("path",{d:"M7.5 10.833 4.167 7.5 7.5 4.167M4.167 7.5h9.166a3.333 3.333 0 0 1 0 6.667H12.5",strokeWidth:"1.25"}),ae),_u=A(h("path",{d:"M12.5 10.833 15.833 7.5 12.5 4.167M15.833 7.5H6.667a3.333 3.333 0 1 0 0 6.667H7.5",strokeWidth:"1.25"}),ae),e1=A("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}),t1=A(h("path",{d:"M5 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 7.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 17.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM7.25 8.917l5.5-2.834M7.25 11.083l5.5 2.834",strokeWidth:"1.5"}),ae),KK=A("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"),$K=A("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}),ZK=A(R("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),jK=A(R(Te,{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}),qK=A(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}),n1=R("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"})]}),o1=R("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"})]}),Ru=A(o1,H),Nu=A(o1,{...H,style:{transform:"rotate(180deg)"}}),Bu=A(n1,H),Fu=A(n1,{...H,style:{transform:"rotate(180deg)"}}),Ou=A(R(Te,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v7.083c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V8.125c0-.92-.746-1.667-1.666-1.667ZM6.875 6.458h-.417c-.92 0-1.666.747-1.666 1.667v3.75c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667v-3.75c0-.92-.747-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),zu=A(R(Te,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M6.875 3.125h-.417c-.92 0-1.666.746-1.666 1.667v7.083c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667V4.792c0-.92-.747-1.667-1.667-1.667ZM13.542 5.817h-.417c-.92 0-1.667.747-1.667 1.667v4.391c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V7.484c0-.92-.746-1.667-1.666-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),Gu=A(R(Te,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M15.208 4.792H8.125c-.92 0-1.667.746-1.667 1.666v.417c0 .92.747 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM12.516 11.458H8.125c-.92 0-1.667.746-1.667 1.667v.417c0 .92.747 1.666 1.667 1.666h4.391c.92 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),Hu=A(R(Te,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M11.875 4.792H4.792c-.92 0-1.667.746-1.667 1.666v.417c0 .92.746 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM11.683 11.458H7.292c-.92 0-1.667.746-1.667 1.667v.417c0 .92.746 1.666 1.667 1.666h4.39c.921 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.666-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),r1=A(R(Te,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M14.375 10.208v-.416c0-.92-.746-1.667-1.667-1.667H7.292c-.92 0-1.667.746-1.667 1.667v.416c0 .92.746 1.667 1.667 1.667h5.416c.92 0 1.667-.746 1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),i1=A(R(Te,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M10.208 5.625h-.416c-.92 0-1.667.746-1.667 1.667v5.416c0 .92.746 1.667 1.667 1.667h.416c.92 0 1.667-.746 1.667-1.667V7.292c0-.92-.746-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),Uu=A(R("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),h("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M6.875 4.792h-.417c-.92 0-1.666.746-1.666 1.666v7.084c0 .92.746 1.666 1.666 1.666h.417c.92 0 1.667-.746 1.667-1.666V6.458c0-.92-.747-1.666-1.667-1.666ZM13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v3.75c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667v-3.75c0-.92-.746-1.667-1.666-1.667Z"})]}),ae),Wu=A(R("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),h("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M4.792 13.125v.417c0 .92.746 1.666 1.666 1.666h7.084c.92 0 1.666-.746 1.666-1.666v-.417c0-.92-.746-1.667-1.666-1.667H6.458c-.92 0-1.666.746-1.666 1.667ZM6.458 6.458v.417c0 .92.747 1.667 1.667 1.667h3.75c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666h-3.75c-.92 0-1.667.746-1.667 1.666Z"})]}),ae),Wc=A(R("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),JK=A("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"),QK=A("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"),an=A(R(Te,{children:[h("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M15 5 5 15M5 5l10 10"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),e$=A("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}),t$=A("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}),n$=A("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}),Vu=et.memo(({theme:e})=>A(R(Te,{children:[h("path",{d:"M25 26H111V111H25",fill:Cn(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:Cn(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:Cn(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:Cn(e),strokeWidth:"2"}),R("g",{fill:Lx(e),stroke:Cn(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})),Yu=et.memo(({theme:e})=>A(R(Te,{children:[h("path",{d:"M25 26H111V111H25",fill:Cn(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:Cn(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:Cn(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:Cn(e),strokeWidth:"2"}),R("g",{fill:Lx(e),stroke:Cn(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})),a1=A(h("g",{strokeWidth:1.25,children:h("path",{d:"M5.879 2.625h8.242a3.27 3.27 0 0 1 3.254 3.254v8.242a3.27 3.27 0 0 1-3.254 3.254H5.88a3.27 3.27 0 0 1-3.254-3.254V5.88A3.27 3.27 0 0 1 5.88 2.626l-.001-.001ZM4.518 16.118l7.608-12.83m.198 13.934 5.051-9.897M2.778 9.675l9.348-6.387m-7.608 12.83 12.857-8.793"})}),ae),s1=A(R(Te,{children:[h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.25"})}),h("g",{mask:"url(#FillHachureIcon)",children:h("path",{d:"M2.258 15.156 15.156 2.258M7.324 20.222 20.222 7.325m-20.444 5.35L12.675-.222m-8.157 18.34L17.416 5.22",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})]}),ae),l1=A(R(Te,{children:[R("g",{clipPath:"url(#a)",children:[h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:h("path",{d:"M2.426 15.044 15.044 2.426M7.383 20 20 7.383M0 12.617 12.617 0m-7.98 17.941L17.256 5.324m-2.211 12.25L2.426 4.956M20 12.617 7.383 0m5.234 20L0 7.383m17.941 7.98L5.324 2.745",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("g",{mask:"url(#FillCrossHatchIcon)",children:h("path",{d:"M14.121 2H5.88A3.879 3.879 0 0 0 2 5.879v8.242A3.879 3.879 0 0 0 5.879 18h8.242A3.879 3.879 0 0 0 18 14.121V5.88A3.879 3.879 0 0 0 14.121 2Z",fill:"currentColor"})})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),c1=A(R(Te,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z",stroke:"currentColor",strokeWidth:"1.25"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...ae,fill:"currentColor"}),Xu=A(h(Te,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),ae),d1=A(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),ae),m1=A(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),ae),o$=et.memo(({theme:e})=>A(h("path",{d:"M6 10H34",stroke:Cn(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),p1=A(R("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),u1=A(R("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),h1=A(h("path",{d:"M2.5 12.038c1.655-.885 5.9-3.292 8.568-4.354 2.668-1.063.101 2.821 1.32 3.104 1.218.283 5.112-1.814 5.112-1.814",strokeWidth:"1.25"}),ae),g1=A(h("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43",strokeWidth:"1.25"}),ae),f1=A(h("path",{d:"M2.5 11.936c1.737-.879 8.627-5.346 10.42-5.268 1.795.078-.418 5.138.345 5.736.763.598 3.53-1.789 4.235-2.147M2.929 9.788c1.164-.519 5.47-3.28 6.987-3.114 1.519.165 1 3.827 2.121 4.109 1.122.281 3.839-2.016 4.606-2.42",strokeWidth:"1.25"}),ae),Ku=A(R("g",{children:[h("path",{d:"M4 12 C 5 8, 6 8, 8 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8 12 C 9 16, 10 16, 12 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M12 12 C 14 8, 15 8, 16 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M16 12 C 17 16, 18 16, 19 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]}),H),$u=A(R("g",{children:[h("path",{d:"M4 12 C 5 8, 6 8, 8 12",fill:"none",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8 12 C 9 16, 10 16, 12 12",fill:"none",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M12 12 C 14 8, 15 8, 16 12",fill:"none",strokeWidth:"2.75",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M16 12 C 17 16, 18 16, 19 12",fill:"none",strokeWidth:"3.25",strokeLinecap:"round",strokeLinejoin:"round"})]}),H),E1=A(R("svg",{strokeWidth:"1.5",children:[h("path",{d:"M3.33334 9.99998V6.66665C3.33334 6.04326 3.33403 4.9332 3.33539 3.33646C4.95233 3.33436 6.06276 3.33331 6.66668 3.33331H10"}),h("path",{d:"M13.3333 3.33331V3.34331"}),h("path",{d:"M16.6667 3.33331V3.34331"}),h("path",{d:"M16.6667 6.66669V6.67669"}),h("path",{d:"M16.6667 10V10.01"}),h("path",{d:"M3.33334 13.3333V13.3433"}),h("path",{d:"M16.6667 13.3333V13.3433"}),h("path",{d:"M3.33334 16.6667V16.6767"}),h("path",{d:"M6.66666 16.6667V16.6767"}),h("path",{d:"M10 16.6667V16.6767"}),h("path",{d:"M13.3333 16.6667V16.6767"}),h("path",{d:"M16.6667 16.6667V16.6767"})]}),ae),b1=A(R("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),x1=et.memo(({flip:e=!1})=>A(R("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"})]}),Dt)),y1=et.memo(({flip:e=!1})=>A(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"})}),Dt)),w1=et.memo(({flip:e=!1})=>A(R("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"})]}),Dt)),v1=et.memo(({flip:e=!1})=>A(R("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"})]}),Dt)),I1=et.memo(({flip:e=!1})=>A(R("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"})]}),Dt)),T1=et.memo(({flip:e=!1})=>A(R("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"})]}),Dt)),S1=et.memo(({flip:e=!1})=>A(R("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"})]}),Dt)),C1=et.memo(({flip:e=!1})=>A(R("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"})]}),Dt)),P1=et.memo(({flip:e=!1})=>A(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"})}),Dt)),k1=et.memo(({flip:e=!1})=>A(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"})}),Dt)),M1=et.memo(({flip:e=!1})=>A(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"})}),Dt)),A1=et.memo(({flip:e=!1})=>A(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"})}),Dt)),D1=et.memo(({flip:e=!1})=>A(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"})}),Dt)),L1=et.memo(({flip:e=!1})=>A(R("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"})]}),Dt)),_1=et.memo(({flip:e=!1})=>A(R("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"})]}),Dt)),R1=A(R(Te,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M14.167 6.667a3.333 3.333 0 0 0-3.334-3.334H9.167a3.333 3.333 0 0 0 0 6.667h1.666a3.333 3.333 0 0 1 0 6.667H9.167a3.333 3.333 0 0 1-3.334-3.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),N1=A(R(Te,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),B1=A(R(Te,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),F1=A(h(Te,{children:h("path",{d:"m1.667 3.333 6.666 13.334M8.333 3.333 1.667 16.667M11.667 3.333v13.334h6.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),ae),zr=A(R("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),O1=A(h(Te,{children:R("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),As=A(h(Te,{children:h("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M5.833 16.667v-10a3.333 3.333 0 0 1 3.334-3.334h1.666a3.333 3.333 0 0 1 3.334 3.334v10M5.833 10.833h8.334"})})}),ae),A3=A(R("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),Vc=A3,z1=A(R("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),G1=A(R("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),H1=A(R("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),U1=et.memo(({theme:e})=>A(R("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)),W1=et.memo(({theme:e})=>A(R("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)),V1=et.memo(({theme:e})=>A(R("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)),Yc=A(R("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),r$=A(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}),i$=A(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"})),Y1=A(R("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),Zu=A(R(Te,{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),X1=A(R(Te,{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),K1=A(R("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),$1=A(R(Te,{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),a$=A(R(Te,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),H),s$=A(R(Te,{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),Z1=A(R(Te,{children:[h("path",{d:"M7 5v14"}),h("path",{d:"M19 6l-9 6l9 6z"})]}),H),j1=A(R(Te,{children:[h("path",{d:"M17 5v14"}),h("path",{d:"M5 6l9 6l-9 6z"})]}),H),q1=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 6h16a1 1 0 0 1 1 1v10a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1 -1v-10a1 1 0 0 1 1 -1z"}),h("path",{d:"M7 6v12"}),h("path",{d:"M17 6v12"}),h("path",{d:"M3 10h4"}),h("path",{d:"M3 14h4"}),h("path",{d:"M17 10h4"}),h("path",{d:"M17 14h4"})]}),H),J1=A(R(Te,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),H),Q1=A(R(Te,{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),ju=["M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z","M11 7l6 6"],Fi=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),ju.map(e=>h("path",{d:e},e))]}),H),jn=A(R("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),l$=A(R("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),c$=A(R("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),d$=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M4.16602 10H15.8327"}),h("path",{d:"M12.5 13.3333L15.8333 10"}),h("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),ae),Gr=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 9.5a6.5 6.5 0 1 0 13 0a6.5 6.5 0 1 0 -13 0"}),h("path",{d:"M10 12a2 2 0 0 1 2 -2h7a2 2 0 0 1 2 2v7a2 2 0 0 1 -2 2h-7a2 2 0 0 1 -2 -2l0 -7"})]}),H),qn=A(R("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),m$=A(R("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),p$=A(R("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),u$=A(R("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),h$=A(R("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),Hr=A(R("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),e0=A(R("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),g$=A(R("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),f$=A(R("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),Jn=A(R("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),E$=A(R("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),b$=A(R("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),t0=A(R("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),n0=A(R("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),x$=A(R("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),o0=A(R("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),r0=A(R("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),i0=A(R("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),a0=A(R("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),qu=A(R("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),Xc=A(R("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),s0=A(R("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),l0=A(R("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),jo=A(R("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),y$=A(R("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),c0=A(R("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}),w$=A(R("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),v$=A(R("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=A(R("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),m0=A(R("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),qo=A(R("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),Jo=A(R("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),Qo=A(R("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),H),Kc=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),H),p0=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),H),u0=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),H),Ju=A(R("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),h0=A(R("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),Qu=A(R("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),eh=A(R("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),I$=A(R("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),th=A(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"})})),g0=A(R("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),f0=A(R("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),nh=A(R("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),T$=A(R("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),S$=A(R("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),C$=A(R("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),P$=A(R("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),$c=h("div",{style:{width:"1rem",height:"1rem"}}),E0=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("polyline",{points:"6 9 12 15 18 9"})]}),H),b0=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("polyline",{points:"9 6 15 12 9 18"})]}),H),x0=A(R("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 y0 from"clsx";import rh,{useEffect as _3,useRef as w0,useState as R3}from"react";import{isPromiseLike as N3}from"@excalidraw/common";import D3 from"react";import{jsx as oh}from"react/jsx-runtime";var L3=({size:e="1em",circleWidth:n=8,synchronized:t=!1,className:o=""})=>{let i=-(D3.useRef(Date.now()).current%1600);return oh("div",{className:`Spinner ${o}`,children:oh("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:oh("circle",{cx:"50",cy:"50",r:50-n/2,strokeWidth:n,fill:"none",strokeMiterlimit:"10"})})})},xo=L3;import{jsx as Ds,jsxs as Zc}from"react/jsx-runtime";var Z=rh.forwardRef(({size:e="medium",visible:n=!0,className:t="",...o},r)=>{let i=rh.useRef(null);rh.useImperativeHandle(r,()=>i.current);let a=`ToolIcon_size_${e}`,[s,l]=R3(!1),c=w0(!0),d=async p=>{let u="onClick"in o&&o.onClick?.(p);if(N3(u))try{l(!0),await u}catch(E){if(E instanceof Pc)console.warn(E);else throw E}finally{c.current&&l(!1)}};_3(()=>(c.current=!0,()=>{c.current=!1}),[]);let m=w0(null);return o.type==="button"||o.type==="icon"?Zc("button",{className:y0("ToolIcon_type_button",a,t,n&&!o.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!o.hidden,"ToolIcon--plain":o.type==="icon"}),style:o.style,"data-testid":o["data-testid"],hidden:o.hidden,title:o.title,"aria-label":o["aria-label"],type:"button",onClick:d,ref:i,disabled:s||o.isLoading||!!o.disabled,children:[(o.icon||o.label)&&Zc("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!o.disabled,children:[o.icon||o.label,o.keyBindingLabel&&Ds("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel}),o.isLoading&&Ds(xo,{})]}),o.showAriaLabel&&Zc("div",{className:"ToolIcon__label",children:[o["aria-label"]," ",s&&Ds(xo,{})]}),o.children]}):Ds("button",{className:y0("ToolIcon","ToolIcon_type_toggle",a,t,{"ToolIcon--checked":o.checked}),type:"button",style:o.style,title:o.title,"aria-label":o["aria-label"],"aria-keyshortcuts":o["aria-keyshortcuts"],"aria-pressed":o.checked,"data-testid":o["data-testid"],disabled:!!o.disabled,"aria-disabled":!!o.disabled,onPointerDown:p=>{m.current=p.pointerType||null},onPointerUp:()=>{requestAnimationFrame(()=>{m.current=null})},onClick:()=>{o.onSelect?.({pointerType:m.current})},ref:i,children:Zc("div",{className:"ToolIcon__icon",children:[o.icon,o.keyBindingLabel&&Ds("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel})]})})});Z.displayName="IconButton";var jc=[],O=e=>(jc=jc.concat(e),e);import{jsx as V3}from"react/jsx-runtime";var W3=(e,n,t)=>{let o=new Set(ce(e.filter(d=>G3(d)),n).map(d=>d.id)),r={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let d of o){let m=H3(e,d);for(let p of m)if(!a.has(p.id)){if(qc(p)){let u=I0(p,i);u&&(r[u.id]=!0)}else r[p.id]=!0;a.add(p.id)}}let s=!0,l=e.map(d=>{if(n.selectedElementIds[d.id]){let m=qc(d)?I0(d,i):null;return d.frameId&&o.has(d.frameId)?(s=!1,r[d.id]=!0,d):m?.frameId&&o.has(m?.frameId)?d:(d.boundElements&&d.boundElements.forEach(p=>{let u=t.scene.getNonDeletedElementsMap().get(p.id);u&&z3(u)&&t.scene.mutateElement(u,{startBinding:d.id===u.startBinding?.elementId?null:u.startBinding,endBinding:d.id===u.endBinding?.elementId?null:u.endBinding})}),Qc(d,{isDeleted:!0}))}return d.frameId&&o.has(d.frameId)?(s=!1,qc(d)||(r[d.id]=!0),Qc(d,{frameId:null})):qc(d)&&n.selectedElementIds[d.containerId]?Qc(d,{isDeleted:!0}):d}),c=n.editingGroupId;if(s&&n.editingGroupId){let d=ah(l,n.editingGroupId).filter(m=>!m.isDeleted);if(d.length>1)d[0]&&(r[d[0].id]=!0);else{c=null,d[0]&&(r[d[0].id]=!0);let m=d[0];if(m){let p=m.groupIds.findIndex(E=>E===n.editingGroupId),u=m.groupIds[p+1];if(u){let E=ah(l,u).filter(g=>!g.isDeleted);E.length>1&&(c=u,E.forEach(g=>{r[g.id]=!0}))}}}}return{elements:l,appState:{...n,...U3({selectedElementIds:r,editingGroupId:c},ed(l),n,null)}}},T0=(e,n)=>{if(e.editingGroupId){let t=ah(ed(n),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},Ls=O({name:"deleteSelectedElements",label:"labels.delete",icon:Or,trackEvent:{category:"element",action:"delete"},perform:(e,n,t,o)=>{if(n.selectedLinearElement?.isEditing){let{elementId:a,selectedPointsIndices:s}=n.selectedLinearElement,l=o.scene.getNonDeletedElementsMap(),c=v0.getElement(a,l);if(!c||s==null)return!1;if(s.length>=c.points.length){let d=e.map(p=>p.id===c.id?Qc(p,{isDeleted:!0}):p),m=T0(n,d);return{elements:d,appState:{...m,selectedLinearElement:null},captureUpdate:Jc.IMMEDIATELY}}return v0.deletePoints(c,o,s),{elements:e,appState:{...n,selectedLinearElement:{...n.selectedLinearElement,selectedPointsIndices:s?.[0]>0?[s[0]-1]:[0]}},captureUpdate:Jc.IMMEDIATELY}}let{elements:r,appState:i}=W3(e,n,o);return O3(r,r.filter(a=>a.isDeleted)),i=T0(i,r),{elements:r,appState:{...i,activeTool:F3(n,{type:o.state.preferredSelectionTool.type}),multiElement:null,newElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Le(ed(e),n)?Jc.IMMEDIATELY:Jc.EVENTUALLY}},keyTest:(e,n,t)=>(e.key===ih.BACKSPACE||e.key===ih.DELETE)&&!e[ih.CTRL_OR_CMD],PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=ct()==="mobile";return V3(Z,{type:"button",icon:Or,title:f("labels.delete"),"aria-label":f("labels.delete"),onClick:()=>t(null),disabled:!Le(ed(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?B3:{}}})}});import{KEYS as Oi,CODES as zi,isDarwin as td}from"@excalidraw/common";import{moveOneLeft as Y3,moveOneRight as X3,moveAllLeft as K3,moveAllRight as $3}from"@excalidraw/element";import{CaptureUpdateAction as nd}from"@excalidraw/element";import{isDarwin as S0}from"@excalidraw/common";var N=e=>e.replace(/\b(Opt(?:ion)?|Alt)\b/i,S0?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,S0?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 od}from"react/jsx-runtime";var sh=O({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:Nu,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Y3(e,n,o.scene),appState:n,captureUpdate:nd.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Oi.CTRL_OR_CMD]&&!e.shiftKey&&e.code===zi.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>od("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendBackward")} \u2014 ${N("CtrlOrCmd+[")}`,children:Nu})}),lh=O({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:Ru,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:X3(e,n,o.scene),appState:n,captureUpdate:nd.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Oi.CTRL_OR_CMD]&&!e.shiftKey&&e.code===zi.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>od("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.bringForward")} \u2014 ${N("CtrlOrCmd+]")}`,children:Ru})}),ch=O({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:Fu,trackEvent:{category:"element"},perform:(e,n)=>({elements:K3(e,n),appState:n,captureUpdate:nd.IMMEDIATELY}),keyTest:e=>td?e[Oi.CTRL_OR_CMD]&&e.altKey&&e.code===zi.BRACKET_LEFT:e[Oi.CTRL_OR_CMD]&&e.shiftKey&&e.code===zi.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>od("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendToBack")} \u2014 ${td?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")}`,children:Fu})}),dh=O({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:Bu,trackEvent:{category:"element"},perform:(e,n)=>({elements:$3(e,n),appState:n,captureUpdate:nd.IMMEDIATELY}),keyTest:e=>td?e[Oi.CTRL_OR_CMD]&&e.altKey&&e.code===zi.BRACKET_RIGHT:e[Oi.CTRL_OR_CMD]&&e.shiftKey&&e.code===zi.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>od("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${f("labels.bringToFront")} \u2014 ${td?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")}`,children:Bu})});import{getNonDeletedElements as Z3}from"@excalidraw/element";import{LinearElementEditor as j3}from"@excalidraw/element/linearElementEditor";import{isLinearElement as q3,isTextElement as J3}from"@excalidraw/element";import{arrayToMap as Q3,KEYS as C0}from"@excalidraw/common";import{selectGroupsForSelectedElements as eA}from"@excalidraw/element";import{CaptureUpdateAction as tA}from"@excalidraw/element";var mh=O({name:"selectAll",label:"labels.selectAll",icon:o0,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,n,t,o)=>{if(n.selectedLinearElement?.isEditing)return!1;let r=e.filter(i=>!i.isDeleted&&!(J3(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...n,...eA({editingGroupId:null,selectedElementIds:r},Z3(e),n,o),selectedLinearElement:Object.keys(r).length===1&&q3(e[0])?new j3(e[0],Q3(e)):null},captureUpdate:tA.IMMEDIATELY}},keyTest:e=>e[C0.CTRL_OR_CMD]&&e.key===C0.A});import{DEFAULT_GRID_SIZE as P0,KEYS as k0,MOBILE_ACTION_BUTTON_BG as nA,arrayToMap as M0}from"@excalidraw/common";import{getNonDeletedElements as A0}from"@excalidraw/element";import{LinearElementEditor as oA}from"@excalidraw/element/linearElementEditor";import{getSelectedElements as rA,getSelectionStateForElements as iA}from"@excalidraw/element";import{syncMovedIndices as aA}from"@excalidraw/element";import{duplicateElements as sA}from"@excalidraw/element";import{CaptureUpdateAction as D0}from"@excalidraw/element";import{jsx as lA}from"react/jsx-runtime";var ph=O({name:"duplicateSelection",label:"labels.duplicateSelection",icon:Ss,trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(n.selectedElementsAreBeingDragged)return!1;if(n.selectedLinearElement?.isEditing)try{let a=oA.duplicateSelectedPoints(n,o.scene);return{elements:e,appState:a,captureUpdate:D0.IMMEDIATELY}}catch{return!1}let{duplicatedElements:r,elementsWithDuplicates:i}=sA({type:"in-place",elements:e,idsOfElementsToDuplicate:M0(rA(e,n,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:n,randomizeSeed:!0,overrides:({origElement:a,origIdToDuplicateId:s})=>{let l=a.frameId&&s.get(a.frameId);return{x:a.x+P0/2,y:a.y+P0/2,frameId:l??a.frameId}}});if(o.props.onDuplicate&&i){let a=o.props.onDuplicate(i,e);a&&(i=a)}return{elements:aA(i,M0(r)),appState:{...n,...iA(r,A0(i),n)},captureUpdate:D0.IMMEDIATELY}},keyTest:e=>e[k0.CTRL_OR_CMD]&&e.key===k0.D,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=ct()==="mobile";return lA(Z,{type:"button",icon:Ss,title:`${f("labels.duplicateSelection")} \u2014 ${N("CtrlOrCmd+D")}`,"aria-label":f("labels.duplicateSelection"),onClick:()=>t(null),disabled:!Le(A0(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?nA:{}}})}});import{pointFrom as H4}from"@excalidraw/math";import{useEffect as _h,useMemo as Bh,useRef as Rh,useState as U4}from"react";import{BUCKET_FILL_BACKGROUND_PICKS as W4,COLOR_PALETTE as V4,DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as Oy,DEFAULT_ELEMENT_BACKGROUND_PICKS as Y4,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as X4,DEFAULT_ELEMENT_STROKE_PICKS as K4,ARROW_TYPE as dn,DEFAULT_FONT_FAMILY as $4,DEFAULT_FONT_SIZE as Z4,FONT_FAMILY as j4,ROUNDNESS as Td,STROKE_WIDTH_KEYS as q4,VERTICAL_ALIGN as vd,KEYS as Zi,randomInteger as J4,arrayToMap as Fh,getFontFamilyString as Q4,getLineHeight as e6,isTransparent as t6,getStrokeWidthByKey as zy,reduceToCommonValue as n6,invariant as Cd,FONT_SIZES as Id}from"@excalidraw/common";import{canBecomePolygon as o6,getNonDeletedElements as Gy,isNonDeletedElement as r6}from"@excalidraw/element";import{bindBindingElement as _y,calculateFixedPointForElbowArrowBinding as Ry,updateBoundElements as i6}from"@excalidraw/element";import{LinearElementEditor as Wr}from"@excalidraw/element/linearElementEditor";import{newElementWith as at}from"@excalidraw/element";import{getArrowheadForPicker as Ny}from"@excalidraw/element";import{getBoundTextElement as sr,redrawTextBoundingBox as Ys}from"@excalidraw/element";import{isArrowElement as Sd,isBoundToContainer as a6,isElbowArrow as Hy,isLinearElement as Nh,isLineElement as By,isTextElement as Ht,isUsingAdaptiveRadius as s6}from"@excalidraw/element";import{hasStrokeColor as l6}from"@excalidraw/element";import{updateElbowArrowPoints as c6,CaptureUpdateAction as tt,toggleLinePolygonState as d6}from"@excalidraw/element";import{deriveStylesPanelMode as m6}from"@excalidraw/common";import{isDevEnv as cA}from"@excalidraw/common";var dA=new Set(["command_palette","export"]),Fe=(e,n,t,o)=>{try{if(typeof window>"u"||S.VITE_WORKER_ID||S.VITE_APP_ENABLE_TRACKING!=="true"||!dA.has(e)||cA())return;S.PROD||console.info("trackEvent",{category:e,action:n,label:t,value:o}),window.sa_event&&window.sa_event(n,{category:e,label:t,value:o})}catch(r){console.error("error during analytics",r)}};import hA from"clsx";import mA from"clsx";import{forwardRef as pA}from"react";import{jsx as uA}from"react/jsx-runtime";var L0=pA((e,n)=>{let{title:t,className:o,testId:r,active:i,icon:a,onClick:s}=e;return uA("button",{type:"button",ref:n,title:t,"data-testid":r,className:mA(o,{active:i}),onClick:s,style:e.style,children:a},t)});import{Fragment as fA,jsx as uh,jsxs as gA}from"react/jsx-runtime";var jt=e=>uh(fA,{children:e.options.map(n=>e.type==="button"?uh(L0,{icon:n.icon,title:n.text,testId:n.testId,active:n.active??e.value===n.value,onClick:t=>e.onClick(n.value,t)},n.text):gA("label",{className:hA({active:e.value===n.value}),title:n.text,children:[uh("input",{type:"radio",name:e.group,onChange:()=>e.onChange(n.value),checked:e.value===n.value,"data-testid":n.testId}),n.icon]},n.text))});import{Popover as my}from"radix-ui";import py from"clsx";import{memo as F5,useRef as uy,useEffect as O5}from"react";import{applyDarkModeFilter as z5,COLOR_OUTLINE_CONTRAST_THRESHOLD as cy,COLOR_PALETTE as hy,DEFAULT_ELEMENT_BACKGROUND_PICKS as G5,DEFAULT_ELEMENT_STROKE_PICKS as H5,isColorDark as dy,isWritableElement as U5,THEME as W5}from"@excalidraw/common";import{jsx as EA}from"react/jsx-runtime";var rd=()=>EA("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as IA,useLayoutEffect as TA,useRef as SA}from"react";import{createPortal as CA}from"react-dom";import{EVENT as er,isColorDark as PA,KEYS as kA,MIME_TYPES as MA,THEME as AA,removeDarkModeFilter as DA,rgbToHex as LA}from"@excalidraw/common";import _0 from"react";var hh=_0.createContext(null),ye=()=>_0.useContext(hh);import{useState as bA,useLayoutEffect as R0}from"react";import{THEME as xA}from"@excalidraw/common";var id=e=>{let[n,t]=bA(null),o=be(),{theme:r}=ye(),{container:i}=Ne();return R0(()=>{n&&(n.className="",n.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),n.classList.toggle("excalidraw--mobile",o.formFactor==="phone"),n.classList.toggle("theme--dark",r===xA.DARK))},[n,r,o.formFactor,e?.className]),R0(()=>{let a=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!a)return;let s=document.createElement("div");return a.appendChild(s),t(s),()=>{a.removeChild(s)}},[i,e?.parentSelector]),n};import{useEffect as yA}from"react";import{EVENT as ad}from"@excalidraw/common";function Gi(e,n,t){yA(()=>{function o(r){let i=r;if(!e.current)return;let a=t?.(i,e.current);if(a===!0)return;if(a===!1)return n(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]")||n(i)}return document.addEventListener(ad.POINTER_DOWN,o),document.addEventListener(ad.TOUCH_START,o),()=>{document.removeEventListener(ad.POINTER_DOWN,o),document.removeEventListener(ad.TOUCH_START,o)}},[e,n,t])}import{useRef as wA}from"react";var Hi=e=>{let n=wA(e);return Object.assign(n.current,e),n.current};import{clamp as vA}from"@excalidraw/math";var N0=({cursorPosition:e,elementSize:n,containerSize:t,gap:o})=>{let r=e+o+n>t?e-o-n:e+o;return vA(r,0,Math.max(0,t-n))},sd=({cursor:e,element:n,container:t,gap:o})=>({left:N0({cursorPosition:e.x-t.left,elementSize:n.width,containerSize:t.width,gap:o}),top:N0({cursorPosition:e.y-t.top,elementSize:n.height,containerSize:t.height,gap:o})});import{jsx as RA}from"react/jsx-runtime";var B0=ju.map((e,n)=>`<path fill="${n===0?"#fff":""}" d="${e}" />`).join(""),_A=`url(data:${MA.svg},${encodeURIComponent(`<svg viewBox="0 0 24 24" width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke-linecap="round" stroke-linejoin="round"><g stroke="#fff" stroke-width="5">${B0}</g><g stroke="#1b1b1f" stroke-width="1.25">${B0}</g></svg>`)}) 2 21, auto`,Gt=Qe(null),F0=({onCancel:e,onChange:n,onSelect:t,colorPickerType:o})=>{let r=id({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=ye(),a=Ui(),s=St(),l=ce(a,i),c=Hi({app:s,onCancel:e,onChange:n,onSelect:t,selectedElements:l}),{container:d}=Ne();TA(()=>{if(r)return r.style.cursor=_A,()=>{r.style.cursor=""}},[r]),IA(()=>{let p=m.current;if(!p||!s.canvas||!r)return;let u=!1,E=s.canvas.getContext("2d"),g=({clientX:P,clientY:M})=>{let D=E.getImageData((P-i.offsetLeft)*window.devicePixelRatio,(M-i.offsetTop)*window.devicePixelRatio,1,1).data;return LA(D[0],D[1],D[2])},b=P=>i.theme===AA.DARK?DA(P):P,w=({clientX:P,clientY:M,altKey:D})=>{let{top:_,left:k}=sd({cursor:{x:P,y:M},element:{width:p.offsetWidth,height:p.offsetHeight},container:r.getBoundingClientRect(),gap:7});p.style.top=`${_}px`,p.style.left=`${k}px`;let L=g({clientX:P,clientY:M});u&&c.onChange(o,b(L),c.selectedElements,{altKey:D}),p.style.background=L,p.style.setProperty("--eye-dropper-preview-border-color",PA(L)?"#fff":"#222")},y=()=>{c.onCancel()},x=(P,M)=>{c.onSelect(P,M)},I=P=>{u=!0,P.stopImmediatePropagation()},T=P=>{u=!1,d?.focus(),P.stopImmediatePropagation(),P.preventDefault(),x(b(g(P)),P)},C=P=>{P.key===kA.ESCAPE&&(P.preventDefault(),P.stopImmediatePropagation(),y())};return r.tabIndex=-1,r.focus(),w({clientX:c.app.viewport.lastPosition.x,clientY:c.app.viewport.lastPosition.y,altKey:!1}),r.addEventListener(er.KEYDOWN,C),r.addEventListener(er.POINTER_DOWN,I),r.addEventListener(er.POINTER_UP,T),window.addEventListener("pointermove",w,{passive:!0}),window.addEventListener(er.BLUR,y),()=>{u=!1,r.removeEventListener(er.KEYDOWN,C),r.removeEventListener(er.POINTER_DOWN,I),r.removeEventListener(er.POINTER_UP,T),window.removeEventListener("pointermove",w),window.removeEventListener(er.BLUR,y)}},[c,s.canvas,r,o,d,i.offsetLeft,i.offsetTop,i.theme]);let m=SA(null);return Gi(m,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),r?CA(RA("div",{ref:m,className:"excalidraw-eye-dropper-preview"}),r):null};import{Popover as gh}from"radix-ui";import OA from"clsx";import zA from"react";import{isInteractive as GA}from"@excalidraw/common";import NA from"react";import BA from"clsx";import{jsx as FA}from"react/jsx-runtime";var Ue=NA.forwardRef(({children:e,padding:n,className:t,style:o,"data-viewport-ui":r,"data-viewport-ui-name":i},a)=>FA("div",{className:BA("Island",t),style:{"--padding":n,...o},"data-viewport-ui":r,"data-viewport-ui-name":i,ref:a,children:e}));import{jsx as fh,jsxs as HA}from"react/jsx-runtime";var yo=zA.forwardRef(({className:e,container:n,children:t,style:o,onClose:r,onKeyDown:i,onFocusOutside:a,onPointerLeave:s,onPointerDownOutside:l,preventAutoFocusOnTouch:c=!1},d)=>{let m=be(),p=m.formFactor==="phone"&&!m.isLandscape;return fh(gh.Portal,{container:n,children:HA(gh.Content,{ref:d,className:OA("focus-visible-none",e),"data-prevent-outside-click":!0,side:p?"bottom":"right",align:p?"center":"start",alignOffset:-16,sideOffset:20,collisionBoundary:n??void 0,style:{zIndex:"var(--zIndex-ui-styles-popup)",marginLeft:m.formFactor==="phone"?"0.5rem":void 0},onPointerLeave:s,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:l,onOpenAutoFocus:u=>{c&&m.isTouchScreen&&u.preventDefault()},onCloseAutoFocus:u=>{u.stopPropagation(),u.preventDefault(),n&&!GA(document.activeElement)&&n.focus(),r()},children:[fh(Ue,{padding:3,style:o,children:t}),fh(gh.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 UA,useCallback as Eh}from"react";var ld=()=>document.querySelector(".excalidraw-wysiwyg"),cd=()=>{let e=ld();return e?{start:e.selectionStart,end:e.selectionEnd}:null},_s=e=>{setTimeout(()=>{let n=ld();n&&(n.focus(),e&&(n.selectionStart=e.start,n.selectionEnd=e.end))},0)},Rs=(e,n,t,o)=>{n&&o&&o();let r=n&&t?cd():null;e(),n&&t&&_s(r)},O0=()=>{let[e,n]=UA(null),t=Eh(()=>{let i=cd();n(i)},[]),o=Eh(()=>{setTimeout(()=>{let i=ld();i&&(i.focus(),e&&(i.selectionStart=e.start,i.selectionEnd=e.end,n(null)))},0)},[e]),r=Eh(()=>{n(null)},[]);return{saveCaretPosition:t,restoreCaretPosition:o,clearSavedPosition:r,hasSavedPosition:!!e}},z0=(e=100)=>{let n=ld();if(n){let t=n.onblur;n.onblur=null,setTimeout(()=>{n.onblur=t},e)}};import H0 from"clsx";import{useCallback as YA,useEffect as xh,useRef as U0,useState as W0}from"react";import{KEYS as yh,normalizeInputColor as XA}from"@excalidraw/common";import{isTransparent as WA,MAX_CUSTOM_COLORS_USED_IN_CANVAS as VA}from"@excalidraw/common";var tr=({palette:e,color:n})=>{if(!n)return null;for(let[t,o]of Object.entries(e))if(Array.isArray(o)){let r=o.indexOf(n);if(r>-1)return{colorName:t,shade:r}}else if(o===n)return{colorName:t,shade:null};return null},Ns=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),bh=({color:e,palette:n})=>!Object.values(n).flat().includes(e),G0=(e,n,t)=>{let o={elementBackground:"backgroundColor",elementStroke:"strokeColor"},r=e.filter(a=>{if(a.isDeleted)return!1;let s=a[o[n]];return!WA(s)&&bh({color:s,palette:t})}),i=new Map;return r.forEach(a=>{let s=a[o[n]];i.has(s)?i.set(s,i.get(s)+1):i.set(s,1)}),[...i.entries()].sort((a,s)=>s[1]-a[1]).map(a=>a[0]).slice(0,VA)},sn=Qe(null);import{Fragment as KA,jsx as Bs,jsxs as wh}from"react/jsx-runtime";var V0=({color:e,onChange:n,label:t,colorPickerType:o,placeholder:r})=>{let i=be(),[a,s]=W0(e),[l,c]=W0(null),[d,m]=He(sn);xh(()=>{s(e)},[e]);let p=YA(w=>{let y=w.toLowerCase().trim(),x=XA(y);x?(n(x),c(null)):y.length===0?c(null):/^#?[0-9a-f]+$/.test(y)?c(f("colorPicker.invalidHexLength")):c(f("colorPicker.invalidColor")),s(y)},[n]),u=U0(null),E=U0(null);xh(()=>{u.current&&u.current.focus()},[d]);let[g,b]=He(Gt);return xh(()=>()=>{b(null)},[b]),wh("div",{className:"color-picker__input-label-container",children:[wh("div",{className:H0("color-picker__input-label",{"has-error":l}),children:[Bs("div",{className:"color-picker__input-hash",children:"#"}),Bs("input",{ref:d==="hex"?u:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,"aria-invalid":!!l,onChange:w=>{p(w.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{s(e),c(null)},tabIndex:-1,onFocus:()=>m("hex"),onKeyDown:w=>{w.key!==yh.TAB&&(w.key===yh.ESCAPE&&E.current?.focus(),w.stopPropagation())},placeholder:r}),i.formFactor!=="phone"&&wh(KA,{children:[Bs("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),Bs("div",{ref:E,className:H0("excalidraw-eye-dropper-trigger",{selected:g}),onClick:()=>b(w=>w?null:{keepOpenOnAlt:!1,onSelect:y=>n(y),colorPickerType:o}),title:`${f("labels.eyeDropper")} \u2014 ${yh.I.toLocaleUpperCase()} or ${N("Alt")} `,children:Fi})]})]}),l&&Bs("div",{className:"color-picker__error-message",role:"alert",children:l})]})};import Th,{useEffect as Sh,useImperativeHandle as S5,useState as C5}from"react";import{EVENT as ry}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as P5,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as k5,KEYS as M5}from"@excalidraw/common";import n5 from"clsx";import{useEffect as o5,useRef as r5}from"react";import{applyDarkModeFilter as i5,THEME as a5}from"@excalidraw/common";import{isColorDark as $A}from"@excalidraw/common";import{jsxs as jA}from"react/jsx-runtime";var ZA=({color:e,keyLabel:n,isShade:t=!1})=>jA("div",{className:"color-picker__button__hotkey-label",style:{color:$A(e)?"#fff":"#000"},children:[t&&"\u21E7",n]}),Wi=ZA;import{createContext as qA,useContext as JA,useEffect as QA,useMemo as Y0,useRef as X0,useState as e5}from"react";import{colorToHex as K0,isTransparent as t5}from"@excalidraw/common";var Ur="excalidraw-color-dnd-ghost",$0="excalidraw-color-dnd-active",Z0=10,j0=100,q0=(e,n)=>{if(e.toLowerCase()===n.toLowerCase())return!0;let t=K0(e);return t!==null&&t===K0(n)},vh=qA(null),ln=()=>JA(vh),J0=({enabled:e,picks:n,onPicksChange:t})=>{let[o,r]=e5(null),i=X0(null),a=X0({enabled:e,picks:n,onPicksChange:t});a.current={enabled:e,picks:n,onPicksChange:t};let s=Y0(()=>{let l=null,c=()=>{l?.activated?r({color:l.color,origin:l.origin,overIndex:l.overIndex,duplicateIndex:l.duplicateIndex,slotSpan:l.slotSpan}):r(null)},d=()=>{let k=i.current;if(!k||!l)return!1;let L=Array.from(k.querySelectorAll("[data-top-pick-index]")).sort((V,G)=>Number(V.dataset.topPickIndex)-Number(G.dataset.topPickIndex));if(!L.length)return!1;l.slotRects=L.map(V=>V.getBoundingClientRect());let[F,Y]=l.slotRects;l.slotSpan=Y?Y.left-F.left:F.width+4;let z=k.getBoundingClientRect(),U=Math.max(Math.abs(l.slotSpan)/2,10);return l.hitRect={left:z.left-U,right:z.right+U,top:z.top-14,bottom:z.bottom+14},!0},m=(k,L)=>{l?.ghost&&(l.ghost.style.transform=`translate(${k-l.ghostW/2}px, ${L-l.ghostH/2}px)`)},p=(k,L,F,Y)=>{l?.ghost&&(l.ghostW!==k||l.ghostH!==L)&&(l.ghostW=k,l.ghostH=L,l.ghost.style.width=`${k}px`,l.ghost.style.height=`${L}px`,m(F,Y))},u=(k,L)=>{if(!l)return;let{sourceRect:F,sourceEl:Y,color:z}=l,U=document.createElement("div");U.className=Ur;let V=document.createElement("div");if(V.className=`${Ur}__swatch`,t5(z))V.classList.add("is-transparent");else{let G=getComputedStyle(Y).backgroundColor;V.style.backgroundColor=G&&G!=="rgba(0, 0, 0, 0)"?G:z}U.appendChild(V),document.body.appendChild(U),l.ghost=U,l.ghostW=F.width,l.ghostH=F.height,U.style.width=`${F.width}px`,U.style.height=`${F.height}px`,m(k,L),requestAnimationFrame(()=>{l?.ghost===U&&U.classList.add(`${Ur}--lifted`)}),document.body.classList.add($0),l.activated=!0,c()},E=(k,L)=>{if(!l?.hitRect)return;let{hitRect:F,slotRects:Y}=l,z=null,U=null;if(k>=F.left&&k<=F.right&&L>=F.top&&L<=F.bottom){let V=0,G=1/0;if(Y.forEach((re,B)=>{let W=Math.abs(k-(re.left+re.width/2));W<G&&(G=W,V=B)}),l.origin.kind==="swatch"){let re=a.current.picks.findIndex(B=>q0(B,l.color));re!==-1?U=re:z=V}else z=V}if(z!==l.overIndex||U!==l.duplicateIndex){l.overIndex=z,l.duplicateIndex=U;let{ghost:V}=l;V&&(V.classList.toggle(`${Ur}--over`,z!==null),V.classList.toggle(`${Ur}--blocked`,U!==null)),c()}if(z!==null){let V=l.slotRects[z];p(V.width,V.height,k,L)}else p(l.sourceRect.width,l.sourceRect.height,k,L)},g=k=>{if(!l?.ghost)return;let{ghost:L}=l;l.ghost=null,L.classList.add(`${Ur}--dropping`);let F=k.rect;F&&(L.style.width=`${F.width}px`,L.style.height=`${F.height}px`,L.style.transform=`translate(${F.left}px, ${F.top}px)`),window.setTimeout(()=>{L.classList.add(`${Ur}--fade`)},160),window.setTimeout(()=>{L.remove()},340)},b=()=>{let k=i.current;if(!k||!l?.activated)return;let L=Array.from(k.querySelectorAll("[data-top-pick-index]"));for(let F of L)F.style.transition="none",F.style.transform="none";k.offsetWidth;for(let F of L)F.style.transition=""},w=()=>{let k=L=>{L.preventDefault(),L.stopPropagation()};window.addEventListener("click",k,{capture:!0,once:!0}),window.setTimeout(()=>{window.removeEventListener("click",k,{capture:!0})},100)},y=()=>{window.removeEventListener("pointermove",C,!0),window.removeEventListener("pointerup",P,!0),window.removeEventListener("pointercancel",M,!0),window.removeEventListener("keydown",D,!0)},x=()=>{y(),document.body.classList.remove($0),l?.activationTimer!=null&&window.clearTimeout(l.activationTimer),l=null,r(null)},I=k=>{l&&(b(),l.ghost&&(k?g({rect:l.sourceRect}):(l.ghost.remove(),l.ghost=null)),x())},T=(k,L)=>{if(!(!l||l.activated)){if(!d()){x();return}u(k,L),E(k,L)}},C=k=>{if(!(!l||k.pointerId!==l.pointerId)){if(l.lastX=k.clientX,l.lastY=k.clientY,!l.activated){if(Math.hypot(k.clientX-l.startX,k.clientY-l.startY)<Z0){l.activationTimer!==null&&(window.clearTimeout(l.activationTimer),l.activationTimer=null);return}let L=performance.now()-l.startTime;if(L<j0){l.activationTimer===null&&(l.activationTimer=window.setTimeout(()=>{l&&(l.activationTimer=null,Math.hypot(l.lastX-l.startX,l.lastY-l.startY)>=Z0&&T(l.lastX,l.lastY))},j0-L));return}if(T(k.clientX,k.clientY),!l?.activated)return}k.preventDefault(),m(k.clientX,k.clientY),E(k.clientX,k.clientY)}},P=k=>{if(!l||k.pointerId!==l.pointerId)return;if(!l.activated){x();return}k.preventDefault(),k.stopPropagation(),w();let{overIndex:L,origin:F,color:Y,slotRects:z}=l,{picks:U,onPicksChange:V}=a.current;if(b(),L!==null){if(F.kind==="swatch"){if(!U.some(G=>q0(G,Y))){let G=[...U];G[L]=Y,V(G)}}else if(F.index!==L){let G=[...U],[re]=G.splice(F.index,1);G.splice(L,0,re),V(G)}g({rect:z[L]})}else g({rect:l.sourceRect});x()},M=k=>{l&&k.pointerId===l.pointerId&&I(!0)},D=k=>{l?.activated&&k.key==="Escape"&&(k.preventDefault(),k.stopPropagation(),I(!0))};return{begin:(k,L,F)=>{!a.current.enabled||l||k.button!==0||!L||(l={pointerId:k.pointerId,startX:k.clientX,startY:k.clientY,startTime:performance.now(),lastX:k.clientX,lastY:k.clientY,activationTimer:null,color:L,origin:F,sourceEl:k.currentTarget,sourceRect:k.currentTarget.getBoundingClientRect(),activated:!1,ghost:null,ghostW:0,ghostH:0,slotRects:[],slotSpan:0,hitRect:null,overIndex:null,duplicateIndex:null},window.addEventListener("pointermove",C,!0),window.addEventListener("pointerup",P,!0),window.addEventListener("pointercancel",M,!0),window.addEventListener("keydown",D,!0))},destroy:()=>I(!1)}},[]);return QA(()=>()=>s.destroy(),[s]),Y0(()=>({dragState:o,startSwatchDrag:(l,c)=>s.begin(l,c,{kind:"swatch"}),startPickDrag:(l,c,d)=>s.begin(l,d,{kind:"pick",index:c}),setStripEl:l=>{i.current=l}}),[o,s])};import{jsx as Ih,jsxs as s5}from"react/jsx-runtime";var Q0=({theme:e,colors:n,color:t,onChange:o,label:r})=>{let[i,a]=He(sn),s=ln(),l=r5(null);return o5(()=>{l.current&&l.current.focus()},[t,i]),Ih("div",{className:"color-picker-content--default",children:n.map((c,d)=>{let m=i5(c,e===a5.DARK);return s5("button",{ref:t===c?l:void 0,tabIndex:-1,type:"button",className:n5("color-picker__button color-picker__button--large has-outline",{active:t===c,"is-transparent":c==="transparent"||!c}),onClick:()=>{o(c),a("custom")},onPointerDown:s?p=>s.startSwatchDrag(p,c):void 0,title:c,"aria-label":r,style:{"--swatch-color":m},children:[Ih("div",{className:"color-picker__button-outline"}),Ih(Wi,{color:m,keyLabel:d+1})]},d)})})};import l5 from"clsx";import{useEffect as c5,useRef as d5}from"react";import{applyDarkModeFilter as m5,isColorDark as p5,THEME as u5}from"@excalidraw/common";import{jsx as dd,jsxs as g5}from"react/jsx-runtime";var h5=({theme:e,palette:n,color:t,onChange:o,activeShade:r,showHotKey:i=!0,excludedColors:a})=>{let s=tr({color:t,palette:n}),[l,c]=He(sn),d=ln(),m=d5(null);return c5(()=>{m.current&&l==="baseColors"&&m.current.focus()},[s?.colorName,l]),dd("div",{className:"color-picker-content--default",children:Object.entries(n).map(([p,u],E)=>{let g=(Array.isArray(u)?u[r]:u)||"transparent";if(a?.includes(g))return dd("div",{className:"color-picker__button color-picker__button--large",style:{visibility:"hidden"},"aria-hidden":"true"},p);let b=Ns[E],w=m5(g,e===u5.DARK),y=f(`colors.${p.replace(/\d+/,"")}`,null,"");return g5("button",{ref:s?.colorName===p?m:void 0,tabIndex:-1,type:"button",className:l5("color-picker__button color-picker__button--large",{"has-outline":!p5(g,255),active:s?.colorName===p,"is-transparent":g==="transparent"||!g}),onClick:()=>{o(g),c("baseColors")},onPointerDown:d?x=>d.startSwatchDrag(x,g):void 0,title:`${y}${g.startsWith("#")?` ${g}`:""} \u2014 ${b}`,"aria-label":`${y} \u2014 ${b}`,style:g?{"--swatch-color":w}:void 0,"data-testid":`color-${p}`,children:[dd("div",{className:"color-picker__button-outline"}),i&&dd(Wi,{color:w,keyLabel:b})]},p)})})},ey=h5;import{jsx as E5}from"react/jsx-runtime";var f5=({children:e})=>E5("div",{className:"color-picker__heading",children:e}),Vi=f5;import b5 from"clsx";import{useEffect as x5,useRef as y5}from"react";import{applyDarkModeFilter as w5,THEME as v5}from"@excalidraw/common";import{jsx as Fs,jsxs as ty}from"react/jsx-runtime";var ny=({theme:e,color:n,onChange:t,palette:o,showHotKey:r})=>{let i=tr({color:n||"transparent",palette:o}),[a,s]=He(sn),l=ln(),c=y5(null);if(x5(()=>{c.current&&a==="shades"&&c.current.focus()},[i,a]),i){let{colorName:d,shade:m}=i,p=o[d];if(Array.isArray(p))return Fs("div",{className:"color-picker-content--default shades",children:p.map((u,E)=>{let g=w5(u,e===v5.DARK);return ty("button",{ref:E===m&&a==="shades"?c:void 0,tabIndex:-1,type:"button",className:b5("color-picker__button color-picker__button--large",{active:E===m}),"aria-label":"Shade",title:`${d} - ${E+1}`,style:u?{"--swatch-color":g}:void 0,onClick:()=>{t(u),s("shades")},onPointerDown:l?b=>l.startSwatchDrag(b,u):void 0,children:[Fs("div",{className:"color-picker__button-outline"}),r&&Fs(Wi,{color:g,keyLabel:E+1,isShade:!0})]},E)})})}return ty("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Fs("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Fs("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 Yi,COLOR_PALETTE as I5,KEYS as Os}from"@excalidraw/common";var md=(e,n,t)=>{let o=Math.ceil(t/Yi);switch(n=n??-1,e){case"ArrowLeft":{let r=n-1;return r<0?t-1:r}case"ArrowRight":return(n+1)%t;case"ArrowDown":{let r=n+Yi;return r>=t?n%Yi:r}case"ArrowUp":{let r=n-Yi,i=r<0?Yi*o+r:r;return i>=t?void 0:i}}},T5=({e,colorObj:n,onChange:t,palette:o,customColors:r,setActiveColorPickerSection:i,activeShade:a,excludedColors:s})=>{if(n?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let l=Number(e.code.slice(-1))-1;return t(o[n.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(Ns.includes(e.key)){let l=Ns.indexOf(e.key),c=Object.keys(o)[l],d=o[c],m=Array.isArray(d)?d[a]:d;return m==null||s?.includes(m)||(t(m),i("baseColors")),!0}return!1},oy=({event:e,activeColorPickerSection:n,palette:t,color:o,onChange:r,customColors:i,setActiveColorPickerSection:a,updateData:s,activeShade:l,onEyeDropperToggle:c,onEscape:d,excludedColors:m})=>{if(e[Os.CTRL_OR_CMD])return!1;if(e.key===Os.ESCAPE)return d(e),!0;if(e.key===Os.ALT)return c(!0),!0;if(e.key===Os.I)return c(),!0;let p=tr({color:o,palette:t});if(e.key===Os.TAB){let u={custom:!!i.length,baseColors:!0,shades:p?.shade!=null,hex:!0},E=Object.entries(u).reduce((x,[I,T])=>(T&&x.push(I),x),[]),g=E.indexOf(n),b=e.shiftKey?-1:1,w=g+b>E.length-1?0:g+b<0?E.length-1:g+b,y=E[w];return y&&a(y),y==="custom"?r(i[0]):y==="baseColors"&&(Object.entries(t).find(([I,T])=>Array.isArray(T)?T.includes(o):T===o?I:null)||r(I5.black)),e.preventDefault(),e.stopPropagation(),!0}if(T5({e,colorObj:p,onChange:r,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:l,excludedColors:m}))return!0;if(n==="shades"&&p){let{shade:u}=p,E=md(e.key,u,Yi);if(E!==void 0)return r(t[p.colorName][E]),!0}if(n==="baseColors"&&p){let{colorName:u}=p,E=Object.keys(t),g=E.indexOf(u),b=md(e.key,g,E.length),w=0;for(;b!==void 0&&w++<E.length;){let y=t[E[b]],x=Array.isArray(y)?y[l]:y;if(!m?.includes(x))break;b=md(e.key,b,E.length)}if(b!==void 0){let y=E[b],x=t[y];return r(Array.isArray(x)?x[l]:x),!0}}if(n==="custom"){let u=o!=null?i.indexOf(o):0,E=md(e.key,u,i.length);if(E!==void 0){let g=i[E];return r(g),!0}}return!1};import{jsx as wo,jsxs as pd}from"react/jsx-runtime";var iy=Th.forwardRef(({theme:e,color:n,onChange:t,type:o,elements:r,palette:i,updateData:a,children:s,showTitle:l,onEyeDropperToggle:c,onEscape:d,showHotKey:m=!0,excludedColors:p},u)=>{let E=l?o==="elementStroke"?f("labels.stroke"):o==="elementBackground"?f("labels.background"):null:null,[g]=Th.useState(()=>o==="canvasBackground"?[]:G0(r,o,i)),[b,w]=He(sn),y=ln(),x=tr({color:n,palette:i});Sh(()=>{if(!b){let P=!!n&&bh({color:n,palette:i}),M=P&&!g.includes(n);w(M?null:P?"custom":x?.shade!=null?"shades":"baseColors")}},[b,n,i,w,x,g]);let[I,T]=C5(x?.shade??(o==="elementBackground"?P5:k5));Sh(()=>{x?.shade!=null&&T(x.shade);let P=M=>{M.key===M5.ALT&&c(!1)};return document.addEventListener(ry.KEYUP,P,{capture:!0}),()=>{document.removeEventListener(ry.KEYUP,P,{capture:!0})}},[x,c]);let C=Th.useRef(null);return S5(u,()=>C.current),Sh(()=>{C?.current?.focus()},[]),wo("div",{role:"dialog","aria-modal":"true","aria-label":f("labels.colorPicker"),children:pd("div",{ref:C,onKeyDown:P=>{oy({event:P,activeColorPickerSection:b,palette:i,color:n,onChange:t,onEyeDropperToggle:c,customColors:g,setActiveColorPickerSection:w,updateData:a,activeShade:I,onEscape:d,excludedColors:p})&&(P.preventDefault(),P.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[E&&wo("div",{className:"color-picker__title",children:E}),!!g.length&&pd("div",{children:[wo(Vi,{children:f("colorPicker.mostUsedCustomColors")}),wo(Q0,{theme:e,colors:g,color:n,label:f("colorPicker.mostUsedCustomColors"),onChange:t})]}),pd("div",{children:[wo(Vi,{children:f("colorPicker.colors")}),wo(ey,{theme:e,color:n,palette:i,onChange:t,activeShade:I,showHotKey:m,excludedColors:p})]}),pd("div",{children:[wo(Vi,{children:f("colorPicker.shades")}),wo(ny,{theme:e,color:n,onChange:t,palette:i,showHotKey:m})]}),s,y&&wo("div",{className:"color-picker__tip",children:f("colorPicker.topPicksTip")})]})})});import ay from"clsx";import{ContextMenu as zs}from"radix-ui";import{applyDarkModeFilter as A5,COLOR_OUTLINE_CONTRAST_THRESHOLD as D5,DEFAULT_CANVAS_BACKGROUND_PICKS as L5,DEFAULT_ELEMENT_BACKGROUND_PICKS as _5,DEFAULT_ELEMENT_STROKE_PICKS as R5,isColorDark as N5,THEME as B5}from"@excalidraw/common";import{jsx as nr,jsxs as sy}from"react/jsx-runtime";var ly=({theme:e,onChange:n,type:t,activeColor:o,topPicks:r,onReset:i,isCustomized:a})=>{let s=ln(),l=s?.dragState??null,{container:c}=Ne(),d;if(t==="elementStroke"&&(d=R5),t==="elementBackground"&&(d=_5),t==="canvasBackground"&&(d=L5),r&&(d=r),!d)return console.error("Invalid type for TopPicks"),null;let m=u=>{if(!l||l.origin.kind!=="pick"||l.overIndex===null)return 0;let E=l.origin.index,g=l.overIndex;if(E===g)return 0;let b=u;return u===E?b=g:(u>E&&(b-=1),b>=g&&(b+=1)),(b-u)*l.slotSpan},p=sy("div",{className:ay("color-picker__top-picks",{"is-dnd-active":!!l}),ref:s?.setStripEl,children:[l&&nr("svg",{className:"color-picker__top-picks__dnd-outline","aria-hidden":"true",children:nr("rect",{})}),d.map((u,E)=>{let g=m(E),b=A5(u,e===B5.DARK);return nr("button",{className:ay("color-picker__button",{active:u===o,"is-transparent":u==="transparent"||!u,"has-outline":!N5(u,D5),"is-dnd-source":l?.origin.kind==="pick"&&l.origin.index===E,"is-dnd-target":l?.origin.kind==="swatch"&&l.overIndex===E,"is-dnd-duplicate":l?.duplicateIndex===E}),style:{"--swatch-color":b,transform:g?`translateX(${g}px)`:void 0},type:"button",title:u,onClick:()=>n(u),onPointerDown:s?w=>s.startPickDrag(w,E,u):void 0,"data-testid":`color-top-pick-${u}`,"data-top-pick-index":E,children:nr("div",{className:"color-picker__button-outline"})},u)})]});return i?sy(zs.Root,{children:[nr(zs.Trigger,{asChild:!0,children:p}),nr(zs.Portal,{container:c,children:nr(zs.Content,{className:"color-picker__context-menu",style:{zIndex:"var(--zIndex-ui-styles-popup)"},children:nr(zs.Item,{className:"color-picker__context-menu-item",disabled:!a,onSelect:i,children:f("colorPicker.resetTopPicks")})})})]}):p};import{jsx as cn,jsxs as ud}from"react/jsx-runtime";var V5=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=hy,updateData:a,getOpenPopup:s,appState:l,excludedColors:c})=>{let{container:d}=Ne(),m=ct(),p=m!=="full",u=m==="mobile",[,E]=He(sn),[g,b]=He(Gt),w=ud("div",{children:[cn(Vi,{children:f("colorPicker.hexCode")}),cn(V0,{color:n||"",label:o,onChange:I=>{t(I)},colorPickerType:e,placeholder:f("colorPicker.color")})]}),y=uy(null),x=()=>{y.current?.focus()};return cn(yo,{container:d,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!l.editingTextElement,onFocusOutside:I=>{if(I.target instanceof HTMLElement&&I.target.closest(".color-picker__context-menu")){I.preventDefault();return}U5(I.target)||(I.target instanceof HTMLElement&&I.target.matches(":active")?window.addEventListener("pointerup",x,{once:!0}):x()),I.preventDefault()},onPointerDownOutside:I=>{g&&I.preventDefault()},onClose:()=>{s()===e&&a({openPopup:null}),E(null),l.editingTextElement&&setTimeout(()=>{let I=document.querySelector(".excalidraw-wysiwyg");I&&I.focus()},0)},children:i?cn(iy,{ref:y,palette:i,excludedColors:c,color:n,theme:l.theme,onChange:I=>{let T=l.editingTextElement?cd():null;t(I),l.editingTextElement&&T&&_s(T)},onEyeDropperToggle:I=>{b(T=>I?(T=T||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},T.keepOpenOnAlt=!0,T):I===!1||T?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:I=>{g?b(null):a({openPopup:null})},type:e,elements:r,updateData:a,showTitle:p,showHotKey:!u,children:w}):w})},Y5=e=>e==="elementStroke"||e==="elementBackground"||e==="canvasBackground",X5=({label:e,color:n,type:t,theme:o,mode:r="background",onToggle:i,editingTextElement:a})=>{let s=ct(),l=s!=="full",c=s==="mobile",d=ln(),m=n?z5(n,o===W5.DARK):null,p=u=>{u.preventDefault(),u.stopPropagation(),a&&z0(),i()};return ud(my.Trigger,{type:"button",className:py("color-picker__button active-color properties-trigger",{"is-transparent":!n||n==="transparent","has-outline":!n||!dy(n,cy),"compact-sizing":l,"mobile-border":c}),"aria-label":e,style:m?{"--swatch-color":m}:void 0,title:t==="elementStroke"?f("labels.showStroke"):f("labels.showBackground"),"data-openpopup":t,onClick:p,onPointerDown:d?u=>d.startSwatchDrag(u,n):void 0,children:[cn("div",{className:"color-picker__button-outline",children:!n&&jx}),l&&n&&r==="stroke"&&cn("div",{className:"color-picker__button-background",children:cn("span",{style:{color:m&&dy(m,cy)?"#fff":"#111"},children:f0})})]})},K5=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=hy,topPicks:a,updateData:s,appState:l,excludedColors:c,customizableTopPicks:d})=>{let m=uy(l.openPopup);O5(()=>{m.current=l.openPopup},[l.openPopup]);let u=ct()!=="full",E=!!d&&!u,g=E&&d?l.colorTopPicks?.[d]:null,b=g?.length?g:a??(e==="elementStroke"?H5:G5),w=J0({enabled:E,picks:b,onPicksChange:y=>{d&&s({colorTopPicks:{...l.colorTopPicks,[d]:y}})}});return cn(vh.Provider,{value:E?w:null,children:ud("div",{role:"dialog","aria-modal":"true",className:py("color-picker-container",{"color-picker-container--no-top-picks":u}),children:[!u&&cn(ly,{theme:l.theme,activeColor:n,onChange:y=>{t(y),Y5(l.openPopup)&&l.openPopup!==e&&setTimeout(()=>s({openPopup:e}),0)},type:e,topPicks:g?.length?g:a,isCustomized:!!g?.length,onReset:E&&d?()=>{s({colorTopPicks:{...l.colorTopPicks,[d]:null}})}:void 0}),!u&&cn(rd,{}),ud(my.Root,{open:l.openPopup===e,onOpenChange:y=>{y&&s({openPopup:e})},children:[cn(X5,{color:n,label:o,type:e,theme:l.theme,mode:e==="elementStroke"?"stroke":"background",editingTextElement:!!l.editingTextElement,onToggle:()=>{l.openPopup===e?s({openPopup:null}):l.openPopup?s({openPopup:e}):s({openPopup:e})}}),l.openPopup===e&&cn(V5,{type:e,color:n,onChange:t,label:o,elements:r,palette:i,excludedColors:c,updateData:s,getOpenPopup:()=>m.current,appState:l})]})]})})},$5=(e,n)=>e.appState.openPopup===e.type||n.appState.openPopup===n.type?!1:e.type===n.type&&e.color===n.color&&e.label===n.label&&e.appState.openPopup===n.appState.openPopup&&e.palette===n.palette&&e.topPicks===n.topPicks&&e.excludedColors===n.excludedColors&&e.customizableTopPicks===n.customizableTopPicks&&e.appState.theme===n.appState.theme&&e.appState.colorTopPicks===n.appState.colorTopPicks&&!!e.appState.editingTextElement==!!n.appState.editingTextElement,Xi=F5(K5,$5);import{Popover as v4}from"radix-ui";import I4 from"clsx";import T4,{useCallback as S4,useMemo as C4}from"react";import{FONT_FAMILY as Mh}from"@excalidraw/common";import p4,{useMemo as ir,useState as u4,useRef as by,useEffect as xy,useCallback as yy}from"react";import{arrayToList as h4,debounce as g4,FONT_FAMILY as ar,getFontFamilyString as f4}from"@excalidraw/common";import Z5 from"clsx";import j5 from"react";import{jsx as q5,jsxs as J5}from"react/jsx-runtime";var hd=j5.forwardRef(({className:e,placeholder:n,onChange:t},o)=>J5("div",{className:Z5("QuickSearch__wrapper",e),children:[Jn,q5("input",{ref:o,className:"QuickSearch__input",type:"text",placeholder:n,onChange:r=>t(r.target.value.trim().toLowerCase())})]}));import Q5 from"clsx";import{Children as e4}from"react";import{jsx as gy}from"react/jsx-runtime";var gd=({className:e,placeholder:n,children:t})=>{let o=!e4.count(t);return gy("div",{className:Q5("ScrollableList__wrapper",e),role:"menu",children:o?gy("div",{className:"empty",children:n}):t})};import{jsx as t4,jsxs as n4}from"react/jsx-runtime";var fy=({children:e,className:n="",style:t,title:o})=>n4("div",{className:`dropdown-menu-group ${n}`,style:t,children:[o&&t4("p",{className:"dropdown-menu-group-title",children:o}),e]}),Gs=fy;fy.displayName="DropdownMenuGroup";import{THEME as d4}from"@excalidraw/common";import{DropdownMenu as m4}from"radix-ui";import o4,{useContext as r4}from"react";import{composeEventHandlers as i4}from"@excalidraw/common";var Ch=o4.createContext({}),or=(e="",n=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${n?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),fd=e=>{let n=r4(Ch);return i4(e,t=>{n.onSelect?.(t)})};import{jsx as a4}from"react/jsx-runtime";var Hs=({children:e,...n})=>a4("span",{...n,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...n.style},children:e});import{Fragment as l4,jsx as Us,jsxs as c4}from"react/jsx-runtime";var s4=({textStyle:e,icon:n,shortcut:t,children:o,badge:r})=>{let i=be();return c4(l4,{children:[n&&Us("div",{className:"dropdown-menu-item__icon",children:n}),Us("div",{style:e,className:"dropdown-menu-item__text",children:Us(Hs,{children:o})}),r&&Us("div",{className:"dropdown-menu-item__badge",children:r}),t&&i.formFactor!=="phone"&&Us("div",{className:"dropdown-menu-item__shortcut",children:t})]})},rr=s4;import{jsx as Ed}from"react/jsx-runtime";var Ph=({icon:e,badge:n,value:t,children:o,shortcut:r,className:i,selected:a,onSelect:s,...l})=>{let c=fd(s);return Ed(m4.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:Ed("button",{...l,value:t,className:or(i,a),title:l.title??l["aria-label"],children:Ed(rr,{icon:e,shortcut:r,badge:n,children:o})})})};Ph.displayName="DropdownMenuItem";var Ki={GREEN:"green",RED:"red",BLUE:"blue"},bd=({type:e=Ki.BLUE,children:n})=>{let{theme:t}=Qn(),o={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===d4.LIGHT?"1.5px solid white":"none"};switch(e){case Ki.GREEN:Object.assign(o,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case Ki.RED:Object.assign(o,{backgroundColor:"pink",color:"darkred"});break;case Ki.BLUE:default:Object.assign(o,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return Ed("div",{className:"DropDownMenuItemBadge",style:o,children:n})};bd.displayName="DropdownMenuItemBadge";Ph.Badge=bd;var qt=Ph;import{KEYS as $i}from"@excalidraw/common";var Ey=({event:e,inputRef:n,hoveredFont:t,filteredFonts:o,onClose:r,onSelect:i,onHover:a})=>{if(!e[$i.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===$i.F)return n.current?.focus(),!0;if(e.key===$i.ESCAPE)return r(),!0;if(e.key===$i.ENTER)return t?.value&&i(t.value),!0;if(e.key===$i.ARROW_DOWN)return t?.next?a(t.next.value):o[0]?.value&&a(o[0].value),!0;if(e.key===$i.ARROW_UP)return t?.prev?a(t.prev.value):o[o.length-1]?.value&&a(o[o.length-1].value),!0};import{jsx as vo,jsxs as x4}from"react/jsx-runtime";var E4=e=>{switch(e){case ar.Excalifont:case ar.Virgil:return $n;case ar.Nunito:case ar.Helvetica:return As;case ar["Lilita One"]:return O1;case ar["Comic Shanns"]:case ar.Cascadia:return Vc;default:return As}},b4=(e,n)=>Object.entries(ar).find(([,t])=>t===e)?.[0]??n[0]?.fontFace?.family??"Unknown",wy=p4.memo(({selectedFontFamily:e,hoveredFontFamily:n,onSelect:t,onHover:o,onLeave:r,onOpen:i,onClose:a})=>{let{container:s}=Ne(),l=St(),{fonts:c}=l,{showDeprecatedFonts:d}=kn(),m=ct(),[p,u]=u4(""),E=by(null),g=ir(()=>Array.from(Eo.registered.entries()).filter(([k,{metadata:L}])=>!L.private&&!L.fallback).map(([k,{metadata:L,fontFaces:F}])=>{let Y={value:k,icon:E4(k),text:b4(k,F)};return L.deprecated&&Object.assign(Y,{deprecated:L.deprecated,badge:{type:Ki.RED,placeholder:f("fontList.badge.old")}}),Y}).sort((k,L)=>k.text.toLowerCase()>L.text.toLowerCase()?1:-1),[]),b=ir(()=>new Set(c.getSceneFamilies()),[e]),w=ir(()=>g.filter(k=>b.has(k.value)),[g,b]),y=ir(()=>g.filter(k=>!b.has(k.value)&&(d||!k.deprecated)),[g,b,d]),x=ir(()=>h4([...w,...y].filter(k=>k.text?.toLowerCase().includes(p))),[w,y,p]),I=ir(()=>{let k;return n?k=x.find(L=>L.value===n):e&&(k=x.find(L=>L.value===e)),!k&&p&&(x[0]?.value?o(x[0].value):r()),k},[n,e,p,x,o,r]),T=yy(k=>{let L=null;if(l.state.editingTextElement){let F=document.querySelector(".excalidraw-wysiwyg");F&&(L={start:F.selectionStart,end:F.selectionEnd})}t(k),l.state.editingTextElement&&L&&setTimeout(()=>{let F=document.querySelector(".excalidraw-wysiwyg");F&&L&&(F.focus(),F.selectionStart=L.start,F.selectionEnd=L.end)},0)},[t,l.state.editingTextElement]),C=yy(k=>{Ey({event:k,inputRef:E,hoveredFont:I,filteredFonts:x,onSelect:T,onHover:o,onClose:a})&&(k.preventDefault(),k.stopPropagation())},[I,x,T,o,a]);xy(()=>(i(),()=>{a()}),[]);let P=ir(()=>x.filter(k=>b.has(k.value)),[x,b]),M=ir(()=>x.filter(k=>!b.has(k.value)),[x,b]),D=({font:k,order:L})=>{let F=by(null),Y=k.value===I?.value,z=k.value===e;return xy(()=>{Y&&(L===0?F.current?.scrollIntoView?.({block:"end"}):F.current?.scrollIntoView?.({block:"nearest"}))},[Y,L]),vo("button",{ref:F,type:"button",value:k.value,className:or("",z,Y),title:k.text,tabIndex:z?0:-1,onClick:U=>{T(Number(U.currentTarget.value))},onMouseMove:()=>{I?.value!==k.value&&o(k.value)},children:vo(rr,{icon:k.icon,badge:k.badge&&vo(bd,{type:k.badge.type,children:k.badge.placeholder}),textStyle:{fontFamily:f4({fontFamily:k.value})},children:k.text})})},_=[];return P.length&&_.push(vo(Gs,{title:f("fontList.sceneFonts"),children:P.map((k,L)=>vo(D,{font:k,order:L},k.value))},"group_1")),M.length&&_.push(vo(Gs,{title:f("fontList.availableFonts"),children:M.map((k,L)=>vo(D,{font:k,order:L+P.length},k.value))},"group_2")),x4(yo,{className:"properties-content",container:s,style:{width:"15rem"},onClose:()=>{a(),l.state.editingTextElement&&setTimeout(()=>{let k=document.querySelector(".excalidraw-wysiwyg");k&&k.focus()},0)},onPointerLeave:r,onKeyDown:C,preventAutoFocusOnTouch:!!l.state.editingTextElement,children:[m==="full"&&vo(hd,{ref:E,placeholder:f("quickSearch.placeholder"),onChange:g4(u,20)}),vo(gd,{className:"dropdown-menu fonts manual-hover",placeholder:f("fontList.empty"),children:_.length?_:null})]})},(e,n)=>e.selectedFontFamily===n.selectedFontFamily&&e.hoveredFontFamily===n.hoveredFontFamily);import{Popover as y4}from"radix-ui";import{MOBILE_ACTION_BUTTON_BG as w4}from"@excalidraw/common";import{jsx as kh}from"react/jsx-runtime";var vy=({selectedFontFamily:e,isOpened:n=!1,compactMode:t=!1})=>{let o=Oe(),r=t?{...w4,width:"2rem",height:"2rem"}:{};return kh(y4.Trigger,{asChild:!0,children:kh("div",{"data-openpopup":"fontFamily",className:"properties-trigger",children:kh(Z,{type:"toggle",icon:Pn,title:f("labels.showFonts"),"aria-label":f("labels.showFonts"),className:"standalone properties-trigger","data-testid":"font-family-show-fonts",checked:n,onSelect:()=>{o(i=>({openPopup:i.openPopup==="fontFamily"?null:i.openPopup}))},style:{border:"none",...r}})})})};import{jsx as Ws,jsxs as Iy}from"react/jsx-runtime";var Ty=[{value:Mh.Excalifont,icon:$n,text:f("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:Mh.Nunito,icon:As,text:f("labels.normal"),testId:"font-family-normal"},{value:Mh["Comic Shanns"],icon:Vc,text:f("labels.code"),testId:"font-family-code"}],ete=new Set(Ty.map(e=>e.value));var Sy=T4.memo(({isOpened:e,selectedFontFamily:n,hoveredFontFamily:t,onSelect:o,onHover:r,onLeave:i,onPopupChange:a,compactMode:s=!1})=>{let l=C4(()=>Ty,[]),c=S4(d=>{d&&o(d)},[o]);return Iy("div",{role:"dialog","aria-modal":"true",className:I4("FontPicker__container",{"FontPicker__container--compact":s}),children:[!s&&Ws("div",{className:"buttonList",children:Ws(jt,{type:"button",options:l,value:n,onClick:c})}),!s&&Ws(rd,{}),Iy(v4.Root,{open:e,onOpenChange:a,children:[Ws(vy,{selectedFontFamily:n,isOpened:e,compactMode:s}),e&&Ws(wy,{selectedFontFamily:n,hoveredFontFamily:t,onSelect:c,onHover:r,onLeave:i,onOpen:()=>a(!0),onClose:()=>a(!1)})]})]})},(e,n)=>e.isOpened===n.isOpened&&e.selectedFontFamily===n.selectedFontFamily&&e.hoveredFontFamily===n.hoveredFontFamily);import{Popover as Ah}from"radix-ui";import A4 from"clsx";import My,{useEffect as D4,useMemo as L4}from"react";import{isArrowKey as _4,KEYS as Io}from"@excalidraw/common";import{jsx as P4}from"react/jsx-runtime";var xd=({className:e,icon:n,size:t="1em"})=>P4("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:n});import{Fragment as M4,jsx as Cy,jsxs as Py}from"react/jsx-runtime";var k4=({label:e,open:n,openTrigger:t,children:o,className:r,showCollapsedIcon:i=!0})=>Py(M4,{children:[Py("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:r,onClick:t,children:[e,i&&Cy(xd,{icon:n?p0:Kc})]}),n&&Cy("div",{style:{display:"flex",flexDirection:"column"},children:o})]}),Vs=k4;import{jsx as eo,jsxs as wd}from"react/jsx-runtime";var R4=Qe(!1),yd=4,N4="default",B4=e=>e.flatMap(n=>n.options),ky=(e,n)=>{for(let t of e){let o=t.options.find(n);if(o)return o}return null},F4=(e,n)=>e.some(t=>t.options.some(n)),O4=e=>e.flatMap(n=>Array.from({length:Math.ceil(n.options.length/yd)},(t,o)=>n.options.slice(o*yd,o*yd+yd)));function z4({visibleSections:e,hiddenSections:n=[],value:t,label:o,onChange:r,onClose:i}){let{container:a}=Ne(),[s,l]=He(R4),c=[...e,...n],d=B4(c),m=O4([...e,...s?n:[]]),p=g=>{let b=d.find(w=>w.keyBinding===g.key.toLowerCase());if(!(g.metaKey||g.altKey||g.ctrlKey)&&b)r(b.value),g.preventDefault();else if(g.key===Io.TAB){let w=d.findIndex(x=>x.value===t),y=g.shiftKey?(d.length+w-1)%d.length:(w+1)%d.length;r(d[y].value)}else if(_4(g.key)){let w=Kn().rtl,y=d.findIndex(x=>x.value===t);if(y!==-1){let x=d.length,I=y;switch(g.key){case(w?Io.ARROW_LEFT:Io.ARROW_RIGHT):I=(y+1)%x;break;case(w?Io.ARROW_RIGHT:Io.ARROW_LEFT):I=(x+y-1)%x;break;case Io.ARROW_DOWN:{let T=m.findIndex(P=>P.some(M=>M.value===t)),C=m[T];if(T!==-1&&C){let P=C.findIndex(_=>_.value===t),M=m[(T+1)%m.length],D=M[Math.min(P,M.length-1)]??d[y];r(D.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}case Io.ARROW_UP:{let T=m.findIndex(P=>P.some(M=>M.value===t)),C=m[T];if(T!==-1&&C){let P=C.findIndex(_=>_.value===t),M=m[(m.length+T-1)%m.length],D=M[Math.min(P,M.length-1)]??d[y];r(D.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}}r(d[I].value)}g.preventDefault()}else(g.key===Io.ESCAPE||g.key===Io.ENTER)&&(g.preventDefault(),i());g.nativeEvent.stopImmediatePropagation(),g.stopPropagation()};D4(()=>{F4(n,g=>g.value===t)&&l(!0)},[t,n,l]);let u=g=>eo("div",{className:"picker-content",children:g.map(b=>wd("button",{type:"button",className:A4("picker-option",{active:t===b.value}),onClick:()=>{r(b.value)},title:b.keyBinding?`${b.text} \u2014 ${b.keyBinding.toUpperCase()}`:b.text,"aria-label":b.text||"none","aria-keyshortcuts":b.keyBinding||void 0,ref:w=>{t===b.value&&setTimeout(()=>{w?.focus()},0)},children:[b.icon,b.keyBinding&&eo("span",{className:"picker-keybinding",children:b.keyBinding})]},b.text))}),E=g=>g.map((b,w)=>b.name===N4?eo(My.Fragment,{children:u(b.options)},`${b.name}-${w}`):wd("div",{className:"picker-section",children:[eo("div",{className:"picker-section-label",children:b.name}),u(b.options)]},`${b.name}-${w}`));return eo(Ah.Content,{className:"picker",role:"dialog","aria-modal":"true","aria-label":o,side:"bottom",align:"start",sideOffset:12,alignOffset:12,style:{zIndex:"var(--zIndex-ui-styles-popup)"},onKeyDown:p,collisionBoundary:a??void 0,children:wd("div",{className:"picker-sections",children:[E(e),n.length>0&&eo(Vs,{label:f("labels.more_options"),open:s,openTrigger:()=>{l(g=>!g)},className:"picker-collapsible",children:eo("div",{className:"picker-sections",children:E(n)})})]})})}function Dh({value:e,label:n,visibleSections:t,hiddenSections:o,onChange:r}){let[i,a]=My.useState(!1),s=L4(()=>ky(t,l=>l.value===e)??ky(o??[],l=>l.value===e),[t,o,e]);return eo("div",{children:wd(Ah.Root,{open:i,onOpenChange:l=>a(l),children:[eo(Ah.Trigger,{type:"button","aria-label":n,onClick:()=>a(!i),className:i?"active":"",children:s?.icon}),i&&eo(z4,{visibleSections:t,hiddenSections:o,value:e,label:n,onChange:r,onClose:()=>{a(!1)}})]})})}import Ay,{useEffect as G4}from"react";import{jsx as Lh,jsxs as Dy}from"react/jsx-runtime";var Ly=({label:e,value:n,onChange:t,min:o=0,max:r=100,step:i=10,minLabel:a=o,hasCommonValue:s=!0,testId:l})=>{let c=Ay.useRef(null),d=Ay.useRef(null);return G4(()=>{if(c.current&&d.current){let m=c.current,p=d.current,u=m.offsetWidth,E=parseFloat(getComputedStyle(m).getPropertyValue("--slider-thumb-size"))||16,g=(n-o)/(r-o||1)*100,b=g/100*(u-E)+E/2;p.style.left=`${b}px`,m.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,o,n]),Dy("label",{className:"control-label",children:[e,Dy("div",{className:"range-wrapper",children:[Lh("input",{style:{"--color-slider-track":s?void 0:"var(--button-bg)"},ref:c,type:"range",min:o,max:r,step:i,onChange:m=>{t(+m.target.value)},value:n,className:"range-input","data-testid":l}),Lh("div",{className:"value-bubble",ref:d,children:n!==o?n:null}),Lh("div",{className:"zero-label",children:a})]})]})};import{Fragment as kd,jsx as ee,jsxs as bt}from"react/jsx-runtime";var Uy=.1,Vr=e=>{let n=m6(e.editorInterface);return{stylesPanelMode:n,isCompact:n!=="full",isMobile:n==="mobile"}},Ct=(e,n,t,o=!1)=>{let r=Fh(ce(e,n,{includeBoundTextElement:o}));return e.map(i=>r.get(i.id)||i.id===n.editingTextElement?.id?(r6(i)||console.error("[NONDELETED][INVARIANT] changeProperty(): skipping deleted selected/editing element"),t(i)):i)},mt=function(e,n,t,o,r){let i=n.state.editingTextElement,a=Gy(e),s=null;if(i&&(s=t(i)),!s)if(Le(a,n.state)){let c=n.scene.getSelectedElements(n.state),d=o===!0?c:c.filter(m=>o(m));s=n6(d,t)??(typeof r=="function"?r(!0):r)}else s=typeof r=="function"?r(!1):r;return s},p6=(e,n,t)=>a6(n)||!n.autoResize?n:t.mutateElement(n,{x:e.textAlign==="left"?e.x:e.x+(e.width-n.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-n.height)/2}),Oh=(e,n,t,o,r)=>{let i=new Set,a=Ct(e,n,s=>{if(Ht(s)){let l=o(s);i.add(l);let c=at(s,{fontSize:l});return Ys(c,t.scene.getContainerElement(s),t.scene),c=p6(s,c,t.scene),c}return s},!0);return ce(e,n,{includeBoundTextElement:!0}).forEach(s=>{Ht(s)&&i6(s,t.scene)}),{elements:a,appState:{...n,currentItemFontSize:i.size===1?[...i][0]:r??n.currentItemFontSize},captureUpdate:tt.IMMEDIATELY}},u6=O({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,n,t)=>({...t?.currentItemStrokeColor&&{elements:Ct(e,n,o=>l6(o.type)?at(o,{strokeColor:t.currentItemStrokeColor}):o,!0)},appState:{...n,...t},captureUpdate:t?.currentItemStrokeColor?tt.IMMEDIATELY:tt.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=Vr(o);return bt(kd,{children:[i==="full"&&ee("h3",{"aria-hidden":"true",children:f("labels.stroke")}),ee(Xi,{topPicks:K4,palette:X4,customizableTopPicks:"elementStroke",type:"elementStroke",label:f("labels.stroke"),color:mt(e,o,a=>a.strokeColor,!0,a=>a?null:n.currentItemStrokeColor),onChange:a=>t({currentItemStrokeColor:a}),elements:e,appState:n,updateData:t})]})}}),h6=O({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t,o)=>{if(!t?.currentItemBackgroundColor)return{appState:{...n,...t},captureUpdate:tt.EVENTUALLY};let r,i=o.scene.getSelectedElements(n);if(!t6(t.currentItemBackgroundColor)&&i.every(s=>By(s)&&o6(s.points))){let s=Fh(i);r=e.map(l=>s.has(l.id)&&By(l)?at(l,{backgroundColor:t.currentItemBackgroundColor,...d6(l,!0)}):l)}else r=Ct(e,n,s=>at(s,{backgroundColor:t.currentItemBackgroundColor}));return{elements:r,appState:{...n,...t},captureUpdate:tt.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=Vr(o);return bt(kd,{children:[i==="full"&&ee("h3",{"aria-hidden":"true",children:f("labels.background")}),ee(Xi,{topPicks:Y4,palette:Oy,customizableTopPicks:"elementBackground",type:"elementBackground",label:f("labels.background"),color:mt(e,o,a=>a.backgroundColor,!0,a=>a?null:n.currentItemBackgroundColor),onChange:a=>t({currentItemBackgroundColor:a}),elements:e,appState:n,updateData:t})]})}}),Pd=O({name:"changeBucketFillBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,...t},captureUpdate:tt.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let{stylesPanelMode:r}=Vr(o);return bt(kd,{children:[r==="full"&&ee("h3",{"aria-hidden":"true",children:f("labels.background")}),ee(Xi,{topPicks:W4,palette:Oy,excludedColors:[V4.transparent],customizableTopPicks:"bucketFill",type:"elementBackground",label:f("labels.background"),color:o.bucketFill.getBucketFillBackgroundColor(n.currentItemBackgroundColor),onChange:i=>t({currentItemBackgroundColor:i}),elements:e,appState:n,updateData:t})]})}}),g6=O({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,n,t,o)=>(Fe("element","changeFillStyle",`${t} (${o.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),{elements:Ct(e,n,r=>at(r,{fillStyle:t})),appState:{...n,currentItemFillStyle:t},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=ce(e,n),i=r.length>0&&r.every(a=>a.fillStyle==="zigzag");return bt("fieldset",{children:[ee("legend",{children:f("labels.fill")}),ee("div",{className:"buttonList",children:ee(jt,{type:"button",options:[{value:"hachure",text:`${i?f("labels.zigzag"):f("labels.hachure")} (${N("Alt-Click")})`,icon:i?a1:s1,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:f("labels.crossHatch"),icon:l1,testId:"fill-cross-hatch"},{value:"solid",text:f("labels.solid"),icon:c1,testId:"fill-solid"}],value:mt(e,o,a=>a.fillStyle,a=>a.hasOwnProperty("fillStyle"),a=>a?null:n.currentItemFillStyle),onClick:(a,s)=>{let l=s.altKey&&a==="hachure"&&r.every(c=>c.fillStyle==="hachure")?"zigzag":a;t(l)}})})]})}}),f6=e=>q4.find(n=>zy(e.type,n)===e.strokeWidth)??null,E6=(e,n)=>zy(e.type,n),b6=O({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,n,t)=>(Cd(t,"actionChangeStrokeWidth: value must be defined"),{elements:Ct(e,n,o=>at(o,{strokeWidth:E6(o,t)})),appState:{...n,currentItemStrokeWidthKey:t},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>bt("fieldset",{children:[ee("legend",{children:f("labels.strokeWidth")}),ee("div",{className:"buttonList",children:ee(jt,{group:"stroke-width",options:[{value:"thin",text:f("labels.thin"),icon:Xu,testId:"strokeWidth-thin"},{value:"medium",text:f("labels.medium"),icon:d1,testId:"strokeWidth-medium"},{value:"bold",text:f("labels.bold"),icon:m1,testId:"strokeWidth-bold"}],value:mt(e,o,f6,i=>i.hasOwnProperty("strokeWidth"),i=>i?null:n.currentItemStrokeWidthKey),onChange:i=>t(i)})})]})}),x6=O({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>at(o,{seed:J4(),roughness:t})),appState:{...n,currentItemRoughness:t},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>bt("fieldset",{children:[ee("legend",{children:f("labels.sloppiness")}),ee("div",{className:"buttonList",children:ee(jt,{group:"sloppiness",options:[{value:0,text:f("labels.architect"),icon:h1},{value:1,text:f("labels.artist"),icon:g1},{value:2,text:f("labels.cartoonist"),icon:f1}],value:mt(e,o,i=>i.roughness,i=>i.hasOwnProperty("roughness"),i=>i?null:n.currentItemRoughness),onChange:i=>t(i)})})]})}),y6=O({name:"changeFreedrawMode",label:"labels.pressure",trackEvent:!1,perform:(e,n,t)=>{let o=t||"constant";return{elements:Ct(e,n,r=>r.type!=="freedraw"?r:at(r,{strokeOptions:{...r.strokeOptions,variability:o}})),appState:{...n,currentItemStrokeVariability:o},captureUpdate:tt.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=mt(e,o,a=>a.strokeOptions?.variability,a=>a.type==="freedraw",a=>a?null:n.currentItemStrokeVariability)??n.currentItemStrokeVariability;if(r?.cycle){let a=i==="variable";return ee(Z,{type:"button",icon:a?$u:Ku,title:f("labels.pressure"),"aria-label":f("labels.pressure"),onClick:()=>t(a?"constant":"variable")})}return bt("fieldset",{children:[ee("legend",{children:f("labels.pressure")}),ee("div",{className:"buttonList",children:ee(jt,{group:"strokeOptions.variability",options:[{value:"constant",text:f("labels.pressure_constant"),icon:Ku},{value:"variable",text:f("labels.pressure_variable"),icon:$u}],value:i,onChange:a=>t(a)})})]})}}),ane=O({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>at(o,{strokeStyle:t})),appState:{...n,currentItemStrokeStyle:t},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>bt("fieldset",{children:[ee("legend",{children:f("labels.strokeStyle")}),ee("div",{className:"buttonList",children:ee(jt,{group:"strokeStyle",options:[{value:"solid",text:f("labels.strokeStyle_solid"),icon:Xu},{value:"dashed",text:f("labels.strokeStyle_dashed"),icon:p1},{value:"dotted",text:f("labels.strokeStyle_dotted"),icon:u1}],value:mt(e,o,i=>i.strokeStyle,i=>i.hasOwnProperty("strokeStyle"),i=>i?null:n.currentItemStrokeStyle),onChange:i=>t(i)})})]})}),w6=O({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>at(o,{opacity:t}),!0),appState:{...n,currentItemOpacity:t},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=mt(e,t,i=>i.opacity,!0,i=>i?null:n.currentItemOpacity);return ee(Ly,{label:f("labels.opacity"),value:r??n.currentItemOpacity,hasCommonValue:r!==null,onChange:o,min:0,max:100,step:10,testId:"opacity"})}}),v6=O({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,n,t,o)=>Oh(e,n,o,()=>(Cd(t,"actionChangeFontSize: Expected a font size value"),t),t),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=Vr(o);return bt("fieldset",{children:[ee("legend",{children:f("labels.fontSize")}),ee("div",{className:"buttonList",children:ee(jt,{group:"font-size",options:[{value:Id.sm,text:f("labels.small"),icon:R1,testId:"fontSize-small"},{value:Id.md,text:f("labels.medium"),icon:N1,testId:"fontSize-medium"},{value:Id.lg,text:f("labels.large"),icon:B1,testId:"fontSize-large"},{value:Id.xl,text:f("labels.veryLarge"),icon:F1,testId:"fontSize-veryLarge"}],value:mt(e,o,a=>{if(Ht(a))return a.fontSize;let s=sr(a,o.scene.getNonDeletedElementsMap());return s?s.fontSize:null},a=>Ht(a)||sr(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:n.currentItemFontSize||Z4),onChange:a=>{Rs(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),zh=O({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:zr,trackEvent:!1,perform:(e,n,t,o)=>Oh(e,n,o,r=>Math.round(1/(1+Uy)*r.fontSize)),keyTest:e=>e[Zi.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Zi.CHEVRON_LEFT||e.key===Zi.COMMA)}),Gh=O({name:"increaseFontSize",label:"labels.increaseFontSize",icon:zr,trackEvent:!1,perform:(e,n,t,o)=>Oh(e,n,o,r=>Math.round(r.fontSize*(1+Uy))),keyTest:e=>e[Zi.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Zi.CHEVRON_RIGHT||e.key===Zi.PERIOD)}),I6=O({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,n,t,o)=>{let{cachedElements:r,resetAll:i,resetContainers:a,...s}=t;if(i)return{elements:Ct(e,n,g=>{let b=r?.get(g.id);return b?at(g,{...b}):g},!0),appState:{...n,...s},captureUpdate:tt.NEVER};Cd(t,"actionChangeFontFamily: value must be defined");let{currentItemFontFamily:l,currentHoveredFontFamily:c}=t,d=tt.EVENTUALLY,m,p=!1;if(l)m=l,d=tt.IMMEDIATELY;else if(c){m=c,d=tt.EVENTUALLY;let E=ce(e,n,{includeBoundTextElement:!0}).filter(g=>Ht(g));if(E.length>200)p=!0;else{let g=0,b=0;for(;g<E.length&&b<5e3;){let w=E[g];b+=w?.originalText.length||0,g++}b>5e3&&(p=!0)}}let u={appState:{...n,...s},captureUpdate:d};if(m&&!p){let E=new Map,g=new Set,b=!1,w=Array.from(Eo.loadedFontsCache.values()),y=Object.entries(j4).find(([T,C])=>C===m)?.[0];c&&y&&w.some(T=>T.startsWith(y))&&(b=!0),Object.assign(u,{elements:Ct(e,n,T=>{if(Ht(T)&&(T.fontFamily!==m||l)){let C=at(T,{fontFamily:m,lineHeight:e6(m)}),P=r?.get(T.containerId||"")||{},M=o.scene.getContainerElement(T);return a&&M&&P&&o.scene.mutateElement(M,{...P}),b||(g=new Set([...g,...Array.from(C.originalText)])),E.set(C,M),C}return T},!0)});let x=`10px ${Q4({fontFamily:m})}`,I=Array.from(g.values()).join();if(b||window.document.fonts.check(x,I))for(let[T,C]of E)Ys(T,C,o.scene);else window.document.fonts.load(x,I).then(T=>{for(let[C,P]of E){let M=o.scene.getElement(C.id),D=P?o.scene.getElement(P.id):null;M&&Ys(M,D,o.scene)}o.fonts.onLoaded(T)})}return u},PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=Rh(new Map),i=Rh(null),[a,s]=U4({}),l=Rh(!0),{stylesPanelMode:c,isCompact:d}=Vr(t),m=Bh(()=>{let p=(u,E)=>mt(u,t,g=>{if(Ht(g))return g.fontFamily;let b=sr(g,E);return b?b.fontFamily:null},g=>Ht(g)||sr(g,E)!==null,g=>g?null:n.currentItemFontFamily||$4);return a.openPopup==="fontFamily"&&n.openPopup==="fontFamily"?p(Array.from(r.current?.values()??[]),r.current):!a.openPopup&&n.openPopup!=="fontFamily"?p(e,t.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,n,e,t]);return _h(()=>{i.current=m},[m]),_h(()=>{Object.keys(a).length&&(o(a),s({}))},[a]),_h(()=>(l.current=!1,()=>{l.current=!0}),[]),bt(kd,{children:[c==="full"&&ee("legend",{children:f("labels.fontFamily")}),ee(Sy,{isOpened:n.openPopup==="fontFamily",selectedFontFamily:m,hoveredFontFamily:n.currentHoveredFontFamily,compactMode:c!=="full",onSelect:p=>{Rs(()=>{s({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:p}),r.current.clear()},d,!!n.editingTextElement)},onHover:p=>{s({currentHoveredFontFamily:p,cachedElements:new Map(r.current),resetContainers:!0})},onLeave:()=>{s({currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0})},onPopupChange:p=>{if(p){r.current.clear();let{editingTextElement:u}=n;if(u?.type==="text"){let E=t.scene.getElement(u.id);r.current.set(u.id,at(E||u,{},!0))}else{let E=ce(e,n,{includeBoundTextElement:!0});for(let g of E)r.current.set(g.id,at(g,{},!0))}s({...a,openPopup:"fontFamily"})}else{let u={currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0};s({...u}),r.current.clear(),d&&n.editingTextElement&&_s(null)}}})]})}}),T6=O({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,n,t,o)=>({elements:Ct(e,n,r=>{if(Ht(r)){let i=at(r,{textAlign:t});return Ys(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n,currentItemTextAlign:t},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=o.scene.getNonDeletedElementsMap(),{isCompact:a}=Vr(o);return bt("fieldset",{children:[ee("legend",{children:f("labels.textAlign")}),ee("div",{className:"buttonList",children:ee(jt,{group:"text-align",options:[{value:"left",text:f("labels.left"),icon:z1,testId:"align-left"},{value:"center",text:f("labels.center"),icon:G1,testId:"align-horizontal-center"},{value:"right",text:f("labels.right"),icon:H1,testId:"align-right"}],value:mt(e,o,s=>{if(Ht(s))return s.textAlign;let l=sr(s,i);return l?l.textAlign:null},s=>Ht(s)||sr(s,i)!==null,s=>s?null:n.currentItemTextAlign),onChange:s=>{Rs(()=>t(s),a,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),S6=O({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Ct(e,n,r=>{if(Ht(r)){let i=at(r,{verticalAlign:t});return Ys(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=Vr(o);return ee("fieldset",{children:ee("div",{className:"buttonList",children:ee(jt,{group:"text-align",options:[{value:vd.TOP,text:f("labels.alignTop"),icon:ee(U1,{theme:n.theme}),testId:"align-top"},{value:vd.MIDDLE,text:f("labels.centerVertically"),icon:ee(V1,{theme:n.theme}),testId:"align-middle"},{value:vd.BOTTOM,text:f("labels.alignBottom"),icon:ee(W1,{theme:n.theme}),testId:"align-bottom"}],value:mt(e,o,a=>{if(Ht(a)&&a.containerId)return a.verticalAlign;let s=sr(a,o.scene.getNonDeletedElementsMap());return s?s.verticalAlign:null},a=>Ht(a)||sr(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:vd.MIDDLE),onChange:a=>{Rs(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})})}}),sne=O({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>Hy(o)?o:at(o,{roundness:t==="round"?{type:s6(o.type)?Td.ADAPTIVE_RADIUS:Td.PROPORTIONAL_RADIUS}:null})),appState:{...n,currentItemRoundness:t},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,renderAction:r})=>{let a=Ci(Gy(e),n).some(s=>s.roundness?.type===Td.LEGACY);return bt("fieldset",{children:[ee("legend",{children:f("labels.edges")}),bt("div",{className:"buttonList",children:[ee(jt,{group:"edges",options:[{value:"sharp",text:f("labels.sharp"),icon:E1},{value:"round",text:f("labels.round"),icon:b1}],value:mt(e,o,s=>a?null:s.roundness?"round":"sharp",s=>!Sd(s)&&s.hasOwnProperty("roundness"),s=>s?null:n.currentItemRoundness),onChange:s=>t(s)}),r("togglePolygon")]})]})}}),Fy=e=>({visibleSections:[{name:"default",options:[{value:null,text:f("labels.arrowhead_none"),keyBinding:"q",icon:ee(x1,{flip:e})},{value:"arrow",text:f("labels.arrowhead_arrow"),keyBinding:"w",icon:ee(y1,{flip:e})},{value:"triangle",text:f("labels.arrowhead_triangle"),icon:ee(w1,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:f("labels.arrowhead_triangle_outline"),icon:ee(v1,{flip:e}),keyBinding:"r"}]}],hiddenSections:[{name:"default",options:[{value:"circle",text:f("labels.arrowhead_circle"),keyBinding:"a",icon:ee(I1,{flip:e})},{value:"circle_outline",text:f("labels.arrowhead_circle_outline"),keyBinding:"s",icon:ee(T1,{flip:e})},{value:"diamond",text:f("labels.arrowhead_diamond"),icon:ee(S1,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:f("labels.arrowhead_diamond_outline"),icon:ee(C1,{flip:e}),keyBinding:"f"},{value:"bar",text:f("labels.arrowhead_bar"),keyBinding:"z",icon:ee(P1,{flip:e})}]},{name:f("labels.cardinality"),options:[{value:"cardinality_one",text:f("labels.arrowhead_cardinality_one"),icon:ee(k1,{flip:e}),keyBinding:"x"},{value:"cardinality_many",text:f("labels.arrowhead_cardinality_many"),icon:ee(M1,{flip:e}),keyBinding:"c"},{value:"cardinality_one_or_many",text:f("labels.arrowhead_cardinality_one_or_many"),icon:ee(A1,{flip:e}),keyBinding:"v"},{value:"cardinality_exactly_one",text:f("labels.arrowhead_cardinality_exactly_one"),icon:ee(D1,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_one",text:f("labels.arrowhead_cardinality_zero_or_one"),icon:ee(L1,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_many",text:f("labels.arrowhead_cardinality_zero_or_many"),icon:ee(_1,{flip:e}),keyBinding:null}]}]}),lne=O({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,n,t)=>(Cd(t,"actionChangeArrowhead: value must be defined"),{elements:Ct(e,n,o=>{if(Nh(o)){let{position:r,type:i}=t;if(r==="start")return at(o,{startArrowhead:i});if(r==="end")return at(o,{endArrowhead:i})}return o}),appState:{...n,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=Kn().rtl,i=Bh(()=>Fy(!r),[r]),a=Bh(()=>Fy(!!r),[r]);return bt("fieldset",{children:[ee("legend",{children:f("labels.arrowheads")}),bt("div",{className:"iconSelectList buttonList",children:[ee(Dh,{visibleSections:i.visibleSections,hiddenSections:i.hiddenSections,label:"arrowhead_start",value:mt(e,o,s=>Nh(s)&&Es(s.type)?Ny(s.startArrowhead):n.currentItemStartArrowhead,!0,s=>s?null:n.currentItemStartArrowhead),onChange:s=>t({position:"start",type:s})}),ee(Dh,{visibleSections:a.visibleSections,hiddenSections:a.hiddenSections,label:"arrowhead_end",value:mt(e,o,s=>Nh(s)&&Es(s.type)?Ny(s.endArrowhead):n.currentItemEndArrowhead,!0,s=>s?null:n.currentItemEndArrowhead),onChange:s=>t({position:"end",type:s})})]})]})}}),C6=O({name:"changeArrowProperties",label:"Change arrow properties",trackEvent:!1,perform:(e,n,t,o)=>!1,PanelComponent:({elements:e,appState:n,updateData:t,app:o,renderAction:r})=>bt("div",{className:"selected-shape-actions",children:[r("changeArrowhead"),r("changeArrowType")]})}),cne=O({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,n,t,o)=>{let r=Ct(e,n,s=>{if(!Sd(s))return s;let l=o.scene.getNonDeletedElementsMap(),c=Wr.getPointAtIndexGlobalCoordinates(s,0,l),d=Wr.getPointAtIndexGlobalCoordinates(s,-1,l),m=at(s,{x:t===dn.elbow?c[0]:s.x,y:t===dn.elbow?c[1]:s.y,roundness:t===dn.round?{type:Td.PROPORTIONAL_RADIUS}:null,elbowed:t===dn.elbow,angle:t===dn.elbow?0:s.angle,points:t===dn.elbow||s.elbowed?[Wr.pointFromAbsoluteCoords({...s,x:c[0],y:c[1],angle:0},c,l),Wr.pointFromAbsoluteCoords({...s,x:c[0],y:c[1],angle:0},d,l)]:s.points});if(Hy(m)){m.fixedSegments=null;let p=o.scene.getNonDeletedElementsMap();o.dismissLinearEditor();let u=Wr.getPointAtIndexGlobalCoordinates(m,0,p),E=Wr.getPointAtIndexGlobalCoordinates(m,-1,p),g=m.startBinding&&p.get(m.startBinding.elementId),b=m.endBinding&&p.get(m.endBinding.elementId),w=g&&m.startBinding?{...m.startBinding,...Ry(m,g,"start",p,n.isBindingEnabled)}:null,y=b&&m.endBinding?{...m.endBinding,...Ry(m,b,"end",p,n.isBindingEnabled)}:null;m={...m,startBinding:w,endBinding:y,...c6(m,p,{points:[u,E].map(x=>H4(x[0]-m.x,x[1]-m.y)),startBinding:w,endBinding:y,fixedSegments:null})}}else{let p=o.scene.getNonDeletedElementsMap();if(m.startBinding){let u=p.get(m.startBinding.elementId);u&&_y(m,u,n.bindMode==="inside"?"inside":"orbit","start",o.scene)}if(m.endBinding){let u=p.get(m.endBinding.elementId);u&&_y(m,u,n.bindMode==="inside"?"inside":"orbit","end",o.scene)}}return m}),i={...n,currentItemArrowType:t},a=n.selectedLinearElement?.elementId;if(a){let s=r.find(l=>l.id===a);s&&(i.selectedLinearElement=new Wr(s,Fh(e)))}return{elements:r,appState:i,captureUpdate:tt.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>bt("fieldset",{children:[ee("legend",{children:f("labels.arrowtypes")}),ee("div",{className:"buttonList",children:ee(jt,{group:"arrowtypes",options:[{value:dn.sharp,text:f("labels.arrowtype_sharp"),icon:qo,testId:"sharp-arrow"},{value:dn.round,text:f("labels.arrowtype_round"),icon:Qo,testId:"round-arrow"},{value:dn.elbow,text:f("labels.arrowtype_elbowed"),icon:Jo,testId:"elbow-arrow"}],value:mt(e,o,r=>Sd(r)?r.elbowed?dn.elbow:r.roundness?dn.round:dn.sharp:null,r=>Sd(r),r=>r?null:n.currentItemArrowType),onChange:r=>t(r)})})]})});import{DEFAULT_CANVAS_BACKGROUND_PICKS as _6,MAX_ZOOM as R6,MIN_ZOOM as N6,THEME as Xs,ZOOM_STEP as Yy,CODES as Yr,KEYS as Ad}from"@excalidraw/common";import{getNonDeletedElements as Ks}from"@excalidraw/element";import{getCommonBounds as $s}from"@excalidraw/element";import{CaptureUpdateAction as Ji}from"@excalidraw/element";import{useEffect as P6}from"react";import{jsx as M6}from"react/jsx-runtime";var ji=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let n=document.createElement("div");return document.body.appendChild(n),n.classList.add("excalidraw-tooltip"),n},Hh=(e,n,t="bottom")=>{let o=e.getBoundingClientRect(),r=window.innerWidth,i=window.innerHeight,a=5,s=n.left+n.width/2-o.width/2;s<0?s=a:s+o.width>=r&&(s=r-o.width-a);let l;t==="bottom"?(l=n.top+n.height+a,l+o.height>=i&&(l=n.top-o.height-a)):(l=n.top-o.height-a,l<0&&(l=n.top+n.height+a)),Object.assign(e.style,{top:`${l}px`,left:`${s}px`})},k6=(e,n,t,o)=>{n.classList.add("excalidraw-tooltip--visible"),n.style.minWidth=o?"50ch":"10ch",n.style.maxWidth=o?"50ch":"15ch",n.textContent=t;let r=e.getBoundingClientRect();Hh(n,r)},pt=({children:e,label:n,long:t=!1,style:o,disabled:r})=>(P6(()=>()=>ji().classList.remove("excalidraw-tooltip--visible"),[]),r?null:M6("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>k6(i.currentTarget,ji(),n,t),onPointerLeave:()=>ji().classList.remove("excalidraw-tooltip--visible"),style:o,children:e}));import{useEffect as Wy,useRef as Vy,useState as A6}from"react";var D6=(e,n)=>typeof n=="function"?n(e):Array.isArray(n)?e:e[n],Uh=(e,n,t)=>{if(e?.isDestroyed)return;let o=e?.getAppState();if(!o){if(!t)return;console.warn("useAppStateValue: excalidrawAPI not defined yet for internal component while it should always be defined. Are you sure you're rendering inside of <Excalidraw/> component tree?"),o=Object.assign({width:0,height:0,offsetLeft:0,offsetTop:0},Xo())}return D6(o,n)};function qi(e,n=!0){let t=Md(),[,o]=A6(0),r=Vy(null);return r.current||(r.current={selector:e,isInitialized:!!t,latestValue:Uh(t,e,n)}),r.current.selector=e,!r.current.isInitialized&&t&&!t.isDestroyed&&(r.current.isInitialized=!0,r.current.latestValue=Uh(t,e,n)),Wy(()=>{let i=r.current;if(!(!t||t.isDestroyed||!i))return t.onStateChange(i.selector,a=>{i.latestValue=a,o(s=>s+1)})},[t]),r.current.latestValue}function L6(e,n){let t=Md(),o=Vy({selector:e,callback:n});o.current.selector=e,o.current.callback=n,Wy(()=>{if(!(!t||t.isDestroyed))return o.current.callback(Uh(t,o.current.selector,!0),t.getAppState()),t.onStateChange(o.current.selector,(r,i)=>{o.current.callback(r,i)})},[t])}import{jsx as Nd,jsxs as O6}from"react/jsx-runtime";var B6=O({name:"changeViewBackgroundColor",label:"labels.canvasBackground",trackEvent:!1,predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.changeViewBackgroundColor&&!n.viewModeEnabled,perform:(e,n,t)=>({appState:{...n,...t},captureUpdate:t?.viewBackgroundColor?Ji.IMMEDIATELY:Ji.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,appProps:o,data:r})=>Nd(Xi,{palette:null,topPicks:_6,label:f("labels.canvasBackground"),type:"canvasBackground",color:n.viewBackgroundColor,onChange:i=>t({viewBackgroundColor:i}),"data-testid":"canvas-background-picker",elements:e,appState:n,updateData:t})}),Dd=O({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,navigation:!0,icon:Mu,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...fo({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:Yn(n.zoom.value+Yy)},n)},captureUpdate:Ji.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=qi(t=>t.zoom.value);return Nd(Z,{type:"button",className:"zoom-in-button zoom-button",icon:Mu,title:`${f("buttons.zoomIn")} \u2014 ${N("CtrlOrCmd++")}`,"aria-label":f("buttons.zoomIn"),disabled:n>=R6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===Yr.EQUAL||e.code===Yr.NUM_ADD)&&(e[Ad.CTRL_OR_CMD]||e.shiftKey)}),Ld=O({name:"zoomOut",label:"buttons.zoomOut",icon:Au,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...fo({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:Yn(n.zoom.value-Yy)},n)},captureUpdate:Ji.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=qi(t=>t.zoom.value);return Nd(Z,{type:"button",className:"zoom-out-button zoom-button",icon:Au,title:`${f("buttons.zoomOut")} \u2014 ${N("CtrlOrCmd+-")}`,"aria-label":f("buttons.zoomOut"),disabled:n<=N6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===Yr.MINUS||e.code===Yr.NUM_SUBTRACT)&&(e[Ad.CTRL_OR_CMD]||e.shiftKey)}),_d=O({name:"resetZoom",label:"buttons.resetZoom",icon:Ux,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=n.scrollConstraints?.lockZoom?n.scrollConstraints.zoom:1;return{appState:{...n,...fo({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:Yn(r)},n)},captureUpdate:Ji.EVENTUALLY}},PanelComponent:({updateData:e})=>{let n=qi(t=>t.zoom.value);return Nd(pt,{label:f("buttons.resetZoom"),style:{height:"100%"},children:O6(Z,{type:"button",className:"reset-zoom-button zoom-button",title:f("buttons.resetZoom"),"aria-label":f("buttons.resetZoom"),onClick:()=>{e(null)},children:[(n*100).toFixed(0),"%"]})})},keyTest:e=>(e.code===Yr.ZERO||e.code===Yr.NUM_ZERO)&&(e[Ad.CTRL_OR_CMD]||e.shiftKey)}),Wh=e=>[e.x,e.y,e.x+e.width,e.y+e.height],Gne=O({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:Xc,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=o.scene.getSelectedElements(n),i=r.length?$s(Ks(r)):n.scrollConstraints?Wh(n.scrollConstraints):$s(Ks(e)),a=_r({bounds:i,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...Vn(a.appState)}}},keyTest:void 0}),Hne=O({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:Xc,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=o.scene.getSelectedElements(n),i=r.length?$s(Ks(r)):n.scrollConstraints?Wh(n.scrollConstraints):$s(Ks(e)),a=_r({bounds:i,appState:n,fit:"contain",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...Vn(a.appState)}}},keyTest:void 0}),F6=O({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:Xc,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=n.scrollConstraints?Wh(n.scrollConstraints):$s(Ks(e)),i=_r({bounds:r,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...i,appState:{...i.appState,...Vn(i.appState)}}},keyTest:void 0}),Rd=O({name:"toggleTheme",label:(e,n)=>n.theme===Xs.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:(e,n)=>e.theme===Xs.LIGHT?Cs:Ps,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=t||(n.theme===Xs.LIGHT?Xs.DARK:Xs.LIGHT);return o.props.onThemeChange?(o.props.onThemeChange(r),!1):{appState:{...n,theme:r},captureUpdate:Ji.EVENTUALLY}},keyTest:e=>!e[Ad.CTRL_OR_CMD]&&e.altKey&&e.shiftKey&&e.code===Yr.D,predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.toggleTheme});import{pointFrom as K6}from"@excalidraw/math";import{bindOrUnbindBindingElement as nw}from"@excalidraw/element/binding";import{isValidPolygon as ow,newElementWith as Xh}from"@excalidraw/element";import{LinearElementEditor as Qs}from"@excalidraw/element/linearElementEditor";import{isBindingElement as Kh,isFreeDrawElement as rw,isLinearElement as iw,isLineElement as Ud}from"@excalidraw/element";import{KEYS as Wd,arrayToMap as $6,invariant as aw,shouldRotateWithDiscreteAngle as Z6,updateActiveTool as sw}from"@excalidraw/common";import{isPathALoop as j6}from"@excalidraw/element";import{isInvisiblySmallElement as $h}from"@excalidraw/element";import{CaptureUpdateAction as Zh}from"@excalidraw/element";import U6 from"clsx";import{useEffect as W6,useState as V6}from"react";import{KEYS as mn,capitalizeString as Xr}from"@excalidraw/common";import{useEffect as z6,useState as G6}from"react";import Xy from"clsx";import{capitalizeString as Bd}from"@excalidraw/common";import{Popover as Vh}from"radix-ui";import{jsx as Fd,jsxs as H6}from"react/jsx-runtime";var Qi=({app:e,options:n,activeTool:t,defaultOption:o,"data-testid":r,onToolChange:i,displayedOption:a})=>{let[s,l]=G6(!1),c=t.type,d=a.type===c,m=16,{container:p}=Ne();return!n.some(u=>u.type===c)&&s&&l(!1),z6(()=>{let u=e.onPointerDownEmitter.on(()=>{l(!1)});return()=>u?.()},[e]),H6(Vh.Root,{open:s,children:[Fd(Vh.Trigger,{asChild:!0,children:Fd(Z,{className:Xy({fillable:a.fillable}),type:"toggle",icon:a.icon,checked:d,disabled:n.every(u=>Je(e,u.type)),title:Bd(a.title),"aria-label":Bd(a.title),"data-testid":r,onSelect:()=>{l(u=>!u),i(o)}})}),Fd(Vh.Content,{className:"tool-popover-content",sideOffset:m,collisionBoundary:p??void 0,children:n.map(({type:u,icon:E,title:g,fillable:b})=>Fd(Z,{className:Xy({fillable:b}),type:"toggle",icon:E,checked:c===u,disabled:Je(e,u),title:Bd(u),"aria-label":Bd(u),"data-testid":`toolbar-${u}`,onSelect:()=>{e.state.activeTool.type!==u&&(Fe("toolbar",u,"ui"),e.setActiveTool({type:u}),i?.(u))}},u))})]})};import{jsx as Yh}from"react/jsx-runtime";var Y6=e=>e,Ye=Y6({hand:{icon:Y1,letterKey:mn.H,toggle:!0},selection:{icon:Oc,letterKey:mn.V,fillable:!0},rectangle:{icon:_i,letterKey:mn.R,fillable:!0},diamond:{icon:Ri,letterKey:mn.D,fillable:!0},ellipse:{icon:Ni,letterKey:mn.O,fillable:!0},arrow:{icon:zc,letterKey:mn.A,fillable:!0},line:{icon:$o,letterKey:mn.L,fillable:!0},freedraw:{icon:$n,letterKey:mn.P},text:{icon:Pn,letterKey:mn.T},image:{icon:Fr},eraser:{icon:Gc,letterKey:mn.E,toggle:!0},frame:{icon:jn,letterKey:mn.F},autoshape:{icon:Gr,letterKey:mn.X,fillable:!1},embeddable:{icon:Zo},laser:{icon:qn},bucketfill:{icon:Zn},lasso:{icon:Li,fillable:!1}});var ea=["autoshape","rectangle","diamond","ellipse","arrow","line"],ta=Object.keys(Ye).filter(e=>Ye[e].toggle),Od=e=>{let{letterKey:n,shiftKey:t}=Ye[e];if(!n)return n;let o=Xr(typeof n=="string"?n:n[0]);return t?N(`Shift+${o}`):o},na=e=>Od(e),X6=e=>{let n=Od(e);return n?.length===1?n:void 0},Ky=(e,n,t=!1)=>{let o=e.toLowerCase();for(let r of Object.keys(Ye)){let{letterKey:i,shiftKey:a}=Ye[r];if(t===!!a&&i&&(typeof i=="string"?i===o:i.includes(o)))return r==="selection"?n.state.preferredSelectionTool.type:r}return null},Je=(e,n)=>e.props.activeTool!=null&&e.props.activeTool.type!==n,Ut=(e,n)=>{let t=Ye[e],o=n?.shortcutType??e,r=({app:i,activeTool:a,hideKeyBinding:s,hideShortcut:l})=>{let c=Xr(f(`toolBar.${e}`)),d=l?null:na(o);return Yh(Z,{className:U6({fillable:t.fillable}),type:"toggle",icon:t.icon,checked:a.type===e,disabled:Je(i,e),title:d?`${c} \u2014 ${d}`:c,keyBindingLabel:s||l?void 0:X6(o),"aria-label":c,"aria-keyshortcuts":d??void 0,"data-testid":`toolbar-${e}`,onSelect:({pointerType:m})=>{if(!i.state.penDetected&&m==="pen"&&i.togglePenMode(!0),n?.onSelect){n.onSelect(i,{pointerType:m});return}i.state.activeTool.type!==e&&(Fe("toolbar",e,"ui"),i.setActiveTool({type:e}))}})};return r.displayName=`${Xr(e)}IconButton`,r},zd=Ut("hand"),$y=Ut("rectangle"),Zy=Ut("diamond"),jy=Ut("ellipse"),qy=Ut("arrow"),Jy=Ut("line"),Zs=Ut("freedraw"),js=Ut("text"),qs=Ut("image"),Js=Ut("eraser"),Qy=Ut("frame"),goe=Ut("autoshape"),ew=Ut("selection",{onSelect:(e,{pointerType:n})=>{if(e.state.activeTool.type==="selection"&&n!==null){e.setActiveTool({type:"lasso"});return}e.state.activeTool.type!=="selection"&&(Fe("toolbar","selection","ui"),e.setActiveTool({type:"selection"}))}}),tw=Ut("lasso",{shortcutType:"selection"}),Gd=({app:e,activeTool:n,setAppState:t})=>{let o=[{type:"selection",icon:Ye.selection.icon,fillable:Ye.selection.fillable,title:Xr(f("toolBar.selection"))},{type:"lasso",icon:Ye.lasso.icon,fillable:Ye.lasso.fillable,title:Xr(f("toolBar.lasso"))}],r=o.find(i=>i.type===e.state.preferredSelectionTool.type)||o[0];return Yh(Qi,{app:e,options:o,activeTool:n,defaultOption:e.state.preferredSelectionTool.type,"data-testid":"toolbar-selection",onToolChange:i=>{(i==="selection"||i==="lasso")&&(e.setActiveTool({type:i}),t({preferredSelectionTool:{type:i,initialized:!0}}))},displayedOption:r})},Hd=({app:e,activeTool:n})=>{let t=[{type:"freedraw",icon:Ye.freedraw.icon,fillable:Ye.freedraw.fillable,title:Xr(f("toolBar.freedraw"))},{type:"autoshape",icon:Ye.autoshape.icon,fillable:Ye.autoshape.fillable,title:Xr(f("toolBar.autoshape"))}],[o,r]=V6(n.type==="autoshape"?"autoshape":"freedraw");W6(()=>{(n.type==="freedraw"||n.type==="autoshape")&&r(n.type)},[n.type]);let i=t.find(a=>a.type===o)||t[0];return Yh(Qi,{app:e,options:t,activeTool:n,defaultOption:o,"data-testid":"toolbar-freedraw",onToolChange:a=>{(a==="freedraw"||a==="autoshape")&&(r(a),e.setActiveTool({type:a}))},displayedOption:i})};import{jsx as q6}from"react/jsx-runtime";var ut=O({name:"finalize",label:"",trackEvent:!1,perform:(e,n,t,o)=>{let r=!0,i=e,{focusContainer:a,scene:s}=o,l=s.getNonDeletedElementsMap(),c=n.activeTool.type==="autoshape";if(t&&n.selectedLinearElement){let{event:b,sceneCoords:w}=t,y=Qs.getElement(n.selectedLinearElement.elementId,l);aw(y,"Arrow element should exist if selectedLinearElement is set"),aw(w,"sceneCoords should be defined if actionFinalize is called with event");let x=Qs.handlePointerUp(b,n.selectedLinearElement,n,o.scene);if(Kh(y)&&!n.selectedLinearElement.segmentMidPointHoveredCoords){let I=!!n.newElement,T=I||!n.selectedLinearElement.selectedPointsIndices?[y.points.length-1]:n.selectedLinearElement.selectedPointsIndices,C=Z6(b),P=b[Wd.CTRL_OR_CMD]?null:o.getEffectiveGridSize(),M=T.reduce((D,_)=>(D.set(_,{point:C?y.points[_]:Qs.createPointAt(y,l,w.x-x.pointerOffset.x,w.y-x.pointerOffset.y,P)}),D),new Map)??new Map;nw(y,M,w.x,w.y,s,n,{newArrow:I,altKey:b.altKey,angleLocked:C,gridSize:o.getEffectiveGridSize()})}else Ud(y)&&n.selectedLinearElement?.isEditing&&!n.newElement&&!ow(y.points)&&s.mutateElement(y,{polygon:!1});if(x!==n.selectedLinearElement){y&&$h(y)&&(i=i.map(T=>T.id===y.id?Xh(T,{isDeleted:!0}):T));let I=n.activeTool?.locked;return{elements:y.points.length<2||$h(y)?e.map(T=>T.id===y.id?Xh(T,{isDeleted:!0}):T):i,appState:{...n,cursorButton:"up",selectedElementIds:c?{}:n.selectedElementIds,selectedLinearElement:I||c?null:{...x,selectedPointsIndices:null,isEditing:!1,initialState:{...x.initialState,lastClickedPoint:-1},pointerOffset:{x:0,y:0}},selectionElement:null,suggestedBinding:null,hoveredArrowTextAnchor:null,newElement:null,multiElement:null},captureUpdate:Zh.IMMEDIATELY}}}window.document.activeElement instanceof HTMLElement&&a();let d=o.drawShape.hasPendingGesture();(d||c)&&(o.drawShape.finalize(),d&&(i=o.scene.getElementsIncludingDeleted()));let m=null;if(n.multiElement)m=n.multiElement;else if(!c&&!d&&(n.newElement?.type==="freedraw"||Kh(n.newElement)))m=n.newElement;else if(Object.keys(n.selectedElementIds).length===1){let b=l.get(Object.keys(n.selectedElementIds)[0]);b&&(m=b)}if(m){if(n.selectedLinearElement&&n.multiElement&&m.type!=="freedraw"&&n.lastPointerDownWith!=="touch"){let{points:b}=m,{lastCommittedPoint:w}=n.selectedLinearElement;if((!w||b[b.length-1]!==w)&&(r=!1,s.mutateElement(m,{points:m.points.slice(0,-1)}),Kh(m)&&m.endBinding&&m.points.length>1)){let y=!!n.newElement,x=new Map([[m.points.length-1,{point:m.points[m.points.length-1],isDragging:!1}]]),I=Qs.getPointAtIndexGlobalCoordinates(m,-1,l);nw(m,x,I[0],I[1],s,n,{newArrow:y})}}if(m&&$h(m)&&(i=i.map(b=>b.id===m?.id?Xh(b,{isDeleted:!0}):b)),iw(m)||rw(m)){if(j6(m.points,n.zoom.value)&&(Ud(m)||rw(m))){let w=m.points,y=w[0],x=w.map((I,T)=>T===w.length-1?K6(y[0],y[1]):I);Ud(m)?s.mutateElement(m,{points:x,polygon:!0}):s.mutateElement(m,{points:x})}Ud(m)&&!ow(m.points)&&s.mutateElement(m,{polygon:!1})}}let p;ta.includes(n.activeTool.type)?p=sw(n,{...n.activeTool.lastActiveTool||{type:o.state.preferredSelectionTool.type},lastActiveTool:null}):p=sw(n,{type:o.state.preferredSelectionTool.type});let u=o.isToolLocked(),E=n.activeTool.type==="autoshape"||(u||n.activeTool.type==="freedraw")&&!!m;E||o.cursor.applyForTool(p);let g=m&&iw(m)?new Qs(m,$6(i)):n.selectedLinearElement;return g=g&&{...g,isEditing:n.newElement?!1:g.isEditing,initialState:{...g.initialState,lastClickedPoint:-1,origin:null}},{elements:i,appState:{...n,cursorButton:"up",activeTool:E?n.activeTool:p,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null,selectedElementIds:c?{}:m&&!u&&n.activeTool.type!=="freedraw"?{...n.selectedElementIds,[m.id]:!0}:n.selectedElementIds,selectedLinearElement:c?null:g},captureUpdate:r?Zh.IMMEDIATELY:Zh.NEVER}},keyTest:(e,n)=>e.key===Wd.ESCAPE&&n.selectedLinearElement?.isEditing||(e.key===Wd.ESCAPE||e.key===Wd.ENTER)&&n.multiElement!==null,PanelComponent:({appState:e,updateData:n,data:t})=>q6(Z,{type:"button",icon:Qx,title:f("buttons.done"),"aria-label":f("buttons.done"),onClick:n,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import{getElementsInGroup as dw,isSomeElementSelected as J6,makeNextSelectedElementIds as Q6,selectGroupsForSelectedElements as eD}from"@excalidraw/element";import{CaptureUpdateAction as lw}from"@excalidraw/element";import{KEYS as tD,isWritableElement as nD,updateActiveTool as cw}from"@excalidraw/common";var oD=(e,n)=>ta.includes(e.activeTool.type)?cw(e,{...e.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveTool:null}):cw(e,{type:n.state.preferredSelectionTool.type}),rD=(e,n,t)=>{if(!e.editingGroupId)return null;let o=n.scene.getNonDeletedElements(),r=n.scene.getSelectedElements({selectedElementIds:t,elements:o}),i=r.length?r:dw(o,e.editingGroupId);for(let a of i){let s=a.groupIds.indexOf(e.editingGroupId);if(s!==-1&&a.groupIds[s+1])return a.groupIds[s+1]}return null},iD=O({name:"deselect",label:"",trackEvent:!1,perform:(e,n,t,o)=>{let r=oD(n,o);if(o.cursor.applyForTool(r),n.editingGroupId){let i=o.scene.getNonDeletedElements(),a=Object.keys(n.selectedElementIds).length>0?n.selectedElementIds:dw(i,n.editingGroupId).reduce((s,l)=>(s[l.id]=!0,s),{});return{appState:{...n,...eD({editingGroupId:rD(n,o,a),selectedElementIds:a},i,n,o),activeEmbeddable:null,activeTool:r,selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null},captureUpdate:lw.IMMEDIATELY}}return{appState:{...n,activeEmbeddable:null,activeTool:r,editingGroupId:null,selectedElementIds:Q6({},n),selectedGroupIds:{},selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null},captureUpdate:lw.IMMEDIATELY}},keyTest:(e,n,t,o)=>e.key!==tD.ESCAPE||nD(e.target)?!1:!n.newElement&&n.multiElement===null&&!n.selectedLinearElement?.isEditing&&(n.activeEmbeddable!==null||n.activeTool.type!==o.state.preferredSelectionTool.type||!!n.editingGroupId||!!n.selectedLinearElement||J6(o.scene.getNonDeletedElements(),n))});import{KEYS as Jd,THEME as ol}from"@excalidraw/common";import{CaptureUpdateAction as Mn}from"@excalidraw/element";import aD from"clsx";import{jsx as mw,jsxs as sD}from"react/jsx-runtime";var jh=({children:e,checked:n,onChange:t,className:o})=>sD("div",{className:aD("Checkbox",o,{"is-checked":n}),onClick:r=>{t(!n,r),r.currentTarget.querySelector(".Checkbox-box").focus()},children:[mw("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":n,children:Hc}),mw("div",{className:"Checkbox-label",children:e})]});import{THEME as el}from"@excalidraw/common";import{jsx as tl}from"react/jsx-runtime";var uw=e=>{let n=e.title||(e.value===el.DARK?f("buttons.lightMode"):f("buttons.darkMode"));return tl(Z,{type:"icon",icon:e.value===el.LIGHT?pw.MOON:pw.SUN,title:n,"aria-label":n,onClick:()=>e.onChange(e.value===el.DARK?el.LIGHT:el.DARK),"data-testid":"toggle-dark-mode"})},pw={SUN:tl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:tl("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:tl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:tl("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 lD}from"react";import{focusNearestParent as cD,KEYS as dD}from"@excalidraw/common";import{jsx as hw,jsxs as mD}from"react/jsx-runtime";var gw=e=>{let{id:n}=Ne(),[t,o]=lD(e.value),r=a=>{e.ignoreFocus||cD(a.target);let s=a.target.value;s!==e.value&&e.onChange(s)},i=a=>{if(a.key===dD.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return mD("div",{className:"ProjectName",children:[hw("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),hw("input",{type:"text",className:"TextInput",onBlur:r,onKeyDown:i,id:`${n}-filename`,value:t,onChange:a=>o(a.target.value)})]})};import{useCallback as pD,useEffect as uD,useRef as hD}from"react";import{jsx as Vd,jsxs as bD}from"react/jsx-runtime";var gD=5e3,fD=({progress:e})=>Vd("div",{className:"Toast__progress-bar",children:Vd("div",{className:"Toast__progress-bar-fill",style:{width:`${Math.min(5,Math.round(e*100))}%`}})}),ED=({message:e,onClose:n,closable:t=!1,duration:o=gD,style:r})=>{let i=hD(0),a=o!==1/0,s=pD(()=>{a&&(i.current=window.setTimeout(()=>n(),o))},[n,o,a]);return uD(()=>{if(a)return s(),()=>clearTimeout(i.current)},[s,e,o,a]),bD("div",{className:"Toast",role:"status",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?s:void 0,style:r,children:[Vd("div",{className:"Toast__message",children:e}),t&&Vd(Z,{icon:an,"aria-label":"close",type:"icon",onClick:n,className:"close"})]})},Yd=Object.assign(ED,{ProgressBar:fD});import{DEFAULT_EXPORT_PADDING as BD,DEFAULT_FILENAME as FD,IMAGE_MIME_TYPES as ww,isFirefox as OD,MIME_TYPES as zD,cloneJSON as GD,SVG_DOCUMENT_PREAMBLE as HD,arrayToMap as UD}from"@excalidraw/common";import{getNonDeletedElements as WD}from"@excalidraw/element";import{isFrameLikeElement as VD}from"@excalidraw/element";import{getElementsOverlappingFrame as YD}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as xD,EXPORT_DATA_TYPES as nl,MIME_TYPES as ht,arrayToMap as yD,isMemberOf as wD,isPromiseLike as vD,EVENT as Xd}from"@excalidraw/common";import{mutateElement as ID}from"@excalidraw/element";import{deepCopyElement as TD}from"@excalidraw/element";import{isFrameLikeElement as SD,isInitializedImageElement as CD}from"@excalidraw/element";import{getContainingFrame as fw}from"@excalidraw/element";var _re="clipboard"in navigator&&"readText"in navigator.clipboard,Kd="clipboard"in navigator&&"writeText"in navigator.clipboard,lr="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,PD=e=>!!([nl.excalidraw,nl.excalidrawClipboard,nl.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),Ew=({types:e,files:n})=>{!e&&!n&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent(Xd.PASTE,{clipboardData:new DataTransfer});if(e)for(let[o,r]of Object.entries(e)){if(typeof r!="string"){n=n||[],n.push(r);continue}try{if(t.clipboardData?.items.add(r,o),t.clipboardData?.getData(o)!==r)throw new Error(`Failed to set "${o}" as clipboardData item`)}catch(i){throw new Error(i.message)}}if(n){let o=-1;for(let r of n){o++;try{if(t.clipboardData?.items.add(r),t.clipboardData?.files[o]!==r)throw new Error(`Failed to set file "${r.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return t},kD=({elements:e,files:n})=>{let t=yD(e),o=new Set(e.filter(s=>SD(s))),r=!1,i=e.reduce((s,l)=>(CD(l)&&(r=!0,n&&n[l.fileId]&&(s[l.fileId]=n[l.fileId])),s),{});r&&!n&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:nl.excalidrawClipboard,elements:e.map(s=>{if(fw(s,t)&&!o.has(fw(s,t))){let l=TD(s);return ID(l,t,{frameId:null}),l}return s}),files:n?i:void 0};return JSON.stringify(a)},$d=async(e,n,t)=>{let o=kD({elements:e,files:n});await To({[ht.excalidrawClipboard]:o,[ht.text]:o},t)};function bw(e){let n=[];for(let t of e.childNodes)if(t.nodeType===3){let o=t.textContent?.trim();o&&n.push({type:"text",value:o})}else if(t instanceof HTMLImageElement){let o=t.getAttribute("src");o&&o.startsWith("http")&&n.push({type:"imageUrl",value:o})}else n=n.concat(bw(t));return n}var MD=e=>{let n=e.value;try{let t=new DOMParser().parseFromString(n,ht.html),o=bw(t.body);if(o.length)return{type:"mixedContent",value:o}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},xw=async()=>{let e={},n;try{n=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 o=await navigator.clipboard?.readText();if(o)return{[ht.text]:o}}}catch(o){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${o.message}). Failling back to navigator.clipboard.read()`);else{if(o.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${o.message}`),e;throw o}}throw t}for(let t of n)for(let o of t.types)if(wD(xD,o))try{if(o===ht.text||o===ht.html)e[o]=await(await t.getType(o)).text();else if(bx(o)){let r=await t.getType(o),i=Sx(r,o,void 0);e[o]=i}else throw new Tu(`Unsupported clipboard type: ${o}`)}catch(r){console.warn(r instanceof Tu?r.message:`Cannot retrieve ${o} from clipboardItem: ${r.message}`)}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},AD=async(e,n=!1)=>{try{let t=e.findByType(ht.html),o=!n&&t&&MD(t);return o?o.value.every(r=>r.type==="text")?{type:"text",value:e.getData(ht.text)??o.value.map(r=>r.value).join(`
2
+ `).trim()}:o:{type:"text",value:(e.getData(ht.text)||"").trim()}}catch{return{type:"text",value:""}}},DD=function(e){return this.find(n=>n.type===e)||null},LD=function(e){return this.find(t=>t.type===e)?.value??null},_D=function(){return this.filter(e=>e.kind==="file")},qh=e=>{let n=Jh(e)?e.clipboardData:e.dataTransfer,t=Array.from(n?.types??[]),o=Array.from(new Set([...t.filter(i=>i!=="Files"),ht.text,ht.html,"text/uri-list","public.url","public.plain-text","text/x-moz-url"])),r={};for(let i of o)try{let a=n?.getData(i);a&&(r[i]=a)}catch{}return{items:Array.from(n?.items??[]).map(i=>({kind:i.kind,type:i.type})),files:Array.from(n?.files??[]).map(i=>({name:i.name,type:i.type,size:i.size,lastModified:i.lastModified})),types:t,data:r}},RD=e=>e.map(n=>n.kind==="string"?{kind:n.kind,type:n.type,value:n.value}:{kind:n.kind,type:n.type,file:{name:n.file.name,type:n.file.type,size:n.file.size,lastModified:n.file.lastModified}}),Zd=(e,n,t)=>{let o=[],r=[],i=[],a=(u,E)=>{let g=E?.trim();g&&!u.includes(g)&&u.push(g)},s=(u,E)=>{E.split(/\r?\n/).map(g=>g.trim()).filter(g=>g&&!g.startsWith("#")).forEach(g=>a(u,g))};e.forEach(u=>{if(u.kind==="string")if(u.type===ht.html)try{let E=new DOMParser().parseFromString(u.value,ht.html);for(let g of Array.from(E.body.querySelectorAll("img")))a(o,g.getAttribute("src")),a(i,g.getAttribute("alt"))}catch{}else u.type===ht.text?a(r,u.value):u.type==="text/uri-list"&&s(r,u.value)});let l=[...o,...r.filter(u=>!o.includes(u))],c=Array.from({length:n},()=>({})),d={...t??{items:[],files:[],types:[],data:{}},parsedItems:RD(e)};c.forEach((u,E)=>{let g=l[E],b=i[E];g&&(u.src=g),b&&(u.alt=b),u.rawDragData=d});let m=l.slice(c.length),p=c[0];return p&&m.length>0&&m.forEach((u,E)=>{p[`additionalUrl${E+1}`]=u}),c},yw=e=>{let n;Jh(e)?n=e.clipboardData?.items:n=e.dataTransfer?.items;let t=new Set;for(let o of Array.from(n||[]))t.has(o.type)||t.add(o.type);return t},Kr=async e=>{let n;Jh(e)?n=e.clipboardData?.items:n=e.dataTransfer?.items;let t=(await Promise.all(Array.from(n||[]).map(async o=>{if(o.kind==="file"){let r=o.getAsFile();if(r){let i=await Tx(o);return r=await Br(r),{type:r.type,kind:"file",file:r,fileHandle:i}}}else if(o.kind==="string"){let{type:r}=o,i;return"clipboardData"in e&&e.clipboardData?i=e.clipboardData?.getData(r):i=await new Promise(a=>{o.getAsString(s=>a(s))}),{type:r,kind:"string",value:i}}return null}))).filter(o=>o!=null);return Object.assign(t,{findByType:DD,getData:LD,getFiles:_D})},jd=async(e,n=!1)=>{let t=await AD(e,n);if(t.type==="mixedContent")return{mixedContent:t.value};try{let o=JSON.parse(t.value),r=o.type===nl.excalidrawClipboardWithAPI;if(PD(o))return{elements:o.elements,files:o.files,text:n?JSON.stringify(o.elements,null,2):void 0,programmaticAPI:r}}catch{}return{text:t.value}},qd=async e=>{try{await navigator.clipboard.write([new ClipboardItem({[ht.png]:e})])}catch(n){if(vD(e))await navigator.clipboard.write([new ClipboardItem({[ht.png]:await e})]);else throw n}},To=async(e,n)=>{e=e||"";let t=Object.entries(typeof e=="string"?{[ht.text]:e}:e);try{if(n){for(let[r,i]of t)if(n.clipboardData?.setData(r,i),n.clipboardData?.getData(r)!==i)throw new Error("Failed to setData on clipboardEvent");return}}catch(r){console.error(r)}let o=t.find(([r])=>r===ht.text);if(Kd&&o)try{await navigator.clipboard.writeText(o[1]);return}catch(r){console.error(r)}if(o&&!ND(o[1]))throw new Error("Error copying to clipboard.")},ND=e=>{e||(e=" ");let n=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[n?"right":"left"]="-9999px";let o=window.pageYOffset||document.documentElement.scrollTop;t.style.top=`${o}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},Jh=e=>e.type===Xd.PASTE||e.type===Xd.COPY||e.type===Xd.CUT;var $r=(e,{selectedElementIds:n},t)=>{let o=WD(e),r=UD(o),i=t&&Le(o,{selectedElementIds:n}),a=null,s=i?ce(o,{selectedElementIds:n},{includeBoundTextElement:!0}):o;if(i){let l=s[0];s.length===1&&VD(l)?(a=l,s=YD(o,l,r)):s.length>1&&(s=ce(o,{selectedElementIds:n},{includeBoundTextElement:!0,includeElementsInFrames:!0}))}return{exportingFrame:a,exportedElements:GD(s)}},Zr=async(e,n,t,o,{exportBackground:r,exportPadding:i=BD,viewBackgroundColor:a,name:s=t.name||FD,fileHandle:l=null,exportingFrame:c=null})=>{if(n.length===0)throw new Error(f("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let m=Rr(n,{exportBackground:r,exportWithDarkMode:t.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:t.exportScale,exportEmbedScene:t.exportEmbedScene&&e==="svg"},o,{exportingFrame:c});if(e==="svg")return Su(m.then(p=>new Blob([HD+p.outerHTML],{type:zD.svg})),{description:"Export to SVG",name:s,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[ww.svg],fileHandle:l});if(e==="clipboard-svg"){let p=await m.then(u=>u.outerHTML);try{await To(p)}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return}}let d=Lc(n,t,o,{exportBackground:r,viewBackgroundColor:a,exportPadding:i,exportingFrame:c});if(e==="png"){let m=Is(d);return t.exportEmbedScene&&(m=m.then(p=>import("./data/image-K4KCMBWW.js").then(({encodePngMetadata:u})=>u({blob:p,metadata:xs(n,t,o,"local")})))),Su(m,{description:"Export to PNG",name:s,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[ww.png],fileHandle:l})}else if(e==="clipboard")try{let m=Is(d);await qd(m)}catch(m){throw console.warn(m),m.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):OD&&m.name==="TypeError"?new Error(`${f("alerts.couldNotCopyToClipboard")}
3
3
 
4
- ${f("hints.firefox_clipboard_write")}`):new Error(f("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var bw=async(e,n,t)=>{let o=px(n);if(!ux(o))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:s,viewBackgroundColor:l}=i;i={...i,exportEmbedScene:!0};let{exportedElements:c,exportingFrame:d}=Vr(r,i,!1);return await Yr(o,c,i,a,{exportBackground:s,viewBackgroundColor:l,name:t,fileHandle:n,exportingFrame:d}),{fileHandle:n}};import{Fragment as KD,jsx as rr,jsxs as vw}from"react/jsx-runtime";var $h=O({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,name:t},captureUpdate:Mn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n,appProps:t,data:o,app:r})=>rr(mw,{label:f("labels.fileTitle"),value:r.getName(),onChange:i=>n(i),ignoreFocus:o?.ignoreFocus??!1})}),xw=O({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,n,t)=>({appState:{...n,exportScale:t},captureUpdate:Mn.EVENTUALLY})}),Zh=O({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,n,t)=>({appState:{...n,exportBackground:t},captureUpdate:Mn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>rr(Vh,{checked:e.exportBackground,onChange:t=>n(t),children:f("imageExportDialog.label.withBackground")})}),Kd=O({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,n,t)=>({appState:{...n,exportEmbedScene:t},captureUpdate:Mn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>vw(Vh,{checked:e.exportEmbedScene,onChange:t=>n(t),children:[f("imageExportDialog.label.embedScene"),rr(pt,{label:f("imageExportDialog.tooltip.embedScene"),long:!0,children:rr("div",{className:"excalidraw-tooltip-icon",children:jx})})]})}),Qi=!1,Kh=(e,n)=>{let t=n.message??f("progressDialog.defaultMessage");e.setAppState({toast:{message:n.progress!=null?vw(KD,{children:[t,rr(zd.ProgressBar,{progress:n.progress})]}):t,duration:1/0}})};async function XD(e,n){if(n.app.state.isLoading&&(Kh(n.app,{progress:null}),await n.app.onStateChange({predicate:t=>!t.isLoading})),e!=null&&typeof e=="object"&&Symbol.asyncIterator in e){for await(let t of e){if(n.signal.aborted){e.return();return}if(t.type==="progress")Kh(n.app,{message:t.message,progress:t.progress??null});else if(t.type==="done")return}return}e instanceof Promise&&(Kh(n.app,{progress:null}),await e)}function yw(e,n,t,o){let r=new AbortController,i=r.signal,a=new Promise(async s=>{try{o.props.onExport&&await XD(o.props.onExport("json",{elements:e,appState:n,files:t},{signal:i}),{app:o,signal:i})}catch(l){l?.name==="AbortError"?console.warn(`onExport() aborted by host app (signal aborted: ${i.aborted})`):console.error("Error during props.onExport() handling",l)}s({elements:e,appState:n,files:o.files})});return{abortController:r,data:a}}var Xr=O({name:"saveToActiveFile",label:"buttons.save",icon:vs,trackEvent:{category:"export"},predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.saveToActiveFile&&!!n.fileHandle&&!n.viewModeEnabled,perform:async(e,n,t,o)=>{if(Qi)return!1;Qi=!0;let r=n.fileHandle,i=o.getName(),{abortController:a,data:s}=yw(e,n,o.files,o);try{let{fileHandle:l}=Pc(r)?await bw(s,r,i):await vc({data:s,filename:i,fileHandle:r});return{captureUpdate:Mn.NEVER,appState:{fileHandle:l,toast:{message:r&&l?.name?f("toast.fileSavedToFilename").replace("{filename}",`"${l.name}"`):f("toast.fileSaved"),duration:1500}}}}catch(l){return a.abort(),l?.name!=="AbortError"?console.error(l):console.warn(l),{captureUpdate:Mn.NEVER,appState:{toast:null}}}finally{Qi=!1}},keyTest:e=>!1}),Js=O({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:vs,viewMode:!0,trackEvent:{category:"export"},perform:async(e,n,t,o)=>{if(Qi)return!1;Qi=!0;let{abortController:r,data:i}=yw(e,n,o.files,o);try{let{fileHandle:a}=await vc({data:i,filename:o.getName(),fileHandle:null});return{captureUpdate:Mn.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:Mn.NEVER,appState:{toast:null}}}finally{Qi=!1}},keyTest:e=>e.key.toLowerCase()===Xd.S&&e.shiftKey&&e[Xd.CTRL_OR_CMD],PanelComponent:({updateData:e})=>rr($,{type:"button",icon:Yx,title:f("buttons.saveAs"),"aria-label":f("buttons.saveAs"),showAriaLabel:Ee().formFactor==="phone",hidden:!Ii,onClick:()=>e(null),"data-testid":"save-as-button"})}),ea=O({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.loadScene&&!n.viewModeEnabled,perform:async(e,n,t,o)=>{try{let{elements:r,appState:i,files:a}=await yu(n,e);return{elements:r,appState:i,files:a,captureUpdate:Mn.IMMEDIATELY}}catch(r){return r?.name==="AbortError"?(console.warn(r),!1):{elements:e,appState:{...n,errorMessage:r.message},files:o.files,captureUpdate:Mn.EVENTUALLY}}},keyTest:e=>e[Xd.CTRL_OR_CMD]&&e.key===Xd.O}),ww=O({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,n,t,o)=>(o.sessionExportThemeOverride=t?qs.DARK:qs.LIGHT,{appState:{...n,exportWithDarkMode:t},captureUpdate:Mn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>rr("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:rr(cw,{value:e.exportWithDarkMode?qs.DARK:qs.LIGHT,onChange:t=>{n(t===qs.DARK)},title:f("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as $D,DEFAULT_FONT_FAMILY as ZD,DEFAULT_TEXT_ALIGN as jD,getLineHeight as qD}from"@excalidraw/common";import{newElementWith as $d}from"@excalidraw/element";import{hasBoundTextElement as JD,canApplyRoundnessTypeToElement as QD,getDefaultRoundnessTypeForElement as eL,isFrameLikeElement as tL,isArrowElement as nL,isExcalidrawElement as oL,isTextElement as Iw}from"@excalidraw/element";import{getBoundTextElement as rL,redrawTextBoundingBox as iL}from"@excalidraw/element";import{CaptureUpdateAction as jh}from"@excalidraw/element";var Tw="{}",aL=O({name:"copyStyles",label:"labels.copyStyles",icon:Yu,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=[],i=e.find(a=>n.selectedElementIds[a.id]);if(r.push(i),i&&JD(i)){let a=rL(i,o.scene.getNonDeletedElementsMap());r.push(a)}return i&&(Tw=JSON.stringify(r)),{appState:{...n,toast:{message:f("toast.copyStyles")}},captureUpdate:jh.EVENTUALLY}}}),sL=O({name:"pasteStyles",label:"labels.pasteStyles",icon:Yu,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=JSON.parse(Tw),i=r[0],a=r[1];if(!oL(i))return{elements:e,captureUpdate:jh.EVENTUALLY};let s=ce(e,n,{includeBoundTextElement:!0}),l=s.map(c=>c.id);return{elements:e.map(c=>{if(l.includes(c.id)){let d=i;if(Iw(c)&&c.containerId&&(d=a),!d)return c;let m=$d(c,{backgroundColor:d?.backgroundColor,strokeWidth:d?.strokeWidth,strokeColor:d?.strokeColor,strokeStyle:d?.strokeStyle,fillStyle:d?.fillStyle,opacity:d?.opacity,roughness:d?.roughness,roundness:d.roundness?QD(d.roundness.type,c)?d.roundness:eL(c):null});if(Iw(m)){let p=d.fontSize||$D,u=d.fontFamily||ZD,E=$d(m,{fontSize:p,fontFamily:u,textAlign:d.textAlign||jD,lineHeight:d.lineHeight||qD(u)});m=E;let g=null;E.containerId&&(g=s.find(b=>b.id===E.containerId)||null),iL(E,g,o.scene)}return m.type==="arrow"&&nL(d)&&(m=$d(m,{startArrowhead:d.startArrowhead,endArrowhead:d.endArrowhead})),tL(c)&&(m=$d(m,{roundness:null,backgroundColor:"transparent"})),m}return c}),captureUpdate:jh.IMMEDIATELY}}});import{KEYS as lL}from"@excalidraw/common";import{CaptureUpdateAction as cL}from"@excalidraw/element";var Kr=O({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:Gx,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,n,t,{focusContainer:o})=>(n.openDialog?.name==="help"&&o(),{appState:{...n,openDialog:n.openDialog?.name==="help"?null:{name:"help"},openMenu:null,openPopup:null},captureUpdate:cL.EVENTUALLY}),keyTest:e=>e.key===lL.QUESTION_MARK});import{getNonDeletedElements as jd}from"@excalidraw/element";import{newElementWith as Cw}from"@excalidraw/element";import{isBoundToContainer as dL}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as mL,getElementsInResizingFrame as pL,getFrameLikeElements as uL,getRootElements as hL,groupByFrameLikes as gL,removeElementsFromFrame as fL,replaceAllElementsInFrame as EL}from"@excalidraw/element";import{KEYS as qd,randomId as bL,arrayToMap as Jh}from"@excalidraw/common";import{getSelectedGroupIds as Zd,selectGroup as xL,selectGroupsForSelectedElements as yL,getElementsInGroup as Sw,addToGroup as wL,removeFromSelectedGroups as vL,isElementInGroup as Pw}from"@excalidraw/element";import{syncMovedIndices as IL}from"@excalidraw/element";import{CaptureUpdateAction as Qs}from"@excalidraw/element";import{jsx as ta}from"react/jsx-runtime";var TL=(e,n)=>{if(e.length>=2){let t=n?e[0].groupIds.indexOf(n):-1,o=t>-1?e[0].groupIds.slice(0,t):e[0].groupIds;for(let r of o)if(e.every(i=>Pw(i,r)))return!0}return!1},qh=(e,n)=>{let t=n.scene.getSelectedElements({selectedElementIds:e.selectedElementIds,includeBoundTextElement:!1});return t.length>=2&&!TL(t,e.editingGroupId)&&!mL(t)},Qh=O({name:"group",label:"labels.group",icon:e=>ta(Ou,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(!qh(n,o))return!1;let r=hL(o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}));if(r.length<2)return{appState:n,elements:e,captureUpdate:Qs.EVENTUALLY};let i=Zd(n);if(i.length===1){let b=i[0],y=new Set(Sw(e,b).map(I=>I.id)),w=new Set(r.map(I=>I.id));if(new Set([...Array.from(y),...Array.from(w)]).size===y.size)return{appState:n,elements:e,captureUpdate:Qs.EVENTUALLY}}let a=[...e];new Set(r.map(b=>b.frameId)).size>1&&gL(r).forEach((y,w)=>{fL(y,o.scene.getNonDeletedElementsMap())});let l=bL(),c=Jh(r);a=a.map(b=>c.get(b.id)?Cw(b,{groupIds:wL(b.groupIds,l,n.editingGroupId)}):b);let d=Sw(a,l),m=d[d.length-1],p=a.lastIndexOf(m),u=a.slice(p+1),E=a.slice(0,p).filter(b=>!Pw(b,l)),g=IL([...E,...d,...u],Jh(d));return{appState:{...n,...xL(l,{...n,selectedGroupIds:{}},jd(a))},elements:g,captureUpdate:Qs.IMMEDIATELY}},predicate:(e,n,t,o)=>qh(n,o),keyTest:e=>!e.shiftKey&&e[qd.CTRL_OR_CMD]&&e.key===qd.G,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ta($,{hidden:!qh(n,o),type:"button",icon:ta(Ou,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.group")} \u2014 ${N("CtrlOrCmd+G")}`,"aria-label":f("labels.group"),visible:De(jd(e),n)})}),eg=O({name:"ungroup",label:"labels.ungroup",icon:e=>ta(zu,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=Zd(n),i=Jh(e);if(r.length===0)return{appState:n,elements:e,captureUpdate:Qs.EVENTUALLY};let a=[...e],s=[];a=a.map(p=>{dL(p)&&s.push(p.id);let u=vL(p.groupIds,n.selectedGroupIds);return u.length===p.groupIds.length?p:Cw(p,{groupIds:u})});let l=yL(n,jd(a),n,null),c=o.scene.getSelectedElements(n),d=new Set(c.filter(p=>p.frameId).map(p=>p.frameId));return uL(e).filter(p=>d.has(p.id)).forEach(p=>{p&&(a=EL(a,pL(a,p,n,i),p))}),l.selectedElementIds=Object.entries(l.selectedElementIds).reduce((p,[u,E])=>(E&&!s.includes(u)&&(p[u]=!0),p),{}),{appState:{...n,...l},elements:a,captureUpdate:Qs.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[qd.CTRL_OR_CMD]&&e.key===qd.G.toUpperCase(),predicate:(e,n)=>Zd(n).length>0,PanelComponent:({elements:e,appState:n,updateData:t})=>ta($,{type:"button",hidden:Zd(n).length===0,icon:ta(zu,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.ungroup")} \u2014 ${N("CtrlOrCmd+Shift+G")}`,"aria-label":f("labels.ungroup"),visible:De(jd(e),n)})});import DL from"clsx";import{CaptureUpdateAction as Lw}from"@excalidraw/element";import{invariant as LL}from"@excalidraw/common";import{COLOR_CHARCOAL_BLACK as SL,COLOR_VOICE_CALL as CL,COLOR_WHITE as Qd,THEME as PL,UserIdleState as kw}from"@excalidraw/common";var Jd=(e,n,t,o,r,i,a)=>{e.beginPath(),e.moveTo(n+i,t),e.lineTo(n+o-i,t),e.quadraticCurveTo(n+o,t,n+o,t+i),e.lineTo(n+o,t+r-i),e.quadraticCurveTo(n+o,t+r,n+o-i,t+r),e.lineTo(n+i,t+r),e.quadraticCurveTo(n,t+r,n,t+r-i),e.lineTo(n,t+i),e.quadraticCurveTo(n,t,n+i,t),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};function kL(e){let n=0;if(e.length===0)return n;for(let t=0;t<e.length;t++){let o=e.charCodeAt(t);n=(n<<5)-n+o}return n}var $r=(e,n)=>`hsl(${Math.abs(kL(n?.id||e))%37*10}, 100%, 83%)`,Mw=e=>{let n=e?.trim()?.codePointAt(0);return(n?String.fromCodePoint(n):"?").toUpperCase()},Aw=({context:e,renderConfig:n,appState:t,normalizedWidth:o,normalizedHeight:r})=>{for(let[i,a]of n.remotePointerViewportCoords){let{x:s,y:l}=a,c=t.collaborators.get(i);s-=t.offsetLeft,l-=t.offsetTop;let d=11,m=14,p=s<0||s>o-d||l<0||l>r-m;s=Math.max(s,0),s=Math.min(s,o-d),l=Math.max(l,0),l=Math.min(l,r-m);let u=$r(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let E=n.remotePointerUserStates.get(i),g=p||E===kw.IDLE||E===kw.AWAY;g&&(e.globalAlpha=.3),n.remotePointerButton.get(i)==="down"&&(e.beginPath(),e.arc(s,l,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(s,l,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=u,e.stroke(),e.closePath());let b=t.theme===PL.DARK?"#2f6330":CL,y=c?.isSpeaking;y&&(e.fillStyle=b,e.strokeStyle=b,e.lineWidth=10,e.lineJoin="round",e.beginPath(),e.moveTo(s,l),e.lineTo(s+0,l+14),e.lineTo(s+4,l+9),e.lineTo(s+11,l+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=Qd,e.strokeStyle=Qd,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(s,l),e.lineTo(s+0,l+14),e.lineTo(s+4,l+9),e.lineTo(s+11,l+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=u,e.strokeStyle=u,e.lineWidth=2,e.lineJoin="round",e.beginPath(),g?(e.moveTo(s-1,l-1),e.lineTo(s-1,l+15),e.lineTo(s+5,l+10),e.lineTo(s+12,l+9),e.closePath(),e.fill()):(e.moveTo(s,l),e.lineTo(s+0,l+14),e.lineTo(s+4,l+9),e.lineTo(s+11,l+8),e.closePath(),e.fill(),e.stroke());let w=n.remotePointerUsernames.get(i)||"";if(!p&&w){e.font="600 12px sans-serif";let x=(y?s+0:s)+d/2,I=(y?l+0:l)+m+2,T=5,C=3,P=e.measureText(w),A=P.actualBoundingBoxDescent+P.actualBoundingBoxAscent,D=Math.max(A,12),_=x-1,k=I-1,L=P.width+2+T*2+2,B=D+2+C*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(_,k,L,B,8),e.fillStyle=u,e.fill(),e.strokeStyle=Qd,e.stroke(),y&&(e.beginPath(),e.roundRect(_-2,k-2,L+4,B+4,8),e.strokeStyle=b,e.stroke())):Jd(e,_,k,L,B,8,Qd),e.fillStyle=SL,e.fillText(w,x+T+1,I+C+P.actualBoundingBoxAscent+Math.floor((D-A)/2)+2),y){e.fillStyle=b;let V=8,z=8,U=5;e.fillRect(_+L+z,k+(B/2-V/2),2,V),e.fillRect(_+L+z+U,k+(B/2-V*2/2),2,V*2),e.fillRect(_+L+z+U*2,k+(B/2-V/2),2,V)}}e.restore(),e.closePath()}};import ML from"clsx";import{useState as AL}from"react";import{jsx as Dw}from"react/jsx-runtime";var tg=({color:e,onClick:n,name:t,src:o,className:r})=>{let i=Mw(t),[a,s]=AL(!1),l=!a&&o,c=l?void 0:{background:e};return Dw("div",{className:ML("Avatar",r),style:c,onClick:n,children:l?Dw("img",{className:"Avatar-img",src:o,alt:i,referrerPolicy:"no-referrer",onError:()=>s(!0)}):i})};import{jsx as to,jsxs as em}from"react/jsx-runtime";var _L=O({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,n,t,o)=>(LL(t,"actionGoToCollaborator: collaborator should be defined when actionGoToCollaborator is called"),!t.socketId||o.props.userToFollow?.socketId===t.socketId||t.isCurrentUser?(o.requestUnfollow(),{appState:n,captureUpdate:Lw.EVENTUALLY}):(o.emitUserFollowIntent({userToFollow:{socketId:t.socketId,username:t.username||""},action:"FOLLOW"}),{appState:{...n,openMenu:n.openMenu==="canvas"?null:n.openMenu},captureUpdate:Lw.EVENTUALLY})),PanelComponent:({updateData:e,data:n,appState:t})=>{let{socketId:o,collaborator:r,withName:i,isBeingFollowed:a}=n,s=$r(o,r),l=DL({"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?em("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:f("userList.hint.isSpeaking"),children:[to("div",{}),to("div",{}),to("div",{})]}):r.isMuted?to("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:f("userList.hint.micMuted"),children:J1}):to("div",{title:f("userList.hint.inCall"),children:q1}):null;return i?em("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${l}`,style:{"--avatar-size":"1.5rem"},onClick:r.isCurrentUser?void 0:()=>e(r),children:[to(tg,{color:s,onClick:()=>{},name:r.username||"",src:r.avatarUrl,className:l}),to("div",{className:"UserList__collaborator-name",children:r.username}),em("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&to("div",{className:"UserList__collaborator-status-icon-is-followed",title:f("userList.hint.followStatus"),children:Fr}),r.isCurrentUser&&` (${f("labels.you")})`,c]})]}):em("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${l}`,children:[to(tg,{color:s,onClick:()=>{e(r)},name:r.username||"",src:r.avatarUrl,className:l}),c&&to("div",{className:"UserList__collaborator-status-icon",children:c})]})}});import{getNonDeletedElements as na}from"@excalidraw/element";import{isFrameLikeElement as RL}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as NL}from"@excalidraw/element";import{KEYS as ir,arrayToMap as BL}from"@excalidraw/common";import{alignElements as FL}from"@excalidraw/element";import{CaptureUpdateAction as oa}from"@excalidraw/element";import{getSelectedElementsByGroup as OL}from"@excalidraw/element";import{jsx as ia}from"react/jsx-runtime";var dt=(e,n)=>{let t=n.scene.getSelectedElements(e);return OL(t,n.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(o=>RL(o))},ra=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),i=FL(r,o,t.scene,n),a=BL(i);return NL(e.map(s=>a.get(s.id)||s),n,t)},zL=O({name:"alignTop",label:"labels.alignTop",icon:Lu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:ra(e,n,o,{position:"start",axis:"y"}),captureUpdate:oa.IMMEDIATELY}),keyTest:e=>e[ir.CTRL_OR_CMD]&&e.shiftKey&&e.key===ir.ARROW_UP,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ia($,{hidden:!dt(n,o),type:"button",icon:Lu,onClick:()=>t(null),title:`${f("labels.alignTop")} \u2014 ${N("CtrlOrCmd+Shift+Up")}`,"aria-label":f("labels.alignTop"),visible:De(na(e),n)})}),GL=O({name:"alignBottom",label:"labels.alignBottom",icon:_u,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:ra(e,n,o,{position:"end",axis:"y"}),captureUpdate:oa.IMMEDIATELY}),keyTest:e=>e[ir.CTRL_OR_CMD]&&e.shiftKey&&e.key===ir.ARROW_DOWN,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ia($,{hidden:!dt(n,o),type:"button",icon:_u,onClick:()=>t(null),title:`${f("labels.alignBottom")} \u2014 ${N("CtrlOrCmd+Shift+Down")}`,"aria-label":f("labels.alignBottom"),visible:De(na(e),n)})}),HL=O({name:"alignLeft",label:"labels.alignLeft",icon:Ru,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:ra(e,n,o,{position:"start",axis:"x"}),captureUpdate:oa.IMMEDIATELY}),keyTest:e=>e[ir.CTRL_OR_CMD]&&e.shiftKey&&e.key===ir.ARROW_LEFT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ia($,{hidden:!dt(n,o),type:"button",icon:Ru,onClick:()=>t(null),title:`${f("labels.alignLeft")} \u2014 ${N("CtrlOrCmd+Shift+Left")}`,"aria-label":f("labels.alignLeft"),visible:De(na(e),n)})}),UL=O({name:"alignRight",label:"labels.alignRight",icon:Nu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:ra(e,n,o,{position:"end",axis:"x"}),captureUpdate:oa.IMMEDIATELY}),keyTest:e=>e[ir.CTRL_OR_CMD]&&e.shiftKey&&e.key===ir.ARROW_RIGHT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ia($,{hidden:!dt(n,o),type:"button",icon:Nu,onClick:()=>t(null),title:`${f("labels.alignRight")} \u2014 ${N("CtrlOrCmd+Shift+Right")}`,"aria-label":f("labels.alignRight"),visible:De(na(e),n)})}),WL=O({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Bu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:ra(e,n,o,{position:"center",axis:"y"}),captureUpdate:oa.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ia($,{hidden:!dt(n,o),type:"button",icon:Bu,onClick:()=>t(null),title:f("labels.centerVertically"),"aria-label":f("labels.centerVertically"),visible:De(na(e),n)})}),VL=O({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Fu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:ra(e,n,o,{position:"center",axis:"x"}),captureUpdate:oa.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ia($,{hidden:!dt(n,o),type:"button",icon:Fu,onClick:()=>t(null),title:f("labels.centerHorizontally"),"aria-label":f("labels.centerHorizontally"),visible:De(na(e),n)})});import{getNonDeletedElements as _w}from"@excalidraw/element";import{isFrameLikeElement as YL}from"@excalidraw/element";import{CODES as Rw,KEYS as Nw,arrayToMap as XL}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as KL}from"@excalidraw/element";import{distributeElements as $L}from"@excalidraw/element";import{CaptureUpdateAction as Bw}from"@excalidraw/element";import{getSelectedElementsByGroup as ZL}from"@excalidraw/element";import{jsx as zw}from"react/jsx-runtime";var Fw=(e,n)=>{let t=n.scene.getSelectedElements(e);return ZL(t,n.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(o=>YL(o))},Ow=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),i=$L(r,t.scene.getNonDeletedElementsMap(),o,n,t.scene),a=XL(i);return KL(e.map(s=>a.get(s.id)||s),n,t)},jL=O({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:Ow(e,n,o,{space:"between",axis:"x"}),captureUpdate:Bw.IMMEDIATELY}),keyTest:e=>!e[Nw.CTRL_OR_CMD]&&e.altKey&&e.code===Rw.H,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>zw($,{hidden:!Fw(n,o),type:"button",icon:e1,onClick:()=>t(null),title:`${f("labels.distributeHorizontally")} \u2014 ${N("Alt+H")}`,"aria-label":f("labels.distributeHorizontally"),visible:De(_w(e),n)})}),qL=O({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:Ow(e,n,o,{space:"between",axis:"y"}),captureUpdate:Bw.IMMEDIATELY}),keyTest:e=>!e[Nw.CTRL_OR_CMD]&&e.altKey&&e.code===Rw.V,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>zw($,{hidden:!Fw(n,o),type:"button",icon:t1,onClick:()=>t(null),title:`${f("labels.distributeVertically")} \u2014 ${N("Alt+V")}`,"aria-label":f("labels.distributeVertically"),visible:De(_w(e),n)})});import{arrayToMap as Gw,KEYS as QL,matchKey as e_}from"@excalidraw/common";import{CaptureUpdateAction as t_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as n_}from"@excalidraw/element/frame";import{arrangeElements as o_}from"@excalidraw/element/arrange";var JL={fitToViewport:!0,animate:!0,duration:200,respectUIElements:!1,viewportZoomFactor:.8},aa=(e,n)=>({smartZoom:{...JL,...n?.smartZoom},arrange:{...e.arrangeConfiguration,...n?.arrange},normalise:{...e.normaliseConfiguration,...n?.normalise}});import{jsx as a_}from"react/jsx-runtime";var r_=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=Gw(e),{arrange:i}=aa(n,t.props.editorPreferences),a=o_(t.scene,o,r,i.algorithm,i.gap),s=Gw(a);return n_(e.map(l=>s.get(l.id)||l),n,t)},i_=dt,ng=O({name:"arrangeElements",label:"labels.arrangeElements",keywords:["arrange","rearrange","spread"],icon:Ku,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>i_(n,o),perform:(e,n,t,o)=>({appState:n,elements:r_(e,n,o),captureUpdate:t_.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e_(e,QL.R),PanelComponent:({updateData:e})=>a_("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:`${f("labels.arrangeElements")} \u2014 ${N("Shift+R")}`,children:Ku})});import{arrayToMap as Hw}from"@excalidraw/common";import{CaptureUpdateAction as s_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as l_}from"@excalidraw/element/frame";import{normaliseElements as c_}from"@excalidraw/element/normalise";import{jsx as p_}from"react/jsx-runtime";var d_=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=Hw(e),{normalise:i}=aa(n,t.props.editorPreferences),a=c_(t.scene,o,r,i.mode,i.metric),s=Hw(a);return l_(e.map(l=>s.get(l.id)||l),n,t)},m_=dt,og=O({name:"normaliseElements",label:"labels.normaliseElements",keywords:["normalize","normalise","scale","size","image"],icon:$u,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>m_(n,o),perform:(e,n,t,o)=>({appState:n,elements:d_(e,n,o),captureUpdate:s_.IMMEDIATELY}),PanelComponent:({updateData:e})=>p_("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:f("labels.normaliseElements"),children:$u})});import{getNonDeletedElements as u_}from"@excalidraw/element";import{bindOrUnbindBindingElements as h_}from"@excalidraw/element";import{getCommonBoundingBox as Uw}from"@excalidraw/element";import{newElementWith as g_}from"@excalidraw/element";import{deepCopyElement as f_}from"@excalidraw/element";import{resizeMultipleElements as E_}from"@excalidraw/element";import{isArrowElement as Ww,isElbowArrow as b_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as Vw}from"@excalidraw/element";import{CODES as Yw,KEYS as x_,arrayToMap as y_}from"@excalidraw/common";import{CaptureUpdateAction as Xw}from"@excalidraw/element";var rg=O({name:"flipHorizontal",label:"labels.flipHorizontal",icon:n0,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Vw(Kw(e,o.scene.getNonDeletedElementsMap(),n,"horizontal",o),n,o),appState:n,captureUpdate:Xw.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===Yw.H}),ig=O({name:"flipVertical",label:"labels.flipVertical",icon:t0,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Vw(Kw(e,o.scene.getNonDeletedElementsMap(),n,"vertical",o),n,o),appState:n,captureUpdate:Xw.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===Yw.V&&!e[x_.CTRL_OR_CMD]}),Kw=(e,n,t,o,r)=>{let i=ce(u_(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=w_(i,n,o,r),s=y_(a);return e.map(l=>s.get(l.id)||l)},w_=(e,n,t,o)=>{if(e.every(p=>Ww(p)&&(p.startBinding||p.endBinding)))return e.map(p=>{let u=p;return g_(u,{startArrowhead:u.endArrowhead,endArrowhead:u.startArrowhead})});let{midX:r,midY:i}=Uw(e);E_(e,n,"nw",o.scene,new Map(Array.from(n.values()).map(p=>[p.id,f_(p)])),{flipByX:t==="horizontal",flipByY:t==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),h_(e.filter(Ww),o.scene,o.state);let{elbowArrows:a,otherElements:s}=e.reduce((p,u)=>b_(u)?{...p,elbowArrows:p.elbowArrows.concat(u)}:{...p,otherElements:p.otherElements.concat(u)},{elbowArrows:[],otherElements:[]}),{midX:l,midY:c}=Uw(e),[d,m]=[r-l,i-c];return s.forEach(p=>o.scene.mutateElement(p,{x:p.x+d,y:p.y+m})),a.forEach(p=>o.scene.mutateElement(p,{x:p.x+d,y:p.y+m})),e};import{isTextElement as v_}from"@excalidraw/element";import{getTextFromElements as I_}from"@excalidraw/element";import{CODES as T_,KEYS as $w,isFirefox as S_}from"@excalidraw/common";import{CaptureUpdateAction as qt}from"@excalidraw/element";var sa=O({name:"copy",label:"labels.copy",icon:xs,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await Ud(r,o.files,t)}catch(i){return{captureUpdate:qt.EVENTUALLY,appState:{...n,errorMessage:i.message}}}return{captureUpdate:qt.EVENTUALLY}},keyTest:void 0}),ag=O({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r;try{r=await gw()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),S_?{captureUpdate:qt.EVENTUALLY,appState:{...n,errorMessage:f("hints.firefox_clipboard_write")}}:{captureUpdate:qt.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnRead")}})}try{o.pasteFromClipboard(uw({types:r}))}catch(i){return console.error(i),{captureUpdate:qt.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:qt.EVENTUALLY}},keyTest:void 0}),tm=O({name:"cut",label:"labels.cut",icon:W1,trackEvent:{category:"element"},perform:(e,n,t,o)=>(sa.perform(e,n,t,o),Cs.perform(e,n,null,o)),keyTest:e=>e[$w.CTRL_OR_CMD]&&e.key===$w.X}),C_=O({name:"copyAsSvg",label:"labels.copyAsSvg",icon:o0,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:qt.EVENTUALLY};let{exportedElements:r,exportingFrame:i}=Vr(e,n,!0);try{await Yr("clipboard-svg",r,n,o.files,{...n,exportingFrame:i,name:o.getName()});let a=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:f("toast.copyToClipboardAsSvg",{exportSelection:a.length?f("toast.selection"):f("toast.canvas"),exportColorScheme:n.exportWithDarkMode?f("buttons.darkMode"):f("buttons.lightMode")})}},captureUpdate:qt.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:qt.EVENTUALLY}}},predicate:e=>Hd&&e.length>0,keywords:["svg","clipboard","copy"]}),P_=O({name:"copyAsPng",label:"labels.copyAsPng",icon:r0,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:qt.EVENTUALLY};let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=Vr(e,n,!0);try{return await Yr("clipboard",i,n,o.files,{...n,exportingFrame:a,name:o.getName()}),{appState:{...n,toast:{message:f("toast.copyToClipboardAsPng",{exportSelection:r.length?f("toast.selection"):f("toast.canvas"),exportColorScheme:n.exportWithDarkMode?f("buttons.darkMode"):f("buttons.lightMode")})}},captureUpdate:qt.EVENTUALLY}}catch(s){return console.error(s),{appState:{...n,errorMessage:s.message},captureUpdate:qt.EVENTUALLY}}},predicate:e=>or&&e.length>0,keyTest:e=>e.code===T_.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),k_=O({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0});try{vo(I_(r))}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return{captureUpdate:qt.EVENTUALLY}},predicate:(e,n,t,o)=>Hd&&o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}).some(v_),keywords:["text","clipboard","copy"]});import{CODES as M_,KEYS as A_}from"@excalidraw/common";import{CaptureUpdateAction as D_}from"@excalidraw/element";var la=O({name:"gridMode",icon:a0,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>e.gridModeEnabled},perform(e,n){return{appState:{...n,gridModeEnabled:!this.checked(n),objectsSnapModeEnabled:!1},captureUpdate:D_.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[A_.CTRL_OR_CMD]&&e.code===M_.QUOTE});import{KEYS as nm}from"@excalidraw/common";import{CaptureUpdateAction as L_}from"@excalidraw/element/store";import{jsx as __}from"react/jsx-runtime";var el=O({name:"smartZoom",label:"toolBar.smartZoom",trackEvent:{category:"toolbar"},icon:Zu,viewMode:!0,perform:(e,n,t,o)=>{let r=aa(n,o.props.editorPreferences).smartZoom,i=ce(e,n);return o.viewport.setViewport({target:i.length?i:e,fit:r.fitToViewport?"contain":"none",animation:r.animate?{duration:r.duration}:!1,offsets:r.respectUIElements?{ui:!0}:void 0,viewportZoomFactor:r.viewportZoomFactor}),{captureUpdate:L_.NEVER}},keyTest:e=>!e[nm.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===nm.F,PanelComponent:({data:e,updateData:n})=>__($,{type:"button",icon:Zu,"aria-label":f("labels.smartZoom"),title:`${f("labels.smartZoom")} - ${nm.F.toLocaleUpperCase()}`,onClick:()=>n(null),size:e?.size||"medium","data-testid":"button-smart-zoom",keyBindingLabel:nm.F.toLocaleUpperCase()})});import{CODES as R_,KEYS as N_}from"@excalidraw/common";import{CaptureUpdateAction as B_}from"@excalidraw/element";var Dt=O({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:Yo,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,n){return{appState:{...n,objectsSnapModeEnabled:!this.checked(n),gridModeEnabled:!1},captureUpdate:B_.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,n,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[N_.CTRL_OR_CMD]&&e.altKey&&e.code===R_.S});import{CaptureUpdateAction as F_}from"@excalidraw/element";var tl=O({name:"arrowBinding",label:"labels.arrowBinding",viewMode:!1,trackEvent:{category:"canvas",predicate:e=>e.bindingPreference==="disabled"},perform(e,n){let t=n.bindingPreference==="enabled"?"disabled":"enabled";return{appState:{...n,bindingPreference:t,isBindingEnabled:t==="enabled"},captureUpdate:F_.NEVER}},checked:e=>e.bindingPreference==="enabled"});import{CaptureUpdateAction as O_}from"@excalidraw/element";var nl=O({name:"midpointSnapping",label:"labels.midpointSnapping",viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.isMidpointSnappingEnabled},perform(e,n){return{appState:{...n,isMidpointSnappingEnabled:!this.checked(n)},captureUpdate:O_.NEVER}},checked:e=>e.isMidpointSnappingEnabled});import{CODES as z_,KEYS as G_}from"@excalidraw/common";import{CaptureUpdateAction as H_}from"@excalidraw/element";var ar=O({name:"stats",label:"stats.fullTitle",icon:e0,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,n){return{appState:{...n,stats:{...n.stats,open:!this.checked(n)}},captureUpdate:H_.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[G_.CTRL_OR_CMD]&&e.altKey&&e.code===z_.SLASH});import{BOUND_TEXT_PADDING as Zw,ROUNDNESS as jw,TEXT_ALIGN as Qw,VERTICAL_ALIGN as ev,arrayToMap as tv,getFontString as U_,getStrokeWidthByKey as W_}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as V_,isBoundToContainer as qw,resetOriginalContainerCache as Y_,updateOriginalContainerCache as X_}from"@excalidraw/element";import{computeBoundTextPosition as K_,computeContainerDimensionForBoundText as Jw,getBoundTextElement as nv,redrawTextBoundingBox as ov}from"@excalidraw/element";import{hasBoundTextElement as $_,isArrowElement as Z_,isTextBindableContainer as sg,isTextElement as ol,isUsingAdaptiveRadius as j_}from"@excalidraw/element";import{measureText as q_}from"@excalidraw/element";import{syncMovedIndices as rv}from"@excalidraw/element";import{newElement as J_}from"@excalidraw/element";import{CaptureUpdateAction as lg}from"@excalidraw/element";var cg=O({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>o.scene.getSelectedElements(n).some(i=>$_(i)),perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=o.scene.getNonDeletedElementsMap();return r.forEach(a=>{let s=nv(a,i);if(s){let{width:l,height:c}=q_(s.originalText,U_(s),s.lineHeight),d=V_(a.id);Y_(a.id);let{x:m,y:p}=K_(a,s,i);o.scene.mutateElement(s,{containerId:null,width:l,height:c,text:s.originalText,x:m,y:p}),o.scene.mutateElement(a,{boundElements:a.boundElements?.filter(u=>u.id!==s.id),height:d||a.height})}}),{elements:e,appState:n,captureUpdate:lg.IMMEDIATELY}}}),dg=O({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);if(r.length===2){let i=ol(r[0])||ol(r[1]),a;if(sg(r[0])?a=r[0]:sg(r[1])&&(a=r[1]),i&&a&&nv(a,o.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i,a;ol(r[0])&&sg(r[1])?(i=r[0],a=r[1]):(i=r[1],a=r[0]),o.scene.mutateElement(i,{containerId:a.id,verticalAlign:ev.MIDDLE,textAlign:Qw.CENTER,autoResize:!0,angle:Z_(a)?0:a?.angle??0}),o.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let s=a.height;return ov(i,a,o.scene),X_(a.id,s),{elements:Q_(e,a,i),appState:{...n,selectedElementIds:{[a.id]:!0}},captureUpdate:lg.IMMEDIATELY}}}),Q_=(e,n,t)=>{let o=e.slice(),r=o.findIndex(a=>a.id===t.id);o.splice(r,1);let i=o.findIndex(a=>a.id===n.id);return o.splice(i+1,0,t),rv(o,tv([n,t])),o},eR=(e,n,t)=>{let o=e.slice(),r=o.findIndex(a=>a.id===n.id);o.splice(r,1);let i=o.findIndex(a=>a.id===t.id);return o.splice(i,0,n),rv(o,tv([n,t])),o},iv=O({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=r.some(a=>ol(a)&&!qw(a));return r.length>0&&i},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=e.slice(),a={};for(let s of r)if(ol(s)&&!qw(s)){let l=J_({type:"rectangle",backgroundColor:n.currentItemBackgroundColor,boundElements:[...s.boundElements||[],{id:s.id,type:"text"}],angle:s.angle,fillStyle:n.currentItemFillStyle,strokeColor:n.currentItemStrokeColor,roughness:n.currentItemRoughness,strokeWidth:W_("rectangle",n.currentItemStrokeWidthKey),strokeStyle:n.currentItemStrokeStyle,roundness:n.currentItemRoundness==="round"?{type:j_("rectangle")?jw.ADAPTIVE_RADIUS:jw.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:s.x-Zw,y:s.y-Zw,width:Jw(s.width,"rectangle"),height:Jw(s.height,"rectangle"),groupIds:s.groupIds,frameId:s.frameId});if(s.boundElements?.length){let c=s.boundElements.filter(m=>m.type==="arrow").map(m=>m.id);i.filter(m=>c.includes(m.id)).forEach(m=>{let p=m.startBinding,u=m.endBinding;p?.elementId===s.id&&(p={...p,elementId:l.id}),u?.elementId===s.id&&(u={...u,elementId:l.id}),(p||u)&&o.scene.mutateElement(m,{startBinding:p,endBinding:u})})}o.scene.mutateElement(s,{containerId:l.id,verticalAlign:ev.MIDDLE,boundElements:null,textAlign:Qw.CENTER,autoResize:!0}),ov(s,l,o.scene),i=eR([...i,l],l,s),a[l.id]=!0}return{elements:i,appState:{...n,selectedElementIds:a},captureUpdate:lg.IMMEDIATELY}}});import{getNonDeletedElements as gv,isEmbeddableElement as ER}from"@excalidraw/element";import{KEYS as fv}from"@excalidraw/common";import{CaptureUpdateAction as bR}from"@excalidraw/element";import{pointFrom as cv}from"@excalidraw/math";import tR from"clsx";import{useCallback as av,useEffect as sv,useLayoutEffect as nR,useRef as oR,useState as rR}from"react";import{EVENT as mg,HYPERLINK_TOOLTIP_DELAY as iR,KEYS as om}from"@excalidraw/common";import{getElementAbsoluteCoords as fg}from"@excalidraw/element";import{hitElementBoundingBox as aR}from"@excalidraw/element";import{isElementLink as sR}from"@excalidraw/element";import{getEmbedLink as lR,embeddableURLValidator as cR}from"@excalidraw/element";import{sceneCoordsToViewportCoords as dv,viewportCoordsToSceneCoords as dR,wrapEvent as mR,isLocalLink as pR,normalizeLink as pg}from"@excalidraw/common";import{isEmbeddableElement as ug}from"@excalidraw/element";import{jsx as ca,jsxs as lv}from"react/jsx-runtime";var Eg=380,uR=42,hg=5,mv=85,hR=500,gg=!1,rm=new Map,pv=({element:e,scene:n,setAppState:t,onLinkOpen:o,setToast:r,updateEmbedValidationStatus:i})=>{let a=n.getNonDeletedElementsMap(),s=Qn(),l=kn(),c=Ee(),d=e.link||"",[m,p]=rR(d),u=oR(null),E=s.showHyperlinkPopup==="editor",g=av(()=>{if(!u.current)return;let I=pg(u.current.value)||null;if(!e.link&&I&&Be("hyperlink","create"),ug(e)){if(s.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!I){n.mutateElement(e,{link:null}),i(e,!1);return}if(!cR(I,l.validateEmbeddable))I&&r({message:f("toast.unableToEmbed"),closable:!0}),e.link&&rm.set(e.id,e.link),n.mutateElement(e,{link:I}),i(e,!1);else{let{width:T,height:C}=e,P=lR(I);P?.error instanceof URIError&&r({message:f("toast.unrecognizedLinkFormat"),closable:!0});let A=P?P.intrinsicSize.w/P.intrinsicSize.h:1,D=rm.get(e.id)!==e.link;n.mutateElement(e,{...D?{width:P?.type==="video"?T>C?T:C*A:T,height:P?.type==="video"&&T>C?T/A:C}:{},link:I}),i(e,!0),rm.has(e.id)&&rm.delete(e.id)}}else n.mutateElement(e,{link:I})},[e,n,r,l.validateEmbeddable,s.activeEmbeddable,t,i]);nR(()=>()=>{g()},[g]),sv(()=>{E&&u?.current&&!(c.formFactor==="phone"||c.isTouchScreen)&&u.current.select()},[E,c.formFactor,c.isTouchScreen]),sv(()=>{let I=null,T=C=>{if(E)return;I&&clearTimeout(I),fR(e,a,s,cv(C.clientX,C.clientY))&&(I=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},hR))};return window.addEventListener(mg.POINTER_MOVE,T,!1),()=>{window.removeEventListener(mg.POINTER_MOVE,T,!1),I&&clearTimeout(I)}},[s,e,E,t,a]);let b=av(()=>{Be("hyperlink","delete"),n.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,n]),y=()=>{Be("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:w,y:x}=uv(e,s,a);return s.contextMenu||s.selectedElementsAreBeingDragged||s.resizingElement||s.isRotating||s.openMenu||s.viewModeEnabled?null:lv("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${x}px`,left:`${w}px`,width:Eg,padding:hg},children:[E?ca("input",{className:tR("excalidraw-hyperlinkContainer-input"),placeholder:f("labels.link.hint"),ref:u,value:m,onChange:I=>p(I.target.value),autoFocus:!0,onKeyDown:I=>{I.stopPropagation(),I[om.CTRL_OR_CMD]&&I.key===om.K&&I.preventDefault(),(I.key===om.ENTER||I.key===om.ESCAPE)&&(g(),t({showHyperlinkPopup:"info"}))}}):e.link?ca("a",{href:pg(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:pR(e.link)?"_self":"_blank",onClick:I=>{if(e.link&&o){let T=mR(mg.EXCALIDRAW_LINK,I.nativeEvent);o({...e,link:pg(e.link)},T),T.defaultPrevented&&I.preventDefault()}},rel:"noopener noreferrer",children:e.link}):ca("div",{className:"excalidraw-hyperlinkContainer-link",children:f("labels.link.empty")}),lv("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!E&&ca($,{type:"button",title:f("buttons.edit"),"aria-label":f("buttons.edit"),label:f("buttons.edit"),onClick:y,className:"excalidraw-hyperlinkContainer--edit",icon:$n}),ca($,{type:"button",title:f("labels.linkToElement"),"aria-label":f("labels.linkToElement"),label:f("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:d0}),d&&!ug(e)&&ca($,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:b,className:"excalidraw-hyperlinkContainer--remove",icon:Rr})]})]})},uv=(e,n,t)=>{let[o,r]=fg(e,t),{x:i,y:a}=dv({sceneX:o+e.width/2,sceneY:r},n),s=i-n.offsetLeft-Eg/2,l=a-n.offsetTop-mv;return{x:s,y:l}},bg=(e,n)=>{let t=ce(e,n);return ug(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},rl=null,hv=(e,n,t)=>{rl&&clearTimeout(rl),rl=window.setTimeout(()=>gR(e,n,t),iR)},gR=(e,n,t)=>{if(!e.link)return;let o=Xi();o.classList.add("excalidraw-tooltip--visible"),o.style.maxWidth="20rem",o.textContent=sR(e.link)?f("labels.link.goToElement"):e.link;let[r,i,a,s]=fg(e,t),[l,c,d,m]=ax([r,i,a,s],e.angle,n),p=dv({sceneX:l,sceneY:c},n);Nh(o,{left:p.x,top:p.y,width:d,height:m},"top"),Be("hyperlink","tooltip","link-icon"),gg=!0},im=()=>{rl&&clearTimeout(rl),gg&&(gg=!1,Xi().classList.remove("excalidraw-tooltip--visible"))},fR=(e,n,t,[o,r])=>{let{x:i,y:a}=dR({clientX:o,clientY:r},t),s=15/t.zoom.value;if(aR(cv(i,a),e,n))return!1;let[l,c,d]=fg(e,n);if(i>=l&&i<=d&&a>=c-mv&&a<=c)return!1;let{x:m,y:p}=uv(e,t,n);return!(o>=m-s&&o<=m+Eg+hg*2+s&&r>=p-s&&r<=p+s+hg*2+uR)};import{jsx as xR}from"react/jsx-runtime";var xg=O({name:"hyperlink",label:(e,n)=>bg(gv(e),n),icon:Is,perform:(e,n)=>n.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...n,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:bR.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[fv.CTRL_OR_CMD]&&e.key===fv.K,predicate:(e,n)=>ce(e,n).length===1,PanelComponent:({elements:e,appState:n,updateData:t})=>{let o=ce(e,n);return xR($,{type:"toggle",icon:Is,"aria-label":f(bg(gv(e),n)),title:`${ER(e[0])?f("labels.link.labelEmbed"):f("labels.link.label")} - ${N("CtrlOrCmd+K")}`,onSelect:()=>t(null),checked:o.length===1&&!!o[0].link})}});import{KEYS as Ev,arrayToMap as wg,randomId as yR}from"@excalidraw/common";import{elementsAreInSameGroup as wR,getNonDeletedElements as bv,newElementWith as xv,selectGroupsFromGivenElements as yv}from"@excalidraw/element";import{CaptureUpdateAction as wv}from"@excalidraw/element";var yg=e=>e.every(n=>!n.locked),il=O({name:"toggleElementLock",label:(e,n,t)=>{let o=t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1});return yg(o)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,n)=>{let t=ce(n,e);return yg(t)?Uo:fo},trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return r.length>0&&!r.some(i=>i.locked&&i.frameId)},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!r.length)return!1;let i=yg(r),a=wg(r),s=r.length>1&&wR(r),c=r.length===1||s?null:yR(),d={...n.lockedMultiSelections};if(i)d={...n.lockedMultiSelections,...c?{[c]:!0}:{}};else if(s){let y=r[0].groupIds.at(-1);delete d[y]}let m=e.map(y=>{if(!a.has(y.id))return y;let w=y.groupIds;return i?c&&(w=[...w,c]):w=w.filter(x=>!n.lockedMultiSelections[x]),xv(y,{locked:i,groupIds:w.length!==y.groupIds.length?w:y.groupIds})}),p=wg(m),u=i?{}:Object.fromEntries(r.map(y=>[y.id,!0])),E=r.map(y=>p.get(y.id)||y),g=i?{}:yv(bv(E),n),b=i?c||(s?r[0].groupIds.at(-1):r[0].id):null;return{elements:m,appState:{...n,selectedElementIds:u,selectedGroupIds:g,selectedLinearElement:i?null:n.selectedLinearElement,lockedMultiSelections:d,activeLockedId:b},captureUpdate:wv.IMMEDIATELY}},keyTest:(e,n,t,o)=>e.key.toLocaleLowerCase()===Ev.L&&e[Ev.CTRL_OR_CMD]&&e.shiftKey&&o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}).length>0}),vv=O({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:fo,predicate:(e,n)=>ce(e,n).length===0&&e.some(o=>o.locked),perform:(e,n)=>{let t=e.filter(s=>s.locked),o=e.map(s=>{if(s.locked){let l=s.groupIds.filter(c=>!n.lockedMultiSelections[c]);return xv(s,{locked:!1,groupIds:s.groupIds.length!==l.length?l:s.groupIds})}return s}),r=wg(o),i=t.map(s=>r.get(s.id)||s),a=bv(i);return{elements:o,appState:{...n,selectedElementIds:Object.fromEntries(a.map(s=>[s.id,!0])),selectedGroupIds:yv(a,n),lockedMultiSelections:{},activeLockedId:null},captureUpdate:wv.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as _8,isLinearElement as R8,isLineElement as Ea}from"@excalidraw/element";import{arrayToMap as N8,invariant as i2}from"@excalidraw/common";import{toggleLinePolygonState as B8,CaptureUpdateAction as a2}from"@excalidraw/element";import{getSizeFromPoints as CTe,randomInteger as D8,getUpdatedTimestamp as L8}from"@excalidraw/common";import{simplify as m8}from"points-on-curve";import{getStroke as p8,getStrokePoints as sTe}from"perfect-freehand";function $e([e,n,t],[o,r,i]){return[e+o,n+r,t+i]}function da([e,n,t],[o,r,i]){return[e-o,n-r,t-i]}function tt([e,n,t],o){return[e*o,n*o,t*o]}function jr([e,n,t]){return[e/Math.sqrt(e**2+n**2),n/Math.sqrt(e**2+n**2),t]}function xt([e,n,t],o){return[Math.cos(o)*e-Math.sin(o)*n,Math.sin(o)*e+Math.cos(o)*n,t]}function Iv(e,n,t){return $e(e,tt(da(n,e),t))}function vg(e,n,t){return Math.atan2(t[1]-e[1],t[0]-e[0])-Math.atan2(n[1]-e[1],n[0]-e[0])}function Ig(e){return Math.atan2(Math.sin(e),Math.cos(e))}function Tg([e,n]){return Math.sqrt(e**2+n**2)}function Zr([e,n],[t,o]){return Math.sqrt((t-e)**2+(o-n)**2)}function Tv(e){if(e.length<2)return 0;let n=0;for(let t=1;t<=e.length-1;t++)n+=Zr(e[t-1],e[t]);return n+=Zr(e[e.length-2],e[e.length-1]),n}var vR=(e,n,t)=>Math.max(n,Math.min(t,e));function Sv(e,n,t){let o=Zr(n,t);if(o===0)return Zr(e,n);let r=vR(((e[0]-n[0])*(t[0]-n[0])+(e[1]-n[1])*(t[1]-n[1]))/o**2,0,1),i=[n[0]+r*(t[0]-n[0]),n[1]+r*(t[1]-n[1]),e[2]];return Zr(i,e)}function al(e,n){if(n===0||e.length<=2)return e;let t=e[0],o=e[e.length-1],[r,i]=e.reduce(([a,s],l,c)=>{let d=Sv(l,t,o);return d>a?[d,c]:[a,s]},[0,-1]);if(r>=n){let a=e[i];return[...al([t,...e.slice(1,i),a],n).slice(0,-1),a,...al([a,...e.slice(i,-1),o],n).slice(1)]}return[t,o]}var sr=class sr{constructor(n){v(this,"options");v(this,"originalPoints",[]);v(this,"stablePoints",[]);v(this,"tailPoints",[]);v(this,"isFresh",!0);this.options=Object.assign({},sr.defaults,n)}get lastPoint(){return this.tailPoints[this.tailPoints.length-1]??this.stablePoints[this.stablePoints.length-1]}addPoint(n){let t=this.originalPoints[this.originalPoints.length-1];if(!(t&&t[0]===n[0]&&t[1]===n[1])){if(this.originalPoints.push(n),this.isFresh){this.isFresh=!1,this.stablePoints.push(n);return}this.options.streamline>0&&(n=Iv(this.lastPoint,n,1-this.options.streamline)),this.tailPoints.push(n),Tv(this.tailPoints)>sr.constants.maxTailLength&&this.stabilizeTail()}}close(){this.stabilizeTail()}stabilizeTail(){if(this.options.simplify>0&&this.options.simplifyPhase==="tail")throw new Error("Not implemented yet");this.stablePoints.push(...this.tailPoints),this.tailPoints=[]}getSize(n,t,o,r,i){return(n??this.options.size)*this.options.sizeMapping({pressure:t,runningLength:i,currentIndex:o,totalLength:r})}getStrokeOutline(n){if(this.isFresh)return[];let t=[...this.stablePoints,...this.tailPoints];this.options.simplify>0&&this.options.simplifyPhase==="input"&&(t=al(t,this.options.simplify));let o=t.length;if(o===0)return[];if(o===1){let P=t[0],A=this.getSize(n,P[2],0,o,0);if(A<.5)return[];let D=[];for(let _=0;_<=Math.PI*2;_+=Math.PI/16)D.push($e(P,tt(xt([1,0,0],_),A)));return D.push($e(P,tt([1,0,0],this.getSize(n,P[2],0,o,0)))),D}if(o===2){let P=t[0],A=t[1],D=this.getSize(n,P[2],0,o,0),_=this.getSize(n,A[2],0,o,0);if(D<.5||_<.5)return[];let k=[],L=vg(P,[P[0],P[1]-100,P[2]],A);for(let B=L;B<=Math.PI+L;B+=Math.PI/16)k.push($e(P,tt(xt([1,0,0],B),D)));for(let B=Math.PI+L;B<=Math.PI*2+L;B+=Math.PI/16)k.push($e(A,tt(xt([1,0,0],B),_)));return k.push(k[0]),k}let r=[],i=[],a=0,s=0,l=0,c=0;for(let P=1;P<o-1;P++){let A=t[P-1],D=t[P],_=t[P+1],k=D[2],L=Zr(A,D);c+=L,a=s+(L-s)*.2;let B=this.getSize(n,k,P,o,c);if(B===0){l=P+1;continue}let V=jr(da(A,D)),z=jr(da(_,D)),U=xt(V,Math.PI/2),K=xt(V,-Math.PI/2),G=xt(z,Math.PI/2),te=xt(z,-Math.PI/2),F=$e(D,tt(U,B)),W=$e(D,tt(K,B)),le=$e(D,tt(G,B)),we=$e(D,tt(te,B)),de=$e(U,te),he=$e(K,G),ve=$e(D,tt(Tg(de)===0?V:jr(de),B)),ae=$e(D,tt(Tg(he)===0?z:jr(he),B)),fe=Ig(vg(D,A,_)),rt=sr.constants.cornerDetectionMaxAngle/180*Math.PI*sr.constants.cornerDetectionVariance(a);if(Math.abs(fe)<rt){let Ge=Math.abs(Ig(Math.PI-fe));if(Ge===0)continue;if(fe<0){i.push(W,ae);for(let Pe=0;Pe<=Ge;Pe+=Ge/4)r.push($e(D,xt(tt(U,B),Pe)));for(let Pe=Ge;Pe>=0;Pe-=Ge/4)i.push($e(D,xt(tt(U,B),Pe)));i.push(ae,le)}else{r.push(F,ve);for(let Pe=0;Pe<=Ge;Pe+=Ge/4)i.push($e(D,xt(tt(U,-B),-Pe)));for(let Pe=Ge;Pe>=0;Pe-=Ge/4)r.push($e(D,xt(tt(U,-B),-Pe)));r.push(ve,we)}}else r.push(ve),i.push(ae);s=a}if(l>=o-2){if(this.options.keepHead){let P=t[o-1],A=[];for(let D=0;D<=Math.PI*2;D+=Math.PI/16)A.push($e(P,tt(xt([1,0,0],D),this.options.size)));return A.push($e(P,tt([1,0,0],this.options.size))),A}return[]}let d=t[l],m=t[l+1],p=t[o-2],u=t[o-1],E=jr(da(m,d)),g=jr(da(p,u)),b=xt(E,-Math.PI/2),y=xt(g,Math.PI/2),w=this.getSize(n,d[2],0,o,0),x=[],I=this.options.keepHead?this.options.size:this.getSize(n,p[2],o-2,o,c),T=[];if(w>.1){for(let P=0;P<=Math.PI;P+=Math.PI/16)x.unshift($e(d,xt(tt(b,w),-P)));x.unshift($e(d,tt(b,-w)))}else x.push(d);for(let P=0;P<=Math.PI*3;P+=Math.PI/16)T.push($e(u,xt(tt(y,-I),-P)));let C=[...x,...r,...T.reverse(),...i.reverse()];return x.length>0&&C.push(x[0]),this.options.simplify>0&&this.options.simplifyPhase==="output"?al(C,this.options.simplify):C}};v(sr,"defaults",{size:2,streamline:.45,simplify:.1,simplifyPhase:"output",keepHead:!1,sizeMapping:()=>1}),v(sr,"constants",{cornerDetectionMaxAngle:75,cornerDetectionVariance:n=>n>35?.5:1,maxTailLength:50});var ma=sr;import{pointsOnBezierCurves as ode}from"points-on-curve";import{invariant as ide}from"@excalidraw/common";import{curve as sde,lineSegment as lde,pointFrom as cde,pointDistance as dde,pointFromArray as mde,pointFromVector as pde,pointRotateRads as ude,polygon as hde,polygonFromPoints as gde,PRECISION as fde,segmentsIntersectAt as Ede,vector as bde,vectorAdd as xde,vectorFromPoint as yde,vectorScale as wde}from"@excalidraw/math";import{getElementAbsoluteCoords as Ide}from"@excalidraw/element";var Sg=e=>{if(!e)return[];for(let n of e.sets)if(n.type==="path")return n.ops;return e.sets[0].ops};import{pointFrom as u8,pointDistance as Qv,pointRotateRads as mTe}from"@excalidraw/math";import{ROUGHNESS as h8,THEME as Vg,isTransparent as xl,assertNever as g8,COLOR_PALETTE as f8,LINE_POLYGON_POINT_MERGE_DISTANCE as uTe,applyDarkModeFilter as yl,DEFAULT_STROKE_STREAMLINE as E8}from"@excalidraw/common";import{RoughGenerator as b8}from"roughjs/bin/generator";import bIe from"roughjs/bin/rough";import{isRightAngleRads as yIe,lineSegment as wIe,pointFrom as vIe,pointRotateRads as IIe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as SIe,DEFAULT_REDUCED_GLOBAL_ALPHA as CIe,ELEMENT_READY_TO_ERASE_OPACITY as PIe,FRAME_STYLE as kIe,DARK_THEME_FILTER as MIe,MIME_TYPES as Jv,THEME as AIe,distance as DIe,getFontString as LIe,isRTL as _Ie,getVerticalOffset as RIe,invariant as NIe,applyDarkModeFilter as BIe,isSafari as FIe}from"@excalidraw/common";import H2e from"roughjs/bin/rough";import{arrayToMap as W2e,invariant as qv,rescalePoints as V2e,sizeOf as Y2e}from"@excalidraw/common";import{degreesToRadians as Gg,lineSegment as K2e,pointFrom as yt,pointFromArray as r8,pointRotateRads as fa}from"@excalidraw/math";import{pointsOnBezierCurves as j2e}from"points-on-curve";import{pointCenter as i2e,pointFrom as a2e,pointRotateRads as s2e,pointsEqual as l2e,pointDistance as c2e,vectorFromPoint as d2e,curveLength as m2e,curvePointAtLength as p2e}from"@excalidraw/math";import{DRAGGING_THRESHOLD as g2e,KEYS as f2e,shouldRotateWithDiscreteAngle as E2e,getGridPoint as b2e,invariant as x2e,isShallowEqual as y2e,getFeatureFlag as w2e}from"@excalidraw/common";import{arrayToMap as yve,getFeatureFlag as wve,getGridPoint as vve,invariant as Ive,isTransparent as Tve}from"@excalidraw/common";import{PRECISION as Cve,clamp as Pve,lineSegment as kve,pointDistance as Mve,pointDistanceSq as Ave,pointFrom as Dve,pointFromArray as Lve,pointFromVector as _ve,pointRotateRads as Rve,pointsEqual as Nve,vectorFromPoint as Bve,vectorNormalize as Fve,vectorScale as Ove}from"@excalidraw/math";import{invariant as Hwe,isTransparent as Uwe}from"@excalidraw/common";import{curveIntersectLineSegment as Vwe,isPointWithinBounds as Ywe,lineSegment as Xwe,lineSegmentIntersectionPoints as Kwe,pointFrom as $we,pointFromVector as Zwe,pointRotateRads as jwe,pointsEqual as qwe,vectorFromPoint as Jwe,vectorNormalize as Qwe,vectorScale as eve}from"@excalidraw/math";import{ellipse as nve,ellipseSegmentInterceptPoints as ove}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as CR,DEFAULT_PROPORTIONAL_RADIUS as kg,invariant as Rde,LINE_CONFIRM_THRESHOLD as PR,ROUNDNESS as Mg}from"@excalidraw/common";import{bezierEquation as Bde,curve as Fde,curveCatmullRomCubicApproxPoints as Ode,curveOffsetPoints as zde,lineSegment as Gde,lineSegmentIntersectionPoints as Hde,pointDistance as kR,pointFrom as Ude,pointFromArray as Wde,pointFromVector as Vde,pointRotateRads as Yde,pointTranslate as Xde,rectangle as Kde,vectorFromPoint as $de,vectorNormalize as Zde,vectorScale as jde}from"@excalidraw/math";import{ROUNDNESS as Pde,assertNever as kde}from"@excalidraw/common";import{pointsEqual as Ade}from"@excalidraw/math";var Cv=e=>!!e&&e.type==="embeddable",Cg=e=>!!e&&e.type==="iframe",Pg=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),mn=e=>e!=null&&e.type==="text";var no=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var pn=e=>e!=null&&TR(e.type);var An=e=>e!=null&&e.type==="arrow",Dn=e=>An(e)&&e.elbowed;var TR=e=>e==="arrow"||e==="line";var Io=e=>e!==null&&"containerId"in e&&e.containerId!==null&&mn(e);var pa=(e,n=1)=>{if(e.length>=3){let[t,o]=[e[0],e[e.length-1]];return kR(t,o)<=PR/n}return!1},sl=(e,n)=>{if(n.roundness?.type===Mg.PROPORTIONAL_RADIUS||n.roundness?.type===Mg.LEGACY)return e*kg;if(n.roundness?.type===Mg.ADAPTIVE_RADIUS){let t=n.roundness?.value??CR,o=t/kg;return e<=o?e*kg:t}return 0};import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as ywe,ARROW_LABEL_WIDTH_FRACTION as wwe,BOUND_TEXT_PADDING as vwe,DEFAULT_FONT_SIZE as Iwe,TEXT_ALIGN as Twe,VERTICAL_ALIGN as Swe,getFontString as Cwe,isProdEnv as Pwe,invariant as kwe}from"@excalidraw/common";import{pointFrom as Awe,pointRotateRads as Dwe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as dme,DEFAULT_FONT_SIZE as mme,DEFAULT_FONT_FAMILY as pme,getFontString as ume,isTestEnv as hme,normalizeEOL as gme}from"@excalidraw/common";var fme="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as Ime,isTestEnv as Tme}from"@excalidraw/common";import{toIterable as uye}from"@excalidraw/common";import{SHIFT_LOCKING_ANGLE as Mme,viewportCoordsToSceneCoords as Ame}from"@excalidraw/common";import{normalizeRadians as Lme,radiansBetweenAngles as _me,radiansDifference as Rme}from"@excalidraw/math";import{pointsEqual as Bme}from"@excalidraw/math";import{arrayToMap as ype,isShallowEqual as LR}from"@excalidraw/common";import{arrayToMap as epe}from"@excalidraw/common";import{isPointWithinBounds as npe,pointFrom as ope,segmentsIntersectAt as rpe}from"@excalidraw/math";import{arrayToMap as Ume}from"@excalidraw/common";import{validateOrderKey as Vme,generateNKeysBetween as Yme}from"@excalidraw/fractional-indexing";var Ag=(e,n)=>{let t=[];for(let o of e.values())o.frameId===n&&t.push(o);return t};var kpe=function(){let e=null,n=null,t=null,o=(r,i)=>(t!=null&&r===e&&i.selectedElementIds===n||(t=r.some(a=>i.selectedElementIds[a.id]),e=r,n=i.selectedElementIds),t);return o.clearCache=()=>{e=null,n=null,t=null},o}(),pl=(e,n,t)=>{let o=new Set,r=[];for(let i of e.values()){if(n.selectedElementIds[i.id]){qr(i)?(r.push(i),o.add(i.id)):console.error("[NONDELETED][INVARIANT] getSelectedElements skipping deleted selected element which should not be in the selection");continue}if(t?.includeBoundTextElement&&Io(i)&&qr(i)&&n.selectedElementIds[i?.containerId]){r.push(i),o.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return r.forEach(a=>{no(a)&&Ag(e,a.id).forEach(s=>!o.has(s.id)&&i.push(s)),i.push(a)}),i}return r};var Lg=(e,n)=>LR(n.selectedElementIds,e)?n.selectedElementIds:e;var _R=function(){let e=null,n=null,t=null,o=(i,a,s,l)=>{if(t!==void 0&&a===n&&i===e&&s.editingGroupId===t?.editingGroupId)return t;let c={};for(let p of i){let u=p.groupIds;if(s.editingGroupId){let E=u.indexOf(s.editingGroupId);E>-1&&(u=u.slice(0,E))}if(u.length>0){let E=u[u.length-1];c[E]=!0}}let d={},m=a.reduce((p,u)=>{if(u.isDeleted)return p;let E=u.groupIds.find(g=>c[g]);return E&&(p[u.id]=!0,Array.isArray(d[E])?d[E].push(u.id):d[E]=[u.id]),p},{});for(let p of Object.keys(d))d[p].length<2&&c[p]&&(c[p]=!1);return n=a,e=i,t={editingGroupId:s.editingGroupId,selectedGroupIds:c,selectedElementIds:Lg({...s.selectedElementIds,...m},l)},t},r=(i,a,s,l)=>{let c=l?l.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):pl(a,i);return c.length?o(c,a,i,s):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:Lg(i.selectedElementIds,s)}};return r.clearCache=()=>{n=null,e=null,t=null},r}();var Xpe=[1,4/3,3/4,3/2,2/3,2,1/2];import{TEXT_ALIGN as Uue,VERTICAL_ALIGN as Wue}from"@excalidraw/common";import{pointDistance as Yue,pointFromVector as Xue,pointsEqual as Kue,vector as $ue,vectorDot as Zue,vectorFromPoint as jue,vectorNormalize as que,vectorScale as Jue}from"@excalidraw/math";import{invariant as rue,isDevEnv as iue,isTestEnv as aue}from"@excalidraw/common";import{pointFrom as lue,pointFromVector as cue,pointRotateRads as due,pointScaleFromOrigin as mue,pointsEqual as pue,triangleIncludesPoint as uue,vectorCross as hue,vectorFromPoint as BR,vectorScale as gue}from"@excalidraw/math";var gl=[1,0],dm=[0,1],fl=[-1,0],mm=[0,-1],pm=e=>{let[n,t]=e,o=Math.abs(n),r=Math.abs(t);return n>r?gl:n<=-r?fl:t>o?dm:mm},Nv=(e,n)=>pm(BR(e,n)),um=(e,n)=>hm(Nv(e,n)),hl=(e,n)=>e[0]===n[0]&&e[1]===n[1],hm=e=>hl(e,gl)||hl(e,fl);import{DEFAULT_ELEMENT_PROPS as yue,DEFAULT_FONT_FAMILY as wue,DEFAULT_FONT_SIZE as vue,DEFAULT_TEXT_ALIGN as Iue,DEFAULT_VERTICAL_ALIGN as Tue,DEFAULT_STROKE_STREAMLINE as Sue,VERTICAL_ALIGN as Cue,randomInteger as Pue,randomId as kue,getFontString as Mue,getUpdatedTimestamp as Aue,getLineHeight as Due}from"@excalidraw/common";import{pointsOnBezierCurves as whe,simplify as vhe}from"points-on-curve";import{curveToBezier as The}from"points-on-curve/lib/curve-to-bezier";import{distanceToLineSegment as Che,lineSegment as Phe,lineSegmentIntersectionPoints as khe,pointDistance as Mhe,pointFrom as Ahe,pointRotateRads as Dhe,polygonArea as Lhe,polygonIncludesPoint as _he,polygonIncludesPointNonZero as Rhe,polygonSignedArea as Nhe}from"@excalidraw/math";import{isOpaqueColor as Fhe,isTransparent as Ohe}from"@excalidraw/common";var zv=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";import{curvePointDistance as che,distanceToLineSegment as dhe,pointRotateRads as mhe}from"@excalidraw/math";import{ellipse as uhe,ellipseDistanceFromPoint as hhe}from"@excalidraw/math/ellipse";import{pointFrom as Jhe,pointCenter as Qhe,pointRotateRads as ege,vectorFromPoint as tge,vectorNormalize as nge,vectorSubtract as oge,vectorAdd as rge,vectorScale as ige,pointFromVector as age,clamp as sge,isCloseTo as lge}from"@excalidraw/math";import{arrayToMap as Ffe,arrayToObject as Ofe,assertNever as zfe,isDevEnv as Gfe,isShallowEqual as Hfe,isTestEnv as Ufe,randomInteger as Wfe}from"@excalidraw/common";import{assertNever as Vge,COLOR_PALETTE as Yge,isDevEnv as Xge,isTestEnv as Kge,randomId as $ge,Emitter as Zge,toIterable as jge}from"@excalidraw/common";import{ORIG_ID as wge,randomId as vge,randomInteger as Ige,arrayToMap as Tge,castArray as Sge,findLastIndex as Cge,getUpdatedTimestamp as Pge,isTestEnv as kge}from"@excalidraw/common";import{arrayToMap as uge}from"@excalidraw/common";import zR from"lodash.throttle";import{randomInteger as mfe,arrayToMap as pfe,toBrandedType as ufe,isDevEnv as Uv,isTestEnv as Wv,toArray as hfe}from"@excalidraw/common";import{isNonDeletedElement as ffe}from"@excalidraw/element";import{isFrameLikeElement as bfe}from"@excalidraw/element";import{getElementsInGroup as yfe}from"@excalidraw/element";import{syncInvalidIndices as vfe,syncMovedIndices as Ife,validateFractionalIndices as GR}from"@excalidraw/element";import{getSelectedElements as Sfe}from"@excalidraw/element";import{mutateElement as Pfe}from"@excalidraw/element";var kfe=zR(e=>{(Uv()||Wv()||window?.DEBUG_FRACTIONAL_INDICES)&&GR(e,{shouldThrow:Uv()||Wv(),includeBoundTextValidation:!0})},1e3*60,{leading:!0,trailing:!1});import{TEXT_AUTOWRAP_THRESHOLD as hEe,getGridPoint as gEe,getFontString as fEe,DRAGGING_THRESHOLD as EEe}from"@excalidraw/common";import{clamp as kEe,pointDistance as MEe,pointFrom as AEe,pointScaleFromOrigin as DEe,pointsEqual as LEe,pointTranslate as _Ee,vector as REe,vectorCross as NEe,vectorFromPoint as BEe,vectorScale as FEe}from"@excalidraw/math";import{BinaryHeap as zEe,invariant as GEe,isAnyTrue as HEe,getSizeFromPoints as UEe,isDevEnv as WEe,arrayToMap as VEe}from"@excalidraw/common";import{ELEMENT_LINK_KEY as rbe,normalizeLink as ibe}from"@excalidraw/common";import{FONT_FAMILY as dbe,VERTICAL_ALIGN as mbe,escapeDoubleQuotes as pbe,getFontString as ube}from"@excalidraw/common";import{invariant as vbe,toBrandedType as Ibe}from"@excalidraw/common";import{clamp as Sbe,pointFrom as Cbe}from"@excalidraw/math";import{pointDistance as txe,pointFrom as nxe}from"@excalidraw/math";import{invariant as rxe}from"@excalidraw/common";import{arrayToMap as Gbe,findIndex as Hbe,findLastIndex as Ube}from"@excalidraw/common";import{isFiniteNumber as Vbe}from"@excalidraw/math";import{decode as hxe,decodeFrames as gxe}from"modern-gif";import{DEFAULT_GIF_AUTO_DECODE_MAX_FILE_SIZE_BYTES as vxe,MIME_TYPES as Ixe,SVG_NS as Txe}from"@excalidraw/common";import{rgbaToThumbHash as Cxe,thumbHashToRGBA as Pxe}from"thumbhash";import{pointCenter as Xxe,normalizeRadians as Kxe,pointFrom as $xe,pointRotateRads as Zxe}from"@excalidraw/math";import{MIN_FONT_SIZE as qxe,SHIFT_LOCKING_ANGLE as Jxe,rescalePoints as Qxe,getFontString as e1e}from"@excalidraw/common";import{pointFrom as P1e,pointOnLineSegment as k1e,pointRotateRads as M1e}from"@excalidraw/math";import{SIDE_RESIZING_THRESHOLD as D1e}from"@excalidraw/common";import{DEFAULT_TRANSFORM_HANDLE_SPACING as h1e}from"@excalidraw/common";import{pointFrom as f1e,pointRotateRads as E1e}from"@excalidraw/math";import{KEYS as _n}from"@excalidraw/common";var U1e=[{icon:Lc,value:"selection",key:_n.V,numericKey:void 0,fillable:!0,myocSimplifiedMode:!0},{icon:Mi,value:"rectangle",key:_n.R,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Ai,value:"diamond",key:_n.D,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Di,value:"ellipse",key:_n.O,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:_c,value:"arrow",key:_n.A,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Wo,value:"line",key:_n.L,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:$n,value:"freedraw",key:[_n.P,_n.X],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Pn,value:"text",key:_n.T,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:_r,value:"image",key:[_n.I],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Rc,value:"eraser",key:_n.E,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0}];import{pointFrom as e0e}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as n0e,DEFAULT_FONT_SIZE as o0e,TEXT_ALIGN as r0e,VERTICAL_ALIGN as i0e,getSizeFromPoints as a0e,randomId as s0e,arrayToMap as l0e,assertNever as c0e,cloneJSON as d0e,getFontString as m0e,isDevEnv as p0e,toBrandedType as u0e,getLineHeight as h0e}from"@excalidraw/common";import{getBoundsFromPoints as F0e,getElementAbsoluteCoords as O0e}from"@excalidraw/element/bounds";import{newArrowElement as G0e,newElement as H0e,newLinearElement as U0e}from"@excalidraw/element/newElement";import{ELEMENT_PENDING_DRAW_SHAPE_OPACITY as V0e,getStrokeWidthByKey as Y0e,ROUNDNESS as X0e}from"@excalidraw/common";import{convexHull as $0e,distanceToLineSegment as Z0e,elongation as j0e,kurtosis as q0e,lineSegment as J0e,orientPrincipalAxes as Q0e,pointFrom as eye,polygonArea as tye,principalAxes as nye,principalCoords as oye,skewness as rye}from"@excalidraw/math";var lye=[{type:"rectangle",hullFillRatio:1,cornerTurnShare:.95,kurtosisProduct:1.83},{type:"diamond",hullFillRatio:.5,cornerTurnShare:.95,kurtosisProduct:3.24},{type:"ellipse",hullFillRatio:Math.PI/4,cornerTurnShare:.55,kurtosisProduct:2.25}];var qr=e=>!e.isDeleted;var qR=10/1.5;var am=e=>{let n=Math.floor(e.width/2)+1,t=0,o=e.width,r=Math.floor(e.height/2)+1,i=n,a=e.height;return[n,t,o,r,i,a,0,r]};var i8=20,a8=15,s8=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 a8;case"cardinality_one":case"cardinality_exactly_one":case"cardinality_zero_or_one":return i8;default:return 15}},l8=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},_t=(e,n,t,o,r=0)=>{if(o===null||n.length<1)return null;let i=Sg(n[0]);if(i.length<1)return null;let a=t==="start"?1:i.length-1,s=i[a].data;qv(s.length===6,"Op data length is not 6");let l=yt(s[4],s[5]),c=yt(s[2],s[3]),d=yt(s[0],s[1]),m=i[a-1],p=yt(0,0);if(m.op==="move"){let G=r8(m.data);qv(G!=null,"Op data is not a point"),p=G}else m.op==="bcurveTo"&&(p=yt(m.data[4],m.data[5]));let u=(G,te)=>Math.pow(1-G,3)*l[te]+3*G*Math.pow(1-G,2)*c[te]+3*Math.pow(G,2)*(1-G)*d[te]+p[te]*Math.pow(G,3),[E,g]=t==="start"?p:l,[b,y]=[u(.3,0),u(.3,1)],w=Math.hypot(E-b,g-y),x=(E-b)/w,I=(g-y)/w,T=s8(o),C=0;{let[G,te]=t==="end"?e.points[e.points.length-1]:e.points[0],[F,W]=e.points.length>1?t==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];C=Math.hypot(G-F,te-W)}let A=Math.min(T,C*(o==="diamond"||o==="diamond_outline"?.25:.5)),D=E-x*A*r,_=g-I*A*r,k=D-x*A,L=_-I*A;if(o==="circle"||o==="circle_outline"){let G=Math.hypot(L-_,k-D)+e.strokeWidth-2;return[D,_,G]}let B=l8(o);if(o==="cardinality_many"||o==="cardinality_one_or_many"){let[G,te]=fa(yt(D,_),yt(k,L),Gg(-B)),[F,W]=fa(yt(D,_),yt(k,L),Gg(B));return[k,L,G,te,F,W]}let[V,z]=fa(yt(k,L),yt(D,_),-B*Math.PI/180),[U,K]=fa(yt(k,L),yt(D,_),Gg(B));if(o==="diamond"||o==="diamond_outline"){let G,te;if(t==="start"){let[F,W]=e.points.length>1?e.points[1]:[0,0];[G,te]=fa(yt(D+A*2,_),yt(D,_),Math.atan2(W-_,F-D))}else{let[F,W]=e.points.length>1?e.points[e.points.length-2]:[0,0];[G,te]=fa(yt(D-A*2,_),yt(D,_),Math.atan2(_-W,D-F))}return[D,_,V,z,G,te,U,K]}return[D,_,V,z,U,K]};var c8=typeof document<"u"?document.createElement("img"):{src:""};c8.src=`data:${Jv.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 d8=typeof document<"u"?document.createElement("img"):{src:""};d8.src=`data:${Jv.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 Hg=new WeakMap;var Ut=class Ut{};v(Ut,"rg",new b8),v(Ut,"cache",new WeakMap),v(Ut,"get",(n,t)=>{let o=Ut.cache.get(n);if(o&&(t===null||o.theme===t))return o.shape}),v(Ut,"delete",n=>{Ut.cache.delete(n),Hg.delete(n)}),v(Ut,"destroy",()=>{Ut.cache=new WeakMap}),v(Ut,"generateElementShape",(n,t)=>{let o=t?.isExporting?void 0:Ut.get(n,t?t.theme:null);if(o!==void 0)return o;Hg.delete(n);let r=w8(n,Ut.rg,t||{isExporting:!1,canvasBackgroundColor:f8.white,embedsValidationStatus:null,theme:Vg.LIGHT});return t?.isExporting||Ut.cache.set(n,{shape:r,theme:t?.theme||Vg.LIGHT}),r});var ga=Ut,x8=e=>[8,8+e],o2=e=>[1.5,6+e];function y8(e){let n=e.roughness,t=Math.max(e.width,e.height),o=Math.min(e.width,e.height);return o>=20&&t>=50||o>=15&&e.roundness&&zv(e.type)||pn(e)&&t>=50?n:Math.min(n/(t<10?3:2),2.5)}var So=(e,n=!1,t=!1)=>{let o={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?x8(e.strokeWidth):e.strokeStyle==="dotted"?o2(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:y8(e),stroke:yl(e.strokeColor,t),preserveVertices:n||e.roughness<h8.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return o.fillStyle=e.fillStyle,o.fill=xl(e.backgroundColor)?void 0:yl(e.backgroundColor,t),e.type==="ellipse"&&(o.curveFitting=1),o;case"line":case"freedraw":return pa(e.points)&&(o.fillStyle=e.fillStyle,o.fill=e.backgroundColor==="transparent"?void 0:yl(e.backgroundColor,t)),o;case"arrow":return o;default:throw new Error(`Unimplemented type ${e.type}`)}},e2=(e,n,t)=>Pg(e)&&(n||Cv(e)&&t?.get(e.id)!==!0)&&xl(e.backgroundColor)&&xl(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:Cg(e)?{...e,strokeColor:xl(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:xl(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,bl=(e,n,t)=>{if(n===null)return[];let[,,o,r,i,a]=n;return[e.line(o,r,i,a,t)]},fm=(e,n,t)=>{if(n===null)return[];let[o,r,i,a,s,l]=n;return[e.line(i,a,o,r,t),e.line(s,l,o,r,t)]},Qr=(e,n)=>{let t={...n};if(e.strokeStyle==="dotted"){let o=o2(e.strokeWidth-1);t.strokeLineDash=[o[0],o[1]-1]}else delete t.strokeLineDash;return t.roughness=Math.min(1,t.roughness||0),t},Ug=(e,n,t,o,r,i=1)=>{if(o===null)return[];let[a,s,l]=o,c={...n,fill:r,fillStyle:"solid",stroke:t,roughness:Math.min(.5,n.roughness||0)};return delete c.strokeLineDash,[e.circle(a,s,l*i,c)]},t2=(e,n,t,o,r,i,a,s)=>{if(o===null)return[];let l=yl(e.strokeColor,s),c=yl(a,s),d=-.25,m=.8;switch(o){case"circle":case"circle_outline":return Ug(r,i,l,_t(e,n,t,o),o==="circle_outline"?c:l);case"triangle":case"triangle_outline":{let p=_t(e,n,t,o);if(p===null)return[];let[u,E,g,b,y,w]=p,x={...i,fill:o==="triangle_outline"?c:l,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)};return delete x.strokeLineDash,[r.polygon([[u,E],[g,b],[y,w],[u,E]],x)]}case"diamond":case"diamond_outline":{let p=_t(e,n,t,o);if(p===null)return[];let[u,E,g,b,y,w,x,I]=p,T={...i,fill:o==="diamond_outline"?c:l,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)};return delete T.strokeLineDash,[r.polygon([[u,E],[g,b],[y,w],[x,I],[u,E]],T)]}case"cardinality_one":return bl(r,_t(e,n,t,o),Qr(e,i));case"cardinality_many":return fm(r,_t(e,n,t,o),Qr(e,i));case"cardinality_one_or_many":{let p=Qr(e,i);return[...fm(r,_t(e,n,t,"cardinality_many"),p),...bl(r,_t(e,n,t,"cardinality_one",d),p)]}case"cardinality_exactly_one":{let p=Qr(e,i);return[...bl(r,_t(e,n,t,"cardinality_one",-.5),p),...bl(r,_t(e,n,t,"cardinality_one"),p)]}case"cardinality_zero_or_one":{let p=Qr(e,i);return[...Ug(r,i,l,_t(e,n,t,"circle_outline",1.5),c,m),...bl(r,_t(e,n,t,"cardinality_one",-.5),p)]}case"cardinality_zero_or_many":{let p=Qr(e,i);return[...fm(r,_t(e,n,t,"cardinality_many"),p),...Ug(r,i,l,_t(e,n,t,"circle_outline",1.5),c,m)]}case"bar":case"arrow":default:return fm(r,_t(e,n,t,o),Qr(e,i))}};var w8=(e,n,{isExporting:t,canvasBackgroundColor:o,embedsValidationStatus:r,theme:i})=>{let a=i===Vg.DARK;switch(e.type){case"rectangle":case"iframe":case"embeddable":{let s;if(e.roundness){let l=e.width,c=e.height,d=sl(Math.min(l,c),e);s=n.path(`M ${d} 0 L ${l-d} 0 Q ${l} 0, ${l} ${d} L ${l} ${c-d} Q ${l} ${c}, ${l-d} ${c} L ${d} ${c} Q 0 ${c}, 0 ${c-d} L 0 ${d} Q 0 0, ${d} 0`,So(e2(e,t,r),!0,a))}else s=n.rectangle(0,0,e.width,e.height,So(e2(e,t,r),!1,a));return s}case"diamond":{let s,[l,c,d,m,p,u,E,g]=am(e);if(e.roundness){let b=sl(Math.abs(l-E),e),y=sl(Math.abs(m-c),e);s=n.path(`M ${l+b} ${c+y} L ${d-b} ${m-y}
5
- C ${d} ${m}, ${d} ${m}, ${d-b} ${m+y}
6
- L ${p+b} ${u-y}
7
- C ${p} ${u}, ${p} ${u}, ${p-b} ${u-y}
8
- L ${E+b} ${g+y}
9
- C ${E} ${g}, ${E} ${g}, ${E+b} ${g-y}
10
- L ${l-b} ${c+y}
11
- C ${l} ${c}, ${l} ${c}, ${l+b} ${c+y}`,So(e,!0,a))}else s=n.polygon([[l,c],[d,m],[p,u],[E,g]],So(e,!1,a));return s}case"ellipse":return n.ellipse(e.width/2,e.height/2,e.width,e.height,So(e,!1,a));case"line":case"arrow":{let s,l=So(e,!1,a),c=e.points.length?e.points:[u8(0,0)];if(Dn(e)?c.every(d=>Math.abs(d[0])<=1e6&&Math.abs(d[1])<=1e6)?s=[n.path(v8(c,16),So(e,!0,a))]:(console.error("Elbow arrow with extreme point positions detected. Arrow not rendered.",e.id,JSON.stringify(c)),s=[]):e.roundness?s=[n.curve(c,l)]:l.fill?s=[n.polygon(c,l)]:s=[n.linearPath(c,l)],e.type==="arrow"){let{startArrowhead:d=null,endArrowhead:m="arrow"}=e;if(d!==null){let p=t2(e,s,"start",d,n,l,o,a);s.push(...p)}if(m!==null){let p=t2(e,s,"end",m,n,l,o,a);s.push(...p)}}return s}case"freedraw":{let s=[];if(pa(e.points)){let l=m8(e.points,.75);s.push(n.curve(l,{...So(e,!1,a),stroke:"none"}))}return s.push(I8(e)),s}case"frame":case"magicframe":case"text":case"image":return null;default:return g8(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},v8=(e,n)=>{let t=[];for(let r=1;r<e.length-1;r+=1){let i=e[r-1],a=e[r+1],s=e[r],l=um(s,i),c=um(a,s),d=Math.min(n,Qv(e[r],a)/2,Qv(e[r],i)/2);l?i[0]<s[0]?t.push([e[r][0]-d,e[r][1]]):t.push([e[r][0]+d,e[r][1]]):i[1]<s[1]?t.push([e[r][0],e[r][1]-d]):t.push([e[r][0],e[r][1]+d]),t.push(e[r]),c?a[0]<s[0]?t.push([e[r][0]-d,e[r][1]]):t.push([e[r][0]+d,e[r][1]]):a[1]<s[1]?t.push([e[r][0],e[r][1]-d]):t.push([e[r][0],e[r][1]+d])}let o=[`M ${e[0][0]} ${e[0][1]}`];for(let r=0;r<t.length;r+=3)o.push(`L ${t[r][0]} ${t[r][1]}`),o.push(`Q ${t[r+1][0]} ${t[r+1][1]}, ${t[r+2][0]} ${t[r+2][1]}`);return o.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),o.join(" ")};var I8=e=>A8(k8(e)),Wg={SIZE_FACTOR:4.25,THINNING:.6,SMOOTHING:.5},T8={SIZE_FACTOR:1.4},r2=e=>e.strokeOptions?.streamline??E8,S8=e=>{let n=e.simulatePressure?e.points:e.points.length?e.points.map(([t,o],r)=>[t,o,e.pressures[r]]):[[0,0,.5]];return p8(n,{simulatePressure:e.simulatePressure,size:e.strokeWidth*Wg.SIZE_FACTOR,thinning:Wg.THINNING,smoothing:Wg.SMOOTHING,streamline:r2(e),easing:t=>Math.sin(t*Math.PI/2),last:!0})},C8=e=>new ma({size:e.strokeWidth*T8.SIZE_FACTOR,streamline:r2(e),simplify:0,sizeMapping:n=>Math.max(.1,n.pressure)}),P8=e=>{let n=C8(e);return e.points.map(([t,o])=>n.addPoint([t,o,1])),n.getStrokeOutline().map(([t,o])=>[t,o])},k8=e=>e.strokeOptions?.variability==="constant"?P8(e):S8(e);var n2=(e,n)=>[(e[0]+n[0])/2,(e[1]+n[1])/2],M8=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g,A8=e=>{if(!e.length)return"";let n=e.length-1;return e.reduce((t,o,r,i)=>(r===n?t.push(o,n2(o,i[0]),"L",i[0],"Z"):t.push(o,n2(o,i[r+1])),t),["M",e[0],"Q"]).join(" ").replace(M8,"$1")};var Jr=(e,n,t=!1)=>{let o=!1;for(let r in n){let i=n[r];if(typeof i<"u"){if(e[r]===i&&(typeof i!="object"||i===null))continue;o=!0}}return!o&&!t?e:{...e,...n,version:n.version??e.version+1,versionNonce:n.versionNonce??D8(),updated:L8()}};import{jsx as s2}from"react/jsx-runtime";var ba=O({name:"toggleLinearEditor",label:(e,n,t)=>t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return!!(!n.selectedLinearElement?.isEditing&&r.length===1&&R8(r[0])&&!_8(r[0]))},perform(e,n,t,o){i2(n.selectedLinearElement,"No selected linear element found");let r=o.scene.getElement(n.selectedLinearElement.elementId);i2(r,"No selected element found");let i={...n.selectedLinearElement,isEditing:!n.selectedLinearElement.isEditing};return{appState:{...n,selectedLinearElement:i},captureUpdate:a2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0];if(!o)return null;let r=f(o.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return s2($,{type:"button",icon:s0,title:r,"aria-label":r,onClick:()=>n(null)})}}),GTe=O({name:"togglePolygon",icon:vu,keywords:["loop"],label:(e,n,t)=>!t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds}).some(i=>!Ea(i)||!i.polygon)?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds});return r.length>0&&r.every(i=>Ea(i)&&i.points.length>=4)},perform(e,n,t,o){let r=o.scene.getSelectedElements(n);if(r.some(l=>!Ea(l)))return!1;let i=r,a=i.some(l=>!l.polygon),s=N8(i);return{elements:e.map(l=>!s.has(l.id)||!Ea(l)?l:Jr(l,{backgroundColor:a?l.backgroundColor:"transparent",...B8(l,a)})),appState:n,captureUpdate:a2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(o.length===0||o.some(a=>!Ea(a)||!a.polygon||a.points.length<3))return null;let r=o.every(a=>Ea(a)&&a.polygon),i=f(r?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return s2($,{type:"toggle",icon:vu,title:i,"aria-label":i,checked:r,onSelect:()=>n(null),style:{marginLeft:"auto"}})}});import{KEYS as l2,CANVAS_SEARCH_TAB as c2,CLASSES as F8,DEFAULT_SIDEBAR as d2}from"@excalidraw/common";import{CaptureUpdateAction as O8}from"@excalidraw/element";var wl=O({name:"searchMenu",icon:Jn,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,n,t,o){if(n.openDialog)return!1;if(n.openSidebar?.name===d2.name&&n.openSidebar.tab===c2){let r=o.excalidrawContainerValue.container?.querySelector(`.${F8.SEARCH_MENU_INPUT_WRAPPER} input`);return r?.focus(),r?.select(),!1}return{appState:{...n,openSidebar:{name:d2.name,tab:c2},openDialog:null},captureUpdate:O8.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[l2.CTRL_OR_CMD]&&e.key===l2.F});import{isImageElement as z8}from"@excalidraw/element";import{CaptureUpdateAction as G8}from"@excalidraw/element";import{jsx as H8}from"react/jsx-runtime";var Yg=O({name:"cropEditor",label:"helpDialog.cropStart",icon:Xu,viewMode:!0,trackEvent:{category:"menu"},keywords:["image","crop"],perform(e,n,t,o){let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...n,isCropping:!1,croppingElementId:r.id},captureUpdate:G8.IMMEDIATELY}},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return!!(!n.croppingElementId&&r.length===1&&z8(r[0]))},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=f("helpDialog.cropStart");return H8($,{type:"button",icon:Xu,title:o,"aria-label":o,onClick:()=>n(null)})}});import{getNonDeletedElements as U8}from"@excalidraw/element";import{mutateElement as W8}from"@excalidraw/element";import{newFrameElement as V8}from"@excalidraw/element";import{isFrameLikeElement as Em}from"@excalidraw/element";import{addElementsToFrame as Y8,removeAllElementsFromFrame as X8}from"@excalidraw/element";import{getFrameChildren as K8}from"@excalidraw/element";import{getElementsInGroup as $8}from"@excalidraw/element";import{getCommonBounds as Z8}from"@excalidraw/element";import{CaptureUpdateAction as xa}from"@excalidraw/element";var m2=(e,n)=>{let t=n.scene.getSelectedElements(e);return t.length===1&&Em(t[0])},p2=O({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;if(Em(r)){let i=K8(U8(e),r.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...n,selectedElementIds:i.reduce((a,s)=>(a[s.id]=!0,a),{})},captureUpdate:xa.IMMEDIATELY}}return{elements:e,appState:n,captureUpdate:xa.EVENTUALLY}},predicate:(e,n,t,o)=>m2(n,o)}),u2=O({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;return Em(r)?{elements:X8(e,r),appState:{...n,selectedElementIds:{[r.id]:!0}},captureUpdate:xa.IMMEDIATELY}:{elements:e,appState:n,captureUpdate:xa.EVENTUALLY}},predicate:(e,n,t,o)=>m2(n,o)}),ZSe=O({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n)=>({elements:e,appState:{...n,frameRendering:{...n.frameRendering,enabled:!n.frameRendering.enabled}},captureUpdate:xa.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),h2=O({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=ce(e,n);return r.length>0&&!r.some(i=>Em(i))},perform:(e,n,t,o)=>{let r=ce(e,n),i=o.scene.getNonDeletedElementsMap(),[a,s,l,c]=Z8(r,i),d=16,m=V8({x:a-d,y:s-d,width:l-a+d*2,height:c-s+d*2});if(n.editingGroupId){let u=$8(r,n.editingGroupId);for(let E of u){let g=E.groupIds.indexOf(n.editingGroupId);W8(E,i,{groupIds:E.groupIds.slice(0,g)})}}return{elements:Y8([...o.scene.getElementsIncludingDeleted(),m],r,m),appState:{selectedElementIds:{[m.id]:!0}},captureUpdate:xa.IMMEDIATELY}}});import{KEYS as wa,matchKey as $g,arrayToMap as g2,MOBILE_ACTION_BUTTON_BG as f2}from"@excalidraw/common";import{CaptureUpdateAction as Kg}from"@excalidraw/element";import{orderByFractionalIndex as nN}from"@excalidraw/element";import{Emitter as j8}from"@excalidraw/common";import{CaptureUpdateAction as q8,StoreChange as J8,StoreDelta as Q8}from"@excalidraw/element";var ya=class extends Q8{applyTo(n,t,o){let[r,i]=this.elements.applyTo(n,o.elements,{excludedProperties:new Set(["version","versionNonce"])}),[a,s]=this.appState.applyTo(t,r);return[r,a,i||s]}static calculate(n,t){return super.calculate(n,t)}static inverse(n){return super.inverse(n)}static applyLatestChanges(n,t,o,r){return super.applyLatestChanges(n,t,o,r)}},ei=class{constructor(n=!0,t=!0){this.isUndoStackEmpty=n;this.isRedoStackEmpty=t}},vl=class e{constructor(n){this.store=n;v(this,"onHistoryChangedEmitter",new j8);v(this,"undoStack",[]);v(this,"redoStack",[])}get isUndoStackEmpty(){return this.undoStack.length===0}get isRedoStackEmpty(){return this.redoStack.length===0}clear(){this.undoStack.length=0,this.redoStack.length=0}record(n){if(n.isEmpty()||n instanceof ya)return;let t=ya.inverse(n);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new ei(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(n,t){return this.perform(n,t,()=>e.pop(this.undoStack),o=>e.push(this.redoStack,o))}redo(n,t){return this.perform(n,t,()=>e.pop(this.redoStack),o=>e.push(this.undoStack,o))}perform(n,t,o,r){try{let i=o();if(i===null)return;let a=q8.IMMEDIATELY,s=this.store.snapshot,l=n,c=t,d=!1;for(;i;){try{[l,c,d]=i.applyTo(l,c,s);let m=s.elements,p=s.maybeClone(a,l,c),u=J8.create(s,p),E=ya.applyLatestChanges(i,m,l);E.isEmpty()||(this.store.scheduleMicroAction({action:a,change:u,delta:E}),i=E),s=p}finally{r(i)}if(d)break;i=o()}return[l,c]}finally{this.onHistoryChangedEmitter.trigger(new ei(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(n){if(!n.length)return null;let t=n.pop();return t!==void 0?t:null}static push(n,t){let o=ya.inverse(t);return n.push(o)}};import{useEffect as eN,useState as tN}from"react";var Xg=(e,n)=>{let[t,o]=tN(n);return eN(()=>{let r=e.on(i=>{o(i)});return()=>{r()}},[e]),t};import{jsx as y2}from"react/jsx-runtime";var E2=(e,n,t)=>{if(!n.multiElement&&!n.resizingElement&&!n.editingTextElement&&!n.newElement&&!n.selectedElementsAreBeingDragged&&!n.selectionElement&&!e.flowchart.isCreatingChart&&!e.drawShape.hasPendingGesture()){let o=t();if(!o)return{captureUpdate:Kg.EVENTUALLY};let[r,i]=o,a=nN(Array.from(r.values()));return{appState:i,elements:a,captureUpdate:Kg.NEVER}}return{captureUpdate:Kg.EVENTUALLY}},b2=e=>({name:"undo",label:"buttons.undo",icon:Cu,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>E2(r,t,()=>e.undo(g2(n),t)),keyTest:n=>n[wa.CTRL_OR_CMD]&&$g(n,wa.Z)&&!n.shiftKey,PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isUndoStackEmpty:i}=Xg(e.onHistoryChangedEmitter,new ei(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=ct()==="mobile";return y2($,{type:"button",icon:Cu,"aria-label":f("buttons.undo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-undo",style:{...a?f2:{}}})}}),x2=e=>({name:"redo",label:"buttons.redo",icon:Pu,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>E2(r,t,()=>e.redo(g2(n),t)),keyTest:n=>n[wa.CTRL_OR_CMD]&&n.shiftKey&&$g(n,wa.Z)||n[wa.CTRL_OR_CMD]&&!n.shiftKey&&$g(n,wa.Y),PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isRedoStackEmpty:i}=Xg(e.onHistoryChangedEmitter,new ei(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=ct()==="mobile";return y2($,{type:"button",icon:Pu,"aria-label":f("buttons.redo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-redo",style:{...a?f2:{}}})}});import{getFontString as oN}from"@excalidraw/common";import{getTextAnchorRatios as rN,isExcalidrawElement as iN,isNonDeletedElement as aN,newElementWith as sN,updateBoundElements as lN}from"@excalidraw/element";import{measureText as cN}from"@excalidraw/element";import{isTextElement as Zg}from"@excalidraw/element";import{CaptureUpdateAction as dN}from"@excalidraw/element";var jg=O({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,n,t)=>{let o=ce(e,n);return o.length===1&&Zg(o[0])&&!o[0].autoResize},perform:(e,n,t,o)=>{let r=ce(e,n),i=iN(t)&&Zg(t)?t:r[0],a=e.find(d=>d.id===i?.id);if(!a||!Zg(a))return!1;let s=cN(a.originalText,oN(a),a.lineHeight),l=rN(a),c=sN(a,{autoResize:!0,width:s.width,height:s.height,x:a.x+(a.width-s.width)*l.x,y:a.y+(a.height-s.height)*l.y,text:a.originalText});return aN(c)&&lN(c,o.scene,{changedElements:new Map([[c.id,c]])}),{appState:n,elements:e.map(d=>d.id===c.id?c:d),captureUpdate:dN.IMMEDIATELY}}});import{CODES as mN,KEYS as pN}from"@excalidraw/common";import uN from"clsx";import{CaptureUpdateAction as hN}from"@excalidraw/element";import{jsx as gN}from"react/jsx-runtime";var va=O({name:"viewMode",label:"labels.viewMode",icon:Fr,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,n){return n.viewModeOnly?!1:{appState:{...n,viewModeEnabled:!this.checked(n)},captureUpdate:hN.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,n,t,o)=>!n.viewModeOnly&&!t.viewModeOnly&&typeof t.viewModeEnabled>"u"&&o.isInteractionEnabled(),keyTest:e=>!e[pN.CTRL_OR_CMD]&&e.altKey&&e.code===mN.R,PanelComponent:({data:e,updateData:n,appState:t,appProps:o})=>{if(t.viewModeOnly||o.viewModeOnly)return null;let r=t.viewModeEnabled?"Edit mode":f("labels.viewMode");return gN($,{type:"button",icon:t.viewModeEnabled?ju:Fr,"aria-label":r,onClick:()=>n(null),size:e?.size||"medium","data-testid":"button-view-mode",className:uN({enabled:t.viewModeEnabled})})}});import{isPromiseLike as fN}from"@excalidraw/common";import{jsx as EN}from"react/jsx-runtime";var qg=(e,n,t,o,r,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,o,i))&&Be(e.trackEvent.category,e.trackEvent.action||e.name,`${n} (${r.editorInterface.formFactor==="phone"?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},bm=class{constructor(n,t,o,r){v(this,"actions",{});v(this,"updater");v(this,"getAppState");v(this,"getElementsIncludingDeleted");v(this,"app");v(this,"isActionBlockedByViewportTransition",n=>n.navigation===!0&&this.app.viewport.isLockedTransitionPending);v(this,"renderAction",(n,t)=>{let o=this.app.props.UIOptions.canvasActions;if(this.actions[n]&&"PanelComponent"in this.actions[n]&&(!(n in o)||o[n])){let r=this.actions[n],i=r.PanelComponent;i.displayName="PanelComponent";let a=s=>{this.isActionBlockedByViewportTransition(r)||(qg(r,"ui",this.getAppState(),this.getElementsIncludingDeleted(),this.app,s),this.updater(r.perform(this.getElementsIncludingDeleted(),this.getAppState(),s,this.app)))};return EN(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:a,appProps:this.app.props,app:this.app,data:t,renderAction:this.renderAction})}return null});v(this,"isActionEnabled",n=>{let t=this.getElementsIncludingDeleted(),o=this.getAppState();return!n.predicate||n.predicate(t,o,this.app.props,this.app)});this.updater=i=>{if(fN(i))i.then(a=>n(a));else return n(i)},this.getAppState=t,this.getElementsIncludingDeleted=o,this.app=r}registerAction(n){this.actions[n.name]=n}registerAll(n){n.forEach(t=>this.registerAction(t))}handleKeyDown(n){if(!this.app.isInteractionEnabled()&&!this.app.isNavigationEnabled())return!1;let t=this.app.props.UIOptions.canvasActions,o=Object.values(this.actions).sort((l,c)=>(c.keyPriority||0)-(l.keyPriority||0)).filter(l=>(l.name in t?t[l.name]:!0)&&l.keyTest&&l.keyTest(n,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(o.length!==1)return o.length>1&&console.warn("Canceling as multiple actions match this shortcut",o),!1;let r=o[0];if(!this.app.isInteractionEnabled()&&r.navigation!==!0||this.getAppState().viewModeEnabled&&r.viewMode!==!0)return!1;if(this.isActionBlockedByViewportTransition(r))return n.preventDefault(),n.stopPropagation(),!0;let i=this.getElementsIncludingDeleted(),a=this.getAppState(),s=null;return qg(r,"keyboard",a,i,this.app,null),n.preventDefault(),n.stopPropagation(),this.updater(o[0].perform(i,a,s,this.app)),!0}executeAction(n,t="api",o=null){if(t!=="api"&&!this.app.isInteractionEnabled()&&!(this.app.isNavigationEnabled()&&n.navigation===!0)||this.isActionBlockedByViewportTransition(n))return;let r=this.getElementsIncludingDeleted(),i=this.getAppState();qg(n,t,i,r,this.app,o),this.updater(n.perform(r,i,o,this.app))}};var Jg=e=>{let n=Array.from(e.values());return{x:w2(n,t=>t.x)/n.length,y:w2(n,t=>t.y)/n.length}},Qg=([e,n])=>Math.hypot(e.x-n.x,e.y-n.y),w2=(e,n)=>e.reduce((t,o)=>t+n(o),0);import{pointFrom as Y,pointRotateRads as lr,rangeInclusive as un,rangeIntersection as xm,rangesOverlap as ym}from"@excalidraw/math";import{TOOL_TYPE as ti,KEYS as v2}from"@excalidraw/common";import{getCommonBounds as ef,getDraggedElementsBounds as tf,getElementAbsoluteCoords as bN}from"@excalidraw/element";import{isBoundToContainer as C2}from"@excalidraw/element";import{getMaximumGroups as P2}from"@excalidraw/element";import{getSelectedElements as xN,getVisibleAndNonSelectedElements as k2}from"@excalidraw/element";var yN=8,I2=99999,wm=e=>yN/e,Rt=class Rt{};v(Rt,"referenceSnapPoints",null),v(Rt,"visibleGaps",null),v(Rt,"setReferenceSnapPoints",n=>{Rt.referenceSnapPoints=n}),v(Rt,"getReferenceSnapPoints",()=>Rt.referenceSnapPoints),v(Rt,"setVisibleGaps",n=>{Rt.visibleGaps=n}),v(Rt,"getVisibleGaps",()=>Rt.visibleGaps),v(Rt,"destroy",()=>{Rt.referenceSnapPoints=null,Rt.visibleGaps=null});var hn=Rt,cr=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,Co=({event:e,app:n,selectedElements:t})=>{if(e){let o=n.state.activeTool.type==="lasso"&&n.state.selectedElementsAreBeingDragged;return(n.state.activeTool.type!=="lasso"||o)&&(n.state.objectsSnapModeEnabled&&!e[v2.CTRL_OR_CMD]||!n.state.objectsSnapModeEnabled&&e[v2.CTRL_OR_CMD]&&!cr(n))}return t.length===1&&t[0].type==="arrow"?!1:n.state.objectsSnapModeEnabled},wN=(e,n,t=.01)=>Math.abs(e-n)<=t,Il=(e,n,{omitCenter:t,boundingBoxCorners:o,dragOffset:r}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[s,l,c,d,m,p]=bN(a,n);r&&(s+=r.x,c+=r.x,m+=r.x,l+=r.y,d+=r.y,p+=r.y);let u=(c-s)/2,E=(d-l)/2;if((a.type==="diamond"||a.type==="ellipse")&&!o){let g=lr(Y(s,l+E),Y(m,p),a.angle),b=lr(Y(s+u,l),Y(m,p),a.angle),y=lr(Y(c,l+E),Y(m,p),a.angle),w=lr(Y(s+u,d),Y(m,p),a.angle),x=Y(m,p);i=t?[g,b,y,w]:[g,b,y,w,x]}else{let g=lr(Y(s,l),Y(m,p),a.angle),b=lr(Y(c,l),Y(m,p),a.angle),y=lr(Y(s,d),Y(m,p),a.angle),w=lr(Y(c,d),Y(m,p),a.angle),x=Y(m,p);i=t?[g,b,y,w]:[g,b,y,w,x]}}else if(e.length>1){let[a,s,l,c]=tf(e,r??{x:0,y:0}),d=l-a,m=c-s,p=Y(a,s),u=Y(l,s),E=Y(a,c),g=Y(l,c),b=Y(a+d/2,s+m/2);i=t?[p,u,E,g]:[p,u,E,g,b]}return i.map(a=>Y(Xe(a[0]),Xe(a[1])))},M2=(e,n,t,o)=>k2(e,n,t,o),A2=(e,n,t,o)=>{let r=M2(e,n,t,o),i=P2(r,o).filter(m=>!(m.length===1&&C2(m[0]))).map(m=>ef(m).map(p=>Xe(p))),a=i.sort((m,p)=>m[0]-p[0]),s=[],l=0;e:for(let m=0;m<a.length;m++){let p=a[m];for(let u=m+1;u<a.length;u++){if(++l>I2)break e;let E=a[u],[,g,b,y]=p,[w,x,,I]=E;b<w&&ym(un(g,y),un(x,I))&&s.push({startBounds:p,endBounds:E,startSide:[Y(b,g),Y(b,y)],endSide:[Y(w,x),Y(w,I)],length:w-b,overlap:xm(un(g,y),un(x,I))})}}let c=i.sort((m,p)=>m[1]-p[1]),d=[];l=0;e:for(let m=0;m<c.length;m++){let p=c[m];for(let u=m+1;u<c.length;u++){if(++l>I2)break e;let E=c[u],[g,,b,y]=p,[w,x,I]=E;y<x&&ym(un(g,b),un(w,I))&&d.push({startBounds:p,endBounds:E,startSide:[Y(g,y),Y(b,y)],endSide:[Y(w,x),Y(I,x)],length:x-y,overlap:xm(un(g,b),un(w,I))})}}return{horizontalGaps:s,verticalGaps:d}},T2=(e,n,t,o,r,i,a)=>{if(!Co({app:t,event:o,selectedElements:e}))return[];if(e.length===0)return[];let s=hn.getVisibleGaps();if(s){let{horizontalGaps:l,verticalGaps:c}=s,[d,m,p,u]=tf(e,n).map(b=>Xe(b)),E=(d+p)/2,g=(m+u)/2;for(let b of l){if(!ym(un(m,u),b.overlap))continue;let y=b.startSide[0][0]+b.length/2,w=Xe(y-E);if(b.length>p-d&&Math.abs(w)<=a.x){Math.abs(w)<a.x&&(r.length=0),a.x=Math.abs(w);let _={type:"gap",direction:"center_horizontal",gap:b,offset:w};r.push(_);continue}let[,,I]=b.endBounds,T=d-I,C=Xe(b.length-T);if(Math.abs(C)<=a.x){Math.abs(C)<a.x&&(r.length=0),a.x=Math.abs(C);let _={type:"gap",direction:"side_right",gap:b,offset:C};r.push(_);continue}let[P,,,]=b.startBounds,A=P-p,D=Xe(A-b.length);if(Math.abs(D)<=a.x){Math.abs(D)<a.x&&(r.length=0),a.x=Math.abs(D);let _={type:"gap",direction:"side_left",gap:b,offset:D};r.push(_);continue}}for(let b of c){if(!ym(un(d,p),b.overlap))continue;let y=b.startSide[0][1]+b.length/2,w=Xe(y-g);if(b.length>u-m&&Math.abs(w)<=a.y){Math.abs(w)<a.y&&(i.length=0),a.y=Math.abs(w);let _={type:"gap",direction:"center_vertical",gap:b,offset:w};i.push(_);continue}let[,I,,]=b.startBounds,T=I-u,C=Xe(T-b.length);if(Math.abs(C)<=a.y){Math.abs(C)<a.y&&(i.length=0),a.y=Math.abs(C);let _={type:"gap",direction:"side_top",gap:b,offset:C};i.push(_);continue}let[,,,P]=b.endBounds,A=Xe(m-P),D=b.length-A;if(Math.abs(D)<=a.y){Math.abs(D)<a.y&&(i.length=0),a.y=Math.abs(D);let _={type:"gap",direction:"side_bottom",gap:b,offset:D};i.push(_);continue}}}},D2=(e,n,t,o)=>{let r=M2(e,n,t,o);return P2(r,o).filter(i=>!(i.length===1&&C2(i[0]))).flatMap(i=>Il(i,o))},Ia=(e,n,t,o,r,i,a)=>{if(!Co({app:t,event:o,selectedElements:e})||e.length===0&&n.length===0)return[];let s=hn.getReferenceSnapPoints();if(s)for(let l of n)for(let c of s){let d=c[0]-l[0],m=c[1]-l[1];Math.abs(d)<=a.x&&(Math.abs(d)<a.x&&(r.length=0),r.push({type:"point",points:[l,c],offset:d}),a.x=Math.abs(d)),Math.abs(m)<=a.y&&(Math.abs(m)<a.y&&(i.length=0),i.push({type:"point",points:[l,c],offset:m}),a.y=Math.abs(m))}},L2=(e,n,t,o,r)=>{let i=t.state,a=xN(e,i);if(!Co({app:t,event:o,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};n.x=Xe(n.x),n.y=Xe(n.y);let s=[],l=[],c=wm(i.zoom.value),d={x:c,y:c},m=Il(a,r,{dragOffset:n});Ia(a,m,t,o,s,l,d),T2(a,n,t,o,s,l,d);let p={x:s[0]?.offset??0,y:l[0]?.offset??0};d.x=0,d.y=0,s.length=0,l.length=0;let u={x:Xe(n.x+p.x),y:Xe(n.y+p.y)};Ia(a,Il(a,r,{dragOffset:u}),t,o,s,l,d),T2(a,u,t,o,s,l,d);let E=nf(s,l),g=IN(a,u,[...s,...l].filter(b=>b.type==="gap"));return{snapOffset:p,snapLines:[...E,...g]}},Xe=e=>Math.round(e*10**6)/10**6,S2=e=>{let n=new Map;for(let t of e){let o=t.join(",");n.has(o)||n.set(o,t)}return Array.from(n.values())},nf=(e,n)=>{let t={},o={};if(e.length>0){for(let r of e)if(r.type==="point"){let i=Xe(r.points[0][0]);t[i]||(t[i]=[]),t[i].push(...r.points.map(a=>Y(Xe(a[0]),Xe(a[1]))))}}if(n.length>0){for(let r of n)if(r.type==="point"){let i=Xe(r.points[0][1]);o[i]||(o[i]=[]),o[i].push(...r.points.map(a=>Y(Xe(a[0]),Xe(a[1]))))}}return Object.entries(t).map(([r,i])=>({type:"points",points:S2(i.map(a=>Y(Number(r),a[1])).sort((a,s)=>a[1]-s[1]))})).concat(Object.entries(o).map(([r,i])=>({type:"points",points:S2(i.map(a=>Y(a[0],Number(r))).sort((a,s)=>a[0]-s[0]))})))},vN=e=>{let n=new Map;for(let t of e){let o=t.points.flat().map(r=>[Xe(r)]).join(",");n.has(o)||n.set(o,t)}return Array.from(n.values())},IN=(e,n,t)=>{let[o,r,i,a]=tf(e,n),s=[];for(let l of t){let[c,d,m,p]=l.gap.startBounds,[u,E,g,b]=l.gap.endBounds,y=xm(un(r,a),l.gap.overlap),w=xm(un(o,i),l.gap.overlap);switch(l.direction){case"center_horizontal":{if(y){let x=(y[0]+y[1])/2;s.push({type:"gap",direction:"horizontal",points:[Y(l.gap.startSide[0][0],x),Y(o,x)]},{type:"gap",direction:"horizontal",points:[Y(i,x),Y(l.gap.endSide[0][0],x)]})}break}case"center_vertical":{if(w){let x=(w[0]+w[1])/2;s.push({type:"gap",direction:"vertical",points:[Y(x,l.gap.startSide[0][1]),Y(x,r)]},{type:"gap",direction:"vertical",points:[Y(x,a),Y(x,l.gap.endSide[0][1])]})}break}case"side_right":{if(y){let x=(y[0]+y[1])/2;s.push({type:"gap",direction:"horizontal",points:[Y(m,x),Y(u,x)]},{type:"gap",direction:"horizontal",points:[Y(g,x),Y(o,x)]})}break}case"side_left":{if(y){let x=(y[0]+y[1])/2;s.push({type:"gap",direction:"horizontal",points:[Y(i,x),Y(c,x)]},{type:"gap",direction:"horizontal",points:[Y(m,x),Y(u,x)]})}break}case"side_top":{if(w){let x=(w[0]+w[1])/2;s.push({type:"gap",direction:"vertical",points:[Y(x,a),Y(x,d)]},{type:"gap",direction:"vertical",points:[Y(x,p),Y(x,E)]})}break}case"side_bottom":{if(w){let x=(w[0]+w[1])/2;s.push({type:"gap",direction:"vertical",points:[Y(x,p),Y(x,E)]},{type:"gap",direction:"vertical",points:[Y(x,b),Y(x,r)]})}break}}}return vN(s.map(l=>({...l,points:l.points.map(c=>Y(Xe(c[0]),Xe(c[1])))})))},of=(e,n,t,o,r,i)=>{if(!Co({event:o,selectedElements:e,app:t})||e.length===0||e.length===1&&!wN(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,s,l,c]=ef(n);i&&(i.includes("e")?l+=r.x:i.includes("w")&&(a+=r.x),i.includes("n")?s+=r.y:i.includes("s")&&(c+=r.y));let d=[];if(i)switch(i){case"e":{d.push(Y(l,s),Y(l,c));break}case"w":{d.push(Y(a,s),Y(a,c));break}case"n":{d.push(Y(a,s),Y(l,s));break}case"s":{d.push(Y(a,c),Y(l,c));break}case"ne":{d.push(Y(l,s));break}case"nw":{d.push(Y(a,s));break}case"se":{d.push(Y(l,c));break}case"sw":{d.push(Y(a,c));break}}let m=wm(t.state.zoom.value),p={x:m,y:m},u=[],E=[];Ia(n,d,t,o,u,E,p);let g={x:u[0]?.offset??0,y:E[0]?.offset??0};p.x=0,p.y=0,u.length=0,E.length=0;let[b,y,w,x]=ef(e).map(C=>Xe(C)),I=[Y(b,y),Y(b,x),Y(w,y),Y(w,x)];Ia(e,I,t,o,u,E,p);let T=nf(u,E);return{snapOffset:g,snapLines:T}},_2=(e,n,t,o,r,i)=>{if(!Co({event:t,selectedElements:[e],app:n}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[Y(o.x+r.x,o.y+r.y)],s=wm(n.state.zoom.value),l={x:s,y:s},c=[],d=[];Ia([e],a,n,t,c,d,l);let m={x:c[0]?.offset??0,y:d[0]?.offset??0};l.x=0,l.y=0,c.length=0,d.length=0;let p=Il([e],i,{boundingBoxCorners:!0,omitCenter:!0});Ia([e],p,n,t,c,d,l);let u=nf(c,d);return{snapOffset:m,snapLines:u}},R2=(e,n,t,o,r)=>{if(!Co({event:o,selectedElements:[],app:n}))return{originOffset:{x:0,y:0},snapLines:[]};let i=k2(e,[],n.state,r),a=wm(n.state.zoom.value),s={x:a,y:a},l=[],c=[];for(let d of i){let m=Il([d],r);for(let p of m){let u=p[0]-t.x;Math.abs(u)<=Math.abs(s.x)&&(Math.abs(u)<Math.abs(s.x)&&(c.length=0),c.push({type:"pointer",points:[p,Y(p[0],t.y)],direction:"vertical"}),s.x=u);let E=p[1]-t.y;Math.abs(E)<=Math.abs(s.y)&&(Math.abs(E)<Math.abs(s.y)&&(l.length=0),l.push({type:"pointer",points:[p,Y(t.x,p[1])],direction:"horizontal"}),s.y=E)}}return{originOffset:{x:c.length>0?c[0].points[0][0]-t.x:0,y:l.length>0?l[0].points[0][1]-t.y:0},snapLines:[...c,...l]}},N2=e=>e===ti.rectangle||e===ti.ellipse||e===ti.diamond||e===ti.frame||e===ti.magicframe||e===ti.image||e===ti.text;import{getCommonFrameId as TN,getFrameChildrenInsertionIndex as SN,isElementInViewport as CN}from"@excalidraw/element";import{arrayToMap as PN,memoize as kN,toBrandedType as MN}from"@excalidraw/common";var Tl=class{constructor(n){v(this,"scene");v(this,"_getRenderableElements",kN(({canvasNonce:n,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height:s,width:l,editingTextElement:c,newElement:d})=>{let m=this.scene.getNonDeletedElements(),{elementsMap:p,newElementCanvasElement:u}=this.getRenderableElementsMap({elements:m,editingTextElement:c,newElement:d}),E=this.getVisibleCanvasElements({elementsMap:p,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height:s,width:l});return{elementsMap:p,visibleElements:E,newElementCanvasElement:u,canvasNonce:n}}));v(this,"getRenderableElements",n=>{let{newElement:t}=n,o=`${this.scene.getSceneNonce()}${t?.frameId?`:${t.versionNonce}`:""}`,r=this._getRenderableElements({canvasNonce:o,zoom:n.zoom,offsetLeft:n.offsetLeft,offsetTop:n.offsetTop,scrollX:n.scrollX,scrollY:n.scrollY,height:n.height,width:n.width,editingTextElement:n.editingTextElement,newElement:n.newElement});if(n.frameToHighlight&&n.selectedElementsAreBeingDragged&&TN(n.selectedElements)!==n.frameToHighlight.id){let i=this.sortSelectedElementsIntoHighlightedFrame({visibleElements:r.visibleElements,selectedElements:n.selectedElements,frameToHighlight:n.frameToHighlight});return{...r,visibleElements:i}}return r});this.scene=n}getVisibleCanvasElements({elementsMap:n,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height:s,width:l}){let c=[];for(let d of n.values())CN(d,l,s,{zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a},n)&&c.push(d);return c}getRenderableElementsMap({elements:n,editingTextElement:t,newElement:o}){let r=MN(new Map),i=o?.frameId?null:o;for(let a of n)i?.id!==a.id&&(!t||t.type!=="text"||a.id!==t.id)&&r.set(a.id,a);return{elementsMap:r,newElementCanvasElement:i}}sortSelectedElementsIntoHighlightedFrame({visibleElements:n,selectedElements:t,frameToHighlight:o}){if(!t.length)return n;let r=PN(t),i=n.filter(s=>!r.has(s.id)),a=SN(i,o.id);return a===null?n:[...i.slice(0,a),...t,...i.slice(a)]}destroy(){cx.cancel(),this._getRenderableElements.clear()}};import{DEFAULT_LASER_COLOR as RN,easeOut as O2}from"@excalidraw/common";import{SVG_NS as F2,getSvgPathFromStroke as LN,sceneCoordsToViewportCoords as _N}from"@excalidraw/common";import{version as AN}from"react";import{unstable_batchedUpdates as B2}from"react-dom";import{throttleRAF as DN}from"@excalidraw/common";var Ke=e=>n=>{B2(e,n)},vm=e=>DN(n=>{B2(e,n)}),Ta=(()=>{let e;try{let t=AN.split(".");e=Number(t[0])>17}catch{e=!1}let n=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(n||(n=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})();var pe=class pe{static start(n,t){if(pe.animations.has(n))return;let o={animation:t,lastTime:0,state:void 0};pe.animations.set(n,o);let r;try{r=t({deltaTime:0,state:void 0})}catch(i){throw pe.animations.get(n)===o&&(pe.animations.delete(n),pe.cancelScheduledFrameIfIdle()),i}if(pe.animations.get(n)===o){if(!r){pe.animations.delete(n),pe.cancelScheduledFrameIfIdle();return}o.state=r,pe.scheduleNextFrame()}}static scheduleNextFrame(){pe.scheduledFrame||(Ta()?pe.scheduledFrame={id:requestAnimationFrame(pe.tick),type:"raf"}:pe.scheduledFrame={id:setTimeout(pe.tick,0),type:"timeout"})}static cancelScheduledFrame(){pe.scheduledFrame&&(pe.scheduledFrame.type==="raf"?cancelAnimationFrame(pe.scheduledFrame.id):clearTimeout(pe.scheduledFrame.id),pe.scheduledFrame=null)}static cancelScheduledFrameIfIdle(){return pe.animations.size>0?!1:(pe.cancelScheduledFrame(),!0)}static tick(){if(pe.scheduledFrame=null,pe.animations.size>0){let n=[...pe.animations];for(let[t,o]of n){if(pe.animations.get(t)!==o)continue;let r=performance.now(),i=o.lastTime===0?0:r-o.lastTime,a=o.animation({deltaTime:i,state:o.state});if(pe.animations.get(t)===o){if(a)o.lastTime=r,o.state=a;else if(pe.animations.delete(t),pe.cancelScheduledFrameIfIdle())return}}if(pe.cancelScheduledFrameIfIdle())return;pe.scheduleNextFrame()}}static running(n){return pe.animations.has(n)}static cancel(n){pe.animations.delete(n),pe.cancelScheduledFrameIfIdle()}static reset(){pe.animations.clear(),pe.cancelScheduledFrame()}};v(pe,"scheduledFrame",null),v(pe,"animations",new Map);var at=pe;var Im=class Im{constructor(n,t){this.app=n;this.options=t;v(this,"currentTrail");v(this,"pastTrails",[]);v(this,"container");v(this,"trailElement");v(this,"trailAnimation");v(this,"key");this.key=`animated-trail-${Im.counter++}`,this.trailElement=document.createElementNS(F2,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(F2,"animate"),this.trailAnimation.setAttribute("attributeName","stroke-dashoffset"),this.trailElement.setAttribute("stroke-dasharray","7 7"),this.trailElement.setAttribute("stroke-dashoffset","10"),this.trailAnimation.setAttribute("from","0"),this.trailAnimation.setAttribute("to","-14"),this.trailAnimation.setAttribute("dur","0.3s"),this.trailElement.appendChild(this.trailAnimation))}get hasCurrentTrail(){return!!this.currentTrail}hasLastPoint(n,t){if(this.currentTrail){let o=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[o-1][0]===n&&this.currentTrail.originalPoints[o-1][1]===t}return!1}cleanup(){this.pastTrails=[],this.currentTrail=void 0,this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}start(n){n&&(this.container=n),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),at.running(this.key)||at.start(this.key,()=>this.onFrame()?{keep:!0}:(this.cleanup(),null))}stop(){at.cancel(this.key),this.cleanup()}startPath(n,t){this.currentTrail=new ma(this.options),this.currentTrail.addPoint([n,t,performance.now()]),this.update()}addPointToPath(n,t){this.currentTrail&&(this.currentTrail.addPoint([n,t,performance.now()]),this.update())}endPath(){this.currentTrail&&(this.currentTrail.close(),this.currentTrail.options.keepHead=!1,this.pastTrails.push(this.currentTrail),this.currentTrail=void 0,this.update())}getCurrentTrail(){return this.currentTrail}clearTrails(){this.pastTrails=[],this.currentTrail=void 0,this.update()}update(){this.start(),this.trailAnimation&&(this.trailAnimation.setAttribute("begin","indefinite"),this.trailAnimation.setAttribute("repeatCount","indefinite"))}onFrame(){let n=[];for(let o of this.pastTrails)n.push(this.drawTrail(o,this.app.state));if(this.currentTrail){let o=this.drawTrail(this.currentTrail,this.app.state);n.push(o)}if(this.pastTrails=this.pastTrails.filter(o=>o.getStrokeOutline(o.options.size/this.app.state.zoom.value).length!==0),n.length===0)return this.trailElement.setAttribute("d",""),!1;let t=n.join(" ").trim();return this.trailElement.setAttribute("d",t),this.trailAnimation?(this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this)),this.trailElement.setAttribute("stroke",(this.options.stroke??(()=>"black"))(this))):this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this)),!0}drawTrail(n,t){let o=n.getStrokeOutline(n.options.size/t.zoom.value).map(([i,a])=>{let s=_N({sceneX:i,sceneY:a},t);return[s.x,s.y]}),r=this.trailAnimation?o.slice(0,o.length/2):o;return LN(r,!0)}};v(Im,"counter",0);var Rn=Im;var Tm=class{constructor(n){this.app=n;v(this,"localTrail");v(this,"collabTrails",new Map);v(this,"container");this.localTrail=new Rn(n,{...this.getTrailOptions(),fill:()=>RN})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:n=>{let r=Math.max(0,1-(performance.now()-n.pressure)/1e3),i=(50-Math.min(50,n.totalLength-n.currentIndex))/50;return Math.min(O2(i),O2(r))}}}startPath(n,t){this.localTrail.startPath(n,t)}addPointToPath(n,t){this.localTrail.addPointToPath(n,t)}endPath(){this.localTrail.endPath()}start(n){this.container=n,this.localTrail.start(n)}stop(){this.localTrail.stop(),this.stopCollabTrails(),this.container=void 0}stopCollabTrails(n){for(let[t,o]of this.collabTrails)n?.get(t)||(o.stop(),this.collabTrails.delete(t))}updateCollabTrails(n){if(this.stopCollabTrails(n),!(!this.container||n.size===0))for(let[t,o]of n.entries()){if(o.isCurrentUser)continue;let r=this.collabTrails.get(t);if(r||(r=new Rn(this.app,{...this.getTrailOptions(),fill:()=>o.pointer?.laserColor||$r(t,o)}),r.start(this.container),this.collabTrails.set(t,r)),o.pointer&&o.pointer.tool==="laser"){let i=o.button==="down",a=o.button==="up",s=r.hasCurrentTrail;i&&!s&&r.startPath(o.pointer.x,o.pointer.y);let l=!r.hasLastPoint(o.pointer.x,o.pointer.y);i&&l&&r.addPointToPath(o.pointer.x,o.pointer.y),a&&s&&(r.addPointToPath(o.pointer.x,o.pointer.y),r.endPath())}}}};import{DEFAULT_TRANSFORM_HANDLE_SPACING as NN}from"@excalidraw/common";import{pointFrom as Sl,pointRotateRads as Sm}from"@excalidraw/math";var BN=12,rf=16,FN=10,ON=rf+2,zN=.8,af=e=>NN*2/e,sf=(e,n,t)=>{let o=af(n);if(t!=="desktop"||rf>(e.height+o*2)*n*zN)return null;let r=BN/n,i=rf/n,a=Sl(e.x+e.width/2,e.y+e.height/2),s=Sm(Sl(a[0]+e.width/2+o+r,a[1]),a,e.angle);return{center:s,start:Sm(Sl(s[0],s[1]-i/2),s,e.angle),end:Sm(Sl(s[0],s[1]+i/2),s,e.angle),hitboxWidth:FN/n,hitboxHeight:ON/n}},z2=(e,n,t,o)=>{let r=sf(n,t,o);if(!r)return!1;let i=Sm(Sl(e.x,e.y),r.center,-n.angle);return Math.abs(i[0]-r.center[0])<=r.hitboxWidth/2&&Math.abs(i[1]-r.center[1])<=r.hitboxHeight/2};import{CODES as lf,KEYS as Cl,CLASSES as cf,POINTER_BUTTON as GN,THEME as HN,isWritableElement as UN,getFontString as G2,getFontFamilyString as H2,isTestEnv as U2,MIME_TYPES as df,applyDarkModeFilter as WN,isRTL as VN}from"@excalidraw/common";import{pointFrom as W2,pointRotateRads as YN}from"@excalidraw/math";import{getTextFromElements as XN,originalContainerCache as KN,updateBoundElements as V2,updateOriginalContainerCache as Y2}from"@excalidraw/element";import{LinearElementEditor as $N}from"@excalidraw/element/linearElementEditor";import{bumpVersion as ZN}from"@excalidraw/element";import{getBoundTextElementId as jN,getContainerElement as mf,getTextElementAngle as qN,redrawTextBoundingBox as JN,getBoundTextMaxHeight as QN,getBoundTextMaxWidth as X2,computeContainerDimensionForBoundText as K2,computeBoundTextPosition as e7,getBoundTextElement as t7}from"@excalidraw/element";import{getTextWidth as n7}from"@excalidraw/element";import{getLineHeightInPx as o7}from"@excalidraw/element";import{getLineWidth as r7}from"@excalidraw/element";import{normalizeText as $2}from"@excalidraw/element";import{wrapText as i7}from"@excalidraw/element";import{getWrappedTextLines as a7}from"@excalidraw/element";import{isArrowElement as Cm,isBoundToContainer as s7,isTextElement as Z2}from"@excalidraw/element";var l7=(e,n,t,o,r,i)=>{let{zoom:a}=o,s=180*t/Math.PI,l=e*(a.value-1)/2,c=n*(a.value-1)/2;return e>r&&a.value!==1&&(l=r*(a.value-1)/2),n>i&&a.value!==1&&(c=i*(a.value-1)/2),`translate(${l}px, ${c}px) scale(${a.value}) rotate(${s}deg)`},c7=(e,n)=>{let t=e.lastIndexOf(`
4
+ ${f("hints.firefox_clipboard_write")}`):new Error(f("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var vw=async(e,n,t)=>{let o=fx(n);if(!Ex(o))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:s,viewBackgroundColor:l}=i;i={...i,exportEmbedScene:!0};let{exportedElements:c,exportingFrame:d}=$r(r,i,!1);return await Zr(o,c,i,a,{exportBackground:s,viewBackgroundColor:l,name:t,fileHandle:n,exportingFrame:d}),{fileHandle:n}};import{Fragment as KD,jsx as cr,jsxs as Cw}from"react/jsx-runtime";var eg=O({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,name:t},captureUpdate:Mn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n,appProps:t,data:o,app:r})=>cr(gw,{label:f("labels.fileTitle"),value:r.getName(),onChange:i=>n(i),ignoreFocus:o?.ignoreFocus??!1})}),Iw=O({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,n,t)=>({appState:{...n,exportScale:t},captureUpdate:Mn.EVENTUALLY})}),tg=O({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,n,t)=>({appState:{...n,exportBackground:t},captureUpdate:Mn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>cr(jh,{checked:e.exportBackground,onChange:t=>n(t),children:f("imageExportDialog.label.withBackground")})}),Qd=O({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,n,t)=>({appState:{...n,exportEmbedScene:t},captureUpdate:Mn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>Cw(jh,{checked:e.exportEmbedScene,onChange:t=>n(t),children:[f("imageExportDialog.label.embedScene"),cr(pt,{label:f("imageExportDialog.tooltip.embedScene"),long:!0,children:cr("div",{className:"excalidraw-tooltip-icon",children:e1})})]})}),oa=!1,Qh=(e,n)=>{let t=n.message??f("progressDialog.defaultMessage");e.setAppState({toast:{message:n.progress!=null?Cw(KD,{children:[t,cr(Yd.ProgressBar,{progress:n.progress})]}):t,duration:1/0}})};async function XD(e,n){if(n.app.state.isLoading&&(Qh(n.app,{progress:null}),await n.app.onStateChange({predicate:t=>!t.isLoading})),e!=null&&typeof e=="object"&&Symbol.asyncIterator in e){for await(let t of e){if(n.signal.aborted){e.return();return}if(t.type==="progress")Qh(n.app,{message:t.message,progress:t.progress??null});else if(t.type==="done")return}return}e instanceof Promise&&(Qh(n.app,{progress:null}),await e)}function Tw(e,n,t,o){let r=new AbortController,i=r.signal,a=new Promise(async s=>{try{o.props.onExport&&await XD(o.props.onExport("json",{elements:e,appState:n,files:t},{signal:i}),{app:o,signal:i})}catch(l){l?.name==="AbortError"?console.warn(`onExport() aborted by host app (signal aborted: ${i.aborted})`):console.error("Error during props.onExport() handling",l)}s({elements:e,appState:n,files:o.files})});return{abortController:r,data:a}}var jr=O({name:"saveToActiveFile",label:"buttons.save",icon:ks,trackEvent:{category:"export"},predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.saveToActiveFile&&!!n.fileHandle&&!n.viewModeEnabled,perform:async(e,n,t,o)=>{if(oa)return!1;oa=!0;let r=n.fileHandle,i=o.getName(),{abortController:a,data:s}=Tw(e,n,o.files,o);try{let{fileHandle:l}=_c(r)?await vw(s,r,i):await kc({data:s,filename:i,fileHandle:r});return{captureUpdate:Mn.NEVER,appState:{fileHandle:l,toast:{message:r&&l?.name?f("toast.fileSavedToFilename").replace("{filename}",`"${l.name}"`):f("toast.fileSaved"),duration:1500}}}}catch(l){return a.abort(),l?.name!=="AbortError"?console.error(l):console.warn(l),{captureUpdate:Mn.NEVER,appState:{toast:null}}}finally{oa=!1}},keyTest:e=>!1}),rl=O({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:ks,viewMode:!0,trackEvent:{category:"export"},perform:async(e,n,t,o)=>{if(oa)return!1;oa=!0;let{abortController:r,data:i}=Tw(e,n,o.files,o);try{let{fileHandle:a}=await kc({data:i,filename:o.getName(),fileHandle:null});return{captureUpdate:Mn.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:Mn.NEVER,appState:{toast:null}}}finally{oa=!1}},keyTest:e=>e.key.toLowerCase()===Jd.S&&e.shiftKey&&e[Jd.CTRL_OR_CMD],PanelComponent:({updateData:e})=>cr(Z,{type:"button",icon:Zx,title:f("buttons.saveAs"),"aria-label":f("buttons.saveAs"),showAriaLabel:be().formFactor==="phone",hidden:!Pi,onClick:()=>e(null),"data-testid":"save-as-button"})}),ra=O({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.loadScene&&!n.viewModeEnabled,perform:async(e,n,t,o)=>{try{let{elements:r,appState:i,files:a}=await Cu(n,e);return{elements:r,appState:i,files:a,captureUpdate:Mn.IMMEDIATELY}}catch(r){return r?.name==="AbortError"?(console.warn(r),!1):{elements:e,appState:{...n,errorMessage:r.message},files:o.files,captureUpdate:Mn.EVENTUALLY}}},keyTest:e=>e[Jd.CTRL_OR_CMD]&&e.key===Jd.O}),Sw=O({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,n,t,o)=>(o.sessionExportThemeOverride=t?ol.DARK:ol.LIGHT,{appState:{...n,exportWithDarkMode:t},captureUpdate:Mn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>cr("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:cr(uw,{value:e.exportWithDarkMode?ol.DARK:ol.LIGHT,onChange:t=>{n(t===ol.DARK)},title:f("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as $D,DEFAULT_FONT_FAMILY as ZD,DEFAULT_TEXT_ALIGN as jD,getLineHeight as qD}from"@excalidraw/common";import{newElementWith as em}from"@excalidraw/element";import{hasBoundTextElement as JD,canApplyRoundnessTypeToElement as QD,getDefaultRoundnessTypeForElement as eL,isFrameLikeElement as tL,isArrowElement as nL,isExcalidrawElement as oL,isTextElement as Pw}from"@excalidraw/element";import{getBoundTextElement as rL,redrawTextBoundingBox as iL}from"@excalidraw/element";import{CaptureUpdateAction as ng}from"@excalidraw/element";var kw="{}",aL=O({name:"copyStyles",label:"labels.copyStyles",icon:qu,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=[],i=e.find(a=>n.selectedElementIds[a.id]);if(r.push(i),i&&JD(i)){let a=rL(i,o.scene.getNonDeletedElementsMap());r.push(a)}return i&&(kw=JSON.stringify(r)),{appState:{...n,toast:{message:f("toast.copyStyles")}},captureUpdate:ng.EVENTUALLY}}}),sL=O({name:"pasteStyles",label:"labels.pasteStyles",icon:qu,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=JSON.parse(kw),i=r[0],a=r[1];if(!oL(i))return{elements:e,captureUpdate:ng.EVENTUALLY};let s=ce(e,n,{includeBoundTextElement:!0}),l=s.map(c=>c.id);return{elements:e.map(c=>{if(l.includes(c.id)){let d=i;if(Pw(c)&&c.containerId&&(d=a),!d)return c;let m=em(c,{backgroundColor:d?.backgroundColor,strokeWidth:d?.strokeWidth,strokeColor:d?.strokeColor,strokeStyle:d?.strokeStyle,fillStyle:d?.fillStyle,opacity:d?.opacity,roughness:d?.roughness,roundness:d.roundness?QD(d.roundness.type,c)?d.roundness:eL(c):null});if(Pw(m)){let p=d.fontSize||$D,u=d.fontFamily||ZD,E=em(m,{fontSize:p,fontFamily:u,textAlign:d.textAlign||jD,lineHeight:d.lineHeight||qD(u)});m=E;let g=null;E.containerId&&(g=s.find(b=>b.id===E.containerId)||null),iL(E,g,o.scene)}return m.type==="arrow"&&nL(d)&&(m=em(m,{startArrowhead:d.startArrowhead,endArrowhead:d.endArrowhead})),tL(c)&&(m=em(m,{roundness:null,backgroundColor:"transparent"})),m}return c}),captureUpdate:ng.IMMEDIATELY}}});import{KEYS as lL}from"@excalidraw/common";import{CaptureUpdateAction as cL}from"@excalidraw/element";var qr=O({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:Vx,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,n,t,{focusContainer:o})=>(n.openDialog?.name==="help"&&o(),{appState:{...n,openDialog:n.openDialog?.name==="help"?null:{name:"help"},openMenu:null,openPopup:null},captureUpdate:cL.EVENTUALLY}),keyTest:e=>e.key===lL.QUESTION_MARK});import{getNonDeletedElements as nm}from"@excalidraw/element";import{newElementWith as Aw}from"@excalidraw/element";import{isBoundToContainer as dL}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as mL,getElementsInResizingFrame as pL,getFrameLikeElements as uL,getRootElements as hL,groupByFrameLikes as gL,removeElementsFromFrame as fL,replaceAllElementsInFrame as EL}from"@excalidraw/element";import{KEYS as om,randomId as bL,arrayToMap as rg}from"@excalidraw/common";import{getSelectedGroupIds as tm,selectGroup as xL,selectGroupsForSelectedElements as yL,getElementsInGroup as Mw,addToGroup as wL,removeFromSelectedGroups as vL,isElementInGroup as Dw}from"@excalidraw/element";import{syncMovedIndices as IL}from"@excalidraw/element";import{CaptureUpdateAction as il}from"@excalidraw/element";import{jsx as ia}from"react/jsx-runtime";var TL=(e,n)=>{if(e.length>=2){let t=n?e[0].groupIds.indexOf(n):-1,o=t>-1?e[0].groupIds.slice(0,t):e[0].groupIds;for(let r of o)if(e.every(i=>Dw(i,r)))return!0}return!1},og=(e,n)=>{let t=n.scene.getSelectedElements({selectedElementIds:e.selectedElementIds,includeBoundTextElement:!1});return t.length>=2&&!TL(t,e.editingGroupId)&&!mL(t)},ig=O({name:"group",label:"labels.group",icon:e=>ia(Vu,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(!og(n,o))return!1;let r=hL(o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}));if(r.length<2)return{appState:n,elements:e,captureUpdate:il.EVENTUALLY};let i=tm(n);if(i.length===1){let b=i[0],w=new Set(Mw(e,b).map(I=>I.id)),y=new Set(r.map(I=>I.id));if(new Set([...Array.from(w),...Array.from(y)]).size===w.size)return{appState:n,elements:e,captureUpdate:il.EVENTUALLY}}let a=[...e];new Set(r.map(b=>b.frameId)).size>1&&gL(r).forEach((w,y)=>{fL(w,o.scene.getNonDeletedElementsMap())});let l=bL(),c=rg(r);a=a.map(b=>c.get(b.id)?Aw(b,{groupIds:wL(b.groupIds,l,n.editingGroupId)}):b);let d=Mw(a,l),m=d[d.length-1],p=a.lastIndexOf(m),u=a.slice(p+1),E=a.slice(0,p).filter(b=>!Dw(b,l)),g=IL([...E,...d,...u],rg(d));return{appState:{...n,...xL(l,{...n,selectedGroupIds:{}},nm(a))},elements:g,captureUpdate:il.IMMEDIATELY}},predicate:(e,n,t,o)=>og(n,o),keyTest:e=>!e.shiftKey&&e[om.CTRL_OR_CMD]&&e.key===om.G,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ia(Z,{hidden:!og(n,o),type:"button",icon:ia(Vu,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.group")} \u2014 ${N("CtrlOrCmd+G")}`,"aria-label":f("labels.group"),visible:Le(nm(e),n)})}),ag=O({name:"ungroup",label:"labels.ungroup",icon:e=>ia(Yu,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=tm(n),i=rg(e);if(r.length===0)return{appState:n,elements:e,captureUpdate:il.EVENTUALLY};let a=[...e],s=[];a=a.map(p=>{dL(p)&&s.push(p.id);let u=vL(p.groupIds,n.selectedGroupIds);return u.length===p.groupIds.length?p:Aw(p,{groupIds:u})});let l=yL(n,nm(a),n,null),c=o.scene.getSelectedElements(n),d=new Set(c.filter(p=>p.frameId).map(p=>p.frameId));return uL(e).filter(p=>d.has(p.id)).forEach(p=>{p&&(a=EL(a,pL(a,p,n,i),p))}),l.selectedElementIds=Object.entries(l.selectedElementIds).reduce((p,[u,E])=>(E&&!s.includes(u)&&(p[u]=!0),p),{}),{appState:{...n,...l},elements:a,captureUpdate:il.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[om.CTRL_OR_CMD]&&e.key===om.G.toUpperCase(),predicate:(e,n)=>tm(n).length>0,PanelComponent:({elements:e,appState:n,updateData:t})=>ia(Z,{type:"button",hidden:tm(n).length===0,icon:ia(Yu,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.ungroup")} \u2014 ${N("CtrlOrCmd+Shift+G")}`,"aria-label":f("labels.ungroup"),visible:Le(nm(e),n)})});import DL from"clsx";import{CaptureUpdateAction as Bw}from"@excalidraw/element";import{invariant as LL}from"@excalidraw/common";import{COLOR_CHARCOAL_BLACK as SL,COLOR_VOICE_CALL as CL,COLOR_WHITE as im,THEME as PL,UserIdleState as Lw}from"@excalidraw/common";var rm=(e,n,t,o,r,i,a)=>{e.beginPath(),e.moveTo(n+i,t),e.lineTo(n+o-i,t),e.quadraticCurveTo(n+o,t,n+o,t+i),e.lineTo(n+o,t+r-i),e.quadraticCurveTo(n+o,t+r,n+o-i,t+r),e.lineTo(n+i,t+r),e.quadraticCurveTo(n,t+r,n,t+r-i),e.lineTo(n,t+i),e.quadraticCurveTo(n,t,n+i,t),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};function kL(e){let n=0;if(e.length===0)return n;for(let t=0;t<e.length;t++){let o=e.charCodeAt(t);n=(n<<5)-n+o}return n}var Jr=(e,n)=>`hsl(${Math.abs(kL(n?.id||e))%37*10}, 100%, 83%)`,_w=e=>{let n=e?.trim()?.codePointAt(0);return(n?String.fromCodePoint(n):"?").toUpperCase()},Rw=({context:e,renderConfig:n,appState:t,normalizedWidth:o,normalizedHeight:r})=>{for(let[i,a]of n.remotePointerViewportCoords){let{x:s,y:l}=a,c=t.collaborators.get(i);s-=t.offsetLeft,l-=t.offsetTop;let d=11,m=14,p=s<0||s>o-d||l<0||l>r-m;s=Math.max(s,0),s=Math.min(s,o-d),l=Math.max(l,0),l=Math.min(l,r-m);let u=Jr(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let E=n.remotePointerUserStates.get(i),g=p||E===Lw.IDLE||E===Lw.AWAY;g&&(e.globalAlpha=.3),n.remotePointerButton.get(i)==="down"&&(e.beginPath(),e.arc(s,l,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(s,l,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=u,e.stroke(),e.closePath());let b=t.theme===PL.DARK?"#2f6330":CL,w=c?.isSpeaking;w&&(e.fillStyle=b,e.strokeStyle=b,e.lineWidth=10,e.lineJoin="round",e.beginPath(),e.moveTo(s,l),e.lineTo(s+0,l+14),e.lineTo(s+4,l+9),e.lineTo(s+11,l+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=im,e.strokeStyle=im,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(s,l),e.lineTo(s+0,l+14),e.lineTo(s+4,l+9),e.lineTo(s+11,l+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=u,e.strokeStyle=u,e.lineWidth=2,e.lineJoin="round",e.beginPath(),g?(e.moveTo(s-1,l-1),e.lineTo(s-1,l+15),e.lineTo(s+5,l+10),e.lineTo(s+12,l+9),e.closePath(),e.fill()):(e.moveTo(s,l),e.lineTo(s+0,l+14),e.lineTo(s+4,l+9),e.lineTo(s+11,l+8),e.closePath(),e.fill(),e.stroke());let y=n.remotePointerUsernames.get(i)||"";if(!p&&y){e.font="600 12px sans-serif";let x=(w?s+0:s)+d/2,I=(w?l+0:l)+m+2,T=5,C=3,P=e.measureText(y),M=P.actualBoundingBoxDescent+P.actualBoundingBoxAscent,D=Math.max(M,12),_=x-1,k=I-1,L=P.width+2+T*2+2,F=D+2+C*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(_,k,L,F,8),e.fillStyle=u,e.fill(),e.strokeStyle=im,e.stroke(),w&&(e.beginPath(),e.roundRect(_-2,k-2,L+4,F+4,8),e.strokeStyle=b,e.stroke())):rm(e,_,k,L,F,8,im),e.fillStyle=SL,e.fillText(y,x+T+1,I+C+P.actualBoundingBoxAscent+Math.floor((D-M)/2)+2),w){e.fillStyle=b;let Y=8,z=8,U=5;e.fillRect(_+L+z,k+(F/2-Y/2),2,Y),e.fillRect(_+L+z+U,k+(F/2-Y*2/2),2,Y*2),e.fillRect(_+L+z+U*2,k+(F/2-Y/2),2,Y)}}e.restore(),e.closePath()}};import ML from"clsx";import{useState as AL}from"react";import{jsx as Nw}from"react/jsx-runtime";var sg=({color:e,onClick:n,name:t,src:o,className:r})=>{let i=_w(t),[a,s]=AL(!1),l=!a&&o,c=l?void 0:{background:e};return Nw("div",{className:ML("Avatar",r),style:c,onClick:n,children:l?Nw("img",{className:"Avatar-img",src:o,alt:i,referrerPolicy:"no-referrer",onError:()=>s(!0)}):i})};import{jsx as to,jsxs as am}from"react/jsx-runtime";var _L=O({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,n,t,o)=>(LL(t,"actionGoToCollaborator: collaborator should be defined when actionGoToCollaborator is called"),!t.socketId||o.props.userToFollow?.socketId===t.socketId||t.isCurrentUser?(o.requestUnfollow(),{appState:n,captureUpdate:Bw.EVENTUALLY}):(o.emitUserFollowIntent({userToFollow:{socketId:t.socketId,username:t.username||""},action:"FOLLOW"}),{appState:{...n,openMenu:n.openMenu==="canvas"?null:n.openMenu},captureUpdate:Bw.EVENTUALLY})),PanelComponent:({updateData:e,data:n,appState:t})=>{let{socketId:o,collaborator:r,withName:i,isBeingFollowed:a}=n,s=Jr(o,r),l=DL({"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?am("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:f("userList.hint.isSpeaking"),children:[to("div",{}),to("div",{}),to("div",{})]}):r.isMuted?to("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:f("userList.hint.micMuted"),children:n0}):to("div",{title:f("userList.hint.inCall"),children:t0}):null;return i?am("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${l}`,style:{"--avatar-size":"1.5rem"},onClick:r.isCurrentUser?void 0:()=>e(r),children:[to(sg,{color:s,onClick:()=>{},name:r.username||"",src:r.avatarUrl,className:l}),to("div",{className:"UserList__collaborator-name",children:r.username}),am("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&to("div",{className:"UserList__collaborator-status-icon-is-followed",title:f("userList.hint.followStatus"),children:Hr}),r.isCurrentUser&&` (${f("labels.you")})`,c]})]}):am("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${l}`,children:[to(sg,{color:s,onClick:()=>{e(r)},name:r.username||"",src:r.avatarUrl,className:l}),c&&to("div",{className:"UserList__collaborator-status-icon",children:c})]})}});import{getNonDeletedElements as aa}from"@excalidraw/element";import{isFrameLikeElement as RL}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as NL}from"@excalidraw/element";import{KEYS as dr,arrayToMap as BL}from"@excalidraw/common";import{alignElements as FL}from"@excalidraw/element";import{CaptureUpdateAction as sa}from"@excalidraw/element";import{getSelectedElementsByGroup as OL}from"@excalidraw/element";import{jsx as ca}from"react/jsx-runtime";var dt=(e,n)=>{let t=n.scene.getSelectedElements(e);return OL(t,n.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(o=>RL(o))},la=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),i=FL(r,o,t.scene,n),a=BL(i);return NL(e.map(s=>a.get(s.id)||s),n,t)},zL=O({name:"alignTop",label:"labels.alignTop",icon:Ou,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:la(e,n,o,{position:"start",axis:"y"}),captureUpdate:sa.IMMEDIATELY}),keyTest:e=>e[dr.CTRL_OR_CMD]&&e.shiftKey&&e.key===dr.ARROW_UP,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ca(Z,{hidden:!dt(n,o),type:"button",icon:Ou,onClick:()=>t(null),title:`${f("labels.alignTop")} \u2014 ${N("CtrlOrCmd+Shift+Up")}`,"aria-label":f("labels.alignTop"),visible:Le(aa(e),n)})}),GL=O({name:"alignBottom",label:"labels.alignBottom",icon:zu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:la(e,n,o,{position:"end",axis:"y"}),captureUpdate:sa.IMMEDIATELY}),keyTest:e=>e[dr.CTRL_OR_CMD]&&e.shiftKey&&e.key===dr.ARROW_DOWN,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ca(Z,{hidden:!dt(n,o),type:"button",icon:zu,onClick:()=>t(null),title:`${f("labels.alignBottom")} \u2014 ${N("CtrlOrCmd+Shift+Down")}`,"aria-label":f("labels.alignBottom"),visible:Le(aa(e),n)})}),HL=O({name:"alignLeft",label:"labels.alignLeft",icon:Gu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:la(e,n,o,{position:"start",axis:"x"}),captureUpdate:sa.IMMEDIATELY}),keyTest:e=>e[dr.CTRL_OR_CMD]&&e.shiftKey&&e.key===dr.ARROW_LEFT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ca(Z,{hidden:!dt(n,o),type:"button",icon:Gu,onClick:()=>t(null),title:`${f("labels.alignLeft")} \u2014 ${N("CtrlOrCmd+Shift+Left")}`,"aria-label":f("labels.alignLeft"),visible:Le(aa(e),n)})}),UL=O({name:"alignRight",label:"labels.alignRight",icon:Hu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:la(e,n,o,{position:"end",axis:"x"}),captureUpdate:sa.IMMEDIATELY}),keyTest:e=>e[dr.CTRL_OR_CMD]&&e.shiftKey&&e.key===dr.ARROW_RIGHT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ca(Z,{hidden:!dt(n,o),type:"button",icon:Hu,onClick:()=>t(null),title:`${f("labels.alignRight")} \u2014 ${N("CtrlOrCmd+Shift+Right")}`,"aria-label":f("labels.alignRight"),visible:Le(aa(e),n)})}),WL=O({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Uu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:la(e,n,o,{position:"center",axis:"y"}),captureUpdate:sa.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ca(Z,{hidden:!dt(n,o),type:"button",icon:Uu,onClick:()=>t(null),title:f("labels.centerVertically"),"aria-label":f("labels.centerVertically"),visible:Le(aa(e),n)})}),VL=O({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Wu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:la(e,n,o,{position:"center",axis:"x"}),captureUpdate:sa.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ca(Z,{hidden:!dt(n,o),type:"button",icon:Wu,onClick:()=>t(null),title:f("labels.centerHorizontally"),"aria-label":f("labels.centerHorizontally"),visible:Le(aa(e),n)})});import{getNonDeletedElements as Fw}from"@excalidraw/element";import{isFrameLikeElement as YL}from"@excalidraw/element";import{CODES as Ow,KEYS as zw,arrayToMap as XL}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as KL}from"@excalidraw/element";import{distributeElements as $L}from"@excalidraw/element";import{CaptureUpdateAction as Gw}from"@excalidraw/element";import{getSelectedElementsByGroup as ZL}from"@excalidraw/element";import{jsx as Ww}from"react/jsx-runtime";var Hw=(e,n)=>{let t=n.scene.getSelectedElements(e);return ZL(t,n.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(o=>YL(o))},Uw=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),i=$L(r,t.scene.getNonDeletedElementsMap(),o,n,t.scene),a=XL(i);return KL(e.map(s=>a.get(s.id)||s),n,t)},jL=O({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:Uw(e,n,o,{space:"between",axis:"x"}),captureUpdate:Gw.IMMEDIATELY}),keyTest:e=>!e[zw.CTRL_OR_CMD]&&e.altKey&&e.code===Ow.H,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ww(Z,{hidden:!Hw(n,o),type:"button",icon:r1,onClick:()=>t(null),title:`${f("labels.distributeHorizontally")} \u2014 ${N("Alt+H")}`,"aria-label":f("labels.distributeHorizontally"),visible:Le(Fw(e),n)})}),qL=O({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:Uw(e,n,o,{space:"between",axis:"y"}),captureUpdate:Gw.IMMEDIATELY}),keyTest:e=>!e[zw.CTRL_OR_CMD]&&e.altKey&&e.code===Ow.V,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ww(Z,{hidden:!Hw(n,o),type:"button",icon:i1,onClick:()=>t(null),title:`${f("labels.distributeVertically")} \u2014 ${N("Alt+V")}`,"aria-label":f("labels.distributeVertically"),visible:Le(Fw(e),n)})});import{arrayToMap as Vw,KEYS as QL,matchKey as e_}from"@excalidraw/common";import{CaptureUpdateAction as t_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as n_}from"@excalidraw/element/frame";import{arrangeElements as o_}from"@excalidraw/element/arrange";var JL={fitToViewport:!0,animate:!0,duration:200,respectUIElements:!1,viewportZoomFactor:.8},da=(e,n)=>({smartZoom:{...JL,...n?.smartZoom},arrange:{...e.arrangeConfiguration,...n?.arrange},normalise:{...e.normaliseConfiguration,...n?.normalise}});import{jsx as a_}from"react/jsx-runtime";var r_=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=Vw(e),{arrange:i}=da(n,t.props.editorPreferences),a=o_(t.scene,o,r,i.algorithm,i.gap),s=Vw(a);return n_(e.map(l=>s.get(l.id)||l),n,t)},i_=dt,lg=O({name:"arrangeElements",label:"labels.arrangeElements",keywords:["arrange","rearrange","spread"],icon:Qu,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>i_(n,o),perform:(e,n,t,o)=>({appState:n,elements:r_(e,n,o),captureUpdate:t_.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e_(e,QL.R),PanelComponent:({updateData:e})=>a_("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:`${f("labels.arrangeElements")} \u2014 ${N("Shift+R")}`,children:Qu})});import{arrayToMap as Yw}from"@excalidraw/common";import{CaptureUpdateAction as s_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as l_}from"@excalidraw/element/frame";import{normaliseElements as c_}from"@excalidraw/element/normalise";import{jsx as p_}from"react/jsx-runtime";var d_=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=Yw(e),{normalise:i}=da(n,t.props.editorPreferences),a=c_(t.scene,o,r,i.mode,i.metric),s=Yw(a);return l_(e.map(l=>s.get(l.id)||l),n,t)},m_=dt,cg=O({name:"normaliseElements",label:"labels.normaliseElements",keywords:["normalize","normalise","scale","size","image"],icon:eh,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>m_(n,o),perform:(e,n,t,o)=>({appState:n,elements:d_(e,n,o),captureUpdate:s_.IMMEDIATELY}),PanelComponent:({updateData:e})=>p_("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:f("labels.normaliseElements"),children:eh})});import{getNonDeletedElements as u_}from"@excalidraw/element";import{bindOrUnbindBindingElements as h_}from"@excalidraw/element";import{getCommonBoundingBox as Xw}from"@excalidraw/element";import{newElementWith as g_}from"@excalidraw/element";import{deepCopyElement as f_}from"@excalidraw/element";import{resizeMultipleElements as E_}from"@excalidraw/element";import{isArrowElement as Kw,isElbowArrow as b_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as $w}from"@excalidraw/element";import{CODES as Zw,KEYS as x_,arrayToMap as y_}from"@excalidraw/common";import{CaptureUpdateAction as jw}from"@excalidraw/element";var dg=O({name:"flipHorizontal",label:"labels.flipHorizontal",icon:a0,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:$w(qw(e,o.scene.getNonDeletedElementsMap(),n,"horizontal",o),n,o),appState:n,captureUpdate:jw.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===Zw.H}),mg=O({name:"flipVertical",label:"labels.flipVertical",icon:i0,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:$w(qw(e,o.scene.getNonDeletedElementsMap(),n,"vertical",o),n,o),appState:n,captureUpdate:jw.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===Zw.V&&!e[x_.CTRL_OR_CMD]}),qw=(e,n,t,o,r)=>{let i=ce(u_(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=w_(i,n,o,r),s=y_(a);return e.map(l=>s.get(l.id)||l)},w_=(e,n,t,o)=>{if(e.every(p=>Kw(p)&&(p.startBinding||p.endBinding)))return e.map(p=>{let u=p;return g_(u,{startArrowhead:u.endArrowhead,endArrowhead:u.startArrowhead})});let{midX:r,midY:i}=Xw(e);E_(e,n,"nw",o.scene,new Map(Array.from(n.values()).map(p=>[p.id,f_(p)])),{flipByX:t==="horizontal",flipByY:t==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),h_(e.filter(Kw),o.scene,o.state);let{elbowArrows:a,otherElements:s}=e.reduce((p,u)=>b_(u)?{...p,elbowArrows:p.elbowArrows.concat(u)}:{...p,otherElements:p.otherElements.concat(u)},{elbowArrows:[],otherElements:[]}),{midX:l,midY:c}=Xw(e),[d,m]=[r-l,i-c];return s.forEach(p=>o.scene.mutateElement(p,{x:p.x+d,y:p.y+m})),a.forEach(p=>o.scene.mutateElement(p,{x:p.x+d,y:p.y+m})),e};import{isTextElement as v_}from"@excalidraw/element";import{getTextFromElements as I_}from"@excalidraw/element";import{CODES as T_,KEYS as Jw,isFirefox as S_}from"@excalidraw/common";import{CaptureUpdateAction as Jt}from"@excalidraw/element";var ma=O({name:"copy",label:"labels.copy",icon:Ss,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await $d(r,o.files,t)}catch(i){return{captureUpdate:Jt.EVENTUALLY,appState:{...n,errorMessage:i.message}}}return{captureUpdate:Jt.EVENTUALLY}},keyTest:void 0}),pg=O({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r;try{r=await xw()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),S_?{captureUpdate:Jt.EVENTUALLY,appState:{...n,errorMessage:f("hints.firefox_clipboard_write")}}:{captureUpdate:Jt.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnRead")}})}try{o.pasteFromClipboard(Ew({types:r}))}catch(i){return console.error(i),{captureUpdate:Jt.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:Jt.EVENTUALLY}},keyTest:void 0}),sm=O({name:"cut",label:"labels.cut",icon:K1,trackEvent:{category:"element"},perform:(e,n,t,o)=>(ma.perform(e,n,t,o),Ls.perform(e,n,null,o)),keyTest:e=>e[Jw.CTRL_OR_CMD]&&e.key===Jw.X}),C_=O({name:"copyAsSvg",label:"labels.copyAsSvg",icon:s0,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:Jt.EVENTUALLY};let{exportedElements:r,exportingFrame:i}=$r(e,n,!0);try{await Zr("clipboard-svg",r,n,o.files,{...n,exportingFrame:i,name:o.getName()});let a=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:f("toast.copyToClipboardAsSvg",{exportSelection:a.length?f("toast.selection"):f("toast.canvas"),exportColorScheme:n.exportWithDarkMode?f("buttons.darkMode"):f("buttons.lightMode")})}},captureUpdate:Jt.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:Jt.EVENTUALLY}}},predicate:e=>Kd&&e.length>0,keywords:["svg","clipboard","copy"]}),P_=O({name:"copyAsPng",label:"labels.copyAsPng",icon:l0,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:Jt.EVENTUALLY};let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=$r(e,n,!0);try{return await Zr("clipboard",i,n,o.files,{...n,exportingFrame:a,name:o.getName()}),{appState:{...n,toast:{message:f("toast.copyToClipboardAsPng",{exportSelection:r.length?f("toast.selection"):f("toast.canvas"),exportColorScheme:n.exportWithDarkMode?f("buttons.darkMode"):f("buttons.lightMode")})}},captureUpdate:Jt.EVENTUALLY}}catch(s){return console.error(s),{appState:{...n,errorMessage:s.message},captureUpdate:Jt.EVENTUALLY}}},predicate:e=>lr&&e.length>0,keyTest:e=>e.code===T_.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),k_=O({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0});try{To(I_(r))}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return{captureUpdate:Jt.EVENTUALLY}},predicate:(e,n,t,o)=>Kd&&o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}).some(v_),keywords:["text","clipboard","copy"]});import{CODES as M_,KEYS as A_}from"@excalidraw/common";import{CaptureUpdateAction as D_}from"@excalidraw/element";var pa=O({name:"gridMode",icon:d0,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>e.gridModeEnabled},perform(e,n){return{appState:{...n,gridModeEnabled:!this.checked(n),objectsSnapModeEnabled:!1},captureUpdate:D_.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[A_.CTRL_OR_CMD]&&e.code===M_.QUOTE});import{KEYS as lm}from"@excalidraw/common";import{CaptureUpdateAction as L_}from"@excalidraw/element/store";import{jsx as __}from"react/jsx-runtime";var al=O({name:"smartZoom",label:"toolBar.smartZoom",trackEvent:{category:"toolbar"},icon:th,viewMode:!0,perform:(e,n,t,o)=>{let r=da(n,o.props.editorPreferences).smartZoom,i=ce(e,n);return o.viewport.setViewport({target:i.length?i:e,fit:r.fitToViewport?"contain":"none",animation:r.animate?{duration:r.duration}:!1,offsets:r.respectUIElements?{ui:!0}:void 0,viewportZoomFactor:r.viewportZoomFactor}),{captureUpdate:L_.NEVER}},keyTest:e=>!e[lm.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===lm.F,PanelComponent:({data:e,updateData:n})=>__(Z,{type:"button",icon:th,"aria-label":f("labels.smartZoom"),title:`${f("labels.smartZoom")} - ${lm.F.toLocaleUpperCase()}`,onClick:()=>n(null),size:e?.size||"medium","data-testid":"button-smart-zoom",keyBindingLabel:lm.F.toLocaleUpperCase()})});import{CODES as R_,KEYS as N_}from"@excalidraw/common";import{CaptureUpdateAction as B_}from"@excalidraw/element";var Lt=O({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:jo,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,n){return{appState:{...n,objectsSnapModeEnabled:!this.checked(n),gridModeEnabled:!1},captureUpdate:B_.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,n,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[N_.CTRL_OR_CMD]&&e.altKey&&e.code===R_.S});import{CaptureUpdateAction as F_}from"@excalidraw/element";var sl=O({name:"arrowBinding",label:"labels.arrowBinding",viewMode:!1,trackEvent:{category:"canvas",predicate:e=>e.bindingPreference==="disabled"},perform(e,n){let t=n.bindingPreference==="enabled"?"disabled":"enabled";return{appState:{...n,bindingPreference:t,isBindingEnabled:t==="enabled"},captureUpdate:F_.NEVER}},checked:e=>e.bindingPreference==="enabled"});import{CaptureUpdateAction as O_}from"@excalidraw/element";var ll=O({name:"midpointSnapping",label:"labels.midpointSnapping",viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.isMidpointSnappingEnabled},perform(e,n){return{appState:{...n,isMidpointSnappingEnabled:!this.checked(n)},captureUpdate:O_.NEVER}},checked:e=>e.isMidpointSnappingEnabled});import{CODES as z_,KEYS as G_}from"@excalidraw/common";import{CaptureUpdateAction as H_}from"@excalidraw/element";var mr=O({name:"stats",label:"stats.fullTitle",icon:r0,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,n){return{appState:{...n,stats:{...n.stats,open:!this.checked(n)}},captureUpdate:H_.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[G_.CTRL_OR_CMD]&&e.altKey&&e.code===z_.SLASH});import{BOUND_TEXT_PADDING as Qw,ROUNDNESS as ev,TEXT_ALIGN as ov,VERTICAL_ALIGN as rv,arrayToMap as iv,getFontString as U_,getStrokeWidthByKey as W_}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as V_,isBoundToContainer as tv,resetOriginalContainerCache as Y_,updateOriginalContainerCache as X_}from"@excalidraw/element";import{computeBoundTextPosition as K_,computeContainerDimensionForBoundText as nv,getBoundTextElement as av,redrawTextBoundingBox as sv}from"@excalidraw/element";import{hasBoundTextElement as $_,isArrowElement as Z_,isTextBindableContainer as ug,isTextElement as cl,isUsingAdaptiveRadius as j_}from"@excalidraw/element";import{measureText as q_}from"@excalidraw/element";import{syncMovedIndices as lv}from"@excalidraw/element";import{newElement as J_}from"@excalidraw/element";import{CaptureUpdateAction as hg}from"@excalidraw/element";var gg=O({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>o.scene.getSelectedElements(n).some(i=>$_(i)),perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=o.scene.getNonDeletedElementsMap();return r.forEach(a=>{let s=av(a,i);if(s){let{width:l,height:c}=q_(s.originalText,U_(s),s.lineHeight),d=V_(a.id);Y_(a.id);let{x:m,y:p}=K_(a,s,i);o.scene.mutateElement(s,{containerId:null,width:l,height:c,text:s.originalText,x:m,y:p}),o.scene.mutateElement(a,{boundElements:a.boundElements?.filter(u=>u.id!==s.id),height:d||a.height})}}),{elements:e,appState:n,captureUpdate:hg.IMMEDIATELY}}}),fg=O({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);if(r.length===2){let i=cl(r[0])||cl(r[1]),a;if(ug(r[0])?a=r[0]:ug(r[1])&&(a=r[1]),i&&a&&av(a,o.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i,a;cl(r[0])&&ug(r[1])?(i=r[0],a=r[1]):(i=r[1],a=r[0]),o.scene.mutateElement(i,{containerId:a.id,verticalAlign:rv.MIDDLE,textAlign:ov.CENTER,autoResize:!0,angle:Z_(a)?0:a?.angle??0}),o.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let s=a.height;return sv(i,a,o.scene),X_(a.id,s),{elements:Q_(e,a,i),appState:{...n,selectedElementIds:{[a.id]:!0}},captureUpdate:hg.IMMEDIATELY}}}),Q_=(e,n,t)=>{let o=e.slice(),r=o.findIndex(a=>a.id===t.id);o.splice(r,1);let i=o.findIndex(a=>a.id===n.id);return o.splice(i+1,0,t),lv(o,iv([n,t])),o},eR=(e,n,t)=>{let o=e.slice(),r=o.findIndex(a=>a.id===n.id);o.splice(r,1);let i=o.findIndex(a=>a.id===t.id);return o.splice(i,0,n),lv(o,iv([n,t])),o},cv=O({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=r.some(a=>cl(a)&&!tv(a));return r.length>0&&i},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=e.slice(),a={};for(let s of r)if(cl(s)&&!tv(s)){let l=J_({type:"rectangle",backgroundColor:n.currentItemBackgroundColor,boundElements:[...s.boundElements||[],{id:s.id,type:"text"}],angle:s.angle,fillStyle:n.currentItemFillStyle,strokeColor:n.currentItemStrokeColor,roughness:n.currentItemRoughness,strokeWidth:W_("rectangle",n.currentItemStrokeWidthKey),strokeStyle:n.currentItemStrokeStyle,roundness:n.currentItemRoundness==="round"?{type:j_("rectangle")?ev.ADAPTIVE_RADIUS:ev.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:s.x-Qw,y:s.y-Qw,width:nv(s.width,"rectangle"),height:nv(s.height,"rectangle"),groupIds:s.groupIds,frameId:s.frameId});if(s.boundElements?.length){let c=s.boundElements.filter(m=>m.type==="arrow").map(m=>m.id);i.filter(m=>c.includes(m.id)).forEach(m=>{let p=m.startBinding,u=m.endBinding;p?.elementId===s.id&&(p={...p,elementId:l.id}),u?.elementId===s.id&&(u={...u,elementId:l.id}),(p||u)&&o.scene.mutateElement(m,{startBinding:p,endBinding:u})})}o.scene.mutateElement(s,{containerId:l.id,verticalAlign:rv.MIDDLE,boundElements:null,textAlign:ov.CENTER,autoResize:!0}),sv(s,l,o.scene),i=eR([...i,l],l,s),a[l.id]=!0}return{elements:i,appState:{...n,selectedElementIds:a},captureUpdate:hg.IMMEDIATELY}}});import{getNonDeletedElements as xv,isEmbeddableElement as ER}from"@excalidraw/element";import{KEYS as yv}from"@excalidraw/common";import{CaptureUpdateAction as bR}from"@excalidraw/element";import{pointFrom as uv}from"@excalidraw/math";import tR from"clsx";import{useCallback as dv,useEffect as mv,useLayoutEffect as nR,useRef as oR,useState as rR}from"react";import{EVENT as Eg,HYPERLINK_TOOLTIP_DELAY as iR,KEYS as cm}from"@excalidraw/common";import{getElementAbsoluteCoords as vg}from"@excalidraw/element";import{hitElementBoundingBox as aR}from"@excalidraw/element";import{isElementLink as sR}from"@excalidraw/element";import{getEmbedLink as lR,embeddableURLValidator as cR}from"@excalidraw/element";import{sceneCoordsToViewportCoords as hv,viewportCoordsToSceneCoords as dR,wrapEvent as mR,isLocalLink as pR,normalizeLink as bg}from"@excalidraw/common";import{isEmbeddableElement as xg}from"@excalidraw/element";import{jsx as ua,jsxs as pv}from"react/jsx-runtime";var Ig=380,uR=42,yg=5,gv=85,hR=500,wg=!1,dm=new Map,fv=({element:e,scene:n,setAppState:t,onLinkOpen:o,setToast:r,updateEmbedValidationStatus:i})=>{let a=n.getNonDeletedElementsMap(),s=Qn(),l=kn(),c=be(),d=e.link||"",[m,p]=rR(d),u=oR(null),E=s.showHyperlinkPopup==="editor",g=dv(()=>{if(!u.current)return;let I=bg(u.current.value)||null;if(!e.link&&I&&Fe("hyperlink","create"),xg(e)){if(s.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!I){n.mutateElement(e,{link:null}),i(e,!1);return}if(!cR(I,l.validateEmbeddable))I&&r({message:f("toast.unableToEmbed"),closable:!0}),e.link&&dm.set(e.id,e.link),n.mutateElement(e,{link:I}),i(e,!1);else{let{width:T,height:C}=e,P=lR(I);P?.error instanceof URIError&&r({message:f("toast.unrecognizedLinkFormat"),closable:!0});let M=P?P.intrinsicSize.w/P.intrinsicSize.h:1,D=dm.get(e.id)!==e.link;n.mutateElement(e,{...D?{width:P?.type==="video"?T>C?T:C*M:T,height:P?.type==="video"&&T>C?T/M:C}:{},link:I}),i(e,!0),dm.has(e.id)&&dm.delete(e.id)}}else n.mutateElement(e,{link:I})},[e,n,r,l.validateEmbeddable,s.activeEmbeddable,t,i]);nR(()=>()=>{g()},[g]),mv(()=>{E&&u?.current&&!(c.formFactor==="phone"||c.isTouchScreen)&&u.current.select()},[E,c.formFactor,c.isTouchScreen]),mv(()=>{let I=null,T=C=>{if(E)return;I&&clearTimeout(I),fR(e,a,s,uv(C.clientX,C.clientY))&&(I=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},hR))};return window.addEventListener(Eg.POINTER_MOVE,T,!1),()=>{window.removeEventListener(Eg.POINTER_MOVE,T,!1),I&&clearTimeout(I)}},[s,e,E,t,a]);let b=dv(()=>{Fe("hyperlink","delete"),n.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,n]),w=()=>{Fe("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:y,y:x}=Ev(e,s,a);return s.contextMenu||s.selectedElementsAreBeingDragged||s.resizingElement||s.isRotating||s.openMenu||s.viewModeEnabled?null:pv("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${x}px`,left:`${y}px`,width:Ig,padding:yg},children:[E?ua("input",{className:tR("excalidraw-hyperlinkContainer-input"),placeholder:f("labels.link.hint"),ref:u,value:m,onChange:I=>p(I.target.value),autoFocus:!0,onKeyDown:I=>{I.stopPropagation(),I[cm.CTRL_OR_CMD]&&I.key===cm.K&&I.preventDefault(),(I.key===cm.ENTER||I.key===cm.ESCAPE)&&(g(),t({showHyperlinkPopup:"info"}))}}):e.link?ua("a",{href:bg(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:pR(e.link)?"_self":"_blank",onClick:I=>{if(e.link&&o){let T=mR(Eg.EXCALIDRAW_LINK,I.nativeEvent);o({...e,link:bg(e.link)},T),T.defaultPrevented&&I.preventDefault()}},rel:"noopener noreferrer",children:e.link}):ua("div",{className:"excalidraw-hyperlinkContainer-link",children:f("labels.link.empty")}),pv("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!E&&ua(Z,{type:"button",title:f("buttons.edit"),"aria-label":f("buttons.edit"),label:f("buttons.edit"),onClick:w,className:"excalidraw-hyperlinkContainer--edit",icon:$n}),ua(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:h0}),d&&!xg(e)&&ua(Z,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:b,className:"excalidraw-hyperlinkContainer--remove",icon:Or})]})]})},Ev=(e,n,t)=>{let[o,r]=vg(e,t),{x:i,y:a}=hv({sceneX:o+e.width/2,sceneY:r},n),s=i-n.offsetLeft-Ig/2,l=a-n.offsetTop-gv;return{x:s,y:l}},Tg=(e,n)=>{let t=ce(e,n);return xg(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},dl=null,bv=(e,n,t)=>{dl&&clearTimeout(dl),dl=window.setTimeout(()=>gR(e,n,t),iR)},gR=(e,n,t)=>{if(!e.link)return;let o=ji();o.classList.add("excalidraw-tooltip--visible"),o.style.maxWidth="20rem",o.textContent=sR(e.link)?f("labels.link.goToElement"):e.link;let[r,i,a,s]=vg(e,t),[l,c,d,m]=dx([r,i,a,s],e.angle,n),p=hv({sceneX:l,sceneY:c},n);Hh(o,{left:p.x,top:p.y,width:d,height:m},"top"),Fe("hyperlink","tooltip","link-icon"),wg=!0},mm=()=>{dl&&clearTimeout(dl),wg&&(wg=!1,ji().classList.remove("excalidraw-tooltip--visible"))},fR=(e,n,t,[o,r])=>{let{x:i,y:a}=dR({clientX:o,clientY:r},t),s=15/t.zoom.value;if(aR(uv(i,a),e,n))return!1;let[l,c,d]=vg(e,n);if(i>=l&&i<=d&&a>=c-gv&&a<=c)return!1;let{x:m,y:p}=Ev(e,t,n);return!(o>=m-s&&o<=m+Ig+yg*2+s&&r>=p-s&&r<=p+s+yg*2+uR)};import{jsx as xR}from"react/jsx-runtime";var Sg=O({name:"hyperlink",label:(e,n)=>Tg(xv(e),n),icon:Ms,perform:(e,n)=>n.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...n,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:bR.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[yv.CTRL_OR_CMD]&&e.key===yv.K,predicate:(e,n)=>ce(e,n).length===1,PanelComponent:({elements:e,appState:n,updateData:t})=>{let o=ce(e,n);return xR(Z,{type:"toggle",icon:Ms,"aria-label":f(Tg(xv(e),n)),title:`${ER(e[0])?f("labels.link.labelEmbed"):f("labels.link.label")} - ${N("CtrlOrCmd+K")}`,onSelect:()=>t(null),checked:o.length===1&&!!o[0].link})}});import{KEYS as wv,arrayToMap as Pg,randomId as yR}from"@excalidraw/common";import{elementsAreInSameGroup as wR,getNonDeletedElements as vv,newElementWith as Iv,selectGroupsFromGivenElements as Tv}from"@excalidraw/element";import{CaptureUpdateAction as Sv}from"@excalidraw/element";var Cg=e=>e.every(n=>!n.locked),ml=O({name:"toggleElementLock",label:(e,n,t)=>{let o=t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1});return Cg(o)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,n)=>{let t=ce(n,e);return Cg(t)?Ko:bo},trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return r.length>0&&!r.some(i=>i.locked&&i.frameId)},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!r.length)return!1;let i=Cg(r),a=Pg(r),s=r.length>1&&wR(r),c=r.length===1||s?null:yR(),d={...n.lockedMultiSelections};if(i)d={...n.lockedMultiSelections,...c?{[c]:!0}:{}};else if(s){let w=r[0].groupIds.at(-1);delete d[w]}let m=e.map(w=>{if(!a.has(w.id))return w;let y=w.groupIds;return i?c&&(y=[...y,c]):y=y.filter(x=>!n.lockedMultiSelections[x]),Iv(w,{locked:i,groupIds:y.length!==w.groupIds.length?y:w.groupIds})}),p=Pg(m),u=i?{}:Object.fromEntries(r.map(w=>[w.id,!0])),E=r.map(w=>p.get(w.id)||w),g=i?{}:Tv(vv(E),n),b=i?c||(s?r[0].groupIds.at(-1):r[0].id):null;return{elements:m,appState:{...n,selectedElementIds:u,selectedGroupIds:g,selectedLinearElement:i?null:n.selectedLinearElement,lockedMultiSelections:d,activeLockedId:b},captureUpdate:Sv.IMMEDIATELY}},keyTest:(e,n,t,o)=>e.key.toLocaleLowerCase()===wv.L&&e[wv.CTRL_OR_CMD]&&e.shiftKey&&o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}).length>0}),Cv=O({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:bo,predicate:(e,n)=>ce(e,n).length===0&&e.some(o=>o.locked),perform:(e,n)=>{let t=e.filter(s=>s.locked),o=e.map(s=>{if(s.locked){let l=s.groupIds.filter(c=>!n.lockedMultiSelections[c]);return Iv(s,{locked:!1,groupIds:s.groupIds.length!==l.length?l:s.groupIds})}return s}),r=Pg(o),i=t.map(s=>r.get(s.id)||s),a=vv(i);return{elements:o,appState:{...n,selectedElementIds:Object.fromEntries(a.map(s=>[s.id,!0])),selectedGroupIds:Tv(a,n),lockedMultiSelections:{},activeLockedId:null},captureUpdate:Sv.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as _8,isLinearElement as R8,isLineElement as wa}from"@excalidraw/element";import{arrayToMap as N8,invariant as c2}from"@excalidraw/common";import{toggleLinePolygonState as B8,CaptureUpdateAction as d2}from"@excalidraw/element";import{getSizeFromPoints as CTe,randomInteger as D8,getUpdatedTimestamp as L8}from"@excalidraw/common";import{simplify as m8}from"points-on-curve";import{getStroke as p8,getStrokePoints as sTe}from"perfect-freehand";function Ze([e,n,t],[o,r,i]){return[e+o,n+r,t+i]}function ha([e,n,t],[o,r,i]){return[e-o,n-r,t-i]}function nt([e,n,t],o){return[e*o,n*o,t*o]}function ei([e,n,t]){return[e/Math.sqrt(e**2+n**2),n/Math.sqrt(e**2+n**2),t]}function xt([e,n,t],o){return[Math.cos(o)*e-Math.sin(o)*n,Math.sin(o)*e+Math.cos(o)*n,t]}function Pv(e,n,t){return Ze(e,nt(ha(n,e),t))}function kg(e,n,t){return Math.atan2(t[1]-e[1],t[0]-e[0])-Math.atan2(n[1]-e[1],n[0]-e[0])}function Mg(e){return Math.atan2(Math.sin(e),Math.cos(e))}function Ag([e,n]){return Math.sqrt(e**2+n**2)}function Qr([e,n],[t,o]){return Math.sqrt((t-e)**2+(o-n)**2)}function kv(e){if(e.length<2)return 0;let n=0;for(let t=1;t<=e.length-1;t++)n+=Qr(e[t-1],e[t]);return n+=Qr(e[e.length-2],e[e.length-1]),n}var vR=(e,n,t)=>Math.max(n,Math.min(t,e));function Mv(e,n,t){let o=Qr(n,t);if(o===0)return Qr(e,n);let r=vR(((e[0]-n[0])*(t[0]-n[0])+(e[1]-n[1])*(t[1]-n[1]))/o**2,0,1),i=[n[0]+r*(t[0]-n[0]),n[1]+r*(t[1]-n[1]),e[2]];return Qr(i,e)}function pl(e,n){if(n===0||e.length<=2)return e;let t=e[0],o=e[e.length-1],[r,i]=e.reduce(([a,s],l,c)=>{let d=Mv(l,t,o);return d>a?[d,c]:[a,s]},[0,-1]);if(r>=n){let a=e[i];return[...pl([t,...e.slice(1,i),a],n).slice(0,-1),a,...pl([a,...e.slice(i,-1),o],n).slice(1)]}return[t,o]}var pr=class pr{constructor(n){v(this,"options");v(this,"originalPoints",[]);v(this,"stablePoints",[]);v(this,"tailPoints",[]);v(this,"isFresh",!0);this.options=Object.assign({},pr.defaults,n)}get lastPoint(){return this.tailPoints[this.tailPoints.length-1]??this.stablePoints[this.stablePoints.length-1]}addPoint(n){let t=this.originalPoints[this.originalPoints.length-1];if(!(t&&t[0]===n[0]&&t[1]===n[1])){if(this.originalPoints.push(n),this.isFresh){this.isFresh=!1,this.stablePoints.push(n);return}this.options.streamline>0&&(n=Pv(this.lastPoint,n,1-this.options.streamline)),this.tailPoints.push(n),kv(this.tailPoints)>pr.constants.maxTailLength&&this.stabilizeTail()}}close(){this.stabilizeTail()}stabilizeTail(){if(this.options.simplify>0&&this.options.simplifyPhase==="tail")throw new Error("Not implemented yet");this.stablePoints.push(...this.tailPoints),this.tailPoints=[]}getSize(n,t,o,r,i){return(n??this.options.size)*this.options.sizeMapping({pressure:t,runningLength:i,currentIndex:o,totalLength:r})}getStrokeOutline(n){if(this.isFresh)return[];let t=[...this.stablePoints,...this.tailPoints];this.options.simplify>0&&this.options.simplifyPhase==="input"&&(t=pl(t,this.options.simplify));let o=t.length;if(o===0)return[];if(o===1){let P=t[0],M=this.getSize(n,P[2],0,o,0);if(M<.5)return[];let D=[];for(let _=0;_<=Math.PI*2;_+=Math.PI/16)D.push(Ze(P,nt(xt([1,0,0],_),M)));return D.push(Ze(P,nt([1,0,0],this.getSize(n,P[2],0,o,0)))),D}if(o===2){let P=t[0],M=t[1],D=this.getSize(n,P[2],0,o,0),_=this.getSize(n,M[2],0,o,0);if(D<.5||_<.5)return[];let k=[],L=kg(P,[P[0],P[1]-100,P[2]],M);for(let F=L;F<=Math.PI+L;F+=Math.PI/16)k.push(Ze(P,nt(xt([1,0,0],F),D)));for(let F=Math.PI+L;F<=Math.PI*2+L;F+=Math.PI/16)k.push(Ze(M,nt(xt([1,0,0],F),_)));return k.push(k[0]),k}let r=[],i=[],a=0,s=0,l=0,c=0;for(let P=1;P<o-1;P++){let M=t[P-1],D=t[P],_=t[P+1],k=D[2],L=Qr(M,D);c+=L,a=s+(L-s)*.2;let F=this.getSize(n,k,P,o,c);if(F===0){l=P+1;continue}let Y=ei(ha(M,D)),z=ei(ha(_,D)),U=xt(Y,Math.PI/2),V=xt(Y,-Math.PI/2),G=xt(z,Math.PI/2),re=xt(z,-Math.PI/2),B=Ze(D,nt(U,F)),W=Ze(D,nt(V,F)),ue=Ze(D,nt(G,F)),Ee=Ze(D,nt(re,F)),le=Ze(U,re),he=Ze(V,G),ge=Ze(D,nt(Ag(le)===0?Y:ei(le),F)),se=Ze(D,nt(Ag(he)===0?z:ei(he),F)),xe=Mg(kg(D,M,_)),it=pr.constants.cornerDetectionMaxAngle/180*Math.PI*pr.constants.cornerDetectionVariance(a);if(Math.abs(xe)<it){let $e=Math.abs(Mg(Math.PI-xe));if($e===0)continue;if(xe<0){i.push(W,se);for(let ke=0;ke<=$e;ke+=$e/4)r.push(Ze(D,xt(nt(U,F),ke)));for(let ke=$e;ke>=0;ke-=$e/4)i.push(Ze(D,xt(nt(U,F),ke)));i.push(se,ue)}else{r.push(B,ge);for(let ke=0;ke<=$e;ke+=$e/4)i.push(Ze(D,xt(nt(U,-F),-ke)));for(let ke=$e;ke>=0;ke-=$e/4)r.push(Ze(D,xt(nt(U,-F),-ke)));r.push(ge,Ee)}}else r.push(ge),i.push(se);s=a}if(l>=o-2){if(this.options.keepHead){let P=t[o-1],M=[];for(let D=0;D<=Math.PI*2;D+=Math.PI/16)M.push(Ze(P,nt(xt([1,0,0],D),this.options.size)));return M.push(Ze(P,nt([1,0,0],this.options.size))),M}return[]}let d=t[l],m=t[l+1],p=t[o-2],u=t[o-1],E=ei(ha(m,d)),g=ei(ha(p,u)),b=xt(E,-Math.PI/2),w=xt(g,Math.PI/2),y=this.getSize(n,d[2],0,o,0),x=[],I=this.options.keepHead?this.options.size:this.getSize(n,p[2],o-2,o,c),T=[];if(y>.1){for(let P=0;P<=Math.PI;P+=Math.PI/16)x.unshift(Ze(d,xt(nt(b,y),-P)));x.unshift(Ze(d,nt(b,-y)))}else x.push(d);for(let P=0;P<=Math.PI*3;P+=Math.PI/16)T.push(Ze(u,xt(nt(w,-I),-P)));let C=[...x,...r,...T.reverse(),...i.reverse()];return x.length>0&&C.push(x[0]),this.options.simplify>0&&this.options.simplifyPhase==="output"?pl(C,this.options.simplify):C}};v(pr,"defaults",{size:2,streamline:.45,simplify:.1,simplifyPhase:"output",keepHead:!1,sizeMapping:()=>1}),v(pr,"constants",{cornerDetectionMaxAngle:75,cornerDetectionVariance:n=>n>35?.5:1,maxTailLength:50});var ga=pr;import{pointsOnBezierCurves as ode}from"points-on-curve";import{invariant as ide}from"@excalidraw/common";import{curve as sde,lineSegment as lde,pointFrom as cde,pointDistance as dde,pointFromArray as mde,pointFromVector as pde,pointRotateRads as ude,polygon as hde,polygonFromPoints as gde,PRECISION as fde,segmentsIntersectAt as Ede,vector as bde,vectorAdd as xde,vectorFromPoint as yde,vectorScale as wde}from"@excalidraw/math";import{getElementAbsoluteCoords as Ide}from"@excalidraw/element";var Dg=e=>{if(!e)return[];for(let n of e.sets)if(n.type==="path")return n.ops;return e.sets[0].ops};import{pointFrom as u8,pointDistance as o2,pointRotateRads as mTe}from"@excalidraw/math";import{ROUGHNESS as h8,THEME as jg,isTransparent as Sl,assertNever as g8,COLOR_PALETTE as f8,LINE_POLYGON_POINT_MERGE_DISTANCE as uTe,applyDarkModeFilter as Cl,DEFAULT_STROKE_STREAMLINE as E8}from"@excalidraw/common";import{RoughGenerator as b8}from"roughjs/bin/generator";import bIe from"roughjs/bin/rough";import{isRightAngleRads as yIe,lineSegment as wIe,pointFrom as vIe,pointRotateRads as IIe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as SIe,DEFAULT_REDUCED_GLOBAL_ALPHA as CIe,ELEMENT_READY_TO_ERASE_OPACITY as PIe,FRAME_STYLE as kIe,DARK_THEME_FILTER as MIe,MIME_TYPES as n2,THEME as AIe,distance as DIe,getFontString as LIe,isRTL as _Ie,getVerticalOffset as RIe,invariant as NIe,applyDarkModeFilter as BIe,isSafari as FIe}from"@excalidraw/common";import H2e from"roughjs/bin/rough";import{arrayToMap as W2e,invariant as t2,rescalePoints as V2e,sizeOf as Y2e}from"@excalidraw/common";import{degreesToRadians as Xg,lineSegment as K2e,pointFrom as yt,pointFromArray as r8,pointRotateRads as ya}from"@excalidraw/math";import{pointsOnBezierCurves as j2e}from"points-on-curve";import{pointCenter as i2e,pointFrom as a2e,pointRotateRads as s2e,pointsEqual as l2e,pointDistance as c2e,vectorFromPoint as d2e,curveLength as m2e,curvePointAtLength as p2e}from"@excalidraw/math";import{DRAGGING_THRESHOLD as g2e,KEYS as f2e,shouldRotateWithDiscreteAngle as E2e,getGridPoint as b2e,invariant as x2e,isShallowEqual as y2e,getFeatureFlag as w2e}from"@excalidraw/common";import{arrayToMap as yve,getFeatureFlag as wve,getGridPoint as vve,invariant as Ive,isTransparent as Tve}from"@excalidraw/common";import{PRECISION as Cve,clamp as Pve,lineSegment as kve,pointDistance as Mve,pointDistanceSq as Ave,pointFrom as Dve,pointFromArray as Lve,pointFromVector as _ve,pointRotateRads as Rve,pointsEqual as Nve,vectorFromPoint as Bve,vectorNormalize as Fve,vectorScale as Ove}from"@excalidraw/math";import{invariant as Hwe,isTransparent as Uwe}from"@excalidraw/common";import{curveIntersectLineSegment as Vwe,isPointWithinBounds as Ywe,lineSegment as Xwe,lineSegmentIntersectionPoints as Kwe,pointFrom as $we,pointFromVector as Zwe,pointRotateRads as jwe,pointsEqual as qwe,vectorFromPoint as Jwe,vectorNormalize as Qwe,vectorScale as eve}from"@excalidraw/math";import{ellipse as nve,ellipseSegmentInterceptPoints as ove}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as CR,DEFAULT_PROPORTIONAL_RADIUS as Rg,invariant as Rde,LINE_CONFIRM_THRESHOLD as PR,ROUNDNESS as Ng}from"@excalidraw/common";import{bezierEquation as Bde,curve as Fde,curveCatmullRomCubicApproxPoints as Ode,curveOffsetPoints as zde,lineSegment as Gde,lineSegmentIntersectionPoints as Hde,pointDistance as kR,pointFrom as Ude,pointFromArray as Wde,pointFromVector as Vde,pointRotateRads as Yde,pointTranslate as Xde,rectangle as Kde,vectorFromPoint as $de,vectorNormalize as Zde,vectorScale as jde}from"@excalidraw/math";import{ROUNDNESS as Pde,assertNever as kde}from"@excalidraw/common";import{pointsEqual as Ade}from"@excalidraw/math";var Av=e=>!!e&&e.type==="embeddable",Lg=e=>!!e&&e.type==="iframe",_g=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),pn=e=>e!=null&&e.type==="text";var no=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var un=e=>e!=null&&TR(e.type);var An=e=>e!=null&&e.type==="arrow",Dn=e=>An(e)&&e.elbowed;var TR=e=>e==="arrow"||e==="line";var So=e=>e!==null&&"containerId"in e&&e.containerId!==null&&pn(e);var fa=(e,n=1)=>{if(e.length>=3){let[t,o]=[e[0],e[e.length-1]];return kR(t,o)<=PR/n}return!1},ul=(e,n)=>{if(n.roundness?.type===Ng.PROPORTIONAL_RADIUS||n.roundness?.type===Ng.LEGACY)return e*Rg;if(n.roundness?.type===Ng.ADAPTIVE_RADIUS){let t=n.roundness?.value??CR,o=t/Rg;return e<=o?e*Rg:t}return 0};import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as ywe,ARROW_LABEL_WIDTH_FRACTION as wwe,BOUND_TEXT_PADDING as vwe,DEFAULT_FONT_SIZE as Iwe,TEXT_ALIGN as Twe,VERTICAL_ALIGN as Swe,getFontString as Cwe,isProdEnv as Pwe,invariant as kwe}from"@excalidraw/common";import{pointFrom as Awe,pointRotateRads as Dwe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as dme,DEFAULT_FONT_SIZE as mme,DEFAULT_FONT_FAMILY as pme,getFontString as ume,isTestEnv as hme,normalizeEOL as gme}from"@excalidraw/common";var fme="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as Ime,isTestEnv as Tme}from"@excalidraw/common";import{toIterable as uye}from"@excalidraw/common";import{SHIFT_LOCKING_ANGLE as Mme,viewportCoordsToSceneCoords as Ame}from"@excalidraw/common";import{normalizeRadians as Lme,radiansBetweenAngles as _me,radiansDifference as Rme}from"@excalidraw/math";import{pointsEqual as Bme}from"@excalidraw/math";import{arrayToMap as ype,isShallowEqual as LR}from"@excalidraw/common";import{arrayToMap as epe}from"@excalidraw/common";import{isPointWithinBounds as npe,pointFrom as ope,segmentsIntersectAt as rpe}from"@excalidraw/math";import{arrayToMap as Ume}from"@excalidraw/common";import{validateOrderKey as Vme,generateNKeysBetween as Yme}from"@excalidraw/fractional-indexing";var Bg=(e,n)=>{let t=[];for(let o of e.values())o.frameId===n&&t.push(o);return t};var kpe=function(){let e=null,n=null,t=null,o=(r,i)=>(t!=null&&r===e&&i.selectedElementIds===n||(t=r.some(a=>i.selectedElementIds[a.id]),e=r,n=i.selectedElementIds),t);return o.clearCache=()=>{e=null,n=null,t=null},o}(),bl=(e,n,t)=>{let o=new Set,r=[];for(let i of e.values()){if(n.selectedElementIds[i.id]){ti(i)?(r.push(i),o.add(i.id)):console.error("[NONDELETED][INVARIANT] getSelectedElements skipping deleted selected element which should not be in the selection");continue}if(t?.includeBoundTextElement&&So(i)&&ti(i)&&n.selectedElementIds[i?.containerId]){r.push(i),o.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return r.forEach(a=>{no(a)&&Bg(e,a.id).forEach(s=>!o.has(s.id)&&i.push(s)),i.push(a)}),i}return r};var Og=(e,n)=>LR(n.selectedElementIds,e)?n.selectedElementIds:e;var _R=function(){let e=null,n=null,t=null,o=(i,a,s,l)=>{if(t!==void 0&&a===n&&i===e&&s.editingGroupId===t?.editingGroupId)return t;let c={};for(let p of i){let u=p.groupIds;if(s.editingGroupId){let E=u.indexOf(s.editingGroupId);E>-1&&(u=u.slice(0,E))}if(u.length>0){let E=u[u.length-1];c[E]=!0}}let d={},m=a.reduce((p,u)=>{if(u.isDeleted)return p;let E=u.groupIds.find(g=>c[g]);return E&&(p[u.id]=!0,Array.isArray(d[E])?d[E].push(u.id):d[E]=[u.id]),p},{});for(let p of Object.keys(d))d[p].length<2&&c[p]&&(c[p]=!1);return n=a,e=i,t={editingGroupId:s.editingGroupId,selectedGroupIds:c,selectedElementIds:Og({...s.selectedElementIds,...m},l)},t},r=(i,a,s,l)=>{let c=l?l.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):bl(a,i);return c.length?o(c,a,i,s):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:Og(i.selectedElementIds,s)}};return r.clearCache=()=>{n=null,e=null,t=null},r}();var Xpe=[1,4/3,3/4,3/2,2/3,2,1/2];import{TEXT_ALIGN as Uue,VERTICAL_ALIGN as Wue}from"@excalidraw/common";import{pointDistance as Yue,pointFromVector as Xue,pointsEqual as Kue,vector as $ue,vectorDot as Zue,vectorFromPoint as jue,vectorNormalize as que,vectorScale as Jue}from"@excalidraw/math";import{invariant as rue,isDevEnv as iue,isTestEnv as aue}from"@excalidraw/common";import{pointFrom as lue,pointFromVector as cue,pointRotateRads as due,pointScaleFromOrigin as mue,pointsEqual as pue,triangleIncludesPoint as uue,vectorCross as hue,vectorFromPoint as BR,vectorScale as gue}from"@excalidraw/math";var wl=[1,0],fm=[0,1],vl=[-1,0],Em=[0,-1],bm=e=>{let[n,t]=e,o=Math.abs(n),r=Math.abs(t);return n>r?wl:n<=-r?vl:t>o?fm:Em},zv=(e,n)=>bm(BR(e,n)),xm=(e,n)=>ym(zv(e,n)),yl=(e,n)=>e[0]===n[0]&&e[1]===n[1],ym=e=>yl(e,wl)||yl(e,vl);import{DEFAULT_ELEMENT_PROPS as yue,DEFAULT_FONT_FAMILY as wue,DEFAULT_FONT_SIZE as vue,DEFAULT_TEXT_ALIGN as Iue,DEFAULT_VERTICAL_ALIGN as Tue,DEFAULT_STROKE_STREAMLINE as Sue,VERTICAL_ALIGN as Cue,randomInteger as Pue,randomId as kue,getFontString as Mue,getUpdatedTimestamp as Aue,getLineHeight as Due}from"@excalidraw/common";import{pointsOnBezierCurves as whe,simplify as vhe}from"points-on-curve";import{curveToBezier as The}from"points-on-curve/lib/curve-to-bezier";import{distanceToLineSegment as Che,lineSegment as Phe,lineSegmentIntersectionPoints as khe,pointDistance as Mhe,pointFrom as Ahe,pointRotateRads as Dhe,polygonArea as Lhe,polygonIncludesPoint as _he,polygonIncludesPointNonZero as Rhe,polygonSignedArea as Nhe}from"@excalidraw/math";import{isOpaqueColor as Fhe,isTransparent as Ohe}from"@excalidraw/common";var Wv=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";import{curvePointDistance as che,distanceToLineSegment as dhe,pointRotateRads as mhe}from"@excalidraw/math";import{ellipse as uhe,ellipseDistanceFromPoint as hhe}from"@excalidraw/math/ellipse";import{pointFrom as Jhe,pointCenter as Qhe,pointRotateRads as ege,vectorFromPoint as tge,vectorNormalize as nge,vectorSubtract as oge,vectorAdd as rge,vectorScale as ige,pointFromVector as age,clamp as sge,isCloseTo as lge}from"@excalidraw/math";import{arrayToMap as Ffe,arrayToObject as Ofe,assertNever as zfe,isDevEnv as Gfe,isShallowEqual as Hfe,isTestEnv as Ufe,randomInteger as Wfe}from"@excalidraw/common";import{assertNever as Vge,COLOR_PALETTE as Yge,isDevEnv as Xge,isTestEnv as Kge,randomId as $ge,Emitter as Zge,toIterable as jge}from"@excalidraw/common";import{ORIG_ID as wge,randomId as vge,randomInteger as Ige,arrayToMap as Tge,castArray as Sge,findLastIndex as Cge,getUpdatedTimestamp as Pge,isTestEnv as kge}from"@excalidraw/common";import{arrayToMap as uge}from"@excalidraw/common";import zR from"lodash.throttle";import{randomInteger as mfe,arrayToMap as pfe,toBrandedType as ufe,isDevEnv as Xv,isTestEnv as Kv,toArray as hfe}from"@excalidraw/common";import{isNonDeletedElement as ffe}from"@excalidraw/element";import{isFrameLikeElement as bfe}from"@excalidraw/element";import{getElementsInGroup as yfe}from"@excalidraw/element";import{syncInvalidIndices as vfe,syncMovedIndices as Ife,validateFractionalIndices as GR}from"@excalidraw/element";import{getSelectedElements as Sfe}from"@excalidraw/element";import{mutateElement as Pfe}from"@excalidraw/element";var kfe=zR(e=>{(Xv()||Kv()||window?.DEBUG_FRACTIONAL_INDICES)&&GR(e,{shouldThrow:Xv()||Kv(),includeBoundTextValidation:!0})},1e3*60,{leading:!0,trailing:!1});import{TEXT_AUTOWRAP_THRESHOLD as hEe,getGridPoint as gEe,getFontString as fEe,DRAGGING_THRESHOLD as EEe}from"@excalidraw/common";import{clamp as kEe,pointDistance as MEe,pointFrom as AEe,pointScaleFromOrigin as DEe,pointsEqual as LEe,pointTranslate as _Ee,vector as REe,vectorCross as NEe,vectorFromPoint as BEe,vectorScale as FEe}from"@excalidraw/math";import{BinaryHeap as zEe,invariant as GEe,isAnyTrue as HEe,getSizeFromPoints as UEe,isDevEnv as WEe,arrayToMap as VEe}from"@excalidraw/common";import{ELEMENT_LINK_KEY as rbe,normalizeLink as ibe}from"@excalidraw/common";import{FONT_FAMILY as dbe,VERTICAL_ALIGN as mbe,escapeDoubleQuotes as pbe,getFontString as ube}from"@excalidraw/common";import{invariant as vbe,toBrandedType as Ibe}from"@excalidraw/common";import{clamp as Sbe,pointFrom as Cbe}from"@excalidraw/math";import{pointDistance as txe,pointFrom as nxe}from"@excalidraw/math";import{invariant as rxe}from"@excalidraw/common";import{arrayToMap as Gbe,findIndex as Hbe,findLastIndex as Ube}from"@excalidraw/common";import{isFiniteNumber as Vbe}from"@excalidraw/math";import{decode as hxe,decodeFrames as gxe}from"modern-gif";import{DEFAULT_GIF_AUTO_DECODE_MAX_FILE_SIZE_BYTES as vxe,MIME_TYPES as Ixe,SVG_NS as Txe}from"@excalidraw/common";import{rgbaToThumbHash as Cxe,thumbHashToRGBA as Pxe}from"thumbhash";import{pointCenter as Xxe,normalizeRadians as Kxe,pointFrom as $xe,pointRotateRads as Zxe}from"@excalidraw/math";import{MIN_FONT_SIZE as qxe,SHIFT_LOCKING_ANGLE as Jxe,rescalePoints as Qxe,getFontString as e1e}from"@excalidraw/common";import{pointFrom as P1e,pointOnLineSegment as k1e,pointRotateRads as M1e}from"@excalidraw/math";import{SIDE_RESIZING_THRESHOLD as D1e}from"@excalidraw/common";import{DEFAULT_TRANSFORM_HANDLE_SPACING as h1e}from"@excalidraw/common";import{pointFrom as f1e,pointRotateRads as E1e}from"@excalidraw/math";import{KEYS as _n}from"@excalidraw/common";var U1e=[{icon:Oc,value:"selection",key:_n.V,numericKey:void 0,fillable:!0,myocSimplifiedMode:!0},{icon:_i,value:"rectangle",key:_n.R,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Ri,value:"diamond",key:_n.D,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Ni,value:"ellipse",key:_n.O,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:zc,value:"arrow",key:_n.A,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:$o,value:"line",key:_n.L,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:$n,value:"freedraw",key:[_n.P,_n.X],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Pn,value:"text",key:_n.T,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Fr,value:"image",key:[_n.I],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Gc,value:"eraser",key:_n.E,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0}];import{pointFrom as e0e}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as n0e,DEFAULT_FONT_SIZE as o0e,TEXT_ALIGN as r0e,VERTICAL_ALIGN as i0e,getSizeFromPoints as a0e,randomId as s0e,arrayToMap as l0e,assertNever as c0e,cloneJSON as d0e,getFontString as m0e,isDevEnv as p0e,toBrandedType as u0e,getLineHeight as h0e}from"@excalidraw/common";import{getBoundsFromPoints as F0e,getElementAbsoluteCoords as O0e}from"@excalidraw/element/bounds";import{newArrowElement as G0e,newElement as H0e,newLinearElement as U0e}from"@excalidraw/element/newElement";import{ELEMENT_PENDING_DRAW_SHAPE_OPACITY as V0e,getStrokeWidthByKey as Y0e,ROUNDNESS as X0e}from"@excalidraw/common";import{convexHull as $0e,distanceToLineSegment as Z0e,elongation as j0e,kurtosis as q0e,lineSegment as J0e,orientPrincipalAxes as Q0e,pointFrom as eye,polygonArea as tye,principalAxes as nye,principalCoords as oye,skewness as rye}from"@excalidraw/math";var lye=[{type:"rectangle",hullFillRatio:1,cornerTurnShare:.95,kurtosisProduct:1.83},{type:"diamond",hullFillRatio:.5,cornerTurnShare:.95,kurtosisProduct:3.24},{type:"ellipse",hullFillRatio:Math.PI/4,cornerTurnShare:.55,kurtosisProduct:2.25}];var ti=e=>!e.isDeleted;var qR=10/1.5;var pm=e=>{let n=Math.floor(e.width/2)+1,t=0,o=e.width,r=Math.floor(e.height/2)+1,i=n,a=e.height;return[n,t,o,r,i,a,0,r]};var i8=20,a8=15,s8=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 a8;case"cardinality_one":case"cardinality_exactly_one":case"cardinality_zero_or_one":return i8;default:return 15}},l8=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},Rt=(e,n,t,o,r=0)=>{if(o===null||n.length<1)return null;let i=Dg(n[0]);if(i.length<1)return null;let a=t==="start"?1:i.length-1,s=i[a].data;t2(s.length===6,"Op data length is not 6");let l=yt(s[4],s[5]),c=yt(s[2],s[3]),d=yt(s[0],s[1]),m=i[a-1],p=yt(0,0);if(m.op==="move"){let G=r8(m.data);t2(G!=null,"Op data is not a point"),p=G}else m.op==="bcurveTo"&&(p=yt(m.data[4],m.data[5]));let u=(G,re)=>Math.pow(1-G,3)*l[re]+3*G*Math.pow(1-G,2)*c[re]+3*Math.pow(G,2)*(1-G)*d[re]+p[re]*Math.pow(G,3),[E,g]=t==="start"?p:l,[b,w]=[u(.3,0),u(.3,1)],y=Math.hypot(E-b,g-w),x=(E-b)/y,I=(g-w)/y,T=s8(o),C=0;{let[G,re]=t==="end"?e.points[e.points.length-1]:e.points[0],[B,W]=e.points.length>1?t==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];C=Math.hypot(G-B,re-W)}let M=Math.min(T,C*(o==="diamond"||o==="diamond_outline"?.25:.5)),D=E-x*M*r,_=g-I*M*r,k=D-x*M,L=_-I*M;if(o==="circle"||o==="circle_outline"){let G=Math.hypot(L-_,k-D)+e.strokeWidth-2;return[D,_,G]}let F=l8(o);if(o==="cardinality_many"||o==="cardinality_one_or_many"){let[G,re]=ya(yt(D,_),yt(k,L),Xg(-F)),[B,W]=ya(yt(D,_),yt(k,L),Xg(F));return[k,L,G,re,B,W]}let[Y,z]=ya(yt(k,L),yt(D,_),-F*Math.PI/180),[U,V]=ya(yt(k,L),yt(D,_),Xg(F));if(o==="diamond"||o==="diamond_outline"){let G,re;if(t==="start"){let[B,W]=e.points.length>1?e.points[1]:[0,0];[G,re]=ya(yt(D+M*2,_),yt(D,_),Math.atan2(W-_,B-D))}else{let[B,W]=e.points.length>1?e.points[e.points.length-2]:[0,0];[G,re]=ya(yt(D-M*2,_),yt(D,_),Math.atan2(_-W,D-B))}return[D,_,Y,z,G,re,U,V]}return[D,_,Y,z,U,V]};var c8=typeof document<"u"?document.createElement("img"):{src:""};c8.src=`data:${n2.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 d8=typeof document<"u"?document.createElement("img"):{src:""};d8.src=`data:${n2.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 Kg=new WeakMap;var Wt=class Wt{};v(Wt,"rg",new b8),v(Wt,"cache",new WeakMap),v(Wt,"get",(n,t)=>{let o=Wt.cache.get(n);if(o&&(t===null||o.theme===t))return o.shape}),v(Wt,"delete",n=>{Wt.cache.delete(n),Kg.delete(n)}),v(Wt,"destroy",()=>{Wt.cache=new WeakMap}),v(Wt,"generateElementShape",(n,t)=>{let o=t?.isExporting?void 0:Wt.get(n,t?t.theme:null);if(o!==void 0)return o;Kg.delete(n);let r=w8(n,Wt.rg,t||{isExporting:!1,canvasBackgroundColor:f8.white,embedsValidationStatus:null,theme:jg.LIGHT});return t?.isExporting||Wt.cache.set(n,{shape:r,theme:t?.theme||jg.LIGHT}),r});var xa=Wt,x8=e=>[8,8+e],s2=e=>[1.5,6+e];function y8(e){let n=e.roughness,t=Math.max(e.width,e.height),o=Math.min(e.width,e.height);return o>=20&&t>=50||o>=15&&e.roundness&&Wv(e.type)||un(e)&&t>=50?n:Math.min(n/(t<10?3:2),2.5)}var Po=(e,n=!1,t=!1)=>{let o={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?x8(e.strokeWidth):e.strokeStyle==="dotted"?s2(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:y8(e),stroke:Cl(e.strokeColor,t),preserveVertices:n||e.roughness<h8.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return o.fillStyle=e.fillStyle,o.fill=Sl(e.backgroundColor)?void 0:Cl(e.backgroundColor,t),e.type==="ellipse"&&(o.curveFitting=1),o;case"line":case"freedraw":return fa(e.points)&&(o.fillStyle=e.fillStyle,o.fill=e.backgroundColor==="transparent"?void 0:Cl(e.backgroundColor,t)),o;case"arrow":return o;default:throw new Error(`Unimplemented type ${e.type}`)}},r2=(e,n,t)=>_g(e)&&(n||Av(e)&&t?.get(e.id)!==!0)&&Sl(e.backgroundColor)&&Sl(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:Lg(e)?{...e,strokeColor:Sl(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:Sl(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,Tl=(e,n,t)=>{if(n===null)return[];let[,,o,r,i,a]=n;return[e.line(o,r,i,a,t)]},vm=(e,n,t)=>{if(n===null)return[];let[o,r,i,a,s,l]=n;return[e.line(i,a,o,r,t),e.line(s,l,o,r,t)]},oi=(e,n)=>{let t={...n};if(e.strokeStyle==="dotted"){let o=s2(e.strokeWidth-1);t.strokeLineDash=[o[0],o[1]-1]}else delete t.strokeLineDash;return t.roughness=Math.min(1,t.roughness||0),t},$g=(e,n,t,o,r,i=1)=>{if(o===null)return[];let[a,s,l]=o,c={...n,fill:r,fillStyle:"solid",stroke:t,roughness:Math.min(.5,n.roughness||0)};return delete c.strokeLineDash,[e.circle(a,s,l*i,c)]},i2=(e,n,t,o,r,i,a,s)=>{if(o===null)return[];let l=Cl(e.strokeColor,s),c=Cl(a,s),d=-.25,m=.8;switch(o){case"circle":case"circle_outline":return $g(r,i,l,Rt(e,n,t,o),o==="circle_outline"?c:l);case"triangle":case"triangle_outline":{let p=Rt(e,n,t,o);if(p===null)return[];let[u,E,g,b,w,y]=p,x={...i,fill:o==="triangle_outline"?c:l,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)};return delete x.strokeLineDash,[r.polygon([[u,E],[g,b],[w,y],[u,E]],x)]}case"diamond":case"diamond_outline":{let p=Rt(e,n,t,o);if(p===null)return[];let[u,E,g,b,w,y,x,I]=p,T={...i,fill:o==="diamond_outline"?c:l,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)};return delete T.strokeLineDash,[r.polygon([[u,E],[g,b],[w,y],[x,I],[u,E]],T)]}case"cardinality_one":return Tl(r,Rt(e,n,t,o),oi(e,i));case"cardinality_many":return vm(r,Rt(e,n,t,o),oi(e,i));case"cardinality_one_or_many":{let p=oi(e,i);return[...vm(r,Rt(e,n,t,"cardinality_many"),p),...Tl(r,Rt(e,n,t,"cardinality_one",d),p)]}case"cardinality_exactly_one":{let p=oi(e,i);return[...Tl(r,Rt(e,n,t,"cardinality_one",-.5),p),...Tl(r,Rt(e,n,t,"cardinality_one"),p)]}case"cardinality_zero_or_one":{let p=oi(e,i);return[...$g(r,i,l,Rt(e,n,t,"circle_outline",1.5),c,m),...Tl(r,Rt(e,n,t,"cardinality_one",-.5),p)]}case"cardinality_zero_or_many":{let p=oi(e,i);return[...vm(r,Rt(e,n,t,"cardinality_many"),p),...$g(r,i,l,Rt(e,n,t,"circle_outline",1.5),c,m)]}case"bar":case"arrow":default:return vm(r,Rt(e,n,t,o),oi(e,i))}};var w8=(e,n,{isExporting:t,canvasBackgroundColor:o,embedsValidationStatus:r,theme:i})=>{let a=i===jg.DARK;switch(e.type){case"rectangle":case"iframe":case"embeddable":{let s;if(e.roundness){let l=e.width,c=e.height,d=ul(Math.min(l,c),e);s=n.path(`M ${d} 0 L ${l-d} 0 Q ${l} 0, ${l} ${d} L ${l} ${c-d} Q ${l} ${c}, ${l-d} ${c} L ${d} ${c} Q 0 ${c}, 0 ${c-d} L 0 ${d} Q 0 0, ${d} 0`,Po(r2(e,t,r),!0,a))}else s=n.rectangle(0,0,e.width,e.height,Po(r2(e,t,r),!1,a));return s}case"diamond":{let s,[l,c,d,m,p,u,E,g]=pm(e);if(e.roundness){let b=ul(Math.abs(l-E),e),w=ul(Math.abs(m-c),e);s=n.path(`M ${l+b} ${c+w} L ${d-b} ${m-w}
5
+ C ${d} ${m}, ${d} ${m}, ${d-b} ${m+w}
6
+ L ${p+b} ${u-w}
7
+ C ${p} ${u}, ${p} ${u}, ${p-b} ${u-w}
8
+ L ${E+b} ${g+w}
9
+ C ${E} ${g}, ${E} ${g}, ${E+b} ${g-w}
10
+ L ${l-b} ${c+w}
11
+ C ${l} ${c}, ${l} ${c}, ${l+b} ${c+w}`,Po(e,!0,a))}else s=n.polygon([[l,c],[d,m],[p,u],[E,g]],Po(e,!1,a));return s}case"ellipse":return n.ellipse(e.width/2,e.height/2,e.width,e.height,Po(e,!1,a));case"line":case"arrow":{let s,l=Po(e,!1,a),c=e.points.length?e.points:[u8(0,0)];if(Dn(e)?c.every(d=>Math.abs(d[0])<=1e6&&Math.abs(d[1])<=1e6)?s=[n.path(v8(c,16),Po(e,!0,a))]:(console.error("Elbow arrow with extreme point positions detected. Arrow not rendered.",e.id,JSON.stringify(c)),s=[]):e.roundness?s=[n.curve(c,l)]:l.fill?s=[n.polygon(c,l)]:s=[n.linearPath(c,l)],e.type==="arrow"){let{startArrowhead:d=null,endArrowhead:m="arrow"}=e;if(d!==null){let p=i2(e,s,"start",d,n,l,o,a);s.push(...p)}if(m!==null){let p=i2(e,s,"end",m,n,l,o,a);s.push(...p)}}return s}case"freedraw":{let s=[];if(fa(e.points)){let l=m8(e.points,.75);s.push(n.curve(l,{...Po(e,!1,a),stroke:"none"}))}return s.push(I8(e)),s}case"frame":case"magicframe":case"text":case"image":return null;default:return g8(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},v8=(e,n)=>{let t=[];for(let r=1;r<e.length-1;r+=1){let i=e[r-1],a=e[r+1],s=e[r],l=xm(s,i),c=xm(a,s),d=Math.min(n,o2(e[r],a)/2,o2(e[r],i)/2);l?i[0]<s[0]?t.push([e[r][0]-d,e[r][1]]):t.push([e[r][0]+d,e[r][1]]):i[1]<s[1]?t.push([e[r][0],e[r][1]-d]):t.push([e[r][0],e[r][1]+d]),t.push(e[r]),c?a[0]<s[0]?t.push([e[r][0]-d,e[r][1]]):t.push([e[r][0]+d,e[r][1]]):a[1]<s[1]?t.push([e[r][0],e[r][1]-d]):t.push([e[r][0],e[r][1]+d])}let o=[`M ${e[0][0]} ${e[0][1]}`];for(let r=0;r<t.length;r+=3)o.push(`L ${t[r][0]} ${t[r][1]}`),o.push(`Q ${t[r+1][0]} ${t[r+1][1]}, ${t[r+2][0]} ${t[r+2][1]}`);return o.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),o.join(" ")};var I8=e=>A8(k8(e)),Zg={SIZE_FACTOR:4.25,THINNING:.6,SMOOTHING:.5},T8={SIZE_FACTOR:1.4},l2=e=>e.strokeOptions?.streamline??E8,S8=e=>{let n=e.simulatePressure?e.points:e.points.length?e.points.map(([t,o],r)=>[t,o,e.pressures[r]]):[[0,0,.5]];return p8(n,{simulatePressure:e.simulatePressure,size:e.strokeWidth*Zg.SIZE_FACTOR,thinning:Zg.THINNING,smoothing:Zg.SMOOTHING,streamline:l2(e),easing:t=>Math.sin(t*Math.PI/2),last:!0})},C8=e=>new ga({size:e.strokeWidth*T8.SIZE_FACTOR,streamline:l2(e),simplify:0,sizeMapping:n=>Math.max(.1,n.pressure)}),P8=e=>{let n=C8(e);return e.points.map(([t,o])=>n.addPoint([t,o,1])),n.getStrokeOutline().map(([t,o])=>[t,o])},k8=e=>e.strokeOptions?.variability==="constant"?P8(e):S8(e);var a2=(e,n)=>[(e[0]+n[0])/2,(e[1]+n[1])/2],M8=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g,A8=e=>{if(!e.length)return"";let n=e.length-1;return e.reduce((t,o,r,i)=>(r===n?t.push(o,a2(o,i[0]),"L",i[0],"Z"):t.push(o,a2(o,i[r+1])),t),["M",e[0],"Q"]).join(" ").replace(M8,"$1")};var ni=(e,n,t=!1)=>{let o=!1;for(let r in n){let i=n[r];if(typeof i<"u"){if(e[r]===i&&(typeof i!="object"||i===null))continue;o=!0}}return!o&&!t?e:{...e,...n,version:n.version??e.version+1,versionNonce:n.versionNonce??D8(),updated:L8()}};import{jsx as m2}from"react/jsx-runtime";var va=O({name:"toggleLinearEditor",label:(e,n,t)=>t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return!!(!n.selectedLinearElement?.isEditing&&r.length===1&&R8(r[0])&&!_8(r[0]))},perform(e,n,t,o){c2(n.selectedLinearElement,"No selected linear element found");let r=o.scene.getElement(n.selectedLinearElement.elementId);c2(r,"No selected element found");let i={...n.selectedLinearElement,isEditing:!n.selectedLinearElement.isEditing};return{appState:{...n,selectedLinearElement:i},captureUpdate:d2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0];if(!o)return null;let r=f(o.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return m2(Z,{type:"button",icon:m0,title:r,"aria-label":r,onClick:()=>n(null)})}}),GTe=O({name:"togglePolygon",icon:ku,keywords:["loop"],label:(e,n,t)=>!t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds}).some(i=>!wa(i)||!i.polygon)?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds});return r.length>0&&r.every(i=>wa(i)&&i.points.length>=4)},perform(e,n,t,o){let r=o.scene.getSelectedElements(n);if(r.some(l=>!wa(l)))return!1;let i=r,a=i.some(l=>!l.polygon),s=N8(i);return{elements:e.map(l=>!s.has(l.id)||!wa(l)?l:ni(l,{backgroundColor:a?l.backgroundColor:"transparent",...B8(l,a)})),appState:n,captureUpdate:d2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(o.length===0||o.some(a=>!wa(a)||!a.polygon||a.points.length<3))return null;let r=o.every(a=>wa(a)&&a.polygon),i=f(r?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return m2(Z,{type:"toggle",icon:ku,title:i,"aria-label":i,checked:r,onSelect:()=>n(null),style:{marginLeft:"auto"}})}});import{KEYS as p2,CANVAS_SEARCH_TAB as u2,CLASSES as F8,DEFAULT_SIDEBAR as h2}from"@excalidraw/common";import{CaptureUpdateAction as O8}from"@excalidraw/element";var Pl=O({name:"searchMenu",icon:Jn,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,n,t,o){if(n.openDialog)return!1;if(n.openSidebar?.name===h2.name&&n.openSidebar.tab===u2){let r=o.excalidrawContainerValue.container?.querySelector(`.${F8.SEARCH_MENU_INPUT_WRAPPER} input`);return r?.focus(),r?.select(),!1}return{appState:{...n,openSidebar:{name:h2.name,tab:u2},openDialog:null},captureUpdate:O8.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[p2.CTRL_OR_CMD]&&e.key===p2.F});import{isImageElement as z8}from"@excalidraw/element";import{CaptureUpdateAction as G8}from"@excalidraw/element";import{jsx as H8}from"react/jsx-runtime";var qg=O({name:"cropEditor",label:"helpDialog.cropStart",icon:Ju,viewMode:!0,trackEvent:{category:"menu"},keywords:["image","crop"],perform(e,n,t,o){let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...n,isCropping:!1,croppingElementId:r.id},captureUpdate:G8.IMMEDIATELY}},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return!!(!n.croppingElementId&&r.length===1&&z8(r[0]))},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=f("helpDialog.cropStart");return H8(Z,{type:"button",icon:Ju,title:o,"aria-label":o,onClick:()=>n(null)})}});import{getNonDeletedElements as U8}from"@excalidraw/element";import{mutateElement as W8}from"@excalidraw/element";import{newFrameElement as V8}from"@excalidraw/element";import{isFrameLikeElement as Im}from"@excalidraw/element";import{addElementsToFrame as Y8,removeAllElementsFromFrame as X8}from"@excalidraw/element";import{getFrameChildren as K8}from"@excalidraw/element";import{getElementsInGroup as $8}from"@excalidraw/element";import{getCommonBounds as Z8}from"@excalidraw/element";import{CaptureUpdateAction as Ia}from"@excalidraw/element";var g2=(e,n)=>{let t=n.scene.getSelectedElements(e);return t.length===1&&Im(t[0])},f2=O({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;if(Im(r)){let i=K8(U8(e),r.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...n,selectedElementIds:i.reduce((a,s)=>(a[s.id]=!0,a),{})},captureUpdate:Ia.IMMEDIATELY}}return{elements:e,appState:n,captureUpdate:Ia.EVENTUALLY}},predicate:(e,n,t,o)=>g2(n,o)}),E2=O({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;return Im(r)?{elements:X8(e,r),appState:{...n,selectedElementIds:{[r.id]:!0}},captureUpdate:Ia.IMMEDIATELY}:{elements:e,appState:n,captureUpdate:Ia.EVENTUALLY}},predicate:(e,n,t,o)=>g2(n,o)}),ZSe=O({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n)=>({elements:e,appState:{...n,frameRendering:{...n.frameRendering,enabled:!n.frameRendering.enabled}},captureUpdate:Ia.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),b2=O({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=ce(e,n);return r.length>0&&!r.some(i=>Im(i))},perform:(e,n,t,o)=>{let r=ce(e,n),i=o.scene.getNonDeletedElementsMap(),[a,s,l,c]=Z8(r,i),d=16,m=V8({x:a-d,y:s-d,width:l-a+d*2,height:c-s+d*2});if(n.editingGroupId){let u=$8(r,n.editingGroupId);for(let E of u){let g=E.groupIds.indexOf(n.editingGroupId);W8(E,i,{groupIds:E.groupIds.slice(0,g)})}}return{elements:Y8([...o.scene.getElementsIncludingDeleted(),m],r,m),appState:{selectedElementIds:{[m.id]:!0}},captureUpdate:Ia.IMMEDIATELY}}});import{KEYS as Sa,matchKey as ef,arrayToMap as x2,MOBILE_ACTION_BUTTON_BG as y2}from"@excalidraw/common";import{CaptureUpdateAction as Qg}from"@excalidraw/element";import{orderByFractionalIndex as nN}from"@excalidraw/element";import{Emitter as j8}from"@excalidraw/common";import{CaptureUpdateAction as q8,StoreChange as J8,StoreDelta as Q8}from"@excalidraw/element";var Ta=class extends Q8{applyTo(n,t,o){let[r,i]=this.elements.applyTo(n,o.elements,{excludedProperties:new Set(["version","versionNonce"])}),[a,s]=this.appState.applyTo(t,r);return[r,a,i||s]}static calculate(n,t){return super.calculate(n,t)}static inverse(n){return super.inverse(n)}static applyLatestChanges(n,t,o,r){return super.applyLatestChanges(n,t,o,r)}},ri=class{constructor(n=!0,t=!0){this.isUndoStackEmpty=n;this.isRedoStackEmpty=t}},kl=class e{constructor(n){this.store=n;v(this,"onHistoryChangedEmitter",new j8);v(this,"undoStack",[]);v(this,"redoStack",[])}get isUndoStackEmpty(){return this.undoStack.length===0}get isRedoStackEmpty(){return this.redoStack.length===0}clear(){this.undoStack.length=0,this.redoStack.length=0}record(n){if(n.isEmpty()||n instanceof Ta)return;let t=Ta.inverse(n);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new ri(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(n,t){return this.perform(n,t,()=>e.pop(this.undoStack),o=>e.push(this.redoStack,o))}redo(n,t){return this.perform(n,t,()=>e.pop(this.redoStack),o=>e.push(this.undoStack,o))}perform(n,t,o,r){try{let i=o();if(i===null)return;let a=q8.IMMEDIATELY,s=this.store.snapshot,l=n,c=t,d=!1;for(;i;){try{[l,c,d]=i.applyTo(l,c,s);let m=s.elements,p=s.maybeClone(a,l,c),u=J8.create(s,p),E=Ta.applyLatestChanges(i,m,l);E.isEmpty()||(this.store.scheduleMicroAction({action:a,change:u,delta:E}),i=E),s=p}finally{r(i)}if(d)break;i=o()}return[l,c]}finally{this.onHistoryChangedEmitter.trigger(new ri(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(n){if(!n.length)return null;let t=n.pop();return t!==void 0?t:null}static push(n,t){let o=Ta.inverse(t);return n.push(o)}};import{useEffect as eN,useState as tN}from"react";var Jg=(e,n)=>{let[t,o]=tN(n);return eN(()=>{let r=e.on(i=>{o(i)});return()=>{r()}},[e]),t};import{jsx as T2}from"react/jsx-runtime";var w2=(e,n,t)=>{if(!n.multiElement&&!n.resizingElement&&!n.editingTextElement&&!n.newElement&&!n.selectedElementsAreBeingDragged&&!n.selectionElement&&!e.flowchart.isCreatingChart&&!e.drawShape.hasPendingGesture()){let o=t();if(!o)return{captureUpdate:Qg.EVENTUALLY};let[r,i]=o,a=nN(Array.from(r.values()));return{appState:i,elements:a,captureUpdate:Qg.NEVER}}return{captureUpdate:Qg.EVENTUALLY}},v2=e=>({name:"undo",label:"buttons.undo",icon:Lu,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>w2(r,t,()=>e.undo(x2(n),t)),keyTest:n=>n[Sa.CTRL_OR_CMD]&&ef(n,Sa.Z)&&!n.shiftKey,PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isUndoStackEmpty:i}=Jg(e.onHistoryChangedEmitter,new ri(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=ct()==="mobile";return T2(Z,{type:"button",icon:Lu,"aria-label":f("buttons.undo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-undo",style:{...a?y2:{}}})}}),I2=e=>({name:"redo",label:"buttons.redo",icon:_u,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>w2(r,t,()=>e.redo(x2(n),t)),keyTest:n=>n[Sa.CTRL_OR_CMD]&&n.shiftKey&&ef(n,Sa.Z)||n[Sa.CTRL_OR_CMD]&&!n.shiftKey&&ef(n,Sa.Y),PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isRedoStackEmpty:i}=Jg(e.onHistoryChangedEmitter,new ri(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=ct()==="mobile";return T2(Z,{type:"button",icon:_u,"aria-label":f("buttons.redo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-redo",style:{...a?y2:{}}})}});import{getFontString as oN}from"@excalidraw/common";import{getTextAnchorRatios as rN,isExcalidrawElement as iN,isNonDeletedElement as aN,newElementWith as sN,updateBoundElements as lN}from"@excalidraw/element";import{measureText as cN}from"@excalidraw/element";import{isTextElement as tf}from"@excalidraw/element";import{CaptureUpdateAction as dN}from"@excalidraw/element";var nf=O({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,n,t)=>{let o=ce(e,n);return o.length===1&&tf(o[0])&&!o[0].autoResize},perform:(e,n,t,o)=>{let r=ce(e,n),i=iN(t)&&tf(t)?t:r[0],a=e.find(d=>d.id===i?.id);if(!a||!tf(a))return!1;let s=cN(a.originalText,oN(a),a.lineHeight),l=rN(a),c=sN(a,{autoResize:!0,width:s.width,height:s.height,x:a.x+(a.width-s.width)*l.x,y:a.y+(a.height-s.height)*l.y,text:a.originalText});return aN(c)&&lN(c,o.scene,{changedElements:new Map([[c.id,c]])}),{appState:n,elements:e.map(d=>d.id===c.id?c:d),captureUpdate:dN.IMMEDIATELY}}});import{CODES as mN,KEYS as pN}from"@excalidraw/common";import uN from"clsx";import{CaptureUpdateAction as hN}from"@excalidraw/element";import{jsx as gN}from"react/jsx-runtime";var Ca=O({name:"viewMode",label:"labels.viewMode",icon:Hr,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,n){return n.viewModeOnly?!1:{appState:{...n,viewModeEnabled:!this.checked(n)},captureUpdate:hN.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,n,t,o)=>!n.viewModeOnly&&!t.viewModeOnly&&typeof t.viewModeEnabled>"u"&&o.isInteractionEnabled(),keyTest:e=>!e[pN.CTRL_OR_CMD]&&e.altKey&&e.code===mN.R,PanelComponent:({data:e,updateData:n,appState:t,appProps:o})=>{if(t.viewModeOnly||o.viewModeOnly)return null;let r=t.viewModeEnabled?"Edit mode":f("labels.viewMode");return gN(Z,{type:"button",icon:t.viewModeEnabled?nh:Hr,"aria-label":r,onClick:()=>n(null),size:e?.size||"medium","data-testid":"button-view-mode",className:uN({enabled:t.viewModeEnabled})})}});import{isPromiseLike as fN}from"@excalidraw/common";import{jsx as EN}from"react/jsx-runtime";var of=(e,n,t,o,r,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,o,i))&&Fe(e.trackEvent.category,e.trackEvent.action||e.name,`${n} (${r.editorInterface.formFactor==="phone"?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},Tm=class{constructor(n,t,o,r){v(this,"actions",{});v(this,"updater");v(this,"getAppState");v(this,"getElementsIncludingDeleted");v(this,"app");v(this,"isActionBlockedByViewportTransition",n=>n.navigation===!0&&this.app.viewport.isLockedTransitionPending);v(this,"renderAction",(n,t)=>{let o=this.app.props.UIOptions.canvasActions;if(this.actions[n]&&"PanelComponent"in this.actions[n]&&(!(n in o)||o[n])){let r=this.actions[n],i=r.PanelComponent;i.displayName="PanelComponent";let a=s=>{this.isActionBlockedByViewportTransition(r)||(of(r,"ui",this.getAppState(),this.getElementsIncludingDeleted(),this.app,s),this.updater(r.perform(this.getElementsIncludingDeleted(),this.getAppState(),s,this.app)))};return EN(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:a,appProps:this.app.props,app:this.app,data:t,renderAction:this.renderAction})}return null});v(this,"isActionEnabled",n=>{let t=this.getElementsIncludingDeleted(),o=this.getAppState();return!n.predicate||n.predicate(t,o,this.app.props,this.app)});this.updater=i=>{if(fN(i))i.then(a=>n(a));else return n(i)},this.getAppState=t,this.getElementsIncludingDeleted=o,this.app=r}registerAction(n){this.actions[n.name]=n}registerAll(n){n.forEach(t=>this.registerAction(t))}handleKeyDown(n){if(!this.app.isInteractionEnabled()&&!this.app.isNavigationEnabled())return!1;let t=this.app.props.UIOptions.canvasActions,o=Object.values(this.actions).sort((l,c)=>(c.keyPriority||0)-(l.keyPriority||0)).filter(l=>(l.name in t?t[l.name]:!0)&&l.keyTest&&l.keyTest(n,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(o.length!==1)return o.length>1&&console.warn("Canceling as multiple actions match this shortcut",o),!1;let r=o[0];if(!this.app.isInteractionEnabled()&&r.navigation!==!0||this.getAppState().viewModeEnabled&&r.viewMode!==!0)return!1;if(this.isActionBlockedByViewportTransition(r))return n.preventDefault(),n.stopPropagation(),!0;let i=this.getElementsIncludingDeleted(),a=this.getAppState(),s=null;return of(r,"keyboard",a,i,this.app,null),n.preventDefault(),n.stopPropagation(),this.updater(o[0].perform(i,a,s,this.app)),!0}executeAction(n,t="api",o=null){if(t!=="api"&&!this.app.isInteractionEnabled()&&!(this.app.isNavigationEnabled()&&n.navigation===!0)||this.isActionBlockedByViewportTransition(n))return;let r=this.getElementsIncludingDeleted(),i=this.getAppState();of(n,t,i,r,this.app,o),this.updater(n.perform(r,i,o,this.app))}};var rf=e=>{let n=Array.from(e.values());return{x:S2(n,t=>t.x)/n.length,y:S2(n,t=>t.y)/n.length}},af=([e,n])=>Math.hypot(e.x-n.x,e.y-n.y),S2=(e,n)=>e.reduce((t,o)=>t+n(o),0);import{pointFrom as X,pointRotateRads as ur,rangeInclusive as hn,rangeIntersection as Sm,rangesOverlap as Cm}from"@excalidraw/math";import{TOOL_TYPE as ii,KEYS as C2}from"@excalidraw/common";import{getCommonBounds as sf,getDraggedElementsBounds as lf,getElementAbsoluteCoords as bN}from"@excalidraw/element";import{isBoundToContainer as A2}from"@excalidraw/element";import{getMaximumGroups as D2}from"@excalidraw/element";import{getSelectedElements as xN,getVisibleAndNonSelectedElements as L2}from"@excalidraw/element";var yN=8,P2=99999,Pm=e=>yN/e,Nt=class Nt{};v(Nt,"referenceSnapPoints",null),v(Nt,"visibleGaps",null),v(Nt,"setReferenceSnapPoints",n=>{Nt.referenceSnapPoints=n}),v(Nt,"getReferenceSnapPoints",()=>Nt.referenceSnapPoints),v(Nt,"setVisibleGaps",n=>{Nt.visibleGaps=n}),v(Nt,"getVisibleGaps",()=>Nt.visibleGaps),v(Nt,"destroy",()=>{Nt.referenceSnapPoints=null,Nt.visibleGaps=null});var gn=Nt,hr=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,ko=({event:e,app:n,selectedElements:t})=>{if(e){let o=n.state.activeTool.type==="lasso"&&n.state.selectedElementsAreBeingDragged;return(n.state.activeTool.type!=="lasso"||o)&&(n.state.objectsSnapModeEnabled&&!e[C2.CTRL_OR_CMD]||!n.state.objectsSnapModeEnabled&&e[C2.CTRL_OR_CMD]&&!hr(n))}return t.length===1&&t[0].type==="arrow"?!1:n.state.objectsSnapModeEnabled},wN=(e,n,t=.01)=>Math.abs(e-n)<=t,Ml=(e,n,{omitCenter:t,boundingBoxCorners:o,dragOffset:r}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[s,l,c,d,m,p]=bN(a,n);r&&(s+=r.x,c+=r.x,m+=r.x,l+=r.y,d+=r.y,p+=r.y);let u=(c-s)/2,E=(d-l)/2;if((a.type==="diamond"||a.type==="ellipse")&&!o){let g=ur(X(s,l+E),X(m,p),a.angle),b=ur(X(s+u,l),X(m,p),a.angle),w=ur(X(c,l+E),X(m,p),a.angle),y=ur(X(s+u,d),X(m,p),a.angle),x=X(m,p);i=t?[g,b,w,y]:[g,b,w,y,x]}else{let g=ur(X(s,l),X(m,p),a.angle),b=ur(X(c,l),X(m,p),a.angle),w=ur(X(s,d),X(m,p),a.angle),y=ur(X(c,d),X(m,p),a.angle),x=X(m,p);i=t?[g,b,w,y]:[g,b,w,y,x]}}else if(e.length>1){let[a,s,l,c]=lf(e,r??{x:0,y:0}),d=l-a,m=c-s,p=X(a,s),u=X(l,s),E=X(a,c),g=X(l,c),b=X(a+d/2,s+m/2);i=t?[p,u,E,g]:[p,u,E,g,b]}return i.map(a=>X(Xe(a[0]),Xe(a[1])))},_2=(e,n,t,o)=>L2(e,n,t,o),R2=(e,n,t,o)=>{let r=_2(e,n,t,o),i=D2(r,o).filter(m=>!(m.length===1&&A2(m[0]))).map(m=>sf(m).map(p=>Xe(p))),a=i.sort((m,p)=>m[0]-p[0]),s=[],l=0;e:for(let m=0;m<a.length;m++){let p=a[m];for(let u=m+1;u<a.length;u++){if(++l>P2)break e;let E=a[u],[,g,b,w]=p,[y,x,,I]=E;b<y&&Cm(hn(g,w),hn(x,I))&&s.push({startBounds:p,endBounds:E,startSide:[X(b,g),X(b,w)],endSide:[X(y,x),X(y,I)],length:y-b,overlap:Sm(hn(g,w),hn(x,I))})}}let c=i.sort((m,p)=>m[1]-p[1]),d=[];l=0;e:for(let m=0;m<c.length;m++){let p=c[m];for(let u=m+1;u<c.length;u++){if(++l>P2)break e;let E=c[u],[g,,b,w]=p,[y,x,I]=E;w<x&&Cm(hn(g,b),hn(y,I))&&d.push({startBounds:p,endBounds:E,startSide:[X(g,w),X(b,w)],endSide:[X(y,x),X(I,x)],length:x-w,overlap:Sm(hn(g,b),hn(y,I))})}}return{horizontalGaps:s,verticalGaps:d}},k2=(e,n,t,o,r,i,a)=>{if(!ko({app:t,event:o,selectedElements:e}))return[];if(e.length===0)return[];let s=gn.getVisibleGaps();if(s){let{horizontalGaps:l,verticalGaps:c}=s,[d,m,p,u]=lf(e,n).map(b=>Xe(b)),E=(d+p)/2,g=(m+u)/2;for(let b of l){if(!Cm(hn(m,u),b.overlap))continue;let w=b.startSide[0][0]+b.length/2,y=Xe(w-E);if(b.length>p-d&&Math.abs(y)<=a.x){Math.abs(y)<a.x&&(r.length=0),a.x=Math.abs(y);let _={type:"gap",direction:"center_horizontal",gap:b,offset:y};r.push(_);continue}let[,,I]=b.endBounds,T=d-I,C=Xe(b.length-T);if(Math.abs(C)<=a.x){Math.abs(C)<a.x&&(r.length=0),a.x=Math.abs(C);let _={type:"gap",direction:"side_right",gap:b,offset:C};r.push(_);continue}let[P,,,]=b.startBounds,M=P-p,D=Xe(M-b.length);if(Math.abs(D)<=a.x){Math.abs(D)<a.x&&(r.length=0),a.x=Math.abs(D);let _={type:"gap",direction:"side_left",gap:b,offset:D};r.push(_);continue}}for(let b of c){if(!Cm(hn(d,p),b.overlap))continue;let w=b.startSide[0][1]+b.length/2,y=Xe(w-g);if(b.length>u-m&&Math.abs(y)<=a.y){Math.abs(y)<a.y&&(i.length=0),a.y=Math.abs(y);let _={type:"gap",direction:"center_vertical",gap:b,offset:y};i.push(_);continue}let[,I,,]=b.startBounds,T=I-u,C=Xe(T-b.length);if(Math.abs(C)<=a.y){Math.abs(C)<a.y&&(i.length=0),a.y=Math.abs(C);let _={type:"gap",direction:"side_top",gap:b,offset:C};i.push(_);continue}let[,,,P]=b.endBounds,M=Xe(m-P),D=b.length-M;if(Math.abs(D)<=a.y){Math.abs(D)<a.y&&(i.length=0),a.y=Math.abs(D);let _={type:"gap",direction:"side_bottom",gap:b,offset:D};i.push(_);continue}}}},N2=(e,n,t,o)=>{let r=_2(e,n,t,o);return D2(r,o).filter(i=>!(i.length===1&&A2(i[0]))).flatMap(i=>Ml(i,o))},Pa=(e,n,t,o,r,i,a)=>{if(!ko({app:t,event:o,selectedElements:e})||e.length===0&&n.length===0)return[];let s=gn.getReferenceSnapPoints();if(s)for(let l of n)for(let c of s){let d=c[0]-l[0],m=c[1]-l[1];Math.abs(d)<=a.x&&(Math.abs(d)<a.x&&(r.length=0),r.push({type:"point",points:[l,c],offset:d}),a.x=Math.abs(d)),Math.abs(m)<=a.y&&(Math.abs(m)<a.y&&(i.length=0),i.push({type:"point",points:[l,c],offset:m}),a.y=Math.abs(m))}},B2=(e,n,t,o,r)=>{let i=t.state,a=xN(e,i);if(!ko({app:t,event:o,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};n.x=Xe(n.x),n.y=Xe(n.y);let s=[],l=[],c=Pm(i.zoom.value),d={x:c,y:c},m=Ml(a,r,{dragOffset:n});Pa(a,m,t,o,s,l,d),k2(a,n,t,o,s,l,d);let p={x:s[0]?.offset??0,y:l[0]?.offset??0};d.x=0,d.y=0,s.length=0,l.length=0;let u={x:Xe(n.x+p.x),y:Xe(n.y+p.y)};Pa(a,Ml(a,r,{dragOffset:u}),t,o,s,l,d),k2(a,u,t,o,s,l,d);let E=cf(s,l),g=IN(a,u,[...s,...l].filter(b=>b.type==="gap"));return{snapOffset:p,snapLines:[...E,...g]}},Xe=e=>Math.round(e*10**6)/10**6,M2=e=>{let n=new Map;for(let t of e){let o=t.join(",");n.has(o)||n.set(o,t)}return Array.from(n.values())},cf=(e,n)=>{let t={},o={};if(e.length>0){for(let r of e)if(r.type==="point"){let i=Xe(r.points[0][0]);t[i]||(t[i]=[]),t[i].push(...r.points.map(a=>X(Xe(a[0]),Xe(a[1]))))}}if(n.length>0){for(let r of n)if(r.type==="point"){let i=Xe(r.points[0][1]);o[i]||(o[i]=[]),o[i].push(...r.points.map(a=>X(Xe(a[0]),Xe(a[1]))))}}return Object.entries(t).map(([r,i])=>({type:"points",points:M2(i.map(a=>X(Number(r),a[1])).sort((a,s)=>a[1]-s[1]))})).concat(Object.entries(o).map(([r,i])=>({type:"points",points:M2(i.map(a=>X(a[0],Number(r))).sort((a,s)=>a[0]-s[0]))})))},vN=e=>{let n=new Map;for(let t of e){let o=t.points.flat().map(r=>[Xe(r)]).join(",");n.has(o)||n.set(o,t)}return Array.from(n.values())},IN=(e,n,t)=>{let[o,r,i,a]=lf(e,n),s=[];for(let l of t){let[c,d,m,p]=l.gap.startBounds,[u,E,g,b]=l.gap.endBounds,w=Sm(hn(r,a),l.gap.overlap),y=Sm(hn(o,i),l.gap.overlap);switch(l.direction){case"center_horizontal":{if(w){let x=(w[0]+w[1])/2;s.push({type:"gap",direction:"horizontal",points:[X(l.gap.startSide[0][0],x),X(o,x)]},{type:"gap",direction:"horizontal",points:[X(i,x),X(l.gap.endSide[0][0],x)]})}break}case"center_vertical":{if(y){let x=(y[0]+y[1])/2;s.push({type:"gap",direction:"vertical",points:[X(x,l.gap.startSide[0][1]),X(x,r)]},{type:"gap",direction:"vertical",points:[X(x,a),X(x,l.gap.endSide[0][1])]})}break}case"side_right":{if(w){let x=(w[0]+w[1])/2;s.push({type:"gap",direction:"horizontal",points:[X(m,x),X(u,x)]},{type:"gap",direction:"horizontal",points:[X(g,x),X(o,x)]})}break}case"side_left":{if(w){let x=(w[0]+w[1])/2;s.push({type:"gap",direction:"horizontal",points:[X(i,x),X(c,x)]},{type:"gap",direction:"horizontal",points:[X(m,x),X(u,x)]})}break}case"side_top":{if(y){let x=(y[0]+y[1])/2;s.push({type:"gap",direction:"vertical",points:[X(x,a),X(x,d)]},{type:"gap",direction:"vertical",points:[X(x,p),X(x,E)]})}break}case"side_bottom":{if(y){let x=(y[0]+y[1])/2;s.push({type:"gap",direction:"vertical",points:[X(x,p),X(x,E)]},{type:"gap",direction:"vertical",points:[X(x,b),X(x,r)]})}break}}}return vN(s.map(l=>({...l,points:l.points.map(c=>X(Xe(c[0]),Xe(c[1])))})))},df=(e,n,t,o,r,i)=>{if(!ko({event:o,selectedElements:e,app:t})||e.length===0||e.length===1&&!wN(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,s,l,c]=sf(n);i&&(i.includes("e")?l+=r.x:i.includes("w")&&(a+=r.x),i.includes("n")?s+=r.y:i.includes("s")&&(c+=r.y));let d=[];if(i)switch(i){case"e":{d.push(X(l,s),X(l,c));break}case"w":{d.push(X(a,s),X(a,c));break}case"n":{d.push(X(a,s),X(l,s));break}case"s":{d.push(X(a,c),X(l,c));break}case"ne":{d.push(X(l,s));break}case"nw":{d.push(X(a,s));break}case"se":{d.push(X(l,c));break}case"sw":{d.push(X(a,c));break}}let m=Pm(t.state.zoom.value),p={x:m,y:m},u=[],E=[];Pa(n,d,t,o,u,E,p);let g={x:u[0]?.offset??0,y:E[0]?.offset??0};p.x=0,p.y=0,u.length=0,E.length=0;let[b,w,y,x]=sf(e).map(C=>Xe(C)),I=[X(b,w),X(b,x),X(y,w),X(y,x)];Pa(e,I,t,o,u,E,p);let T=cf(u,E);return{snapOffset:g,snapLines:T}},F2=(e,n,t,o,r,i)=>{if(!ko({event:t,selectedElements:[e],app:n}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[X(o.x+r.x,o.y+r.y)],s=Pm(n.state.zoom.value),l={x:s,y:s},c=[],d=[];Pa([e],a,n,t,c,d,l);let m={x:c[0]?.offset??0,y:d[0]?.offset??0};l.x=0,l.y=0,c.length=0,d.length=0;let p=Ml([e],i,{boundingBoxCorners:!0,omitCenter:!0});Pa([e],p,n,t,c,d,l);let u=cf(c,d);return{snapOffset:m,snapLines:u}},O2=(e,n,t,o,r)=>{if(!ko({event:o,selectedElements:[],app:n}))return{originOffset:{x:0,y:0},snapLines:[]};let i=L2(e,[],n.state,r),a=Pm(n.state.zoom.value),s={x:a,y:a},l=[],c=[];for(let d of i){let m=Ml([d],r);for(let p of m){let u=p[0]-t.x;Math.abs(u)<=Math.abs(s.x)&&(Math.abs(u)<Math.abs(s.x)&&(c.length=0),c.push({type:"pointer",points:[p,X(p[0],t.y)],direction:"vertical"}),s.x=u);let E=p[1]-t.y;Math.abs(E)<=Math.abs(s.y)&&(Math.abs(E)<Math.abs(s.y)&&(l.length=0),l.push({type:"pointer",points:[p,X(t.x,p[1])],direction:"horizontal"}),s.y=E)}}return{originOffset:{x:c.length>0?c[0].points[0][0]-t.x:0,y:l.length>0?l[0].points[0][1]-t.y:0},snapLines:[...c,...l]}},z2=e=>e===ii.rectangle||e===ii.ellipse||e===ii.diamond||e===ii.frame||e===ii.magicframe||e===ii.image||e===ii.text;import{getCommonFrameId as TN,getFrameChildrenInsertionIndex as SN,isElementInViewport as CN}from"@excalidraw/element";import{arrayToMap as PN,memoize as kN,toBrandedType as MN}from"@excalidraw/common";var Al=class{constructor(n){v(this,"scene");v(this,"_getRenderableElements",kN(({canvasNonce:n,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height:s,width:l,editingTextElement:c,newElement:d})=>{let m=this.scene.getNonDeletedElements(),{elementsMap:p,newElementCanvasElement:u}=this.getRenderableElementsMap({elements:m,editingTextElement:c,newElement:d}),E=this.getVisibleCanvasElements({elementsMap:p,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height:s,width:l});return{elementsMap:p,visibleElements:E,newElementCanvasElement:u,canvasNonce:n}}));v(this,"getRenderableElements",n=>{let{newElement:t}=n,o=`${this.scene.getSceneNonce()}${t?.frameId?`:${t.versionNonce}`:""}`,r=this._getRenderableElements({canvasNonce:o,zoom:n.zoom,offsetLeft:n.offsetLeft,offsetTop:n.offsetTop,scrollX:n.scrollX,scrollY:n.scrollY,height:n.height,width:n.width,editingTextElement:n.editingTextElement,newElement:n.newElement});if(n.frameToHighlight&&n.selectedElementsAreBeingDragged&&TN(n.selectedElements)!==n.frameToHighlight.id){let i=this.sortSelectedElementsIntoHighlightedFrame({visibleElements:r.visibleElements,selectedElements:n.selectedElements,frameToHighlight:n.frameToHighlight});return{...r,visibleElements:i}}return r});this.scene=n}getVisibleCanvasElements({elementsMap:n,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height:s,width:l}){let c=[];for(let d of n.values())CN(d,l,s,{zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a},n)&&c.push(d);return c}getRenderableElementsMap({elements:n,editingTextElement:t,newElement:o}){let r=MN(new Map),i=o?.frameId?null:o;for(let a of n)i?.id!==a.id&&(!t||t.type!=="text"||a.id!==t.id)&&r.set(a.id,a);return{elementsMap:r,newElementCanvasElement:i}}sortSelectedElementsIntoHighlightedFrame({visibleElements:n,selectedElements:t,frameToHighlight:o}){if(!t.length)return n;let r=PN(t),i=n.filter(s=>!r.has(s.id)),a=SN(i,o.id);return a===null?n:[...i.slice(0,a),...t,...i.slice(a)]}destroy(){ux.cancel(),this._getRenderableElements.clear()}};import{DEFAULT_LASER_COLOR as RN,easeOut as U2}from"@excalidraw/common";import{SVG_NS as H2,getSvgPathFromStroke as LN,sceneCoordsToViewportCoords as _N}from"@excalidraw/common";import{version as AN}from"react";import{unstable_batchedUpdates as G2}from"react-dom";import{throttleRAF as DN}from"@excalidraw/common";var Ke=e=>n=>{G2(e,n)},km=e=>DN(n=>{G2(e,n)}),ka=(()=>{let e;try{let t=AN.split(".");e=Number(t[0])>17}catch{e=!1}let n=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(n||(n=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})();var me=class me{static start(n,t){if(me.animations.has(n))return;let o={animation:t,lastTime:0,state:void 0};me.animations.set(n,o);let r;try{r=t({deltaTime:0,state:void 0})}catch(i){throw me.animations.get(n)===o&&(me.animations.delete(n),me.cancelScheduledFrameIfIdle()),i}if(me.animations.get(n)===o){if(!r){me.animations.delete(n),me.cancelScheduledFrameIfIdle();return}o.state=r,me.scheduleNextFrame()}}static scheduleNextFrame(){me.scheduledFrame||(ka()?me.scheduledFrame={id:requestAnimationFrame(me.tick),type:"raf"}:me.scheduledFrame={id:setTimeout(me.tick,0),type:"timeout"})}static cancelScheduledFrame(){me.scheduledFrame&&(me.scheduledFrame.type==="raf"?cancelAnimationFrame(me.scheduledFrame.id):clearTimeout(me.scheduledFrame.id),me.scheduledFrame=null)}static cancelScheduledFrameIfIdle(){return me.animations.size>0?!1:(me.cancelScheduledFrame(),!0)}static tick(){if(me.scheduledFrame=null,me.animations.size>0){let n=[...me.animations];for(let[t,o]of n){if(me.animations.get(t)!==o)continue;let r=performance.now(),i=o.lastTime===0?0:r-o.lastTime,a=o.animation({deltaTime:i,state:o.state});if(me.animations.get(t)===o){if(a)o.lastTime=r,o.state=a;else if(me.animations.delete(t),me.cancelScheduledFrameIfIdle())return}}if(me.cancelScheduledFrameIfIdle())return;me.scheduleNextFrame()}}static running(n){return me.animations.has(n)}static cancel(n){me.animations.delete(n),me.cancelScheduledFrameIfIdle()}static reset(){me.animations.clear(),me.cancelScheduledFrame()}};v(me,"scheduledFrame",null),v(me,"animations",new Map);var st=me;var Mm=class Mm{constructor(n,t){this.app=n;this.options=t;v(this,"currentTrail");v(this,"pastTrails",[]);v(this,"container");v(this,"trailElement");v(this,"trailAnimation");v(this,"key");this.key=`animated-trail-${Mm.counter++}`,this.trailElement=document.createElementNS(H2,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(H2,"animate"),this.trailAnimation.setAttribute("attributeName","stroke-dashoffset"),this.trailElement.setAttribute("stroke-dasharray","7 7"),this.trailElement.setAttribute("stroke-dashoffset","10"),this.trailAnimation.setAttribute("from","0"),this.trailAnimation.setAttribute("to","-14"),this.trailAnimation.setAttribute("dur","0.3s"),this.trailElement.appendChild(this.trailAnimation))}get hasCurrentTrail(){return!!this.currentTrail}hasLastPoint(n,t){if(this.currentTrail){let o=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[o-1][0]===n&&this.currentTrail.originalPoints[o-1][1]===t}return!1}cleanup(){this.pastTrails=[],this.currentTrail=void 0,this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}start(n){n&&(this.container=n),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),st.running(this.key)||st.start(this.key,()=>this.onFrame()?{keep:!0}:(this.cleanup(),null))}stop(){st.cancel(this.key),this.cleanup()}startPath(n,t){this.currentTrail=new ga(this.options),this.currentTrail.addPoint([n,t,performance.now()]),this.update()}addPointToPath(n,t){this.currentTrail&&(this.currentTrail.addPoint([n,t,performance.now()]),this.update())}endPath(){this.currentTrail&&(this.currentTrail.close(),this.currentTrail.options.keepHead=!1,this.pastTrails.push(this.currentTrail),this.currentTrail=void 0,this.update())}getCurrentTrail(){return this.currentTrail}clearTrails(){this.pastTrails=[],this.currentTrail=void 0,this.update()}update(){this.start(),this.trailAnimation&&(this.trailAnimation.setAttribute("begin","indefinite"),this.trailAnimation.setAttribute("repeatCount","indefinite"))}onFrame(){let n=[];for(let o of this.pastTrails)n.push(this.drawTrail(o,this.app.state));if(this.currentTrail){let o=this.drawTrail(this.currentTrail,this.app.state);n.push(o)}if(this.pastTrails=this.pastTrails.filter(o=>o.getStrokeOutline(o.options.size/this.app.state.zoom.value).length!==0),n.length===0)return this.trailElement.setAttribute("d",""),!1;let t=n.join(" ").trim();return this.trailElement.setAttribute("d",t),this.trailAnimation?(this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this)),this.trailElement.setAttribute("stroke",(this.options.stroke??(()=>"black"))(this))):this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this)),!0}drawTrail(n,t){let o=n.getStrokeOutline(n.options.size/t.zoom.value).map(([i,a])=>{let s=_N({sceneX:i,sceneY:a},t);return[s.x,s.y]}),r=this.trailAnimation?o.slice(0,o.length/2):o;return LN(r,!0)}};v(Mm,"counter",0);var Rn=Mm;var Am=class{constructor(n){this.app=n;v(this,"localTrail");v(this,"collabTrails",new Map);v(this,"container");this.localTrail=new Rn(n,{...this.getTrailOptions(),fill:()=>RN})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:n=>{let r=Math.max(0,1-(performance.now()-n.pressure)/1e3),i=(50-Math.min(50,n.totalLength-n.currentIndex))/50;return Math.min(U2(i),U2(r))}}}startPath(n,t){this.localTrail.startPath(n,t)}addPointToPath(n,t){this.localTrail.addPointToPath(n,t)}endPath(){this.localTrail.endPath()}start(n){this.container=n,this.localTrail.start(n)}stop(){this.localTrail.stop(),this.stopCollabTrails(),this.container=void 0}stopCollabTrails(n){for(let[t,o]of this.collabTrails)n?.get(t)||(o.stop(),this.collabTrails.delete(t))}updateCollabTrails(n){if(this.stopCollabTrails(n),!(!this.container||n.size===0))for(let[t,o]of n.entries()){if(o.isCurrentUser)continue;let r=this.collabTrails.get(t);if(r||(r=new Rn(this.app,{...this.getTrailOptions(),fill:()=>o.pointer?.laserColor||Jr(t,o)}),r.start(this.container),this.collabTrails.set(t,r)),o.pointer&&o.pointer.tool==="laser"){let i=o.button==="down",a=o.button==="up",s=r.hasCurrentTrail;i&&!s&&r.startPath(o.pointer.x,o.pointer.y);let l=!r.hasLastPoint(o.pointer.x,o.pointer.y);i&&l&&r.addPointToPath(o.pointer.x,o.pointer.y),a&&s&&(r.addPointToPath(o.pointer.x,o.pointer.y),r.endPath())}}}};import{DEFAULT_TRANSFORM_HANDLE_SPACING as NN}from"@excalidraw/common";import{pointFrom as Dl,pointRotateRads as Dm}from"@excalidraw/math";var BN=12,mf=16,FN=10,ON=mf+2,zN=.8,pf=e=>NN*2/e,uf=(e,n,t)=>{let o=pf(n);if(t!=="desktop"||mf>(e.height+o*2)*n*zN)return null;let r=BN/n,i=mf/n,a=Dl(e.x+e.width/2,e.y+e.height/2),s=Dm(Dl(a[0]+e.width/2+o+r,a[1]),a,e.angle);return{center:s,start:Dm(Dl(s[0],s[1]-i/2),s,e.angle),end:Dm(Dl(s[0],s[1]+i/2),s,e.angle),hitboxWidth:FN/n,hitboxHeight:ON/n}},W2=(e,n,t,o)=>{let r=uf(n,t,o);if(!r)return!1;let i=Dm(Dl(e.x,e.y),r.center,-n.angle);return Math.abs(i[0]-r.center[0])<=r.hitboxWidth/2&&Math.abs(i[1]-r.center[1])<=r.hitboxHeight/2};import{CODES as hf,KEYS as Ll,CLASSES as gf,POINTER_BUTTON as GN,THEME as HN,isWritableElement as UN,getFontString as V2,getFontFamilyString as Y2,isTestEnv as X2,MIME_TYPES as ff,applyDarkModeFilter as WN,isRTL as VN}from"@excalidraw/common";import{pointFrom as K2,pointRotateRads as YN}from"@excalidraw/math";import{getTextFromElements as XN,originalContainerCache as KN,updateBoundElements as $2,updateOriginalContainerCache as Z2}from"@excalidraw/element";import{LinearElementEditor as $N}from"@excalidraw/element/linearElementEditor";import{bumpVersion as ZN}from"@excalidraw/element";import{getBoundTextElementId as jN,getContainerElement as Ef,getTextElementAngle as qN,redrawTextBoundingBox as JN,getBoundTextMaxHeight as QN,getBoundTextMaxWidth as j2,computeContainerDimensionForBoundText as q2,computeBoundTextPosition as e7,getBoundTextElement as t7}from"@excalidraw/element";import{getTextWidth as n7}from"@excalidraw/element";import{getLineHeightInPx as o7}from"@excalidraw/element";import{getLineWidth as r7}from"@excalidraw/element";import{normalizeText as J2}from"@excalidraw/element";import{wrapText as i7}from"@excalidraw/element";import{getWrappedTextLines as a7}from"@excalidraw/element";import{isArrowElement as Lm,isBoundToContainer as s7,isTextElement as Q2}from"@excalidraw/element";var l7=(e,n,t,o,r,i)=>{let{zoom:a}=o,s=180*t/Math.PI,l=e*(a.value-1)/2,c=n*(a.value-1)/2;return e>r&&a.value!==1&&(l=r*(a.value-1)/2),n>i&&a.value!==1&&(c=i*(a.value-1)/2),`translate(${l}px, ${c}px) scale(${a.value}) rotate(${s}deg)`},c7=(e,n)=>{let t=e.lastIndexOf(`
12
12
  `,Math.max(0,n-1))+1,o=e.indexOf(`
13
- `,n),r=e.slice(t,o===-1?e.length:o);return VN(r)?"rtl":"ltr"},d7=e=>{let n=[0],t=0;for(let o of Array.from(e))t+=o.length,n.push(t);return n},m7=({text:e,font:n,lineHeightPx:t,direction:o,targetX:r})=>{if(!e||!document.body||typeof document.createRange!="function")return null;let i=d7(e),a=document.createElement("div"),s=document.createTextNode(e),l=document.createRange(),c=[];a.dir=o,Object.assign(a.style,{position:"fixed",top:"0",left:"0",margin:0,padding:0,border:0,opacity:"0",pointerEvents:"none",whiteSpace:"pre",font:n,lineHeight:`${t}px`}),a.append(s),document.body.append(a);try{for(let u of i){l.setStart(s,u),l.setEnd(s,u);let E=l.getBoundingClientRect();if(!Number.isFinite(E.left))return null;c.push(E.left)}}catch{return null}finally{a.remove()}let d=Math.min(...c),m=i[0],p=1/0;for(let u=0;u<i.length;u++){let E=Math.abs(c[u]-d-r);E<p&&(p=E,m=i[u])}return m},j2=({onChange:e,onSubmit:n,getViewportCoords:t,element:o,canvas:r,excalidrawContainer:i,app:a,autoSelect:s=!0,initialCaretSceneCoords:l=null})=>{let c=null,d=(F,W)=>{if(!W.style.fontFamily||!W.style.fontSize)return!1;let le=W.style.fontFamily.replace(/"/g,"");return H2({fontFamily:F.fontFamily})!==le||`${F.fontSize}px`!==W.style.fontSize},m=a.state.theme,p=()=>{m=a.state.theme;let F=a.state,W=a.scene.getElement(o.id);if(!W)return;let{textAlign:le,verticalAlign:we}=W,de=a.scene.getNonDeletedElementsMap();if(W&&Z2(W)){let he=W.x,ve=W.y,ae=mf(W,a.scene.getNonDeletedElementsMap()),fe=W.width,rt=W.height,Ge=W.width,Pe=W.height;if(ae&&W.containerId){if(Cm(ae)){let nn=$N.getBoundTextElementPosition(ae,W,de);he=nn.x,ve=nn.y}let $t=d(W,u),Sn;if($t?Sn=Y2(ae.id,ae.height):(Sn=KN[ae.id],Sn||(Sn=Y2(ae.id,ae.height))),Ge=X2(ae,W),Pe=QN(ae,W),!Cm(ae)&&rt>Pe){let nn=K2(rt,ae.type);a.scene.mutateElement(ae,{height:nn}),V2(ae,a.scene);return}else if(!Cm(ae)&&ae.height>Sn.height&&rt<Pe){let nn=K2(rt,ae.type);a.scene.mutateElement(ae,{height:nn}),V2(ae,a.scene)}else{let{x:nn,y:yi}=e7(ae,W,de);he=nn,ve=yi}}let[Wn,zo]=t(he,ve);ae?fe+=.5:(Ge=(F.width-8-Wn)/F.zoom.value,fe=Math.min(fe,Ge)),rt*=1.05;let xi=G2(W),re=qN(W,ae),lt=(F.height-zo)/F.zoom.value;Object.assign(u.style,{font:xi,lineHeight:W.lineHeight,width:`${fe}px`,height:`${rt}px`,left:`${Wn}px`,top:`${zo}px`,transform:l7(fe,rt,re,F,Ge,lt),textAlign:le,verticalAlign:we,color:WN(W.strokeColor,F.theme===HN.DARK),opacity:W.opacity/100,maxHeight:`${lt}px`}),c={angle:re,font:xi,height:W.height,lineHeightPx:o7(W.fontSize,W.lineHeight),textAlign:le,width:W.width,x:he,y:ve},u.scrollTop=0,U2()&&(u.style.fontFamily=H2(W)),a.scene.mutateElement(W,{x:he,y:ve})}},u=document.createElement("textarea");u.dir="auto",u.tabIndex=0,u.dataset.type="wysiwyg",u.wrap="off",u.classList.add("excalidraw-wysiwyg");let E="pre",g="normal";(s7(o)||!o.autoResize)&&(E="pre-wrap",g="break-word"),Object.assign(u.style,{position:"absolute",display:"inline-block",minHeight:"1em",backfaceVisibility:"hidden",margin:0,padding:0,border:0,outline:0,resize:"none",background:"transparent",overflow:"hidden",zIndex:"var(--zIndex-wysiwyg)",wordBreak:g,whiteSpace:E,overflowWrap:"break-word",boxSizing:"content-box"}),u.value=o.originalText,p();let b=()=>{if(!l||!c)return null;let F=c,W=W2(F.x+F.width/2,F.y+F.height/2),[le,we]=YN(W2(l.x,l.y),W,-F.angle),de=le-F.x,he=we-F.y,ve=a7(u.value,F.font,E==="pre-wrap"?F.width:1/0),ae=Math.max(0,Math.min(ve.length-1,Math.floor(he/F.lineHeightPx))),fe=ve[ae],rt=c7(u.value,fe.start),Ge=r7(fe.text,F.font),Pe=F.textAlign==="center"?(F.width-Ge)/2:F.textAlign==="right"?F.width-Ge:0,Wn=de-Pe;if(!fe.text)return fe.start;let zo=m7({text:fe.text,font:F.font,lineHeightPx:F.lineHeightPx,direction:rt,targetX:Wn});return fe.start+(zo||0)},y=(()=>{let F=b();return F===null?null:{start:F,end:F}})();e&&(u.onpaste=async F=>{let W=fw(F),le=null;if(W.has(df.excalidrawClipboard)||W.has(df.excalidraw)){F.preventDefault(),le=await Wr(F);try{let ae=await Vd(le);if(ae.elements){let fe=XN(ae.elements);if(fe){let{selectionStart:rt,selectionEnd:Ge,value:Pe}=u;u.value=Pe.slice(0,rt)+fe+Pe.slice(Ge);let Wn=rt+fe.length;u.selectionStart=u.selectionEnd=Wn,u.dispatchEvent(new Event("input"))}}return}catch{console.warn("failed to parse excalidraw clipboard data")}}le=le||await Wr(F);let we=le.findByType(df.text);if(!we)return;let de=$2(we.value);if(!de)return;let he=mf(o,a.scene.getNonDeletedElementsMap()),ve=G2({fontSize:a.state.currentItemFontSize,fontFamily:a.state.currentItemFontFamily});if(he){let ae=t7(he,a.scene.getNonDeletedElementsMap()),fe=i7(`${u.value}${de}`,ve,X2(he,ae)),rt=n7(fe,ve);u.style.width=`${rt}px`}},u.oninput=()=>{let F=$2(u.value);if(u.value!==F){let W=u.selectionStart;u.value=F,u.selectionStart=W,u.selectionEnd=W}e(u.value)}),u.onkeydown=F=>{if(!F.shiftKey&&Sd.keyTest(F))F.preventDefault(),a.actionManager.executeAction(Sd),p();else if(!F.shiftKey&&Cd.keyTest(F))F.preventDefault(),a.actionManager.executeAction(Cd),p();else if(!F.shiftKey&&Pd.keyTest(F))F.preventDefault(),a.actionManager.executeAction(Pd),p();else if(_h.keyTest(F))a.actionManager.executeAction(_h);else if(Rh.keyTest(F))a.actionManager.executeAction(Rh);else if(F.key===Cl.ESCAPE)F.preventDefault(),D=!0,_();else if(Xr.keyTest(F))F.preventDefault(),_(),a.actionManager.executeAction(Xr);else if(F.key===Cl.ENTER&&F[Cl.CTRL_OR_CMD]){if(F.preventDefault(),F.isComposing||F.keyCode===229)return;D=!0,_()}else if(F.key===Cl.TAB||F[Cl.CTRL_OR_CMD]&&(F.code===lf.BRACKET_LEFT||F.code===lf.BRACKET_RIGHT)){if(F.preventDefault(),F.isComposing)return;F.shiftKey||F.code===lf.BRACKET_LEFT?C():T(),u.dispatchEvent(new Event("input"))}};let w=4,x=" ".repeat(w),I=new RegExp(`^ {1,${w}}`),T=()=>{let{selectionStart:F,selectionEnd:W}=u,le=P(),we=u.value;le.forEach(de=>{let he=we.slice(0,de),ve=we.slice(de);we=`${he}${x}${ve}`}),u.value=we,u.selectionStart=F+w,u.selectionEnd=W+w*le.length},C=()=>{let{selectionStart:F,selectionEnd:W}=u,le=P(),we=[],de=u.value;le.forEach(he=>{let ve=de.slice(he,he+w).match(I);if(ve){let ae=de.slice(0,he),fe=de.slice(he+ve[0].length);de=`${ae}${fe}`,we.push(he)}}),u.value=de,we.length&&(F>we[we.length-1]?u.selectionStart=Math.max(F-w,we[we.length-1]):u.selectionStart=F,u.selectionEnd=Math.max(u.selectionStart,W-w*we.length))},P=()=>{let{selectionStart:F,selectionEnd:W,value:le}=u,we=le.slice(0,F).match(/[^\n]*$/)[0].length;return F=F-we,le.slice(F,W).split(`
14
- `).reduce((he,ve,ae,fe)=>he.concat(ae?he[ae-1]+fe[ae-1].length+1:F),[]).reverse()},A=F=>{F.target instanceof HTMLCanvasElement&&(F.preventDefault(),F.stopPropagation())},D=!1,_=()=>{if(G)return;G=!0,k();let F=a.scene.getElement(o.id);if(!F)return;let W=mf(F,a.scene.getNonDeletedElementsMap());if(W){if(u.value.trim()){let le=jN(W);!le||le!==o.id?a.scene.mutateElement(W,{boundElements:(W.boundElements||[]).concat({type:"text",id:o.id})}):Cm(W)&&ZN(W)}else a.scene.mutateElement(W,{boundElements:W.boundElements?.filter(le=>!Z2(le))});JN(F,W,a.scene)}n({viaKeyboard:D,nextOriginalText:u.value})},k=()=>{u.onblur=null,u.oninput=null,u.onkeydown=null,te&&te.disconnect(),window.removeEventListener("resize",p),window.removeEventListener("wheel",A,!0),window.removeEventListener("pointerdown",V),window.removeEventListener("pointerup",L),window.removeEventListener("blur",_),window.removeEventListener("beforeunload",_),U(),z(),K(),u.remove()},L=F=>{window.removeEventListener("pointerup",L);let W=F?.target,le=W instanceof HTMLElement&&W.classList.contains("properties-trigger"),we=(W instanceof HTMLElement||W instanceof SVGElement)&&!!W.closest(".properties-content"),de=(W instanceof HTMLElement||W instanceof SVGElement)&&(!!W.closest(`.${cf.SHAPE_ACTIONS_MENU}`)||!!W.closest(".compact-shape-actions-island"));setTimeout(()=>{de||le||we||(u.onblur=_,u.focus(),y&&(u.setSelectionRange(y.start,y.end),y=null))})},B=()=>{u.onblur=null,window.addEventListener("pointerup",L),window.addEventListener("blur",_)},V=F=>{let W=F?.target;if(F.button===GN.WHEEL){W instanceof HTMLTextAreaElement&&(F.preventDefault(),a.handleCanvasPanUsingWheelOrSpaceDrag(F)),B();return}let le=W instanceof HTMLElement&&W.classList.contains("properties-trigger"),we=(W instanceof HTMLElement||W instanceof SVGElement)&&!!W.closest(".properties-content");(F.target instanceof HTMLElement||F.target instanceof SVGElement)&&(F.target.closest(`.${cf.SHAPE_ACTIONS_MENU}, .${cf.ZOOM_ACTIONS}`)||F.target.closest(".compact-shape-actions-island"))&&!UN(F.target)||le||we?B():F.target instanceof HTMLCanvasElement&&!U2()&&requestAnimationFrame(()=>{_()})},z=a.onChangeEmitter.on(F=>{a.state.theme!==m&&p()}),U=a.scene.onUpdate(()=>{p(),!!document.activeElement?.closest(".properties-content")||u.focus()}),K=a.onScrollChangeEmitter.on(()=>{p()}),G=!1;s&&!y&&u.select(),L();let te=null;return r&&"ResizeObserver"in window?(te=new window.ResizeObserver(()=>{p()}),te.observe(r)):window.addEventListener("resize",p),u.onpointerdown=F=>F.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",V,{capture:!0})}),window.addEventListener("beforeunload",_),i?.querySelector(".excalidraw-textEditorContainer").appendChild(u),_};import{getGlobalCSSVariable as Pm}from"@excalidraw/common";import{getCommonBounds as p7}from"@excalidraw/element";var Po=4,gn=6,q2="rgba(0,0,0,0.3)",J2=(e,n,t,o)=>{if(!e.size)return{horizontal:null,vertical:null};let[r,i,a,s]=p7(e),l=n/o.zoom.value,c=t/o.zoom.value,d={top:parseInt(Pm("sat"))||0,bottom:parseInt(Pm("sab"))||0,left:parseInt(Pm("sal"))||0,right:parseInt(Pm("sar"))||0},m=Kn().rtl,p=-o.scrollX+d.left,u=-o.scrollY+d.top,E=p+l-d.right,g=u+c-d.bottom,b=Math.min(r,p),y=Math.min(i,u),w=Math.max(a,E),x=Math.max(s,g),I=a-r,T=s-i,C=w-b,P=x-y,A=Math.max(Po*2,d.left+d.right)+gn*2,D=n*(l/C)-A,_=Math.max(Po*2,d.top+d.bottom)+gn*2,k=t*(c/P)-_,L=C>I?C*o.zoom.value/(D+A):n/(D+A),B=P>T?P*o.zoom.value/(k+_):t/(k+_);return{horizontal:p===b&&E===w?null:{x:Math.max(d.left,Po)+gn+(p-b)/C*n,y:t-gn-Math.max(Po,d.bottom),width:D,height:gn,deltaMultiplier:L},vertical:u===y&&g===x?null:{x:m?Math.max(d.left,Po):n-gn-Math.max(d.right,Po),y:Math.max(d.top,Po)+gn+(u-y)/P*t,width:gn,height:k,deltaMultiplier:B}}},pf=(e,n,t)=>{let[o,r]=[e.horizontal,e.vertical].map(a=>a!=null&&a.x<=n&&n<=a.x+a.width&&a.y<=t&&t<=a.y+a.height);return{isOverEither:o||r,isOverHorizontal:o,isOverVertical:r}};import{pointFrom as D7}from"@excalidraw/math";import{getElementLineSegments as L7}from"@excalidraw/element";import{LinearElementEditor as _7}from"@excalidraw/element/linearElementEditor";import{isFrameLikeElement as R7,isLinearElement as N7}from"@excalidraw/element";import{getFrameChildren as B7}from"@excalidraw/element";import{selectGroupsForSelectedElements as F7}from"@excalidraw/element";import{arrayToMap as O7,easeOut as iI,isShallowEqual as z7}from"@excalidraw/common";import{simplify as u7}from"points-on-curve";import{polygonFromPoints as h7,lineSegment as Mm,pointFrom as Sa,pointOnLineSegment as g7,polygonIncludesPointNonZero as f7,PRECISION as km}from"@excalidraw/math";import{boundsContainBounds as eI,computeBoundTextPosition as E7,doBoundsIntersect as b7,elementOverlapsWithFrame as x7,getBoundTextElement as tI,getContainingFrame as y7,getElementBounds as nI,intersectElementWithLineSegment as w7,isBoundToContainer as oI,pointInsideBoundsInclusive as v7}from"@excalidraw/element";var rI=e=>{let{lassoPath:n,elements:t,elementsMap:o,elementsSegments:r,intersectedElements:i,enclosedElements:a,simplifyDistance:s,mode:l="contain"}=e,c=n;s&&(c=u7(n,s));let d=t.filter(g=>!g.locked&&!oI(g));a.clear(),i.clear();let m=n.reduce((g,b)=>[Math.min(g[0],b[0]),Math.min(g[1],b[1]),Math.max(g[2],b[0]),Math.max(g[3],b[1])],[1/0,1/0,-1/0,-1/0]),p=h7(c),u=[m[0]-km,m[1]-km,m[2]+km,m[3]+km];for(let g of d){let b=nI(g,o),y=I7(g,b,o),w=T7(b,y);if(b7(m,w)&&!i.has(g.id)&&!a.has(g.id)){if(l==="contain"&&!eI(u,w))continue;let x=S7(g,o,r,y),I=k7(p,x,w,l);l==="contain"?I&&!Q2(c,g,o,y)&&a.add(g.id):I?a.add(g.id):Q2(c,g,o,y)&&i.add(g.id)}}return{selectedElementIds:l==="contain"?P7([...a],o):[...i,...a]}},I7=(e,n,t)=>{let o=y7(e,t);if(!o)return null;let r=nI(o,t);return eI(r,n)?null:x7(e,o,t)?r:null},T7=(e,n)=>n?[Math.max(e[0],n[0]),Math.max(e[1],n[1]),Math.min(e[2],n[2]),Math.min(e[3],n[3])]:e,S7=(e,n,t,o)=>{let r=t.get(e.id)??[],i=tI(e,n),a=i?t.get(i.id):null,s=a?.length?[...r,...a]:r;return o?C7(s,o):s},C7=(e,n)=>{let[t,o,r,i]=n,a=[];for(let[[s,l],[c,d]]of e){let m=c-s,p=d-l,u=0,E=1,g=!0;for(let[b,y]of[[-m,s-t],[m,r-s],[-p,l-o],[p,i-l]]){if(b===0){if(y<0){g=!1;break}continue}let w=y/b;if(b<0){if(w>E){g=!1;break}u=Math.max(u,w)}else{if(w<u){g=!1;break}E=Math.min(E,w)}}g&&a.push(Mm(Sa(s+u*m,l+u*p),Sa(s+E*m,l+E*p)))}return a},P7=(e,n)=>{if(!e.some(r=>n.get(r)?.groupIds.length))return e;let t=new Map;for(let r of n.values()){let i=r.groupIds.at(-1);if(!i||r.locked||oI(r))continue;let a=t.get(i);a?a.push(r.id):t.set(i,[r.id])}if(!t.size)return e;let o=new Set(e);return e.filter(r=>{let i=n.get(r)?.groupIds.at(-1),a=i?t.get(i):null;return!a||a.every(s=>o.has(s))})},k7=(e,n,t,o)=>{let r=o==="contain"?"every":"some",i=a=>f7(a,e)||o==="contain"&&A7(a,e);return n.length===0?M7(t)[r](i):n[r](a=>a[r](i))},M7=([e,n,t,o])=>[Sa(e,n),Sa(t,n),Sa(t,o),Sa(e,o)],A7=(e,n)=>n.some((t,o)=>o>0&&g7(e,Mm(n[o-1],t))),Q2=(e,n,t,o)=>{let r=e.slice(1).map((s,l)=>Mm(e[l],s)).concat([Mm(e[e.length-1],e[0])]),i=tI(n,t),a=(s,l)=>{let c=w7(s,t,l,0,!o);return o?c.some(d=>v7(d,o)):c.length>0};return r.some(s=>a(n,s)||!!i&&a({...i,...E7(n,i,t)},s))};var Am=class extends Rn{constructor(t){super(t,{animateTrail:!0,streamline:.4,sizeMapping:o=>{let a=Math.max(0,1-(performance.now()-o.pressure)/(1/0)),s=(5e3-Math.min(5e3,o.totalLength-o.currentIndex))/5e3;return Math.min(iI(s),iI(a))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});v(this,"intersectedElements",new Set);v(this,"enclosedElements",new Set);v(this,"elementsSegments",null);v(this,"canvasTranslate",null);v(this,"keepPreviousSelection",!1);v(this,"selectElementsFromIds",t=>{this.app.setState(o=>{let r=t.reduce((l,c)=>(l[c]=!0,l),{});if(this.keepPreviousSelection)for(let l of Object.keys(o.selectedElementIds))r[l]=!0;for(let[l]of Object.entries(r)){let c=this.app.scene.getNonDeletedElement(l);if(c&&R7(c)){let d=B7(this.app.scene.getNonDeletedElementsMap(),c.id);for(let m of d)delete r[m.id]}}let i=F7({editingGroupId:o.editingGroupId,selectedElementIds:r},this.app.scene.getNonDeletedElements(),o,this.app),a=[...Object.keys(i.selectedElementIds)],s=[...Object.keys(i.selectedGroupIds)];return{selectedElementIds:i.selectedElementIds,selectedGroupIds:i.selectedGroupIds,selectedLinearElement:a.length===1&&!s.length&&N7(this.app.scene.getNonDeletedElement(a[0]))?new _7(this.app.scene.getNonDeletedElement(a[0]),this.app.scene.getNonDeletedElementsMap()):null}})});v(this,"addPointToPath",(t,o,r=!1)=>{super.addPointToPath(t,o),this.keepPreviousSelection=r,this.updateSelection()});v(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(r=>D7(r[0],r[1])),o={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!z7(o,this.canvasTranslate??{})){this.canvasTranslate=o,this.elementsSegments=new Map;let r=O7(this.app.visibleElements);for(let i of this.app.visibleElements){let a=L7(i,r);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:r}=rI({lassoPath:t,elements:this.app.visibleElements,elementsMap:this.app.scene.getNonDeletedElementsMap(),elementsSegments:this.elementsSegments,intersectedElements:this.intersectedElements,enclosedElements:this.enclosedElements,simplifyDistance:5/this.app.state.zoom.value,mode:this.app.state.boxSelectionMode});this.selectElementsFromIds(r)}})}startPath(t,o,r=!1){this.endPath(),super.startPath(t,o),this.intersectedElements.clear(),this.enclosedElements.clear(),this.keepPreviousSelection=r,this.keepPreviousSelection||this.app.setState({selectedElementIds:{},selectedGroupIds:{},selectedLinearElement:null})}endPath(){super.endPath(),super.clearTrails(),this.intersectedElements.clear(),this.enclosedElements.clear(),this.elementsSegments=null}};import{arrayToMap as G7,easeOut as aI,THEME as H7}from"@excalidraw/common";import{computeBoundTextPosition as U7,doBoundsIntersect as W7,getBoundTextElement as V7,getElementBounds as Y7,getElementLineSegments as X7,getFreedrawOutlineAsSegments as K7,getFreedrawOutlinePoints as $7,intersectElementWithLineSegment as sI,isArrowElement as Z7,isFreeDrawElement as lI,isLineElement as j7,isPointInElement as q7}from"@excalidraw/element";import{lineSegment as J7,lineSegmentsDistance as cI,pointFrom as gI,polygon as Q7,polygonIncludesPointNonZero as eB}from"@excalidraw/math";import{getElementsInGroup as dI}from"@excalidraw/element";import{shouldTestInside as tB}from"@excalidraw/element";import{hasBoundTextElement as mI,isBoundToContainer as pI}from"@excalidraw/element";import{getBoundTextElementId as uI}from"@excalidraw/element";var Dm=class extends Rn{constructor(t){super(t,{streamline:.2,size:5,keepHead:!0,sizeMapping:o=>{let a=Math.max(0,1-(performance.now()-o.pressure)/200),s=(10-Math.min(10,o.totalLength-o.currentIndex))/10;return Math.min(aI(s),aI(a))},fill:()=>t.props.renderCustomizations?.traceColor??(t.state.theme===H7.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)")});v(this,"elementsToErase",new Set);v(this,"groupsToErase",new Set)}startPath(t,o){this.endPath(),super.startPath(t,o),this.elementsToErase.clear()}addPointToPath(t,o,r=!1){return super.addPointToPath(t,o),this.updateElementsToBeErased(r)}updateElementsToBeErased(t){let o=super.getCurrentTrail()?.originalPoints?.map(s=>gI(s[0],s[1]))||[];if(o.length<2)return[];let r=J7(o[o.length-1],o[o.length-2]),i=this.app.visibleElements.filter(s=>!s.locked),a=G7(i);for(let s of i)if(t&&this.elementsToErase.has(s.id)){if(hI(r,s,a,this.app.state.zoom.value)){let c=s.groupIds.at(-1);if(this.groupsToErase.has(c)){let d=dI(this.app.scene.getNonDeletedElementsMap(),c);for(let m of d)this.elementsToErase.delete(m.id);this.groupsToErase.delete(c)}if(pI(s)&&this.elementsToErase.delete(s.containerId),mI(s)){let d=uI(s);d&&this.elementsToErase.delete(d)}this.elementsToErase.delete(s.id)}}else if(!t&&!this.elementsToErase.has(s.id)&&hI(r,s,a,this.app.state.zoom.value)){let c=s.groupIds.at(-1);if(!this.groupsToErase.has(c)){let d=dI(this.app.scene.getNonDeletedElementsMap(),c);for(let m of d)this.elementsToErase.add(m.id);this.groupsToErase.add(c)}if(mI(s)){let d=uI(s);d&&this.elementsToErase.add(d)}pI(s)&&this.elementsToErase.add(s.containerId),this.elementsToErase.add(s.id)}return Array.from(this.elementsToErase)}endPath(){super.endPath(),super.clearTrails(),this.elementsToErase.clear(),this.groupsToErase.clear()}},hI=(e,n,t,o)=>{let r=e[1],i=lI(n)?15:n.strokeWidth/2,a=[Math.min(e[0][0],e[1][0])-i,Math.min(e[0][1],e[1][1])-i,Math.max(e[0][0],e[1][0])+i,Math.max(e[0][1],e[1][1])+i],s=Y7(n,t),l=[s[0]-i,s[1]-i,s[2]+i,s[3]+i];if(!W7(a,l))return!1;if(tB(n)&&q7(r,n,t))return!0;if(lI(n)){let d=$7(n),m=K7(n,d,t),p=Math.max(2.25,5/o);for(let E of m)if(cI(E,e)<=p)return!0;let u=Q7(...d.map(([E,g])=>gI(n.x+E,n.y+g)));return!!eB(e[0],u)}let c=V7(n,t);if(Z7(n)||j7(n)&&!n.polygon){let d=Math.max(n.strokeWidth,n.strokeWidth*2/o),m=X7(n,t);for(let p of m)if(cI(p,e)<=d)return!0;return!1}return sI(n,t,e,0,!0).length>0||!!c&&sI({...c,...U7(n,c,t)},t,e,0,!0).length>0};import{isDevEnv as EB}from"@excalidraw/common";import{newElement as bB}from"@excalidraw/element";import{COLOR_PALETTE as nB,DEFAULT_FONT_FAMILY as oB,DEFAULT_FONT_SIZE as rB,VERTICAL_ALIGN as iB}from"@excalidraw/common";var fI=44,EI=22,bI=66,xI=48,Pl=14,yI=304,wI=320,uf=5.87,vI=28,II=4,TI=2,hf=10,SI=10,CI=8,oo=12,Ca=256,ni=10,gf=4,Pa=oo*2,ff=oo*2,PI=100,kI=140,kl=.35,MI=oo/2,dr=20,Lm=oo*2,Ef=oo,Ne={fillStyle:"hachure",fontFamily:oB,fontSize:rB,opacity:100,roughness:1,strokeColor:nB.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:iB.MIDDLE,locked:!1};import{pointFrom as ka}from"@excalidraw/math";import{COLOR_PALETTE as RI,DEFAULT_CHART_COLOR_INDEX as aB,FONT_FAMILY as yf,FONT_SIZES as _m,ROUNDNESS as AI,DEFAULT_FONT_SIZE as sB,getAllColorsSpecificShade as lB,getFontString as wf,getLineHeight as vf,ROUGHNESS as DI}from"@excalidraw/common";import{getApproxMinLineWidth as If,measureText as mr,newElement as xf,newLinearElement as bf,newTextElement as Ma,wrapText as NI}from"@excalidraw/element";var oi=lB(aB),cB=e=>e.labels?.length??e.series[0]?.values.length??0,Aa=(e,n)=>{if(!e)return!1;let t=cB(e);return t<2?!1:n==="radar"?t>=3:!0},LI=(e,n)=>{let t=n<=1?0:Math.min(bI,(n-1)*EI);return e+t},Rm=(e,n)=>{if(e==="line"){let o=LI(xI,n);return{slotWidth:o,gap:Pl,chartHeight:wI,xLabelMaxWidth:o+Pl*3+hf}}let t=LI(fI,n);return{slotWidth:t,gap:Pl,chartHeight:yI,xLabelMaxWidth:t+Pl*3+hf}},Da=(e,n)=>{let t=(n.slotWidth+n.gap)*e.series[0].values.length+n.gap,o=n.chartHeight+n.gap*2;return{chartWidth:t,chartHeight:o}},BI=()=>{let e=Ca+ff*2,n=Ca+ff*2;return{chartWidth:e,chartHeight:n}},dB=(e,n,t)=>{let o=Math.abs(e-n);return Math.min(o,t-o)},La=(e,n)=>{if(e<=0||oi.length===0)return[];let t=oi.length,o=(n%t+t)%t,r=[o],i=Math.min(e,t),a=new Set(Array.from({length:t},(s,l)=>l).filter(s=>s!==o));for(;r.length<i;){let s=-1,l=-1,c=-1;for(let d of a){let m=r.map(E=>dB(d,E,t)),p=Math.min(...m),u=m.reduce((E,g)=>E+g,0)/m.length;(p>l||p===l&&u>c)&&(s=d,l=p,c=u)}r.push(s),a.delete(s)}return Array.from({length:e},(s,l)=>oi[r[l%r.length]])},_a=e=>{if(oi.length===0)return 0;if(typeof e!="number"||!Number.isFinite(e))return Math.floor(Math.random()*oi.length);let n=e.toString(),t=0;for(let o=0;o<n.length;o++)t=t*31+n.charCodeAt(o)|0;return Math.abs(t)%oi.length},Ra=e=>oi[e],FI=(e,n)=>{let t=e.flatMap(s=>s.values.map(l=>Math.max(0,l))),o=t.filter(s=>s>0),r=Math.max(1,...t),i=o.length>0?Math.min(...o):1,a=e.length===1&&i>0&&r/i>=PI;return{renderSteps:!1,normalize:(s,l)=>{let c=Math.max(0,s);return a?Math.log10(c+1)/Math.log10(r+1):c/r}}},mB=e=>/\s/.test(e.trim()),Nm=(e,n,t)=>mB(e)?NI(e,n,t):e,OI=(e,n,t,o,r,i)=>{let a=yf.Excalifont,s=_m.sm,l=vf(a),c=wf({fontFamily:a,fontSize:s}),d=Math.min(kI,r*(e.length>8?.56:.72)),m=If(c,l),p=e.map((g,b)=>{let y=n[b],w=Math.max(0,...g.trim().split(/\s+/).filter(Boolean).map(z=>mr(z,c,l).width)),x=Math.max(m,d,w),I=Nm(g,c,x),T=mr(I,c,l),C=Math.cos(y),P=Math.sin(y),A=C>kl?"left":C<-kl?"right":"center",D=A==="center"?T.width/2:0,_=Math.abs(C)*D+Math.abs(P)*(T.height/2),k=Pa+_+MI,L=t+C*(r+k),B=o+P*(r+k),V=P>kl?oo/3:P<-kl?-oo/3:0;return Ma({backgroundColor:i,...Ne,text:I,originalText:g,x:L,y:B+V,fontFamily:a,fontSize:s,lineHeight:l,textAlign:A,verticalAlign:"middle"})}),u=Math.min(...p.map(g=>g.y)),E=Math.max(...p.map(g=>g.y+g.height));return{axisLabels:p,axisLabelTopY:u,axisLabelBottomY:E}},Na=(e,n,t,o,r,i)=>{if(e.length<=1)return[];let a=yf["Lilita One"],s=_m.lg,l=vf(a),c=wf({fontFamily:a,fontSize:s}),d=e.map((I,T)=>{let C=I.title?.trim()||`Series ${T+1}`,P=Nm(C,c,Ca),A=mr(P,c,l),D=dr+Ef+A.width;return{label:C,displayLabel:P,color:n[T],width:D,height:A.height}}),m=Math.max(dr/2,...d.map(I=>I.height/2)),p=Math.max(r,o+m+Pa),u=Lm,E=dr*.6,g=d.reduce((I,T)=>I+T.width,0)+Lm*Math.max(0,d.length-1),b=g+u*2,y=m*2+E*2,w=[];w.push(xf({...Ne,backgroundColor:"transparent",type:"rectangle",fillStyle:"solid",strokeColor:RI.black,x:t-b/2,y:p-y/2,width:b,height:y,roughness:DI.architect,roundness:{type:AI.PROPORTIONAL_RADIUS}}));let x=t-g/2;return d.forEach(I=>{w.push(xf({...Ne,backgroundColor:I.color,type:"rectangle",x,y:p-dr/2,width:dr,height:dr,fillStyle:"solid",strokeColor:I.color,roughness:DI.architect,roundness:{type:AI.PROPORTIONAL_RADIUS}})),w.push(Ma({...Ne,text:I.displayLabel,originalText:I.label,autoResize:!1,x:x+dr+Ef,y:p,fontFamily:a,fontSize:s,lineHeight:l,textAlign:"left",verticalAlign:"middle"})),x+=I.width+Lm}),w},pB=(e,n,t,o)=>{if(mr(e,t,o).width<=n)return e;let r=e.length;for(;r>1;){let i=`${e.slice(0,r)}...`;if(mr(i,t,o).width<=n)return i;r--}return e[0]?`${e[0]}...`:e},uB=(e,n,t,o)=>{if(mr(e,t,o).width<=n)return{wrapped:!1,text:e};let r=e.trim().split(/\s+/).filter(Boolean);return r.length>1&&!r.some(a=>mr(a,t,o).width>n)&&n>=If(t,o)?{wrapped:!0,text:NI(e,t,n)}:{wrapped:!1,text:pB(e,n,t,o)}},zI=(e,n,t)=>{let o=Math.abs(Math.cos(t)),r=Math.abs(Math.sin(t));return{width:e*o+n*r,height:e*r+n*o}},_I=e=>e.includes("..."),hB=(e,n,t,o,r)=>{let i=Math.max(vI,Math.ceil(If(o,r))),a=Math.max(i,Math.floor(n)),s=[];for(let u=a;u>=i;u-=4)s.push(u);s[s.length-1]!==i&&s.push(i);let l=u=>{let E=_I(u.text),g=u.text.replace(/\.\.\./g,"").replace(/\n/g,"").length,b=u.text.split(`
15
- `).length;return{ellipsified:E,visibleChars:g,lineCount:b}},c=(u,E)=>{let g=l(u),b=l(E);return g.ellipsified!==b.ellipsified?!g.ellipsified:g.visibleChars!==b.visibleChars?g.visibleChars>b.visibleChars:g.lineCount!==b.lineCount?g.lineCount<b.lineCount:u.rotatedHeight<E.rotatedHeight},d=null,m=null,p=null;for(let u of s){let{wrapped:E,text:g}=uB(e,u,o,r),b=mr(g,o,r),y=zI(b.width,b.height,uf),w={originalText:e,text:g,metrics:b,rotatedWidth:y.width,rotatedHeight:y.height,wrapped:E},x=y.width-t;if(x<=0){(!d||c(w,d))&&(d=w);continue}(!m||x<m.overflow||x===m.overflow&&c(w,m.spec))&&(m={overflow:x,spec:w}),!_I(w.text)&&(!p||x<p.overflow||x===p.overflow&&c(w,p.spec))&&(p={overflow:x,spec:w})}return d||(p&&m&&p.overflow<=m.overflow+CI?p.spec:m.spec)},Bm=e=>{if(e.type!=="text")return e.y+e.height;let n=zI(e.width,e.height,e.angle);return e.y+e.height/2+n.height/2},Ml=(e,n,t,o,r)=>{let i=Ne.fontFamily,a=_m.sm,s=vf(i),l=wf({fontFamily:i,fontSize:a}),c=Math.max(1,r.slotWidth+r.gap-II*2+SI),d=t;return e.labels?.map((m,p)=>{let u=hB(m,r.xLabelMaxWidth,c,l,s),E=n+p*(r.slotWidth+r.gap)+r.gap+r.slotWidth/2,g=d+TI+(u.rotatedHeight-u.metrics.height)/2;return Ma({backgroundColor:o,...Ne,text:u.text,originalText:u.wrapped?m:u.text,autoResize:!u.wrapped,x:E,y:g,angle:uf,fontSize:a,lineHeight:s,textAlign:"center",verticalAlign:"top"})})||[]},gB=(e,n,t,o,r,i=Math.max(...e.series[0].values))=>{let a=Ma({backgroundColor:o,...Ne,x:n-r.gap,y:t-r.gap,text:"0",textAlign:"right"}),s=Ma({backgroundColor:o,...Ne,x:n-r.gap,y:t-r.chartHeight-a.height/2,text:i.toLocaleString(),textAlign:"right"});return[a,s]},fB=(e,n,t,o,r)=>{let{chartWidth:i,chartHeight:a}=Da(e,r),s=bf({backgroundColor:o,...Ne,type:"line",x:n,y:t,width:i,points:[ka(0,0),ka(i,0)]}),l=bf({backgroundColor:o,...Ne,type:"line",x:n,y:t,height:a,points:[ka(0,0),ka(0,-a)]}),c=bf({backgroundColor:o,...Ne,type:"line",x:n,y:t-r.chartHeight-r.gap,strokeStyle:"dotted",width:i,opacity:ni,points:[ka(0,0),ka(i,0)]});return[s,l,c]},Fm=(e,n,t,o,r,i=Math.max(...e.series[0].values),a)=>{let{chartWidth:s,chartHeight:l}=Da(e,r),c=e.title?Ma({backgroundColor:o,...Ne,text:e.title,x:n+s/2,y:t-r.chartHeight-r.gap*2-sB,roundness:null,textAlign:"center",fontSize:_m.xl,fontFamily:yf["Lilita One"]}):null,d=a?xf({backgroundColor:o,...Ne,type:"rectangle",x:n,y:t-l,width:s,height:l,strokeColor:RI.black,fillStyle:"solid",opacity:6}):null;return[...d?[d]:[],...c?[c]:[],...Ml(e,n,t,o,r),...gB(e,n,t,o,r,i),...fB(e,n,t,o,r)]};var GI=(e,n,t,o)=>{let r=e.series,i=Rm("bar",r.length),a=Math.max(1,...r.flatMap(I=>I.values.map(T=>Math.max(0,T)))),s=_a(o),l=Ra(s),c=La(r.length,s),d=r.length>1?Math.max(1,Math.floor(i.gap/(r.length+1))):0,m=r.length>1?Math.max(2,(i.slotWidth-d*(r.length-1))/r.length):i.slotWidth,p=r.length*m+d*(r.length-1),u=(i.slotWidth-p)/2,E=r[0].values.flatMap((I,T)=>r.map((C,P)=>{let D=Math.max(0,C.values[T]??0)/a*i.chartHeight,_=r.length>1?c[P]:l;return bB({backgroundColor:_,...Ne,type:"rectangle",fillStyle:r.length>1?"solid":Ne.fillStyle,strokeColor:r.length>1?_:Ne.strokeColor,x:n+T*(i.slotWidth+i.gap)+i.gap+u+P*(m+d),y:t-D-i.gap,width:m,height:D})})),g=Fm(e,n,t,l,i,a,EB()),b=Ml(e,n,t,l,i),y=Math.max(t+i.gap/2,...b.map(I=>Bm(I))),{chartWidth:w}=Da(e,i),x=Na(r,c,n+w/2,y,t+i.gap*5,l);return[...g,...E,...x]};import{pointFrom as Tf}from"@excalidraw/math";import{isDevEnv as xB}from"@excalidraw/common";import{newElement as yB,newLinearElement as HI}from"@excalidraw/element";var UI=(e,n,t,o)=>{let r=e.series,i=Rm("line",r.length),a=Math.max(1,...r.flatMap(x=>x.values)),s=_a(o),l=Ra(s),c=La(r.length,s),d=r.map((x,I)=>{let T=x.values.map((_,k)=>Tf(k*(i.slotWidth+i.gap),-(_/a)*i.chartHeight)),C=Math.max(...T.map(_=>_[0])),P=Math.max(...T.map(_=>_[1])),A=Math.min(...T.map(_=>_[0])),D=Math.min(...T.map(_=>_[1]));return HI({backgroundColor:"transparent",...Ne,type:"line",x:n+i.gap+i.slotWidth/2,y:t-i.gap,height:P-D,width:C-A,strokeColor:c[I],strokeWidth:2,points:T})}),m=r.flatMap((x,I)=>x.values.map((T,C)=>{let P=C*(i.slotWidth+i.gap)+i.gap/2,A=-(T/a)*i.chartHeight+i.gap/2;return yB({backgroundColor:c[I],...Ne,fillStyle:"solid",strokeColor:c[I],strokeWidth:2,type:"ellipse",x:n+P+i.slotWidth/2,y:t+A-i.gap*2,width:i.gap,height:i.gap})})),u=r[0].values.map((x,I)=>Math.max(0,...r.map(T=>T.values[I]??0))).map((x,I)=>{let T=I*(i.slotWidth+i.gap)+i.gap/2,C=x/a*i.chartHeight+i.gap/2+i.gap;return HI({backgroundColor:l,...Ne,type:"line",x:n+T+i.slotWidth/2+i.gap/2,y:t-C,height:C,strokeStyle:"dotted",opacity:ni,points:[Tf(0,0),Tf(0,C)]})}),E=Fm(e,n,t,l,i,a,xB()),g=Ml(e,n,t,l,i),b=Math.max(t+i.gap/2,...g.map(x=>Bm(x))),{chartWidth:y}=Da(e,i),w=Na(r,c,n+y/2,b,t+i.gap*5,l);return[...E,...d,...u,...m,...w]};var Nn=e=>{let n=/^([-+]?)[$\u20AC\u00A3\u00A5\u20A9]?([-+]?)([\d.,]+)[%]?$/.exec(e);return n?parseFloat(`${(n[1]||n[2])+n[3]}`.replace(/,/g,"")):null},wB=(e,n)=>e.slice(1).every(t=>Nn(t[n])!==null),WI=e=>{let n=e[0].length;if(n>2){let a=e[0].every(m=>Nn(m)===null),s=a?e.slice(1):e;if(s.length<1)return{ok:!1,reason:"No data rows"};if(s.some(m=>m.slice(1).some(p=>Nn(p)===null)))return{ok:!1,reason:"Value is not numeric"};if(n-1>s.length){let m=a?e[0].slice(1).map(E=>E.trim()):null,p=s.map(E=>({title:E[0]?.trim()||null,values:E.slice(1).map(g=>Nn(g))}));return{ok:!0,data:{title:p.length===1?p[0].title:a&&e[0][0].trim()||null,labels:m,series:p}}}let d=e[0].slice(1).map((m,p)=>{let u=p+1,E=`Series ${u}`;return{title:a&&m.trim()||E,values:s.map(g=>Nn(g[u]))}});return{ok:!0,data:{title:a&&e[0][0].trim()||null,labels:s.map(m=>m[0]),series:d}}}if(n===1){if(!wB(e,0))return{ok:!1,reason:"Value is not numeric"};let a=Nn(e[0][0])===null,s=a?e[0][0]:null,l=(a?e.slice(1):e).map(c=>Nn(c[0]));return l.length<2?{ok:!1,reason:"Less than two rows"}:{ok:!0,data:{title:s,labels:null,series:[{title:s,values:l}]}}}let t=Nn(e[0][1])===null,o=t?e.slice(1):e;if(o.length<2)return{ok:!1,reason:"Less than 2 rows"};if(o.some(a=>Nn(a[1])===null))return{ok:!1,reason:"Value is not numeric"};let i=t?e[0][1]:null;return{ok:!0,data:{title:i,labels:o.map(a=>a[0]),series:[{title:i,values:o.map(a=>Nn(a[1]))}]}}},Om=e=>{let n=s=>e.replace(/\r\n?/g,`
13
+ `,n),r=e.slice(t,o===-1?e.length:o);return VN(r)?"rtl":"ltr"},d7=e=>{let n=[0],t=0;for(let o of Array.from(e))t+=o.length,n.push(t);return n},m7=({text:e,font:n,lineHeightPx:t,direction:o,targetX:r})=>{if(!e||!document.body||typeof document.createRange!="function")return null;let i=d7(e),a=document.createElement("div"),s=document.createTextNode(e),l=document.createRange(),c=[];a.dir=o,Object.assign(a.style,{position:"fixed",top:"0",left:"0",margin:0,padding:0,border:0,opacity:"0",pointerEvents:"none",whiteSpace:"pre",font:n,lineHeight:`${t}px`}),a.append(s),document.body.append(a);try{for(let u of i){l.setStart(s,u),l.setEnd(s,u);let E=l.getBoundingClientRect();if(!Number.isFinite(E.left))return null;c.push(E.left)}}catch{return null}finally{a.remove()}let d=Math.min(...c),m=i[0],p=1/0;for(let u=0;u<i.length;u++){let E=Math.abs(c[u]-d-r);E<p&&(p=E,m=i[u])}return m},eI=({onChange:e,onSubmit:n,getViewportCoords:t,element:o,canvas:r,excalidrawContainer:i,app:a,autoSelect:s=!0,initialCaretSceneCoords:l=null})=>{let c=null,d=(B,W)=>{if(!W.style.fontFamily||!W.style.fontSize)return!1;let ue=W.style.fontFamily.replace(/"/g,"");return Y2({fontFamily:B.fontFamily})!==ue||`${B.fontSize}px`!==W.style.fontSize},m=a.state.theme,p=()=>{m=a.state.theme;let B=a.state,W=a.scene.getElement(o.id);if(!W)return;let{textAlign:ue,verticalAlign:Ee}=W,le=a.scene.getNonDeletedElementsMap();if(W&&Q2(W)){let he=W.x,ge=W.y,se=Ef(W,a.scene.getNonDeletedElementsMap()),xe=W.width,it=W.height,$e=W.width,ke=W.height;if(se&&W.containerId){if(Lm(se)){let on=$N.getBoundTextElementPosition(se,W,le);he=on.x,ge=on.y}let gs=d(W,u),ho;if(gs?ho=Z2(se.id,se.height):(ho=KN[se.id],ho||(ho=Z2(se.id,se.height))),$e=j2(se,W),ke=QN(se,W),!Lm(se)&&it>ke){let on=q2(it,se.type);a.scene.mutateElement(se,{height:on}),$2(se,a.scene);return}else if(!Lm(se)&&se.height>ho.height&&it<ke){let on=q2(it,se.type);a.scene.mutateElement(se,{height:on}),$2(se,a.scene)}else{let{x:on,y:Vo}=e7(se,W,le);he=on,ge=Vo}}let[Zt,Ho]=t(he,ge);se?xe+=.5:($e=(B.width-8-Zt)/B.zoom.value,xe=Math.min(xe,$e)),it*=1.05;let Uo=V2(W),Wo=qN(W,se),Ii=(B.height-Ho)/B.zoom.value;Object.assign(u.style,{font:Uo,lineHeight:W.lineHeight,width:`${xe}px`,height:`${it}px`,left:`${Zt}px`,top:`${Ho}px`,transform:l7(xe,it,Wo,B,$e,Ii),textAlign:ue,verticalAlign:Ee,color:WN(W.strokeColor,B.theme===HN.DARK),opacity:W.opacity/100,maxHeight:`${Ii}px`}),c={angle:Wo,font:Uo,height:W.height,lineHeightPx:o7(W.fontSize,W.lineHeight),textAlign:ue,width:W.width,x:he,y:ge},u.scrollTop=0,X2()&&(u.style.fontFamily=Y2(W)),a.scene.mutateElement(W,{x:he,y:ge})}},u=document.createElement("textarea");u.dir="auto",u.tabIndex=0,u.dataset.type="wysiwyg",u.wrap="off",u.classList.add("excalidraw-wysiwyg");let E="pre",g="normal";(s7(o)||!o.autoResize)&&(E="pre-wrap",g="break-word"),Object.assign(u.style,{position:"absolute",display:"inline-block",minHeight:"1em",backfaceVisibility:"hidden",margin:0,padding:0,border:0,outline:0,resize:"none",background:"transparent",overflow:"hidden",zIndex:"var(--zIndex-wysiwyg)",wordBreak:g,whiteSpace:E,overflowWrap:"break-word",boxSizing:"content-box"}),u.value=o.originalText,p();let b=()=>{if(!l||!c)return null;let B=c,W=K2(B.x+B.width/2,B.y+B.height/2),[ue,Ee]=YN(K2(l.x,l.y),W,-B.angle),le=ue-B.x,he=Ee-B.y,ge=a7(u.value,B.font,E==="pre-wrap"?B.width:1/0),se=Math.max(0,Math.min(ge.length-1,Math.floor(he/B.lineHeightPx))),xe=ge[se],it=c7(u.value,xe.start),$e=r7(xe.text,B.font),ke=B.textAlign==="center"?(B.width-$e)/2:B.textAlign==="right"?B.width-$e:0,Zt=le-ke;if(!xe.text)return xe.start;let Ho=m7({text:xe.text,font:B.font,lineHeightPx:B.lineHeightPx,direction:it,targetX:Zt});return xe.start+(Ho||0)},w=(()=>{let B=b();return B===null?null:{start:B,end:B}})();e&&(u.onpaste=async B=>{let W=yw(B),ue=null;if(W.has(ff.excalidrawClipboard)||W.has(ff.excalidraw)){B.preventDefault(),ue=await Kr(B);try{let se=await jd(ue);if(se.elements){let xe=XN(se.elements);if(xe){let{selectionStart:it,selectionEnd:$e,value:ke}=u;u.value=ke.slice(0,it)+xe+ke.slice($e);let Zt=it+xe.length;u.selectionStart=u.selectionEnd=Zt,u.dispatchEvent(new Event("input"))}}return}catch{console.warn("failed to parse excalidraw clipboard data")}}ue=ue||await Kr(B);let Ee=ue.findByType(ff.text);if(!Ee)return;let le=J2(Ee.value);if(!le)return;let he=Ef(o,a.scene.getNonDeletedElementsMap()),ge=V2({fontSize:a.state.currentItemFontSize,fontFamily:a.state.currentItemFontFamily});if(he){let se=t7(he,a.scene.getNonDeletedElementsMap()),xe=i7(`${u.value}${le}`,ge,j2(he,se)),it=n7(xe,ge);u.style.width=`${it}px`}},u.oninput=()=>{let B=J2(u.value);if(u.value!==B){let W=u.selectionStart;u.value=B,u.selectionStart=W,u.selectionEnd=W}e(u.value)}),u.onkeydown=B=>{if(!B.shiftKey&&Dd.keyTest(B))B.preventDefault(),a.actionManager.executeAction(Dd),p();else if(!B.shiftKey&&Ld.keyTest(B))B.preventDefault(),a.actionManager.executeAction(Ld),p();else if(!B.shiftKey&&_d.keyTest(B))B.preventDefault(),a.actionManager.executeAction(_d),p();else if(zh.keyTest(B))a.actionManager.executeAction(zh);else if(Gh.keyTest(B))a.actionManager.executeAction(Gh);else if(B.key===Ll.ESCAPE)B.preventDefault(),D=!0,_();else if(jr.keyTest(B))B.preventDefault(),_(),a.actionManager.executeAction(jr);else if(B.key===Ll.ENTER&&B[Ll.CTRL_OR_CMD]){if(B.preventDefault(),B.isComposing||B.keyCode===229)return;D=!0,_()}else if(B.key===Ll.TAB||B[Ll.CTRL_OR_CMD]&&(B.code===hf.BRACKET_LEFT||B.code===hf.BRACKET_RIGHT)){if(B.preventDefault(),B.isComposing)return;B.shiftKey||B.code===hf.BRACKET_LEFT?C():T(),u.dispatchEvent(new Event("input"))}};let y=4,x=" ".repeat(y),I=new RegExp(`^ {1,${y}}`),T=()=>{let{selectionStart:B,selectionEnd:W}=u,ue=P(),Ee=u.value;ue.forEach(le=>{let he=Ee.slice(0,le),ge=Ee.slice(le);Ee=`${he}${x}${ge}`}),u.value=Ee,u.selectionStart=B+y,u.selectionEnd=W+y*ue.length},C=()=>{let{selectionStart:B,selectionEnd:W}=u,ue=P(),Ee=[],le=u.value;ue.forEach(he=>{let ge=le.slice(he,he+y).match(I);if(ge){let se=le.slice(0,he),xe=le.slice(he+ge[0].length);le=`${se}${xe}`,Ee.push(he)}}),u.value=le,Ee.length&&(B>Ee[Ee.length-1]?u.selectionStart=Math.max(B-y,Ee[Ee.length-1]):u.selectionStart=B,u.selectionEnd=Math.max(u.selectionStart,W-y*Ee.length))},P=()=>{let{selectionStart:B,selectionEnd:W,value:ue}=u,Ee=ue.slice(0,B).match(/[^\n]*$/)[0].length;return B=B-Ee,ue.slice(B,W).split(`
14
+ `).reduce((he,ge,se,xe)=>he.concat(se?he[se-1]+xe[se-1].length+1:B),[]).reverse()},M=B=>{B.target instanceof HTMLCanvasElement&&(B.preventDefault(),B.stopPropagation())},D=!1,_=()=>{if(G)return;G=!0,k();let B=a.scene.getElement(o.id);if(!B)return;let W=Ef(B,a.scene.getNonDeletedElementsMap());if(W){if(u.value.trim()){let ue=jN(W);!ue||ue!==o.id?a.scene.mutateElement(W,{boundElements:(W.boundElements||[]).concat({type:"text",id:o.id})}):Lm(W)&&ZN(W)}else a.scene.mutateElement(W,{boundElements:W.boundElements?.filter(ue=>!Q2(ue))});JN(B,W,a.scene)}n({viaKeyboard:D,nextOriginalText:u.value})},k=()=>{u.onblur=null,u.oninput=null,u.onkeydown=null,re&&re.disconnect(),window.removeEventListener("resize",p),window.removeEventListener("wheel",M,!0),window.removeEventListener("pointerdown",Y),window.removeEventListener("pointerup",L),window.removeEventListener("blur",_),window.removeEventListener("beforeunload",_),U(),z(),V(),u.remove()},L=B=>{window.removeEventListener("pointerup",L);let W=B?.target,ue=W instanceof HTMLElement&&W.classList.contains("properties-trigger"),Ee=(W instanceof HTMLElement||W instanceof SVGElement)&&!!W.closest(".properties-content"),le=(W instanceof HTMLElement||W instanceof SVGElement)&&(!!W.closest(`.${gf.SHAPE_ACTIONS_MENU}`)||!!W.closest(".compact-shape-actions-island"));setTimeout(()=>{le||ue||Ee||(u.onblur=_,u.focus(),w&&(u.setSelectionRange(w.start,w.end),w=null))})},F=()=>{u.onblur=null,window.addEventListener("pointerup",L),window.addEventListener("blur",_)},Y=B=>{let W=B?.target;if(B.button===GN.WHEEL){W instanceof HTMLTextAreaElement&&(B.preventDefault(),a.handleCanvasPanUsingWheelOrSpaceDrag(B)),F();return}let ue=W instanceof HTMLElement&&W.classList.contains("properties-trigger"),Ee=(W instanceof HTMLElement||W instanceof SVGElement)&&!!W.closest(".properties-content");(B.target instanceof HTMLElement||B.target instanceof SVGElement)&&(B.target.closest(`.${gf.SHAPE_ACTIONS_MENU}, .${gf.ZOOM_ACTIONS}`)||B.target.closest(".compact-shape-actions-island"))&&!UN(B.target)||ue||Ee?F():B.target instanceof HTMLCanvasElement&&!X2()&&requestAnimationFrame(()=>{_()})},z=a.onChangeEmitter.on(B=>{a.state.theme!==m&&p()}),U=a.scene.onUpdate(()=>{p(),!!document.activeElement?.closest(".properties-content")||u.focus()}),V=a.onScrollChangeEmitter.on(()=>{p()}),G=!1;s&&!w&&u.select(),L();let re=null;return r&&"ResizeObserver"in window?(re=new window.ResizeObserver(()=>{p()}),re.observe(r)):window.addEventListener("resize",p),u.onpointerdown=B=>B.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",Y,{capture:!0})}),window.addEventListener("beforeunload",_),i?.querySelector(".excalidraw-textEditorContainer").appendChild(u),_};import{getGlobalCSSVariable as _m}from"@excalidraw/common";import{getCommonBounds as p7}from"@excalidraw/element";var Mo=4,fn=6,tI="rgba(0,0,0,0.3)",nI=(e,n,t,o)=>{if(!e.size)return{horizontal:null,vertical:null};let[r,i,a,s]=p7(e),l=n/o.zoom.value,c=t/o.zoom.value,d={top:parseInt(_m("sat"))||0,bottom:parseInt(_m("sab"))||0,left:parseInt(_m("sal"))||0,right:parseInt(_m("sar"))||0},m=Kn().rtl,p=-o.scrollX+d.left,u=-o.scrollY+d.top,E=p+l-d.right,g=u+c-d.bottom,b=Math.min(r,p),w=Math.min(i,u),y=Math.max(a,E),x=Math.max(s,g),I=a-r,T=s-i,C=y-b,P=x-w,M=Math.max(Mo*2,d.left+d.right)+fn*2,D=n*(l/C)-M,_=Math.max(Mo*2,d.top+d.bottom)+fn*2,k=t*(c/P)-_,L=C>I?C*o.zoom.value/(D+M):n/(D+M),F=P>T?P*o.zoom.value/(k+_):t/(k+_);return{horizontal:p===b&&E===y?null:{x:Math.max(d.left,Mo)+fn+(p-b)/C*n,y:t-fn-Math.max(Mo,d.bottom),width:D,height:fn,deltaMultiplier:L},vertical:u===w&&g===x?null:{x:m?Math.max(d.left,Mo):n-fn-Math.max(d.right,Mo),y:Math.max(d.top,Mo)+fn+(u-w)/P*t,width:fn,height:k,deltaMultiplier:F}}},bf=(e,n,t)=>{let[o,r]=[e.horizontal,e.vertical].map(a=>a!=null&&a.x<=n&&n<=a.x+a.width&&a.y<=t&&t<=a.y+a.height);return{isOverEither:o||r,isOverHorizontal:o,isOverVertical:r}};import{pointFrom as D7}from"@excalidraw/math";import{getElementLineSegments as L7}from"@excalidraw/element";import{LinearElementEditor as _7}from"@excalidraw/element/linearElementEditor";import{isFrameLikeElement as R7,isLinearElement as N7}from"@excalidraw/element";import{getFrameChildren as B7}from"@excalidraw/element";import{selectGroupsForSelectedElements as F7}from"@excalidraw/element";import{arrayToMap as O7,easeOut as cI,isShallowEqual as z7}from"@excalidraw/common";import{simplify as u7}from"points-on-curve";import{polygonFromPoints as h7,lineSegment as Nm,pointFrom as Ma,pointOnLineSegment as g7,polygonIncludesPointNonZero as f7,PRECISION as Rm}from"@excalidraw/math";import{boundsContainBounds as rI,computeBoundTextPosition as E7,doBoundsIntersect as b7,elementOverlapsWithFrame as x7,getBoundTextElement as iI,getContainingFrame as y7,getElementBounds as aI,intersectElementWithLineSegment as w7,isBoundToContainer as sI,pointInsideBoundsInclusive as v7}from"@excalidraw/element";var lI=e=>{let{lassoPath:n,elements:t,elementsMap:o,elementsSegments:r,intersectedElements:i,enclosedElements:a,simplifyDistance:s,mode:l="contain"}=e,c=n;s&&(c=u7(n,s));let d=t.filter(g=>!g.locked&&!sI(g));a.clear(),i.clear();let m=n.reduce((g,b)=>[Math.min(g[0],b[0]),Math.min(g[1],b[1]),Math.max(g[2],b[0]),Math.max(g[3],b[1])],[1/0,1/0,-1/0,-1/0]),p=h7(c),u=[m[0]-Rm,m[1]-Rm,m[2]+Rm,m[3]+Rm];for(let g of d){let b=aI(g,o),w=I7(g,b,o),y=T7(b,w);if(b7(m,y)&&!i.has(g.id)&&!a.has(g.id)){if(l==="contain"&&!rI(u,y))continue;let x=S7(g,o,r,w),I=k7(p,x,y,l);l==="contain"?I&&!oI(c,g,o,w)&&a.add(g.id):I?a.add(g.id):oI(c,g,o,w)&&i.add(g.id)}}return{selectedElementIds:l==="contain"?P7([...a],o):[...i,...a]}},I7=(e,n,t)=>{let o=y7(e,t);if(!o)return null;let r=aI(o,t);return rI(r,n)?null:x7(e,o,t)?r:null},T7=(e,n)=>n?[Math.max(e[0],n[0]),Math.max(e[1],n[1]),Math.min(e[2],n[2]),Math.min(e[3],n[3])]:e,S7=(e,n,t,o)=>{let r=t.get(e.id)??[],i=iI(e,n),a=i?t.get(i.id):null,s=a?.length?[...r,...a]:r;return o?C7(s,o):s},C7=(e,n)=>{let[t,o,r,i]=n,a=[];for(let[[s,l],[c,d]]of e){let m=c-s,p=d-l,u=0,E=1,g=!0;for(let[b,w]of[[-m,s-t],[m,r-s],[-p,l-o],[p,i-l]]){if(b===0){if(w<0){g=!1;break}continue}let y=w/b;if(b<0){if(y>E){g=!1;break}u=Math.max(u,y)}else{if(y<u){g=!1;break}E=Math.min(E,y)}}g&&a.push(Nm(Ma(s+u*m,l+u*p),Ma(s+E*m,l+E*p)))}return a},P7=(e,n)=>{if(!e.some(r=>n.get(r)?.groupIds.length))return e;let t=new Map;for(let r of n.values()){let i=r.groupIds.at(-1);if(!i||r.locked||sI(r))continue;let a=t.get(i);a?a.push(r.id):t.set(i,[r.id])}if(!t.size)return e;let o=new Set(e);return e.filter(r=>{let i=n.get(r)?.groupIds.at(-1),a=i?t.get(i):null;return!a||a.every(s=>o.has(s))})},k7=(e,n,t,o)=>{let r=o==="contain"?"every":"some",i=a=>f7(a,e)||o==="contain"&&A7(a,e);return n.length===0?M7(t)[r](i):n[r](a=>a[r](i))},M7=([e,n,t,o])=>[Ma(e,n),Ma(t,n),Ma(t,o),Ma(e,o)],A7=(e,n)=>n.some((t,o)=>o>0&&g7(e,Nm(n[o-1],t))),oI=(e,n,t,o)=>{let r=e.slice(1).map((s,l)=>Nm(e[l],s)).concat([Nm(e[e.length-1],e[0])]),i=iI(n,t),a=(s,l)=>{let c=w7(s,t,l,0,!o);return o?c.some(d=>v7(d,o)):c.length>0};return r.some(s=>a(n,s)||!!i&&a({...i,...E7(n,i,t)},s))};var Bm=class extends Rn{constructor(t){super(t,{animateTrail:!0,streamline:.4,sizeMapping:o=>{let a=Math.max(0,1-(performance.now()-o.pressure)/(1/0)),s=(5e3-Math.min(5e3,o.totalLength-o.currentIndex))/5e3;return Math.min(cI(s),cI(a))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});v(this,"intersectedElements",new Set);v(this,"enclosedElements",new Set);v(this,"elementsSegments",null);v(this,"canvasTranslate",null);v(this,"keepPreviousSelection",!1);v(this,"selectElementsFromIds",t=>{this.app.setState(o=>{let r=t.reduce((l,c)=>(l[c]=!0,l),{});if(this.keepPreviousSelection)for(let l of Object.keys(o.selectedElementIds))r[l]=!0;for(let[l]of Object.entries(r)){let c=this.app.scene.getNonDeletedElement(l);if(c&&R7(c)){let d=B7(this.app.scene.getNonDeletedElementsMap(),c.id);for(let m of d)delete r[m.id]}}let i=F7({editingGroupId:o.editingGroupId,selectedElementIds:r},this.app.scene.getNonDeletedElements(),o,this.app),a=[...Object.keys(i.selectedElementIds)],s=[...Object.keys(i.selectedGroupIds)];return{selectedElementIds:i.selectedElementIds,selectedGroupIds:i.selectedGroupIds,selectedLinearElement:a.length===1&&!s.length&&N7(this.app.scene.getNonDeletedElement(a[0]))?new _7(this.app.scene.getNonDeletedElement(a[0]),this.app.scene.getNonDeletedElementsMap()):null}})});v(this,"addPointToPath",(t,o,r=!1)=>{super.addPointToPath(t,o),this.keepPreviousSelection=r,this.updateSelection()});v(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(r=>D7(r[0],r[1])),o={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!z7(o,this.canvasTranslate??{})){this.canvasTranslate=o,this.elementsSegments=new Map;let r=O7(this.app.visibleElements);for(let i of this.app.visibleElements){let a=L7(i,r);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:r}=lI({lassoPath:t,elements:this.app.visibleElements,elementsMap:this.app.scene.getNonDeletedElementsMap(),elementsSegments:this.elementsSegments,intersectedElements:this.intersectedElements,enclosedElements:this.enclosedElements,simplifyDistance:5/this.app.state.zoom.value,mode:this.app.state.boxSelectionMode});this.selectElementsFromIds(r)}})}startPath(t,o,r=!1){this.endPath(),super.startPath(t,o),this.intersectedElements.clear(),this.enclosedElements.clear(),this.keepPreviousSelection=r,this.keepPreviousSelection||this.app.setState({selectedElementIds:{},selectedGroupIds:{},selectedLinearElement:null})}endPath(){super.endPath(),super.clearTrails(),this.intersectedElements.clear(),this.enclosedElements.clear(),this.elementsSegments=null}};import{arrayToMap as G7,easeOut as dI,THEME as H7}from"@excalidraw/common";import{computeBoundTextPosition as U7,doBoundsIntersect as W7,getBoundTextElement as V7,getElementBounds as Y7,getElementLineSegments as X7,getFreedrawOutlineAsSegments as K7,getFreedrawOutlinePoints as $7,intersectElementWithLineSegment as mI,isArrowElement as Z7,isFreeDrawElement as pI,isLineElement as j7,isPointInElement as q7}from"@excalidraw/element";import{lineSegment as J7,lineSegmentsDistance as uI,pointFrom as xI,polygon as Q7,polygonIncludesPointNonZero as eB}from"@excalidraw/math";import{getElementsInGroup as hI}from"@excalidraw/element";import{shouldTestInside as tB}from"@excalidraw/element";import{hasBoundTextElement as gI,isBoundToContainer as fI}from"@excalidraw/element";import{getBoundTextElementId as EI}from"@excalidraw/element";var Fm=class extends Rn{constructor(t){super(t,{streamline:.2,size:5,keepHead:!0,sizeMapping:o=>{let a=Math.max(0,1-(performance.now()-o.pressure)/200),s=(10-Math.min(10,o.totalLength-o.currentIndex))/10;return Math.min(dI(s),dI(a))},fill:()=>t.props.renderCustomizations?.traceColor??(t.state.theme===H7.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)")});v(this,"elementsToErase",new Set);v(this,"groupsToErase",new Set)}startPath(t,o){this.endPath(),super.startPath(t,o),this.elementsToErase.clear()}addPointToPath(t,o,r=!1){return super.addPointToPath(t,o),this.updateElementsToBeErased(r)}updateElementsToBeErased(t){let o=super.getCurrentTrail()?.originalPoints?.map(s=>xI(s[0],s[1]))||[];if(o.length<2)return[];let r=J7(o[o.length-1],o[o.length-2]),i=this.app.visibleElements.filter(s=>!s.locked),a=G7(i);for(let s of i)if(t&&this.elementsToErase.has(s.id)){if(bI(r,s,a,this.app.state.zoom.value)){let c=s.groupIds.at(-1);if(this.groupsToErase.has(c)){let d=hI(this.app.scene.getNonDeletedElementsMap(),c);for(let m of d)this.elementsToErase.delete(m.id);this.groupsToErase.delete(c)}if(fI(s)&&this.elementsToErase.delete(s.containerId),gI(s)){let d=EI(s);d&&this.elementsToErase.delete(d)}this.elementsToErase.delete(s.id)}}else if(!t&&!this.elementsToErase.has(s.id)&&bI(r,s,a,this.app.state.zoom.value)){let c=s.groupIds.at(-1);if(!this.groupsToErase.has(c)){let d=hI(this.app.scene.getNonDeletedElementsMap(),c);for(let m of d)this.elementsToErase.add(m.id);this.groupsToErase.add(c)}if(gI(s)){let d=EI(s);d&&this.elementsToErase.add(d)}fI(s)&&this.elementsToErase.add(s.containerId),this.elementsToErase.add(s.id)}return Array.from(this.elementsToErase)}endPath(){super.endPath(),super.clearTrails(),this.elementsToErase.clear(),this.groupsToErase.clear()}},bI=(e,n,t,o)=>{let r=e[1],i=pI(n)?15:n.strokeWidth/2,a=[Math.min(e[0][0],e[1][0])-i,Math.min(e[0][1],e[1][1])-i,Math.max(e[0][0],e[1][0])+i,Math.max(e[0][1],e[1][1])+i],s=Y7(n,t),l=[s[0]-i,s[1]-i,s[2]+i,s[3]+i];if(!W7(a,l))return!1;if(tB(n)&&q7(r,n,t))return!0;if(pI(n)){let d=$7(n),m=K7(n,d,t),p=Math.max(2.25,5/o);for(let E of m)if(uI(E,e)<=p)return!0;let u=Q7(...d.map(([E,g])=>xI(n.x+E,n.y+g)));return!!eB(e[0],u)}let c=V7(n,t);if(Z7(n)||j7(n)&&!n.polygon){let d=Math.max(n.strokeWidth,n.strokeWidth*2/o),m=X7(n,t);for(let p of m)if(uI(p,e)<=d)return!0;return!1}return mI(n,t,e,0,!0).length>0||!!c&&mI({...c,...U7(n,c,t)},t,e,0,!0).length>0};import{isDevEnv as EB}from"@excalidraw/common";import{newElement as bB}from"@excalidraw/element";import{COLOR_PALETTE as nB,DEFAULT_FONT_FAMILY as oB,DEFAULT_FONT_SIZE as rB,VERTICAL_ALIGN as iB}from"@excalidraw/common";var yI=44,wI=22,vI=66,II=48,_l=14,TI=304,SI=320,xf=5.87,CI=28,PI=4,kI=2,yf=10,MI=10,AI=8,oo=12,Aa=256,ai=10,wf=4,Da=oo*2,vf=oo*2,DI=100,LI=140,Rl=.35,_I=oo/2,gr=20,Om=oo*2,If=oo,Be={fillStyle:"hachure",fontFamily:oB,fontSize:rB,opacity:100,roughness:1,strokeColor:nB.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:iB.MIDDLE,locked:!1};import{pointFrom as La}from"@excalidraw/math";import{COLOR_PALETTE as OI,DEFAULT_CHART_COLOR_INDEX as aB,FONT_FAMILY as Cf,FONT_SIZES as zm,ROUNDNESS as RI,DEFAULT_FONT_SIZE as sB,getAllColorsSpecificShade as lB,getFontString as Pf,getLineHeight as kf,ROUGHNESS as NI}from"@excalidraw/common";import{getApproxMinLineWidth as Mf,measureText as fr,newElement as Sf,newLinearElement as Tf,newTextElement as _a,wrapText as zI}from"@excalidraw/element";var si=lB(aB),cB=e=>e.labels?.length??e.series[0]?.values.length??0,Ra=(e,n)=>{if(!e)return!1;let t=cB(e);return t<2?!1:n==="radar"?t>=3:!0},BI=(e,n)=>{let t=n<=1?0:Math.min(vI,(n-1)*wI);return e+t},Gm=(e,n)=>{if(e==="line"){let o=BI(II,n);return{slotWidth:o,gap:_l,chartHeight:SI,xLabelMaxWidth:o+_l*3+yf}}let t=BI(yI,n);return{slotWidth:t,gap:_l,chartHeight:TI,xLabelMaxWidth:t+_l*3+yf}},Na=(e,n)=>{let t=(n.slotWidth+n.gap)*e.series[0].values.length+n.gap,o=n.chartHeight+n.gap*2;return{chartWidth:t,chartHeight:o}},GI=()=>{let e=Aa+vf*2,n=Aa+vf*2;return{chartWidth:e,chartHeight:n}},dB=(e,n,t)=>{let o=Math.abs(e-n);return Math.min(o,t-o)},Ba=(e,n)=>{if(e<=0||si.length===0)return[];let t=si.length,o=(n%t+t)%t,r=[o],i=Math.min(e,t),a=new Set(Array.from({length:t},(s,l)=>l).filter(s=>s!==o));for(;r.length<i;){let s=-1,l=-1,c=-1;for(let d of a){let m=r.map(E=>dB(d,E,t)),p=Math.min(...m),u=m.reduce((E,g)=>E+g,0)/m.length;(p>l||p===l&&u>c)&&(s=d,l=p,c=u)}r.push(s),a.delete(s)}return Array.from({length:e},(s,l)=>si[r[l%r.length]])},Fa=e=>{if(si.length===0)return 0;if(typeof e!="number"||!Number.isFinite(e))return Math.floor(Math.random()*si.length);let n=e.toString(),t=0;for(let o=0;o<n.length;o++)t=t*31+n.charCodeAt(o)|0;return Math.abs(t)%si.length},Oa=e=>si[e],HI=(e,n)=>{let t=e.flatMap(s=>s.values.map(l=>Math.max(0,l))),o=t.filter(s=>s>0),r=Math.max(1,...t),i=o.length>0?Math.min(...o):1,a=e.length===1&&i>0&&r/i>=DI;return{renderSteps:!1,normalize:(s,l)=>{let c=Math.max(0,s);return a?Math.log10(c+1)/Math.log10(r+1):c/r}}},mB=e=>/\s/.test(e.trim()),Hm=(e,n,t)=>mB(e)?zI(e,n,t):e,UI=(e,n,t,o,r,i)=>{let a=Cf.Excalifont,s=zm.sm,l=kf(a),c=Pf({fontFamily:a,fontSize:s}),d=Math.min(LI,r*(e.length>8?.56:.72)),m=Mf(c,l),p=e.map((g,b)=>{let w=n[b],y=Math.max(0,...g.trim().split(/\s+/).filter(Boolean).map(z=>fr(z,c,l).width)),x=Math.max(m,d,y),I=Hm(g,c,x),T=fr(I,c,l),C=Math.cos(w),P=Math.sin(w),M=C>Rl?"left":C<-Rl?"right":"center",D=M==="center"?T.width/2:0,_=Math.abs(C)*D+Math.abs(P)*(T.height/2),k=Da+_+_I,L=t+C*(r+k),F=o+P*(r+k),Y=P>Rl?oo/3:P<-Rl?-oo/3:0;return _a({backgroundColor:i,...Be,text:I,originalText:g,x:L,y:F+Y,fontFamily:a,fontSize:s,lineHeight:l,textAlign:M,verticalAlign:"middle"})}),u=Math.min(...p.map(g=>g.y)),E=Math.max(...p.map(g=>g.y+g.height));return{axisLabels:p,axisLabelTopY:u,axisLabelBottomY:E}},za=(e,n,t,o,r,i)=>{if(e.length<=1)return[];let a=Cf["Lilita One"],s=zm.lg,l=kf(a),c=Pf({fontFamily:a,fontSize:s}),d=e.map((I,T)=>{let C=I.title?.trim()||`Series ${T+1}`,P=Hm(C,c,Aa),M=fr(P,c,l),D=gr+If+M.width;return{label:C,displayLabel:P,color:n[T],width:D,height:M.height}}),m=Math.max(gr/2,...d.map(I=>I.height/2)),p=Math.max(r,o+m+Da),u=Om,E=gr*.6,g=d.reduce((I,T)=>I+T.width,0)+Om*Math.max(0,d.length-1),b=g+u*2,w=m*2+E*2,y=[];y.push(Sf({...Be,backgroundColor:"transparent",type:"rectangle",fillStyle:"solid",strokeColor:OI.black,x:t-b/2,y:p-w/2,width:b,height:w,roughness:NI.architect,roundness:{type:RI.PROPORTIONAL_RADIUS}}));let x=t-g/2;return d.forEach(I=>{y.push(Sf({...Be,backgroundColor:I.color,type:"rectangle",x,y:p-gr/2,width:gr,height:gr,fillStyle:"solid",strokeColor:I.color,roughness:NI.architect,roundness:{type:RI.PROPORTIONAL_RADIUS}})),y.push(_a({...Be,text:I.displayLabel,originalText:I.label,autoResize:!1,x:x+gr+If,y:p,fontFamily:a,fontSize:s,lineHeight:l,textAlign:"left",verticalAlign:"middle"})),x+=I.width+Om}),y},pB=(e,n,t,o)=>{if(fr(e,t,o).width<=n)return e;let r=e.length;for(;r>1;){let i=`${e.slice(0,r)}...`;if(fr(i,t,o).width<=n)return i;r--}return e[0]?`${e[0]}...`:e},uB=(e,n,t,o)=>{if(fr(e,t,o).width<=n)return{wrapped:!1,text:e};let r=e.trim().split(/\s+/).filter(Boolean);return r.length>1&&!r.some(a=>fr(a,t,o).width>n)&&n>=Mf(t,o)?{wrapped:!0,text:zI(e,t,n)}:{wrapped:!1,text:pB(e,n,t,o)}},WI=(e,n,t)=>{let o=Math.abs(Math.cos(t)),r=Math.abs(Math.sin(t));return{width:e*o+n*r,height:e*r+n*o}},FI=e=>e.includes("..."),hB=(e,n,t,o,r)=>{let i=Math.max(CI,Math.ceil(Mf(o,r))),a=Math.max(i,Math.floor(n)),s=[];for(let u=a;u>=i;u-=4)s.push(u);s[s.length-1]!==i&&s.push(i);let l=u=>{let E=FI(u.text),g=u.text.replace(/\.\.\./g,"").replace(/\n/g,"").length,b=u.text.split(`
15
+ `).length;return{ellipsified:E,visibleChars:g,lineCount:b}},c=(u,E)=>{let g=l(u),b=l(E);return g.ellipsified!==b.ellipsified?!g.ellipsified:g.visibleChars!==b.visibleChars?g.visibleChars>b.visibleChars:g.lineCount!==b.lineCount?g.lineCount<b.lineCount:u.rotatedHeight<E.rotatedHeight},d=null,m=null,p=null;for(let u of s){let{wrapped:E,text:g}=uB(e,u,o,r),b=fr(g,o,r),w=WI(b.width,b.height,xf),y={originalText:e,text:g,metrics:b,rotatedWidth:w.width,rotatedHeight:w.height,wrapped:E},x=w.width-t;if(x<=0){(!d||c(y,d))&&(d=y);continue}(!m||x<m.overflow||x===m.overflow&&c(y,m.spec))&&(m={overflow:x,spec:y}),!FI(y.text)&&(!p||x<p.overflow||x===p.overflow&&c(y,p.spec))&&(p={overflow:x,spec:y})}return d||(p&&m&&p.overflow<=m.overflow+AI?p.spec:m.spec)},Um=e=>{if(e.type!=="text")return e.y+e.height;let n=WI(e.width,e.height,e.angle);return e.y+e.height/2+n.height/2},Nl=(e,n,t,o,r)=>{let i=Be.fontFamily,a=zm.sm,s=kf(i),l=Pf({fontFamily:i,fontSize:a}),c=Math.max(1,r.slotWidth+r.gap-PI*2+MI),d=t;return e.labels?.map((m,p)=>{let u=hB(m,r.xLabelMaxWidth,c,l,s),E=n+p*(r.slotWidth+r.gap)+r.gap+r.slotWidth/2,g=d+kI+(u.rotatedHeight-u.metrics.height)/2;return _a({backgroundColor:o,...Be,text:u.text,originalText:u.wrapped?m:u.text,autoResize:!u.wrapped,x:E,y:g,angle:xf,fontSize:a,lineHeight:s,textAlign:"center",verticalAlign:"top"})})||[]},gB=(e,n,t,o,r,i=Math.max(...e.series[0].values))=>{let a=_a({backgroundColor:o,...Be,x:n-r.gap,y:t-r.gap,text:"0",textAlign:"right"}),s=_a({backgroundColor:o,...Be,x:n-r.gap,y:t-r.chartHeight-a.height/2,text:i.toLocaleString(),textAlign:"right"});return[a,s]},fB=(e,n,t,o,r)=>{let{chartWidth:i,chartHeight:a}=Na(e,r),s=Tf({backgroundColor:o,...Be,type:"line",x:n,y:t,width:i,points:[La(0,0),La(i,0)]}),l=Tf({backgroundColor:o,...Be,type:"line",x:n,y:t,height:a,points:[La(0,0),La(0,-a)]}),c=Tf({backgroundColor:o,...Be,type:"line",x:n,y:t-r.chartHeight-r.gap,strokeStyle:"dotted",width:i,opacity:ai,points:[La(0,0),La(i,0)]});return[s,l,c]},Wm=(e,n,t,o,r,i=Math.max(...e.series[0].values),a)=>{let{chartWidth:s,chartHeight:l}=Na(e,r),c=e.title?_a({backgroundColor:o,...Be,text:e.title,x:n+s/2,y:t-r.chartHeight-r.gap*2-sB,roundness:null,textAlign:"center",fontSize:zm.xl,fontFamily:Cf["Lilita One"]}):null,d=a?Sf({backgroundColor:o,...Be,type:"rectangle",x:n,y:t-l,width:s,height:l,strokeColor:OI.black,fillStyle:"solid",opacity:6}):null;return[...d?[d]:[],...c?[c]:[],...Nl(e,n,t,o,r),...gB(e,n,t,o,r,i),...fB(e,n,t,o,r)]};var VI=(e,n,t,o)=>{let r=e.series,i=Gm("bar",r.length),a=Math.max(1,...r.flatMap(I=>I.values.map(T=>Math.max(0,T)))),s=Fa(o),l=Oa(s),c=Ba(r.length,s),d=r.length>1?Math.max(1,Math.floor(i.gap/(r.length+1))):0,m=r.length>1?Math.max(2,(i.slotWidth-d*(r.length-1))/r.length):i.slotWidth,p=r.length*m+d*(r.length-1),u=(i.slotWidth-p)/2,E=r[0].values.flatMap((I,T)=>r.map((C,P)=>{let D=Math.max(0,C.values[T]??0)/a*i.chartHeight,_=r.length>1?c[P]:l;return bB({backgroundColor:_,...Be,type:"rectangle",fillStyle:r.length>1?"solid":Be.fillStyle,strokeColor:r.length>1?_:Be.strokeColor,x:n+T*(i.slotWidth+i.gap)+i.gap+u+P*(m+d),y:t-D-i.gap,width:m,height:D})})),g=Wm(e,n,t,l,i,a,EB()),b=Nl(e,n,t,l,i),w=Math.max(t+i.gap/2,...b.map(I=>Um(I))),{chartWidth:y}=Na(e,i),x=za(r,c,n+y/2,w,t+i.gap*5,l);return[...g,...E,...x]};import{pointFrom as Af}from"@excalidraw/math";import{isDevEnv as xB}from"@excalidraw/common";import{newElement as yB,newLinearElement as YI}from"@excalidraw/element";var XI=(e,n,t,o)=>{let r=e.series,i=Gm("line",r.length),a=Math.max(1,...r.flatMap(x=>x.values)),s=Fa(o),l=Oa(s),c=Ba(r.length,s),d=r.map((x,I)=>{let T=x.values.map((_,k)=>Af(k*(i.slotWidth+i.gap),-(_/a)*i.chartHeight)),C=Math.max(...T.map(_=>_[0])),P=Math.max(...T.map(_=>_[1])),M=Math.min(...T.map(_=>_[0])),D=Math.min(...T.map(_=>_[1]));return YI({backgroundColor:"transparent",...Be,type:"line",x:n+i.gap+i.slotWidth/2,y:t-i.gap,height:P-D,width:C-M,strokeColor:c[I],strokeWidth:2,points:T})}),m=r.flatMap((x,I)=>x.values.map((T,C)=>{let P=C*(i.slotWidth+i.gap)+i.gap/2,M=-(T/a)*i.chartHeight+i.gap/2;return yB({backgroundColor:c[I],...Be,fillStyle:"solid",strokeColor:c[I],strokeWidth:2,type:"ellipse",x:n+P+i.slotWidth/2,y:t+M-i.gap*2,width:i.gap,height:i.gap})})),u=r[0].values.map((x,I)=>Math.max(0,...r.map(T=>T.values[I]??0))).map((x,I)=>{let T=I*(i.slotWidth+i.gap)+i.gap/2,C=x/a*i.chartHeight+i.gap/2+i.gap;return YI({backgroundColor:l,...Be,type:"line",x:n+T+i.slotWidth/2+i.gap/2,y:t-C,height:C,strokeStyle:"dotted",opacity:ai,points:[Af(0,0),Af(0,C)]})}),E=Wm(e,n,t,l,i,a,xB()),g=Nl(e,n,t,l,i),b=Math.max(t+i.gap/2,...g.map(x=>Um(x))),{chartWidth:w}=Na(e,i),y=za(r,c,n+w/2,b,t+i.gap*5,l);return[...E,...d,...u,...m,...y]};var Nn=e=>{let n=/^([-+]?)[$\u20AC\u00A3\u00A5\u20A9]?([-+]?)([\d.,]+)[%]?$/.exec(e);return n?parseFloat(`${(n[1]||n[2])+n[3]}`.replace(/,/g,"")):null},wB=(e,n)=>e.slice(1).every(t=>Nn(t[n])!==null),KI=e=>{let n=e[0].length;if(n>2){let a=e[0].every(m=>Nn(m)===null),s=a?e.slice(1):e;if(s.length<1)return{ok:!1,reason:"No data rows"};if(s.some(m=>m.slice(1).some(p=>Nn(p)===null)))return{ok:!1,reason:"Value is not numeric"};if(n-1>s.length){let m=a?e[0].slice(1).map(E=>E.trim()):null,p=s.map(E=>({title:E[0]?.trim()||null,values:E.slice(1).map(g=>Nn(g))}));return{ok:!0,data:{title:p.length===1?p[0].title:a&&e[0][0].trim()||null,labels:m,series:p}}}let d=e[0].slice(1).map((m,p)=>{let u=p+1,E=`Series ${u}`;return{title:a&&m.trim()||E,values:s.map(g=>Nn(g[u]))}});return{ok:!0,data:{title:a&&e[0][0].trim()||null,labels:s.map(m=>m[0]),series:d}}}if(n===1){if(!wB(e,0))return{ok:!1,reason:"Value is not numeric"};let a=Nn(e[0][0])===null,s=a?e[0][0]:null,l=(a?e.slice(1):e).map(c=>Nn(c[0]));return l.length<2?{ok:!1,reason:"Less than two rows"}:{ok:!0,data:{title:s,labels:null,series:[{title:s,values:l}]}}}let t=Nn(e[0][1])===null,o=t?e.slice(1):e;if(o.length<2)return{ok:!1,reason:"Less than 2 rows"};if(o.some(a=>Nn(a[1])===null))return{ok:!1,reason:"Value is not numeric"};let i=t?e[0][1]:null;return{ok:!0,data:{title:i,labels:o.map(a=>a[0]),series:[{title:i,values:o.map(a=>Nn(a[1]))}]}}},Vm=e=>{let n=s=>e.replace(/\r\n?/g,`
16
16
  `).split(`
17
- `).filter(l=>l.trim().length>0).map(l=>l.split(s).map(c=>c.trim())),t=[" ",",",";"].map(s=>{let l=n(s),c=l[0]?.length??0,d=l.length>0&&l.every(m=>m.length===c);return{delimiter:s,parsed:l,numCols:c,isConsistent:d}}),r=(t.find(s=>s.isConsistent&&s.numCols>1)??t.find(s=>s.isConsistent)??t[0]).parsed;if(r.length===0)return{ok:!1,reason:"No values"};let i=r[0].length;return r.every(s=>s.length===i)?WI(r):{ok:!1,reason:"All rows don't have same number of columns"}};import{pointFrom as Ba}from"@excalidraw/math";import{FONT_FAMILY as vB,FONT_SIZES as IB,getFontString as TB,getLineHeight as SB,ROUGHNESS as VI}from"@excalidraw/common";import{measureText as CB,newLinearElement as Sf,newTextElement as PB}from"@excalidraw/element";var YI=(e,n,t,o)=>{if(!Aa(e,"radar"))return null;let r=e.labels??e.series[0].values.map((z,U)=>`Value ${U+1}`),i=e.series,{normalize:a,renderSteps:s}=FI(i,r.length),l=_a(o),c=Ra(l),d=La(i.length,l),{chartWidth:m,chartHeight:p}=BI(),u=n+m/2,E=t-p/2,g=Ca/2,b=r.map((z,U)=>-Math.PI/2+Math.PI*2*U/r.length),{axisLabels:y,axisLabelTopY:w,axisLabelBottomY:x}=OI(r,b,u,E,g,c),I=vB["Lilita One"],T=IB.xl,C=SB(I),P=TB({fontFamily:I,fontSize:T}),A=e.title?Nm(e.title,P,m+Pa*2):null,D=A?CB(A,P,C):null,_=A?PB({backgroundColor:c,...Ne,text:A,originalText:e.title??A,x:n+m/2,y:w-Pa-D.height/2,fontFamily:I,fontSize:T,lineHeight:C,textAlign:"center"}):null,k=s?Array.from({length:gf},(z,U)=>{let K=(U+1)/gf,G=g*K,te=b.map(F=>Ba(Math.cos(F)*G,Math.sin(F)*G));return te.push(Ba(te[0][0],te[0][1])),Sf({backgroundColor:"transparent",...Ne,type:"line",x:u,y:E,width:G*2,height:G*2,strokeStyle:"solid",roughness:VI.architect,opacity:ni,polygon:!0,points:te})}):[],L=b.map(z=>{let U=Math.cos(z)*g,K=Math.sin(z)*g;return Sf({backgroundColor:"transparent",...Ne,type:"line",x:u,y:E,width:Math.abs(U),height:Math.abs(K),strokeStyle:"solid",roughness:VI.architect,opacity:ni,points:[Ba(0,0),Ba(U,K)]})}),B=i.map((z,U)=>{let K=b.map((G,te)=>{let F=z.values[te]??0,W=a(F,te)*g;return Ba(Math.cos(G)*W,Math.sin(G)*W)});return K.push(Ba(K[0][0],K[0][1])),Sf({backgroundColor:"transparent",...Ne,type:"line",x:u,y:E,width:g*2,height:g*2,strokeColor:d[U],strokeWidth:2,polygon:!0,points:K})}),V=Na(i,d,u,x,t+oo*5,c);return[..._?[_]:[],...y,...k,...L,...B,...V]};var Cf=(e,n,t,o,r)=>e==="line"?UI(n,t,o,r):e==="radar"?YI(n,t,o,r):GI(n,t,o,r);import{clamp as zm,pointFrom as Fa,pointsEqual as RB,bezierEquation as tT,pointRotateRads as Gm,pointDistance as NB}from"@excalidraw/math";import{arrayToMap as BB,BIND_MODE_TIMEOUT as Al,DEFAULT_TRANSFORM_HANDLE_SPACING as nT,FRAME_STYLE as En,getFeatureFlag as FB,invariant as jI,shouldRotateWithDiscreteAngle as oT,THEME as ko}from"@excalidraw/common";import{deconstructDiamondElement as Df,deconstructRectanguloidElement as rT,elementCenterPoint as Oa,getDiamondBaseCorners as OB,FOCUS_POINT_SIZE as zB,getOmitSidesForEditorInterface as Pf,getTransformHandles as GB,getTransformHandlesFromCoords as HB,hasBoundingBox as UB,hitElementItself as WB,isArrowElement as iT,isBindableElement as aT,isElbowArrow as za,isFrameLikeElement as Ga,isImageElement as Hm,isLinearElement as VB,isLineElement as YB,maxBindingDistance_simple as XB,isTextElement as KB,LinearElementEditor as bn,getActiveTextElement as $B,getElementsInGroup as Lf,getSelectedGroupIds as ZB,isSelectedViaGroup as jB,selectGroupsFromGivenElements as qB}from"@excalidraw/element";import{renderSelectionElement as JB}from"@excalidraw/element";import{getCommonBounds as _f,getElementAbsoluteCoords as Ll}from"@excalidraw/element";import{getGlobalFixedPointForBindableElement as qI,isFocusPointVisible as QB}from"@excalidraw/element";import{pointFrom as Pt}from"@excalidraw/math";import{THEME as kB}from"@excalidraw/common";var MB="#ff6b6b",AB="#ff0000",XI=1,KI=2,$I=(e,n)=>{if(!n.snapLines.length)return;let t=n.theme===kB.LIGHT||n.zenModeEnabled?MB:AB,o=(n.zenModeEnabled?XI*1.5:XI)/n.zoom.value;e.save(),e.translate(n.scrollX,n.scrollY);for(let r of n.snapLines)r.type==="pointer"?(e.lineWidth=o,e.strokeStyle=t,LB(r,e,n)):r.type==="gap"?(e.lineWidth=o,e.strokeStyle=t,_B(r.points[0],r.points[1],r.direction,n,e)):r.type==="points"&&(e.lineWidth=o,e.strokeStyle=t,DB(r,e,n));e.restore()},DB=(e,n,t)=>{if(!t.zenModeEnabled){let o=e.points[0],r=e.points[e.points.length-1];fn(o,r,n)}for(let o of e.points)ZI(o,t,n)},LB=(e,n,t)=>{ZI(e.points[0],t,n),t.zenModeEnabled||fn(e.points[0],e.points[1],n)},ZI=([e,n],t,o)=>{o.save();let r=(t.zenModeEnabled?KI*1.5:KI)/t.zoom.value;o.beginPath(),o.moveTo(e-r,n-r),o.lineTo(e+r,n+r),o.moveTo(e+r,n-r),o.lineTo(e-r,n+r),o.stroke(),o.restore()},fn=(e,n,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(n[0],n[1]),t.stroke()},_B=(e,n,t,o,r)=>{let i=8/o.zoom.value,a=i/2,s=i/4;if(t==="horizontal"){let l=[(e[0]+n[0])/2,e[1]];o.zenModeEnabled||fn(Pt(e[0],e[1]-i),Pt(e[0],e[1]+i),r),fn(Pt(l[0]-s,l[1]-a),Pt(l[0]-s,l[1]+a),r),fn(Pt(l[0]+s,l[1]-a),Pt(l[0]+s,l[1]+a),r),o.zenModeEnabled||(fn(Pt(n[0],n[1]-i),Pt(n[0],n[1]+i),r),fn(e,n,r))}else{let l=[e[0],(e[1]+n[1])/2];o.zenModeEnabled||fn(Pt(e[0]-i,e[1]),Pt(e[0]+i,e[1]),r),fn(Pt(l[0]-a,l[1]-s),Pt(l[0]+a,l[1]-s),r),fn(Pt(l[0]-a,l[1]+s),Pt(l[0]+a,l[1]+s),r),o.zenModeEnabled||(fn(Pt(n[0]-i,n[1]),Pt(n[0]+i,n[1]),r),fn(e,n,r))}};var eF=(e,n)=>{jI(n.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=n.selectedLinearElement;jI(t,"midPointCoords is null"),Um(t,e,n)},tF=(e,n,t)=>{let{elementId:o,hoverPointIndex:r}=n.selectedLinearElement;if(n.selectedLinearElement?.isEditing&&n.selectedLinearElement?.selectedPointsIndices?.includes(r)||n.selectedLinearElement?.isDragging)return;let i=bn.getElement(o,t);if(!i)return;let a=bn.getPointAtIndexGlobalCoordinates(i,r,t);Um(a,e,n)},Um=(e,n,t)=>{n.save(),n.translate(t.scrollX,t.scrollY),n.fillStyle="rgba(105, 101, 219, 0.4)",hs(n,e[0],e[1],bn.POINT_HANDLE_SIZE/t.zoom.value,!1),n.restore()},nF=(e,n,t)=>{let{elementId:o,anchor:r}=n.hoveredArrowTextAnchor,i=t.get(o);if(!i||!iT(i)||i.isDeleted)return;let a=r==="label"?bn.getBoundTextElementCenter(i,t):bn.getPointAtIndexGlobalCoordinates(i,r==="start"?0:-1,t);Um(a,e,n)},kf=(e,n,t,o,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)"),hs(e,t[0],t[1],(a?o*(n.selectedLinearElement?.isEditing?1.5:2):o)/n.zoom.value,!i,!a||r)},oF=(e,n,t,o,r,i=!1)=>{let a=n.element.frameId&&t.get(n.element.frameId);switch(a&&Ga(a)&&(e.translate(a.x,a.y),e.beginPath(),En.radius&&e.roundRect?e.roundRect(-1,-1,a.width+1,a.height+1,En.radius/o.zoom.value):e.rect(-1,-1,a.width+1,a.height+1),e.clip(),e.translate(-a.x,-a.y)),n.element.type){case"magicframe":case"frame":e.save(),e.translate(n.element.x,n.element.y),e.lineWidth=En.strokeWidth/o.zoom.value,e.strokeStyle=o.theme===ko.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",En.radius&&e.roundRect?(e.beginPath(),e.roundRect(0,0,n.element.width,n.element.height,En.radius/o.zoom.value),e.stroke(),e.closePath()):e.strokeRect(0,0,n.element.width,n.element.height),e.restore();break;default:e.save();let s=Oa(n.element,t);switch(e.translate(s[0],s[1]),e.rotate(n.element.angle),e.translate(-s[0],-s[1]),e.translate(n.element.x,n.element.y),e.lineWidth=zm(1.75,n.element.strokeWidth,4)/Math.max(.25,o.zoom.value),e.strokeStyle=o.theme===ko.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",n.element.type){case"ellipse":e.beginPath(),e.ellipse(n.element.width/2,n.element.height/2,n.element.width/2,n.element.height/2,0,0,2*Math.PI),e.closePath(),e.stroke();break;case"diamond":{let[l,c]=Df(n.element);l.forEach(d=>{e.beginPath(),e.moveTo(d[0][0]-n.element.x,d[0][1]-n.element.y),e.lineTo(d[1][0]-n.element.x,d[1][1]-n.element.y),e.stroke()}),c.forEach(d=>{let[m,p,u,E]=d;e.beginPath(),e.moveTo(m[0]-n.element.x,m[1]-n.element.y),e.bezierCurveTo(p[0]-n.element.x,p[1]-n.element.y,u[0]-n.element.x,u[1]-n.element.y,E[0]-n.element.x,E[1]-n.element.y),e.stroke()})}break;default:{let[l,c]=rT(n.element);l.forEach(d=>{e.beginPath(),e.moveTo(d[0][0]-n.element.x,d[0][1]-n.element.y),e.lineTo(d[1][0]-n.element.x,d[1][1]-n.element.y),e.stroke()}),c.forEach(d=>{let[m,p,u,E]=d;e.beginPath(),e.moveTo(m[0]-n.element.x,m[1]-n.element.y),e.bezierCurveTo(p[0]-n.element.x,p[1]-n.element.y,u[0]-n.element.x,u[1]-n.element.y,E[0]-n.element.x,E[1]-n.element.y),e.stroke()})}break}e.restore();break}if(o.isMidpointSnappingEnabled&&!o.gridModeEnabled&&!i&&(Ga(n.element)||aT(n.element))){let s=o.selectedLinearElement,l=s?.elementId&&bn.getElement(s?.elementId,t),c=r&&WB({point:r,element:n.element,elementsMap:t,threshold:0,overrideShouldTestInside:!0}),d=l&&za(l)||o.activeTool.type==="arrow"&&o.currentItemArrowType==="elbow";if(!c||d){e.save();let m=Oa(n.element,t),p;if(n.element.type==="diamond"){let b=Oa(n.element,t);p=OB(n.element).map(y=>{let w=tT(y,.5),x=Gm(w,b,n.element.angle);return Fa(x[0],x[1])})}else p=[{x:n.element.width,y:n.element.height/2},{x:n.element.width/2,y:n.element.height},{x:0,y:n.element.height/2},{x:n.element.width/2,y:0}].map(y=>{let w=Fa(y.x+n.element.x,y.y+n.element.y),x=Gm(w,m,n.element.angle);return Fa(x[0],x[1])});let u=r&&p.reduce((b,y,w)=>{let x=NB(y,r);return w===-1||x<b.distance?{idx:w,distance:x}:b},{idx:-1,distance:1/0}),E=4/o.zoom.value,g=XB(o.zoom)+n.element.strokeWidth/2;p.forEach((b,y)=>{let w=(!c||d)&&u?.idx===y&&u.distance<=g,x=!w&&(d||y===u?.idx&&u.distance<=g*2);w?(e.fillStyle=o.theme===ko.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",e.beginPath(),e.arc(b[0],b[1],E,0,2*Math.PI),e.fill()):x&&(e.fillStyle=o.theme===ko.DARK?"rgba(0, 0, 0, 0.8)":"rgba(65, 65, 65, 0.5)",e.beginPath(),e.arc(b[0],b[1],E,0,2*Math.PI),e.fill())}),e.restore()}}},rF=(e,n,t,o,r,i,a)=>{let s=e.state.bindMode==="orbit"&&e.bindModeHandler!==null,l=Al-(a?.runtime??(s?0:Al)),c=zm(1/Al*l,1e-4,1),d=t.strokeWidth/2,m=t.frameId&&o.get(t.frameId);switch(m&&Ga(m)&&(n.translate(m.x,m.y),n.beginPath(),En.radius&&n.roundRect?n.roundRect(-1,-1,m.width+1,m.height+1,En.radius/r.zoom.value):n.rect(-1,-1,m.width+1,m.height+1),n.clip(),n.translate(-m.x,-m.y)),t.type){case"magicframe":case"frame":n.save(),n.translate(t.x,t.y),n.lineWidth=En.strokeWidth/r.zoom.value,n.strokeStyle=r.theme===ko.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,En.radius&&n.roundRect?(n.beginPath(),n.roundRect(0,0,t.width,t.height,En.radius/r.zoom.value),n.stroke(),n.closePath()):n.strokeRect(0,0,t.width,t.height),n.restore();break;default:n.save();let u=Oa(t,o),E=u[0]+r.scrollX,g=u[1]+r.scrollY;switch(n.translate(E,g),n.rotate(t.angle),n.translate(-E,-g),n.translate(t.x+r.scrollX-d,t.y+r.scrollY-d),n.lineWidth=zm(2.5,t.strokeWidth*1.75,4)/Math.max(.25,r.zoom.value),n.strokeStyle=r.theme===ko.DARK?`rgba(3, 93, 161, ${c/2})`:`rgba(106, 189, 252, ${c/2})`,t.type){case"ellipse":n.beginPath(),n.ellipse((t.width+d*2)/2,(t.height+d*2)/2,(t.width+d*2)/2,(t.height+d*2)/2,0,0,2*Math.PI),n.closePath(),n.stroke();break;case"diamond":{let[b,y]=Df(t,d);b.forEach(w=>{n.beginPath(),n.moveTo(w[0][0]-t.x+d,w[0][1]-t.y+d),n.lineTo(w[1][0]-t.x+d,w[1][1]-t.y+d),n.stroke()}),y.forEach(w=>{let[x,I,T,C]=w;n.beginPath(),n.moveTo(x[0]-t.x+d,x[1]-t.y+d),n.bezierCurveTo(I[0]-t.x+d,I[1]-t.y+d,T[0]-t.x+d,T[1]-t.y+d,C[0]-t.x+d,C[1]-t.y+d),n.stroke()})}break;default:{let[b,y]=rT(t,d);b.forEach(w=>{n.beginPath(),n.moveTo(w[0][0]-t.x+d,w[0][1]-t.y+d),n.lineTo(w[1][0]-t.x+d,w[1][1]-t.y+d),n.stroke()}),y.forEach(w=>{let[x,I,T,C]=w;n.beginPath(),n.moveTo(x[0]-t.x+d,x[1]-t.y+d),n.bezierCurveTo(I[0]-t.x+d,I[1]-t.y+d,T[0]-t.x+d,T[1]-t.y+d,C[0]-t.x+d,C[1]-t.y+d),n.stroke()})}break}n.restore();break}if(!s||(a?.runtime??0)>Al)return;let p=.5*(Math.min(t.width,t.height)/2);if(!Ga(t)){n.save(),n.translate(t.x+r.scrollX,t.y+r.scrollY);let u=1/Al*l;if(n.strokeStyle="rgba(0, 0, 0, 0.2)",n.lineWidth=1/r.zoom.value,n.setLineDash([4/r.zoom.value,4/r.zoom.value]),n.lineDashOffset=-u*10/r.zoom.value,n.beginPath(),n.ellipse(t.width/2,t.height/2,p,p,0,0,2*Math.PI),n.stroke(),n.fillStyle="rgba(0, 0, 0, 0.04)",n.beginPath(),n.ellipse(t.width/2,t.height/2,p*(1-c),p*(1-c),0,0,2*Math.PI),n.fill(),n.restore(),r.isMidpointSnappingEnabled&&!r.gridModeEnabled&&(!e.lastPointerMoveEvent||!oT(e.lastPointerMoveEvent))){n.save(),n.translate(t.x+r.scrollX,t.y+r.scrollY);let E=5/r.zoom.value,g=5/r.zoom.value,b=E+g,y;if(t.type==="diamond"){let[,w]=Df(t),x=Oa(t,o);y=w.map(I=>{let T=tT(I,.5),C=Gm(T,x,t.angle);return{x:C[0]-t.x,y:C[1]-t.y}})}else{let w=Oa(t,o);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(I=>{let T=Fa(I.x+t.x,I.y+t.y),C=Gm(T,w,t.angle);return{x:C[0]-t.x,y:C[1]-t.y}})}y.forEach(w=>{n.clearRect(w.x-b,w.y-b,b*2,b*2)}),n.fillStyle=r.theme===ko.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,y.forEach(w=>{n.beginPath(),n.arc(w.x,w.y,E,0,2*Math.PI),n.fill()}),n.restore()}}return{runtime:(a?.runtime??0)+i}},iF=(e,n,t,o,r,i,a)=>{if(t===null)return;if(FB("COMPLEX_BINDINGS"))return rF(e,n,t.element,o,r,i,a);n.save(),n.translate(r.scrollX,r.scrollY);let s=e.lastPointerMoveCoords?Fa(e.lastPointerMoveCoords.x,e.lastPointerMoveCoords.y):null,l=!!e.lastPointerMoveEvent&&oT(e.lastPointerMoveEvent);oF(n,t,o,r,s,l),n.restore()},sT=(e,n,t)=>{let{angle:o,x1:r,y1:i,x2:a,y2:s,selectionColors:l,cx:c,cy:d,dashed:m,activeEmbeddable:p}=t,u=a-r,E=s-i,b=(t.padding??nT*2)/n.zoom.value,y=8/n.zoom.value,w=4/n.zoom.value;e.save(),e.translate(n.scrollX,n.scrollY),e.lineWidth=(p?4:1)/n.zoom.value;let x=l.length;for(let I=0;I<x;++I)e.strokeStyle=l[I],m&&e.setLineDash([y,w+(y+w)*(x-1)]),e.lineDashOffset=(y+w)*I,gs(e,r-b,i-b,u+b*2,E+b*2,c,d,o);e.restore()},aF=(e,n,t,o)=>{let[r,i,a,s]=Ll(t,o),l=a-r,c=s-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=En.strokeWidth/n.zoom.value,e.save(),e.translate(n.scrollX,n.scrollY),gs(e,r,i,l,c,r+l/2,i+c/2,t.angle,!1,En.radius/n.zoom.value),e.restore()},JI=(e,n,t,o)=>{let{colors:r=["rgb(0,118,255)"],dashed:i=!1}=o||{},a=t.filter(d=>d.groupIds.length===0),s=t.filter(d=>d.groupIds.length>0),l=d=>{let[m,p,u,E]=_f(d);return{angle:0,x1:m,x2:u,y1:p,y2:E,selectionColors:r,dashed:i,cx:m+(u-m)/2,cy:p+(E-p)/2,activeEmbeddable:!1}},c=d=>{let m=Lf(t,d);return l(m)};Object.entries(qB(s,n)).filter(([d,m])=>m).map(([d,m])=>d).map(d=>c(d)).concat(a.map(d=>l([d]))).forEach(d=>sT(e,n,d))},Mf=(e,n,t,o)=>{if(!n.selectedLinearElement)return;e.save(),e.translate(n.scrollX,n.scrollY),e.lineWidth=1/n.zoom.value;let r=bn.getPointsGlobalCoordinates(t,o),{POINT_HANDLE_SIZE:i}=bn,a=n.selectedLinearElement?.isEditing?i:i/2,s=za(t),l=YB(t);if(r.forEach((c,d)=>{if(s&&d!==0&&d!==r.length-1)return;let m=d>0&&(d!==r.length-1||!l||!t.polygon)&&RB(c,d===r.length-1?r[0]:r[d-1],2/n.zoom.value),p=!!n.selectedLinearElement?.isEditing&&!!n.selectedLinearElement?.selectedPointsIndices?.includes(d);l&&t.polygon&&!p&&d===t.points.length-1&&n.selectedLinearElement?.isEditing&&n.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(p=!0),kf(e,n,c,a,p,!1,m)}),za(t)){let c=t.fixedSegments?.map(d=>d.index)||[];r.slice(0,-1).forEach((d,m)=>{bn.isSegmentTooShort(t,r[m+1],r[m],m,n.zoom,o)||kf(e,n,Fa((d[0]+r[m+1][0])/2,(d[1]+r[m+1][1])/2),i/2,!1,!c.includes(m+1),!1)})}else bn.getEditorMidPoints(t,o,n).filter((d,m,p)=>d!==null&&!(za(t)&&(m===0||m===p.length-1))).forEach(d=>{(n.selectedLinearElement?.isEditing||r.length===2)&&kf(e,n,d,i/2,!1,!0,!1)});e.restore()},sF=(e,n,t,o)=>{e.save(),e.translate(n.scrollX,n.scrollY),e.strokeStyle="rgba(134, 131, 226, 0.6)",e.lineWidth=1/n.zoom.value,e.setLineDash([4/n.zoom.value,4/n.zoom.value]),e.beginPath(),e.moveTo(t[0],t[1]),e.lineTo(o[0],o[1]),e.stroke(),e.restore()},lF=(e,n,t,o,r)=>{e.save(),e.translate(n.scrollX,n.scrollY),e.strokeStyle="rgba(134, 131, 226, 0.6)",e.lineWidth=1/n.zoom.value,e.setLineDash([]),e.fillStyle=r?"rgba(134, 131, 226, 0.9)":"rgba(255, 255, 255, 0.9)",hs(e,t[0],t[1],o/n.zoom.value,!0,!0),e.restore()},QI=({arrow:e,appState:n,type:t,context:o,elementsMap:r})=>{let i=t==="start"?e.startBinding:e.endBinding,a=i?.elementId&&r.get(i.elementId);if(!a||!aT(a)||a.isDeleted)return;let s=qI(i.fixedPoint,a,r);if(!QB(s,e,a,r,n,t))return;let l=n.selectedLinearElement,c=!!l?.isDragging,d=t==="start"?0:e.points.length-1,m=!!l?.selectedPointsIndices?.includes(d);if(l?.hoveredFocusPointBinding===t&&!l.draggedFocusPointBinding&&Um(s,o,n),!(m&&c)){let p=qI(i.fixedPoint,a,r),u=l?.hoveredFocusPointBinding===t,E=bn.getPointAtIndexGlobalCoordinates(e,d,r);sF(o,n,E,p),lF(o,n,p,zB/1.5,u)}},eT=(e,n,t,o,r)=>{Object.keys(o).forEach(i=>{let a=o[i];if(a!==void 0){let[s,l,c,d]=a;e.save(),e.lineWidth=1/t.zoom.value,n.selectionColor&&(e.strokeStyle=n.selectionColor),i==="rotation"?hs(e,s+c/2,l+d/2,c/2,!0):e.roundRect?(e.beginPath(),e.roundRect(s,l,c,d,2/t.zoom.value),e.fill(),e.stroke()):gs(e,s,l,c,d,s+c/2,l+d/2,r,!0),e.restore()}})},cF=(e,n,t,o,r)=>{let[i,a,,,s,l]=Ll(o,r),c=3,d=20,m=c/t.zoom.value,p=m/2,u=s-i+m,E=l-a+m,g=Math.min(d/t.zoom.value,u),b=Math.min(d/t.zoom.value,E);e.save(),e.fillStyle=n.selectionColor,e.strokeStyle=n.selectionColor,e.lineWidth=m,[[[-u,-E],[0,p],[g,p],[p,0],[p,b]],[[u-p,-E],[p,p],[-g+p,p],[0,0],[0,b]],[[-u,E],[0,-p],[g,-p],[p,0],[p,-b]],[[u-p,E],[p,-p],[-g+p,-p],[0,0],[0,-b]]].forEach(w=>{let[[x,I],[T,C],[P,A],[D,_],[k,L]]=w;e.save(),e.translate(s,l),e.rotate(o.angle),e.beginPath(),e.moveTo(x+T,I+C),e.lineTo(x+P,I+A),e.stroke(),e.beginPath(),e.moveTo(x+D,I+_),e.lineTo(x+k,I+L),e.stroke(),e.restore()}),e.restore()},dF=(e,n,t,o)=>{n.save();let r=af(t.zoom.value),i=e.width+r*2,a=e.height+r*2,s=e.x+e.width/2,l=e.y+e.height/2,c=-(e.width/2+r),d=-(e.height/2+r);n.translate(s+t.scrollX,l+t.scrollY),n.rotate(e.angle),n.lineWidth=1/t.zoom.value,n.strokeStyle=o,n.globalAlpha=.5,n.setLineDash([6/t.zoom.value,4/t.zoom.value]),n.strokeRect(c,d,i,a),n.restore()},mF=(e,n,t,o,r)=>{let i=sf(e,t.zoom.value,r);i&&(n.save(),n.globalAlpha=.5,n.lineWidth=1.5/t.zoom.value,n.lineCap="round",n.strokeStyle=o,n.beginPath(),n.moveTo(i.start[0]+t.scrollX,i.start[1]+t.scrollY),n.lineTo(i.end[0]+t.scrollX,i.end[1]+t.scrollY),n.stroke(),n.restore())},pF=(e,n,t,o,r,i)=>{for(let a of n){if(!Hm(a)||!a.fileId)continue;let s=o.imageStatus.get(a.fileId);if(!!s?.downloadError){let d=Dl(a,t,r,"center");d&&cT(e,d.centerX+r.scrollX,d.centerY+r.scrollY,d.radius,r,s?.downloadError??void 0)}else{let d=o.imageLoadingProgress.get(a.fileId);if(d!==void 0){let m=Dl(a,t,r,"center");m&&lT(e,m.centerX+r.scrollX,m.centerY+r.scrollY,m.radius,m.lineWidth,d,r,i)}}let c=s?.uploadProgress;if(c){let d=Dl(a,t,r,"top-right");d&&hF(e,d.centerX+r.scrollX,d.centerY+r.scrollY,d.radius,d.lineWidth,c,r,i)}}},Dl=(e,n,t,o)=>{if(!Hm(e))return null;let[r,i,a,s]=Ll(e,n),l=t.zoom.value,c=Math.min(a-r,s-i)*l,d=Math.min(o==="center"?14:11.7,c/(o==="center"?4:4.62))/l,m=Math.min((o==="center"?3:2.6)/l,d/2);if(d<=0||m<=0)return null;if(o==="top-right"){let p=6/l;return{centerX:a-p-d,centerY:i+p+d,radius:d,lineWidth:m}}return{centerX:(r+a)/2,centerY:(i+s)/2,radius:d,lineWidth:m}},lT=(e,n,t,o,r,i,a,s,l)=>{e.save(),e.lineWidth=r,e.lineCap="round",e.strokeStyle=l?.trackColor??(a.theme===ko.DARK?"rgba(255, 255, 255, 0.35)":"rgba(0, 0, 0, 0.25)"),e.beginPath(),e.arc(n,t,o,0,Math.PI*2),e.stroke(),i>0&&(e.strokeStyle=l?.color??s,e.beginPath(),e.arc(n,t,o,-Math.PI/2,-Math.PI/2+Math.PI*2*zm(i,0,1)),e.stroke()),e.restore()},Af=(e,n)=>typeof window>"u"?n:window.getComputedStyle(document.documentElement).getPropertyValue(e).trim()||n,uF=(e,n,t,o,r)=>{e.save(),e.strokeStyle=r.color,e.lineWidth=r.lineWidth,e.lineCap="round",e.lineJoin="round",e.beginPath(),e.moveTo(n-o*.48,t+o*.26),e.bezierCurveTo(n-o*.68,t+o*.14,n-o*.58,t-o*.22,n-o*.34,t-o*.22),e.bezierCurveTo(n-o*.14,t-o*.48,n+o*.26,t-o*.48,n+o*.34,t-o*.18),e.bezierCurveTo(n+o*.58,t-o*.2,n+o*.7,t+o*.26,n+o*.42,t+o*.26),e.lineTo(n-o*.48,t+o*.26),e.stroke(),e.restore()},hF=(e,n,t,o,r,i,a,s)=>{let l=i.state??"uploading",c=i.color??Af("--color-primary",s),d=i.color??Af("--color-warning-darkest","#ec8b14");if(l==="failed"){cT(e,n,t,o,a,{color:i.color??Af("--color-danger","#e03131")});return}if(l==="uploading"&&lT(e,n,t,o,r,i.progress??0,a,s,{color:c,trackColor:i.trackColor}),uF(e,n,t-o*.02,o*1.125,{color:l==="error"?d:c,lineWidth:Math.max(r*.75,1/a.zoom.value)}),l==="error"){e.save(),e.strokeStyle=d,e.fillStyle=d,e.lineWidth=Math.max(r*.75,1/a.zoom.value),e.lineCap="round",e.beginPath();let m=o*.18,p=t-o*.09;e.moveTo(n-m,p-m),e.lineTo(n+m,p+m),e.moveTo(n+m,p-m),e.lineTo(n-m,p+m),e.stroke(),e.restore()}else l==="pending"&&(e.save(),e.strokeStyle=c,e.lineWidth=Math.max(r*.65,1/a.zoom.value),e.lineCap="round",e.beginPath(),e.moveTo(n,t+o*.072),e.lineTo(n,t-o*.18),e.moveTo(n-o*.144,t-o*.036),e.lineTo(n,t-o*.18),e.lineTo(n+o*.144,t-o*.036),e.stroke(),e.restore())},cT=(e,n,t,o,r,i)=>{e.save();let a=i?.color??"#e03131",s=Math.max(o*.16,1.5/r.zoom.value);i?.backgroundColor&&(e.fillStyle=i.backgroundColor,e.beginPath(),e.arc(n,t,o,0,Math.PI*2),e.fill()),e.strokeStyle=a,e.lineWidth=s,e.beginPath(),e.arc(n,t,o,0,Math.PI*2),e.stroke(),e.strokeStyle=a,e.fillStyle=a,e.lineCap="round",e.beginPath(),e.moveTo(n,t-o*.45),e.lineTo(n,t+o*.12),e.stroke(),e.beginPath(),e.arc(n,t+o*.48,o*.11,0,Math.PI*2),e.fill(),i?.text&&(e.font=`600 ${Math.max(11/r.zoom.value,o*.65)}px Assistant, system-ui, BlinkMacSystemFont, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif`,e.textAlign="center",e.textBaseline="top",e.fillText(i.text,n,t+o+6/r.zoom.value)),e.restore()},gF=({app:e,canvas:n,elementsMap:t,visibleElements:o,selectedElements:r,allElementsMap:i,scale:a,appState:s,renderConfig:l,editorInterface:c,animationState:d,deltaTime:m})=>{if(n===null)return{};let[p,u]=Tc(n,a),E=d,g=Sc({canvas:n,scale:a,normalizedWidth:p,normalizedHeight:u});g.save(),g.scale(s.zoom.value,s.zoom.value);let b;if(o.forEach(C=>{s.selectedLinearElement?.isEditing&&s.selectedLinearElement.elementId===C.id&&C&&(b=C)}),b&&Mf(g,s,b,t),s.selectionElement&&!s.isCropping)try{JB(s.selectionElement,g,s,l.selectionColor)}catch(C){console.error(C)}let y=$B(r,s);if(y&&!y.autoResize&&mF(y,g,s,l.selectionColor,c.formFactor),s.editingTextElement){let C=i.get(s.editingTextElement.id);C&&!C.autoResize&&dF(C,g,s,l.selectionColor)}if(s.isBindingEnabled&&s.suggestedBinding?E={...d,bindingHighlight:iF(e,g,s.suggestedBinding,i,s,m,d?.bindingHighlight)}:E={...d,bindingHighlight:void 0},s.hoveredArrowTextAnchor&&nF(g,s,i),s.frameToHighlight&&aF(g,s,s.frameToHighlight,t),s.elementsToHighlight&&JI(g,s,s.elementsToHighlight),s.activeLockedId){let C=i.get(s.activeLockedId),P=C?[C]:Lf(i,s.activeLockedId);JI(g,s,P,{colors:["#ced4da"],dashed:!0})}let w=r.some(C=>Ga(C));r.length===1&&s.selectedLinearElement?.isEditing&&s.selectedLinearElement.elementId===r[0].id&&Mf(g,s,r[0],t);let x=s.selectedLinearElement,I=x&&bn.getElement(x.elementId,i);if(I&&(s.selectedLinearElement.isDragging||(x.segmentMidPointHoveredCoords?eF(g,s):(za(I)?x.hoverPointIndex===0||x.hoverPointIndex===I.points.length-1:x.hoverPointIndex>=0)&&tF(g,s,t)),iT(I)&&(QI({arrow:I,elementsMap:i,appState:s,context:g,type:"start"}),QI({arrow:I,elementsMap:i,appState:s,context:g,type:"end"}))),!s.multiElement&&!s.newElement&&!s.selectedLinearElement?.isEditing){let C=UB(r,s,c),P=r.length===1&&VB(r[0]);P&&s.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&Mf(g,s,r[0],t);let A=l.selectionColor||"#000";if(C){let D=BB(r),_=[];for(let L of t.values()){let B=[],V=l.remoteSelectedElementIds.get(L.id);if(P&&za(L)&&(L.startBinding||L.endBinding)||(D.has(L.id)&&!jB(s,L)&&B.push(A),V&&B.push(...V.map(z=>$r(z,s.collaborators.get(z))))),B.length){let[z,U,K,G,te,F]=Ll(L,t,!0);_.push({angle:L.angle,x1:z,y1:U,x2:K,y2:G,selectionColors:L.locked?["#ced4da"]:B,dashed:!!V||L.locked,cx:te,cy:F,activeEmbeddable:s.activeEmbeddable?.element===L&&s.activeEmbeddable.state==="active",padding:L.id===s.croppingElementId||Hm(L)?0:void 0})}}let k=L=>{let B=Lf(t,L),[V,z,U,K]=_f(B);_.push({angle:0,x1:V,x2:U,y1:z,y2:K,selectionColors:B.some(G=>G.locked)?["#ced4da"]:["#000"],dashed:!0,cx:V+(U-V)/2,cy:z+(K-z)/2,activeEmbeddable:!1})};for(let L of ZB(s))k(L);s.editingGroupId&&k(s.editingGroupId),_.forEach(L=>sT(g,s,L))}if(g.save(),g.translate(s.scrollX,s.scrollY),r.length===1){g.fillStyle="#fff";let D=GB(r[0],s.zoom,t,"mouse",Pf(c));if(!s.viewModeEnabled&&C&&!KB(s.editingTextElement)&&!s.croppingElementId&&eT(g,l,s,D,r[0].angle),s.croppingElementId&&!s.isCropping){let _=t.get(s.croppingElementId);_&&Hm(_)&&cF(g,l,s,_,t)}}else if(r.length>1&&!s.isRotating&&!r.some(D=>D.locked)){let D=nT*2/s.zoom.value;g.fillStyle="#fff";let[_,k,L,B]=_f(r,t),V=g.getLineDash();g.setLineDash([2/s.zoom.value]);let z=g.lineWidth;g.lineWidth=1/s.zoom.value,g.strokeStyle=A,gs(g,_-D,k-D,L-_+D*2,B-k+D*2,(_+L)/2,(k+B)/2,0),g.lineWidth=z,g.setLineDash(V);let U=HB([_,k,L,B,(_+L)/2,(k+B)/2],0,s.zoom,"mouse",w?{...Pf(c),rotation:!0}:Pf(c));r.some(K=>!K.locked)&&eT(g,l,s,U,0)}g.restore()}s.searchMatches?.matches.forEach(({id:C,focus:P,matchedLines:A})=>{let D=t.get(C);if(D){let[_,k,,,L,B]=Ll(D,t,!0);g.save(),s.theme===ko.LIGHT?P?g.fillStyle="rgba(255, 124, 0, 0.4)":g.fillStyle="rgba(255, 226, 0, 0.4)":P?g.fillStyle="rgba(229, 82, 0, 0.4)":g.fillStyle="rgba(99, 52, 0, 0.4)";let V=Ga(D)?s.zoom.value:1;g.translate(s.scrollX,s.scrollY),g.translate(L,B),g.rotate(D.angle),A.forEach(z=>{(z.showOnCanvas||P)&&g.fillRect(_+z.offsetX/V-L,k+z.offsetY/V-B,z.width/V,z.height/V)}),g.restore()}}),$I(g,s),pF(g,o,t,e,s,l.selectionColor),g.restore(),Aw({context:g,renderConfig:l,appState:s,normalizedWidth:p,normalizedHeight:u});let T;return l.renderScrollbars&&(T=J2(t,p,u,s),g.save(),g.fillStyle=q2,g.strokeStyle="rgba(255,255,255,0.8)",[T.horizontal,T.vertical].forEach(C=>{C&&Jd(g,C.x,C.y,C.width,C.height,gn/2)}),g.restore()),{scrollBars:T,animationState:E}},Rf=e=>{let n=gF(e);return e.callback(n),n};import{useEffect as Bl,useMemo as dT,useRef as zf,useState as fF}from"react";import{bumpVersion as _l,getLinearElementSubType as Ua,mutateElement as Gf,updateElbowArrowPoints as EF}from"@excalidraw/element";import{pointFrom as Vm,pointRotateRads as bF}from"@excalidraw/math";import{hasBoundTextElement as xF,isArrowBoundToElement as yF,isArrowElement as wF,isElbowArrow as vF,isLinearElement as Vf,isUsingAdaptiveRadius as IF}from"@excalidraw/element";import{getCommonBoundingBox as TF,getElementAbsoluteCoords as SF}from"@excalidraw/element";import{getBoundTextElement as gT,getBoundTextMaxHeight as CF,getBoundTextMaxWidth as PF,redrawTextBoundingBox as kF}from"@excalidraw/element";import{wrapText as MF}from"@excalidraw/element";import{assertNever as AF,CLASSES as DF,getFontString as Nf,isProdEnv as LF,mapFind as _F,reduceToCommonValue as RF,ROUNDNESS as Bf,sceneCoordsToViewportCoords as NF,updateActiveTool as mT}from"@excalidraw/common";import{measureText as pT}from"@excalidraw/element";import{LinearElementEditor as BF}from"@excalidraw/element/linearElementEditor";import{newArrowElement as Ff,newElement as FF,newLinearElement as OF}from"@excalidraw/element";import{ShapeCache as zF}from"@excalidraw/element";import{updateBindings as GF}from"@excalidraw/element";import{jsx as Wf}from"react/jsx-runtime";var HF=8,UF=10,Rl=["rectangle","diamond","ellipse"],Nl=["line","sharpArrow","curvedArrow","elbowArrow"],WF=new Set(Rl),VF=new Set(Nl),Wa=e=>WF.has(e),Ym=e=>e==="arrow"||VF.has(e),ro=Je(null),Fl=new Map,Ol=new Map,YF=({app:e})=>{let n=e.scene.getSelectedElements(e.state),t=zf(null);return Bl(()=>{if(n.length===0){e.updateEditorAtom(ro,null);return}let o=Xm(n);o&&!t.current?t.current=o:(t.current&&!o||t.current&&o!==t.current)&&(e.updateEditorAtom(ro,null),t.current=null)},[n,e]),Bl(()=>()=>{Fl.clear(),Ol.clear()},[]),Wf(XF,{app:e,elements:n})},XF=({app:e,elements:n})=>{let t=Xm(n),o=dT(()=>t==="generic"?ET(n):[],[t,n]),r=dT(()=>t==="linear"?Uf(n):[],[t,n]),i=t==="generic"?o.every(m=>m.type===o[0].type):t==="linear"?r.every(m=>Ua(m)===Ua(r[0])):!1,[a,s]=fF({x:0,y:0}),l=zf(""),c=zf(null);Bl(()=>{let m=[...o,...r].sort((b,y)=>b.id.localeCompare(y.id)),p=`
18
- ${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${m.map(b=>b.id).join(",")}`;if(p===l.current)return;l.current=p;let u;if(m.length===1){let[b,,,y,w,x]=SF(m[0],e.scene.getNonDeletedElementsMap());u=bF(Vm(b,y),Vm(w,x),m[0].angle)}else{let{minX:b,maxY:y}=TF(m);u=Vm(b,y)}let{x:E,y:g}=NF({sceneX:u[0],sceneY:u[1]},e.state);s({x:E,y:g})},[o,r,e.scene,e.state]),Bl(()=>{for(let m of r){let p=Hf(m.id,qF(m));Ol.has(p)||Ol.set(p,m)}},[r]),Bl(()=>{for(let m of o)if(!Fl.has(m.id)){let p=gT(m,e.scene.getNonDeletedElementsMap());p&&Fl.set(m.id,{fontSize:p.fontSize})}},[o,e.scene]);let d=t==="linear"?[["line",Wo],["sharpArrow",Xo],["curvedArrow",$o],["elbowArrow",Ko]]:t==="generic"?[["rectangle",Mi],["diamond",Ai],["ellipse",Di]]:[];return Wf("div",{ref:c,tabIndex:-1,style:{position:"absolute",top:`${a.y+(UF+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-HF}px`,zIndex:2},className:DF.CONVERT_ELEMENT_TYPE_POPUP,children:d.map(([m,p])=>{let u=i&&(t==="generic"&&o[0].type===m||t==="linear"&&Ua(r[0])===m);return Wf($,{type:"toggle",icon:p,checked:u,title:m,"aria-label":m,"data-testid":`toolbar-${m}`,onSelect:()=>{u||(e.state.activeTool.type!==m&&Be("convertElementType",m,"ui"),Yf(e,{conversionType:t,nextType:m}),c.current?.focus())}},`${n[0].id}${n[0].version}_${m}`)})})},KF=(e,n,t)=>{let o=PF(e,n),r=CF(e,n),i=MF(n.text,Nf(n),o),a=pT(i,Nf(n),n.lineHeight),s=n.fontSize;for(;(a.width>o||a.height>r)&&s>0;){s-=1;let l={...n,fontSize:s};a=pT(n.text,Nf(l),n.lineHeight)}Gf(n,t.getNonDeletedElementsMap(),{fontSize:s,width:a.width,height:a.height}),kF(n,e,t)},Yf=(e,{conversionType:n,nextType:t,direction:o="right"})=>{if(!n)return!1;let r=e.scene.getSelectedElements(e.state),i=r.reduce((s,l)=>({...s,[l.id]:!0}),{}),a=o==="right"?1:-1;if(n==="generic"){let s=ET(r),c=s.every(d=>d.type===s[0].type)?Rl.indexOf(s[0].type):-1;if(t=t??Rl[(c+Rl.length+a)%Rl.length],t&&Wa(t)){let d={};for(let p of s){let u=hT(p,t,e);d[u.id]=u}let m=[];for(let p of e.scene.getElementsIncludingDeleted())d[p.id]?m.push(d[p.id]):m.push(p);e.scene.replaceAllElements(m);for(let p of Object.values(d)){let u=gT(p,e.scene.getNonDeletedElementsMap());u&&(Fl.get(p.id)&&Gf(u,e.scene.getNonDeletedElementsMap(),{fontSize:Fl.get(p.id)?.fontSize??u.fontSize}),KF(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:mT(p,{type:"selection"})}))}}if(n==="linear"){let s=Uf(r);if(!t){let c=RF(s,Ua),d=c?Nl.indexOf(c):-1;t=Nl[(d+Nl.length+a)%Nl.length]}if(Ym(t)){let c=[],d=e.scene.getElementsMapIncludingDeleted();for(let m of s){let p=Ol.get(Hf(m.id,t));if(p&&Ua(p)===t)d.set(p.id,p),c.push(p);else{let u=hT(m,t,e);d.set(u.id,u),c.push(u)}}e.scene.replaceAllElements(d);for(let m of c)if(Vf(m))if(vF(m)){let p=$F(m);if(p.length<2)continue;let u=[];for(let g=1;g<p.length-2;g++)u.push({start:p[g],end:p[g+1],index:g+1});let E=EF(m,e.scene.getNonDeletedElementsMap(),{points:p,fixedSegments:u});Gf(m,e.scene.getNonDeletedElementsMap(),{...E,endArrowhead:"arrow"})}else{let p=_F(["line","sharpArrow","curvedArrow"],u=>Ol.get(Hf(m.id,u)));if(p){let u=p.points;e.scene.mutateElement(m,{points:u})}}}let l=Uf(e.scene.getSelectedElements(e.state));e.setState(c=>({selectedElementIds:i,selectedLinearElement:l.length===1?new BF(l[0],e.scene.getNonDeletedElementsMap()):null,activeTool:mT(c,{type:"selection"})}))}return!0},Xm=e=>{if(e.length===0)return null;let n=!1;for(let t of e){if(Wa(t.type))return"generic";fT(t)&&(n=!0)}return n?"linear":null},fT=e=>Vf(e)&&(!wF(e)||!yF(e)&&!xF(e)),Hf=(e,n)=>`${e}:${n}`,ET=e=>e.filter(n=>Wa(n.type)),Uf=e=>e.filter(n=>fT(n)),Wm=20,Ha=(e,n)=>e[0]===n[0],Of=(e,n)=>e[1]===n[1],uT=(e,n)=>Ha(e,n)?Math.abs(e[1]-n[1]):Math.abs(e[0]-n[0]),$F=e=>{let n=[e.points[0]],t=ZF(e.points);for(let i=1;i<t.length;++i){let a=n[n.length-1],s=[...t[i]];Math.abs(s[0]-a[0])<Wm?s[0]=a[0]:Math.abs(s[1]-a[1])<Wm&&(s[1]=a[1]),Ha(a,s)||Of(a,s)||n.push(Vm(a[0],s[1])),n.push(s)}let o=[n[0]];for(let i=1;i<n.length-1;++i)Ha(n[i-1],n[i])&&Ha(n[i],n[i+1])||Of(n[i-1],n[i])&&Of(n[i],n[i+1])||o.push(n[i]);o.push(n[n.length-1]);let r=[o[0]];for(let i=1;i<o.length-1;++i){let a=r[r.length-1],s=o[i],l=o[i+1],c=Ha(a,s),d=Ha(s,l);if(c!==d){let m=uT(a,s),p=uT(s,l);if(m<Wm||p<Wm){if(p<m)c?l[0]=a[0]:l[1]=a[1];else if(d)for(let u=r.length-1;u>=0&&r[u][0]===a[0];--u)r[u][0]=s[0];else for(let u=r.length-1;u>=0&&r[u][1]===a[1];--u)r[u][1]=s[1];continue}}r.push(s)}return r.push(o[o.length-1]),r},ZF=e=>{if(e.length===0)return[];let n=[e[0]];for(let t=1;t<e.length;t++){let[o,r]=n[n.length-1],[i,a]=e[t];(o!==i||r!==a)&&n.push(e[t])}return n},hT=(e,n,t)=>{if(!jF(e.type,n)){if(!LF())throw Error(`Invalid conversion from ${e.type} to ${n}.`);return e}if(e.type===n)return e;if(zF.delete(e),Wa(n)){let o=_l(FF({...e,type:n,roundness:e.roundness?{type:IF(n)?Bf.ADAPTIVE_RADIUS:Bf.PROPORTIONAL_RADIUS}:e.roundness}));return GF(o,t.scene,t.state),o}if(Ym(n))switch(n){case"line":return _l(OF({...e,type:"line"}));case"sharpArrow":return _l(Ff({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return _l(Ff({...e,type:"arrow",elbowed:!1,roundness:{type:Bf.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return _l(Ff({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return AF(n,`unhandled conversion type: ${n}`),e},jF=(e,n)=>!!(Wa(e)&&Wa(n)||Ym(e)&&Ym(n)),qF=e=>Vf(e)?Ua(e):e.type,bT=YF;import{bindBindingElementToFixedPoint as JF,dragNewTextElement as QF,getBoundTextElement as eO,getEndpointBoundTextDragAnchor as tO,getTextBindingForArrowEndpoint as nO,getUnboundArrowEndpointAtPoint as oO,isArrowElement as rO,isBindingEnabled as iO,isEndpointBoundText as aO,isTextElement as sO}from"@excalidraw/element";import{pointFrom as lO}from"@excalidraw/math";var Km=class{constructor(n){this.app=n;v(this,"updateHoveredAnchor",n=>{let t=this.app.state.activeTool.type==="text"&&!this.app.state.editingTextElement&&!this.app.state.newElement?this.getAnchorAtPosition(n.x,n.y):null,o=this.app.state.hoveredArrowTextAnchor;return(o?.elementId!==t?.elementId||o?.anchor!==t?.anchor)&&this.app.setState({hoveredArrowTextAnchor:t}),t});v(this,"refresh",()=>{this.app.lastPointerMoveCoords&&this.updateHoveredAnchor(this.app.lastPointerMoveCoords)})}getBindableEndpointAtPosition(n,t){if(!iO(this.app.state))return null;let o=oO(lO(n,t),this.app.scene.getNonDeletedElements(),this.app.scene.getNonDeletedElementsMap(),this.app.state.zoom);if(!o||this.app.getTextElementAtPosition(n,t))return null;let r=this.app.getElementAtPosition(n,t,{includeLockedElements:!0});return r&&r.id!==o.arrow.id&&this.app.scene.getElementIndex(r.id)>this.app.scene.getElementIndex(o.arrow.id)?null:o}getAnchorAtPosition(n,t){let o=this.getBindableEndpointAtPosition(n,t);if(o)return{elementId:o.arrow.id,anchor:o.startOrEnd};let r=this.app.getTextBindableContainerAtPosition(n,t);return!rO(r)||eO(r,this.app.scene.getNonDeletedElementsMap())?null:this.app.getTextWysiwygSnappedToCenterPosition(n,t,this.app.state,r)?{elementId:r.id,anchor:"label"}:null}getTextBinding({arrow:n,startOrEnd:t},o){return nO(n,t,this.app.scene.getNonDeletedElementsMap(),o)}bindText({arrow:n,startOrEnd:t},o,r){JF(n,o,t,r,this.app.scene)}maybeDragNewText(n,t){return!sO(n)||!aO(n,this.app.scene.getNonDeletedElementsMap())?!1:(QF({newElement:n,...tO(n),pointerX:t.x,zoom:this.app.state.zoom.value,scene:this.app.scene}),!0)}};import{applyDarkModeFilter as cO,BUCKET_FILL_BACKGROUND_PICKS as dO,COLOR_PALETTE as yT,DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as mO,getSizeFromPoints as pO,isTransparent as uO,THEME as hO}from"@excalidraw/common";import{pointFrom as xT}from"@excalidraw/math";import{computeBucketFillPolygon as gO,isBucketFillCompatible as fO,isFrameLikeElement as EO,isRestylableFill as bO,newLinearElement as xO,ShapeCache as yO}from"@excalidraw/element";var Xf=dO.filter(e=>e!==yT.white),$m=class{constructor(n){this.app=n;v(this,"temporaryEyeDropper",null);v(this,"pending",null);v(this,"handlePointerDown",n=>{this.pending=n});v(this,"handlePointerUp",()=>{let n=this.pending;this.pending=null,n&&this.fill(n)});v(this,"cancel",()=>{this.pending=null});v(this,"cycleBackgroundColor",()=>{let n=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor),t=Xf.indexOf(n),o=Xf[(t+1)%Xf.length];this.app.actionManager.executeAction(wd,"keyboard",{currentItemBackgroundColor:o})});v(this,"openTemporaryEyeDropper",()=>{if(Et.get(zt))return;let n={colorPickerType:"elementBackground",keepOpenOnAlt:!0,onSelect:t=>{this.app.actionManager.executeAction(wd,"ui",{currentItemBackgroundColor:t})}};this.temporaryEyeDropper=n,this.app.updateEditorAtom(zt,n)});v(this,"closeTemporaryEyeDropper",()=>{let n=this.temporaryEyeDropper;this.temporaryEyeDropper=null,n&&Et.get(zt)===n&&this.app.updateEditorAtom(zt,null)});v(this,"restyle",n=>{let t=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor);n.backgroundColor===t&&n.fillStyle===this.app.state.currentItemFillStyle&&n.opacity===this.app.state.currentItemOpacity||(this.app.scene.mutateElement(n,{backgroundColor:t,fillStyle:this.app.state.currentItemFillStyle,opacity:this.app.state.currentItemOpacity}),yO.delete(n),this.app.scheduleCapture())});v(this,"fill",n=>{let t=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor),o=this.app.scene.getNonDeletedElements(),r=this.app.scene.getNonDeletedElementsMap(),i=xT(n.x,n.y),a=this.app.getElementAtPosition(i[0],i[1]),s=gO({point:i,elements:o,elementsMap:r});if(!s.ok){if(a&&fO(a)){this.restyle(a);return}s.reason==="too_complex"?this.app.setToast({message:f("bucketfill.tooComplex"),duration:3e3}):(s.reason==="open_region"||s.reason==="too_small"||s.reason==="invalid_polygon")&&this.app.setToast({message:f("bucketfill.noRegion"),duration:3e3});return}if(a&&bO({hitElement:a,scenePoints:s.scenePoints,elementsMap:r})){this.restyle(a);return}let{width:l,height:c}=pO(s.scenePoints),[d,m]=s.scenePoints[0],p=s.scenePoints.map(w=>xT(w[0]-d,w[1]-m)),u=s.ownerId?r.get(s.ownerId):null,E=u?EO(u)?u.id:u.frameId:this.app.getTopLayerFrameAtSceneCoords(n)?.id??null,g=u?u.groupIds:s.boundaryElementIds.map(w=>r.get(w)?.groupIds).filter(w=>!!w).reduce((w,x)=>w===null?x:w.filter(I=>x.includes(I)),null)??[],b=xO({type:"line",x:d,y:m,width:l,height:c,points:p,polygon:!0,strokeColor:"transparent",backgroundColor:t,fillStyle:this.app.state.currentItemFillStyle,strokeWidth:1,strokeStyle:"solid",roughness:0,roundness:null,opacity:this.app.state.currentItemOpacity,frameId:E,groupIds:g}),y=this.app.scene.getElementsIncludingDeleted().findIndex(w=>w.id===s.insertion.elementId);this.app.scene.insertElementsAtIndex([b],y<0?null:s.insertion.placement==="above"?y+1:y),this.app.scheduleCapture()});v(this,"getBucketFillBackgroundColor",(n,t)=>uO(n)?yT.green[mO]:cO(n,t===hO.DARK))}};import{CURSOR_TYPE as zl,MIME_TYPES as jm,THEME as wT}from"@excalidraw/common";var vT='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',wO='<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"/>',IT='<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"/>',vO=`data:${jm.svg},${encodeURIComponent(`${vT}${IT}</svg>`)}`,IO=`data:${jm.svg},${encodeURIComponent(`${vT}${wO}${IT}</svg>`)}`,TO=e=>{let n=Su.map((t,o)=>`<path d="${t}" ${o<2?`fill="${e}"`:""} />`).join("");return`data:${jm.svg},${encodeURIComponent(`<svg viewBox="0 0 24 24" width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke-linecap="round" stroke-linejoin="round"><g stroke="#fff" fill="#fff" stroke-width="5">${n}</g><g stroke="#1b1b1f" stroke-width="1.25">${n}</g></svg>`)}`},Zm=class{constructor(n){this.app=n;v(this,"toolCursorMemo",null);v(this,"eraserCanvasCache",null);v(this,"eraserPreviewDataURL",null);v(this,"set",n=>{this.toolCursorMemo=null,this.canvas&&(this.canvas.style.cursor=n)});v(this,"reset",()=>{this.app.state.viewModeEnabled&&!this.app.isActiveToolPointerCapturing()?this.app.isNavigationEnabled()?this.set(zl.GRAB):this.clear():this.applyForTool()});v(this,"applyForTool",(n=this.app.state.activeTool)=>{let t=this.canvas;if(!t)return;let o=n.type==="eraser"||n.type==="laser"||n.type==="bucketfill"?this.app.state.theme:void 0,r=n.type==="bucketfill"?this.app.bucketFill.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor,o):void 0,i=this.toolCursorMemo;if(!(i?.canvas===t&&i.type===n.type&&i.bucketFillColor===r&&i.theme===o)){if(n.type==="selection")this.clear();else if(ps({activeTool:n}))this.set(zl.GRAB);else if(on({activeTool:n}))this.applyEraser();else if(n.type==="autoshape")this.set(zl.CROSSHAIR);else if(n.type==="bucketfill")this.set(`url(${TO(r)}) 5 18, auto`);else if(n.type==="laser"){let a=this.app.state.theme===wT.LIGHT?vO:IO;this.set(`url(${a}), auto`)}else["image","custom"].includes(n.type)?n.type!=="image"&&this.set(zl.AUTO):this.set(zl.CROSSHAIR);this.toolCursorMemo={canvas:t,type:n.type,bucketFillColor:r,theme:o}}});v(this,"clear",()=>{this.set("")});v(this,"applyEraser",()=>{let t=this.app.state.theme;if(!this.eraserCanvasCache||this.eraserCanvasCache.theme!==t){let o=t===wT.DARK;this.eraserCanvasCache=document.createElement("canvas"),this.eraserCanvasCache.theme=t,this.eraserCanvasCache.height=20,this.eraserCanvasCache.width=20;let r=this.eraserCanvasCache.getContext("2d");r.lineWidth=1,r.beginPath(),r.arc(this.eraserCanvasCache.width/2,this.eraserCanvasCache.height/2,5,0,2*Math.PI),r.fillStyle=o?"#000":"#fff",r.fill(),r.strokeStyle=o?"#fff":"#000",r.stroke(),this.eraserPreviewDataURL=this.eraserCanvasCache.toDataURL(jm.svg)}this.set(`url(${this.eraserPreviewDataURL}) ${20/2} ${20/2}, auto`)})}get canvas(){return this.app.interactiveCanvas}};import{randomInteger as MO}from"@excalidraw/common";import{bindBindingElement as AO,convertToShape as DO,convertToShapeHandlePointerMoveFromPointerDown as LO,getHoveredElementForBinding as TT,isBindingElement as _O,isLineElement as RO,LinearElementEditor as Kf,maxBindingDistance_simple as ST,newArrowElement as NO,updateBoundPoint as BO}from"@excalidraw/element";import{getStrokeWidthByKey as SO,THEME as CO}from"@excalidraw/common";import{clamp as PO,pointFrom as kO}from"@excalidraw/math";var qm=class{constructor(n){this.app=n;v(this,"trail");this.trail=new Rn(this.app,{...this.getTrailOptions(),fill:()=>n.props.renderCustomizations?.traceColor??(n.state.theme===CO.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)")})}getTrailOptions(){return{simplify:0,streamline:.4,size:1,sizeMapping:()=>PO(SO("line",this.app.state.currentItemStrokeWidthKey)*.65*this.app.state.zoom.value,1.25,4)}}startPath(n,t){this.trail.startPath(n,t)}addPointToPath(n,t){this.trail.addPointToPath(n,t)}endPath(){this.trail.endPath()}clearTrails(){this.trail.clearTrails()}getCurrentPoints(){let n=this.trail.getCurrentTrail();return n?n.originalPoints.map(([t,o])=>kO(t,o)):[]}start(n){this.trail.start(n)}stop(){this.trail.stop()}};var Jm=class{constructor(n){this.app=n;v(this,"trail");v(this,"gestureInProgress",!1);v(this,"stop",()=>{this.trail.stop()});v(this,"hasPendingGesture",()=>this.gestureInProgress);v(this,"handlePointerDown",n=>{this.gestureInProgress&&this.app.actionManager.executeAction(ut),this.gestureInProgress=!0,this.trail.startPath(n.lastCoords.x,n.lastCoords.y)});v(this,"handlePointerMove",n=>LO(this.app,n));v(this,"bindRecognizedArrow",n=>{let{app:t}=this,o=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=ST(t.state.zoom),a=["start","end"].map(d=>{let m=Kf.getPointAtIndexGlobalCoordinates(n,d==="start"?0:-1,o);return{startOrEnd:d,globalPoint:m,target:TT(m,r,o,i)}}),s=!!a[0].target&&a[0].target===a[1].target,l=t.state.isMidpointSnappingEnabled&&!t.state.gridModeEnabled;for(let{startOrEnd:d,globalPoint:m,target:p}of a)p&&AO(n,p,s?"inside":"orbit",d,t.scene,m,t.state.isBindingEnabled,l);if(s)return;let c=new Map;for(let{startOrEnd:d,target:m}of a){if(!m)continue;let p=BO(n,d==="start"?"startBinding":"endBinding",d==="start"?n.startBinding:n.endBinding,m,o);p&&c.set(d==="start"?0:n.points.length-1,{point:p})}c.size&&Kf.movePoints(n,t.scene,c)});v(this,"maybeUpgradeLineToArrow",n=>{let{app:t}=this,o=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=ST(t.state.zoom),[a,s]=[0,-1].map(l=>TT(Kf.getPointAtIndexGlobalCoordinates(n,l,o),r,o,i));return!a&&!s||a===s?null:NO({type:"arrow",x:n.x,y:n.y,width:n.width,height:n.height,startArrowhead:null,endArrowhead:t.state.currentItemEndArrowhead,points:n.points,groupIds:n.groupIds,frameId:n.frameId,locked:!1,angle:n.angle,strokeColor:n.strokeColor,backgroundColor:n.backgroundColor,fillStyle:n.fillStyle,roughness:n.roughness,opacity:n.opacity,strokeStyle:n.strokeStyle,strokeWidth:n.strokeWidth})});v(this,"finalize",()=>{let{app:n}=this,t=this.gestureInProgress?this.trail.getCurrentPoints():[];if(this.gestureInProgress=!1,this.trail.endPath(),t.length>=3){let o=n.state.newElement||DO(t,n.state,n.scene.getNonDeletedElementsMap(),n.state.newElement,n.scene.getNonDeletedFramesLikes());if(o){let r={...o,seed:MO(),opacity:n.state.currentItemOpacity};n.state.isBindingEnabled&&RO(r)&&(r=this.maybeUpgradeLineToArrow(r)??r),n.insertNewElement(r),n.state.isBindingEnabled&&_O(r)&&this.bindRecognizedArrow(r)}}this.trail.clearTrails()});this.trail=new qm(n)}};import{isArrowKey as FO,KEYS as ri}from"@excalidraw/common";import{makeNextSelectedElementIds as OO,CaptureUpdateAction as zO,FlowChartCreator as GO,FlowChartNavigator as HO,getSelectedElements as CT,isFlowchartNodeElement as UO}from"@excalidraw/element";var Qm=class e{constructor(n){this.app=n;v(this,"creator",new GO);v(this,"navigator",new HO);v(this,"clear",()=>{this.creator.clear(),this.navigator.clear()});v(this,"handleKeyEvent",n=>{let t=this.resolveKeyboardEventToOperation(n);switch(t.type){case"none":return!1;case"canceled":return this.app.triggerRender(!0),!0;case"creating":return n.preventDefault(),t.pending.length&&this.app.revealIfHidden(t.pending),!0;case"navigating":{n.preventDefault();let o=t.nodeId&&this.app.scene.getNonDeletedElementsMap().get(t.nodeId);return o&&this.selectAndReveal(o),!0}case"committed":{t.nodes.length&&this.app.insertNewElements(t.nodes);let o=t.nodes[0];return o&&this.selectAndReveal(o),this.captureUpdate(),!0}case"navigationEnded":return this.captureUpdate(),!0}})}get pendingNodes(){return this.creator.pendingNodes}get isCreatingChart(){return this.creator.isCreatingChart}resolveKeyboardEventToOperation(n){let{creator:t,navigator:o,app:r}=this;if(n.type==="keydown"){if(n.key===ri.ESCAPE&&t.isCreatingChart)return t.clear(),{type:"canceled"};if(!FO(n.key))return{type:"none"};if(n[ri.CTRL_OR_CMD]&&!n.shiftKey){let a=CT(r.scene.getNonDeletedElementsMap(),r.state);return a.length===1&&UO(a[0])&&t.createNodes(a[0],r.state,e.getLinkDirectionFromKey(n.key),r.scene),{type:"creating",pending:t.pendingNodes??[]}}if(n.altKey){let a=r.scene.getNonDeletedElementsMap(),s=CT(a,r.state);if(s.length===1)return{type:"navigating",nodeId:o.exploreByDirection(s[0],a,e.getLinkDirectionFromKey(n.key))}}return{type:"none"}}let i=!n.altKey&&o.isExploring;if(i&&o.clear(),!n[ri.CTRL_OR_CMD]&&t.isCreatingChart){let a=t.pendingNodes??[];return t.clear(),{type:"committed",nodes:a}}return i?{type:"navigationEnded"}:{type:"none"}}selectAndReveal(n){this.app.setState(t=>({selectedElementIds:OO({[n.id]:!0},t)})),this.app.revealIfHidden([n])}captureUpdate(){this.app.syncActionResult({captureUpdate:zO.IMMEDIATELY})}static getLinkDirectionFromKey(n){switch(n){case ri.ARROW_UP:return"up";case ri.ARROW_DOWN:return"down";case ri.ARROW_RIGHT:return"right";case ri.ARROW_LEFT:return"left";default:return"right"}}};import{createGifPlaybackMetadata as PT,hasPlayableGif as WO,isInitializedImageElement as VO,newElementWith as kT,ShapeCache as YO}from"@excalidraw/element";import{MIME_TYPES as MT}from"@excalidraw/common";var ep=class{constructor(n){this.app=n;v(this,"playbackRaf",null);v(this,"runtimeState",new Map);v(this,"stop",()=>{this.playbackRaf!==null&&(cancelAnimationFrame(this.playbackRaf),this.playbackRaf=null),this.runtimeState.clear()});v(this,"getFrameIndex",n=>n.gifPlayback?.playing?this.runtimeState.get(n.id)?.frameIndex??n.gifPlayback.frameIndex:n.gifPlayback?.frameIndex);v(this,"setFrameIndex",(n,t)=>{this.runtimeState.set(n.id,{frameIndex:t,lastFrameTime:performance.now()})});v(this,"ensureLoop",()=>{this.playbackRaf!==null||this.app.unmounted||WO(this.app.scene.getNonDeletedElements(),this.app.imageCache)&&(this.playbackRaf=requestAnimationFrame(this.tick))});v(this,"createPlaceholderDecodeState",(n,t)=>{if(t.type!==MT.gif)return null;let o=n.id;this.app.imageCache.set(o,{image:new Promise(()=>{}),mimeType:MT.gif,gifDecodeStatus:"pending"});let r=kT(n,{fileId:o,gifPlayback:PT({playing:!0})});return this.app.scene.replaceAllElements(this.app.scene.getElementsIncludingDeleted().map(i=>i.id===r.id?r:i)),this.app.imagePlaceholderUpdateEmitter.trigger(),o});v(this,"ensureElementPlaybackMetadata",(n,t={})=>n.gifPlayback&&(t.playing===void 0||n.gifPlayback.playing===t.playing)?n:kT(n,{gifPlayback:n.gifPlayback?{...n.gifPlayback,playing:t.playing??n.gifPlayback.playing}:PT(t)}));v(this,"removePlaceholderDecodeState",n=>{n&&this.app.imageCache.delete(n)});v(this,"tick",()=>{if(this.playbackRaf=null,this.app.unmounted)return;let n=performance.now(),t=!1,o=!1;for(let r of this.app.scene.getNonDeletedElements()){if(!VO(r)||!r.gifPlayback?.playing)continue;let i=this.app.imageCache.get(r.fileId)?.gif;if(!i||i.frames.length<2)continue;o=!0;let a=Math.max(r.gifPlayback.speed||1,.1),s=this.runtimeState.get(r.id)??{frameIndex:r.gifPlayback.frameIndex,lastFrameTime:n};this.runtimeState.set(r.id,s);let l=s.frameIndex,c=i.delays[l]??100;n-s.lastFrameTime>=c/a&&(s.frameIndex=(l+1)%i.frames.length,s.lastFrameTime=n,YO.delete(r),t=!0)}t&&this.app.scene.triggerUpdate(),o&&(this.playbackRaf=requestAnimationFrame(this.tick))})}};import{debounce as XO,easeOut as NT,isBounds as KO}from"@excalidraw/common";import{clamp as BT}from"@excalidraw/math";import{getCommonBounds as AT,getElementsInGroup as $O,isElementLink as ZO,isExcalidrawElement as jO,parseElementLinkFromURL as qO}from"@excalidraw/element";var tp="animateScrollToContent",Va="animateScrollConstraintsSnapBack",DT=500,JO=250,QO=200,$f=302,LT={full:216,compact:64},e9=e=>{if(!e||typeof e!="object"||Array.isArray(e))return!1;let n=e;return typeof n.x=="number"&&typeof n.y=="number"&&(n.width==null||typeof n.width=="number")&&(n.height==null||typeof n.height=="number")},t9=(e,n)=>{let t=n.get(e);return t?[t]:$O(n,e)},_T=(e,n,t)=>{if(typeof e=="string"){let a=ZO(e),s=a?"link":"element",l=a?qO(e):e,c=l?t9(l,n):[];return c.length?{bounds:AT(c,n),type:s}:{bounds:null,type:s}}if(KO(e))return{bounds:e,type:"area"};if(e9(e)&&!jO(e)){let a=e.width??t.width,s=e.height??t.height;return{bounds:[e.x,e.y,e.x+a,e.y+s],type:"area"}}let o=Array.isArray(e)?e:[e],r=o.reduce((a,s)=>{if(s&&!s.isDeleted){let l=n.get(s.id);l&&a.push(l)}return a},[]),i=!r.length;return(r.length!==o.length||i)&&console.warn("supplied element target(s) for setViewport contain deleted or non-existent elements which have been filtered out"),i?{bounds:null,type:"element"}:{bounds:AT(r,n),type:"element"}},n9=e=>e===!1?0:e===!0||e==null?gu:Math.max(e,0),o9=(e,n,t="scale-down",o,r)=>{let{appState:i}=Mr({bounds:n,appState:e,fit:t,canvasOffsets:o,steppedZoom:!1,viewportZoomFactor:r});return{scrollX:i.scrollX,scrollY:i.scrollY,zoom:i.zoom}},RT=(e,n,{fit:t,offsets:o,lock:r,viewportZoomFactor:i})=>{let a=o9(e,n,t,o,i);if(!r?.scroll&&!r?.zoom)return{...a,scrollConstraints:null};let[s,l,c,d]=n,m={x:s,y:l,width:c-s,height:d-l,lockScroll:!!r.scroll,lockZoom:!!r.zoom,zoom:a.zoom.value,overscroll:n9(r.overscroll),offsets:o};return{...Vn({...e,...a,scrollConstraints:m}),scrollConstraints:m}},r9=({from:e,target:n,factor:t})=>{if(t>=1)return{...n};let o=e.zoom.value*Math.pow(n.zoom.value/e.zoom.value,t),r=n.zoom.value===e.zoom.value?t:(o-e.zoom.value)/(n.zoom.value-e.zoom.value);return{scrollX:((1-r)*e.scrollX*e.zoom.value+r*n.scrollX*n.zoom.value)/o,scrollY:((1-r)*e.scrollY*e.zoom.value+r*n.scrollY*n.zoom.value)/o,zoom:{value:o}}},i9=e=>e===!1?null:e===!0||e==null?DT:e.duration??DT,a9=(e,n,t,o,r)=>{at.start(tp,({deltaTime:i,state:a})=>{let s=(a?.elapsed??0)+i,l=Math.min(s/t,1),c=NT(BT(l,0,1));return l<1?(o({...r9({from:e,target:n,factor:c}),shouldCacheIgnoreZoom:!0}),{elapsed:s}):(r(),null)})},s9=(e,n,t=JO)=>{let o=Vn(e);if(o.scrollX===e.scrollX&&o.scrollY===e.scrollY&&o.zoom.value===e.zoom.value||at.running(tp))return;let r=(e.scrollX-o.scrollX)*e.zoom.value,i=(e.scrollY-o.scrollY)*e.zoom.value;at.start(Va,({deltaTime:a,state:s})=>{let l=(s?.elapsed??0)+a,c=Math.min(l/t,1),d=1-NT(BT(c,0,1));return n(m=>{if(!m.scrollConstraints)return null;let p=Vn(m),u=p.zoom.value;return{scrollX:p.scrollX+r*d/u,scrollY:p.scrollY+i*d/u,zoom:p.zoom}}),c<1?{elapsed:l}:null})},np=class{constructor(n,t){this.app=n;this.dependencies=t;v(this,"lastPosition",{x:0,y:0});v(this,"activeTransition",null);v(this,"uiLastMeasured",new Map);v(this,"invalidateUIOffset",n=>{this.uiLastMeasured.delete(n)});v(this,"resolveOffsets",n=>{if(!n)return n;let{ui:t,...o}=n;if(!t)return o;let r=this.getOffsets(t===!0?void 0:t);return{top:o.top??r.top,right:o.right??r.right,bottom:o.bottom??r.bottom,left:o.left??r.left}});v(this,"getOffsets",n=>{let t=this.dependencies.getContainer(),o=t?.getBoundingClientRect(),r=Kn().rtl,i={top:0,right:0,bottom:0,left:0},a=new Set;if(t&&o)for(let u of t.querySelectorAll("[data-viewport-ui]")){let E=u.getBoundingClientRect(),g={top:E.top-o.top,right:E.right-o.left,bottom:E.bottom-o.top,left:E.left-o.left,width:E.width};switch(u.dataset.viewportUi){case"top":i.top=Math.max(i.top,g.bottom);break;case"bottom":i.bottom=Math.max(i.bottom,this.app.state.height-g.top);break;case"side":{let[b,y]=g.left+g.width/2<this.app.state.width/2?["left",g.right]:["right",this.app.state.width-g.left];i[b]=Math.max(i[b],y);let w=u.dataset.viewportUiName;w&&(a.add(w),y>0&&this.uiLastMeasured.set(w,{side:b,offset:y}));break}}}if(n?.reserve&&this.app.editorInterface.formFactor!=="phone"){let u=(E,g)=>{if(a.has(E))return;let{side:b,offset:y}=this.uiLastMeasured.get(E)??g;i[b]=Math.max(i[b],y)};n.reserve.stylesPanel&&u("stylesPanel",{side:r?"right":"left",offset:this.dependencies.getStylesPanelMode()==="compact"?LT.compact:LT.full}),n.reserve.sidebar&&u("sidebar",{side:r?"left":"right",offset:$f})}let s=n?.padding??24,l=n?.paddingTop??s,c=(r?n?.paddingLeft:n?.paddingRight)??s,d=n?.paddingBottom??s,m=(r?n?.paddingRight:n?.paddingLeft)??s,p={top:i.top+l,right:i.right+c,bottom:i.bottom+d,left:i.left+m};return{top:n?.top??p.top,right:(r?n?.left:n?.right)??p.right,bottom:n?.bottom??p.bottom,left:(r?n?.right:n?.left)??p.left}});v(this,"resolveInitialViewport",(n,t,o)=>{let{bounds:r}=_T(n.target,t,o);return r?RT(o,r,{...n,offsets:this.resolveOffsets(n.offsets)}):null});v(this,"setViewport",n=>{if(n===null){this.cancelTransition(),at.cancel(Va),this.snapBackDebounced.cancel(),this.app.setState({scrollConstraints:null,shouldCacheIgnoreZoom:!1});return}let{target:t,fit:o,lock:r,animation:i,viewportZoomFactor:a}=n,s=this.resolveOffsets(n.offsets),{bounds:l,type:c}=_T(t,this.app.scene.getNonDeletedElementsMap(),this.app.state);if(!l){c==="link"&&this.app.setState({toast:{message:f("elementLink.notFound"),duration:3e3,closable:!0}});return}let d=RT(this.app.state,l,{fit:o,offsets:s,lock:r,viewportZoomFactor:a}),m=i9(i),p={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom};if(this.cancelTransition(),at.cancel(Va),this.snapBackDebounced.cancel(),m===null){this.app.setState({...d,shouldCacheIgnoreZoom:!1});return}let u={target:d};this.activeTransition=u,this.app.state.scrollConstraints&&this.app.setState({scrollConstraints:null}),a9(p,d,m,E=>{this.activeTransition===u&&this.app.setState(E)},()=>{this.activeTransition===u&&(this.activeTransition=null,this.app.setState({...u.target,shouldCacheIgnoreZoom:!1}))})});v(this,"translate",(n,t)=>{if(this.isLockedTransitionPending)return!1;this.cancelTransition(),t?.preserveScrollConstraintsSnapBack||at.cancel(Va),this.app.setState({shouldCacheIgnoreZoom:!1}),this.app.requestUnfollow();let o=this.app.state.zoom.value;return this.app.setState(n),this.app.setState(r=>{if(!r.scrollConstraints)return null;let a=!t?.zoomPreConstrained&&r.zoom.value!==o?0:r.scrollConstraints.overscroll;return a>0&&this.snapBackDebounced(),Vn(r,a)}),!0});v(this,"constrain",(n=0)=>{this.app.setState(t=>t.scrollConstraints?Vn(t,n):null)});v(this,"releaseOverscroll",()=>{this.app.state.scrollConstraints&&(this.snapBackDebounced.cancel(),this.snapBack())});v(this,"snapBack",()=>{this.app.unmounted||this.dependencies.isGestureActive()||s9(this.app.state,n=>this.app.setState(t=>n(t)))});v(this,"snapBackDebounced",XO(this.snapBack,QO));v(this,"cancelTransition",()=>{this.activeTransition=null,at.cancel(tp)});v(this,"destroy",()=>{this.cancelTransition(),at.cancel(Va),this.snapBackDebounced.cancel()})}get isAnimating(){return at.running(tp)||at.running(Va)}get isLockedTransitionPending(){return!!this.activeTransition?.target.scrollConstraints}};import op from"react";var l9=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,c9=/{{([\w-]+)}}/,d9=/<([\w-]+)>/,m9=/<\/([\w-]+)>/,p9=(e,n)=>{let t=[{name:"",children:[]}];return e.split(l9).filter(Boolean).forEach(o=>{let r=o.match(d9),i=o.match(m9),a=o.match(c9);if(r!==null){let s=r[1];n.hasOwnProperty(s)?t.push({name:s,children:[]}):console.warn(`Trans: missed to pass in prop ${s} for interpolating ${e}`)}else if(i!==null)if(i[1]===t[t.length-1].name){let l=t.pop(),c=op.createElement(op.Fragment,{},...l.children),d=n[l.name];typeof d=="function"&&t[t.length-1].children.push(d(c))}else console.warn(`Trans: unexpected end tag ${o} for interpolating ${e}`);else if(a!==null){let s=a[1];n.hasOwnProperty(s)?t[t.length-1].children.push(n[s]):console.warn(`Trans: key ${s} not in props for interpolating ${e}`)}else t[t.length-1].children.push(o)}),t.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),t[0].children},u9=({i18nKey:e,children:n,...t})=>{let{t:o}=Le();return op.createElement(op.Fragment,{},...p9(o(e),t))},ii=u9;import{jsx as xn,jsxs as FT}from"react/jsx-runtime";var h9=()=>FT("div",{"data-testid":"brave-measure-text-error",children:[xn("p",{children:xn(ii,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>xn("span",{style:{fontWeight:600},children:e})})}),xn("p",{children:xn(ii,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>xn("span",{style:{fontWeight:600},children:e})})}),xn("p",{children:xn(ii,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>xn("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),xn("p",{children:xn(ii,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>xn("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>FT("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),OT=h9;import v9 from"clsx";import I9 from"react";import{isDarwin as zT}from"@excalidraw/common";var g9={toggleTheme:[N("Shift+Alt+D")],saveScene:[N("CtrlOrCmd+S")],loadScene:[N("CtrlOrCmd+O")],imageExport:[N("CtrlOrCmd+Shift+E")],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:[zT?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")],bringToFront:[zT?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")],copyAsPng:[N("Shift+Alt+C")],group:[N("CtrlOrCmd+G")],ungroup:[N("CtrlOrCmd+Shift+G")],gridMode:[N("CtrlOrCmd+'")],objectsSnapMode:[N("Alt+S")],stats:[N("Alt+/")],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:[],zoomToFit:[],zoomToFitSelectionInViewport:[],smartZoom:[N("F")],saveFileToDisk:[N("CtrlOrCmd+S")],saveToActiveFile:[N("CtrlOrCmd+S")],toggleShortcuts:[N("?")],searchMenu:[N("CtrlOrCmd+F")],wrapSelectionInFrame:[],arrangeElements:[N("Shift+R")],toolLock:[N("Q")]},Ze=(e,n=0)=>{let t=g9[e];return t&&t.length>0?t[n]||t[0]:""};import{useLayoutEffect as f9,useRef as GT,useEffect as HT}from"react";import{unstable_batchedUpdates as E9}from"react-dom";import{KEYS as b9,queryFocusableElements as x9}from"@excalidraw/common";import{clamp as UT}from"@excalidraw/math";import y9 from"clsx";import{jsx as w9}from"react/jsx-runtime";var pr=10,WT=({children:e,left:n,top:t,onCloseRequest:o,fitInViewport:r=!1,viewportWidth:i=window.innerWidth,viewportHeight:a=window.innerHeight,className:s})=>{let l=GT(null);HT(()=>{let d=l.current;if(!d)return;d.contains(document.activeElement)||d.focus();let m=p=>{if(p.key===b9.TAB){let u=x9(d),{activeElement:E}=document,g=u.findIndex(b=>b===E);E===d?(p.shiftKey?u[u.length-1]?.focus():u[0].focus(),p.preventDefault(),p.stopImmediatePropagation()):g===0&&p.shiftKey?(u[u.length-1]?.focus(),p.preventDefault(),p.stopImmediatePropagation()):g===u.length-1&&!p.shiftKey&&(u[0]?.focus(),p.preventDefault(),p.stopImmediatePropagation())}};return d.addEventListener("keydown",m),()=>d.removeEventListener("keydown",m)},[]);let c=GT(null);return f9(()=>{if(r&&l.current&&t!=null&&n!=null){let d=l.current,{width:m,height:p}=d.getBoundingClientRect();if(c.current?.top===t&&c.current?.left===n)return;c.current={top:t,left:n};let u=Math.max(0,i-pr*2);m>=u?(d.style.width=`${u}px`,d.style.left=`${pr}px`,d.style.overflowX="scroll"):d.style.left=`${UT(n,pr,i-pr-m)}px`;let E=Math.max(0,a-pr*2);p>=E?(d.style.height=`${E}px`,d.style.top=`${pr}px`,d.style.overflowY="scroll"):d.style.top=`${UT(t,pr,a-pr-p)}px`}},[t,n,r,i,a]),HT(()=>{if(o){let d=m=>{l.current?.contains(m.target)||E9(()=>o(m))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[o]),w9("div",{className:y9("popover",s),ref:l,tabIndex:-1,children:e})};import{jsx as Mo,jsxs as YT}from"react/jsx-runtime";var je="separator",VT=e=>"onSelect"in e,XT=I9.memo(({actionManager:e,items:n,top:t,left:o,onClose:r})=>{let i=Qn(),a=Oi(),s=n.reduce((l,c)=>c?c===je||VT(c)?(l.push(c),l):((!c.predicate||c.predicate(a,i,e.app.props,e.app))&&l.push(c),l):l,[]);return Mo(WT,{onCloseRequest:()=>{r()},top:t,left:o,fitInViewport:!0,viewportWidth:i.width,viewportHeight:i.height,className:"context-menu-popover",children:Mo("ul",{className:"context-menu",onContextMenu:l=>l.preventDefault(),children:s.map((l,c)=>{if(l===je)return!s[c-1]||s[c-1]===je?null:Mo("hr",{className:"context-menu-item-separator"},c);if(VT(l))return Mo("li",{"data-testid":l.key,onClick:()=>{r(()=>{l.onSelect()})},children:YT("button",{type:"button",className:"context-menu-item",children:[Mo("div",{className:"context-menu-item__label",children:l.label}),Mo("kbd",{className:"context-menu-item__shortcut"})]})},l.key);let d=l.name,m="";return l.label&&(typeof l.label=="function"?m=f(l.label(a,i,e.app)):m=f(l.label)),Mo("li",{"data-testid":d,onClick:()=>{r(()=>{e.executeAction(l,"contextMenu")})},children:YT("button",{type:"button",className:v9("context-menu-item",{dangerous:d==="deleteSelectedElements",checkmark:l.checked?.(i)}),children:[Mo("div",{className:"context-menu-item__label",children:m}),Mo("kbd",{className:"context-menu-item__shortcut",children:d?Ze(d):""})]})},c)})})})});import{useId as T9}from"react";import S9 from"clsx";import{Fragment as C9,jsx as Gl,jsxs as KT}from"react/jsx-runtime";var rp=({border:e,style:n})=>Gl("div",{className:"viewport-status-frame__border",style:{borderColor:e,...n}}),ip=({label:e,border:n})=>{let t=T9(),o=KT(C9,{children:[e.icon&&Gl("span",{className:"viewport-status-frame__badge-icon",children:e.icon}),e.label]});return KT("div",{className:S9("viewport-status-frame__badge",{"viewport-status-frame__badge--clickable":e.onClick}),role:"status",style:{"--viewport-status-frame-badge-background":e.background||n||"var(--color-primary)",color:e.color},children:[e.onClick&&Gl("button",{type:"button",className:"viewport-status-frame__badge-action","aria-labelledby":t,onClick:e.onClick}),Gl("div",{className:"viewport-status-frame__badge-label",id:e.onClick?t:void 0,children:o}),e.onClose&&Gl("button",{type:"button",className:"viewport-status-frame__badge-close","aria-label":f("buttons.close"),onClick:e.onClose,children:rn})]})};import rs from"clsx";import JW from"react";import{CLASSES as QW,TOOL_TYPE as Tk,arrayToMap as eV,isShallowEqual as zp}from"@excalidraw/common";import{mutateElement as tV,ShapeCache as nV}from"@excalidraw/element";import{showSelectedShapeActions as oV}from"@excalidraw/element";import{createIsolation as P9}from"jotai-scope";import Zf from"react";import Ao from"tunnel-rat";var jf=Zf.createContext(null),nt=()=>Zf.useContext(jf),k9=P9(),$T=()=>Zf.useMemo(()=>({MainMenuTunnel:Ao(),WelcomeScreenMenuHintTunnel:Ao(),WelcomeScreenToolbarHintTunnel:Ao(),WelcomeScreenHelpHintTunnel:Ao(),WelcomeScreenCenterTunnel:Ao(),FooterCenterTunnel:Ao(),DefaultSidebarTriggerTunnel:Ao(),DefaultSidebarTabTriggersTunnel:Ao(),OverwriteConfirmDialogTunnel:Ao(),tunnelsJotai:k9}),[]);import hr from"clsx";import{useRef as F9}from"react";import{Popover as ur}from"radix-ui";import{CLASSES as iS}from"@excalidraw/common";import{isArrowElement as rS}from"@excalidraw/element";import{forwardRef as ZT}from"react";import jT from"clsx";import{jsx as qT}from"react/jsx-runtime";var M9=ZT(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>qT("div",{className:jT("Stack Stack_horizontal",r),style:{"--gap":n,alignItems:t,justifyContent:o,...i},ref:a,children:e})),A9=ZT(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>qT("div",{className:jT("Stack Stack_vertical",r),style:{"--gap":n,justifyItems:t,justifyContent:o,...i},ref:a,children:e})),Nt={Row:M9,Col:A9};import{isTransparent as JT}from"@excalidraw/common";import{shouldAllowVerticalAlign as D9,suppportsHorizontalAlign as L9,hasBoundTextElement as QT,isElbowArrow as _9,isImageElement as eS,isLinearElement as R9,isTextElement as N9,hasStrokeColor as tS,toolIsArrow as B9}from"@excalidraw/element";var nS=(e,n)=>{let t=n[0]?.type||null;for(let o of n)if(o.type!==t){t=null;break}return tS(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||n.some(o=>tS(o.type))},oS=(e,n)=>Go(e.activeTool.type)||n.some(t=>Go(t.type)),ap=(e,n,t,o)=>{let r=e.activeTool.type,i=d=>d(r)||n.some(m=>d(m.type)),a=n.length===1,s=n.length===2&&(QT(n[0])||QT(n[1])),l=!!(e.editingTextElement||e.newElement),c=n.length>0;return{hasSelection:c,showExtraActions:c&&!l,strokeColor:nS(e,n),backgroundColor:oS(e,n),fill:r==="bucketfill"||Go(r)&&!JT(e.currentItemBackgroundColor)||n.some(d=>Go(d.type)&&!JT(d.backgroundColor)),strokeWidth:i(tx),freedrawMode:i(nx),strokeStyle:i(fu),sloppiness:i(fu),roundness:i(ox),arrowType:i(B9),arrowheads:i(ms),text:r==="text"||n.some(N9),textAlign:r==="text"||L9(n,t),verticalAlign:D9(n,t),opacity:r!=="autoshape"||c,layers:r!=="freedraw"&&r!=="autoshape"&&!n.some(d=>d.type==="freedraw")||ce(t,e).some(d=>d.type==="freedraw"),align:!s&&dt(e,o),distribute:n.length>2,imageLayout:n.length>1&&n.every(eS)&&dt(e,o),link:a||s,linkSingleOnly:a,cropEditor:!e.croppingElementId&&a&&eS(n[0]),lineEditor:!e.selectedLinearElement?.isEditing&&a&&R9(n[0])&&!_9(n[0])}};import{Fragment as Jt,jsx as j,jsxs as Se}from"react/jsx-runtime";var qf=hr([iS.SHAPE_ACTIONS_THEME_SCOPE,"properties-content"]),aS=({renderAction:e})=>Se("fieldset",{children:[j("legend",{children:f("labels.layers")}),Se("div",{className:"buttonList",children:[e("sendToBack"),e("sendBackward"),e("bringForward"),e("bringToFront")]})]}),sS=({renderAction:e,showDistribute:n,showImageLayout:t})=>{let o=document.documentElement.getAttribute("dir")==="rtl";return Se("fieldset",{children:[j("legend",{children:f("labels.align")}),Se("div",{className:"buttonList",children:[o?Se(Jt,{children:[e("alignRight"),e("alignHorizontallyCentered"),e("alignLeft")]}):Se(Jt,{children:[e("alignLeft"),e("alignHorizontallyCentered"),e("alignRight")]}),n&&e("distributeHorizontally"),j("div",{style:{flexBasis:"100%",height:0}}),Se("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[e("alignTop"),e("alignVerticallyCentered"),e("alignBottom"),n&&e("distributeVertically")]}),t&&Se(Jt,{children:[j("div",{style:{flexBasis:"100%",height:0}}),e("arrangeElements"),e("normaliseElements")]})]})]})},lS=({appState:e,elementsMap:n,renderAction:t,app:o})=>{let r=vi(n,e),i=ap(e,r,n,o);return e.activeTool.type==="bucketfill"?Se("div",{className:"selected-shape-actions",children:[j("div",{children:t("changeBucketFillBackgroundColor")}),t("changeFillStyle"),t("changeOpacity")]}):Se("div",{className:"selected-shape-actions",children:[j("div",{children:i.strokeColor&&t("changeStrokeColor")}),i.backgroundColor&&j("div",{children:t("changeBackgroundColor")}),i.fill&&t("changeFillStyle"),i.strokeWidth&&t("changeStrokeWidth"),i.strokeStyle&&j(Jt,{children:t("changeStrokeStyle")}),i.freedrawMode&&t("changeFreedrawMode"),i.sloppiness&&j(Jt,{children:t("changeSloppiness")}),i.roundness&&j(Jt,{children:t("changeRoundness")}),i.arrowType&&j(Jt,{children:t("changeArrowType")}),i.text&&Se(Jt,{children:[j("fieldset",{children:t("changeFontFamily")}),t("changeFontSize"),i.textAlign&&t("changeTextAlign")]}),i.verticalAlign&&t("changeVerticalAlign"),i.arrowheads&&j(Jt,{children:t("changeArrowhead")}),i.opacity&&t("changeOpacity"),i.layers&&j(aS,{renderAction:t}),i.align&&j(sS,{renderAction:t,showDistribute:i.distribute,showImageLayout:i.imageLayout}),i.showExtraActions&&Se("fieldset",{children:[j("legend",{children:f("labels.actions")}),Se("div",{className:"buttonList",children:[t("duplicateSelection"),t("deleteSelectedElements"),t("group"),t("ungroup"),i.link&&t("hyperlink"),i.cropEditor&&t("cropEditor"),i.lineEditor&&t("toggleLinearEditor"),t("smartZoom")]})]})]})},cS=({appState:e,renderAction:n,setAppState:t,predicates:o,container:r})=>{let i=o.hasSelection||e.activeTool.type!=="selection"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser"&&e.activeTool.type!=="lasso",a=e.openPopup==="compactStrokeStyles";return i?j("div",{className:"compact-action-item",children:Se(ur.Root,{open:a,onOpenChange:s=>{t(s?{openPopup:"compactStrokeStyles"}:{openPopup:null})},children:[j(ur.Trigger,{asChild:!0,children:j("button",{type:"button",className:hr("compact-action-button properties-trigger",{active:a}),title:f("labels.stroke"),onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:a?null:"compactStrokeStyles"})},children:m0})}),a&&j(bo,{className:qf,container:r,style:{maxWidth:"13rem"},onClose:()=>{},children:Se("div",{className:"selected-shape-actions",children:[o.fill&&n("changeFillStyle"),o.strokeWidth&&n("changeStrokeWidth"),o.freedrawMode&&n("changeFreedrawMode"),o.strokeStyle&&j(Jt,{children:n("changeStrokeStyle")}),o.sloppiness&&j(Jt,{children:n("changeSloppiness")}),o.roundness&&n("changeRoundness"),o.opacity&&n("changeOpacity")]})})]})}):null},dS=({appState:e,renderAction:n,setAppState:t,targetElements:o,predicates:r,container:i,app:a})=>{if(!r.arrowType)return null;let s=e.openPopup==="compactArrowProperties";return j("div",{className:"compact-action-item",children:Se(ur.Root,{open:s,onOpenChange:l=>{t(l?{openPopup:"compactArrowProperties"}:{openPopup:null})},children:[j(ur.Trigger,{asChild:!0,children:j("button",{type:"button",className:hr("compact-action-button properties-trigger",{active:s}),title:f("labels.arrowtypes"),onClick:l=>{l.preventDefault(),l.stopPropagation(),t({openPopup:s?null:"compactArrowProperties"})},children:(()=>{let l=mt(o,a,c=>rS(c)?c.elbowed?"elbow":c.roundness?"round":"sharp":null,c=>rS(c),c=>c?null:e.currentItemArrowType);return l==="elbow"?Ko:l==="round"?$o:Xo})()})}),s&&j(bo,{container:i,className:"properties-content",style:{maxWidth:"13rem"},onClose:()=>{},children:n("changeArrowProperties")})]})})},mS=({appState:e,renderAction:n,setAppState:t,predicates:o,container:r})=>{let{saveCaretPosition:i,restoreCaretPosition:a}=R0(),s=e.openPopup==="compactTextProperties";return j("div",{className:"compact-action-item",children:Se(ur.Root,{open:s,onOpenChange:l=>{l?(e.editingTextElement&&i(),t({openPopup:"compactTextProperties"})):(t({openPopup:null}),e.editingTextElement&&a())},children:[j(ur.Trigger,{asChild:!0,children:j("button",{type:"button",className:hr("compact-action-button properties-trigger",{active:s}),title:f("labels.textAlign"),onClick:l=>{l.preventDefault(),l.stopPropagation(),s?t({openPopup:null}):(e.editingTextElement&&i(),t({openPopup:"compactTextProperties"}))},children:Fx})}),e.openPopup==="compactTextProperties"&&j(bo,{className:qf,container:r,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&a()},children:Se("div",{className:"selected-shape-actions",children:[o.text&&n("changeFontSize"),o.textAlign&&n("changeTextAlign"),o.verticalAlign&&n("changeVerticalAlign")]})})]})})},pS=({appState:e,renderAction:n,predicates:t,setAppState:o,container:r,showDuplicate:i,showDelete:a})=>{let s=e.openPopup==="compactOtherProperties";return t.showExtraActions?j("div",{className:"compact-action-item",children:Se(ur.Root,{open:s,onOpenChange:l=>{o(l?{openPopup:"compactOtherProperties"}:{openPopup:null})},children:[j(ur.Trigger,{asChild:!0,children:j("button",{type:"button",className:hr("compact-action-button properties-trigger",{active:s}),title:f("labels.actions"),onClick:l=>{l.preventDefault(),l.stopPropagation(),o({openPopup:s?null:"compactOtherProperties"})},children:Ax})}),s&&j(bo,{className:qf,container:r,style:{maxWidth:"12rem",justifyContent:"center",alignItems:"center"},onClose:()=>{},children:Se("div",{className:"selected-shape-actions",children:[t.layers&&j(aS,{renderAction:n}),t.align&&j(sS,{renderAction:n,showDistribute:t.distribute,showImageLayout:t.imageLayout}),Se("fieldset",{children:[j("legend",{children:f("labels.actions")}),Se("div",{className:"buttonList",children:[n("group"),n("ungroup"),t.linkSingleOnly&&n("hyperlink"),t.cropEditor&&n("cropEditor"),n("smartZoom"),i&&n("duplicateSelection"),a&&n("deleteSelectedElements")]})]})]})})]})}):null},O9=({renderAction:e,predicates:n})=>n.lineEditor?j("div",{className:"compact-action-item",children:e("toggleLinearEditor")}):null,uS=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r})=>{let i=vi(n,e),a=ap(e,i,n,o),{container:s}=Re();return Se("div",{className:"compact-shape-actions",children:[a.strokeColor&&j("div",{className:hr("compact-action-item"),children:t("changeStrokeColor")}),a.backgroundColor&&j("div",{className:"compact-action-item",children:t(e.activeTool.type==="bucketfill"?"changeBucketFillBackgroundColor":"changeBackgroundColor")}),a.freedrawMode&&j("div",{className:"compact-action-item",children:t("changeFreedrawMode",{cycle:!0})}),j(cS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s}),j(dS,{appState:e,renderAction:t,setAppState:r,targetElements:i,predicates:a,container:s,app:o}),a.lineEditor&&j("div",{className:"compact-action-item",children:t("toggleLinearEditor")}),a.text&&Se(Jt,{children:[j("div",{className:"compact-action-item",children:t("changeFontFamily")}),j(mS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s})]}),a.showExtraActions&&j("div",{className:"compact-action-item",children:t("duplicateSelection")}),a.showExtraActions&&j("div",{className:"compact-action-item",children:t("deleteSelectedElements")}),j(pS,{appState:e,renderAction:t,predicates:a,setAppState:r,container:s})]})},hS=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r})=>{let i=vi(n,e),a=ap(e,i,n,o),{container:s}=Re(),l=F9(null),c=l.current?.getBoundingClientRect()?.width??0,d=9,m=6,p=32,u=d*p+(d-1)*m,E=p+m,g=c>=u+E,b=c>=u+2*E;return Se(Ue,{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:[Se("div",{style:{display:"flex",flexDirection:"row",gap:m,flex:1},children:[a.strokeColor&&j("div",{className:hr("compact-action-item"),children:t("changeStrokeColor")}),a.backgroundColor&&j("div",{className:"compact-action-item",children:t(e.activeTool.type==="bucketfill"?"changeBucketFillBackgroundColor":"changeBackgroundColor")}),j(cS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s}),j(dS,{appState:e,renderAction:t,setAppState:r,targetElements:i,predicates:a,container:s,app:o}),j(O9,{renderAction:t,predicates:a}),a.text&&Se(Jt,{children:[j("div",{className:"compact-action-item",children:t("changeFontFamily")}),j(mS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s})]}),j(pS,{appState:e,renderAction:t,predicates:a,setAppState:r,container:s,showDuplicate:!b,showDelete:!g})]}),Se("div",{style:{display:"flex",flexDirection:"row",gap:m},children:[j("div",{className:"compact-action-item",children:t("undo")}),j("div",{className:"compact-action-item",children:t("redo")}),b&&j("div",{className:"compact-action-item",children:t("duplicateSelection")}),g&&j("div",{className:"compact-action-item",children:t("deleteSelectedElements")})]})]})},gS=({renderAction:e})=>j(Nt.Col,{gap:1,className:iS.ZOOM_ACTIONS,children:Se(Nt.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),fS=({renderAction:e,className:n})=>Se("div",{className:`undo-redo-buttons ${n}`,children:[j("div",{className:"undo-button-container",children:j(pt,{label:f("buttons.undo"),children:e("undo")})}),j("div",{className:"redo-button-container",children:Se(pt,{label:f("buttons.redo"),children:[" ",e("redo")]})})]}),ES=({showExitZenModeBtn:e})=>j("button",{type:"button",className:hr("disable-zen-mode",{"disable-zen-mode--visible":e}),children:f("buttons.exitZenMode")});import z9 from"clsx";import{useState as G9,useEffect as H9}from"react";import{THEME as U9}from"@excalidraw/common";import{jsx as Jf,jsxs as W9}from"react/jsx-runtime";var sp=({delay:e,theme:n})=>{let[t,o]=G9(!!e);return H9(()=>{if(!e)return;let r=setTimeout(()=>{o(!1)},e);return()=>clearTimeout(r)},[e]),t?null:W9("div",{className:z9("LoadingMessage",{"LoadingMessage--dark":n===U9.DARK}),children:[Jf("div",{children:Jf(Eo,{})}),Jf("div",{className:"LoadingMessage-text",children:f("labels.loadingScene")})]})};import{useState as mp,useEffect as zS}from"react";import bz from"clsx";import{KEYS as nE,capitalizeString as GS}from"@excalidraw/common";import OS from"react";import{DropdownMenu as hz}from"radix-ui";import{CLASSES as gz}from"@excalidraw/common";import V9 from"clsx";import{useCallback as Y9,useEffect as X9,useRef as K9}from"react";import{CLASSES as $9,EVENT as bS,KEYS as Z9}from"@excalidraw/common";import{DropdownMenu as j9}from"radix-ui";import{jsx as lp}from"react/jsx-runtime";var xS=({children:e,onClickOutside:n,className:t="",onSelect:o,open:r=!0,align:i="end",style:a})=>{let s=Ee(),l=K9(null),c=Fi({onClickOutside:n});Bi(l,Y9(m=>{l.current?.closest(`.${$9.DROPDOWN_MENU_EVENT_WRAPPER}`)?.contains(m.target)||c.onClickOutside?.()},[c])),X9(()=>{if(!r)return;let m=u=>{u.key===Z9.ESCAPE&&(u.preventDefault(),u.stopImmediatePropagation(),c.onClickOutside?.())},p={capture:!0};return document.addEventListener(bS.KEYDOWN,m,p),()=>{document.removeEventListener(bS.KEYDOWN,m,p)}},[c,r]);let d=V9(`dropdown-menu ${t}`,{"dropdown-menu--mobile":s.formFactor==="phone"}).trim();return lp(yh.Provider,{value:{onSelect:o},children:lp(j9.Content,{ref:l,className:d,style:a,"data-testid":"dropdown-menu",align:i,sideOffset:8,onCloseAutoFocus:m=>m.preventDefault(),children:s.formFactor==="phone"?lp(Nt.Col,{className:"dropdown-menu-container",children:e}):lp(Ue,{className:"dropdown-menu-container",padding:2,children:e})})})};xS.displayName="DropdownMenuContent";var yS=xS;import{jsx as J9}from"react/jsx-runtime";var q9=({children:e,className:n="",selected:t,...o})=>J9("div",{...o,className:`dropdown-menu-item-base dropdown-menu-item-custom ${n} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),wS=q9;import{DropdownMenu as Q9}from"radix-ui";import{jsx as Qf}from"react/jsx-runtime";var vS=({icon:e,shortcut:n,href:t,children:o,onSelect:r,className:i="",selected:a,rel:s="noopener",...l})=>{let c=dd(r);return Qf(Q9.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:Qf("a",{...l,href:t,target:"_blank",rel:`noopener ${s}`,className:Jo(i,a),title:l.title??l["aria-label"],children:Qf(Qo,{icon:e,shortcut:n,children:o})})})},Ya=vS;vS.displayName="DropdownMenuItemLink";import{jsx as ez}from"react/jsx-runtime";var IS=()=>ez("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:"6px 0",flex:"0 0 auto"}}),TS=IS;IS.displayName="DropdownMenuSeparator";import{DropdownMenu as sz}from"radix-ui";import tz from"clsx";import{DropdownMenu as nz}from"radix-ui";import{useCallback as oz,useState as SS}from"react";import{jsx as tE}from"react/jsx-runtime";var eE=-4,rz=4,CS=({children:e,className:n})=>{let t=Ee(),o=tz(`dropdown-menu dropdown-submenu ${n}`,{"dropdown-menu--mobile":t.formFactor==="phone"}).trim(),r=oz(c=>{if(c){let m=c.closest(".dropdown-menu-container")?.getBoundingClientRect();if(m){let p=c.getBoundingClientRect().width,E=window.innerWidth-m.right;E<p+20&&(a(E-p+eE),l(eE+8))}}},[]),[i,a]=SS(rz),[s,l]=SS(eE);return tE(nz.SubContent,{className:o,sideOffset:i,alignOffset:s,collisionPadding:8,ref:r,children:t.formFactor==="phone"?tE(Nt.Col,{className:"dropdown-menu-container",children:e}):tE(Ue,{className:"dropdown-menu-container",padding:2,style:{zIndex:1},children:e})})},PS=CS;CS.displayName="DropdownMenuSubContent";import{DropdownMenu as iz}from"radix-ui";import{jsx as kS,jsxs as az}from"react/jsx-runtime";var MS=({children:e,icon:n,shortcut:t,className:o})=>az(iz.SubTrigger,{className:`${Jo(o)} dropdown-menu__submenu-trigger`,children:[kS(Qo,{icon:n,shortcut:t,children:e}),kS("div",{className:"dropdown-menu__submenu-trigger-icon",children:h0})]}),AS=MS;MS.displayName="DropdownMenuSubTrigger";import DS from"react";var cp=e=>n=>{let t=DS.Children.toArray(n).find(o=>DS.isValidElement(o)&&typeof o.type!="string"&&o?.type.displayName&&o.type.displayName===e);return t||null},LS=cp("DropdownMenuTrigger"),_S=cp("DropdownMenuContent"),RS=cp("DropdownMenuSubTrigger"),NS=cp("DropdownMenuSubContent");import{jsxs as lz}from"react/jsx-runtime";var dp=({children:e})=>{let n=RS(e),t=NS(e);return lz(sz.Sub,{children:[n,t]})};dp.Trigger=AS;dp.Content=PS;dp.displayName="DropdownMenuSub";var gr=dp;import cz from"clsx";import{DropdownMenu as dz}from"radix-ui";import{jsx as mz}from"react/jsx-runtime";var BS=({className:e="",children:n,onToggle:t,title:o,...r})=>{let i=Ee(),a=cz(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.formFactor==="phone"}).trim();return mz(dz.Trigger,{className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:o,...r,children:n})},FS=BS;BS.displayName="DropdownMenuTrigger";import{jsx as uz}from"react/jsx-runtime";var pz=e=>uz(jt,{...e,icon:e.checked?Nc:Uc}),io=pz;import{jsx as Ez,jsxs as fz}from"react/jsx-runtime";var Bn=({children:e,open:n})=>{let t=LS(e),o=_S(e),r=o&&OS.isValidElement(o)?OS.cloneElement(o,{open:n}):o;return Ez(hz.Root,{open:n,modal:!1,children:fz("div",{className:gz.DROPDOWN_MENU_EVENT_WRAPPER,style:{display:"contents"},children:[t,r]})})};Bn.Trigger=FS;Bn.Content=yS;Bn.Item=jt;Bn.ItemCheckbox=io;Bn.ItemLink=Ya;Bn.ItemCustom=wS;Bn.Group=Rs;Bn.Separator=TS;Bn.Sub=gr;var ue=Bn;Bn.displayName="DropdownMenu";import{Fragment as oE,jsx as _e,jsxs as Xa}from"react/jsx-runtime";var xz=({actionManager:e,app:n})=>{if(!e.isActionEnabled(Dt))return null;let t=f("buttons.objectsSnapMode");return _e($,{type:"toggle",icon:Yo,checked:n.state.objectsSnapModeEnabled,title:t,"aria-label":t,"data-testid":"toolbar-objects-snap-mode",onSelect:()=>e.executeAction(Dt,"ui")})},yz=({app:e})=>_e($,{type:"button",icon:_i,title:f("labels.eyeDropper"),"aria-label":f("labels.eyeDropper"),"data-testid":"toolbar-eyedropper",onClick:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1})}),HS=({app:e,actionManager:n,setAppState:t})=>{let o=e.state.activeTool,r=e.state.myocSimplifiedMode,i=e.props.UIOptions.tools?.image!==!1,[a,s]=mp(!1),[l,c]=mp("rectangle"),[d,m]=mp("arrow");zS(()=>{(o.type==="rectangle"||o.type==="diamond"||o.type==="ellipse")&&c(o.type)},[o.type]),zS(()=>{(o.type==="arrow"||o.type==="line")&&m(o.type)},[o.type]);let p=o.type==="frame",u=o.type==="autoshape",E=o.type==="laser",g=o.type==="embeddable",b=o.type==="bucketfill",y=["rectangle","diamond","ellipse"].map(G=>({type:G,icon:Ye[G].icon,title:GS(f(`toolBar.${G}`)),fillable:Ye[G].fillable})),w=["arrow","line"].map(G=>({type:G,icon:Ye[G].icon,title:GS(f(`toolBar.${G}`)),fillable:Ye[G].fillable})),[x,I]=mp(0),T=36,C=4,P=7,A=P*T+(P-1)*C,D=T+C,_=x>=A+1*D,k=i&&x>=A+2*D,L=x>=A+3*D,B=(r?["text","image"]:["text","image","frame","embeddable","laser","bucketfill"]).filter(G=>!(_&&G==="text"||(!i||k)&&G==="image"||L&&G==="frame")),V=r&&ji.includes(o.type),z=V||B.includes(o.type),U=z?V?Ye[o.type].icon:o.type==="text"?Pn:o.type==="image"?_r:o.type==="frame"?jn:o.type==="embeddable"?Vo:o.type==="laser"?qn:o.type==="bucketfill"?Zn:bs:bs,K={app:e,activeTool:o,hideShortcut:!0};return Xa("div",{className:"mobile-toolbar",ref:G=>{G&&I(G.getBoundingClientRect().width)},children:[_e(_d,{...K}),_e(Rd,{...K,setAppState:t}),r?_e(Ws,{...K}):_e(Nd,{...K}),_e(Xs,{...K}),!r&&_e(Zi,{app:e,options:y,activeTool:o,defaultOption:l,"data-testid":"toolbar-rectangle",onToolChange:G=>{(G==="rectangle"||G==="diamond"||G==="ellipse")&&(c(G),e.setActiveTool({type:G}))},displayedOption:y.find(G=>G.type===l)||y[0]}),!r&&_e(Zi,{app:e,options:w,activeTool:o,defaultOption:d,"data-testid":"toolbar-arrow",onToolChange:G=>{(G==="arrow"||G==="line")&&(m(G),e.setActiveTool({type:G}))},displayedOption:w.find(G=>G.type===d)||w[0]}),_&&_e(Vs,{...K}),r&&k&&_e(yz,{app:e}),k&&_e(Ys,{...K}),!r&&L&&_e(Zy,{...K,hideShortcut:!0}),Xa(ue,{open:a,children:[_e(ue.Trigger,{className:bz("App-toolbar__extra-tools-trigger App-toolbar__extra-tools-trigger--mobile",{"App-toolbar__extra-tools-trigger--selected":z||a}),onToggle:()=>{s(!a),t({openMenu:null,openPopup:null})},title:f("toolBar.extraTools"),style:{width:T,height:T,display:"flex",alignItems:"center",justifyContent:"center"},children:U}),Xa(ue.Content,{onClickOutside:()=>s(!1),onSelect:()=>s(!1),className:"App-toolbar__extra-tools-dropdown",align:"start",children:[r&&ji.map(G=>_e(ue.Item,{onSelect:()=>e.setActiveTool({type:G}),icon:Ye[G].icon,"data-testid":`toolbar-${G}`,selected:o.type===G,shortcut:Ld(G),disabled:qe(e,G),children:f(`toolBar.${G}`)},G)),!r&&_e("div",{className:"App-toolbar__dropdown-divider"}),!r&&n.isActionEnabled(Dt)&&_e(ue.Item,{onSelect:()=>n.executeAction(Dt,"ui"),icon:Yo,"data-testid":"toolbar-objects-snap-mode",selected:e.state.objectsSnapModeEnabled,shortcut:Ze("objectsSnapMode"),children:f("buttons.objectsSnapMode")}),e.props.activeTool==null&&Xa(oE,{children:[r&&_e("div",{className:"App-toolbar__dropdown-divider"}),_e(ue.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?Uo:fo,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:nE.Q.toLocaleUpperCase(),children:f("toolBar.lock-short")})]}),!_&&_e(ue.Item,{onSelect:()=>e.setActiveTool({type:"text"}),icon:Pn,shortcut:nE.T.toLocaleUpperCase(),"data-testid":"toolbar-text",selected:o.type==="text",disabled:qe(e,"text"),children:f("toolBar.text")}),i&&!k&&_e(ue.Item,{onSelect:()=>e.setActiveTool({type:"image"}),icon:_r,"data-testid":"toolbar-image",selected:o.type==="image",disabled:qe(e,"image"),children:f("toolBar.image")}),!r&&!L&&_e(ue.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:jn,shortcut:nE.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:p,disabled:qe(e,"frame"),children:f("toolBar.frame")}),!r&&Xa(oE,{children:[_e(ue.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:Vo,"data-testid":"toolbar-embeddable",selected:g,disabled:qe(e,"embeddable"),children:f("toolBar.embeddable")}),_e(ue.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:Br,shortcut:Ji("autoshape"),"data-testid":"toolbar-autoshape",selected:u,disabled:qe(e,"autoshape"),children:f("toolBar.autoshape")}),_e(ue.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:qn,"data-testid":"toolbar-laser",selected:E,disabled:qe(e,"laser"),children:f("toolBar.laser")}),_e(ue.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:Zn,"data-testid":"toolbar-bucketfill",selected:b,disabled:qe(e,"bucketfill"),children:f("toolBar.bucketfill")})]})]})]}),r&&Xa(oE,{children:[_e("div",{className:"App-toolbar__divider"}),_e(xz,{actionManager:n,app:e})]})]})};import wz from"clsx";import{jsx as vz}from"react/jsx-runtime";var pp=({children:e,side:n,className:t})=>vz("div",{className:wz("FixedSideContainer",`FixedSideContainer_side_${n}`,t),children:e});import Iz from"clsx";import{jsx as Tz}from"react/jsx-runtime";var Ka=e=>e.penDetected?Tz($,{className:Iz("ToolIcon__penMode",{"is-mobile":e.isMobile}),type:"toggle",icon:Bx,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,onSelect:()=>e.onChange?.()}):null;import{Fragment as US,jsx as wt,jsxs as ai}from"react/jsx-runtime";var WS=({appState:e,elements:n,actionManager:t,setAppState:o,renderTopLeftUI:r,renderTopRightUI:i,renderSidebars:a,renderWelcomeScreen:s,defaultUIEnabled:l,scrollBackToContentUIEnabled:c,app:d,onPenModeToggle:m})=>{let{WelcomeScreenCenterTunnel:p,MainMenuTunnel:u,DefaultSidebarTriggerTunnel:E}=nt(),g=()=>{if(e.openDialog?.name==="elementLinkSelector")return null;let P=wt("div",{className:"excalidraw-ui-top-right",children:i?.(!0,e)??(!e.viewModeEnabled&&ai(US,{children:[l&&wt(Ka,{checked:e.penMode,onChange:()=>m(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),wt(E.Out,{})]}))}),A=ai("div",{className:"excalidraw-ui-top-left",children:[r?.(!0,e),wt(u.Out,{})]});return ai("div",{className:"App-toolbar-content",style:{display:"flex",flexDirection:"row",justifyContent:"space-between"},children:[A,P]})},b=()=>wt(HS,{app:d,actionManager:t,setAppState:o}),y=c&&e.scrolledOutside,w=l,x=l&&(!e.viewModeEnabled||w),I=y&&!e.openMenu&&!e.openSidebar?wt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(P=>({...wi(n,P)}))},children:f("buttons.scrollBackToContent")}):null,T=d.props.viewportStatusFrame?.label,C=T?wt(ip,{label:T,border:d.props.viewportStatusFrame?.border}):null;return ai(US,{children:[a(),wt("div",{className:"App-welcome-screen",children:s&&wt(p.Out,{})}),x&&ai("div",{className:"App-bottom-bar",style:{marginBottom:gn+Po,left:14,transform:"none"},"data-viewport-ui":"bottom",children:[I&&wt("div",{className:"floating-status-stack",children:I}),ai("div",{className:"App-bottom-bar__actions-row",children:[w&&ai(Ue,{className:"mobile-canvas-actions",children:[!e.viewModeOnly&&wt("div",{className:"view-mode-button",children:t.renderAction("viewMode")}),wt("div",{className:"smart-zoom-button",children:t.renderAction("smartZoom")})]}),!e.viewModeEnabled&&wt(hS,{appState:e,elementsMap:d.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:d,setAppState:o})]}),!e.viewModeEnabled&&wt(Ue,{className:"App-toolbar",style:{justifyContent:"flex-start"},children:e.openDialog?.name!=="elementLinkSelector"&&b()})]}),!x&&I&&wt("div",{className:"floating-status-stack",children:I}),C&&wt("div",{className:"viewport-status-frame__badge-row",children:C}),wt(pp,{side:"top",className:"App-top-bar",children:g()})]})};import jS,{useLayoutEffect as qS,useRef as JS,useState as QS}from"react";import{newTextElement as eC}from"@excalidraw/element";import Dz from"clsx";import{useEffect as Lz,useState as _z}from"react";import{KEYS as Rz,queryFocusableElements as $S}from"@excalidraw/common";import{useCallback as Sz,useState as Cz}from"react";var VS=()=>{let[e,n]=Cz(null),t=Sz(o=>n(o),[]);return[e,t]};import YS from"clsx";import{useRef as Pz}from"react";import{createPortal as kz}from"react-dom";import{KEYS as Mz}from"@excalidraw/common";import{jsx as XS,jsxs as Az}from"react/jsx-runtime";var KS=e=>{let{closeOnClickOutside:n=!0}=e,t=Qc({className:YS("excalidraw-modal-container",e.portalContainerClassName)}),o=Pz(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let r=i=>{i.key===Mz.ESCAPE&&(i.preventDefault(),i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return kz(Az("div",{className:YS("Modal",e.className,{"animations-disabled":o.current}),role:"dialog","aria-modal":"true",onKeyDown:r,"aria-labelledby":e.labelledBy,children:[XS("div",{className:"Modal__background",onClick:n?e.onCloseRequest:void 0}),XS("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as up,jsxs as ZS}from"react/jsx-runtime";function Nz(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var yn=e=>{let[n,t]=VS(),[o]=_z(document.activeElement),{id:r}=Re(),i=Ee().formFactor==="phone";Lz(()=>{if(!n)return;let l=$S(n);setTimeout(()=>{l.length>0&&e.autofocus!==!1&&(l[1]||l[0]).focus()});let c=d=>{if(d.key===Rz.TAB){let m=$S(n),{activeElement:p}=document,u=m.findIndex(E=>E===p);u===0&&d.shiftKey?(m[m.length-1].focus(),d.preventDefault()):u===m.length-1&&!d.shiftKey&&(m[0].focus(),d.preventDefault())}};return n.addEventListener("keydown",c),()=>n.removeEventListener("keydown",c)},[n,e.autofocus]);let a=Fe(),s=()=>{a({openMenu:null}),o.focus(),e.onCloseRequest()};return up(KS,{className:Dz("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:Nz(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,portalContainerClassName:e.portalContainerClassName,children:ZS(Ue,{ref:t,children:[e.title&&ZS("h2",{id:`${r}-dialog-title`,className:"Dialog__title",children:[up("span",{className:"Dialog__titleContent",children:e.title}),e.titleButton]}),i&&up("button",{className:"Dialog__close",onClick:s,title:f("buttons.close"),"aria-label":f("buttons.close"),type:"button",children:rn}),up("div",{className:"Dialog__content",children:e.children})]})})};import{jsx as Do,jsxs as hp}from"react/jsx-runtime";var Bz=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}},Fz=e=>{let n=JS(null),[t,o]=QS(null),{theme:r}=be();qS(()=>{if(!e.spreadsheet){o(null);return}let a=Cf(e.chartType,e.spreadsheet,0,0,e.colorSeed);if(!a){o(null),n.current?.replaceChildren();return}o(a);let s,l=n.current;return(async()=>(s=await Ar(a,{exportBackground:!1,viewBackgroundColor:"#fff",exportWithDarkMode:r==="dark"},null,{skipInliningFonts:!0}),s.querySelector(".style-fonts")?.remove(),l.replaceChildren(),l.appendChild(s)))(),()=>{l.replaceChildren()}},[e.spreadsheet,e.chartType,e.colorSeed,r]);let i=Bz(e.chartType);return hp("button",{type:"button",className:"ChartPreview","aria-label":i,onClick:()=>{t&&e.onClick(e.chartType,t)},children:[Do("div",{className:"ChartPreview__canvas",ref:n}),Do("div",{className:"ChartPreview__label",children:i})]})},Oz=e=>{let n=JS(null),{theme:t}=be();return qS(()=>{if(!e.rawText)return;let o=eC({text:e.rawText,x:0,y:0}),r=n.current;return(async()=>{let i=await Ar([o],{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]),hp("button",{type:"button",className:"ChartPreview","aria-label":f("labels.chartType_plaintext"),onClick:()=>{e.onClick(e.rawText)},children:[Do("div",{className:"ChartPreview__canvas",ref:n}),Do("div",{className:"ChartPreview__label",children:f("labels.chartType_plaintext")})]})},tC=({data:e,rawText:n,onClose:t})=>{let{onInsertElements:o,focusContainer:r}=St(),[i,a]=QS(Math.random()),s=jS.useCallback(()=>{a(Math.random())},[]),l=jS.useCallback(()=>{t&&t()},[t]),c=(m,p)=>{o(p),Be("paste","chart",m),t(),r()},d=m=>{let p=eC({text:m,x:0,y:0});o([p]),Be("paste","chart","plaintext"),t(),r()};return Do(yn,{size:"regular",onCloseRequest:l,title:hp("div",{className:"PasteChartDialog__title",children:[Do("div",{className:"PasteChartDialog__titleText",children:f("labels.pasteCharts")}),Do("div",{className:"PasteChartDialog__reshuffleBtn",onClick:s,role:"button",tabIndex:0,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),s())},children:Zn})]}),className:"PasteChartDialog",autofocus:!1,children:hp("div",{className:"container",children:[["bar","line","radar"].map(m=>Aa(e,m)?Do(Fz,{chartType:m,spreadsheet:e,colorSeed:i,onClick:c},m):null),n&&Do(Oz,{rawText:n,onClick:d})]})})};import{Fragment as zz,jsx as nC,jsxs as Gz}from"react/jsx-runtime";var Hl=({heading:e,children:n,...t})=>{let{id:o}=Re(),r=nC("h2",{className:"visually-hidden",id:`${o}-${e}-title`,children:f(`headings.${e}`)});return nC("section",{...t,"aria-labelledby":`${o}-${e}-title`,children:typeof n=="function"?n(r):Gz(zz,{children:[r,n]})})};import{Popover as Ul}from"radix-ui";import oC from"clsx";import gp,{useLayoutEffect as Hz}from"react";import{supportsResizeObserver as Uz,isShallowEqual as Wz}from"@excalidraw/common";import{Fragment as aE,jsx as vt,jsxs as $a}from"react/jsx-runtime";var Vz=4,Yz=8,rE=38,rC=21,Xz=({shouldWrap:e,children:n,username:t})=>e?vt(pt,{label:t||"Unknown user",children:n}):vt(aE,{children:n}),iE=({actionManager:e,collaborator:n,socketId:t,withName:o=!1,shouldWrapWithTooltip:r=!1,isBeingFollowed:i})=>{let a={socketId:t,collaborator:n,withName:o,isBeingFollowed:i},s=e.renderAction("goToCollaborator",a);return vt(Xz,{username:n.username,shouldWrap:r,children:s},t)},Kz=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted","isCurrentUser"],fp=gp.memo(({className:e,mobile:n,collaborators:t,userToFollow:o,currentUserControls:r})=>{let i=ot(),a=typeof r=="function"?r(!!n):r,s=Array.from(t,([C,P])=>({...P,socketId:C})).filter(C=>C.username?.trim()),l=s.find(C=>C.isCurrentUser),c=s.filter(C=>!C.isCurrentUser),[d,m]=gp.useState(""),p=s.filter(C=>C.username?.toLowerCase().includes(d)),u=gp.useRef(null);Hz(()=>{if(u.current){let C=A=>{g(A)};if(C(u.current.clientWidth),!Uz)return;let P=new ResizeObserver(A=>{for(let D of A){let{width:_}=D.contentRect;C(_)}});return P.observe(u.current),()=>{P.disconnect()}}},[]);let[E,g]=gp.useState(Vz*rE),b=l?E-rC:E,y=Math.max(1,Math.min(8,Math.floor(b/rE))),w=l?Math.max(0,y-1):y,x=c.slice(0,w),I=l?[...x,l]:x,T=I.map(C=>{let P=iE({actionManager:i,collaborator:C,socketId:C.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:C.socketId===o});return C.isCurrentUser?$a(Ul.Root,{children:[vt(Ul.Trigger,{asChild:!0,children:$a("div",{className:"UserList__pill",children:[P,vt("div",{className:"UserList__pill-chevron",children:u0})]})}),vt(Ul.Content,{className:"focus-visible-none",style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:$a(Ue,{padding:2,children:[s.length>=Yz&&vt(ld,{placeholder:f("quickSearch.placeholder"),onChange:m}),vt(cd,{className:"dropdown-menu UserList__collaborators",placeholder:f("userList.empty"),children:p.length>0?[vt("div",{className:"hint",children:f("userList.hint.text")},"hint"),p.map(A=>iE({actionManager:i,collaborator:A,socketId:A.socketId,withName:!0,isBeingFollowed:A.socketId===o}))]:[]}),a&&$a(aE,{children:[vt("div",{className:"UserList__menu-divider"}),vt(Ul.Close,{asChild:!0,children:vt("div",{className:"dropdown-menu",children:a})})]}),vt(Ul.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})]},C.socketId):P});return n?$a("div",{className:oC("UserList UserList_mobile",e),children:[vt("div",{className:"UserList_mobile__avatars",children:s.map(C=>iE({actionManager:i,collaborator:C,socketId:C.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:C.socketId===o}))}),a&&$a(aE,{children:[vt("div",{className:"UserList__menu-divider"}),a]})]}):vt("div",{className:"UserList__wrapper",ref:u,children:vt("div",{className:oC("UserList",e),style:{"--max-avatars":I.length+(l?rC/rE:0)},children:T})})},(e,n)=>{if(e.collaborators.size!==n.collaborators.size||e.mobile!==n.mobile||e.className!==n.className||e.userToFollow!==n.userToFollow||e.currentUserControls!==n.currentUserControls)return!1;let t=n.collaborators.keys();for(let[o,r]of e.collaborators){let i=n.collaborators.get(o);if(!i||o!==t.next().value||!Wz(r,i,Kz))return!1}return!0});import Wl from"clsx";import{jsx as iC}from"react/jsx-runtime";var aC=e=>iC(pt,{label:`${f("helpDialog.title")} \u2014 ?`,children:iC("button",{className:"help-icon",onClick:e.onClick,type:"button","aria-label":f("helpDialog.title"),children:Li})});import{jsx as Qt,jsxs as sE}from"react/jsx-runtime";var sC=({appState:e,actionManager:n,showExitZenModeBtn:t,renderWelcomeScreen:o,defaultUIEnabled:r,zoomUIEnabled:i})=>{let{FooterCenterTunnel:a,WelcomeScreenHelpHintTunnel:s}=nt(),l=St();return sE("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[(r||i&&l.isNavigationEnabled())&&Qt("div",{className:Wl("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:Qt(Nt.Col,{gap:2,children:sE(Hl,{heading:"canvasActions",children:[!e.viewModeOnly&&Qt(pt,{label:e.viewModeEnabled?"Edit mode":f("labels.viewMode"),children:Qt("div",{className:Wl("view-mode-button"),children:n.renderAction("viewMode")})}),Qt(pt,{label:f("buttons.smartZoom"),children:Qt("div",{className:Wl("smart-zoom-button"),children:n.renderAction("smartZoom")})}),i&&l.isNavigationEnabled()&&Qt(gS,{renderAction:n.renderAction}),r&&!e.viewModeEnabled&&Qt(fS,{renderAction:n.renderAction,className:Wl("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),Qt(a.Out,{}),(r||o)&&Qt("div",{className:Wl("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:sE("div",{style:{position:"relative"},children:[o&&Qt(s.Out,{}),r&&Qt(aC,{onClick:()=>n.executeAction(Kr)})]})}),r&&Qt(ES,{showExitZenModeBtn:t})]})},lC=sC;sC.displayName="Footer";import{composeEventHandlers as tG}from"@excalidraw/common";import{useLayoutEffect as $z,useRef as Zz}from"react";import{jsx as jz}from"react/jsx-runtime";var si=(e,n)=>{let t=Je(0),o=r=>{let{tunnelsJotai:{useAtom:i}}=nt(),[,a]=i(t),s=Zz({preferHost:!1,counter:0});return $z(()=>{let l=s.current;return a(c=>{let d=c+1;return l.counter=d,d}),()=>{a(c=>{let d=c-1;return l.counter=d,d||(l.preferHost=!1),d})}},[a]),r.__fallback||(s.current.preferHost=!0),!s.current.counter&&r.__fallback&&s.current.preferHost||s.current.counter>1&&r.__fallback?null:jz(n,{...r})};return o.displayName=e,o};var mE={};w3(mE,{ChangeCanvasBackground:()=>xC,Export:()=>yC,Help:()=>EC,LiveCollaborationTrigger:()=>vC,LoadScene:()=>uC,Preferences:()=>ao,PreferencesToggleGridModeItem:()=>dE,SaveAsImage:()=>gC,SaveToActiveFile:()=>hC,SearchMenu:()=>fC,Socials:()=>wC,ToggleTheme:()=>bC});import eG from"clsx";import{THEME as Yl}from"@excalidraw/common";var lE=Je({active:!1});async function cC({title:e,description:n,actionLabel:t,color:o}){return new Promise(r=>{Et.set(lE,{active:!0,onConfirm:()=>r(!0),onClose:()=>r(!1),onReject:()=>r(!1),title:e,description:n,actionLabel:t,color:o})})}import qz from"clsx";import{jsx as dC,jsxs as Jz}from"react/jsx-runtime";var Ep=function({onChange:e,value:n,choices:t,name:o}){return dC("div",{className:"RadioGroup",children:t.map(r=>Jz("div",{className:qz("RadioGroup__choice",{active:r.value===n}),title:r.ariaLabel,children:[dC("input",{name:o,type:"radio",checked:r.value===n,onChange:()=>e(r.value),"aria-label":r.ariaLabel}),r.label]},String(r.value)))})};import{Fragment as Qz,jsx as Vl,jsxs as mC}from"react/jsx-runtime";var pC=({value:e,shortcut:n,onChange:t,choices:o,children:r,name:i,icon:a})=>{let s=Ee();return mC(Qz,{children:[mC("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[a&&Vl("div",{className:"dropdown-menu-item__icon",children:a}),Vl("label",{className:"dropdown-menu-item__text",children:Vl(Ns,{children:r})}),Vl(Ep,{name:i,value:e,onChange:t,choices:o})]}),n&&s.formFactor!=="phone"&&Vl("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:n})]})};pC.displayName="DropdownMenuItemContentRadio";var cE=pC;import{Fragment as AC,jsx as xe,jsxs as Xl}from"react/jsx-runtime";var uC=()=>{let{t:e}=Le(),n=ot(),t=Oi();return n.isActionEnabled(ea)?xe(jt,{icon:Bc,onSelect:async()=>{(!t.length||await cC({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:xe(ii,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:r=>xe("strong",{children:r}),br:()=>xe("br",{})})}))&&n.executeAction(ea)},"data-testid":"load-button",shortcut:Ze("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};uC.displayName="LoadScene";var hC=()=>{let{t:e}=Le(),n=ot();return n.isActionEnabled(Xr)?xe(jt,{shortcut:Ze("saveScene"),"data-testid":"save-button",onSelect:()=>n.executeAction(Xr),icon:Vx,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};hC.displayName="SaveToActiveFile";var gC=()=>{let e=Fe(),{t:n}=Le();return xe(jt,{icon:Kx,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:Ze("imageExport"),"aria-label":n("buttons.exportImage"),children:n("buttons.exportImage")})};gC.displayName="SaveAsImage";var fC=e=>{let{t:n}=Le(),t=ot();return xe(jt,{icon:Jn,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(wl)},shortcut:Ze("searchMenu"),"aria-label":n("search.title"),className:e?.className,children:n("search.title")})};fC.displayName="SearchMenu";var EC=()=>{let{t:e}=Le(),n=ot();return xe(jt,{"data-testid":"help-menu-item",icon:Li,onSelect:()=>n.executeAction(Kr),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};EC.displayName="Help";var bC=e=>{let{t:n}=Le(),t=be(),o=ot(),r=Ze("toggleTheme"),i=kn();return o.isActionEnabled(kd)?e?.allowSystemTheme?xe(cE,{name:"theme",value:e.theme,onChange:a=>{if(i.onThemeChange){i.onThemeChange(a);return}console.warn("MainMenu.DefaultItems.ToggleTheme: `<Excalidraw/> props.onThemeChange` must be defined to use system theme selection.")},choices:[{value:Yl.LIGHT,label:ws,ariaLabel:`${n("buttons.lightMode")} - ${r}`},{value:Yl.DARK,label:ys,ariaLabel:`${n("buttons.darkMode")} - ${r}`},{value:"system",label:i0,ariaLabel:n("buttons.systemMode")}],children:n("labels.theme")}):xe(jt,{onSelect:a=>{a.preventDefault(),o.executeAction(kd)},icon:t.theme===Yl.DARK?ws:ys,"data-testid":"toggle-dark-mode",shortcut:r,"aria-label":t.theme===Yl.DARK?n("buttons.lightMode"):n("buttons.darkMode"),children:t.theme===Yl.DARK?n("buttons.lightMode"):n("buttons.darkMode")}):null};bC.displayName="ToggleTheme";var xC=()=>{let{t:e}=Le(),n=be(),t=ot(),o=kn();return n.viewModeEnabled||!o.UIOptions.canvasActions.changeViewBackgroundColor?null:Xl("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")})]})};xC.displayName="ChangeCanvasBackground";var yC=()=>{let{t:e}=Le(),n=Fe();return xe(jt,{icon:vs,onSelect:()=>{n({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};yC.displayName="Export";var wC=()=>{let{t:e}=Le();return Xl(AC,{children:[xe(Ya,{icon:Hx,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),xe(Ya,{icon:Wx,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),xe(Ya,{icon:Ux,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};wC.displayName="Socials";var vC=({onSelect:e,isCollaborating:n})=>{let{t}=Le();return xe(jt,{"data-testid":"collab-button",icon:Fc,className:eG({"active-collab":n}),onSelect:e,children:t("labels.liveCollaboration")})};vC.displayName="LiveCollaborationTrigger";var IC=()=>{let{t:e}=Le(),n=St(),t=be();return xe(io,{checked:t.activeTool.locked,shortcut:Ze("toolLock"),onSelect:o=>{n.toggleLock(),o.preventDefault()},children:e("labels.preferences_toolLock")})},TC=()=>{let{t:e}=Le(),n=be(),t=Fe();return xe(cE,{name:"boxSelectionMode",icon:Uc,value:n.boxSelectionMode,onChange:o=>{t({boxSelectionMode:o})},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")})},SC=()=>{let{t:e}=Le(),n=ot(),t=be();return xe(io,{checked:t.objectsSnapModeEnabled,shortcut:Ze("objectsSnapMode"),onSelect:o=>{n.executeAction(Dt),o.preventDefault()},children:e("buttons.objectsSnapMode")})},CC=()=>{let{t:e}=Le(),n=ot(),t=be();return xe(io,{checked:t.bindingPreference==="enabled",onSelect:o=>{n.executeAction(tl),o.preventDefault()},children:e("labels.arrowBinding")})},PC=()=>{let{t:e}=Le(),n=ot(),t=be();return xe(io,{checked:t.isMidpointSnappingEnabled,onSelect:o=>{n.executeAction(nl),o.preventDefault()},children:e("labels.midpointSnapping")})},dE=()=>{let{t:e}=Le(),n=ot(),t=be();return xe(io,{checked:t.gridModeEnabled,shortcut:Ze("gridMode"),onSelect:o=>{n.executeAction(la),o.preventDefault()},children:e("labels.toggleGrid")})},kC=()=>{let{t:e}=Le(),n=ot(),t=be();return t.viewModeOnly?null:xe(io,{checked:t.viewModeEnabled,shortcut:Ze("viewMode"),onSelect:o=>{n.executeAction(va),o.preventDefault()},children:e("labels.viewMode")})},MC=()=>{let{t:e}=Le(),n=ot(),t=be();return xe(io,{checked:t.stats.open,shortcut:Ze("stats"),onSelect:o=>{n.executeAction(ar),o.preventDefault()},children:e("stats.fullTitle")})},ao=({children:e,additionalItems:n})=>{let{t}=Le();return Xl(gr,{children:[xe(gr.Trigger,{icon:g0,children:t("labels.preferences")}),Xl(gr.Content,{className:"excalidraw-main-menu-preferences-submenu",children:[e||Xl(AC,{children:[xe(TC,{}),xe(IC,{}),xe(SC,{}),xe(dE,{}),xe(kC,{}),xe(MC,{}),xe(CC,{}),xe(PC,{})]}),n]})]})};ao.ToggleToolLock=IC;ao.BoxSelectionMode=TC;ao.ToggleSnapMode=SC;ao.ToggleArrowBinding=CC;ao.ToggleMidpointSnapping=PC;ao.ToggleGridMode=dE;ao.ToggleViewMode=kC;ao.ToggleElementProperties=MC;ao.displayName="Preferences";import{jsx as bp,jsxs as pE}from"react/jsx-runtime";var nG=Object.assign(si("MainMenu",({children:e,onSelect:n})=>{let{MainMenuTunnel:t}=nt(),o=Ee(),r=be(),i=kn(),a=Fe();return bp(t.In,{children:pE(ue,{open:r.openMenu==="canvas",children:[bp(ue.Trigger,{onToggle:()=>{a({openMenu:r.openMenu==="canvas"?null:"canvas",openPopup:null,openDialog:null})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:zx}),pE(ue.Content,{onClickOutside:()=>a({openMenu:null}),onSelect:tG(n,()=>{a({openMenu:null})}),className:"main-menu",align:"start",children:[e,o.formFactor==="phone"&&r.collaborators.size>0&&pE("fieldset",{className:"UserList-Wrapper",children:[bp("legend",{children:f("labels.collaborators")}),bp(fp,{mobile:!0,collaborators:r.collaborators,userToFollow:i.userToFollow?.socketId||null,currentUserControls:i.currentUserControls})]})]})]})})}),{Trigger:ue.Trigger,Item:ue.Item,ItemLink:ue.ItemLink,ItemCustom:ue.ItemCustom,Group:ue.Group,Separator:ue.Separator,Sub:gr,DefaultItems:mE}),Bt=nG;import oG from"clsx";import{forwardRef as rG,useState as iG}from"react";import{isPromiseLike as aG}from"@excalidraw/common";import{jsx as xp,jsxs as sG}from"react/jsx-runtime";var fr=rG(({children:e,icon:n,onClick:t,label:o,variant:r="filled",color:i="primary",size:a="medium",fullWidth:s,className:l,status:c,disabled:d},m)=>{let[p,u]=iG(!1),E=async b=>{let y=t?.(b);if(aG(y)){let w=window.setTimeout(()=>{u(!0)},50);try{await y}catch(x){if(x instanceof wc)console.warn(x);else throw x}finally{clearTimeout(w),u(!1)}}},g=p?"loading":c;return i=g==="success"?"success":i,xp("button",{className:oG("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${r}`,`ExcButton--size-${a}`,`ExcButton--status-${g}`,{"ExcButton--fullWidth":s},l),onClick:E,type:"button","aria-label":o,ref:m,disabled:d||g==="loading"||g==="success",children:sG("div",{className:"ExcButton__contents",children:[g==="loading"?xp(Eo,{className:"ExcButton__statusIcon"}):g==="success"&&xp("div",{className:"ExcButton__statusIcon",children:$1}),n&&xp("div",{className:"ExcButton__icon","aria-hidden":!0,children:n}),r!=="icon"&&(e??o)]})})});import{jsx as Za,jsxs as dG}from"react/jsx-runtime";var yp=({title:e,children:n,actionLabel:t,onClick:o})=>dG("div",{className:"OverwriteConfirm__Actions__Action",children:[Za("h4",{children:e}),Za("div",{className:"OverwriteConfirm__Actions__Action__content",children:n}),Za(fr,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:o})]}),lG=()=>{let{t:e}=Le(),n=ot(),t=Fe();return Za(yp,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{n.executeAction(Kd,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},cG=()=>{let{t:e}=Le(),n=ot();return Za(yp,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{n.executeAction(Js,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},uE=Object.assign(({children:e})=>Za("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:lG,SaveToDisk:cG});import{jsx as Er,jsxs as DC}from"react/jsx-runtime";var wp=Object.assign(si("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:n}=nt(),[t,o]=He(lE);if(!t.active)return null;let r=()=>{t.onClose(),o(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),o(a=>({...a,active:!1}))};return Er(n.In,{children:Er(yn,{onCloseRequest:r,title:!1,size:916,children:DC("div",{className:"OverwriteConfirm",children:[Er("h3",{children:t.title}),DC("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[Er("div",{className:"OverwriteConfirm__Description__icon",children:Z1}),Er("div",{children:t.description}),Er("div",{className:"OverwriteConfirm__Description__spacer"}),Er(fr,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),Er(uE,{children:e})]})})})}),{Actions:uE,Action:yp});import{round as wP}from"@excalidraw/math";import kH from"clsx";import MH from"lodash.throttle";import{useEffect as vP,useMemo as PE,useState as AH,memo as DH}from"react";import{STATS_PANELS as Ap}from"@excalidraw/common";import{getCommonBounds as LH}from"@excalidraw/element";import{getUncroppedWidthAndHeight as _H}from"@excalidraw/element";import{isImageElement as kE}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as RH}from"@excalidraw/element";import{elementsAreInSameGroup as NH}from"@excalidraw/element";import{degreesToRadians as zC,radiansToDegrees as WC}from"@excalidraw/math";import{getBoundTextElement as GC}from"@excalidraw/element";import{isArrowElement as HC,isElbowArrow as TG}from"@excalidraw/element";import{updateBindings as UC}from"@excalidraw/element";import bG from"clsx";import{useEffect as FC,useRef as Ip,useState as xG}from"react";import{EVENT as Ja,KEYS as yG,cloneJSON as hE}from"@excalidraw/common";import{deepCopyElement as wG}from"@excalidraw/element";import{CaptureUpdateAction as OC}from"@excalidraw/element";import{pointFrom as br,pointRotateRads as vp}from"@excalidraw/math";import{getBoundTextElement as mG,getNonDeletedElements as pG,isBindingElement as uG,unbindBindingElement as LC}from"@excalidraw/element";import{isFrameLikeElement as NC}from"@excalidraw/element";import{getSelectedGroupIds as hG,getElementsInGroup as gG,isInGroup as fG}from"@excalidraw/element";import{getFrameChildren as EG}from"@excalidraw/element";import{updateBindings as _C}from"@excalidraw/element";import{DRAGGING_THRESHOLD as RC}from"@excalidraw/common";var BC=.01,Kl=10,Wt=(e,n)=>!(n==="angle"&&NC(e)),We=(e,n)=>{let t=e+n/2;return t-t%n},ja=(e,n,t)=>Object.keys(e).map(o=>({original:(t??n).get(o),latest:n.get(o)})).filter(o=>o.original!==void 0&&o.latest!==void 0);var li=(e,n,t,o,r,i,a=!0)=>{if(uG(t)&&(t.startBinding||t.endBinding)){if(Math.abs(e-t.x)<RC&&Math.abs(n-t.y)<RC)return;LC(t,"start",o),LC(t,"end",o)}let s=o.getNonDeletedElementsMap(),l=s.get(t.id);if(!l)return;let[c,d]=[t.x+t.width/2,t.y+t.height/2],[m,p]=vp(br(t.x,t.y),br(c,d),t.angle),u=e-m,E=n-p,[g,b]=vp(br(e,n),br(c+u,d+E),-t.angle);o.mutateElement(l,{x:g,y:b},{informMutation:a,isDragging:!1}),_C(l,o,r);let y=mG(t,i);if(y){let w=s.get(y.id);w&&o.mutateElement(w,{x:y.x+u,y:y.y+E},{informMutation:a,isDragging:!1})}if(NC(t)){let w=EG(i,t.id);w.forEach(x=>{let I=s.get(x.id);if(!I)return;let[T,C]=[x.x+x.width/2,x.y+x.height/2],[P,A]=vp(br(x.x,x.y),br(T,C),x.angle),D=Math.round(P+u),_=Math.round(A+E),[k,L]=vp(br(D,_),br(T+u,C+E),-x.angle);o.mutateElement(I,{x:k,y:L},{informMutation:a,isDragging:!1}),_C(I,o,r,{simultaneouslyUpdated:pG(w)})})}},qa=(e,n)=>{let o=hG(n).map(r=>gG(e,r).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(r=>!fG(r)).forEach(r=>{o.push({[r.id]:!0})}),o};import{jsx as gE,jsxs as IG}from"react/jsx-runtime";var vG=({label:e,icon:n,dragInputCallback:t,value:o,elements:r,editable:i=!0,shouldKeepAspectRatio:a,property:s,scene:l,appState:c,sensitivity:d=1,dragFinishedCallback:m})=>{let p=St(),u=Fe(),E=Ip(null),g=Ip(null),[b,y]=xG(o.toString()),w=Ip(null);w.current||(w.current={originalAppState:hE(c),originalElements:r,lastUpdatedValue:b,updatePending:!1}),FC(()=>{let T=o.toString();y(T),w.current.lastUpdatedValue=T},[o]);let x=(T,C,P)=>{if(!w.current.updatePending)return!1;w.current.updatePending=!1;let A=Number(T);if(isNaN(A)){y(o.toString());return}let D=Number(A.toFixed(2)),_=Number(o);(isNaN(_)||Math.abs(D-_)>=BC)&&(w.current.lastUpdatedValue=T,t({accumulatedChange:0,instantChange:0,originalElements:C,originalElementsMap:p.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:l,nextValue:D,property:s,originalAppState:P,setInputValue:k=>y(String(k)),app:p,setAppState:u}),p.syncActionResult({captureUpdate:OC.IMMEDIATELY}))},I=Ip({});return I.current.handleInputValue=x,FC(()=>{let T=E.current,C=I.current;return()=>{let P=T?.value;P&&C.handleInputValue?.(P,w.current.originalElements,w.current.originalAppState),window.removeEventListener(Ja.POINTER_MOVE,C.onPointerMove,!1),window.removeEventListener(Ja.POINTER_UP,C.onPointerUp,!1)}},[i]),i?IG("div",{className:bG("drag-input-container",!i&&"disabled"),"data-testid":e,children:[gE("div",{className:"drag-input-label",ref:g,onPointerDown:T=>{if(E.current&&i){document.body.classList.add("excalidraw-cursor-resize");let C=Number(E.current.value);isNaN(C)&&(C=0);let P=null,A=p.scene.getNonDeletedElements().reduce((z,U)=>(z.set(U.id,wG(U)),z),new Map),D=r.map(z=>A.get(z.id)),_=hE(c),k=0,L=0,B=z=>{if(P&&A!==null&&D!==null){let U=z.clientX-P.x;U!==0&&(L+=U,Math.abs(L)>=d&&(L=Math.sign(L)*Math.floor(Math.abs(L)/d),k+=L,t({accumulatedChange:k,instantChange:L,originalElements:D,originalElementsMap:A,shouldKeepAspectRatio:a,shouldChangeByStepSize:z.shiftKey,property:s,scene:l,originalAppState:_,setInputValue:K=>y(String(K)),app:p,setAppState:u}),L=0))}P={x:z.clientX,y:z.clientY}},V=()=>{window.removeEventListener(Ja.POINTER_MOVE,B,!1),p.syncActionResult({captureUpdate:OC.IMMEDIATELY}),m?.({app:p,setAppState:u,originalElements:D,originalAppState:_}),P=null,k=0,L=0,D=null,A=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(Ja.POINTER_UP,V,!1)};I.current.onPointerMove=B,I.current.onPointerUp=V,window.addEventListener(Ja.POINTER_MOVE,B,!1),window.addEventListener(Ja.POINTER_UP,V,!1)}},onPointerEnter:()=>{g.current&&(g.current.style.cursor="ew-resize")},children:n?gE(ud,{icon:n}):e}),gE("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:T=>{if(i){let C=T.target;C instanceof HTMLInputElement&&T.key===yG.ENTER&&(x(C.value,r,c),p.focusContainer())}},ref:E,value:b,onChange:T=>{w.current.updatePending=!0,y(T.target.value)},onFocus:T=>{T.target.select(),w.current.originalElements=r,w.current.originalAppState=hE(c)},onBlur:T=>{b?i&&x(T.target.value,w.current.originalElements,w.current.originalAppState):y(o.toString())},disabled:!i})]}):null},gt=vG;import{jsx as kG}from"react/jsx-runtime";var SG=15,CG=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r,app:i})=>{let a=r.getNonDeletedElementsMap(),s=n[0];if(s&&!TG(s)){let l=a.get(s.id);if(!l)return;if(o!==void 0){let E=zC(o);r.mutateElement(l,{angle:E}),UC(l,r,i.state);let g=GC(l,a);g&&!HC(l)&&r.mutateElement(g,{angle:E});return}let c=Math.round(WC(s.angle)*100)/100,d=Math.round(e),m=(c+d)%360;t&&(m=We(m,SG)),m=m<0?m+360:m;let p=zC(m);r.mutateElement(l,{angle:p}),UC(l,r,i.state);let u=GC(l,a);u&&!HC(l)&&r.mutateElement(u,{angle:p})}},PG=({element:e,scene:n,appState:t,property:o})=>kG(gt,{label:"A",icon:zc,value:Math.round(WC(e.angle)%360*100)/100,elements:[e],dragInputCallback:CG,editable:Wt(e,"angle"),scene:n,appState:t,property:o}),VC=PG;import{jsx as AG}from"react/jsx-runtime";var YC=5,MG=({property:e,scene:n,appState:t,setAppState:o})=>AG(gt,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:r,instantChange:i,shouldChangeByStepSize:a,setInputValue:s})=>{o(l=>{let c;return r?c=r:i&&(c=a?We(l.gridStep+YC*Math.sign(i),YC):l.gridStep+i),c?(c=Qb(c),s(c),{gridStep:c}):(s(l.gridStep),null)})},scene:n,value:t.gridStep,property:e,appState:t}),XC=MG;import{clamp as Tp,round as fE}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as Sp}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as KC,getNonDeletedElements as DG,getUncroppedWidthAndHeight as jC}from"@excalidraw/element";import{resizeSingleElement as $C}from"@excalidraw/element";import{isImageElement as qC}from"@excalidraw/element";import{isFrameLikeElement as EE}from"@excalidraw/element";import{getElementsInResizingFrame as bE}from"@excalidraw/element";import{replaceAllElementsInFrame as JC}from"@excalidraw/element";import{jsx as BG}from"react/jsx-runtime";var ZC=10,LG=e=>e.type==="image",_G=({accumulatedChange:e,originalElements:n,originalElementsMap:t,shouldKeepAspectRatio:o,shouldChangeByStepSize:r,nextValue:i,property:a,originalAppState:s,instantChange:l,scene:c,app:d,setAppState:m})=>{let p=c.getNonDeletedElementsMap(),u=n[0],E=p.get(u.id);if(u&&E){let g=o||LG(u),b=u.width/u.height;if(s.croppingElementId===u.id){let y=p.get(u.id);if(!y||!qC(y)||!y.crop)return;let w=y.crop,x={...w},I=y.scale[0]===-1,T=y.scale[1]===-1,{width:C,height:P}=jC(y),A=w.naturalWidth/C,D=w.naturalHeight/P,_=I?w.width+w.x:w.naturalWidth-w.x,k=T?w.height+w.y:w.naturalHeight-w.y,L=KC*A,B=KC*D;if(i!==void 0){if(a==="width"){let G=i*A,te=Tp(G,L,_);x={...x,width:te,x:I?w.x+w.width-te:w.x}}else if(a==="height"){let G=i*D,te=Tp(G,B,k);x={...x,height:te,y:T?w.y+w.height-te:w.y}}c.mutateElement(y,{crop:x,width:x.width/(w.naturalWidth/C),height:x.height/(w.naturalHeight/P)});return}let V=a==="width"?l:0,z=a==="height"?l:0,U=Tp(w.width+V,L,_),K=Tp(w.height+z,L,k);x={...w,x:I?w.x+w.width-U:w.x,y:T?w.y+w.height-K:w.y,width:U,height:K},c.mutateElement(y,{crop:x,width:x.width/(w.naturalWidth/C),height:x.height/(w.naturalHeight/P)});return}if(i!==void 0){let y=Math.max(a==="width"?i:g?i*b:u.width,Sp),w=Math.max(a==="height"?i:g?i/b:u.height,Sp);if($C(y,w,E,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),EE(E)){let x=bE(c.getElementsIncludingDeleted(),E,s,c.getNonDeletedElementsMap()),I=JC(c.getElementsIncludingDeleted(),x,E);c.replaceAllElements(I)}return}{let y=a==="width"?e:0,w=a==="height"?e:0,x=Math.max(0,u.width+y);a==="width"&&(r?x=We(x,ZC):x=Math.round(x));let I=Math.max(0,u.height+w);if(a==="height"&&(r?I=We(I,ZC):I=Math.round(I)),g&&(a==="width"?I=Math.round(x/b*100)/100:x=Math.round(I*b*100)/100),I=Math.max(Sp,I),x=Math.max(Sp,x),$C(x,I,E,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),EE(E)){let T=DG(bE(c.getElementsIncludingDeleted(),E,s,c.getNonDeletedElementsMap()));m({elementsToHighlight:T})}}}},RG=({setAppState:e,app:n,originalElements:t,originalAppState:o})=>{let r=n.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&EE(a)){let s=bE(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),l=JC(n.scene.getElementsIncludingDeleted(),s,a);n.scene.replaceAllElements(l),e({elementsToHighlight:null})}},NG=({property:e,element:n,scene:t,appState:o})=>{let r=fE(e==="width"?n.width:n.height,2);if(o.croppingElementId&&o.croppingElementId===n.id&&qC(n)&&n.crop){let{width:i,height:a}=jC(n);if(e==="width"){let s=i/n.crop.naturalWidth;r=fE(n.crop.width*s,2)}if(e==="height"){let s=a/n.crop.naturalHeight;r=fE(n.crop.height*s,2)}}return BG(gt,{label:e==="width"?"W":"H",elements:[n],dragInputCallback:_G,value:r,editable:Wt(n,e),scene:t,appState:o,property:e,dragFinishedCallback:RG})},xE=NG;import{getBoundTextElement as FG,redrawTextBoundingBox as OG}from"@excalidraw/element";import{hasBoundTextElement as zG,isTextElement as eP}from"@excalidraw/element";import{jsx as WG}from"react/jsx-runtime";var QC=4,GG=4,HG=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=n[0];if(a){let s=i.get(a.id);if(!s||!eP(s))return;let l;if(o!==void 0)l=Math.max(Math.round(o),QC);else if(a.type==="text"){let c=Math.round(a.fontSize),d=Math.round(e);l=Math.max(c+d,QC),t&&(l=We(l,GG))}l&&(r.mutateElement(s,{fontSize:l}),OG(s,r.getContainerElement(s),r))}},UG=({element:e,scene:n,appState:t,property:o})=>{let r=eP(e)?e:zG(e)?FG(e,n.getNonDeletedElementsMap()):null;return r?WG(gt,{label:"F",value:Math.round(r.fontSize*10)/10,elements:[r],dragInputCallback:HG,icon:Nr,appState:t,scene:n,property:o}):null},tP=UG;import{degreesToRadians as nP,radiansToDegrees as iP}from"@excalidraw/math";import{getBoundTextElement as oP}from"@excalidraw/element";import{isArrowElement as rP}from"@excalidraw/element";import{isInGroup as yE}from"@excalidraw/element";import{jsx as KG}from"react/jsx-runtime";var VG=15,YG=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,property:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),s=n.map(c=>a.get(c.id)).filter(c=>c&&!yE(c)&&Wt(c,r)),l=n.filter(c=>!yE(c)&&Wt(c,r));if(o!==void 0){let c=nP(o);for(let d of s){if(!d)continue;i.mutateElement(d,{angle:c});let m=oP(d,a);m&&!rP(d)&&i.mutateElement(m,{angle:c})}i.triggerUpdate();return}for(let c=0;c<s.length;c++){let d=s[c];if(!d)continue;let m=l[c],p=Math.round(iP(m.angle)*100)/100,u=Math.round(e),E=(p+u)%360;t&&(E=We(E,VG)),E=E<0?E+360:E;let g=nP(E);i.mutateElement(d,{angle:g});let b=oP(d,a);b&&!rP(d)&&i.mutateElement(b,{angle:g})}i.triggerUpdate()},XG=({elements:e,scene:n,appState:t,property:o})=>{let r=e.filter(l=>!yE(l)&&Wt(l,"angle")),i=r.map(l=>Math.round(iP(l.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",s=r.some(l=>Wt(l,"angle"));return KG(gt,{label:"A",icon:zc,value:a,elements:e,dragInputCallback:YG,editable:s,appState:t,scene:n,property:o})},aP=XG;import{pointFrom as dP}from"@excalidraw/math";import{useMemo as ZG}from"react";import{MIN_WIDTH_OR_HEIGHT as xr}from"@excalidraw/common";import{getElementsInResizingFrame as wE,getNonDeletedElements as jG,isFrameLikeElement as vE,replaceAllElementsInFrame as uP,updateBoundElements as qG}from"@excalidraw/element";import{rescalePointsInElement as JG,resizeSingleElement as mP}from"@excalidraw/element";import{getBoundTextElement as QG,handleBindTextResize as eH}from"@excalidraw/element";import{isTextElement as hP}from"@excalidraw/element";import{MIME_TYPES as ci}from"@excalidraw/common";import{getNonDeletedElements as sP}from"@excalidraw/element";var Cp=({elements:e,appState:n,files:t,maxWidthOrHeight:o,getDimensions:r,exportPadding:i,exportingFrame:a})=>{let s=sP(Dr(e,null,{deleteInvisibleElements:!0})),l=Ti(n,null),{exportBackground:c,viewBackgroundColor:d}=l;return Cc(s,{...l,offsetTop:0,offsetLeft:0,width:0,height:0},t||{},{exportBackground:c,exportPadding:i,viewBackgroundColor:d,exportingFrame:a},(m,p)=>{let u=document.createElement("canvas");if(o){typeof r=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let g=Math.max(m,p),b=o<g?o/g:n?.exportScale??1;return u.width=m*b,u.height=p*b,{canvas:u,scale:b}}let E=r?.(m,p)||{width:m,height:p};return u.width=E.width,u.height=E.height,{canvas:u,scale:E.scale??1}})},lP=async e=>{let{mimeType:n=ci.png,quality:t}=e;n===ci.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${ci.png}" mimeType`),n==="image/jpg"&&(n=ci.jpg),n===ci.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${ci.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let o=await Cp(e);return t=t||(/image\/jpe?g/.test(n)?.92:.8),new Promise((r,i)=>{o.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&n===ci.png&&e.appState?.exportEmbedScene&&(a=await mx({blob:a,metadata:us(e.elements,e.appState,e.files||{},"local")})),r(a)},n,t)})},cP=async({elements:e,appState:n=Ho(),files:t={},exportPadding:o,renderEmbeddables:r,exportingFrame:i,skipInliningFonts:a,reuseImages:s})=>{let l=sP(Dr(e,null,{deleteInvisibleElements:!0})),d={...Ti(n,null),exportPadding:o};return Ar(l,d,t,{exportingFrame:i,renderEmbeddables:r,skipInliningFonts:a,reuseImages:s})},$G=async e=>{if(e.type==="svg"){let n=await cP(e);await vo(n.outerHTML)}else if(e.type==="png")await Yd(lP(e));else if(e.type==="json")await Ud(e.elements,e.files);else throw new Error("Invalid export type")};import{elementsOverlappingBBox as nNe}from"@excalidraw/element";import{getCommonBounds as Pp}from"@excalidraw/element";import{jsx as aH}from"react/jsx-runtime";var Qa=10,tH=(e,n,t,o)=>{let r=o.x-e,i=o.y-n,a=o.width*t,s=o.height*t,l=e+r*t,c=n+i*t;return{width:a,height:s,x:l,y:c,...JG(o,a,s,!1),...hP(o)?{fontSize:o.fontSize*t}:{}}},nH=(e,n,t,o,r,i,a,s)=>{let l=s.getNonDeletedElementsMap(),c=tH(e,n,o,i);s.mutateElement(r,c);let d=QG(i,a);if(d){let m=d.fontSize*o;qG(r,s);let p=l.get(d.id);p&&hP(p)&&(s.mutateElement(p,{fontSize:m}),eH(r,s,t==="width"?"e":"s",!0))}},pP=(e,n,t,o,r,i,a,s,l,c)=>{i==="width"?n=Math.round(e/o*100)/100:e=Math.round(n*o*100)/100;let d=n/t;for(let m=0;m<s.length;m++){let p=s[m],u=a[m];nH(r[0],r[1],i,d,u,p,l,c)}},oH=({accumulatedChange:e,originalElements:n,originalElementsMap:t,originalAppState:o,shouldChangeByStepSize:r,nextValue:i,scene:a,property:s,setAppState:l,app:c})=>{let d=a.getNonDeletedElementsMap(),m=qa(n,o);if(i!==void 0){for(let g of m){let b=ja(g,d,t);if(b.length>1){let y=b.map(L=>L.latest),w=b.map(L=>L.original),[x,I,T,C]=Pp(w),P=T-x,A=C-I,D=P/A,_=Math.max(xr,s==="width"?Math.max(0,i):P),k=Math.max(xr,s==="height"?Math.max(0,i):A);pP(_,k,A,D,dP(x,I),s,y,w,t,a)}else{let[y]=b,w=y?.latest,x=y?.original;if(w&&x&&Wt(w,s)){let I=s==="width"?Math.max(0,i):w.width;s==="width"&&(r?I=We(I,Qa):I=Math.round(I));let T=s==="height"?Math.max(0,i):w.height;if(s==="height"&&(r?T=We(T,Qa):T=Math.round(T)),I=Math.max(xr,I),T=Math.max(xr,T),mP(I,T,w,x,t,a,s==="width"?"e":"s",{shouldInformMutation:!1}),vE(w)){let C=wE(a.getElementsIncludingDeleted(),w,o,a.getNonDeletedElementsMap()),P=uP(a.getElementsIncludingDeleted(),C,w);a.replaceAllElements(P)}}}}a.triggerUpdate();return}let p=s==="width"?e:0,u=s==="height"?e:0,E=[];for(let g of m){let b=ja(g,d,t);if(b.length>1){let y=b.map(L=>L.latest),w=b.map(L=>L.original),[x,I,T,C]=Pp(w),P=T-x,A=C-I,D=P/A,_=Math.max(0,P+p);s==="width"&&(r?_=We(_,Qa):_=Math.round(_));let k=Math.max(0,A+u);s==="height"&&(r?k=We(k,Qa):k=Math.round(k)),_=Math.max(xr,_),k=Math.max(xr,k),pP(_,k,A,D,dP(x,I),s,y,w,t,a)}else{let[y]=b,w=y?.latest,x=y?.original;if(w&&x&&Wt(w,s)){let I=Math.max(0,x.width+p);s==="width"&&(r?I=We(I,Qa):I=Math.round(I));let T=Math.max(0,x.height+u);if(s==="height"&&(r?T=We(T,Qa):T=Math.round(T)),I=Math.max(xr,I),T=Math.max(xr,T),mP(I,T,w,x,t,a,s==="width"?"e":"s",{shouldInformMutation:!1}),vE(w)){let C=jG(wE(a.getElementsIncludingDeleted(),w,o,a.getNonDeletedElementsMap()));E.push(...C)}}}}l({elementsToHighlight:E}),a.triggerUpdate()},rH=({setAppState:e,app:n,originalElements:t,originalAppState:o})=>{let r=n.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&vE(a)){let s=wE(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),l=uP(n.scene.getElementsIncludingDeleted(),s,a);n.scene.replaceAllElements(l),e({elementsToHighlight:null})}},iH=({property:e,elements:n,elementsMap:t,atomicUnits:o,scene:r,appState:i})=>{let a=ZG(()=>o.map(c=>{let d=ja(c,t);if(d.length>1){let[p,u,E,g]=Pp(d.map(b=>b.latest));return Math.round((e==="width"?E-p:g-u)*100)/100}let[m]=d;return Math.round((e==="width"?m.latest.width:m.latest.height)*100)/100}),[t,o,e]),s=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",l=a.length>0;return aH(gt,{label:e==="width"?"W":"H",elements:n,dragInputCallback:oH,value:s,editable:l,appState:i,property:e,scene:r,dragFinishedCallback:rH})},IE=iH;import{getBoundTextElement as sH,redrawTextBoundingBox as gP}from"@excalidraw/element";import{hasBoundTextElement as lH,isTextElement as cH}from"@excalidraw/element";import{isInGroup as dH}from"@excalidraw/element";import{jsx as gH}from"react/jsx-runtime";var fP=4,mH=4,pH=(e,n)=>e.reduce((t,o)=>{if(!o||dH(o))return t;if(cH(o))return t.push(o),t;if(lH(o)){let r=sH(o,n);if(r)return t.push(r),t}return t},[]),uH=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=n.map(l=>i.get(l.id)),s;if(o){s=Math.max(Math.round(o),fP);for(let l of a)r.mutateElement(l,{fontSize:s}),gP(l,r.getContainerElement(l),r);r.triggerUpdate()}else{let l=n;for(let c=0;c<a.length;c++){let d=a[c],m=l[c],p=Math.round(m.fontSize),u=Math.round(e),E=Math.max(p+u,fP);t&&(E=We(E,mH)),r.mutateElement(d,{fontSize:E}),gP(d,r.getContainerElement(d),r)}r.triggerUpdate()}},hH=({elements:e,scene:n,appState:t,property:o,elementsMap:r})=>{let i=pH(e,r);if(!i.length)return null;let a=i.map(c=>Math.round(c.fontSize*10)/10),s=new Set(a).size===1?a[0]:"Mixed",l=a.length>0;return gH(gt,{label:"F",icon:Nr,elements:i,dragInputCallback:uH,value:s,editable:l,scene:n,property:o,appState:t})},EP=hH;import{pointFrom as yr,pointRotateRads as kp}from"@excalidraw/math";import{useMemo as fH}from"react";import{isTextElement as EH}from"@excalidraw/element";import{getCommonBounds as TE}from"@excalidraw/element";import{jsx as vH}from"react/jsx-runtime";var bH=(e,n,t,o,r,i,a)=>{for(let s=0;s<o.length;s++){let l=o[s],[c,d]=[l.x+l.width/2,l.y+l.height/2],[m,p]=kp(yr(l.x,l.y),yr(c,d),l.angle),u=e==="x"?Math.round(m+n):m,E=e==="y"?Math.round(p+t):p;li(u,E,l,i,a,r,!1)}},xH=(e,n,t,o,r,i)=>{let a=r.getNonDeletedElementsMap(),[s,l,,]=TE(t),c=e-s,d=n-l;for(let m=0;m<t.length;m++){let p=t[m],u=a.get(p.id);if(u&&(!EH(u)||!u.containerId)){let[E,g]=[u.x+u.width/2,u.y+u.height/2],[b,y]=kp(yr(u.x,u.y),yr(E,g),u.angle);li(b+c,y+d,p,r,i,o,!1)}}},yH=({accumulatedChange:e,originalElements:n,originalElementsMap:t,shouldChangeByStepSize:o,nextValue:r,property:i,scene:a,originalAppState:s,app:l})=>{let c=a.getNonDeletedElementsMap();if(r!==void 0){for(let u of qa(n,s)){let E=ja(u,c,t);if(E.length>1){let[g,b,,]=TE(E.map(x=>x.latest));xH(i==="x"?r:g,i==="y"?r:b,E.map(x=>x.original),t,a,l.state)}else{let g=E[0]?.original,b=E[0]?.latest;if(g&&b&&Wt(b,i)){let[y,w]=[g.x+g.width/2,g.y+g.height/2],[x,I]=kp(yr(g.x,g.y),yr(y,w),g.angle);li(i==="x"?r:x,i==="y"?r:I,g,a,l.state,t,!1)}}}a.triggerUpdate();return}let d=o?We(e,Kl):e;bH(i,i==="x"?d:0,i==="y"?d:0,n,t,a,l.state),a.triggerUpdate()},wH=({property:e,elements:n,elementsMap:t,atomicUnits:o,scene:r,appState:i})=>{let a=fH(()=>o.map(l=>{let c=Object.keys(l).map(g=>t.get(g)).filter(g=>g!==void 0);if(c.length>1){let[g,b]=TE(c);return Math.round((e==="x"?g:b)*100)/100}let[d]=c,[m,p]=[d.x+d.width/2,d.y+d.height/2],[u,E]=kp(yr(d.x,d.y),yr(m,p),d.angle);return Math.round((e==="x"?u:E)*100)/100}),[o,t,e]),s=new Set(a).size===1?a[0]:"Mixed";return vH(gt,{label:e==="x"?"X":"Y",elements:n,dragInputCallback:yH,value:s,property:e,scene:r,appState:i})},SE=wH;import{clamp as $l,pointFrom as Mp,pointRotateRads as xP,round as bP}from"@excalidraw/math";import{getFlipAdjustedCropPosition as IH,getUncroppedWidthAndHeight as TH}from"@excalidraw/element";import{isImageElement as yP}from"@excalidraw/element";import{jsx as PH}from"react/jsx-runtime";var SH=({accumulatedChange:e,instantChange:n,originalElements:t,originalElementsMap:o,shouldChangeByStepSize:r,nextValue:i,property:a,scene:s,originalAppState:l,app:c})=>{let d=s.getNonDeletedElementsMap(),m=t[0],[p,u]=[m.x+m.width/2,m.y+m.height/2],[E,g]=xP(Mp(m.x,m.y),Mp(p,u),m.angle);if(l.croppingElementId===m.id){let I=d.get(m.id);if(!I||!yP(I)||!I.crop)return;let T=I.crop,C=T,P=I.scale[0]===-1,A=I.scale[1]===-1,{width:D,height:_}=TH(I);if(i!==void 0){if(a==="x"){let B=i*(T.naturalWidth/D);P?C={...T,x:$l(T.naturalWidth-B-T.width,0,T.naturalWidth-T.width)}:C={...T,x:$l(i*(T.naturalWidth/D),0,T.naturalWidth-T.width)}}a==="y"&&(C={...T,y:$l(i*(T.naturalHeight/_),0,T.naturalHeight-T.height)}),s.mutateElement(I,{crop:C});return}let k=(a==="x"?n:0)*(P?-1:1),L=(a==="y"?n:0)*(A?-1:1);C={...T,x:$l(T.x+k,0,T.naturalWidth-T.width),y:$l(T.y+L,0,T.naturalHeight-T.height)},s.mutateElement(I,{crop:C});return}if(i!==void 0){li(a==="x"?i:E,a==="y"?i:g,m,s,c.state,o);return}let b=a==="x"?e:0,y=a==="y"?e:0,w=a==="x"?Math.round(r?We(m.x+b,Kl):E+b):E,x=a==="y"?Math.round(r?We(m.y+y,Kl):g+y):g;li(w,x,m,s,c.state,o)},CH=({property:e,element:n,scene:t,appState:o})=>{let[r,i]=xP(Mp(n.x,n.y),Mp(n.x+n.width/2,n.y+n.height/2),n.angle),a=bP(e==="x"?r:i,2);if(o.croppingElementId===n.id&&yP(n)&&n.crop){let s=IH(n);s&&(a=bP(e==="x"?s.x:s.y,2))}return PH(gt,{label:e==="x"?"X":"Y",elements:[n],dragInputCallback:SH,scene:t,value:a,property:e,appState:o})},CE=CH;import{Fragment as ME,jsx as ne,jsxs as Vt}from"react/jsx-runtime";var BH=50,Zl=e=>{let n=Qn(),t=e.app.scene.getSceneNonce()||1,o=e.app.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}),r=cr(e.app);return ne(FH,{...e,appState:n,sceneNonce:t,selectedElements:o,gridModeEnabled:r})},Oe=({children:e,columns:n=1,heading:t,style:o,...r})=>ne("div",{className:kH("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${n}, 1fr)`,...o},...r,children:e});Oe.displayName="StatsRow";var Dp=({children:e,order:n,style:t,...o})=>ne("div",{className:"exc-stats__rows",style:{order:n,...t},...o,children:e});Dp.displayName="StatsRows";Zl.StatsRow=Oe;Zl.StatsRows=Dp;var FH=DH(({app:e,onClose:n,renderCustomStats:t,selectedElements:o,appState:r,sceneNonce:i,gridModeEnabled:a})=>{let s=e.scene,l=s.getNonDeletedElements(),c=s.getNonDeletedElementsMap(),d=Fe(),m=o.length===1?o[0]:null,p=o.length>1?o:null,u=r.croppingElementId&&kE(m),E=u?_H(m):null,[g,b]=AH({width:0,height:0}),y=PE(()=>MH(I=>{let T=LH(I);b({width:Math.round(T[2])-Math.round(T[0]),height:Math.round(T[3])-Math.round(T[1])})},BH),[]);vP(()=>{y(l)},[i,l,y]),vP(()=>()=>y.cancel(),[y]);let w=PE(()=>qa(o,r),[o,r]),x=PE(()=>RH(o),[o]);return ne("div",{className:"exc-stats",children:Vt(Ue,{padding:3,children:[Vt("div",{className:"title",children:[ne("h2",{children:f("stats.title")}),ne("div",{className:"close",onClick:n,children:rn})]}),Vt(Os,{label:ne("h3",{children:f("stats.generalStats")}),open:!!(r.stats.panels&Ap.generalStats),openTrigger:()=>d(I=>({stats:{open:!0,panels:I.stats.panels^Ap.generalStats}})),children:[Vt(Dp,{children:[ne(Oe,{heading:!0,children:f("stats.scene")}),Vt(Oe,{columns:2,children:[ne("div",{children:f("stats.shapes")}),ne("div",{children:l.length})]}),Vt(Oe,{columns:2,children:[ne("div",{children:f("stats.width")}),ne("div",{children:g.width})]}),Vt(Oe,{columns:2,children:[ne("div",{children:f("stats.height")}),ne("div",{children:g.height})]}),a&&Vt(ME,{children:[ne(Oe,{heading:!0,children:"Canvas"}),ne(Oe,{children:ne(XC,{property:"gridStep",scene:s,appState:r,setAppState:d})})]})]}),t?.(l,r)]}),!x&&o.length>0&&ne("div",{id:"elementStats",style:{marginTop:12},children:ne(Os,{label:ne("h3",{children:f("stats.elementProperties")}),open:!!(r.stats.panels&Ap.elementProperties),openTrigger:()=>d(I=>({stats:{open:!0,panels:I.stats.panels^Ap.elementProperties}})),children:Vt(Dp,{children:[m&&Vt(ME,{children:[u&&ne(Oe,{heading:!0,children:f("labels.unCroppedDimension")}),r.croppingElementId&&kE(m)&&E&&Vt(Oe,{columns:2,children:[ne("div",{children:f("stats.width")}),ne("div",{children:wP(E.width,2)})]}),r.croppingElementId&&kE(m)&&E&&Vt(Oe,{columns:2,children:[ne("div",{children:f("stats.height")}),ne("div",{children:wP(E.height,2)})]}),ne(Oe,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:r.croppingElementId?f("labels.imageCropping"):m.type==="magicframe"?f("element.frame"):f(`element.${m.type}`)}),ne(Oe,{children:ne(CE,{element:m,property:"x",elementsMap:c,scene:s,appState:r})}),ne(Oe,{children:ne(CE,{element:m,property:"y",elementsMap:c,scene:s,appState:r})}),ne(Oe,{children:ne(xE,{property:"width",element:m,scene:s,appState:r})}),ne(Oe,{children:ne(xE,{property:"height",element:m,scene:s,appState:r})}),ne(Oe,{children:ne(VC,{property:"angle",element:m,scene:s,appState:r})}),ne(Oe,{children:ne(tP,{property:"fontSize",element:m,scene:s,appState:r})})]}),p&&Vt(ME,{children:[NH(p)&&ne(Oe,{heading:!0,children:f("element.group")}),Vt(Oe,{columns:2,style:{margin:"0.3125rem 0"},children:[ne("div",{children:f("stats.shapes")}),ne("div",{children:o.length})]}),ne(Oe,{children:ne(SE,{property:"x",elements:p,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),ne(Oe,{children:ne(SE,{property:"y",elements:p,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),ne(Oe,{children:ne(IE,{property:"width",elements:p,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),ne(Oe,{children:ne(IE,{property:"height",elements:p,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),ne(Oe,{children:ne(aP,{property:"angle",elements:p,scene:s,appState:r})}),ne(Oe,{children:ne(EP,{property:"fontSize",elements:p,scene:s,appState:r,elementsMap:c})})]})]})})})]})})},(e,n)=>e.sceneNonce===n.sceneNonce&&e.selectedElements===n.selectedElements&&e.appState.stats.panels===n.appState.stats.panels&&e.gridModeEnabled===n.gridModeEnabled&&e.appState.gridStep===n.appState.gridStep&&e.appState.croppingElementId===n.appState.croppingElementId);import{useCallback as ZH,useEffect as TP,useState as SP}from"react";import{normalizeLink as jH,KEYS as _E}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as qH,getLinkIdAndTypeFromSelection as JH}from"@excalidraw/element";import OH from"clsx";import{jsx as Lp,jsxs as GH}from"react/jsx-runtime";var zH=({label:e,onClick:n,className:t,children:o,actionType:r,type:i="button",isLoading:a,...s})=>{let l=r?`Dialog__action-button--${r}`:"";return GH("button",{className:OH("Dialog__action-button",l,t),type:i,"aria-label":e,onClick:n,...s,children:[o&&Lp("div",{style:a?{visibility:"hidden"}:{},children:o}),Lp("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&Lp("div",{style:{position:"absolute",inset:0},children:Lp(Eo,{})})]})},AE=zH;import DE from"clsx";import{forwardRef as VH,useRef as YH,useImperativeHandle as XH,useLayoutEffect as KH,useState as $H}from"react";import HH from"clsx";import{composeEventHandlers as UH}from"@excalidraw/common";import{jsx as WH}from"react/jsx-runtime";var wn=({type:e="button",onSelect:n,selected:t,children:o,className:r="",...i})=>WH("button",{onClick:UH(i.onClick,a=>{n()}),type:e,className:HH("excalidraw-button",r,{selected:t}),...i,children:o});import{jsx as LE,jsxs as IP}from"react/jsx-runtime";var _p=VH(({onChange:e,label:n,fullWidth:t,placeholder:o,readonly:r,selectOnRender:i,onKeyDown:a,isRedacted:s=!1,icon:l,className:c,type:d,...m},p)=>{let u=YH(null);XH(p,()=>u.current),KH(()=>{i&&(u.current?.focus(),u.current?.select())},[i]);let[E,g]=$H(!1);return IP("div",{className:DE("ExcTextField",c,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!l}),onClick:()=>{u.current?.focus()},children:[l,n&&LE("div",{className:"ExcTextField__label",children:n}),IP("div",{className:DE("ExcTextField__input",{"ExcTextField__input--readonly":r}),children:[LE("input",{className:DE({"is-redacted":"value"in m&&m.value&&s&&!E}),readOnly:r,value:"value"in m?m.value:void 0,defaultValue:"defaultValue"in m?m.defaultValue:void 0,placeholder:o,ref:u,onChange:b=>e?.(b.target.value),onKeyDown:a,type:d}),s&&LE(wn,{onSelect:()=>g(!E),style:{border:0,userSelect:"none"},children:E?j1:Fr})]})]})});import{jsx as es,jsxs as Rp}from"react/jsx-runtime";var QH=({sourceElementId:e,onClose:n,appState:t,scene:o,generateLinkForSelection:r=qH})=>{let i=o.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[s,l]=SP(a),[c,d]=SP(!1);TP(()=>{let p=ce(i,t),u=a;if(p.length>0&&r){let E=JH(p,t);E&&(u=jH(r(E.id,E.type)))}l(u)},[i,t,t.selectedElementIds,a,r]);let m=ZH(()=>{if(s&&s!==i.get(e)?.link){let p=i.get(e);p&&o.mutateElement(p,{link:s})}if(!s&&c&&e){let p=i.get(e);p&&o.mutateElement(p,{link:null})}n?.()},[e,s,i,c,o,n]);return TP(()=>{let p=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===_E.ENTER&&m(),t.openDialog?.name==="elementLinkSelector"&&u.key===_E.ESCAPE&&n?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[t,n,m]),Rp("div",{className:"ElementLinkDialog",children:[Rp("div",{className:"ElementLinkDialog__header",children:[es("h2",{children:f("elementLink.title")}),es("p",{children:f("elementLink.desc")})]}),Rp("div",{className:"ElementLinkDialog__input",children:[es(_p,{value:s??"",onChange:p=>{c||d(!0),l(p)},onKeyDown:p=>{p.key===_E.ENTER&&m()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&s&&es($,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:()=>{l(null),d(!0)},className:"ElementLinkDialog__remove",icon:Rr})]}),Rp("div",{className:"ElementLinkDialog__actions",children:[es(AE,{label:f("buttons.cancel"),onClick:()=>{n?.()},style:{marginRight:10}}),es(AE,{label:f("buttons.confirm"),onClick:m,actionType:"primary"})]})]})},CP=QH;import eU,{useState as tU}from"react";import{Fragment as nU,jsx as RE}from"react/jsx-runtime";var PP=({children:e,onClose:n})=>{let[t,o]=tU(!!e),{container:r}=Re(),i=eU.useCallback(()=>{o(!1),n&&n(),r?.focus()},[n,r]);return RE(nU,{children:t&&RE(yn,{size:"small",onCloseRequest:i,title:f("errorDialog.title"),children:RE("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import kP from"clsx";import wr from"react";import{MIME_TYPES as MP,sceneCoordsToViewportCoords as NE}from"@excalidraw/common";import{getCommonBounds as _P,isInitializedImageElement as AP,ShapeCache as oU}from"@excalidraw/element";import{Fragment as lU,jsx as kt,jsxs as di}from"react/jsx-runtime";var rU=kt("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:kt("path",{d:"M8 5v14l11 -7z"})}),iU=di("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[kt("path",{d:"M8 5v14"}),kt("path",{d:"M16 5v14"})]}),aU=76,RP=4,jl=aU+RP,DP=8,mi=8,sU=(e,n)=>{let t=n/2;return Math.min(Math.max(e,t+mi),window.innerWidth-t-mi)},LP=(e,n)=>{let[,,t,o]=_P([e]),r=NE({sceneX:t,sceneY:o},n);return{left:Math.min(Math.max(r.x-n.offsetLeft,8),n.width-8),top:Math.min(Math.max(r.y-n.offsetTop,8),n.height-8)}},NP=({app:e,files:n,setAppState:t})=>{let o=Qn(),[,r]=wr.useReducer(y=>y+1,0),[i,a]=wr.useState(0),s=wr.useRef(null),l=wr.useRef(null),c=wr.useRef(null),d=wr.useRef(null),[m,p]=wr.useState(null);wr.useLayoutEffect(()=>{let y=o.openPopup;if(y!=="gifSpeedPicker"&&y!=="gifFrameGallery"){m!==null&&p(null);return}let w=y==="gifSpeedPicker"?s.current:l.current,x=y==="gifSpeedPicker"?c.current:d.current;if(!w||!x)return;let I=w.getBoundingClientRect(),T=x.getBoundingClientRect(),C=sU(I.left+I.width/2,T.width),P=y==="gifSpeedPicker"?Math.max(mi,I.top-T.height-mi):Math.min(window.innerHeight-T.height-mi,I.bottom+mi),A={left:C,top:Math.max(mi,P)};p(D=>D?.left===A.left&&D.top===A.top?D:A)},[i,m,o.openPopup,o.scrollX,o.scrollY,o.zoom.value]);let u=(y,w)=>{oU.delete(y),e.scene.mutateElement(y,{gifPlayback:w}),e.scheduleUpdate(),t({}),r(),w.playing&&e.ensureGifPlaybackLoop()},E=e.scene.getNonDeletedElements().filter(y=>AP(y)&&!o.selectedElementIds[y.id]&&n[y.fileId]?.mimeType===MP.gif&&e.imageCache.get(y.fileId)?.gifDecodeStatus==="deferred").map(y=>{let w=LP(y,o);return kt("span",{className:"gif-playback-controls gif-playback-controls__deferred-badge",role:"img","aria-label":"GIF paused",style:w,children:Mx},y.id)}),g=e.scene.getSelectedElements(o);return di(lU,{children:[E,(()=>{if(g.length!==1)return null;let y=g[0];if(!AP(y)||n[y.fileId]?.mimeType!==MP.gif)return null;let w=e.imageCache.get(y.fileId),x=w?.gif,[I,,T,C]=_P([y]),P=NE({sceneX:I,sceneY:C},o),D=NE({sceneX:T,sceneY:C},o).x-P.x,_=P.x-o.offsetLeft+D/2,k=Math.max(12,Math.min(o.height-86,P.y-o.offsetTop+16));if(w?.gifDecodeStatus==="deferred"){let re=LP(y,o);return kt("div",{className:"gif-playback-controls gif-playback-controls--deferred",style:re,onPointerDown:lt=>lt.stopPropagation(),children:kt("button",{type:"button",className:"gif-playback-controls__load-large",title:"Load Large GIF",onClick:()=>{e.loadDeferredGif(y.fileId)},children:"Load Large GIF"})})}if(w?.gifDecodeStatus==="pending")return null;let L=x?.frames.length??0;if(!x||L<2)return null;let B=y.gifPlayback??{frameIndex:0,speed:1,playing:!1},V=e.state,z=e.getGifPlaybackFrameIndex(y)??B.frameIndex,U=Math.min(Math.max(z,0),L-1),K=Math.min(V.height-120,k+48),G=Math.max(12,k-52),te=re=>{let lt=(re+L)%L;e.setGifPlaybackFrameIndex(y,lt),u(y,{...B,frameIndex:lt,playing:!1})},F=re=>{re.preventDefault(),re.stopPropagation(),te(U+(re.deltaY<0?1:-1))},W=re=>{e.setGifPlaybackFrameIndex(y,U),u(y,{...B,frameIndex:U,playing:re})},le=[.25,.5,.75,1,1.25,1.5,1.75,2,4],we=re=>{let lt=le.indexOf(re);return lt!==-1?lt:le.reduce(($t,Sn,nn)=>Math.abs(Sn-re)<Math.abs(le[$t]-re)?nn:$t,0)},de=re=>{u(y,{...B,speed:re})},he=re=>{let lt=we(B.speed);de(le[Math.min(Math.max(lt+re,0),le.length-1)])},ve=Number.isInteger(B.speed)?`${B.speed}`:`${B.speed}`,ae=L*jl-RP,fe=Math.min(Math.max(V.width*.9,1),ae),rt=Math.max(ae-fe,0),Ge=Math.min(i,rt),Pe=Math.max(Math.floor(Ge/jl)-DP,0),Wn=Math.ceil(fe/jl)+DP*2,zo=Math.min(Pe+Wn,L),xi=x.frames.slice(Pe,zo);return di("div",{className:"gif-playback-controls",style:{left:_,top:k},onPointerDown:re=>re.stopPropagation(),children:[o.openPopup==="gifSpeedPicker"&&kt("div",{className:"gif-speed-picker",ref:c,style:m??{left:_,top:G},children:le.map(re=>{let lt=Number.isInteger(re)?`${re}`:`${re}`;return di("button",{type:"button",className:kP("gif-speed-picker__speed",{"gif-speed-picker__speed--selected":re===B.speed}),onClick:()=>de(re),title:`${lt}x`,children:["x",lt]},re)})}),di("div",{className:"gif-playback-controls__bar",children:[di("button",{type:"button",className:"gif-playback-controls__button gif-playback-controls__button--speed",ref:s,onClick:()=>t({openPopup:o.openPopup==="gifSpeedPicker"?null:"gifSpeedPicker"}),onWheel:re=>{re.preventDefault(),re.stopPropagation(),he(re.deltaY<0?1:-1)},title:"Speed",children:["x",ve]}),kt("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>te(U-1),onWheel:F,title:"Previous frame",children:Y1}),kt("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>W(!B.playing),onWheel:F,title:B.playing?"Pause":"Play",children:B.playing?iU:rU}),kt("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>te(U+1),onWheel:F,title:"Next frame",children:X1}),kt("button",{type:"button",className:"gif-playback-controls__button gif-playback-controls__button--frames",ref:l,onClick:()=>{o.openPopup!=="gifFrameGallery"&&a(Math.max(U*jl-fe/2,0)),t({openPopup:o.openPopup==="gifFrameGallery"?null:"gifFrameGallery"})},onWheel:F,title:"Frames",children:K1})]}),o.openPopup==="gifFrameGallery"&&kt("div",{className:"gif-frame-gallery",style:{...m??{left:_,top:K},width:fe},ref:re=>{d.current=re,re&&re.scrollLeft!==Ge&&(re.scrollLeft=Ge)},onScroll:re=>{a(re.currentTarget.scrollLeft)},onWheelCapture:re=>{re.preventDefault(),re.stopPropagation(),re.currentTarget.scrollLeft+=re.deltaY,a(re.currentTarget.scrollLeft)},children:kt("div",{className:"gif-frame-gallery__spacer",style:{width:ae},children:xi.map((re,lt)=>{let $t=Pe+lt;return di("button",{type:"button",className:kP("gif-frame-gallery__frame",{"gif-frame-gallery__frame--selected":$t===U}),style:{left:$t*jl},onClick:()=>te($t),title:`Frame ${$t+1}`,children:[kt("canvas",{width:re.width,height:re.height,ref:Sn=>{Sn?.getContext("2d")?.drawImage(re,0,0)}}),kt("span",{children:$t+1})]},$t)})})})]})})()]})};import BP,{useMemo as fU}from"react";import FP from"clsx";import{isDarwin as OP,isFirefox as EU,isWindows as bU}from"@excalidraw/common";import{KEYS as ts}from"@excalidraw/common";import{SHAPES as xU}from"@excalidraw/element/shapes";import{isFirefox as cU,KEYS as BE}from"@excalidraw/common";import{SHAPES as dU}from"@excalidraw/element/shapes";import{Fragment as gU,jsx as Ve,jsxs as pi}from"react/jsx-runtime";var mU=e=>pi(gU,{children:[Ve("h3",{children:e.title}),Ve("div",{className:"HelpDialog__islands-container",children:e.children})]}),FE=e=>pi("div",{className:`HelpDialog__island ${e.className}`,children:[Ve("h4",{className:"HelpDialog__island-title",children:e.caption}),Ve("div",{className:"HelpDialog__island-content",children:e.children})]});function*pU(e,n){let t=!0;for(let o of e)t||(yield n),t=!1,yield o}var uU=e=>e.replace(/\b[a-z]\b/,n=>n.toUpperCase()),It=({label:e,shortcuts:n,isOr:t=!0})=>{let o=n.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>Ve(hU,{children:uU(a)},a)));return pi("div",{className:"HelpDialog__shortcut",children:[Ve("div",{children:e}),Ve("div",{className:"HelpDialog__key-container",children:[...pU(o,t?f("helpDialog.or"):null)]})]})},hU=e=>Ve("kbd",{className:"HelpDialog__key",...e});function OE(){return pi(mU,{title:f("helpDialog.shortcuts"),children:[pi(FE,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[Ve(It,{label:f("toolBar.hand"),shortcuts:[BE.H]}),dU.filter(({myocSimplifiedMode:e})=>e).map(({value:e,key:n})=>Ve(It,{label:f(`toolBar.${e}`),shortcuts:[...n]},e)),Ve(It,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),Ve(It,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0})]}),pi(FE,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[Ve(It,{label:f("helpDialog.smartZoom"),shortcuts:[BE.F]}),Ve(It,{label:f("helpDialog.dragToZoom"),shortcuts:[`${BE.Z}+${f("helpDialog.drag")}`]}),Ve(It,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]})]}),pi(FE,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[Ve(It,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),Ve(It,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),Ve(It,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),Ve(It,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(or||cU)&&Ve(It,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),Ve(It,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),Ve(It,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),Ve(It,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),Ve(It,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),Ve(It,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]})]})]})}import{Fragment as GP,jsx as Z,jsxs as ui}from"react/jsx-runtime";var yU=e=>ui(GP,{children:[Z("h3",{children:e.title}),Z("div",{className:"HelpDialog__islands-container",children:e.children})]}),zE=e=>ui("div",{className:`HelpDialog__island ${e.className}`,children:[Z("h4",{className:"HelpDialog__island-title",children:e.caption}),Z("div",{className:"HelpDialog__island-content",children:e.children})]});function*wU(e,n){let t=!0;for(let o of e)t||(yield n),t=!1,yield o}var vU=e=>e.replace(/\b[a-z]\b/,n=>n.toUpperCase()),q=({label:e,shortcuts:n,isOr:t=!0})=>{let o=n.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>Z(IU,{children:vU(a)},a)));return ui("div",{className:"HelpDialog__shortcut",children:[Z("div",{children:e}),Z("div",{className:"HelpDialog__key-container",children:[...wU(o,t?f("helpDialog.or"):null)]})]})},IU=e=>Z("kbd",{className:"HelpDialog__key",...e}),zP=({onClose:e})=>{let[n,t]=BP.useState(!1),o=BP.useCallback(()=>{e&&e()},[e]),r=fU(()=>n?Z("button",{className:FP("toggle-button",{}),onClick:()=>t(!1),children:f("helpDialog.myoc.showingAll")}):Z("button",{className:FP("toggle-button",{}),onClick:()=>t(!0),children:f("helpDialog.myoc.showingBasic")}),[n]);return Z(GP,{children:Z(yn,{onCloseRequest:o,title:f("helpDialog.title"),className:"HelpDialog",titleButton:r,portalContainerClassName:"HelpDialog__modalContainer",children:n?ui(yU,{title:f("helpDialog.shortcuts"),children:[ui(zE,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[Z(q,{label:f("toolBar.hand"),shortcuts:[ts.H]}),xU.map(({value:i,key:a})=>Z(q,{label:f(`toolBar.${i}`),shortcuts:[...a]},i)),Z(q,{label:f("toolBar.frame"),shortcuts:[ts.F]}),Z(q,{label:f("labels.eyeDropper"),shortcuts:[ts.I,"Shift+S","Shift+I"]}),Z(q,{label:f("helpDialog.editLineArrowPoints"),shortcuts:[N("CtrlOrCmd+Enter")]}),Z(q,{label:f("helpDialog.editText"),shortcuts:[N("Enter")]}),Z(q,{label:f("helpDialog.textNewLine"),shortcuts:[N("Enter"),N("Shift+Enter")]}),Z(q,{label:f("helpDialog.textFinish"),shortcuts:[N("Esc"),N("CtrlOrCmd+Enter")]}),Z(q,{label:f("helpDialog.curvedArrow"),shortcuts:["A",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),Z(q,{label:f("helpDialog.curvedLine"),shortcuts:["L",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),Z(q,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),Z(q,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0}),Z(q,{label:f("toolBar.lock"),shortcuts:[ts.Q]}),Z(q,{label:f("helpDialog.preventBinding"),shortcuts:[N("CtrlOrCmd")]}),Z(q,{label:f("toolBar.link"),shortcuts:[N("CtrlOrCmd+K")]}),Z(q,{label:f("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),ui(zE,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[Z(q,{label:f("helpDialog.smartZoom"),shortcuts:[ts.F]}),Z(q,{label:f("helpDialog.dragToZoom"),shortcuts:[`${ts.Z}+${f("helpDialog.drag")}`]}),Z(q,{label:f("buttons.zoomIn"),shortcuts:[N("CtrlOrCmd++")]}),Z(q,{label:f("buttons.zoomOut"),shortcuts:[N("CtrlOrCmd+-")]}),Z(q,{label:f("buttons.resetZoom"),shortcuts:[N("CtrlOrCmd+0")]}),Z(q,{label:f("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),Z(q,{label:f("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),Z(q,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]}),Z(q,{label:f("labels.toggleGrid"),shortcuts:[N("CtrlOrCmd+'")]}),Z(q,{label:f("labels.viewMode"),shortcuts:[N("Alt+R")]}),Z(q,{label:f("stats.fullTitle"),shortcuts:[N("Alt+/")]}),Z(q,{label:f("search.title"),shortcuts:[Ze("searchMenu")]})]}),ui(zE,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[Z(q,{label:f("labels.moveCanvas"),shortcuts:[N(`Space+${f("helpDialog.drag")}`),N(`Wheel+${f("helpDialog.drag")}`)],isOr:!0}),Z(q,{label:f("labels.delete"),shortcuts:[N("Delete")]}),Z(q,{label:f("labels.cut"),shortcuts:[N("CtrlOrCmd+X")]}),Z(q,{label:f("labels.copy"),shortcuts:[N("CtrlOrCmd+C")]}),Z(q,{label:f("labels.paste"),shortcuts:[N("CtrlOrCmd+V")]}),Z(q,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),Z(q,{label:f("labels.selectAll"),shortcuts:[N("CtrlOrCmd+A")]}),Z(q,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),Z(q,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),Z(q,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(or||EU)&&Z(q,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),Z(q,{label:f("labels.sendToBack"),shortcuts:[OP?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")]}),Z(q,{label:f("labels.bringToFront"),shortcuts:[OP?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")]}),Z(q,{label:f("labels.sendBackward"),shortcuts:[N("CtrlOrCmd+[")]}),Z(q,{label:f("labels.bringForward"),shortcuts:[N("CtrlOrCmd+]")]}),Z(q,{label:f("labels.alignTop"),shortcuts:[N("CtrlOrCmd+Shift+Up")]}),Z(q,{label:f("labels.alignBottom"),shortcuts:[N("CtrlOrCmd+Shift+Down")]}),Z(q,{label:f("labels.alignLeft"),shortcuts:[N("CtrlOrCmd+Shift+Left")]}),Z(q,{label:f("labels.alignRight"),shortcuts:[N("CtrlOrCmd+Shift+Right")]}),Z(q,{label:f("labels.arrangeElements"),shortcuts:[N("Shift+R")]}),Z(q,{label:f("labels.duplicateSelection"),shortcuts:[N("CtrlOrCmd+D"),N(`Alt+${f("helpDialog.drag")}`)]}),Z(q,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),Z(q,{label:f("buttons.undo"),shortcuts:[N("CtrlOrCmd+Z")]}),Z(q,{label:f("buttons.redo"),shortcuts:bU?[N("CtrlOrCmd+Y"),N("CtrlOrCmd+Shift+Z")]:[N("CtrlOrCmd+Shift+Z")]}),Z(q,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),Z(q,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),Z(q,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),Z(q,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]}),Z(q,{label:f("labels.showStroke"),shortcuts:[N("S")]}),Z(q,{label:f("labels.showBackground"),shortcuts:[N("G")]}),Z(q,{label:f("labels.showFonts"),shortcuts:[N("Shift+F")]}),Z(q,{label:f("labels.decreaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+<")]}),Z(q,{label:f("labels.increaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+>")]})]})]}):Z(OE,{})})})};import{useEffect as WP,useRef as VP,useState as hi}from"react";import{DEFAULT_EXPORT_PADDING as MU,EXPORT_IMAGE_TYPES as GE,isFirefox as AU,EXPORT_SCALES as DU,cloneJSON as YP}from"@excalidraw/common";import{useCallback as TU,useRef as SU,useState as CU}from"react";var PU=2e3,HP=()=>{let[e,n]=CU(null),t=SU(0),o=()=>{clearTimeout(t.current),n("success"),t.current=window.setTimeout(()=>{n(null)},PU)},r=TU(()=>{n(null)},[]);return{copyStatus:e,resetCopyStatus:r,onCopy:o}};import kU from"clsx";import{jsx as UP}from"react/jsx-runtime";var ql=({title:e,name:n,checked:t,onChange:o,disabled:r=!1})=>UP("div",{className:kU("Switch",{toggled:t,disabled:r}),children:UP("input",{name:n,id:n,title:e,type:"checkbox",checked:t,disabled:r,onChange:()=>o(!t),onKeyDown:i=>{i.key===" "&&o(!t)}})});import{jsx as ze,jsxs as vr}from"react/jsx-runtime";var LU=()=>vr("div",{children:[ze("h3",{children:f("canvasError.cannotShowPreview")}),ze("p",{children:ze("span",{children:f("canvasError.canvasTooBig")})}),vr("em",{children:["(",f("canvasError.canvasTooBigTip"),")"]})]}),_U=({appStateSnapshot:e,elementsSnapshot:n,files:t,actionManager:o,onExportImage:r,name:i,exportWithDarkMode:a})=>{let s=De(n,e),[l,c]=hi(i),[d,m]=hi(s),[p,u]=hi(e.exportBackground),[E,g]=hi(e.exportEmbedScene),[b,y]=hi(e.exportScale),w=VP(null),x=VP(0),[I,T]=hi(null),{onCopy:C,copyStatus:P,resetCopyStatus:A}=HP();WP(()=>{A()},[l,p,a,b,E,A]);let{exportedElements:D,exportingFrame:_}=Vr(n,e,d);return WP(()=>{let k=w.current;if(!k)return;let L=k.offsetWidth,B=k.offsetHeight;if(!L)return;let V=++x.current,z=()=>V!==x.current;return Cp({elements:D,appState:{...e,name:l,exportBackground:p,exportWithDarkMode:a,exportScale:b,exportEmbedScene:E},files:t,exportPadding:MU,maxWidthOrHeight:Math.max(L,B),exportingFrame:_}).then(async U=>{if(!z()){try{await Es(U)}catch(K){throw K.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):K}z()||(T(null),k.replaceChildren(U))}}).catch(U=>{z()||(console.error(U),T(U))}),()=>{x.current+=1}},[e,t,D,_,l,p,a,b,E]),vr("div",{className:"ImageExportModal",children:[ze("h3",{children:f("imageExportDialog.header")}),vr("div",{className:"ImageExportModal__preview",children:[ze("div",{className:"ImageExportModal__preview__canvas",ref:w,children:I&&ze(LU,{})}),ze("div",{className:"ImageExportModal__preview__filename",children:!Ii&&ze("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:k=>{c(k.target.value),o.executeAction($h,"ui",k.target.value)}})})]}),vr("div",{className:"ImageExportModal__settings",children:[ze("h3",{children:f("imageExportDialog.header")}),s&&ze(Jl,{label:f("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:ze(ql,{name:"exportOnlySelected",checked:d,onChange:k=>{m(k)}})}),ze(Jl,{label:f("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:ze(ql,{name:"exportBackgroundSwitch",checked:p,onChange:k=>{u(k),o.executeAction(Zh,"ui",k)}})}),ze(Jl,{label:f("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:ze(ql,{name:"exportDarkModeSwitch",checked:a,onChange:k=>{o.executeAction(ww,"ui",k)}})}),ze(Jl,{label:f("imageExportDialog.label.embedScene"),tooltip:f("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:ze(ql,{name:"exportEmbedSwitch",checked:E,onChange:k=>{g(k),o.executeAction(Kd,"ui",k)}})}),ze(Jl,{label:f("imageExportDialog.label.scale"),name:"exportScale",children:ze(Ep,{name:"exportScale",value:b,onChange:k=>{y(k),o.executeAction(xw,"ui",k)},choices:DU.map(k=>({value:k,label:`${k}\xD7`}))})}),vr("div",{className:"ImageExportModal__settings__buttons",children:[ze(fr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToPng"),onClick:()=>r(GE.png,D,{exportingFrame:_}),icon:Wu,children:f("imageExportDialog.button.exportToPng")}),ze(fr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToSvg"),onClick:()=>r(GE.svg,D,{exportingFrame:_}),icon:Wu,children:f("imageExportDialog.button.exportToSvg")}),(or||AU)&&ze(fr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.copyPngToClipboard"),status:P,onClick:async()=>{await r(GE.clipboard,D,{exportingFrame:_}),C()},icon:U1,children:f("imageExportDialog.button.copyPngToClipboard")})]})]})]})},Jl=({label:e,children:n,tooltip:t,name:o})=>vr("div",{className:"ImageExportModal__settings__setting",title:e,children:[vr("label",{htmlFor:o,className:"ImageExportModal__settings__setting__label",children:[e,t&&ze(pt,{label:t,long:!0,children:V1})]}),ze("div",{className:"ImageExportModal__settings__setting__content",children:n})]}),XP=({elements:e,appState:n,files:t,actionManager:o,onExportImage:r,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:s,elementsSnapshot:l}]=hi(()=>({appStateSnapshot:YP(n),elementsSnapshot:YP(e)}));return ze(yn,{onCloseRequest:i,size:"wide",title:!1,children:ze(_U,{elementsSnapshot:l,appStateSnapshot:s,files:t,actionManager:o,onExportImage:r,name:a,exportWithDarkMode:n.exportWithDarkMode})})};import wW from"clsx";import{CANVAS_SEARCH_TAB as mk,DEFAULT_SIDEBAR as vW}from"@excalidraw/common";import RU from"clsx";import NU from"lodash.debounce";import{Fragment as BU,memo as FU,useEffect as Ql,useMemo as KP,useRef as HE,useState as $P}from"react";import{CLASSES as OU,EVENT as zU,FONT_FAMILY as UE,FRAME_STYLE as WE,getLineHeight as GU}from"@excalidraw/common";import{getCommonBounds as HU,isElementCompletelyInViewport as UU}from"@excalidraw/element";import{measureText as ec}from"@excalidraw/element";import{KEYS as ns,randomInteger as ZP,addEventListener as WU,getFontString as Np}from"@excalidraw/common";import{newTextElement as VU}from"@excalidraw/element";import{isTextElement as QP,isFrameLikeElement as Bp}from"@excalidraw/element";import{getDefaultFrameName as ek}from"@excalidraw/element/frame";import{Fragment as eW,jsx as ft,jsxs as Fn}from"react/jsx-runtime";var YU=Je(""),VE=Je(null),XU=350,tk=()=>{let e=St(),n=Fe(),t=HE(null),[o,r]=He(YU),i=o.trim(),[a,s]=$P(!1),[l,c]=$P({nonce:null,items:[]}),d=HE(null),m=HE(void 0),[p,u]=He(VE),E=e.scene.getNonDeletedElementsMap();Ql(()=>{a||(i!==d.current||e.scene.getSceneNonce()!==m.current)&&(d.current=null,JP(i,e,(x,I)=>{c({nonce:ZP(),items:x}),d.current=i,m.current=e.scene.getSceneNonce(),n({searchMatches:x.length?{focusedId:null,matches:x.map(T=>({id:T.element.id,focus:!1,matchedLines:T.matchedLines}))}:null})}))},[a,i,E,e,n,u,m]);let g=()=>{l.items.length>0&&u(x=>x===null?0:(x+1)%l.items.length)},b=()=>{l.items.length>0&&u(x=>x===null?0:x-1<0?l.items.length-1:x-1)};Ql(()=>{n(x=>x.searchMatches?{searchMatches:{focusedId:p!==null&&x.searchMatches?.matches[p]?.id||null,matches:x.searchMatches.matches.map((T,C)=>C===p?{...T,focus:!0}:{...T,focus:!1})}}:null)},[p,n]),Ql(()=>{if(l.items.length>0&&p!==null){let x=l.items[p];if(x){let I=e.state.zoom.value,T=VU({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:Bp(x.element)?WE.nameFontSize:x.element.fontSize,fontFamily:Bp(x.element)?UE.Assistant:x.element.fontFamily}),C=14,P=T.fontSize,A=P*I<C;if(!UU([T],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.viewport.getOffsets())||A){let D=A&&P<C?"contain":"scale-down";e.viewport.setViewport({target:HU([T]),fit:D,animation:{duration:300},offsets:{ui:!0}})}}}},[p,l,e]),Ql(()=>()=>{u(null),d.current=null,m.current=void 0,n({searchMatches:null}),s(!1)},[n,u]);let y=Fi({goToNextItem:g,goToPreviousItem:b,searchMatches:l});Ql(()=>{let x=I=>{if(I.key===ns.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){I.preventDefault(),I.stopPropagation(),n({openSidebar:null});return}if(I[ns.CTRL_OR_CMD]&&I.key===ns.F){if(I.preventDefault(),I.stopPropagation(),e.state.openDialog)return;t.current?.matches(":focus")||(e.state.openDialog&&n({openDialog:null}),t.current?.focus(),t.current?.select())}I.target instanceof HTMLElement&&I.target.closest(".layer-ui__search")&&y.searchMatches.items.length&&(I.key===ns.ENTER&&(I.stopPropagation(),y.goToNextItem()),I.key===ns.ARROW_UP?(I.stopPropagation(),y.goToPreviousItem()):I.key===ns.ARROW_DOWN&&(I.stopPropagation(),y.goToNextItem()))};return WU(window,zU.KEYDOWN,x,{capture:!0,passive:!1})},[n,y,e]);let w=`${l.items.length} ${l.items.length===1?f("search.singleResult"):f("search.multipleResults")}`;return Fn("div",{className:"layer-ui__search",children:[Fn("div",{className:"layer-ui__search-header",children:[ft(_p,{className:OU.SEARCH_MENU_INPUT_WRAPPER,value:o,ref:t,placeholder:f("search.placeholder"),icon:Jn,onChange:x=>{r(x),s(!0);let I=x.trim();JP(I,e,(T,C)=>{c({nonce:ZP(),items:T}),u(C),d.current=I,m.current=e.scene.getSceneNonce(),n({searchMatches:T.length?{focusedId:null,matches:T.map(P=>({id:P.element.id,focus:!1,matchedLines:P.matchedLines}))}:null}),s(!1)})},selectOnRender:!0}),ft(wn,{"data-testid":"sidebar-close",className:"layer-ui__search-close",onSelect:()=>{n({openSidebar:null})},"aria-label":f("buttons.close"),children:rn})]}),Fn("div",{className:"layer-ui__search-count",children:[l.items.length>0&&Fn(eW,{children:[p!==null&&p>-1?Fn("div",{children:[p+1," / ",w]}):ft("div",{children:w}),Fn("div",{className:"result-nav",children:[ft(wn,{onSelect:()=>{g()},className:"result-nav-btn",children:Hc}),ft(wn,{onSelect:()=>{b()},className:"result-nav-btn",children:c0})]})]}),l.items.length===0&&i&&d.current&&ft("div",{style:{margin:"1rem auto"},children:f("search.noMatch")})]}),ft(ZU,{matches:l,onItemClick:u,focusIndex:p,searchQuery:i})]})},jP=e=>{let n=[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 ft("div",{tabIndex:-1,className:RU("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:ft("div",{className:"preview-text",children:n.flatMap((t,o)=>ft(BU,{children:o===2?ft("b",{children:t}):t},o))})})},KU=e=>{let n=KP(()=>e.matches.items.filter(o=>Bp(o.element)),[e.matches]),t=KP(()=>e.matches.items.filter(o=>QP(o.element)),[e.matches]);return Fn("div",{className:"layer-ui__search-results",children:[n.length>0&&Fn("div",{className:"layer-ui__search-result-container",children:[Fn("div",{className:"layer-ui__search-result-title",children:[ft("div",{className:"title-icon",children:jn}),ft("div",{children:f("search.frames")})]}),n.map((o,r)=>ft(jP,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r===e.focusIndex,onClick:()=>e.onItemClick(r)},o.element.id+o.index)),t.length>0&&ft("div",{className:"layer-ui__divider"})]}),t.length>0&&Fn("div",{className:"layer-ui__search-result-container",children:[Fn("div",{className:"layer-ui__search-result-title",children:[ft("div",{className:"title-icon",children:Pn}),ft("div",{children:f("search.texts")})]}),t.map((o,r)=>ft(jP,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r+n.length===e.focusIndex,onClick:()=>e.onItemClick(r+n.length)},o.element.id+o.index))]})]})},$U=(e,n)=>e.matches.nonce===n.matches.nonce&&e.focusIndex===n.focusIndex,ZU=FU(KU,$U),qP=(e,n,t)=>{let i=e.slice(0,n),a=i.split(/\s+/),s=i.endsWith(" "),l=a.length-2-1-(s?0:1),c=a.slice(l<=0?0:l).join(" ")+(s?" ":""),d=20;c=c.length>d?c.slice(-d):c;let m=e.slice(n+t.length),p=m.split(/\s+/),u=!m.startsWith(" "),E=u?6:5,g=(u?"":" ")+p.slice(0,E).join(" ");return{indexInSearchQuery:c.length,previewText:c+t+g,moreBefore:l>0,moreAfter:p.length>E}},jU=(e,n)=>{let t=e.split(`
17
+ `).filter(l=>l.trim().length>0).map(l=>l.split(s).map(c=>c.trim())),t=[" ",",",";"].map(s=>{let l=n(s),c=l[0]?.length??0,d=l.length>0&&l.every(m=>m.length===c);return{delimiter:s,parsed:l,numCols:c,isConsistent:d}}),r=(t.find(s=>s.isConsistent&&s.numCols>1)??t.find(s=>s.isConsistent)??t[0]).parsed;if(r.length===0)return{ok:!1,reason:"No values"};let i=r[0].length;return r.every(s=>s.length===i)?KI(r):{ok:!1,reason:"All rows don't have same number of columns"}};import{pointFrom as Ga}from"@excalidraw/math";import{FONT_FAMILY as vB,FONT_SIZES as IB,getFontString as TB,getLineHeight as SB,ROUGHNESS as $I}from"@excalidraw/common";import{measureText as CB,newLinearElement as Df,newTextElement as PB}from"@excalidraw/element";var ZI=(e,n,t,o)=>{if(!Ra(e,"radar"))return null;let r=e.labels??e.series[0].values.map((z,U)=>`Value ${U+1}`),i=e.series,{normalize:a,renderSteps:s}=HI(i,r.length),l=Fa(o),c=Oa(l),d=Ba(i.length,l),{chartWidth:m,chartHeight:p}=GI(),u=n+m/2,E=t-p/2,g=Aa/2,b=r.map((z,U)=>-Math.PI/2+Math.PI*2*U/r.length),{axisLabels:w,axisLabelTopY:y,axisLabelBottomY:x}=UI(r,b,u,E,g,c),I=vB["Lilita One"],T=IB.xl,C=SB(I),P=TB({fontFamily:I,fontSize:T}),M=e.title?Hm(e.title,P,m+Da*2):null,D=M?CB(M,P,C):null,_=M?PB({backgroundColor:c,...Be,text:M,originalText:e.title??M,x:n+m/2,y:y-Da-D.height/2,fontFamily:I,fontSize:T,lineHeight:C,textAlign:"center"}):null,k=s?Array.from({length:wf},(z,U)=>{let V=(U+1)/wf,G=g*V,re=b.map(B=>Ga(Math.cos(B)*G,Math.sin(B)*G));return re.push(Ga(re[0][0],re[0][1])),Df({backgroundColor:"transparent",...Be,type:"line",x:u,y:E,width:G*2,height:G*2,strokeStyle:"solid",roughness:$I.architect,opacity:ai,polygon:!0,points:re})}):[],L=b.map(z=>{let U=Math.cos(z)*g,V=Math.sin(z)*g;return Df({backgroundColor:"transparent",...Be,type:"line",x:u,y:E,width:Math.abs(U),height:Math.abs(V),strokeStyle:"solid",roughness:$I.architect,opacity:ai,points:[Ga(0,0),Ga(U,V)]})}),F=i.map((z,U)=>{let V=b.map((G,re)=>{let B=z.values[re]??0,W=a(B,re)*g;return Ga(Math.cos(G)*W,Math.sin(G)*W)});return V.push(Ga(V[0][0],V[0][1])),Df({backgroundColor:"transparent",...Be,type:"line",x:u,y:E,width:g*2,height:g*2,strokeColor:d[U],strokeWidth:2,polygon:!0,points:V})}),Y=za(i,d,u,x,t+oo*5,c);return[..._?[_]:[],...w,...k,...L,...F,...Y]};var Lf=(e,n,t,o,r)=>e==="line"?XI(n,t,o,r):e==="radar"?ZI(n,t,o,r):VI(n,t,o,r);import{clamp as Ym,pointFrom as Ha,pointsEqual as RB,bezierEquation as iT,pointRotateRads as Xm,pointDistance as NB}from"@excalidraw/math";import{arrayToMap as BB,BIND_MODE_TIMEOUT as Bl,DEFAULT_TRANSFORM_HANDLE_SPACING as aT,FRAME_STYLE as bn,getFeatureFlag as FB,invariant as eT,shouldRotateWithDiscreteAngle as sT,THEME as Ao}from"@excalidraw/common";import{deconstructDiamondElement as Ff,deconstructRectanguloidElement as lT,elementCenterPoint as Ua,getDiamondBaseCorners as OB,FOCUS_POINT_SIZE as zB,getOmitSidesForEditorInterface as _f,getTransformHandles as GB,getTransformHandlesFromCoords as HB,hasBoundingBox as UB,hitElementItself as WB,isArrowElement as cT,isBindableElement as dT,isElbowArrow as Wa,isFrameLikeElement as Va,isImageElement as Km,isLinearElement as VB,isLineElement as YB,maxBindingDistance_simple as XB,isTextElement as KB,LinearElementEditor as xn,getActiveTextElement as $B,getElementsInGroup as Of,getSelectedGroupIds as ZB,isSelectedViaGroup as jB,selectGroupsFromGivenElements as qB}from"@excalidraw/element";import{renderSelectionElement as JB}from"@excalidraw/element";import{getCommonBounds as zf,getElementAbsoluteCoords as Ol}from"@excalidraw/element";import{getGlobalFixedPointForBindableElement as tT,isFocusPointVisible as QB}from"@excalidraw/element";import{pointFrom as Pt}from"@excalidraw/math";import{THEME as kB}from"@excalidraw/common";var MB="#ff6b6b",AB="#ff0000",jI=1,qI=2,JI=(e,n)=>{if(!n.snapLines.length)return;let t=n.theme===kB.LIGHT||n.zenModeEnabled?MB:AB,o=(n.zenModeEnabled?jI*1.5:jI)/n.zoom.value;e.save(),e.translate(n.scrollX,n.scrollY);for(let r of n.snapLines)r.type==="pointer"?(e.lineWidth=o,e.strokeStyle=t,LB(r,e,n)):r.type==="gap"?(e.lineWidth=o,e.strokeStyle=t,_B(r.points[0],r.points[1],r.direction,n,e)):r.type==="points"&&(e.lineWidth=o,e.strokeStyle=t,DB(r,e,n));e.restore()},DB=(e,n,t)=>{if(!t.zenModeEnabled){let o=e.points[0],r=e.points[e.points.length-1];En(o,r,n)}for(let o of e.points)QI(o,t,n)},LB=(e,n,t)=>{QI(e.points[0],t,n),t.zenModeEnabled||En(e.points[0],e.points[1],n)},QI=([e,n],t,o)=>{o.save();let r=(t.zenModeEnabled?qI*1.5:qI)/t.zoom.value;o.beginPath(),o.moveTo(e-r,n-r),o.lineTo(e+r,n+r),o.moveTo(e+r,n-r),o.lineTo(e-r,n+r),o.stroke(),o.restore()},En=(e,n,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(n[0],n[1]),t.stroke()},_B=(e,n,t,o,r)=>{let i=8/o.zoom.value,a=i/2,s=i/4;if(t==="horizontal"){let l=[(e[0]+n[0])/2,e[1]];o.zenModeEnabled||En(Pt(e[0],e[1]-i),Pt(e[0],e[1]+i),r),En(Pt(l[0]-s,l[1]-a),Pt(l[0]-s,l[1]+a),r),En(Pt(l[0]+s,l[1]-a),Pt(l[0]+s,l[1]+a),r),o.zenModeEnabled||(En(Pt(n[0],n[1]-i),Pt(n[0],n[1]+i),r),En(e,n,r))}else{let l=[e[0],(e[1]+n[1])/2];o.zenModeEnabled||En(Pt(e[0]-i,e[1]),Pt(e[0]+i,e[1]),r),En(Pt(l[0]-a,l[1]-s),Pt(l[0]+a,l[1]-s),r),En(Pt(l[0]-a,l[1]+s),Pt(l[0]+a,l[1]+s),r),o.zenModeEnabled||(En(Pt(n[0]-i,n[1]),Pt(n[0]+i,n[1]),r),En(e,n,r))}};var eF=(e,n)=>{eT(n.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=n.selectedLinearElement;eT(t,"midPointCoords is null"),$m(t,e,n)},tF=(e,n,t)=>{let{elementId:o,hoverPointIndex:r}=n.selectedLinearElement;if(n.selectedLinearElement?.isEditing&&n.selectedLinearElement?.selectedPointsIndices?.includes(r)||n.selectedLinearElement?.isDragging)return;let i=xn.getElement(o,t);if(!i)return;let a=xn.getPointAtIndexGlobalCoordinates(i,r,t);$m(a,e,n)},$m=(e,n,t)=>{n.save(),n.translate(t.scrollX,t.scrollY),n.fillStyle="rgba(105, 101, 219, 0.4)",ys(n,e[0],e[1],xn.POINT_HANDLE_SIZE/t.zoom.value,!1),n.restore()},nF=(e,n,t)=>{let{elementId:o,anchor:r}=n.hoveredArrowTextAnchor,i=t.get(o);if(!i||!cT(i)||i.isDeleted)return;let a=r==="label"?xn.getBoundTextElementCenter(i,t):xn.getPointAtIndexGlobalCoordinates(i,r==="start"?0:-1,t);$m(a,e,n)},Rf=(e,n,t,o,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)"),ys(e,t[0],t[1],(a?o*(n.selectedLinearElement?.isEditing?1.5:2):o)/n.zoom.value,!i,!a||r)},oF=(e,n,t,o,r,i=!1)=>{let a=n.element.frameId&&t.get(n.element.frameId);switch(a&&Va(a)&&(e.translate(a.x,a.y),e.beginPath(),bn.radius&&e.roundRect?e.roundRect(-1,-1,a.width+1,a.height+1,bn.radius/o.zoom.value):e.rect(-1,-1,a.width+1,a.height+1),e.clip(),e.translate(-a.x,-a.y)),n.element.type){case"magicframe":case"frame":e.save(),e.translate(n.element.x,n.element.y),e.lineWidth=bn.strokeWidth/o.zoom.value,e.strokeStyle=o.theme===Ao.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",bn.radius&&e.roundRect?(e.beginPath(),e.roundRect(0,0,n.element.width,n.element.height,bn.radius/o.zoom.value),e.stroke(),e.closePath()):e.strokeRect(0,0,n.element.width,n.element.height),e.restore();break;default:e.save();let s=Ua(n.element,t);switch(e.translate(s[0],s[1]),e.rotate(n.element.angle),e.translate(-s[0],-s[1]),e.translate(n.element.x,n.element.y),e.lineWidth=Ym(1.75,n.element.strokeWidth,4)/Math.max(.25,o.zoom.value),e.strokeStyle=o.theme===Ao.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",n.element.type){case"ellipse":e.beginPath(),e.ellipse(n.element.width/2,n.element.height/2,n.element.width/2,n.element.height/2,0,0,2*Math.PI),e.closePath(),e.stroke();break;case"diamond":{let[l,c]=Ff(n.element);l.forEach(d=>{e.beginPath(),e.moveTo(d[0][0]-n.element.x,d[0][1]-n.element.y),e.lineTo(d[1][0]-n.element.x,d[1][1]-n.element.y),e.stroke()}),c.forEach(d=>{let[m,p,u,E]=d;e.beginPath(),e.moveTo(m[0]-n.element.x,m[1]-n.element.y),e.bezierCurveTo(p[0]-n.element.x,p[1]-n.element.y,u[0]-n.element.x,u[1]-n.element.y,E[0]-n.element.x,E[1]-n.element.y),e.stroke()})}break;default:{let[l,c]=lT(n.element);l.forEach(d=>{e.beginPath(),e.moveTo(d[0][0]-n.element.x,d[0][1]-n.element.y),e.lineTo(d[1][0]-n.element.x,d[1][1]-n.element.y),e.stroke()}),c.forEach(d=>{let[m,p,u,E]=d;e.beginPath(),e.moveTo(m[0]-n.element.x,m[1]-n.element.y),e.bezierCurveTo(p[0]-n.element.x,p[1]-n.element.y,u[0]-n.element.x,u[1]-n.element.y,E[0]-n.element.x,E[1]-n.element.y),e.stroke()})}break}e.restore();break}if(o.isMidpointSnappingEnabled&&!o.gridModeEnabled&&!i&&(Va(n.element)||dT(n.element))){let s=o.selectedLinearElement,l=s?.elementId&&xn.getElement(s?.elementId,t),c=r&&WB({point:r,element:n.element,elementsMap:t,threshold:0,overrideShouldTestInside:!0}),d=l&&Wa(l)||o.activeTool.type==="arrow"&&o.currentItemArrowType==="elbow";if(!c||d){e.save();let m=Ua(n.element,t),p;if(n.element.type==="diamond"){let b=Ua(n.element,t);p=OB(n.element).map(w=>{let y=iT(w,.5),x=Xm(y,b,n.element.angle);return Ha(x[0],x[1])})}else p=[{x:n.element.width,y:n.element.height/2},{x:n.element.width/2,y:n.element.height},{x:0,y:n.element.height/2},{x:n.element.width/2,y:0}].map(w=>{let y=Ha(w.x+n.element.x,w.y+n.element.y),x=Xm(y,m,n.element.angle);return Ha(x[0],x[1])});let u=r&&p.reduce((b,w,y)=>{let x=NB(w,r);return y===-1||x<b.distance?{idx:y,distance:x}:b},{idx:-1,distance:1/0}),E=4/o.zoom.value,g=XB(o.zoom)+n.element.strokeWidth/2;p.forEach((b,w)=>{let y=(!c||d)&&u?.idx===w&&u.distance<=g,x=!y&&(d||w===u?.idx&&u.distance<=g*2);y?(e.fillStyle=o.theme===Ao.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",e.beginPath(),e.arc(b[0],b[1],E,0,2*Math.PI),e.fill()):x&&(e.fillStyle=o.theme===Ao.DARK?"rgba(0, 0, 0, 0.8)":"rgba(65, 65, 65, 0.5)",e.beginPath(),e.arc(b[0],b[1],E,0,2*Math.PI),e.fill())}),e.restore()}}},rF=(e,n,t,o,r,i,a)=>{let s=e.state.bindMode==="orbit"&&e.bindModeHandler!==null,l=Bl-(a?.runtime??(s?0:Bl)),c=Ym(1/Bl*l,1e-4,1),d=t.strokeWidth/2,m=t.frameId&&o.get(t.frameId);switch(m&&Va(m)&&(n.translate(m.x,m.y),n.beginPath(),bn.radius&&n.roundRect?n.roundRect(-1,-1,m.width+1,m.height+1,bn.radius/r.zoom.value):n.rect(-1,-1,m.width+1,m.height+1),n.clip(),n.translate(-m.x,-m.y)),t.type){case"magicframe":case"frame":n.save(),n.translate(t.x,t.y),n.lineWidth=bn.strokeWidth/r.zoom.value,n.strokeStyle=r.theme===Ao.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,bn.radius&&n.roundRect?(n.beginPath(),n.roundRect(0,0,t.width,t.height,bn.radius/r.zoom.value),n.stroke(),n.closePath()):n.strokeRect(0,0,t.width,t.height),n.restore();break;default:n.save();let u=Ua(t,o),E=u[0]+r.scrollX,g=u[1]+r.scrollY;switch(n.translate(E,g),n.rotate(t.angle),n.translate(-E,-g),n.translate(t.x+r.scrollX-d,t.y+r.scrollY-d),n.lineWidth=Ym(2.5,t.strokeWidth*1.75,4)/Math.max(.25,r.zoom.value),n.strokeStyle=r.theme===Ao.DARK?`rgba(3, 93, 161, ${c/2})`:`rgba(106, 189, 252, ${c/2})`,t.type){case"ellipse":n.beginPath(),n.ellipse((t.width+d*2)/2,(t.height+d*2)/2,(t.width+d*2)/2,(t.height+d*2)/2,0,0,2*Math.PI),n.closePath(),n.stroke();break;case"diamond":{let[b,w]=Ff(t,d);b.forEach(y=>{n.beginPath(),n.moveTo(y[0][0]-t.x+d,y[0][1]-t.y+d),n.lineTo(y[1][0]-t.x+d,y[1][1]-t.y+d),n.stroke()}),w.forEach(y=>{let[x,I,T,C]=y;n.beginPath(),n.moveTo(x[0]-t.x+d,x[1]-t.y+d),n.bezierCurveTo(I[0]-t.x+d,I[1]-t.y+d,T[0]-t.x+d,T[1]-t.y+d,C[0]-t.x+d,C[1]-t.y+d),n.stroke()})}break;default:{let[b,w]=lT(t,d);b.forEach(y=>{n.beginPath(),n.moveTo(y[0][0]-t.x+d,y[0][1]-t.y+d),n.lineTo(y[1][0]-t.x+d,y[1][1]-t.y+d),n.stroke()}),w.forEach(y=>{let[x,I,T,C]=y;n.beginPath(),n.moveTo(x[0]-t.x+d,x[1]-t.y+d),n.bezierCurveTo(I[0]-t.x+d,I[1]-t.y+d,T[0]-t.x+d,T[1]-t.y+d,C[0]-t.x+d,C[1]-t.y+d),n.stroke()})}break}n.restore();break}if(!s||(a?.runtime??0)>Bl)return;let p=.5*(Math.min(t.width,t.height)/2);if(!Va(t)){n.save(),n.translate(t.x+r.scrollX,t.y+r.scrollY);let u=1/Bl*l;if(n.strokeStyle="rgba(0, 0, 0, 0.2)",n.lineWidth=1/r.zoom.value,n.setLineDash([4/r.zoom.value,4/r.zoom.value]),n.lineDashOffset=-u*10/r.zoom.value,n.beginPath(),n.ellipse(t.width/2,t.height/2,p,p,0,0,2*Math.PI),n.stroke(),n.fillStyle="rgba(0, 0, 0, 0.04)",n.beginPath(),n.ellipse(t.width/2,t.height/2,p*(1-c),p*(1-c),0,0,2*Math.PI),n.fill(),n.restore(),r.isMidpointSnappingEnabled&&!r.gridModeEnabled&&(!e.lastPointerMoveEvent||!sT(e.lastPointerMoveEvent))){n.save(),n.translate(t.x+r.scrollX,t.y+r.scrollY);let E=5/r.zoom.value,g=5/r.zoom.value,b=E+g,w;if(t.type==="diamond"){let[,y]=Ff(t),x=Ua(t,o);w=y.map(I=>{let T=iT(I,.5),C=Xm(T,x,t.angle);return{x:C[0]-t.x,y:C[1]-t.y}})}else{let y=Ua(t,o);w=[{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(I=>{let T=Ha(I.x+t.x,I.y+t.y),C=Xm(T,y,t.angle);return{x:C[0]-t.x,y:C[1]-t.y}})}w.forEach(y=>{n.clearRect(y.x-b,y.y-b,b*2,b*2)}),n.fillStyle=r.theme===Ao.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,w.forEach(y=>{n.beginPath(),n.arc(y.x,y.y,E,0,2*Math.PI),n.fill()}),n.restore()}}return{runtime:(a?.runtime??0)+i}},iF=(e,n,t,o,r,i,a)=>{if(t===null)return;if(FB("COMPLEX_BINDINGS"))return rF(e,n,t.element,o,r,i,a);n.save(),n.translate(r.scrollX,r.scrollY);let s=e.lastPointerMoveCoords?Ha(e.lastPointerMoveCoords.x,e.lastPointerMoveCoords.y):null,l=!!e.lastPointerMoveEvent&&sT(e.lastPointerMoveEvent);oF(n,t,o,r,s,l),n.restore()},mT=(e,n,t)=>{let{angle:o,x1:r,y1:i,x2:a,y2:s,selectionColors:l,cx:c,cy:d,dashed:m,activeEmbeddable:p}=t,u=a-r,E=s-i,b=(t.padding??aT*2)/n.zoom.value,w=8/n.zoom.value,y=4/n.zoom.value;e.save(),e.translate(n.scrollX,n.scrollY),e.lineWidth=(p?4:1)/n.zoom.value;let x=l.length;for(let I=0;I<x;++I)e.strokeStyle=l[I],m&&e.setLineDash([w,y+(w+y)*(x-1)]),e.lineDashOffset=(w+y)*I,ws(e,r-b,i-b,u+b*2,E+b*2,c,d,o);e.restore()},aF=(e,n,t,o)=>{let[r,i,a,s]=Ol(t,o),l=a-r,c=s-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=bn.strokeWidth/n.zoom.value,e.save(),e.translate(n.scrollX,n.scrollY),ws(e,r,i,l,c,r+l/2,i+c/2,t.angle,!1,bn.radius/n.zoom.value),e.restore()},nT=(e,n,t,o)=>{let{colors:r=["rgb(0,118,255)"],dashed:i=!1}=o||{},a=t.filter(d=>d.groupIds.length===0),s=t.filter(d=>d.groupIds.length>0),l=d=>{let[m,p,u,E]=zf(d);return{angle:0,x1:m,x2:u,y1:p,y2:E,selectionColors:r,dashed:i,cx:m+(u-m)/2,cy:p+(E-p)/2,activeEmbeddable:!1}},c=d=>{let m=Of(t,d);return l(m)};Object.entries(qB(s,n)).filter(([d,m])=>m).map(([d,m])=>d).map(d=>c(d)).concat(a.map(d=>l([d]))).forEach(d=>mT(e,n,d))},Nf=(e,n,t,o)=>{if(!n.selectedLinearElement)return;e.save(),e.translate(n.scrollX,n.scrollY),e.lineWidth=1/n.zoom.value;let r=xn.getPointsGlobalCoordinates(t,o),{POINT_HANDLE_SIZE:i}=xn,a=n.selectedLinearElement?.isEditing?i:i/2,s=Wa(t),l=YB(t);if(r.forEach((c,d)=>{if(s&&d!==0&&d!==r.length-1)return;let m=d>0&&(d!==r.length-1||!l||!t.polygon)&&RB(c,d===r.length-1?r[0]:r[d-1],2/n.zoom.value),p=!!n.selectedLinearElement?.isEditing&&!!n.selectedLinearElement?.selectedPointsIndices?.includes(d);l&&t.polygon&&!p&&d===t.points.length-1&&n.selectedLinearElement?.isEditing&&n.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(p=!0),Rf(e,n,c,a,p,!1,m)}),Wa(t)){let c=t.fixedSegments?.map(d=>d.index)||[];r.slice(0,-1).forEach((d,m)=>{xn.isSegmentTooShort(t,r[m+1],r[m],m,n.zoom,o)||Rf(e,n,Ha((d[0]+r[m+1][0])/2,(d[1]+r[m+1][1])/2),i/2,!1,!c.includes(m+1),!1)})}else xn.getEditorMidPoints(t,o,n).filter((d,m,p)=>d!==null&&!(Wa(t)&&(m===0||m===p.length-1))).forEach(d=>{(n.selectedLinearElement?.isEditing||r.length===2)&&Rf(e,n,d,i/2,!1,!0,!1)});e.restore()},sF=(e,n,t,o)=>{e.save(),e.translate(n.scrollX,n.scrollY),e.strokeStyle="rgba(134, 131, 226, 0.6)",e.lineWidth=1/n.zoom.value,e.setLineDash([4/n.zoom.value,4/n.zoom.value]),e.beginPath(),e.moveTo(t[0],t[1]),e.lineTo(o[0],o[1]),e.stroke(),e.restore()},lF=(e,n,t,o,r)=>{e.save(),e.translate(n.scrollX,n.scrollY),e.strokeStyle="rgba(134, 131, 226, 0.6)",e.lineWidth=1/n.zoom.value,e.setLineDash([]),e.fillStyle=r?"rgba(134, 131, 226, 0.9)":"rgba(255, 255, 255, 0.9)",ys(e,t[0],t[1],o/n.zoom.value,!0,!0),e.restore()},oT=({arrow:e,appState:n,type:t,context:o,elementsMap:r})=>{let i=t==="start"?e.startBinding:e.endBinding,a=i?.elementId&&r.get(i.elementId);if(!a||!dT(a)||a.isDeleted)return;let s=tT(i.fixedPoint,a,r);if(!QB(s,e,a,r,n,t))return;let l=n.selectedLinearElement,c=!!l?.isDragging,d=t==="start"?0:e.points.length-1,m=!!l?.selectedPointsIndices?.includes(d);if(l?.hoveredFocusPointBinding===t&&!l.draggedFocusPointBinding&&$m(s,o,n),!(m&&c)){let p=tT(i.fixedPoint,a,r),u=l?.hoveredFocusPointBinding===t,E=xn.getPointAtIndexGlobalCoordinates(e,d,r);sF(o,n,E,p),lF(o,n,p,zB/1.5,u)}},rT=(e,n,t,o,r)=>{Object.keys(o).forEach(i=>{let a=o[i];if(a!==void 0){let[s,l,c,d]=a;e.save(),e.lineWidth=1/t.zoom.value,n.selectionColor&&(e.strokeStyle=n.selectionColor),i==="rotation"?ys(e,s+c/2,l+d/2,c/2,!0):e.roundRect?(e.beginPath(),e.roundRect(s,l,c,d,2/t.zoom.value),e.fill(),e.stroke()):ws(e,s,l,c,d,s+c/2,l+d/2,r,!0),e.restore()}})},cF=(e,n,t,o,r)=>{let[i,a,,,s,l]=Ol(o,r),c=3,d=20,m=c/t.zoom.value,p=m/2,u=s-i+m,E=l-a+m,g=Math.min(d/t.zoom.value,u),b=Math.min(d/t.zoom.value,E);e.save(),e.fillStyle=n.selectionColor,e.strokeStyle=n.selectionColor,e.lineWidth=m,[[[-u,-E],[0,p],[g,p],[p,0],[p,b]],[[u-p,-E],[p,p],[-g+p,p],[0,0],[0,b]],[[-u,E],[0,-p],[g,-p],[p,0],[p,-b]],[[u-p,E],[p,-p],[-g+p,-p],[0,0],[0,-b]]].forEach(y=>{let[[x,I],[T,C],[P,M],[D,_],[k,L]]=y;e.save(),e.translate(s,l),e.rotate(o.angle),e.beginPath(),e.moveTo(x+T,I+C),e.lineTo(x+P,I+M),e.stroke(),e.beginPath(),e.moveTo(x+D,I+_),e.lineTo(x+k,I+L),e.stroke(),e.restore()}),e.restore()},dF=(e,n,t,o)=>{n.save();let r=pf(t.zoom.value),i=e.width+r*2,a=e.height+r*2,s=e.x+e.width/2,l=e.y+e.height/2,c=-(e.width/2+r),d=-(e.height/2+r);n.translate(s+t.scrollX,l+t.scrollY),n.rotate(e.angle),n.lineWidth=1/t.zoom.value,n.strokeStyle=o,n.globalAlpha=.5,n.setLineDash([6/t.zoom.value,4/t.zoom.value]),n.strokeRect(c,d,i,a),n.restore()},mF=(e,n,t,o,r)=>{let i=uf(e,t.zoom.value,r);i&&(n.save(),n.globalAlpha=.5,n.lineWidth=1.5/t.zoom.value,n.lineCap="round",n.strokeStyle=o,n.beginPath(),n.moveTo(i.start[0]+t.scrollX,i.start[1]+t.scrollY),n.lineTo(i.end[0]+t.scrollX,i.end[1]+t.scrollY),n.stroke(),n.restore())},pF=(e,n,t,o,r,i)=>{for(let a of n){if(!Km(a)||!a.fileId)continue;let s=o.imageStatus.get(a.fileId);if(!!s?.downloadError){let d=Fl(a,t,r,"center");d&&uT(e,d.centerX+r.scrollX,d.centerY+r.scrollY,d.radius,r,s?.downloadError??void 0)}else{let d=o.imageLoadingProgress.get(a.fileId);if(d!==void 0){let m=Fl(a,t,r,"center");m&&pT(e,m.centerX+r.scrollX,m.centerY+r.scrollY,m.radius,m.lineWidth,d,r,i)}}let c=s?.uploadProgress;if(c){let d=Fl(a,t,r,"top-right");d&&hF(e,d.centerX+r.scrollX,d.centerY+r.scrollY,d.radius,d.lineWidth,c,r,i)}}},Fl=(e,n,t,o)=>{if(!Km(e))return null;let[r,i,a,s]=Ol(e,n),l=t.zoom.value,c=Math.min(a-r,s-i)*l,d=Math.min(o==="center"?14:11.7,c/(o==="center"?4:4.62))/l,m=Math.min((o==="center"?3:2.6)/l,d/2);if(d<=0||m<=0)return null;if(o==="top-right"){let p=6/l;return{centerX:a-p-d,centerY:i+p+d,radius:d,lineWidth:m}}return{centerX:(r+a)/2,centerY:(i+s)/2,radius:d,lineWidth:m}},pT=(e,n,t,o,r,i,a,s,l)=>{e.save(),e.lineWidth=r,e.lineCap="round",e.strokeStyle=l?.trackColor??(a.theme===Ao.DARK?"rgba(255, 255, 255, 0.35)":"rgba(0, 0, 0, 0.25)"),e.beginPath(),e.arc(n,t,o,0,Math.PI*2),e.stroke(),i>0&&(e.strokeStyle=l?.color??s,e.beginPath(),e.arc(n,t,o,-Math.PI/2,-Math.PI/2+Math.PI*2*Ym(i,0,1)),e.stroke()),e.restore()},Bf=(e,n)=>typeof window>"u"?n:window.getComputedStyle(document.documentElement).getPropertyValue(e).trim()||n,uF=(e,n,t,o,r)=>{e.save(),e.strokeStyle=r.color,e.lineWidth=r.lineWidth,e.lineCap="round",e.lineJoin="round",e.beginPath(),e.moveTo(n-o*.48,t+o*.26),e.bezierCurveTo(n-o*.68,t+o*.14,n-o*.58,t-o*.22,n-o*.34,t-o*.22),e.bezierCurveTo(n-o*.14,t-o*.48,n+o*.26,t-o*.48,n+o*.34,t-o*.18),e.bezierCurveTo(n+o*.58,t-o*.2,n+o*.7,t+o*.26,n+o*.42,t+o*.26),e.lineTo(n-o*.48,t+o*.26),e.stroke(),e.restore()},hF=(e,n,t,o,r,i,a,s)=>{let l=i.state??"uploading",c=i.color??Bf("--color-primary",s),d=i.color??Bf("--color-warning-darkest","#ec8b14");if(l==="failed"){uT(e,n,t,o,a,{color:i.color??Bf("--color-danger","#e03131")});return}if(l==="uploading"&&pT(e,n,t,o,r,i.progress??0,a,s,{color:c,trackColor:i.trackColor}),uF(e,n,t-o*.02,o*1.125,{color:l==="error"?d:c,lineWidth:Math.max(r*.75,1/a.zoom.value)}),l==="error"){e.save(),e.strokeStyle=d,e.fillStyle=d,e.lineWidth=Math.max(r*.75,1/a.zoom.value),e.lineCap="round",e.beginPath();let m=o*.18,p=t-o*.09;e.moveTo(n-m,p-m),e.lineTo(n+m,p+m),e.moveTo(n+m,p-m),e.lineTo(n-m,p+m),e.stroke(),e.restore()}else l==="pending"&&(e.save(),e.strokeStyle=c,e.lineWidth=Math.max(r*.65,1/a.zoom.value),e.lineCap="round",e.beginPath(),e.moveTo(n,t+o*.072),e.lineTo(n,t-o*.18),e.moveTo(n-o*.144,t-o*.036),e.lineTo(n,t-o*.18),e.lineTo(n+o*.144,t-o*.036),e.stroke(),e.restore())},uT=(e,n,t,o,r,i)=>{e.save();let a=i?.color??"#e03131",s=Math.max(o*.16,1.5/r.zoom.value);i?.backgroundColor&&(e.fillStyle=i.backgroundColor,e.beginPath(),e.arc(n,t,o,0,Math.PI*2),e.fill()),e.strokeStyle=a,e.lineWidth=s,e.beginPath(),e.arc(n,t,o,0,Math.PI*2),e.stroke(),e.strokeStyle=a,e.fillStyle=a,e.lineCap="round",e.beginPath(),e.moveTo(n,t-o*.45),e.lineTo(n,t+o*.12),e.stroke(),e.beginPath(),e.arc(n,t+o*.48,o*.11,0,Math.PI*2),e.fill(),i?.text&&(e.font=`600 ${Math.max(11/r.zoom.value,o*.65)}px Assistant, system-ui, BlinkMacSystemFont, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif`,e.textAlign="center",e.textBaseline="top",e.fillText(i.text,n,t+o+6/r.zoom.value)),e.restore()},gF=({app:e,canvas:n,elementsMap:t,visibleElements:o,selectedElements:r,allElementsMap:i,scale:a,appState:s,renderConfig:l,editorInterface:c,animationState:d,deltaTime:m})=>{if(n===null)return{};let[p,u]=Ac(n,a),E=d,g=Dc({canvas:n,scale:a,normalizedWidth:p,normalizedHeight:u});g.save(),g.scale(s.zoom.value,s.zoom.value);let b;if(o.forEach(C=>{s.selectedLinearElement?.isEditing&&s.selectedLinearElement.elementId===C.id&&C&&(b=C)}),b&&Nf(g,s,b,t),s.selectionElement&&!s.isCropping)try{JB(s.selectionElement,g,s,l.selectionColor)}catch(C){console.error(C)}let w=$B(r,s);if(w&&!w.autoResize&&mF(w,g,s,l.selectionColor,c.formFactor),s.editingTextElement){let C=i.get(s.editingTextElement.id);C&&!C.autoResize&&dF(C,g,s,l.selectionColor)}if(s.isBindingEnabled&&s.suggestedBinding?E={...d,bindingHighlight:iF(e,g,s.suggestedBinding,i,s,m,d?.bindingHighlight)}:E={...d,bindingHighlight:void 0},s.hoveredArrowTextAnchor&&nF(g,s,i),s.frameToHighlight&&aF(g,s,s.frameToHighlight,t),s.elementsToHighlight&&nT(g,s,s.elementsToHighlight),s.activeLockedId){let C=i.get(s.activeLockedId),P=C?[C]:Of(i,s.activeLockedId);nT(g,s,P,{colors:["#ced4da"],dashed:!0})}let y=r.some(C=>Va(C));r.length===1&&s.selectedLinearElement?.isEditing&&s.selectedLinearElement.elementId===r[0].id&&Nf(g,s,r[0],t);let x=s.selectedLinearElement,I=x&&xn.getElement(x.elementId,i);if(I&&(s.selectedLinearElement.isDragging||(x.segmentMidPointHoveredCoords?eF(g,s):(Wa(I)?x.hoverPointIndex===0||x.hoverPointIndex===I.points.length-1:x.hoverPointIndex>=0)&&tF(g,s,t)),cT(I)&&(oT({arrow:I,elementsMap:i,appState:s,context:g,type:"start"}),oT({arrow:I,elementsMap:i,appState:s,context:g,type:"end"}))),!s.multiElement&&!s.newElement&&!s.selectedLinearElement?.isEditing){let C=UB(r,s,c),P=r.length===1&&VB(r[0]);P&&s.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&Nf(g,s,r[0],t);let M=l.selectionColor||"#000";if(C){let D=BB(r),_=[];for(let L of t.values()){let F=[],Y=l.remoteSelectedElementIds.get(L.id);if(P&&Wa(L)&&(L.startBinding||L.endBinding)||(D.has(L.id)&&!jB(s,L)&&F.push(M),Y&&F.push(...Y.map(z=>Jr(z,s.collaborators.get(z))))),F.length){let[z,U,V,G,re,B]=Ol(L,t,!0);_.push({angle:L.angle,x1:z,y1:U,x2:V,y2:G,selectionColors:L.locked?["#ced4da"]:F,dashed:!!Y||L.locked,cx:re,cy:B,activeEmbeddable:s.activeEmbeddable?.element===L&&s.activeEmbeddable.state==="active",padding:L.id===s.croppingElementId||Km(L)?0:void 0})}}let k=L=>{let F=Of(t,L),[Y,z,U,V]=zf(F);_.push({angle:0,x1:Y,x2:U,y1:z,y2:V,selectionColors:F.some(G=>G.locked)?["#ced4da"]:["#000"],dashed:!0,cx:Y+(U-Y)/2,cy:z+(V-z)/2,activeEmbeddable:!1})};for(let L of ZB(s))k(L);s.editingGroupId&&k(s.editingGroupId),_.forEach(L=>mT(g,s,L))}if(g.save(),g.translate(s.scrollX,s.scrollY),r.length===1){g.fillStyle="#fff";let D=GB(r[0],s.zoom,t,"mouse",_f(c));if(!s.viewModeEnabled&&C&&!KB(s.editingTextElement)&&!s.croppingElementId&&rT(g,l,s,D,r[0].angle),s.croppingElementId&&!s.isCropping){let _=t.get(s.croppingElementId);_&&Km(_)&&cF(g,l,s,_,t)}}else if(r.length>1&&!s.isRotating&&!r.some(D=>D.locked)){let D=aT*2/s.zoom.value;g.fillStyle="#fff";let[_,k,L,F]=zf(r,t),Y=g.getLineDash();g.setLineDash([2/s.zoom.value]);let z=g.lineWidth;g.lineWidth=1/s.zoom.value,g.strokeStyle=M,ws(g,_-D,k-D,L-_+D*2,F-k+D*2,(_+L)/2,(k+F)/2,0),g.lineWidth=z,g.setLineDash(Y);let U=HB([_,k,L,F,(_+L)/2,(k+F)/2],0,s.zoom,"mouse",y?{..._f(c),rotation:!0}:_f(c));r.some(V=>!V.locked)&&rT(g,l,s,U,0)}g.restore()}s.searchMatches?.matches.forEach(({id:C,focus:P,matchedLines:M})=>{let D=t.get(C);if(D){let[_,k,,,L,F]=Ol(D,t,!0);g.save(),s.theme===Ao.LIGHT?P?g.fillStyle="rgba(255, 124, 0, 0.4)":g.fillStyle="rgba(255, 226, 0, 0.4)":P?g.fillStyle="rgba(229, 82, 0, 0.4)":g.fillStyle="rgba(99, 52, 0, 0.4)";let Y=Va(D)?s.zoom.value:1;g.translate(s.scrollX,s.scrollY),g.translate(L,F),g.rotate(D.angle),M.forEach(z=>{(z.showOnCanvas||P)&&g.fillRect(_+z.offsetX/Y-L,k+z.offsetY/Y-F,z.width/Y,z.height/Y)}),g.restore()}}),JI(g,s),pF(g,o,t,e,s,l.selectionColor),g.restore(),Rw({context:g,renderConfig:l,appState:s,normalizedWidth:p,normalizedHeight:u});let T;return l.renderScrollbars&&(T=nI(t,p,u,s),g.save(),g.fillStyle=tI,g.strokeStyle="rgba(255,255,255,0.8)",[T.horizontal,T.vertical].forEach(C=>{C&&rm(g,C.x,C.y,C.width,C.height,fn/2)}),g.restore()),{scrollBars:T,animationState:E}},Gf=e=>{let n=gF(e);return e.callback(n),n};import{useEffect as Ul,useMemo as hT,useRef as Yf,useState as fF}from"react";import{bumpVersion as zl,getLinearElementSubType as Xa,mutateElement as Xf,updateElbowArrowPoints as EF}from"@excalidraw/element";import{pointFrom as jm,pointRotateRads as bF}from"@excalidraw/math";import{hasBoundTextElement as xF,isArrowBoundToElement as yF,isArrowElement as wF,isElbowArrow as vF,isLinearElement as jf,isUsingAdaptiveRadius as IF}from"@excalidraw/element";import{getCommonBoundingBox as TF,getElementAbsoluteCoords as SF}from"@excalidraw/element";import{getBoundTextElement as xT,getBoundTextMaxHeight as CF,getBoundTextMaxWidth as PF,redrawTextBoundingBox as kF}from"@excalidraw/element";import{wrapText as MF}from"@excalidraw/element";import{assertNever as AF,CLASSES as DF,getFontString as Hf,isProdEnv as LF,mapFind as _F,reduceToCommonValue as RF,ROUNDNESS as Uf,sceneCoordsToViewportCoords as NF,updateActiveTool as gT}from"@excalidraw/common";import{measureText as fT}from"@excalidraw/element";import{LinearElementEditor as BF}from"@excalidraw/element/linearElementEditor";import{newArrowElement as Wf,newElement as FF,newLinearElement as OF}from"@excalidraw/element";import{ShapeCache as zF}from"@excalidraw/element";import{updateBindings as GF}from"@excalidraw/element";import{jsx as Zf}from"react/jsx-runtime";var HF=8,UF=10,Gl=["rectangle","diamond","ellipse"],Hl=["line","sharpArrow","curvedArrow","elbowArrow"],WF=new Set(Gl),VF=new Set(Hl),Ka=e=>WF.has(e),qm=e=>e==="arrow"||VF.has(e),ro=Qe(null),Wl=new Map,Vl=new Map,YF=({app:e})=>{let n=e.scene.getSelectedElements(e.state),t=Yf(null);return Ul(()=>{if(n.length===0){e.updateEditorAtom(ro,null);return}let o=Jm(n);o&&!t.current?t.current=o:(t.current&&!o||t.current&&o!==t.current)&&(e.updateEditorAtom(ro,null),t.current=null)},[n,e]),Ul(()=>()=>{Wl.clear(),Vl.clear()},[]),Zf(XF,{app:e,elements:n})},XF=({app:e,elements:n})=>{let t=Jm(n),o=hT(()=>t==="generic"?wT(n):[],[t,n]),r=hT(()=>t==="linear"?$f(n):[],[t,n]),i=t==="generic"?o.every(m=>m.type===o[0].type):t==="linear"?r.every(m=>Xa(m)===Xa(r[0])):!1,[a,s]=fF({x:0,y:0}),l=Yf(""),c=Yf(null);Ul(()=>{let m=[...o,...r].sort((b,w)=>b.id.localeCompare(w.id)),p=`
18
+ ${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${m.map(b=>b.id).join(",")}`;if(p===l.current)return;l.current=p;let u;if(m.length===1){let[b,,,w,y,x]=SF(m[0],e.scene.getNonDeletedElementsMap());u=bF(jm(b,w),jm(y,x),m[0].angle)}else{let{minX:b,maxY:w}=TF(m);u=jm(b,w)}let{x:E,y:g}=NF({sceneX:u[0],sceneY:u[1]},e.state);s({x:E,y:g})},[o,r,e.scene,e.state]),Ul(()=>{for(let m of r){let p=Kf(m.id,qF(m));Vl.has(p)||Vl.set(p,m)}},[r]),Ul(()=>{for(let m of o)if(!Wl.has(m.id)){let p=xT(m,e.scene.getNonDeletedElementsMap());p&&Wl.set(m.id,{fontSize:p.fontSize})}},[o,e.scene]);let d=t==="linear"?[["line",$o],["sharpArrow",qo],["curvedArrow",Qo],["elbowArrow",Jo]]:t==="generic"?[["rectangle",_i],["diamond",Ri],["ellipse",Ni]]:[];return Zf("div",{ref:c,tabIndex:-1,style:{position:"absolute",top:`${a.y+(UF+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-HF}px`,zIndex:2},className:DF.CONVERT_ELEMENT_TYPE_POPUP,children:d.map(([m,p])=>{let u=i&&(t==="generic"&&o[0].type===m||t==="linear"&&Xa(r[0])===m);return Zf(Z,{type:"toggle",icon:p,checked:u,title:m,"aria-label":m,"data-testid":`toolbar-${m}`,onSelect:()=>{u||(e.state.activeTool.type!==m&&Fe("convertElementType",m,"ui"),qf(e,{conversionType:t,nextType:m}),c.current?.focus())}},`${n[0].id}${n[0].version}_${m}`)})})},KF=(e,n,t)=>{let o=PF(e,n),r=CF(e,n),i=MF(n.text,Hf(n),o),a=fT(i,Hf(n),n.lineHeight),s=n.fontSize;for(;(a.width>o||a.height>r)&&s>0;){s-=1;let l={...n,fontSize:s};a=fT(n.text,Hf(l),n.lineHeight)}Xf(n,t.getNonDeletedElementsMap(),{fontSize:s,width:a.width,height:a.height}),kF(n,e,t)},qf=(e,{conversionType:n,nextType:t,direction:o="right"})=>{if(!n)return!1;let r=e.scene.getSelectedElements(e.state),i=r.reduce((s,l)=>({...s,[l.id]:!0}),{}),a=o==="right"?1:-1;if(n==="generic"){let s=wT(r),c=s.every(d=>d.type===s[0].type)?Gl.indexOf(s[0].type):-1;if(t=t??Gl[(c+Gl.length+a)%Gl.length],t&&Ka(t)){let d={};for(let p of s){let u=bT(p,t,e);d[u.id]=u}let m=[];for(let p of e.scene.getElementsIncludingDeleted())d[p.id]?m.push(d[p.id]):m.push(p);e.scene.replaceAllElements(m);for(let p of Object.values(d)){let u=xT(p,e.scene.getNonDeletedElementsMap());u&&(Wl.get(p.id)&&Xf(u,e.scene.getNonDeletedElementsMap(),{fontSize:Wl.get(p.id)?.fontSize??u.fontSize}),KF(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:gT(p,{type:"selection"})}))}}if(n==="linear"){let s=$f(r);if(!t){let c=RF(s,Xa),d=c?Hl.indexOf(c):-1;t=Hl[(d+Hl.length+a)%Hl.length]}if(qm(t)){let c=[],d=e.scene.getElementsMapIncludingDeleted();for(let m of s){let p=Vl.get(Kf(m.id,t));if(p&&Xa(p)===t)d.set(p.id,p),c.push(p);else{let u=bT(m,t,e);d.set(u.id,u),c.push(u)}}e.scene.replaceAllElements(d);for(let m of c)if(jf(m))if(vF(m)){let p=$F(m);if(p.length<2)continue;let u=[];for(let g=1;g<p.length-2;g++)u.push({start:p[g],end:p[g+1],index:g+1});let E=EF(m,e.scene.getNonDeletedElementsMap(),{points:p,fixedSegments:u});Xf(m,e.scene.getNonDeletedElementsMap(),{...E,endArrowhead:"arrow"})}else{let p=_F(["line","sharpArrow","curvedArrow"],u=>Vl.get(Kf(m.id,u)));if(p){let u=p.points;e.scene.mutateElement(m,{points:u})}}}let l=$f(e.scene.getSelectedElements(e.state));e.setState(c=>({selectedElementIds:i,selectedLinearElement:l.length===1?new BF(l[0],e.scene.getNonDeletedElementsMap()):null,activeTool:gT(c,{type:"selection"})}))}return!0},Jm=e=>{if(e.length===0)return null;let n=!1;for(let t of e){if(Ka(t.type))return"generic";yT(t)&&(n=!0)}return n?"linear":null},yT=e=>jf(e)&&(!wF(e)||!yF(e)&&!xF(e)),Kf=(e,n)=>`${e}:${n}`,wT=e=>e.filter(n=>Ka(n.type)),$f=e=>e.filter(n=>yT(n)),Zm=20,Ya=(e,n)=>e[0]===n[0],Vf=(e,n)=>e[1]===n[1],ET=(e,n)=>Ya(e,n)?Math.abs(e[1]-n[1]):Math.abs(e[0]-n[0]),$F=e=>{let n=[e.points[0]],t=ZF(e.points);for(let i=1;i<t.length;++i){let a=n[n.length-1],s=[...t[i]];Math.abs(s[0]-a[0])<Zm?s[0]=a[0]:Math.abs(s[1]-a[1])<Zm&&(s[1]=a[1]),Ya(a,s)||Vf(a,s)||n.push(jm(a[0],s[1])),n.push(s)}let o=[n[0]];for(let i=1;i<n.length-1;++i)Ya(n[i-1],n[i])&&Ya(n[i],n[i+1])||Vf(n[i-1],n[i])&&Vf(n[i],n[i+1])||o.push(n[i]);o.push(n[n.length-1]);let r=[o[0]];for(let i=1;i<o.length-1;++i){let a=r[r.length-1],s=o[i],l=o[i+1],c=Ya(a,s),d=Ya(s,l);if(c!==d){let m=ET(a,s),p=ET(s,l);if(m<Zm||p<Zm){if(p<m)c?l[0]=a[0]:l[1]=a[1];else if(d)for(let u=r.length-1;u>=0&&r[u][0]===a[0];--u)r[u][0]=s[0];else for(let u=r.length-1;u>=0&&r[u][1]===a[1];--u)r[u][1]=s[1];continue}}r.push(s)}return r.push(o[o.length-1]),r},ZF=e=>{if(e.length===0)return[];let n=[e[0]];for(let t=1;t<e.length;t++){let[o,r]=n[n.length-1],[i,a]=e[t];(o!==i||r!==a)&&n.push(e[t])}return n},bT=(e,n,t)=>{if(!jF(e.type,n)){if(!LF())throw Error(`Invalid conversion from ${e.type} to ${n}.`);return e}if(e.type===n)return e;if(zF.delete(e),Ka(n)){let o=zl(FF({...e,type:n,roundness:e.roundness?{type:IF(n)?Uf.ADAPTIVE_RADIUS:Uf.PROPORTIONAL_RADIUS}:e.roundness}));return GF(o,t.scene,t.state),o}if(qm(n))switch(n){case"line":return zl(OF({...e,type:"line"}));case"sharpArrow":return zl(Wf({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return zl(Wf({...e,type:"arrow",elbowed:!1,roundness:{type:Uf.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return zl(Wf({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return AF(n,`unhandled conversion type: ${n}`),e},jF=(e,n)=>!!(Ka(e)&&Ka(n)||qm(e)&&qm(n)),qF=e=>jf(e)?Xa(e):e.type,vT=YF;import{bindBindingElementToFixedPoint as JF,dragNewTextElement as QF,getBoundTextElement as eO,getEndpointBoundTextDragAnchor as tO,getTextBindingForArrowEndpoint as nO,getUnboundArrowEndpointAtPoint as oO,isArrowElement as rO,isBindingEnabled as iO,isEndpointBoundText as aO,isTextElement as sO}from"@excalidraw/element";import{pointFrom as lO}from"@excalidraw/math";var Qm=class{constructor(n){this.app=n;v(this,"updateHoveredAnchor",n=>{let t=this.app.state.activeTool.type==="text"&&!this.app.state.editingTextElement&&!this.app.state.newElement?this.getAnchorAtPosition(n.x,n.y):null,o=this.app.state.hoveredArrowTextAnchor;return(o?.elementId!==t?.elementId||o?.anchor!==t?.anchor)&&this.app.setState({hoveredArrowTextAnchor:t}),t});v(this,"refresh",()=>{this.app.lastPointerMoveCoords&&this.updateHoveredAnchor(this.app.lastPointerMoveCoords)})}getBindableEndpointAtPosition(n,t){if(!iO(this.app.state))return null;let o=oO(lO(n,t),this.app.scene.getNonDeletedElements(),this.app.scene.getNonDeletedElementsMap(),this.app.state.zoom);if(!o||this.app.getTextElementAtPosition(n,t))return null;let r=this.app.getElementAtPosition(n,t,{includeLockedElements:!0});return r&&r.id!==o.arrow.id&&this.app.scene.getElementIndex(r.id)>this.app.scene.getElementIndex(o.arrow.id)?null:o}getAnchorAtPosition(n,t){let o=this.getBindableEndpointAtPosition(n,t);if(o)return{elementId:o.arrow.id,anchor:o.startOrEnd};let r=this.app.getTextBindableContainerAtPosition(n,t);return!rO(r)||eO(r,this.app.scene.getNonDeletedElementsMap())?null:this.app.getTextWysiwygSnappedToCenterPosition(n,t,this.app.state,r)?{elementId:r.id,anchor:"label"}:null}getTextBinding({arrow:n,startOrEnd:t},o){return nO(n,t,this.app.scene.getNonDeletedElementsMap(),o)}bindText({arrow:n,startOrEnd:t},o,r){JF(n,o,t,r,this.app.scene)}maybeDragNewText(n,t){return!sO(n)||!aO(n,this.app.scene.getNonDeletedElementsMap())?!1:(QF({newElement:n,...tO(n),pointerX:t.x,zoom:this.app.state.zoom.value,scene:this.app.scene}),!0)}};import{applyDarkModeFilter as cO,BUCKET_FILL_BACKGROUND_PICKS as dO,COLOR_PALETTE as TT,DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as mO,getSizeFromPoints as pO,isTransparent as uO,THEME as hO}from"@excalidraw/common";import{pointFrom as IT}from"@excalidraw/math";import{computeBucketFillPolygon as gO,isBucketFillCompatible as fO,isFrameLikeElement as EO,isRestylableFill as bO,newLinearElement as xO,ShapeCache as yO}from"@excalidraw/element";var Jf=dO.filter(e=>e!==TT.white),ep=class{constructor(n){this.app=n;v(this,"temporaryEyeDropper",null);v(this,"pending",null);v(this,"handlePointerDown",n=>{this.pending=n});v(this,"handlePointerUp",()=>{let n=this.pending;this.pending=null,n&&this.fill(n)});v(this,"cancel",()=>{this.pending=null});v(this,"cycleBackgroundColor",()=>{let n=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor),t=Jf.indexOf(n),o=Jf[(t+1)%Jf.length];this.app.actionManager.executeAction(Pd,"keyboard",{currentItemBackgroundColor:o})});v(this,"openTemporaryEyeDropper",()=>{if(Et.get(Gt))return;let n={colorPickerType:"elementBackground",keepOpenOnAlt:!0,onSelect:t=>{this.app.actionManager.executeAction(Pd,"ui",{currentItemBackgroundColor:t})}};this.temporaryEyeDropper=n,this.app.updateEditorAtom(Gt,n)});v(this,"closeTemporaryEyeDropper",()=>{let n=this.temporaryEyeDropper;this.temporaryEyeDropper=null,n&&Et.get(Gt)===n&&this.app.updateEditorAtom(Gt,null)});v(this,"restyle",n=>{let t=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor);n.backgroundColor===t&&n.fillStyle===this.app.state.currentItemFillStyle&&n.opacity===this.app.state.currentItemOpacity||(this.app.scene.mutateElement(n,{backgroundColor:t,fillStyle:this.app.state.currentItemFillStyle,opacity:this.app.state.currentItemOpacity}),yO.delete(n),this.app.scheduleCapture())});v(this,"fill",n=>{let t=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor),o=this.app.scene.getNonDeletedElements(),r=this.app.scene.getNonDeletedElementsMap(),i=IT(n.x,n.y),a=this.app.getElementAtPosition(i[0],i[1]),s=gO({point:i,elements:o,elementsMap:r});if(!s.ok){if(a&&fO(a)){this.restyle(a);return}s.reason==="too_complex"?this.app.setToast({message:f("bucketfill.tooComplex"),duration:3e3}):(s.reason==="open_region"||s.reason==="too_small"||s.reason==="invalid_polygon")&&this.app.setToast({message:f("bucketfill.noRegion"),duration:3e3});return}if(a&&bO({hitElement:a,scenePoints:s.scenePoints,elementsMap:r})){this.restyle(a);return}let{width:l,height:c}=pO(s.scenePoints),[d,m]=s.scenePoints[0],p=s.scenePoints.map(y=>IT(y[0]-d,y[1]-m)),u=s.ownerId?r.get(s.ownerId):null,E=u?EO(u)?u.id:u.frameId:this.app.getTopLayerFrameAtSceneCoords(n)?.id??null,g=u?u.groupIds:s.boundaryElementIds.map(y=>r.get(y)?.groupIds).filter(y=>!!y).reduce((y,x)=>y===null?x:y.filter(I=>x.includes(I)),null)??[],b=xO({type:"line",x:d,y:m,width:l,height:c,points:p,polygon:!0,strokeColor:"transparent",backgroundColor:t,fillStyle:this.app.state.currentItemFillStyle,strokeWidth:1,strokeStyle:"solid",roughness:0,roundness:null,opacity:this.app.state.currentItemOpacity,frameId:E,groupIds:g}),w=this.app.scene.getElementsIncludingDeleted().findIndex(y=>y.id===s.insertion.elementId);this.app.scene.insertElementsAtIndex([b],w<0?null:s.insertion.placement==="above"?w+1:w),this.app.scheduleCapture()});v(this,"getBucketFillBackgroundColor",(n,t)=>uO(n)?TT.green[mO]:cO(n,t===hO.DARK))}};import{CURSOR_TYPE as Yl,MIME_TYPES as np,THEME as ST}from"@excalidraw/common";var CT='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',wO='<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"/>',PT='<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"/>',vO=`data:${np.svg},${encodeURIComponent(`${CT}${PT}</svg>`)}`,IO=`data:${np.svg},${encodeURIComponent(`${CT}${wO}${PT}</svg>`)}`,TO=e=>{let n=Du.map((t,o)=>`<path d="${t}" ${o<2?`fill="${e}"`:""} />`).join("");return`data:${np.svg},${encodeURIComponent(`<svg viewBox="0 0 24 24" width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke-linecap="round" stroke-linejoin="round"><g stroke="#fff" fill="#fff" stroke-width="5">${n}</g><g stroke="#1b1b1f" stroke-width="1.25">${n}</g></svg>`)}`},tp=class{constructor(n){this.app=n;v(this,"toolCursorMemo",null);v(this,"eraserCanvasCache",null);v(this,"eraserPreviewDataURL",null);v(this,"set",n=>{this.toolCursorMemo=null,this.canvas&&(this.canvas.style.cursor=n)});v(this,"reset",()=>{this.app.state.viewModeEnabled&&!this.app.isActiveToolPointerCapturing()?this.app.isNavigationEnabled()?this.set(Yl.GRAB):this.clear():this.applyForTool()});v(this,"applyForTool",(n=this.app.state.activeTool)=>{let t=this.canvas;if(!t)return;let o=n.type==="eraser"||n.type==="laser"||n.type==="bucketfill"?this.app.state.theme:void 0,r=n.type==="bucketfill"?this.app.bucketFill.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor,o):void 0,i=this.toolCursorMemo;if(!(i?.canvas===t&&i.type===n.type&&i.bucketFillColor===r&&i.theme===o)){if(n.type==="selection")this.clear();else if(bs({activeTool:n}))this.set(Yl.GRAB);else if(rn({activeTool:n}))this.applyEraser();else if(n.type==="autoshape")this.set(Yl.CROSSHAIR);else if(n.type==="bucketfill")this.set(`url(${TO(r)}) 5 18, auto`);else if(n.type==="laser"){let a=this.app.state.theme===ST.LIGHT?vO:IO;this.set(`url(${a}), auto`)}else["image","custom"].includes(n.type)?n.type!=="image"&&this.set(Yl.AUTO):this.set(Yl.CROSSHAIR);this.toolCursorMemo={canvas:t,type:n.type,bucketFillColor:r,theme:o}}});v(this,"clear",()=>{this.set("")});v(this,"applyEraser",()=>{let t=this.app.state.theme;if(!this.eraserCanvasCache||this.eraserCanvasCache.theme!==t){let o=t===ST.DARK;this.eraserCanvasCache=document.createElement("canvas"),this.eraserCanvasCache.theme=t,this.eraserCanvasCache.height=20,this.eraserCanvasCache.width=20;let r=this.eraserCanvasCache.getContext("2d");r.lineWidth=1,r.beginPath(),r.arc(this.eraserCanvasCache.width/2,this.eraserCanvasCache.height/2,5,0,2*Math.PI),r.fillStyle=o?"#000":"#fff",r.fill(),r.strokeStyle=o?"#fff":"#000",r.stroke(),this.eraserPreviewDataURL=this.eraserCanvasCache.toDataURL(np.svg)}this.set(`url(${this.eraserPreviewDataURL}) ${20/2} ${20/2}, auto`)})}get canvas(){return this.app.interactiveCanvas}};import{randomInteger as MO}from"@excalidraw/common";import{bindBindingElement as AO,convertToShape as DO,convertToShapeHandlePointerMoveFromPointerDown as LO,getHoveredElementForBinding as kT,isBindingElement as _O,isLineElement as RO,LinearElementEditor as Qf,maxBindingDistance_simple as MT,newArrowElement as NO,updateBoundPoint as BO}from"@excalidraw/element";import{getStrokeWidthByKey as SO,THEME as CO}from"@excalidraw/common";import{clamp as PO,pointFrom as kO}from"@excalidraw/math";var op=class{constructor(n){this.app=n;v(this,"trail");this.trail=new Rn(this.app,{...this.getTrailOptions(),fill:()=>n.props.renderCustomizations?.traceColor??(n.state.theme===CO.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)")})}getTrailOptions(){return{simplify:0,streamline:.4,size:1,sizeMapping:()=>PO(SO("line",this.app.state.currentItemStrokeWidthKey)*.65*this.app.state.zoom.value,1.25,4)}}startPath(n,t){this.trail.startPath(n,t)}addPointToPath(n,t){this.trail.addPointToPath(n,t)}endPath(){this.trail.endPath()}clearTrails(){this.trail.clearTrails()}getCurrentPoints(){let n=this.trail.getCurrentTrail();return n?n.originalPoints.map(([t,o])=>kO(t,o)):[]}start(n){this.trail.start(n)}stop(){this.trail.stop()}};var rp=class{constructor(n){this.app=n;v(this,"trail");v(this,"gestureInProgress",!1);v(this,"stop",()=>{this.trail.stop()});v(this,"hasPendingGesture",()=>this.gestureInProgress);v(this,"handlePointerDown",n=>{this.gestureInProgress&&this.app.actionManager.executeAction(ut),this.gestureInProgress=!0,this.trail.startPath(n.lastCoords.x,n.lastCoords.y)});v(this,"handlePointerMove",n=>LO(this.app,n));v(this,"bindRecognizedArrow",n=>{let{app:t}=this,o=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=MT(t.state.zoom),a=["start","end"].map(d=>{let m=Qf.getPointAtIndexGlobalCoordinates(n,d==="start"?0:-1,o);return{startOrEnd:d,globalPoint:m,target:kT(m,r,o,i)}}),s=!!a[0].target&&a[0].target===a[1].target,l=t.state.isMidpointSnappingEnabled&&!t.state.gridModeEnabled;for(let{startOrEnd:d,globalPoint:m,target:p}of a)p&&AO(n,p,s?"inside":"orbit",d,t.scene,m,t.state.isBindingEnabled,l);if(s)return;let c=new Map;for(let{startOrEnd:d,target:m}of a){if(!m)continue;let p=BO(n,d==="start"?"startBinding":"endBinding",d==="start"?n.startBinding:n.endBinding,m,o);p&&c.set(d==="start"?0:n.points.length-1,{point:p})}c.size&&Qf.movePoints(n,t.scene,c)});v(this,"maybeUpgradeLineToArrow",n=>{let{app:t}=this,o=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=MT(t.state.zoom),[a,s]=[0,-1].map(l=>kT(Qf.getPointAtIndexGlobalCoordinates(n,l,o),r,o,i));return!a&&!s||a===s?null:NO({type:"arrow",x:n.x,y:n.y,width:n.width,height:n.height,startArrowhead:null,endArrowhead:t.state.currentItemEndArrowhead,points:n.points,groupIds:n.groupIds,frameId:n.frameId,locked:!1,angle:n.angle,strokeColor:n.strokeColor,backgroundColor:n.backgroundColor,fillStyle:n.fillStyle,roughness:n.roughness,opacity:n.opacity,strokeStyle:n.strokeStyle,strokeWidth:n.strokeWidth})});v(this,"finalize",()=>{let{app:n}=this,t=this.gestureInProgress?this.trail.getCurrentPoints():[];if(this.gestureInProgress=!1,this.trail.endPath(),t.length>=3){let o=n.state.newElement||DO(t,n.state,n.scene.getNonDeletedElementsMap(),n.state.newElement,n.scene.getNonDeletedFramesLikes());if(o){let r={...o,seed:MO(),opacity:n.state.currentItemOpacity};n.state.isBindingEnabled&&RO(r)&&(r=this.maybeUpgradeLineToArrow(r)??r),n.insertNewElement(r),n.state.isBindingEnabled&&_O(r)&&this.bindRecognizedArrow(r)}}this.trail.clearTrails()});this.trail=new op(n)}};import{isArrowKey as FO,KEYS as li}from"@excalidraw/common";import{makeNextSelectedElementIds as OO,CaptureUpdateAction as zO,FlowChartCreator as GO,FlowChartNavigator as HO,getSelectedElements as AT,isFlowchartNodeElement as UO}from"@excalidraw/element";var ip=class e{constructor(n){this.app=n;v(this,"creator",new GO);v(this,"navigator",new HO);v(this,"clear",()=>{this.creator.clear(),this.navigator.clear()});v(this,"handleKeyEvent",n=>{let t=this.resolveKeyboardEventToOperation(n);switch(t.type){case"none":return!1;case"canceled":return this.app.triggerRender(!0),!0;case"creating":return n.preventDefault(),t.pending.length&&this.app.revealIfHidden(t.pending),!0;case"navigating":{n.preventDefault();let o=t.nodeId&&this.app.scene.getNonDeletedElementsMap().get(t.nodeId);return o&&this.selectAndReveal(o),!0}case"committed":{t.nodes.length&&this.app.insertNewElements(t.nodes);let o=t.nodes[0];return o&&this.selectAndReveal(o),this.captureUpdate(),!0}case"navigationEnded":return this.captureUpdate(),!0}})}get pendingNodes(){return this.creator.pendingNodes}get isCreatingChart(){return this.creator.isCreatingChart}resolveKeyboardEventToOperation(n){let{creator:t,navigator:o,app:r}=this;if(n.type==="keydown"){if(n.key===li.ESCAPE&&t.isCreatingChart)return t.clear(),{type:"canceled"};if(!FO(n.key))return{type:"none"};if(n[li.CTRL_OR_CMD]&&!n.shiftKey){let a=AT(r.scene.getNonDeletedElementsMap(),r.state);return a.length===1&&UO(a[0])&&t.createNodes(a[0],r.state,e.getLinkDirectionFromKey(n.key),r.scene),{type:"creating",pending:t.pendingNodes??[]}}if(n.altKey){let a=r.scene.getNonDeletedElementsMap(),s=AT(a,r.state);if(s.length===1)return{type:"navigating",nodeId:o.exploreByDirection(s[0],a,e.getLinkDirectionFromKey(n.key))}}return{type:"none"}}let i=!n.altKey&&o.isExploring;if(i&&o.clear(),!n[li.CTRL_OR_CMD]&&t.isCreatingChart){let a=t.pendingNodes??[];return t.clear(),{type:"committed",nodes:a}}return i?{type:"navigationEnded"}:{type:"none"}}selectAndReveal(n){this.app.setState(t=>({selectedElementIds:OO({[n.id]:!0},t)})),this.app.revealIfHidden([n])}captureUpdate(){this.app.syncActionResult({captureUpdate:zO.IMMEDIATELY})}static getLinkDirectionFromKey(n){switch(n){case li.ARROW_UP:return"up";case li.ARROW_DOWN:return"down";case li.ARROW_RIGHT:return"right";case li.ARROW_LEFT:return"left";default:return"right"}}};import{createGifPlaybackMetadata as DT,hasPlayableGif as WO,isInitializedImageElement as VO,newElementWith as LT,ShapeCache as YO}from"@excalidraw/element";import{MIME_TYPES as _T}from"@excalidraw/common";var ap=class{constructor(n){this.app=n;v(this,"playbackRaf",null);v(this,"runtimeState",new Map);v(this,"stop",()=>{this.playbackRaf!==null&&(cancelAnimationFrame(this.playbackRaf),this.playbackRaf=null),this.runtimeState.clear()});v(this,"getFrameIndex",n=>n.gifPlayback?.playing?this.runtimeState.get(n.id)?.frameIndex??n.gifPlayback.frameIndex:n.gifPlayback?.frameIndex);v(this,"setFrameIndex",(n,t)=>{this.runtimeState.set(n.id,{frameIndex:t,lastFrameTime:performance.now()})});v(this,"ensureLoop",()=>{this.playbackRaf!==null||this.app.unmounted||WO(this.app.scene.getNonDeletedElements(),this.app.imageCache)&&(this.playbackRaf=requestAnimationFrame(this.tick))});v(this,"createPlaceholderDecodeState",(n,t)=>{if(t.type!==_T.gif)return null;let o=n.id;this.app.imageCache.set(o,{image:new Promise(()=>{}),mimeType:_T.gif,gifDecodeStatus:"pending"});let r=LT(n,{fileId:o,gifPlayback:DT({playing:!0})});return this.app.scene.replaceAllElements(this.app.scene.getElementsIncludingDeleted().map(i=>i.id===r.id?r:i)),this.app.imagePlaceholderUpdateEmitter.trigger(),o});v(this,"ensureElementPlaybackMetadata",(n,t={})=>n.gifPlayback&&(t.playing===void 0||n.gifPlayback.playing===t.playing)?n:LT(n,{gifPlayback:n.gifPlayback?{...n.gifPlayback,playing:t.playing??n.gifPlayback.playing}:DT(t)}));v(this,"removePlaceholderDecodeState",n=>{n&&this.app.imageCache.delete(n)});v(this,"tick",()=>{if(this.playbackRaf=null,this.app.unmounted)return;let n=performance.now(),t=!1,o=!1;for(let r of this.app.scene.getNonDeletedElements()){if(!VO(r)||!r.gifPlayback?.playing)continue;let i=this.app.imageCache.get(r.fileId)?.gif;if(!i||i.frames.length<2)continue;o=!0;let a=Math.max(r.gifPlayback.speed||1,.1),s=this.runtimeState.get(r.id)??{frameIndex:r.gifPlayback.frameIndex,lastFrameTime:n};this.runtimeState.set(r.id,s);let l=s.frameIndex,c=i.delays[l]??100;n-s.lastFrameTime>=c/a&&(s.frameIndex=(l+1)%i.frames.length,s.lastFrameTime=n,YO.delete(r),t=!0)}t&&this.app.imagePlaceholderUpdateEmitter.trigger(),o&&(this.playbackRaf=requestAnimationFrame(this.tick))})}};import{debounce as XO,easeOut as zT,isBounds as KO}from"@excalidraw/common";import{clamp as GT}from"@excalidraw/math";import{getCommonBounds as RT,getElementsInGroup as $O,isElementLink as ZO,isExcalidrawElement as jO,parseElementLinkFromURL as qO}from"@excalidraw/element";var sp="animateScrollToContent",$a="animateScrollConstraintsSnapBack",NT=500,JO=250,QO=200,eE=302,BT={full:216,compact:64},e9=e=>{if(!e||typeof e!="object"||Array.isArray(e))return!1;let n=e;return typeof n.x=="number"&&typeof n.y=="number"&&(n.width==null||typeof n.width=="number")&&(n.height==null||typeof n.height=="number")},t9=(e,n)=>{let t=n.get(e);return t?[t]:$O(n,e)},FT=(e,n,t)=>{if(typeof e=="string"){let a=ZO(e),s=a?"link":"element",l=a?qO(e):e,c=l?t9(l,n):[];return c.length?{bounds:RT(c,n),type:s}:{bounds:null,type:s}}if(KO(e))return{bounds:e,type:"area"};if(e9(e)&&!jO(e)){let a=e.width??t.width,s=e.height??t.height;return{bounds:[e.x,e.y,e.x+a,e.y+s],type:"area"}}let o=Array.isArray(e)?e:[e],r=o.reduce((a,s)=>{if(s&&!s.isDeleted){let l=n.get(s.id);l&&a.push(l)}return a},[]),i=!r.length;return(r.length!==o.length||i)&&console.warn("supplied element target(s) for setViewport contain deleted or non-existent elements which have been filtered out"),i?{bounds:null,type:"element"}:{bounds:RT(r,n),type:"element"}},n9=e=>e===!1?0:e===!0||e==null?wu:Math.max(e,0),o9=(e,n,t="scale-down",o,r)=>{let{appState:i}=_r({bounds:n,appState:e,fit:t,canvasOffsets:o,steppedZoom:!1,viewportZoomFactor:r});return{scrollX:i.scrollX,scrollY:i.scrollY,zoom:i.zoom}},OT=(e,n,{fit:t,offsets:o,lock:r,viewportZoomFactor:i})=>{let a=o9(e,n,t,o,i);if(!r?.scroll&&!r?.zoom)return{...a,scrollConstraints:null};let[s,l,c,d]=n,m={x:s,y:l,width:c-s,height:d-l,lockScroll:!!r.scroll,lockZoom:!!r.zoom,zoom:a.zoom.value,overscroll:n9(r.overscroll),offsets:o};return{...Vn({...e,...a,scrollConstraints:m}),scrollConstraints:m}},r9=({from:e,target:n,factor:t})=>{if(t>=1)return{...n};let o=e.zoom.value*Math.pow(n.zoom.value/e.zoom.value,t),r=n.zoom.value===e.zoom.value?t:(o-e.zoom.value)/(n.zoom.value-e.zoom.value);return{scrollX:((1-r)*e.scrollX*e.zoom.value+r*n.scrollX*n.zoom.value)/o,scrollY:((1-r)*e.scrollY*e.zoom.value+r*n.scrollY*n.zoom.value)/o,zoom:{value:o}}},i9=e=>e===!1?null:e===!0||e==null?NT:e.duration??NT,a9=(e,n,t,o,r)=>{st.start(sp,({deltaTime:i,state:a})=>{let s=(a?.elapsed??0)+i,l=Math.min(s/t,1),c=zT(GT(l,0,1));return l<1?(o({...r9({from:e,target:n,factor:c}),shouldCacheIgnoreZoom:!0}),{elapsed:s}):(r(),null)})},s9=(e,n,t=JO)=>{let o=Vn(e);if(o.scrollX===e.scrollX&&o.scrollY===e.scrollY&&o.zoom.value===e.zoom.value||st.running(sp))return;let r=(e.scrollX-o.scrollX)*e.zoom.value,i=(e.scrollY-o.scrollY)*e.zoom.value;st.start($a,({deltaTime:a,state:s})=>{let l=(s?.elapsed??0)+a,c=Math.min(l/t,1),d=1-zT(GT(c,0,1));return n(m=>{if(!m.scrollConstraints)return null;let p=Vn(m),u=p.zoom.value;return{scrollX:p.scrollX+r*d/u,scrollY:p.scrollY+i*d/u,zoom:p.zoom}}),c<1?{elapsed:l}:null})},lp=class{constructor(n,t){this.app=n;this.dependencies=t;v(this,"lastPosition",{x:0,y:0});v(this,"activeTransition",null);v(this,"uiLastMeasured",new Map);v(this,"invalidateUIOffset",n=>{this.uiLastMeasured.delete(n)});v(this,"resolveOffsets",n=>{if(!n)return n;let{ui:t,...o}=n;if(!t)return o;let r=this.getOffsets(t===!0?void 0:t);return{top:o.top??r.top,right:o.right??r.right,bottom:o.bottom??r.bottom,left:o.left??r.left}});v(this,"getOffsets",n=>{let t=this.dependencies.getContainer(),o=t?.getBoundingClientRect(),r=Kn().rtl,i={top:0,right:0,bottom:0,left:0},a=new Set;if(t&&o)for(let u of t.querySelectorAll("[data-viewport-ui]")){let E=u.getBoundingClientRect(),g={top:E.top-o.top,right:E.right-o.left,bottom:E.bottom-o.top,left:E.left-o.left,width:E.width};switch(u.dataset.viewportUi){case"top":i.top=Math.max(i.top,g.bottom);break;case"bottom":i.bottom=Math.max(i.bottom,this.app.state.height-g.top);break;case"side":{let[b,w]=g.left+g.width/2<this.app.state.width/2?["left",g.right]:["right",this.app.state.width-g.left];i[b]=Math.max(i[b],w);let y=u.dataset.viewportUiName;y&&(a.add(y),w>0&&this.uiLastMeasured.set(y,{side:b,offset:w}));break}}}if(n?.reserve&&this.app.editorInterface.formFactor!=="phone"){let u=(E,g)=>{if(a.has(E))return;let{side:b,offset:w}=this.uiLastMeasured.get(E)??g;i[b]=Math.max(i[b],w)};n.reserve.stylesPanel&&u("stylesPanel",{side:r?"right":"left",offset:this.dependencies.getStylesPanelMode()==="compact"?BT.compact:BT.full}),n.reserve.sidebar&&u("sidebar",{side:r?"left":"right",offset:eE})}let s=n?.padding??24,l=n?.paddingTop??s,c=(r?n?.paddingLeft:n?.paddingRight)??s,d=n?.paddingBottom??s,m=(r?n?.paddingRight:n?.paddingLeft)??s,p={top:i.top+l,right:i.right+c,bottom:i.bottom+d,left:i.left+m};return{top:n?.top??p.top,right:(r?n?.left:n?.right)??p.right,bottom:n?.bottom??p.bottom,left:(r?n?.right:n?.left)??p.left}});v(this,"resolveInitialViewport",(n,t,o)=>{let{bounds:r}=FT(n.target,t,o);return r?OT(o,r,{...n,offsets:this.resolveOffsets(n.offsets)}):null});v(this,"setViewport",n=>{if(n===null){this.cancelTransition(),st.cancel($a),this.snapBackDebounced.cancel(),this.app.setState({scrollConstraints:null,shouldCacheIgnoreZoom:!1});return}let{target:t,fit:o,lock:r,animation:i,viewportZoomFactor:a}=n,s=this.resolveOffsets(n.offsets),{bounds:l,type:c}=FT(t,this.app.scene.getNonDeletedElementsMap(),this.app.state);if(!l){c==="link"&&this.app.setState({toast:{message:f("elementLink.notFound"),duration:3e3,closable:!0}});return}let d=OT(this.app.state,l,{fit:o,offsets:s,lock:r,viewportZoomFactor:a}),m=i9(i),p={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom};if(this.cancelTransition(),st.cancel($a),this.snapBackDebounced.cancel(),m===null){this.app.setState({...d,shouldCacheIgnoreZoom:!1});return}let u={target:d};this.activeTransition=u,this.app.state.scrollConstraints&&this.app.setState({scrollConstraints:null}),a9(p,d,m,E=>{this.activeTransition===u&&this.app.setState(E)},()=>{this.activeTransition===u&&(this.activeTransition=null,this.app.setState({...u.target,shouldCacheIgnoreZoom:!1}))})});v(this,"translate",(n,t)=>{if(this.isLockedTransitionPending)return!1;this.cancelTransition(),t?.preserveScrollConstraintsSnapBack||st.cancel($a),this.app.setState({shouldCacheIgnoreZoom:!1}),this.app.requestUnfollow();let o=this.app.state.zoom.value;return this.app.setState(n),this.app.setState(r=>{if(!r.scrollConstraints)return null;let a=!t?.zoomPreConstrained&&r.zoom.value!==o?0:r.scrollConstraints.overscroll;return a>0&&this.snapBackDebounced(),Vn(r,a)}),!0});v(this,"constrain",(n=0)=>{this.app.setState(t=>t.scrollConstraints?Vn(t,n):null)});v(this,"releaseOverscroll",()=>{this.app.state.scrollConstraints&&(this.snapBackDebounced.cancel(),this.snapBack())});v(this,"snapBack",()=>{this.app.unmounted||this.dependencies.isGestureActive()||s9(this.app.state,n=>this.app.setState(t=>n(t)))});v(this,"snapBackDebounced",XO(this.snapBack,QO));v(this,"cancelTransition",()=>{this.activeTransition=null,st.cancel(sp)});v(this,"destroy",()=>{this.cancelTransition(),st.cancel($a),this.snapBackDebounced.cancel()})}get isAnimating(){return st.running(sp)||st.running($a)}get isLockedTransitionPending(){return!!this.activeTransition?.target.scrollConstraints}};import cp from"react";var l9=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,c9=/{{([\w-]+)}}/,d9=/<([\w-]+)>/,m9=/<\/([\w-]+)>/,p9=(e,n)=>{let t=[{name:"",children:[]}];return e.split(l9).filter(Boolean).forEach(o=>{let r=o.match(d9),i=o.match(m9),a=o.match(c9);if(r!==null){let s=r[1];n.hasOwnProperty(s)?t.push({name:s,children:[]}):console.warn(`Trans: missed to pass in prop ${s} for interpolating ${e}`)}else if(i!==null)if(i[1]===t[t.length-1].name){let l=t.pop(),c=cp.createElement(cp.Fragment,{},...l.children),d=n[l.name];typeof d=="function"&&t[t.length-1].children.push(d(c))}else console.warn(`Trans: unexpected end tag ${o} for interpolating ${e}`);else if(a!==null){let s=a[1];n.hasOwnProperty(s)?t[t.length-1].children.push(n[s]):console.warn(`Trans: key ${s} not in props for interpolating ${e}`)}else t[t.length-1].children.push(o)}),t.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),t[0].children},u9=({i18nKey:e,children:n,...t})=>{let{t:o}=_e();return cp.createElement(cp.Fragment,{},...p9(o(e),t))},ci=u9;import{jsx as yn,jsxs as HT}from"react/jsx-runtime";var h9=()=>HT("div",{"data-testid":"brave-measure-text-error",children:[yn("p",{children:yn(ci,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>yn("span",{style:{fontWeight:600},children:e})})}),yn("p",{children:yn(ci,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>yn("span",{style:{fontWeight:600},children:e})})}),yn("p",{children:yn(ci,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>yn("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),yn("p",{children:yn(ci,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>yn("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>HT("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),UT=h9;import v9 from"clsx";import I9 from"react";import{isDarwin as WT}from"@excalidraw/common";var g9={toggleTheme:[N("Shift+Alt+D")],saveScene:[N("CtrlOrCmd+S")],loadScene:[N("CtrlOrCmd+O")],imageExport:[N("CtrlOrCmd+Shift+E")],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:[WT?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")],bringToFront:[WT?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")],copyAsPng:[N("Shift+Alt+C")],group:[N("CtrlOrCmd+G")],ungroup:[N("CtrlOrCmd+Shift+G")],gridMode:[N("CtrlOrCmd+'")],objectsSnapMode:[N("Alt+S")],stats:[N("Alt+/")],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:[],zoomToFit:[],zoomToFitSelectionInViewport:[],smartZoom:[N("F")],saveFileToDisk:[N("CtrlOrCmd+S")],saveToActiveFile:[N("CtrlOrCmd+S")],toggleShortcuts:[N("?")],searchMenu:[N("CtrlOrCmd+F")],wrapSelectionInFrame:[],arrangeElements:[N("Shift+R")],toolLock:[N("Q")]},je=(e,n=0)=>{let t=g9[e];return t&&t.length>0?t[n]||t[0]:""};import{useLayoutEffect as f9,useRef as VT,useEffect as YT}from"react";import{unstable_batchedUpdates as E9}from"react-dom";import{KEYS as b9,queryFocusableElements as x9}from"@excalidraw/common";import{clamp as XT}from"@excalidraw/math";import y9 from"clsx";import{jsx as w9}from"react/jsx-runtime";var Er=10,KT=({children:e,left:n,top:t,onCloseRequest:o,fitInViewport:r=!1,viewportWidth:i=window.innerWidth,viewportHeight:a=window.innerHeight,className:s})=>{let l=VT(null);YT(()=>{let d=l.current;if(!d)return;d.contains(document.activeElement)||d.focus();let m=p=>{if(p.key===b9.TAB){let u=x9(d),{activeElement:E}=document,g=u.findIndex(b=>b===E);E===d?(p.shiftKey?u[u.length-1]?.focus():u[0].focus(),p.preventDefault(),p.stopImmediatePropagation()):g===0&&p.shiftKey?(u[u.length-1]?.focus(),p.preventDefault(),p.stopImmediatePropagation()):g===u.length-1&&!p.shiftKey&&(u[0]?.focus(),p.preventDefault(),p.stopImmediatePropagation())}};return d.addEventListener("keydown",m),()=>d.removeEventListener("keydown",m)},[]);let c=VT(null);return f9(()=>{if(r&&l.current&&t!=null&&n!=null){let d=l.current,{width:m,height:p}=d.getBoundingClientRect();if(c.current?.top===t&&c.current?.left===n)return;c.current={top:t,left:n};let u=Math.max(0,i-Er*2);m>=u?(d.style.width=`${u}px`,d.style.left=`${Er}px`,d.style.overflowX="scroll"):d.style.left=`${XT(n,Er,i-Er-m)}px`;let E=Math.max(0,a-Er*2);p>=E?(d.style.height=`${E}px`,d.style.top=`${Er}px`,d.style.overflowY="scroll"):d.style.top=`${XT(t,Er,a-Er-p)}px`}},[t,n,r,i,a]),YT(()=>{if(o){let d=m=>{l.current?.contains(m.target)||E9(()=>o(m))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[o]),w9("div",{className:y9("popover",s),ref:l,tabIndex:-1,children:e})};import{jsx as Do,jsxs as ZT}from"react/jsx-runtime";var qe="separator",$T=e=>"onSelect"in e,jT=I9.memo(({actionManager:e,items:n,top:t,left:o,onClose:r})=>{let i=Qn(),a=Ui(),s=n.reduce((l,c)=>c?c===qe||$T(c)?(l.push(c),l):((!c.predicate||c.predicate(a,i,e.app.props,e.app))&&l.push(c),l):l,[]);return Do(KT,{onCloseRequest:()=>{r()},top:t,left:o,fitInViewport:!0,viewportWidth:i.width,viewportHeight:i.height,className:"context-menu-popover",children:Do("ul",{className:"context-menu",onContextMenu:l=>l.preventDefault(),children:s.map((l,c)=>{if(l===qe)return!s[c-1]||s[c-1]===qe?null:Do("hr",{className:"context-menu-item-separator"},c);if($T(l))return Do("li",{"data-testid":l.key,onClick:()=>{r(()=>{l.onSelect()})},children:ZT("button",{type:"button",className:"context-menu-item",children:[Do("div",{className:"context-menu-item__label",children:l.label}),Do("kbd",{className:"context-menu-item__shortcut"})]})},l.key);let d=l.name,m="";return l.label&&(typeof l.label=="function"?m=f(l.label(a,i,e.app)):m=f(l.label)),Do("li",{"data-testid":d,onClick:()=>{r(()=>{e.executeAction(l,"contextMenu")})},children:ZT("button",{type:"button",className:v9("context-menu-item",{dangerous:d==="deleteSelectedElements",checkmark:l.checked?.(i)}),children:[Do("div",{className:"context-menu-item__label",children:m}),Do("kbd",{className:"context-menu-item__shortcut",children:d?je(d):""})]})},c)})})})});import{useId as T9}from"react";import S9 from"clsx";import{Fragment as C9,jsx as Xl,jsxs as qT}from"react/jsx-runtime";var dp=({border:e,style:n})=>Xl("div",{className:"viewport-status-frame__border",style:{borderColor:e,...n}}),mp=({label:e,border:n})=>{let t=T9(),o=qT(C9,{children:[e.icon&&Xl("span",{className:"viewport-status-frame__badge-icon",children:e.icon}),e.label]});return qT("div",{className:S9("viewport-status-frame__badge",{"viewport-status-frame__badge--clickable":e.onClick}),role:"status",style:{"--viewport-status-frame-badge-background":e.background||n||"var(--color-primary)",color:e.color},children:[e.onClick&&Xl("button",{type:"button",className:"viewport-status-frame__badge-action","aria-labelledby":t,onClick:e.onClick}),Xl("div",{className:"viewport-status-frame__badge-label",id:e.onClick?t:void 0,children:o}),e.onClose&&Xl("button",{type:"button",className:"viewport-status-frame__badge-close","aria-label":f("buttons.close"),onClick:e.onClose,children:an})]})};import ls from"clsx";import JW from"react";import{CLASSES as QW,TOOL_TYPE as Pk,arrayToMap as eV,isShallowEqual as Yp}from"@excalidraw/common";import{mutateElement as tV,ShapeCache as nV}from"@excalidraw/element";import{showSelectedShapeActions as oV}from"@excalidraw/element";import{createIsolation as P9}from"jotai-scope";import tE from"react";import Lo from"tunnel-rat";var nE=tE.createContext(null),ot=()=>tE.useContext(nE),k9=P9(),JT=()=>tE.useMemo(()=>({MainMenuTunnel:Lo(),WelcomeScreenMenuHintTunnel:Lo(),WelcomeScreenToolbarHintTunnel:Lo(),WelcomeScreenHelpHintTunnel:Lo(),WelcomeScreenCenterTunnel:Lo(),FooterCenterTunnel:Lo(),DefaultSidebarTriggerTunnel:Lo(),DefaultSidebarTabTriggersTunnel:Lo(),OverwriteConfirmDialogTunnel:Lo(),tunnelsJotai:k9}),[]);import xr from"clsx";import{useRef as F9}from"react";import{Popover as br}from"radix-ui";import{CLASSES as cS}from"@excalidraw/common";import{isArrowElement as lS}from"@excalidraw/element";import{forwardRef as QT}from"react";import eS from"clsx";import{jsx as tS}from"react/jsx-runtime";var M9=QT(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>tS("div",{className:eS("Stack Stack_horizontal",r),style:{"--gap":n,alignItems:t,justifyContent:o,...i},ref:a,children:e})),A9=QT(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>tS("div",{className:eS("Stack Stack_vertical",r),style:{"--gap":n,justifyItems:t,justifyContent:o,...i},ref:a,children:e})),Bt={Row:M9,Col:A9};import{isTransparent as nS}from"@excalidraw/common";import{shouldAllowVerticalAlign as D9,suppportsHorizontalAlign as L9,hasBoundTextElement as oS,isElbowArrow as _9,isImageElement as rS,isLinearElement as R9,isTextElement as N9,hasStrokeColor as iS,toolIsArrow as B9}from"@excalidraw/element";var aS=(e,n)=>{let t=n[0]?.type||null;for(let o of n)if(o.type!==t){t=null;break}return iS(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||n.some(o=>iS(o.type))},sS=(e,n)=>Yo(e.activeTool.type)||n.some(t=>Yo(t.type)),pp=(e,n,t,o)=>{let r=e.activeTool.type,i=d=>d(r)||n.some(m=>d(m.type)),a=n.length===1,s=n.length===2&&(oS(n[0])||oS(n[1])),l=!!(e.editingTextElement||e.newElement),c=n.length>0;return{hasSelection:c,showExtraActions:c&&!l,strokeColor:aS(e,n),backgroundColor:sS(e,n),fill:r==="bucketfill"||Yo(r)&&!nS(e.currentItemBackgroundColor)||n.some(d=>Yo(d.type)&&!nS(d.backgroundColor)),strokeWidth:i(ix),freedrawMode:i(ax),strokeStyle:i(vu),sloppiness:i(vu),roundness:i(sx),arrowType:i(B9),arrowheads:i(Es),text:r==="text"||n.some(N9),textAlign:r==="text"||L9(n,t),verticalAlign:D9(n,t),opacity:r!=="autoshape"||c,layers:r!=="freedraw"&&r!=="autoshape"&&!n.some(d=>d.type==="freedraw")||ce(t,e).some(d=>d.type==="freedraw"),align:!s&&dt(e,o),distribute:n.length>2,imageLayout:n.length>1&&n.every(rS)&&dt(e,o),link:a||s,linkSingleOnly:a,cropEditor:!e.croppingElementId&&a&&rS(n[0]),lineEditor:!e.selectedLinearElement?.isEditing&&a&&R9(n[0])&&!_9(n[0])}};import{Fragment as Qt,jsx as q,jsxs as Ce}from"react/jsx-runtime";var oE=xr([cS.SHAPE_ACTIONS_THEME_SCOPE,"properties-content"]),dS=({renderAction:e})=>Ce("fieldset",{children:[q("legend",{children:f("labels.layers")}),Ce("div",{className:"buttonList",children:[e("sendToBack"),e("sendBackward"),e("bringForward"),e("bringToFront")]})]}),mS=({renderAction:e,showDistribute:n,showImageLayout:t})=>{let o=document.documentElement.getAttribute("dir")==="rtl";return Ce("fieldset",{children:[q("legend",{children:f("labels.align")}),Ce("div",{className:"buttonList",children:[o?Ce(Qt,{children:[e("alignRight"),e("alignHorizontallyCentered"),e("alignLeft")]}):Ce(Qt,{children:[e("alignLeft"),e("alignHorizontallyCentered"),e("alignRight")]}),n&&e("distributeHorizontally"),q("div",{style:{flexBasis:"100%",height:0}}),Ce("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[e("alignTop"),e("alignVerticallyCentered"),e("alignBottom"),n&&e("distributeVertically")]}),t&&Ce(Qt,{children:[q("div",{style:{flexBasis:"100%",height:0}}),e("arrangeElements"),e("normaliseElements")]})]})]})},pS=({appState:e,elementsMap:n,renderAction:t,app:o})=>{let r=Ci(n,e),i=pp(e,r,n,o);return e.activeTool.type==="bucketfill"?Ce("div",{className:"selected-shape-actions",children:[q("div",{children:t("changeBucketFillBackgroundColor")}),t("changeFillStyle"),t("changeOpacity")]}):Ce("div",{className:"selected-shape-actions",children:[q("div",{children:i.strokeColor&&t("changeStrokeColor")}),i.backgroundColor&&q("div",{children:t("changeBackgroundColor")}),i.fill&&t("changeFillStyle"),i.strokeWidth&&t("changeStrokeWidth"),i.strokeStyle&&q(Qt,{children:t("changeStrokeStyle")}),i.freedrawMode&&t("changeFreedrawMode"),i.sloppiness&&q(Qt,{children:t("changeSloppiness")}),i.roundness&&q(Qt,{children:t("changeRoundness")}),i.arrowType&&q(Qt,{children:t("changeArrowType")}),i.text&&Ce(Qt,{children:[q("fieldset",{children:t("changeFontFamily")}),t("changeFontSize"),i.textAlign&&t("changeTextAlign")]}),i.verticalAlign&&t("changeVerticalAlign"),i.arrowheads&&q(Qt,{children:t("changeArrowhead")}),i.opacity&&t("changeOpacity"),i.layers&&q(dS,{renderAction:t}),i.align&&q(mS,{renderAction:t,showDistribute:i.distribute,showImageLayout:i.imageLayout}),i.showExtraActions&&Ce("fieldset",{children:[q("legend",{children:f("labels.actions")}),Ce("div",{className:"buttonList",children:[t("duplicateSelection"),t("deleteSelectedElements"),t("group"),t("ungroup"),i.link&&t("hyperlink"),i.cropEditor&&t("cropEditor"),i.lineEditor&&t("toggleLinearEditor"),t("smartZoom")]})]})]})},uS=({appState:e,renderAction:n,setAppState:t,predicates:o,container:r})=>{let i=o.hasSelection||e.activeTool.type!=="selection"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser"&&e.activeTool.type!=="lasso",a=e.openPopup==="compactStrokeStyles";return i?q("div",{className:"compact-action-item",children:Ce(br.Root,{open:a,onOpenChange:s=>{t(s?{openPopup:"compactStrokeStyles"}:{openPopup:null})},children:[q(br.Trigger,{asChild:!0,children:q("button",{type:"button",className:xr("compact-action-button properties-trigger",{active:a}),title:f("labels.stroke"),onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:a?null:"compactStrokeStyles"})},children:g0})}),a&&q(yo,{className:oE,container:r,style:{maxWidth:"13rem"},onClose:()=>{},children:Ce("div",{className:"selected-shape-actions",children:[o.fill&&n("changeFillStyle"),o.strokeWidth&&n("changeStrokeWidth"),o.freedrawMode&&n("changeFreedrawMode"),o.strokeStyle&&q(Qt,{children:n("changeStrokeStyle")}),o.sloppiness&&q(Qt,{children:n("changeSloppiness")}),o.roundness&&n("changeRoundness"),o.opacity&&n("changeOpacity")]})})]})}):null},hS=({appState:e,renderAction:n,setAppState:t,targetElements:o,predicates:r,container:i,app:a})=>{if(!r.arrowType)return null;let s=e.openPopup==="compactArrowProperties";return q("div",{className:"compact-action-item",children:Ce(br.Root,{open:s,onOpenChange:l=>{t(l?{openPopup:"compactArrowProperties"}:{openPopup:null})},children:[q(br.Trigger,{asChild:!0,children:q("button",{type:"button",className:xr("compact-action-button properties-trigger",{active:s}),title:f("labels.arrowtypes"),onClick:l=>{l.preventDefault(),l.stopPropagation(),t({openPopup:s?null:"compactArrowProperties"})},children:(()=>{let l=mt(o,a,c=>lS(c)?c.elbowed?"elbow":c.roundness?"round":"sharp":null,c=>lS(c),c=>c?null:e.currentItemArrowType);return l==="elbow"?Jo:l==="round"?Qo:qo})()})}),s&&q(yo,{container:i,className:"properties-content",style:{maxWidth:"13rem"},onClose:()=>{},children:n("changeArrowProperties")})]})})},gS=({appState:e,renderAction:n,setAppState:t,predicates:o,container:r})=>{let{saveCaretPosition:i,restoreCaretPosition:a}=O0(),s=e.openPopup==="compactTextProperties";return q("div",{className:"compact-action-item",children:Ce(br.Root,{open:s,onOpenChange:l=>{l?(e.editingTextElement&&i(),t({openPopup:"compactTextProperties"})):(t({openPopup:null}),e.editingTextElement&&a())},children:[q(br.Trigger,{asChild:!0,children:q("button",{type:"button",className:xr("compact-action-button properties-trigger",{active:s}),title:f("labels.textAlign"),onClick:l=>{l.preventDefault(),l.stopPropagation(),s?t({openPopup:null}):(e.editingTextElement&&i(),t({openPopup:"compactTextProperties"}))},children:Hx})}),e.openPopup==="compactTextProperties"&&q(yo,{className:oE,container:r,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&a()},children:Ce("div",{className:"selected-shape-actions",children:[o.text&&n("changeFontSize"),o.textAlign&&n("changeTextAlign"),o.verticalAlign&&n("changeVerticalAlign")]})})]})})},fS=({appState:e,renderAction:n,predicates:t,setAppState:o,container:r,showDuplicate:i,showDelete:a})=>{let s=e.openPopup==="compactOtherProperties";return t.showExtraActions?q("div",{className:"compact-action-item",children:Ce(br.Root,{open:s,onOpenChange:l=>{o(l?{openPopup:"compactOtherProperties"}:{openPopup:null})},children:[q(br.Trigger,{asChild:!0,children:q("button",{type:"button",className:xr("compact-action-button properties-trigger",{active:s}),title:f("labels.actions"),onClick:l=>{l.preventDefault(),l.stopPropagation(),o({openPopup:s?null:"compactOtherProperties"})},children:Rx})}),s&&q(yo,{className:oE,container:r,style:{maxWidth:"12rem",justifyContent:"center",alignItems:"center"},onClose:()=>{},children:Ce("div",{className:"selected-shape-actions",children:[t.layers&&q(dS,{renderAction:n}),t.align&&q(mS,{renderAction:n,showDistribute:t.distribute,showImageLayout:t.imageLayout}),Ce("fieldset",{children:[q("legend",{children:f("labels.actions")}),Ce("div",{className:"buttonList",children:[n("group"),n("ungroup"),t.linkSingleOnly&&n("hyperlink"),t.cropEditor&&n("cropEditor"),n("smartZoom"),i&&n("duplicateSelection"),a&&n("deleteSelectedElements")]})]})]})})]})}):null},O9=({renderAction:e,predicates:n})=>n.lineEditor?q("div",{className:"compact-action-item",children:e("toggleLinearEditor")}):null,ES=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r})=>{let i=Ci(n,e),a=pp(e,i,n,o),{container:s}=Ne();return Ce("div",{className:"compact-shape-actions",children:[a.strokeColor&&q("div",{className:xr("compact-action-item"),children:t("changeStrokeColor")}),a.backgroundColor&&q("div",{className:"compact-action-item",children:t(e.activeTool.type==="bucketfill"?"changeBucketFillBackgroundColor":"changeBackgroundColor")}),a.freedrawMode&&q("div",{className:"compact-action-item",children:t("changeFreedrawMode",{cycle:!0})}),q(uS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s}),q(hS,{appState:e,renderAction:t,setAppState:r,targetElements:i,predicates:a,container:s,app:o}),a.lineEditor&&q("div",{className:"compact-action-item",children:t("toggleLinearEditor")}),a.text&&Ce(Qt,{children:[q("div",{className:"compact-action-item",children:t("changeFontFamily")}),q(gS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s})]}),a.showExtraActions&&q("div",{className:"compact-action-item",children:t("duplicateSelection")}),a.showExtraActions&&q("div",{className:"compact-action-item",children:t("deleteSelectedElements")}),q(fS,{appState:e,renderAction:t,predicates:a,setAppState:r,container:s})]})},bS=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r})=>{let i=Ci(n,e),a=pp(e,i,n,o),{container:s}=Ne(),l=F9(null),c=l.current?.getBoundingClientRect()?.width??0,d=9,m=6,p=32,u=d*p+(d-1)*m,E=p+m,g=c>=u+E,b=c>=u+2*E;return Ce(Ue,{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:[Ce("div",{style:{display:"flex",flexDirection:"row",gap:m,flex:1},children:[a.strokeColor&&q("div",{className:xr("compact-action-item"),children:t("changeStrokeColor")}),a.backgroundColor&&q("div",{className:"compact-action-item",children:t(e.activeTool.type==="bucketfill"?"changeBucketFillBackgroundColor":"changeBackgroundColor")}),q(uS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s}),q(hS,{appState:e,renderAction:t,setAppState:r,targetElements:i,predicates:a,container:s,app:o}),q(O9,{renderAction:t,predicates:a}),a.text&&Ce(Qt,{children:[q("div",{className:"compact-action-item",children:t("changeFontFamily")}),q(gS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s})]}),q(fS,{appState:e,renderAction:t,predicates:a,setAppState:r,container:s,showDuplicate:!b,showDelete:!g})]}),Ce("div",{style:{display:"flex",flexDirection:"row",gap:m},children:[q("div",{className:"compact-action-item",children:t("undo")}),q("div",{className:"compact-action-item",children:t("redo")}),b&&q("div",{className:"compact-action-item",children:t("duplicateSelection")}),g&&q("div",{className:"compact-action-item",children:t("deleteSelectedElements")})]})]})},xS=({renderAction:e})=>q(Bt.Col,{gap:1,className:cS.ZOOM_ACTIONS,children:Ce(Bt.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),yS=({renderAction:e,className:n})=>Ce("div",{className:`undo-redo-buttons ${n}`,children:[q("div",{className:"undo-button-container",children:q(pt,{label:f("buttons.undo"),children:e("undo")})}),q("div",{className:"redo-button-container",children:Ce(pt,{label:f("buttons.redo"),children:[" ",e("redo")]})})]}),wS=({showExitZenModeBtn:e})=>q("button",{type:"button",className:xr("disable-zen-mode",{"disable-zen-mode--visible":e}),children:f("buttons.exitZenMode")});import z9 from"clsx";import{useState as G9,useEffect as H9}from"react";import{THEME as U9}from"@excalidraw/common";import{jsx as rE,jsxs as W9}from"react/jsx-runtime";var up=({delay:e,theme:n})=>{let[t,o]=G9(!!e);return H9(()=>{if(!e)return;let r=setTimeout(()=>{o(!1)},e);return()=>clearTimeout(r)},[e]),t?null:W9("div",{className:z9("LoadingMessage",{"LoadingMessage--dark":n===U9.DARK}),children:[rE("div",{children:rE(xo,{})}),rE("div",{className:"LoadingMessage-text",children:f("labels.loadingScene")})]})};import{useState as Ep,useEffect as WS}from"react";import bz from"clsx";import{KEYS as lE,capitalizeString as VS}from"@excalidraw/common";import US from"react";import{DropdownMenu as hz}from"radix-ui";import{CLASSES as gz}from"@excalidraw/common";import V9 from"clsx";import{useCallback as Y9,useEffect as X9,useRef as K9}from"react";import{CLASSES as $9,EVENT as vS,KEYS as Z9}from"@excalidraw/common";import{DropdownMenu as j9}from"radix-ui";import{jsx as hp}from"react/jsx-runtime";var IS=({children:e,onClickOutside:n,className:t="",onSelect:o,open:r=!0,align:i="end",style:a})=>{let s=be(),l=K9(null),c=Hi({onClickOutside:n});Gi(l,Y9(m=>{l.current?.closest(`.${$9.DROPDOWN_MENU_EVENT_WRAPPER}`)?.contains(m.target)||c.onClickOutside?.()},[c])),X9(()=>{if(!r)return;let m=u=>{u.key===Z9.ESCAPE&&(u.preventDefault(),u.stopImmediatePropagation(),c.onClickOutside?.())},p={capture:!0};return document.addEventListener(vS.KEYDOWN,m,p),()=>{document.removeEventListener(vS.KEYDOWN,m,p)}},[c,r]);let d=V9(`dropdown-menu ${t}`,{"dropdown-menu--mobile":s.formFactor==="phone"}).trim();return hp(Ch.Provider,{value:{onSelect:o},children:hp(j9.Content,{ref:l,className:d,style:a,"data-testid":"dropdown-menu",align:i,sideOffset:8,onCloseAutoFocus:m=>m.preventDefault(),children:s.formFactor==="phone"?hp(Bt.Col,{className:"dropdown-menu-container",children:e}):hp(Ue,{className:"dropdown-menu-container",padding:2,children:e})})})};IS.displayName="DropdownMenuContent";var TS=IS;import{jsx as J9}from"react/jsx-runtime";var q9=({children:e,className:n="",selected:t,...o})=>J9("div",{...o,className:`dropdown-menu-item-base dropdown-menu-item-custom ${n} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),SS=q9;import{DropdownMenu as Q9}from"radix-ui";import{jsx as iE}from"react/jsx-runtime";var CS=({icon:e,shortcut:n,href:t,children:o,onSelect:r,className:i="",selected:a,rel:s="noopener",...l})=>{let c=fd(r);return iE(Q9.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:iE("a",{...l,href:t,target:"_blank",rel:`noopener ${s}`,className:or(i,a),title:l.title??l["aria-label"],children:iE(rr,{icon:e,shortcut:n,children:o})})})},Za=CS;CS.displayName="DropdownMenuItemLink";import{jsx as ez}from"react/jsx-runtime";var PS=()=>ez("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:"6px 0",flex:"0 0 auto"}}),kS=PS;PS.displayName="DropdownMenuSeparator";import{DropdownMenu as sz}from"radix-ui";import tz from"clsx";import{DropdownMenu as nz}from"radix-ui";import{useCallback as oz,useState as MS}from"react";import{jsx as sE}from"react/jsx-runtime";var aE=-4,rz=4,AS=({children:e,className:n})=>{let t=be(),o=tz(`dropdown-menu dropdown-submenu ${n}`,{"dropdown-menu--mobile":t.formFactor==="phone"}).trim(),r=oz(c=>{if(c){let m=c.closest(".dropdown-menu-container")?.getBoundingClientRect();if(m){let p=c.getBoundingClientRect().width,E=window.innerWidth-m.right;E<p+20&&(a(E-p+aE),l(aE+8))}}},[]),[i,a]=MS(rz),[s,l]=MS(aE);return sE(nz.SubContent,{className:o,sideOffset:i,alignOffset:s,collisionPadding:8,ref:r,children:t.formFactor==="phone"?sE(Bt.Col,{className:"dropdown-menu-container",children:e}):sE(Ue,{className:"dropdown-menu-container",padding:2,style:{zIndex:1},children:e})})},DS=AS;AS.displayName="DropdownMenuSubContent";import{DropdownMenu as iz}from"radix-ui";import{jsx as LS,jsxs as az}from"react/jsx-runtime";var _S=({children:e,icon:n,shortcut:t,className:o})=>az(iz.SubTrigger,{className:`${or(o)} dropdown-menu__submenu-trigger`,children:[LS(rr,{icon:n,shortcut:t,children:e}),LS("div",{className:"dropdown-menu__submenu-trigger-icon",children:b0})]}),RS=_S;_S.displayName="DropdownMenuSubTrigger";import NS from"react";var gp=e=>n=>{let t=NS.Children.toArray(n).find(o=>NS.isValidElement(o)&&typeof o.type!="string"&&o?.type.displayName&&o.type.displayName===e);return t||null},BS=gp("DropdownMenuTrigger"),FS=gp("DropdownMenuContent"),OS=gp("DropdownMenuSubTrigger"),zS=gp("DropdownMenuSubContent");import{jsxs as lz}from"react/jsx-runtime";var fp=({children:e})=>{let n=OS(e),t=zS(e);return lz(sz.Sub,{children:[n,t]})};fp.Trigger=RS;fp.Content=DS;fp.displayName="DropdownMenuSub";var yr=fp;import cz from"clsx";import{DropdownMenu as dz}from"radix-ui";import{jsx as mz}from"react/jsx-runtime";var GS=({className:e="",children:n,onToggle:t,title:o,...r})=>{let i=be(),a=cz(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.formFactor==="phone"}).trim();return mz(dz.Trigger,{className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:o,...r,children:n})},HS=GS;GS.displayName="DropdownMenuTrigger";import{jsx as uz}from"react/jsx-runtime";var pz=e=>uz(qt,{...e,icon:e.checked?Hc:$c}),io=pz;import{jsx as Ez,jsxs as fz}from"react/jsx-runtime";var Bn=({children:e,open:n})=>{let t=BS(e),o=FS(e),r=o&&US.isValidElement(o)?US.cloneElement(o,{open:n}):o;return Ez(hz.Root,{open:n,modal:!1,children:fz("div",{className:gz.DROPDOWN_MENU_EVENT_WRAPPER,style:{display:"contents"},children:[t,r]})})};Bn.Trigger=HS;Bn.Content=TS;Bn.Item=qt;Bn.ItemCheckbox=io;Bn.ItemLink=Za;Bn.ItemCustom=SS;Bn.Group=Gs;Bn.Separator=kS;Bn.Sub=yr;var pe=Bn;Bn.displayName="DropdownMenu";import{Fragment as cE,jsx as Re,jsxs as ja}from"react/jsx-runtime";var xz=({actionManager:e,app:n})=>{if(!e.isActionEnabled(Lt))return null;let t=f("buttons.objectsSnapMode");return Re(Z,{type:"toggle",icon:jo,checked:n.state.objectsSnapModeEnabled,title:t,"aria-label":t,"data-testid":"toolbar-objects-snap-mode",onSelect:()=>e.executeAction(Lt,"ui")})},yz=({app:e})=>Re(Z,{type:"button",icon:Fi,title:f("labels.eyeDropper"),"aria-label":f("labels.eyeDropper"),"data-testid":"toolbar-eyedropper",onClick:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1})}),YS=({app:e,actionManager:n,setAppState:t})=>{let o=e.state.activeTool,r=e.state.myocSimplifiedMode,i=e.props.UIOptions.tools?.image!==!1,[a,s]=Ep(!1),[l,c]=Ep("rectangle"),[d,m]=Ep("arrow");WS(()=>{(o.type==="rectangle"||o.type==="diamond"||o.type==="ellipse")&&c(o.type)},[o.type]),WS(()=>{(o.type==="arrow"||o.type==="line")&&m(o.type)},[o.type]);let p=o.type==="frame",u=o.type==="autoshape",E=o.type==="laser",g=o.type==="embeddable",b=o.type==="bucketfill",w=["rectangle","diamond","ellipse"].map(G=>({type:G,icon:Ye[G].icon,title:VS(f(`toolBar.${G}`)),fillable:Ye[G].fillable})),y=["arrow","line"].map(G=>({type:G,icon:Ye[G].icon,title:VS(f(`toolBar.${G}`)),fillable:Ye[G].fillable})),[x,I]=Ep(0),T=36,C=4,P=7,M=P*T+(P-1)*C,D=T+C,_=x>=M+1*D,k=i&&x>=M+2*D,L=x>=M+3*D,F=(r?["text","image"]:["text","image","frame","embeddable","laser","bucketfill"]).filter(G=>!(_&&G==="text"||(!i||k)&&G==="image"||L&&G==="frame")),Y=r&&ea.includes(o.type),z=Y||F.includes(o.type),U=z?Y?Ye[o.type].icon:o.type==="text"?Pn:o.type==="image"?Fr:o.type==="frame"?jn:o.type==="embeddable"?Zo:o.type==="laser"?qn:o.type==="bucketfill"?Zn:Ts:Ts,V={app:e,activeTool:o,hideShortcut:!0};return ja("div",{className:"mobile-toolbar",ref:G=>{G&&I(G.getBoundingClientRect().width)},children:[Re(zd,{...V}),Re(Gd,{...V,setAppState:t}),r?Re(Zs,{...V}):Re(Hd,{...V}),Re(Js,{...V}),!r&&Re(Qi,{app:e,options:w,activeTool:o,defaultOption:l,"data-testid":"toolbar-rectangle",onToolChange:G=>{(G==="rectangle"||G==="diamond"||G==="ellipse")&&(c(G),e.setActiveTool({type:G}))},displayedOption:w.find(G=>G.type===l)||w[0]}),!r&&Re(Qi,{app:e,options:y,activeTool:o,defaultOption:d,"data-testid":"toolbar-arrow",onToolChange:G=>{(G==="arrow"||G==="line")&&(m(G),e.setActiveTool({type:G}))},displayedOption:y.find(G=>G.type===d)||y[0]}),_&&Re(js,{...V}),r&&k&&Re(yz,{app:e}),k&&Re(qs,{...V}),!r&&L&&Re(Qy,{...V,hideShortcut:!0}),ja(pe,{open:a,children:[Re(pe.Trigger,{className:bz("App-toolbar__extra-tools-trigger App-toolbar__extra-tools-trigger--mobile",{"App-toolbar__extra-tools-trigger--selected":z||a}),onToggle:()=>{s(!a),t({openMenu:null,openPopup:null})},title:f("toolBar.extraTools"),style:{width:T,height:T,display:"flex",alignItems:"center",justifyContent:"center"},children:U}),ja(pe.Content,{onClickOutside:()=>s(!1),onSelect:()=>s(!1),className:"App-toolbar__extra-tools-dropdown",align:"start",children:[r&&ea.map(G=>Re(pe.Item,{onSelect:()=>e.setActiveTool({type:G}),icon:Ye[G].icon,"data-testid":`toolbar-${G}`,selected:o.type===G,shortcut:Od(G),disabled:Je(e,G),children:f(`toolBar.${G}`)},G)),!r&&Re("div",{className:"App-toolbar__dropdown-divider"}),!r&&n.isActionEnabled(Lt)&&Re(pe.Item,{onSelect:()=>n.executeAction(Lt,"ui"),icon:jo,"data-testid":"toolbar-objects-snap-mode",selected:e.state.objectsSnapModeEnabled,shortcut:je("objectsSnapMode"),children:f("buttons.objectsSnapMode")}),e.props.activeTool==null&&ja(cE,{children:[r&&Re("div",{className:"App-toolbar__dropdown-divider"}),Re(pe.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?Ko:bo,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:lE.Q.toLocaleUpperCase(),children:f("toolBar.lock-short")})]}),!_&&Re(pe.Item,{onSelect:()=>e.setActiveTool({type:"text"}),icon:Pn,shortcut:lE.T.toLocaleUpperCase(),"data-testid":"toolbar-text",selected:o.type==="text",disabled:Je(e,"text"),children:f("toolBar.text")}),i&&!k&&Re(pe.Item,{onSelect:()=>e.setActiveTool({type:"image"}),icon:Fr,"data-testid":"toolbar-image",selected:o.type==="image",disabled:Je(e,"image"),children:f("toolBar.image")}),!r&&!L&&Re(pe.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:jn,shortcut:lE.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:p,disabled:Je(e,"frame"),children:f("toolBar.frame")}),!r&&ja(cE,{children:[Re(pe.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:Zo,"data-testid":"toolbar-embeddable",selected:g,disabled:Je(e,"embeddable"),children:f("toolBar.embeddable")}),Re(pe.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:Gr,shortcut:na("autoshape"),"data-testid":"toolbar-autoshape",selected:u,disabled:Je(e,"autoshape"),children:f("toolBar.autoshape")}),Re(pe.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:qn,"data-testid":"toolbar-laser",selected:E,disabled:Je(e,"laser"),children:f("toolBar.laser")}),Re(pe.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:Zn,"data-testid":"toolbar-bucketfill",selected:b,disabled:Je(e,"bucketfill"),children:f("toolBar.bucketfill")})]})]})]}),r&&ja(cE,{children:[Re("div",{className:"App-toolbar__divider"}),Re(xz,{actionManager:n,app:e})]})]})};import wz from"clsx";import{jsx as vz}from"react/jsx-runtime";var bp=({children:e,side:n,className:t})=>vz("div",{className:wz("FixedSideContainer",`FixedSideContainer_side_${n}`,t),children:e});import Iz from"clsx";import{jsx as Tz}from"react/jsx-runtime";var qa=e=>e.penDetected?Tz(Z,{className:Iz("ToolIcon__penMode",{"is-mobile":e.isMobile}),type:"toggle",icon:Gx,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,onSelect:()=>e.onChange?.()}):null;import{Fragment as XS,jsx as wt,jsxs as di}from"react/jsx-runtime";var KS=({appState:e,elements:n,actionManager:t,setAppState:o,renderTopLeftUI:r,renderTopRightUI:i,renderSidebars:a,renderWelcomeScreen:s,defaultUIEnabled:l,scrollBackToContentUIEnabled:c,app:d,onPenModeToggle:m})=>{let{WelcomeScreenCenterTunnel:p,MainMenuTunnel:u,DefaultSidebarTriggerTunnel:E}=ot(),g=()=>{if(e.openDialog?.name==="elementLinkSelector")return null;let P=wt("div",{className:"excalidraw-ui-top-right",children:i?.(!0,e)??(!e.viewModeEnabled&&di(XS,{children:[l&&wt(qa,{checked:e.penMode,onChange:()=>m(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),wt(E.Out,{})]}))}),M=di("div",{className:"excalidraw-ui-top-left",children:[r?.(!0,e),wt(u.Out,{})]});return di("div",{className:"App-toolbar-content",style:{display:"flex",flexDirection:"row",justifyContent:"space-between"},children:[M,P]})},b=()=>wt(YS,{app:d,actionManager:t,setAppState:o}),w=c&&e.scrolledOutside,y=l,x=l&&(!e.viewModeEnabled||y),I=w&&!e.openMenu&&!e.openSidebar?wt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(P=>({...Si(n,P)}))},children:f("buttons.scrollBackToContent")}):null,T=d.props.viewportStatusFrame?.label,C=T?wt(mp,{label:T,border:d.props.viewportStatusFrame?.border}):null;return di(XS,{children:[a(),wt("div",{className:"App-welcome-screen",children:s&&wt(p.Out,{})}),x&&di("div",{className:"App-bottom-bar",style:{marginBottom:fn+Mo,left:14,transform:"none"},"data-viewport-ui":"bottom",children:[I&&wt("div",{className:"floating-status-stack",children:I}),di("div",{className:"App-bottom-bar__actions-row",children:[y&&di(Ue,{className:"mobile-canvas-actions",children:[!e.viewModeOnly&&wt("div",{className:"view-mode-button",children:t.renderAction("viewMode")}),wt("div",{className:"smart-zoom-button",children:t.renderAction("smartZoom")})]}),!e.viewModeEnabled&&wt(bS,{appState:e,elementsMap:d.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:d,setAppState:o})]}),!e.viewModeEnabled&&wt(Ue,{className:"App-toolbar",style:{justifyContent:"flex-start"},children:e.openDialog?.name!=="elementLinkSelector"&&b()})]}),!x&&I&&wt("div",{className:"floating-status-stack",children:I}),C&&wt("div",{className:"viewport-status-frame__badge-row",children:C}),wt(bp,{side:"top",className:"App-top-bar",children:g()})]})};import eC,{useLayoutEffect as tC,useRef as nC,useState as oC}from"react";import{newTextElement as rC}from"@excalidraw/element";import Dz from"clsx";import{useEffect as Lz,useState as _z}from"react";import{KEYS as Rz,queryFocusableElements as JS}from"@excalidraw/common";import{useCallback as Sz,useState as Cz}from"react";var $S=()=>{let[e,n]=Cz(null),t=Sz(o=>n(o),[]);return[e,t]};import ZS from"clsx";import{useRef as Pz}from"react";import{createPortal as kz}from"react-dom";import{KEYS as Mz}from"@excalidraw/common";import{jsx as jS,jsxs as Az}from"react/jsx-runtime";var qS=e=>{let{closeOnClickOutside:n=!0}=e,t=id({className:ZS("excalidraw-modal-container",e.portalContainerClassName)}),o=Pz(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let r=i=>{i.key===Mz.ESCAPE&&(i.preventDefault(),i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return kz(Az("div",{className:ZS("Modal",e.className,{"animations-disabled":o.current}),role:"dialog","aria-modal":"true",onKeyDown:r,"aria-labelledby":e.labelledBy,children:[jS("div",{className:"Modal__background",onClick:n?e.onCloseRequest:void 0}),jS("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as xp,jsxs as QS}from"react/jsx-runtime";function Nz(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var wn=e=>{let[n,t]=$S(),[o]=_z(document.activeElement),{id:r}=Ne(),i=be().formFactor==="phone";Lz(()=>{if(!n)return;let l=JS(n);setTimeout(()=>{l.length>0&&e.autofocus!==!1&&(l[1]||l[0]).focus()});let c=d=>{if(d.key===Rz.TAB){let m=JS(n),{activeElement:p}=document,u=m.findIndex(E=>E===p);u===0&&d.shiftKey?(m[m.length-1].focus(),d.preventDefault()):u===m.length-1&&!d.shiftKey&&(m[0].focus(),d.preventDefault())}};return n.addEventListener("keydown",c),()=>n.removeEventListener("keydown",c)},[n,e.autofocus]);let a=Oe(),s=()=>{a({openMenu:null}),o.focus(),e.onCloseRequest()};return xp(qS,{className:Dz("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:Nz(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,portalContainerClassName:e.portalContainerClassName,children:QS(Ue,{ref:t,children:[e.title&&QS("h2",{id:`${r}-dialog-title`,className:"Dialog__title",children:[xp("span",{className:"Dialog__titleContent",children:e.title}),e.titleButton]}),i&&xp("button",{className:"Dialog__close",onClick:s,title:f("buttons.close"),"aria-label":f("buttons.close"),type:"button",children:an}),xp("div",{className:"Dialog__content",children:e.children})]})})};import{jsx as _o,jsxs as yp}from"react/jsx-runtime";var Bz=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}},Fz=e=>{let n=nC(null),[t,o]=oC(null),{theme:r}=ye();tC(()=>{if(!e.spreadsheet){o(null);return}let a=Lf(e.chartType,e.spreadsheet,0,0,e.colorSeed);if(!a){o(null),n.current?.replaceChildren();return}o(a);let s,l=n.current;return(async()=>(s=await Rr(a,{exportBackground:!1,viewBackgroundColor:"#fff",exportWithDarkMode:r==="dark"},null,{skipInliningFonts:!0}),s.querySelector(".style-fonts")?.remove(),l.replaceChildren(),l.appendChild(s)))(),()=>{l.replaceChildren()}},[e.spreadsheet,e.chartType,e.colorSeed,r]);let i=Bz(e.chartType);return yp("button",{type:"button",className:"ChartPreview","aria-label":i,onClick:()=>{t&&e.onClick(e.chartType,t)},children:[_o("div",{className:"ChartPreview__canvas",ref:n}),_o("div",{className:"ChartPreview__label",children:i})]})},Oz=e=>{let n=nC(null),{theme:t}=ye();return tC(()=>{if(!e.rawText)return;let o=rC({text:e.rawText,x:0,y:0}),r=n.current;return(async()=>{let i=await Rr([o],{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]),yp("button",{type:"button",className:"ChartPreview","aria-label":f("labels.chartType_plaintext"),onClick:()=>{e.onClick(e.rawText)},children:[_o("div",{className:"ChartPreview__canvas",ref:n}),_o("div",{className:"ChartPreview__label",children:f("labels.chartType_plaintext")})]})},iC=({data:e,rawText:n,onClose:t})=>{let{onInsertElements:o,focusContainer:r}=St(),[i,a]=oC(Math.random()),s=eC.useCallback(()=>{a(Math.random())},[]),l=eC.useCallback(()=>{t&&t()},[t]),c=(m,p)=>{o(p),Fe("paste","chart",m),t(),r()},d=m=>{let p=rC({text:m,x:0,y:0});o([p]),Fe("paste","chart","plaintext"),t(),r()};return _o(wn,{size:"regular",onCloseRequest:l,title:yp("div",{className:"PasteChartDialog__title",children:[_o("div",{className:"PasteChartDialog__titleText",children:f("labels.pasteCharts")}),_o("div",{className:"PasteChartDialog__reshuffleBtn",onClick:s,role:"button",tabIndex:0,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),s())},children:Zn})]}),className:"PasteChartDialog",autofocus:!1,children:yp("div",{className:"container",children:[["bar","line","radar"].map(m=>Ra(e,m)?_o(Fz,{chartType:m,spreadsheet:e,colorSeed:i,onClick:c},m):null),n&&_o(Oz,{rawText:n,onClick:d})]})})};import{Fragment as zz,jsx as aC,jsxs as Gz}from"react/jsx-runtime";var Kl=({heading:e,children:n,...t})=>{let{id:o}=Ne(),r=aC("h2",{className:"visually-hidden",id:`${o}-${e}-title`,children:f(`headings.${e}`)});return aC("section",{...t,"aria-labelledby":`${o}-${e}-title`,children:typeof n=="function"?n(r):Gz(zz,{children:[r,n]})})};import{Popover as $l}from"radix-ui";import sC from"clsx";import wp,{useLayoutEffect as Hz}from"react";import{supportsResizeObserver as Uz,isShallowEqual as Wz}from"@excalidraw/common";import{Fragment as pE,jsx as vt,jsxs as Ja}from"react/jsx-runtime";var Vz=4,Yz=8,dE=38,lC=21,Xz=({shouldWrap:e,children:n,username:t})=>e?vt(pt,{label:t||"Unknown user",children:n}):vt(pE,{children:n}),mE=({actionManager:e,collaborator:n,socketId:t,withName:o=!1,shouldWrapWithTooltip:r=!1,isBeingFollowed:i})=>{let a={socketId:t,collaborator:n,withName:o,isBeingFollowed:i},s=e.renderAction("goToCollaborator",a);return vt(Xz,{username:n.username,shouldWrap:r,children:s},t)},Kz=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted","isCurrentUser"],vp=wp.memo(({className:e,mobile:n,collaborators:t,userToFollow:o,currentUserControls:r})=>{let i=rt(),a=typeof r=="function"?r(!!n):r,s=Array.from(t,([C,P])=>({...P,socketId:C})).filter(C=>C.username?.trim()),l=s.find(C=>C.isCurrentUser),c=s.filter(C=>!C.isCurrentUser),[d,m]=wp.useState(""),p=s.filter(C=>C.username?.toLowerCase().includes(d)),u=wp.useRef(null);Hz(()=>{if(u.current){let C=M=>{g(M)};if(C(u.current.clientWidth),!Uz)return;let P=new ResizeObserver(M=>{for(let D of M){let{width:_}=D.contentRect;C(_)}});return P.observe(u.current),()=>{P.disconnect()}}},[]);let[E,g]=wp.useState(Vz*dE),b=l?E-lC:E,w=Math.max(1,Math.min(8,Math.floor(b/dE))),y=l?Math.max(0,w-1):w,x=c.slice(0,y),I=l?[...x,l]:x,T=I.map(C=>{let P=mE({actionManager:i,collaborator:C,socketId:C.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:C.socketId===o});return C.isCurrentUser?Ja($l.Root,{children:[vt($l.Trigger,{asChild:!0,children:Ja("div",{className:"UserList__pill",children:[P,vt("div",{className:"UserList__pill-chevron",children:E0})]})}),vt($l.Content,{className:"focus-visible-none",style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:Ja(Ue,{padding:2,children:[s.length>=Yz&&vt(hd,{placeholder:f("quickSearch.placeholder"),onChange:m}),vt(gd,{className:"dropdown-menu UserList__collaborators",placeholder:f("userList.empty"),children:p.length>0?[vt("div",{className:"hint",children:f("userList.hint.text")},"hint"),p.map(M=>mE({actionManager:i,collaborator:M,socketId:M.socketId,withName:!0,isBeingFollowed:M.socketId===o}))]:[]}),a&&Ja(pE,{children:[vt("div",{className:"UserList__menu-divider"}),vt($l.Close,{asChild:!0,children:vt("div",{className:"dropdown-menu",children:a})})]}),vt($l.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})]},C.socketId):P});return n?Ja("div",{className:sC("UserList UserList_mobile",e),children:[vt("div",{className:"UserList_mobile__avatars",children:s.map(C=>mE({actionManager:i,collaborator:C,socketId:C.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:C.socketId===o}))}),a&&Ja(pE,{children:[vt("div",{className:"UserList__menu-divider"}),a]})]}):vt("div",{className:"UserList__wrapper",ref:u,children:vt("div",{className:sC("UserList",e),style:{"--max-avatars":I.length+(l?lC/dE:0)},children:T})})},(e,n)=>{if(e.collaborators.size!==n.collaborators.size||e.mobile!==n.mobile||e.className!==n.className||e.userToFollow!==n.userToFollow||e.currentUserControls!==n.currentUserControls)return!1;let t=n.collaborators.keys();for(let[o,r]of e.collaborators){let i=n.collaborators.get(o);if(!i||o!==t.next().value||!Wz(r,i,Kz))return!1}return!0});import Zl from"clsx";import{jsx as cC}from"react/jsx-runtime";var dC=e=>cC(pt,{label:`${f("helpDialog.title")} \u2014 ?`,children:cC("button",{className:"help-icon",onClick:e.onClick,type:"button","aria-label":f("helpDialog.title"),children:Bi})});import{jsx as en,jsxs as uE}from"react/jsx-runtime";var mC=({appState:e,actionManager:n,showExitZenModeBtn:t,renderWelcomeScreen:o,defaultUIEnabled:r,zoomUIEnabled:i})=>{let{FooterCenterTunnel:a,WelcomeScreenHelpHintTunnel:s}=ot(),l=St();return uE("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[(r||i&&l.isNavigationEnabled())&&en("div",{className:Zl("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:en(Bt.Col,{gap:2,children:uE(Kl,{heading:"canvasActions",children:[!e.viewModeOnly&&en(pt,{label:e.viewModeEnabled?"Edit mode":f("labels.viewMode"),children:en("div",{className:Zl("view-mode-button"),children:n.renderAction("viewMode")})}),en(pt,{label:f("buttons.smartZoom"),children:en("div",{className:Zl("smart-zoom-button"),children:n.renderAction("smartZoom")})}),i&&l.isNavigationEnabled()&&en(xS,{renderAction:n.renderAction}),r&&!e.viewModeEnabled&&en(yS,{renderAction:n.renderAction,className:Zl("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),en(a.Out,{}),(r||o)&&en("div",{className:Zl("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:uE("div",{style:{position:"relative"},children:[o&&en(s.Out,{}),r&&en(dC,{onClick:()=>n.executeAction(qr)})]})}),r&&en(wS,{showExitZenModeBtn:t})]})},pC=mC;mC.displayName="Footer";import{composeEventHandlers as tG}from"@excalidraw/common";import{useLayoutEffect as $z,useRef as Zz}from"react";import{jsx as jz}from"react/jsx-runtime";var mi=(e,n)=>{let t=Qe(0),o=r=>{let{tunnelsJotai:{useAtom:i}}=ot(),[,a]=i(t),s=Zz({preferHost:!1,counter:0});return $z(()=>{let l=s.current;return a(c=>{let d=c+1;return l.counter=d,d}),()=>{a(c=>{let d=c-1;return l.counter=d,d||(l.preferHost=!1),d})}},[a]),r.__fallback||(s.current.preferHost=!0),!s.current.counter&&r.__fallback&&s.current.preferHost||s.current.counter>1&&r.__fallback?null:jz(n,{...r})};return o.displayName=e,o};var EE={};w3(EE,{ChangeCanvasBackground:()=>IC,Export:()=>TC,Help:()=>wC,LiveCollaborationTrigger:()=>CC,LoadScene:()=>EC,Preferences:()=>ao,PreferencesToggleGridModeItem:()=>fE,SaveAsImage:()=>xC,SaveToActiveFile:()=>bC,SearchMenu:()=>yC,Socials:()=>SC,ToggleTheme:()=>vC});import eG from"clsx";import{THEME as ql}from"@excalidraw/common";var hE=Qe({active:!1});async function uC({title:e,description:n,actionLabel:t,color:o}){return new Promise(r=>{Et.set(hE,{active:!0,onConfirm:()=>r(!0),onClose:()=>r(!1),onReject:()=>r(!1),title:e,description:n,actionLabel:t,color:o})})}import qz from"clsx";import{jsx as hC,jsxs as Jz}from"react/jsx-runtime";var Ip=function({onChange:e,value:n,choices:t,name:o}){return hC("div",{className:"RadioGroup",children:t.map(r=>Jz("div",{className:qz("RadioGroup__choice",{active:r.value===n}),title:r.ariaLabel,children:[hC("input",{name:o,type:"radio",checked:r.value===n,onChange:()=>e(r.value),"aria-label":r.ariaLabel}),r.label]},String(r.value)))})};import{Fragment as Qz,jsx as jl,jsxs as gC}from"react/jsx-runtime";var fC=({value:e,shortcut:n,onChange:t,choices:o,children:r,name:i,icon:a})=>{let s=be();return gC(Qz,{children:[gC("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[a&&jl("div",{className:"dropdown-menu-item__icon",children:a}),jl("label",{className:"dropdown-menu-item__text",children:jl(Hs,{children:r})}),jl(Ip,{name:i,value:e,onChange:t,choices:o})]}),n&&s.formFactor!=="phone"&&jl("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:n})]})};fC.displayName="DropdownMenuItemContentRadio";var gE=fC;import{Fragment as RC,jsx as we,jsxs as Jl}from"react/jsx-runtime";var EC=()=>{let{t:e}=_e(),n=rt(),t=Ui();return n.isActionEnabled(ra)?we(qt,{icon:Uc,onSelect:async()=>{(!t.length||await uC({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:we(ci,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:r=>we("strong",{children:r}),br:()=>we("br",{})})}))&&n.executeAction(ra)},"data-testid":"load-button",shortcut:je("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};EC.displayName="LoadScene";var bC=()=>{let{t:e}=_e(),n=rt();return n.isActionEnabled(jr)?we(qt,{shortcut:je("saveScene"),"data-testid":"save-button",onSelect:()=>n.executeAction(jr),icon:$x,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};bC.displayName="SaveToActiveFile";var xC=()=>{let e=Oe(),{t:n}=_e();return we(qt,{icon:qx,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:je("imageExport"),"aria-label":n("buttons.exportImage"),children:n("buttons.exportImage")})};xC.displayName="SaveAsImage";var yC=e=>{let{t:n}=_e(),t=rt();return we(qt,{icon:Jn,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(Pl)},shortcut:je("searchMenu"),"aria-label":n("search.title"),className:e?.className,children:n("search.title")})};yC.displayName="SearchMenu";var wC=()=>{let{t:e}=_e(),n=rt();return we(qt,{"data-testid":"help-menu-item",icon:Bi,onSelect:()=>n.executeAction(qr),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};wC.displayName="Help";var vC=e=>{let{t:n}=_e(),t=ye(),o=rt(),r=je("toggleTheme"),i=kn();return o.isActionEnabled(Rd)?e?.allowSystemTheme?we(gE,{name:"theme",value:e.theme,onChange:a=>{if(i.onThemeChange){i.onThemeChange(a);return}console.warn("MainMenu.DefaultItems.ToggleTheme: `<Excalidraw/> props.onThemeChange` must be defined to use system theme selection.")},choices:[{value:ql.LIGHT,label:Ps,ariaLabel:`${n("buttons.lightMode")} - ${r}`},{value:ql.DARK,label:Cs,ariaLabel:`${n("buttons.darkMode")} - ${r}`},{value:"system",label:c0,ariaLabel:n("buttons.systemMode")}],children:n("labels.theme")}):we(qt,{onSelect:a=>{a.preventDefault(),o.executeAction(Rd)},icon:t.theme===ql.DARK?Ps:Cs,"data-testid":"toggle-dark-mode",shortcut:r,"aria-label":t.theme===ql.DARK?n("buttons.lightMode"):n("buttons.darkMode"),children:t.theme===ql.DARK?n("buttons.lightMode"):n("buttons.darkMode")}):null};vC.displayName="ToggleTheme";var IC=()=>{let{t:e}=_e(),n=ye(),t=rt(),o=kn();return n.viewModeEnabled||!o.UIOptions.canvasActions.changeViewBackgroundColor?null:Jl("div",{style:{marginTop:"0.75rem"},children:[we("div",{"data-testid":"canvas-background-label",style:{fontSize:"0.875rem",marginBottom:"0.25rem",marginLeft:"0.5rem"},children:e("labels.canvasBackground")}),we("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};IC.displayName="ChangeCanvasBackground";var TC=()=>{let{t:e}=_e(),n=Oe();return we(qt,{icon:ks,onSelect:()=>{n({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};TC.displayName="Export";var SC=()=>{let{t:e}=_e();return Jl(RC,{children:[we(Za,{icon:Yx,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),we(Za,{icon:Kx,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),we(Za,{icon:Xx,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};SC.displayName="Socials";var CC=({onSelect:e,isCollaborating:n})=>{let{t}=_e();return we(qt,{"data-testid":"collab-button",icon:Wc,className:eG({"active-collab":n}),onSelect:e,children:t("labels.liveCollaboration")})};CC.displayName="LiveCollaborationTrigger";var PC=()=>{let{t:e}=_e(),n=St(),t=ye();return we(io,{checked:t.activeTool.locked,shortcut:je("toolLock"),onSelect:o=>{n.toggleLock(),o.preventDefault()},children:e("labels.preferences_toolLock")})},kC=()=>{let{t:e}=_e(),n=ye(),t=Oe();return we(gE,{name:"boxSelectionMode",icon:$c,value:n.boxSelectionMode,onChange:o=>{t({boxSelectionMode:o})},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")})},MC=()=>{let{t:e}=_e(),n=rt(),t=ye();return we(io,{checked:t.objectsSnapModeEnabled,shortcut:je("objectsSnapMode"),onSelect:o=>{n.executeAction(Lt),o.preventDefault()},children:e("buttons.objectsSnapMode")})},AC=()=>{let{t:e}=_e(),n=rt(),t=ye();return we(io,{checked:t.bindingPreference==="enabled",onSelect:o=>{n.executeAction(sl),o.preventDefault()},children:e("labels.arrowBinding")})},DC=()=>{let{t:e}=_e(),n=rt(),t=ye();return we(io,{checked:t.isMidpointSnappingEnabled,onSelect:o=>{n.executeAction(ll),o.preventDefault()},children:e("labels.midpointSnapping")})},fE=()=>{let{t:e}=_e(),n=rt(),t=ye();return we(io,{checked:t.gridModeEnabled,shortcut:je("gridMode"),onSelect:o=>{n.executeAction(pa),o.preventDefault()},children:e("labels.toggleGrid")})},LC=()=>{let{t:e}=_e(),n=rt(),t=ye();return t.viewModeOnly?null:we(io,{checked:t.viewModeEnabled,shortcut:je("viewMode"),onSelect:o=>{n.executeAction(Ca),o.preventDefault()},children:e("labels.viewMode")})},_C=()=>{let{t:e}=_e(),n=rt(),t=ye();return we(io,{checked:t.stats.open,shortcut:je("stats"),onSelect:o=>{n.executeAction(mr),o.preventDefault()},children:e("stats.fullTitle")})},ao=({children:e,additionalItems:n})=>{let{t}=_e();return Jl(yr,{children:[we(yr.Trigger,{icon:x0,children:t("labels.preferences")}),Jl(yr.Content,{className:"excalidraw-main-menu-preferences-submenu",children:[e||Jl(RC,{children:[we(kC,{}),we(PC,{}),we(MC,{}),we(fE,{}),we(LC,{}),we(_C,{}),we(AC,{}),we(DC,{})]}),n]})]})};ao.ToggleToolLock=PC;ao.BoxSelectionMode=kC;ao.ToggleSnapMode=MC;ao.ToggleArrowBinding=AC;ao.ToggleMidpointSnapping=DC;ao.ToggleGridMode=fE;ao.ToggleViewMode=LC;ao.ToggleElementProperties=_C;ao.displayName="Preferences";import{jsx as Tp,jsxs as bE}from"react/jsx-runtime";var nG=Object.assign(mi("MainMenu",({children:e,onSelect:n})=>{let{MainMenuTunnel:t}=ot(),o=be(),r=ye(),i=kn(),a=Oe();return Tp(t.In,{children:bE(pe,{open:r.openMenu==="canvas",children:[Tp(pe.Trigger,{onToggle:()=>{a({openMenu:r.openMenu==="canvas"?null:"canvas",openPopup:null,openDialog:null})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:Wx}),bE(pe.Content,{onClickOutside:()=>a({openMenu:null}),onSelect:tG(n,()=>{a({openMenu:null})}),className:"main-menu",align:"start",children:[e,o.formFactor==="phone"&&r.collaborators.size>0&&bE("fieldset",{className:"UserList-Wrapper",children:[Tp("legend",{children:f("labels.collaborators")}),Tp(vp,{mobile:!0,collaborators:r.collaborators,userToFollow:i.userToFollow?.socketId||null,currentUserControls:i.currentUserControls})]})]})]})})}),{Trigger:pe.Trigger,Item:pe.Item,ItemLink:pe.ItemLink,ItemCustom:pe.ItemCustom,Group:pe.Group,Separator:pe.Separator,Sub:yr,DefaultItems:EE}),Ft=nG;import oG from"clsx";import{forwardRef as rG,useState as iG}from"react";import{isPromiseLike as aG}from"@excalidraw/common";import{jsx as Sp,jsxs as sG}from"react/jsx-runtime";var wr=rG(({children:e,icon:n,onClick:t,label:o,variant:r="filled",color:i="primary",size:a="medium",fullWidth:s,className:l,status:c,disabled:d},m)=>{let[p,u]=iG(!1),E=async b=>{let w=t?.(b);if(aG(w)){let y=window.setTimeout(()=>{u(!0)},50);try{await w}catch(x){if(x instanceof Pc)console.warn(x);else throw x}finally{clearTimeout(y),u(!1)}}},g=p?"loading":c;return i=g==="success"?"success":i,Sp("button",{className:oG("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${r}`,`ExcButton--size-${a}`,`ExcButton--status-${g}`,{"ExcButton--fullWidth":s},l),onClick:E,type:"button","aria-label":o,ref:m,disabled:d||g==="loading"||g==="success",children:sG("div",{className:"ExcButton__contents",children:[g==="loading"?Sp(xo,{className:"ExcButton__statusIcon"}):g==="success"&&Sp("div",{className:"ExcButton__statusIcon",children:J1}),n&&Sp("div",{className:"ExcButton__icon","aria-hidden":!0,children:n}),r!=="icon"&&(e??o)]})})});import{jsx as Qa,jsxs as dG}from"react/jsx-runtime";var Cp=({title:e,children:n,actionLabel:t,onClick:o})=>dG("div",{className:"OverwriteConfirm__Actions__Action",children:[Qa("h4",{children:e}),Qa("div",{className:"OverwriteConfirm__Actions__Action__content",children:n}),Qa(wr,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:o})]}),lG=()=>{let{t:e}=_e(),n=rt(),t=Oe();return Qa(Cp,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{n.executeAction(Qd,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},cG=()=>{let{t:e}=_e(),n=rt();return Qa(Cp,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{n.executeAction(rl,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},xE=Object.assign(({children:e})=>Qa("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:lG,SaveToDisk:cG});import{jsx as vr,jsxs as NC}from"react/jsx-runtime";var Pp=Object.assign(mi("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:n}=ot(),[t,o]=He(hE);if(!t.active)return null;let r=()=>{t.onClose(),o(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),o(a=>({...a,active:!1}))};return vr(n.In,{children:vr(wn,{onCloseRequest:r,title:!1,size:916,children:NC("div",{className:"OverwriteConfirm",children:[vr("h3",{children:t.title}),NC("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[vr("div",{className:"OverwriteConfirm__Description__icon",children:Q1}),vr("div",{children:t.description}),vr("div",{className:"OverwriteConfirm__Description__spacer"}),vr(wr,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),vr(xE,{children:e})]})})})}),{Actions:xE,Action:Cp});import{round as SP}from"@excalidraw/math";import kH from"clsx";import MH from"lodash.throttle";import{useEffect as CP,useMemo as _E,useState as AH,memo as DH}from"react";import{STATS_PANELS as Bp}from"@excalidraw/common";import{getCommonBounds as LH}from"@excalidraw/element";import{getUncroppedWidthAndHeight as _H}from"@excalidraw/element";import{isImageElement as RE}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as RH}from"@excalidraw/element";import{elementsAreInSameGroup as NH}from"@excalidraw/element";import{degreesToRadians as WC,radiansToDegrees as KC}from"@excalidraw/math";import{getBoundTextElement as VC}from"@excalidraw/element";import{isArrowElement as YC,isElbowArrow as TG}from"@excalidraw/element";import{updateBindings as XC}from"@excalidraw/element";import bG from"clsx";import{useEffect as HC,useRef as Mp,useState as xG}from"react";import{EVENT as ns,KEYS as yG,cloneJSON as yE}from"@excalidraw/common";import{deepCopyElement as wG}from"@excalidraw/element";import{CaptureUpdateAction as UC}from"@excalidraw/element";import{pointFrom as Ir,pointRotateRads as kp}from"@excalidraw/math";import{getBoundTextElement as mG,getNonDeletedElements as pG,isBindingElement as uG,unbindBindingElement as BC}from"@excalidraw/element";import{isFrameLikeElement as zC}from"@excalidraw/element";import{getSelectedGroupIds as hG,getElementsInGroup as gG,isInGroup as fG}from"@excalidraw/element";import{getFrameChildren as EG}from"@excalidraw/element";import{updateBindings as FC}from"@excalidraw/element";import{DRAGGING_THRESHOLD as OC}from"@excalidraw/common";var GC=.01,Ql=10,Vt=(e,n)=>!(n==="angle"&&zC(e)),We=(e,n)=>{let t=e+n/2;return t-t%n},es=(e,n,t)=>Object.keys(e).map(o=>({original:(t??n).get(o),latest:n.get(o)})).filter(o=>o.original!==void 0&&o.latest!==void 0);var pi=(e,n,t,o,r,i,a=!0)=>{if(uG(t)&&(t.startBinding||t.endBinding)){if(Math.abs(e-t.x)<OC&&Math.abs(n-t.y)<OC)return;BC(t,"start",o),BC(t,"end",o)}let s=o.getNonDeletedElementsMap(),l=s.get(t.id);if(!l)return;let[c,d]=[t.x+t.width/2,t.y+t.height/2],[m,p]=kp(Ir(t.x,t.y),Ir(c,d),t.angle),u=e-m,E=n-p,[g,b]=kp(Ir(e,n),Ir(c+u,d+E),-t.angle);o.mutateElement(l,{x:g,y:b},{informMutation:a,isDragging:!1}),FC(l,o,r);let w=mG(t,i);if(w){let y=s.get(w.id);y&&o.mutateElement(y,{x:w.x+u,y:w.y+E},{informMutation:a,isDragging:!1})}if(zC(t)){let y=EG(i,t.id);y.forEach(x=>{let I=s.get(x.id);if(!I)return;let[T,C]=[x.x+x.width/2,x.y+x.height/2],[P,M]=kp(Ir(x.x,x.y),Ir(T,C),x.angle),D=Math.round(P+u),_=Math.round(M+E),[k,L]=kp(Ir(D,_),Ir(T+u,C+E),-x.angle);o.mutateElement(I,{x:k,y:L},{informMutation:a,isDragging:!1}),FC(I,o,r,{simultaneouslyUpdated:pG(y)})})}},ts=(e,n)=>{let o=hG(n).map(r=>gG(e,r).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(r=>!fG(r)).forEach(r=>{o.push({[r.id]:!0})}),o};import{jsx as wE,jsxs as IG}from"react/jsx-runtime";var vG=({label:e,icon:n,dragInputCallback:t,value:o,elements:r,editable:i=!0,shouldKeepAspectRatio:a,property:s,scene:l,appState:c,sensitivity:d=1,dragFinishedCallback:m})=>{let p=St(),u=Oe(),E=Mp(null),g=Mp(null),[b,w]=xG(o.toString()),y=Mp(null);y.current||(y.current={originalAppState:yE(c),originalElements:r,lastUpdatedValue:b,updatePending:!1}),HC(()=>{let T=o.toString();w(T),y.current.lastUpdatedValue=T},[o]);let x=(T,C,P)=>{if(!y.current.updatePending)return!1;y.current.updatePending=!1;let M=Number(T);if(isNaN(M)){w(o.toString());return}let D=Number(M.toFixed(2)),_=Number(o);(isNaN(_)||Math.abs(D-_)>=GC)&&(y.current.lastUpdatedValue=T,t({accumulatedChange:0,instantChange:0,originalElements:C,originalElementsMap:p.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:l,nextValue:D,property:s,originalAppState:P,setInputValue:k=>w(String(k)),app:p,setAppState:u}),p.syncActionResult({captureUpdate:UC.IMMEDIATELY}))},I=Mp({});return I.current.handleInputValue=x,HC(()=>{let T=E.current,C=I.current;return()=>{let P=T?.value;P&&C.handleInputValue?.(P,y.current.originalElements,y.current.originalAppState),window.removeEventListener(ns.POINTER_MOVE,C.onPointerMove,!1),window.removeEventListener(ns.POINTER_UP,C.onPointerUp,!1)}},[i]),i?IG("div",{className:bG("drag-input-container",!i&&"disabled"),"data-testid":e,children:[wE("div",{className:"drag-input-label",ref:g,onPointerDown:T=>{if(E.current&&i){document.body.classList.add("excalidraw-cursor-resize");let C=Number(E.current.value);isNaN(C)&&(C=0);let P=null,M=p.scene.getNonDeletedElements().reduce((z,U)=>(z.set(U.id,wG(U)),z),new Map),D=r.map(z=>M.get(z.id)),_=yE(c),k=0,L=0,F=z=>{if(P&&M!==null&&D!==null){let U=z.clientX-P.x;U!==0&&(L+=U,Math.abs(L)>=d&&(L=Math.sign(L)*Math.floor(Math.abs(L)/d),k+=L,t({accumulatedChange:k,instantChange:L,originalElements:D,originalElementsMap:M,shouldKeepAspectRatio:a,shouldChangeByStepSize:z.shiftKey,property:s,scene:l,originalAppState:_,setInputValue:V=>w(String(V)),app:p,setAppState:u}),L=0))}P={x:z.clientX,y:z.clientY}},Y=()=>{window.removeEventListener(ns.POINTER_MOVE,F,!1),p.syncActionResult({captureUpdate:UC.IMMEDIATELY}),m?.({app:p,setAppState:u,originalElements:D,originalAppState:_}),P=null,k=0,L=0,D=null,M=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(ns.POINTER_UP,Y,!1)};I.current.onPointerMove=F,I.current.onPointerUp=Y,window.addEventListener(ns.POINTER_MOVE,F,!1),window.addEventListener(ns.POINTER_UP,Y,!1)}},onPointerEnter:()=>{g.current&&(g.current.style.cursor="ew-resize")},children:n?wE(xd,{icon:n}):e}),wE("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:T=>{if(i){let C=T.target;C instanceof HTMLInputElement&&T.key===yG.ENTER&&(x(C.value,r,c),p.focusContainer())}},ref:E,value:b,onChange:T=>{y.current.updatePending=!0,w(T.target.value)},onFocus:T=>{T.target.select(),y.current.originalElements=r,y.current.originalAppState=yE(c)},onBlur:T=>{b?i&&x(T.target.value,y.current.originalElements,y.current.originalAppState):w(o.toString())},disabled:!i})]}):null},gt=vG;import{jsx as kG}from"react/jsx-runtime";var SG=15,CG=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r,app:i})=>{let a=r.getNonDeletedElementsMap(),s=n[0];if(s&&!TG(s)){let l=a.get(s.id);if(!l)return;if(o!==void 0){let E=WC(o);r.mutateElement(l,{angle:E}),XC(l,r,i.state);let g=VC(l,a);g&&!YC(l)&&r.mutateElement(g,{angle:E});return}let c=Math.round(KC(s.angle)*100)/100,d=Math.round(e),m=(c+d)%360;t&&(m=We(m,SG)),m=m<0?m+360:m;let p=WC(m);r.mutateElement(l,{angle:p}),XC(l,r,i.state);let u=VC(l,a);u&&!YC(l)&&r.mutateElement(u,{angle:p})}},PG=({element:e,scene:n,appState:t,property:o})=>kG(gt,{label:"A",icon:Yc,value:Math.round(KC(e.angle)%360*100)/100,elements:[e],dragInputCallback:CG,editable:Vt(e,"angle"),scene:n,appState:t,property:o}),$C=PG;import{jsx as AG}from"react/jsx-runtime";var ZC=5,MG=({property:e,scene:n,appState:t,setAppState:o})=>AG(gt,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:r,instantChange:i,shouldChangeByStepSize:a,setInputValue:s})=>{o(l=>{let c;return r?c=r:i&&(c=a?We(l.gridStep+ZC*Math.sign(i),ZC):l.gridStep+i),c?(c=ox(c),s(c),{gridStep:c}):(s(l.gridStep),null)})},scene:n,value:t.gridStep,property:e,appState:t}),jC=MG;import{clamp as Ap,round as vE}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as Dp}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as qC,getNonDeletedElements as DG,getUncroppedWidthAndHeight as eP}from"@excalidraw/element";import{resizeSingleElement as JC}from"@excalidraw/element";import{isImageElement as tP}from"@excalidraw/element";import{isFrameLikeElement as IE}from"@excalidraw/element";import{getElementsInResizingFrame as TE}from"@excalidraw/element";import{replaceAllElementsInFrame as nP}from"@excalidraw/element";import{jsx as BG}from"react/jsx-runtime";var QC=10,LG=e=>e.type==="image",_G=({accumulatedChange:e,originalElements:n,originalElementsMap:t,shouldKeepAspectRatio:o,shouldChangeByStepSize:r,nextValue:i,property:a,originalAppState:s,instantChange:l,scene:c,app:d,setAppState:m})=>{let p=c.getNonDeletedElementsMap(),u=n[0],E=p.get(u.id);if(u&&E){let g=o||LG(u),b=u.width/u.height;if(s.croppingElementId===u.id){let w=p.get(u.id);if(!w||!tP(w)||!w.crop)return;let y=w.crop,x={...y},I=w.scale[0]===-1,T=w.scale[1]===-1,{width:C,height:P}=eP(w),M=y.naturalWidth/C,D=y.naturalHeight/P,_=I?y.width+y.x:y.naturalWidth-y.x,k=T?y.height+y.y:y.naturalHeight-y.y,L=qC*M,F=qC*D;if(i!==void 0){if(a==="width"){let G=i*M,re=Ap(G,L,_);x={...x,width:re,x:I?y.x+y.width-re:y.x}}else if(a==="height"){let G=i*D,re=Ap(G,F,k);x={...x,height:re,y:T?y.y+y.height-re:y.y}}c.mutateElement(w,{crop:x,width:x.width/(y.naturalWidth/C),height:x.height/(y.naturalHeight/P)});return}let Y=a==="width"?l:0,z=a==="height"?l:0,U=Ap(y.width+Y,L,_),V=Ap(y.height+z,L,k);x={...y,x:I?y.x+y.width-U:y.x,y:T?y.y+y.height-V:y.y,width:U,height:V},c.mutateElement(w,{crop:x,width:x.width/(y.naturalWidth/C),height:x.height/(y.naturalHeight/P)});return}if(i!==void 0){let w=Math.max(a==="width"?i:g?i*b:u.width,Dp),y=Math.max(a==="height"?i:g?i/b:u.height,Dp);if(JC(w,y,E,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),IE(E)){let x=TE(c.getElementsIncludingDeleted(),E,s,c.getNonDeletedElementsMap()),I=nP(c.getElementsIncludingDeleted(),x,E);c.replaceAllElements(I)}return}{let w=a==="width"?e:0,y=a==="height"?e:0,x=Math.max(0,u.width+w);a==="width"&&(r?x=We(x,QC):x=Math.round(x));let I=Math.max(0,u.height+y);if(a==="height"&&(r?I=We(I,QC):I=Math.round(I)),g&&(a==="width"?I=Math.round(x/b*100)/100:x=Math.round(I*b*100)/100),I=Math.max(Dp,I),x=Math.max(Dp,x),JC(x,I,E,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),IE(E)){let T=DG(TE(c.getElementsIncludingDeleted(),E,s,c.getNonDeletedElementsMap()));m({elementsToHighlight:T})}}}},RG=({setAppState:e,app:n,originalElements:t,originalAppState:o})=>{let r=n.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&IE(a)){let s=TE(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),l=nP(n.scene.getElementsIncludingDeleted(),s,a);n.scene.replaceAllElements(l),e({elementsToHighlight:null})}},NG=({property:e,element:n,scene:t,appState:o})=>{let r=vE(e==="width"?n.width:n.height,2);if(o.croppingElementId&&o.croppingElementId===n.id&&tP(n)&&n.crop){let{width:i,height:a}=eP(n);if(e==="width"){let s=i/n.crop.naturalWidth;r=vE(n.crop.width*s,2)}if(e==="height"){let s=a/n.crop.naturalHeight;r=vE(n.crop.height*s,2)}}return BG(gt,{label:e==="width"?"W":"H",elements:[n],dragInputCallback:_G,value:r,editable:Vt(n,e),scene:t,appState:o,property:e,dragFinishedCallback:RG})},SE=NG;import{getBoundTextElement as FG,redrawTextBoundingBox as OG}from"@excalidraw/element";import{hasBoundTextElement as zG,isTextElement as rP}from"@excalidraw/element";import{jsx as WG}from"react/jsx-runtime";var oP=4,GG=4,HG=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=n[0];if(a){let s=i.get(a.id);if(!s||!rP(s))return;let l;if(o!==void 0)l=Math.max(Math.round(o),oP);else if(a.type==="text"){let c=Math.round(a.fontSize),d=Math.round(e);l=Math.max(c+d,oP),t&&(l=We(l,GG))}l&&(r.mutateElement(s,{fontSize:l}),OG(s,r.getContainerElement(s),r))}},UG=({element:e,scene:n,appState:t,property:o})=>{let r=rP(e)?e:zG(e)?FG(e,n.getNonDeletedElementsMap()):null;return r?WG(gt,{label:"F",value:Math.round(r.fontSize*10)/10,elements:[r],dragInputCallback:HG,icon:zr,appState:t,scene:n,property:o}):null},iP=UG;import{degreesToRadians as aP,radiansToDegrees as cP}from"@excalidraw/math";import{getBoundTextElement as sP}from"@excalidraw/element";import{isArrowElement as lP}from"@excalidraw/element";import{isInGroup as CE}from"@excalidraw/element";import{jsx as KG}from"react/jsx-runtime";var VG=15,YG=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,property:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),s=n.map(c=>a.get(c.id)).filter(c=>c&&!CE(c)&&Vt(c,r)),l=n.filter(c=>!CE(c)&&Vt(c,r));if(o!==void 0){let c=aP(o);for(let d of s){if(!d)continue;i.mutateElement(d,{angle:c});let m=sP(d,a);m&&!lP(d)&&i.mutateElement(m,{angle:c})}i.triggerUpdate();return}for(let c=0;c<s.length;c++){let d=s[c];if(!d)continue;let m=l[c],p=Math.round(cP(m.angle)*100)/100,u=Math.round(e),E=(p+u)%360;t&&(E=We(E,VG)),E=E<0?E+360:E;let g=aP(E);i.mutateElement(d,{angle:g});let b=sP(d,a);b&&!lP(d)&&i.mutateElement(b,{angle:g})}i.triggerUpdate()},XG=({elements:e,scene:n,appState:t,property:o})=>{let r=e.filter(l=>!CE(l)&&Vt(l,"angle")),i=r.map(l=>Math.round(cP(l.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",s=r.some(l=>Vt(l,"angle"));return KG(gt,{label:"A",icon:Yc,value:a,elements:e,dragInputCallback:YG,editable:s,appState:t,scene:n,property:o})},dP=XG;import{pointFrom as hP}from"@excalidraw/math";import{useMemo as ZG}from"react";import{MIN_WIDTH_OR_HEIGHT as Tr}from"@excalidraw/common";import{getElementsInResizingFrame as PE,getNonDeletedElements as jG,isFrameLikeElement as kE,replaceAllElementsInFrame as EP,updateBoundElements as qG}from"@excalidraw/element";import{rescalePointsInElement as JG,resizeSingleElement as gP}from"@excalidraw/element";import{getBoundTextElement as QG,handleBindTextResize as eH}from"@excalidraw/element";import{isTextElement as bP}from"@excalidraw/element";import{MIME_TYPES as ui}from"@excalidraw/common";import{getNonDeletedElements as mP}from"@excalidraw/element";var Lp=({elements:e,appState:n,files:t,maxWidthOrHeight:o,getDimensions:r,exportPadding:i,exportingFrame:a})=>{let s=mP(Nr(e,null,{deleteInvisibleElements:!0})),l=ki(n,null),{exportBackground:c,viewBackgroundColor:d}=l;return Lc(s,{...l,offsetTop:0,offsetLeft:0,width:0,height:0},t||{},{exportBackground:c,exportPadding:i,viewBackgroundColor:d,exportingFrame:a},(m,p)=>{let u=document.createElement("canvas");if(o){typeof r=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let g=Math.max(m,p),b=o<g?o/g:n?.exportScale??1;return u.width=m*b,u.height=p*b,{canvas:u,scale:b}}let E=r?.(m,p)||{width:m,height:p};return u.width=E.width,u.height=E.height,{canvas:u,scale:E.scale??1}})},pP=async e=>{let{mimeType:n=ui.png,quality:t}=e;n===ui.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${ui.png}" mimeType`),n==="image/jpg"&&(n=ui.jpg),n===ui.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${ui.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let o=await Lp(e);return t=t||(/image\/jpe?g/.test(n)?.92:.8),new Promise((r,i)=>{o.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&n===ui.png&&e.appState?.exportEmbedScene&&(a=await gx({blob:a,metadata:xs(e.elements,e.appState,e.files||{},"local")})),r(a)},n,t)})},uP=async({elements:e,appState:n=Xo(),files:t={},exportPadding:o,renderEmbeddables:r,exportingFrame:i,skipInliningFonts:a,reuseImages:s})=>{let l=mP(Nr(e,null,{deleteInvisibleElements:!0})),d={...ki(n,null),exportPadding:o};return Rr(l,d,t,{exportingFrame:i,renderEmbeddables:r,skipInliningFonts:a,reuseImages:s})},$G=async e=>{if(e.type==="svg"){let n=await uP(e);await To(n.outerHTML)}else if(e.type==="png")await qd(pP(e));else if(e.type==="json")await $d(e.elements,e.files);else throw new Error("Invalid export type")};import{elementsOverlappingBBox as nNe}from"@excalidraw/element";import{getCommonBounds as _p}from"@excalidraw/element";import{jsx as aH}from"react/jsx-runtime";var os=10,tH=(e,n,t,o)=>{let r=o.x-e,i=o.y-n,a=o.width*t,s=o.height*t,l=e+r*t,c=n+i*t;return{width:a,height:s,x:l,y:c,...JG(o,a,s,!1),...bP(o)?{fontSize:o.fontSize*t}:{}}},nH=(e,n,t,o,r,i,a,s)=>{let l=s.getNonDeletedElementsMap(),c=tH(e,n,o,i);s.mutateElement(r,c);let d=QG(i,a);if(d){let m=d.fontSize*o;qG(r,s);let p=l.get(d.id);p&&bP(p)&&(s.mutateElement(p,{fontSize:m}),eH(r,s,t==="width"?"e":"s",!0))}},fP=(e,n,t,o,r,i,a,s,l,c)=>{i==="width"?n=Math.round(e/o*100)/100:e=Math.round(n*o*100)/100;let d=n/t;for(let m=0;m<s.length;m++){let p=s[m],u=a[m];nH(r[0],r[1],i,d,u,p,l,c)}},oH=({accumulatedChange:e,originalElements:n,originalElementsMap:t,originalAppState:o,shouldChangeByStepSize:r,nextValue:i,scene:a,property:s,setAppState:l,app:c})=>{let d=a.getNonDeletedElementsMap(),m=ts(n,o);if(i!==void 0){for(let g of m){let b=es(g,d,t);if(b.length>1){let w=b.map(L=>L.latest),y=b.map(L=>L.original),[x,I,T,C]=_p(y),P=T-x,M=C-I,D=P/M,_=Math.max(Tr,s==="width"?Math.max(0,i):P),k=Math.max(Tr,s==="height"?Math.max(0,i):M);fP(_,k,M,D,hP(x,I),s,w,y,t,a)}else{let[w]=b,y=w?.latest,x=w?.original;if(y&&x&&Vt(y,s)){let I=s==="width"?Math.max(0,i):y.width;s==="width"&&(r?I=We(I,os):I=Math.round(I));let T=s==="height"?Math.max(0,i):y.height;if(s==="height"&&(r?T=We(T,os):T=Math.round(T)),I=Math.max(Tr,I),T=Math.max(Tr,T),gP(I,T,y,x,t,a,s==="width"?"e":"s",{shouldInformMutation:!1}),kE(y)){let C=PE(a.getElementsIncludingDeleted(),y,o,a.getNonDeletedElementsMap()),P=EP(a.getElementsIncludingDeleted(),C,y);a.replaceAllElements(P)}}}}a.triggerUpdate();return}let p=s==="width"?e:0,u=s==="height"?e:0,E=[];for(let g of m){let b=es(g,d,t);if(b.length>1){let w=b.map(L=>L.latest),y=b.map(L=>L.original),[x,I,T,C]=_p(y),P=T-x,M=C-I,D=P/M,_=Math.max(0,P+p);s==="width"&&(r?_=We(_,os):_=Math.round(_));let k=Math.max(0,M+u);s==="height"&&(r?k=We(k,os):k=Math.round(k)),_=Math.max(Tr,_),k=Math.max(Tr,k),fP(_,k,M,D,hP(x,I),s,w,y,t,a)}else{let[w]=b,y=w?.latest,x=w?.original;if(y&&x&&Vt(y,s)){let I=Math.max(0,x.width+p);s==="width"&&(r?I=We(I,os):I=Math.round(I));let T=Math.max(0,x.height+u);if(s==="height"&&(r?T=We(T,os):T=Math.round(T)),I=Math.max(Tr,I),T=Math.max(Tr,T),gP(I,T,y,x,t,a,s==="width"?"e":"s",{shouldInformMutation:!1}),kE(y)){let C=jG(PE(a.getElementsIncludingDeleted(),y,o,a.getNonDeletedElementsMap()));E.push(...C)}}}}l({elementsToHighlight:E}),a.triggerUpdate()},rH=({setAppState:e,app:n,originalElements:t,originalAppState:o})=>{let r=n.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&kE(a)){let s=PE(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),l=EP(n.scene.getElementsIncludingDeleted(),s,a);n.scene.replaceAllElements(l),e({elementsToHighlight:null})}},iH=({property:e,elements:n,elementsMap:t,atomicUnits:o,scene:r,appState:i})=>{let a=ZG(()=>o.map(c=>{let d=es(c,t);if(d.length>1){let[p,u,E,g]=_p(d.map(b=>b.latest));return Math.round((e==="width"?E-p:g-u)*100)/100}let[m]=d;return Math.round((e==="width"?m.latest.width:m.latest.height)*100)/100}),[t,o,e]),s=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",l=a.length>0;return aH(gt,{label:e==="width"?"W":"H",elements:n,dragInputCallback:oH,value:s,editable:l,appState:i,property:e,scene:r,dragFinishedCallback:rH})},ME=iH;import{getBoundTextElement as sH,redrawTextBoundingBox as xP}from"@excalidraw/element";import{hasBoundTextElement as lH,isTextElement as cH}from"@excalidraw/element";import{isInGroup as dH}from"@excalidraw/element";import{jsx as gH}from"react/jsx-runtime";var yP=4,mH=4,pH=(e,n)=>e.reduce((t,o)=>{if(!o||dH(o))return t;if(cH(o))return t.push(o),t;if(lH(o)){let r=sH(o,n);if(r)return t.push(r),t}return t},[]),uH=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=n.map(l=>i.get(l.id)),s;if(o){s=Math.max(Math.round(o),yP);for(let l of a)r.mutateElement(l,{fontSize:s}),xP(l,r.getContainerElement(l),r);r.triggerUpdate()}else{let l=n;for(let c=0;c<a.length;c++){let d=a[c],m=l[c],p=Math.round(m.fontSize),u=Math.round(e),E=Math.max(p+u,yP);t&&(E=We(E,mH)),r.mutateElement(d,{fontSize:E}),xP(d,r.getContainerElement(d),r)}r.triggerUpdate()}},hH=({elements:e,scene:n,appState:t,property:o,elementsMap:r})=>{let i=pH(e,r);if(!i.length)return null;let a=i.map(c=>Math.round(c.fontSize*10)/10),s=new Set(a).size===1?a[0]:"Mixed",l=a.length>0;return gH(gt,{label:"F",icon:zr,elements:i,dragInputCallback:uH,value:s,editable:l,scene:n,property:o,appState:t})},wP=hH;import{pointFrom as Sr,pointRotateRads as Rp}from"@excalidraw/math";import{useMemo as fH}from"react";import{isTextElement as EH}from"@excalidraw/element";import{getCommonBounds as AE}from"@excalidraw/element";import{jsx as vH}from"react/jsx-runtime";var bH=(e,n,t,o,r,i,a)=>{for(let s=0;s<o.length;s++){let l=o[s],[c,d]=[l.x+l.width/2,l.y+l.height/2],[m,p]=Rp(Sr(l.x,l.y),Sr(c,d),l.angle),u=e==="x"?Math.round(m+n):m,E=e==="y"?Math.round(p+t):p;pi(u,E,l,i,a,r,!1)}},xH=(e,n,t,o,r,i)=>{let a=r.getNonDeletedElementsMap(),[s,l,,]=AE(t),c=e-s,d=n-l;for(let m=0;m<t.length;m++){let p=t[m],u=a.get(p.id);if(u&&(!EH(u)||!u.containerId)){let[E,g]=[u.x+u.width/2,u.y+u.height/2],[b,w]=Rp(Sr(u.x,u.y),Sr(E,g),u.angle);pi(b+c,w+d,p,r,i,o,!1)}}},yH=({accumulatedChange:e,originalElements:n,originalElementsMap:t,shouldChangeByStepSize:o,nextValue:r,property:i,scene:a,originalAppState:s,app:l})=>{let c=a.getNonDeletedElementsMap();if(r!==void 0){for(let u of ts(n,s)){let E=es(u,c,t);if(E.length>1){let[g,b,,]=AE(E.map(x=>x.latest));xH(i==="x"?r:g,i==="y"?r:b,E.map(x=>x.original),t,a,l.state)}else{let g=E[0]?.original,b=E[0]?.latest;if(g&&b&&Vt(b,i)){let[w,y]=[g.x+g.width/2,g.y+g.height/2],[x,I]=Rp(Sr(g.x,g.y),Sr(w,y),g.angle);pi(i==="x"?r:x,i==="y"?r:I,g,a,l.state,t,!1)}}}a.triggerUpdate();return}let d=o?We(e,Ql):e;bH(i,i==="x"?d:0,i==="y"?d:0,n,t,a,l.state),a.triggerUpdate()},wH=({property:e,elements:n,elementsMap:t,atomicUnits:o,scene:r,appState:i})=>{let a=fH(()=>o.map(l=>{let c=Object.keys(l).map(g=>t.get(g)).filter(g=>g!==void 0);if(c.length>1){let[g,b]=AE(c);return Math.round((e==="x"?g:b)*100)/100}let[d]=c,[m,p]=[d.x+d.width/2,d.y+d.height/2],[u,E]=Rp(Sr(d.x,d.y),Sr(m,p),d.angle);return Math.round((e==="x"?u:E)*100)/100}),[o,t,e]),s=new Set(a).size===1?a[0]:"Mixed";return vH(gt,{label:e==="x"?"X":"Y",elements:n,dragInputCallback:yH,value:s,property:e,scene:r,appState:i})},DE=wH;import{clamp as ec,pointFrom as Np,pointRotateRads as IP,round as vP}from"@excalidraw/math";import{getFlipAdjustedCropPosition as IH,getUncroppedWidthAndHeight as TH}from"@excalidraw/element";import{isImageElement as TP}from"@excalidraw/element";import{jsx as PH}from"react/jsx-runtime";var SH=({accumulatedChange:e,instantChange:n,originalElements:t,originalElementsMap:o,shouldChangeByStepSize:r,nextValue:i,property:a,scene:s,originalAppState:l,app:c})=>{let d=s.getNonDeletedElementsMap(),m=t[0],[p,u]=[m.x+m.width/2,m.y+m.height/2],[E,g]=IP(Np(m.x,m.y),Np(p,u),m.angle);if(l.croppingElementId===m.id){let I=d.get(m.id);if(!I||!TP(I)||!I.crop)return;let T=I.crop,C=T,P=I.scale[0]===-1,M=I.scale[1]===-1,{width:D,height:_}=TH(I);if(i!==void 0){if(a==="x"){let F=i*(T.naturalWidth/D);P?C={...T,x:ec(T.naturalWidth-F-T.width,0,T.naturalWidth-T.width)}:C={...T,x:ec(i*(T.naturalWidth/D),0,T.naturalWidth-T.width)}}a==="y"&&(C={...T,y:ec(i*(T.naturalHeight/_),0,T.naturalHeight-T.height)}),s.mutateElement(I,{crop:C});return}let k=(a==="x"?n:0)*(P?-1:1),L=(a==="y"?n:0)*(M?-1:1);C={...T,x:ec(T.x+k,0,T.naturalWidth-T.width),y:ec(T.y+L,0,T.naturalHeight-T.height)},s.mutateElement(I,{crop:C});return}if(i!==void 0){pi(a==="x"?i:E,a==="y"?i:g,m,s,c.state,o);return}let b=a==="x"?e:0,w=a==="y"?e:0,y=a==="x"?Math.round(r?We(m.x+b,Ql):E+b):E,x=a==="y"?Math.round(r?We(m.y+w,Ql):g+w):g;pi(y,x,m,s,c.state,o)},CH=({property:e,element:n,scene:t,appState:o})=>{let[r,i]=IP(Np(n.x,n.y),Np(n.x+n.width/2,n.y+n.height/2),n.angle),a=vP(e==="x"?r:i,2);if(o.croppingElementId===n.id&&TP(n)&&n.crop){let s=IH(n);s&&(a=vP(e==="x"?s.x:s.y,2))}return PH(gt,{label:e==="x"?"X":"Y",elements:[n],dragInputCallback:SH,scene:t,value:a,property:e,appState:o})},LE=CH;import{Fragment as NE,jsx as ne,jsxs as Yt}from"react/jsx-runtime";var BH=50,tc=e=>{let n=Qn(),t=e.app.scene.getSceneNonce()||1,o=e.app.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}),r=hr(e.app);return ne(FH,{...e,appState:n,sceneNonce:t,selectedElements:o,gridModeEnabled:r})},ze=({children:e,columns:n=1,heading:t,style:o,...r})=>ne("div",{className:kH("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${n}, 1fr)`,...o},...r,children:e});ze.displayName="StatsRow";var Fp=({children:e,order:n,style:t,...o})=>ne("div",{className:"exc-stats__rows",style:{order:n,...t},...o,children:e});Fp.displayName="StatsRows";tc.StatsRow=ze;tc.StatsRows=Fp;var FH=DH(({app:e,onClose:n,renderCustomStats:t,selectedElements:o,appState:r,sceneNonce:i,gridModeEnabled:a})=>{let s=e.scene,l=s.getNonDeletedElements(),c=s.getNonDeletedElementsMap(),d=Oe(),m=o.length===1?o[0]:null,p=o.length>1?o:null,u=r.croppingElementId&&RE(m),E=u?_H(m):null,[g,b]=AH({width:0,height:0}),w=_E(()=>MH(I=>{let T=LH(I);b({width:Math.round(T[2])-Math.round(T[0]),height:Math.round(T[3])-Math.round(T[1])})},BH),[]);CP(()=>{w(l)},[i,l,w]),CP(()=>()=>w.cancel(),[w]);let y=_E(()=>ts(o,r),[o,r]),x=_E(()=>RH(o),[o]);return ne("div",{className:"exc-stats",children:Yt(Ue,{padding:3,children:[Yt("div",{className:"title",children:[ne("h2",{children:f("stats.title")}),ne("div",{className:"close",onClick:n,children:an})]}),Yt(Vs,{label:ne("h3",{children:f("stats.generalStats")}),open:!!(r.stats.panels&Bp.generalStats),openTrigger:()=>d(I=>({stats:{open:!0,panels:I.stats.panels^Bp.generalStats}})),children:[Yt(Fp,{children:[ne(ze,{heading:!0,children:f("stats.scene")}),Yt(ze,{columns:2,children:[ne("div",{children:f("stats.shapes")}),ne("div",{children:l.length})]}),Yt(ze,{columns:2,children:[ne("div",{children:f("stats.width")}),ne("div",{children:g.width})]}),Yt(ze,{columns:2,children:[ne("div",{children:f("stats.height")}),ne("div",{children:g.height})]}),a&&Yt(NE,{children:[ne(ze,{heading:!0,children:"Canvas"}),ne(ze,{children:ne(jC,{property:"gridStep",scene:s,appState:r,setAppState:d})})]})]}),t?.(l,r)]}),!x&&o.length>0&&ne("div",{id:"elementStats",style:{marginTop:12},children:ne(Vs,{label:ne("h3",{children:f("stats.elementProperties")}),open:!!(r.stats.panels&Bp.elementProperties),openTrigger:()=>d(I=>({stats:{open:!0,panels:I.stats.panels^Bp.elementProperties}})),children:Yt(Fp,{children:[m&&Yt(NE,{children:[u&&ne(ze,{heading:!0,children:f("labels.unCroppedDimension")}),r.croppingElementId&&RE(m)&&E&&Yt(ze,{columns:2,children:[ne("div",{children:f("stats.width")}),ne("div",{children:SP(E.width,2)})]}),r.croppingElementId&&RE(m)&&E&&Yt(ze,{columns:2,children:[ne("div",{children:f("stats.height")}),ne("div",{children:SP(E.height,2)})]}),ne(ze,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:r.croppingElementId?f("labels.imageCropping"):m.type==="magicframe"?f("element.frame"):f(`element.${m.type}`)}),ne(ze,{children:ne(LE,{element:m,property:"x",elementsMap:c,scene:s,appState:r})}),ne(ze,{children:ne(LE,{element:m,property:"y",elementsMap:c,scene:s,appState:r})}),ne(ze,{children:ne(SE,{property:"width",element:m,scene:s,appState:r})}),ne(ze,{children:ne(SE,{property:"height",element:m,scene:s,appState:r})}),ne(ze,{children:ne($C,{property:"angle",element:m,scene:s,appState:r})}),ne(ze,{children:ne(iP,{property:"fontSize",element:m,scene:s,appState:r})})]}),p&&Yt(NE,{children:[NH(p)&&ne(ze,{heading:!0,children:f("element.group")}),Yt(ze,{columns:2,style:{margin:"0.3125rem 0"},children:[ne("div",{children:f("stats.shapes")}),ne("div",{children:o.length})]}),ne(ze,{children:ne(DE,{property:"x",elements:p,elementsMap:c,atomicUnits:y,scene:s,appState:r})}),ne(ze,{children:ne(DE,{property:"y",elements:p,elementsMap:c,atomicUnits:y,scene:s,appState:r})}),ne(ze,{children:ne(ME,{property:"width",elements:p,elementsMap:c,atomicUnits:y,scene:s,appState:r})}),ne(ze,{children:ne(ME,{property:"height",elements:p,elementsMap:c,atomicUnits:y,scene:s,appState:r})}),ne(ze,{children:ne(dP,{property:"angle",elements:p,scene:s,appState:r})}),ne(ze,{children:ne(wP,{property:"fontSize",elements:p,scene:s,appState:r,elementsMap:c})})]})]})})})]})})},(e,n)=>e.sceneNonce===n.sceneNonce&&e.selectedElements===n.selectedElements&&e.appState.stats.panels===n.appState.stats.panels&&e.gridModeEnabled===n.gridModeEnabled&&e.appState.gridStep===n.appState.gridStep&&e.appState.croppingElementId===n.appState.croppingElementId);import{useCallback as ZH,useEffect as kP,useState as MP}from"react";import{normalizeLink as jH,KEYS as zE}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as qH,getLinkIdAndTypeFromSelection as JH}from"@excalidraw/element";import OH from"clsx";import{jsx as Op,jsxs as GH}from"react/jsx-runtime";var zH=({label:e,onClick:n,className:t,children:o,actionType:r,type:i="button",isLoading:a,...s})=>{let l=r?`Dialog__action-button--${r}`:"";return GH("button",{className:OH("Dialog__action-button",l,t),type:i,"aria-label":e,onClick:n,...s,children:[o&&Op("div",{style:a?{visibility:"hidden"}:{},children:o}),Op("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&Op("div",{style:{position:"absolute",inset:0},children:Op(xo,{})})]})},BE=zH;import FE from"clsx";import{forwardRef as VH,useRef as YH,useImperativeHandle as XH,useLayoutEffect as KH,useState as $H}from"react";import HH from"clsx";import{composeEventHandlers as UH}from"@excalidraw/common";import{jsx as WH}from"react/jsx-runtime";var vn=({type:e="button",onSelect:n,selected:t,children:o,className:r="",...i})=>WH("button",{onClick:UH(i.onClick,a=>{n()}),type:e,className:HH("excalidraw-button",r,{selected:t}),...i,children:o});import{jsx as OE,jsxs as PP}from"react/jsx-runtime";var zp=VH(({onChange:e,label:n,fullWidth:t,placeholder:o,readonly:r,selectOnRender:i,onKeyDown:a,isRedacted:s=!1,icon:l,className:c,type:d,...m},p)=>{let u=YH(null);XH(p,()=>u.current),KH(()=>{i&&(u.current?.focus(),u.current?.select())},[i]);let[E,g]=$H(!1);return PP("div",{className:FE("ExcTextField",c,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!l}),onClick:()=>{u.current?.focus()},children:[l,n&&OE("div",{className:"ExcTextField__label",children:n}),PP("div",{className:FE("ExcTextField__input",{"ExcTextField__input--readonly":r}),children:[OE("input",{className:FE({"is-redacted":"value"in m&&m.value&&s&&!E}),readOnly:r,value:"value"in m?m.value:void 0,defaultValue:"defaultValue"in m?m.defaultValue:void 0,placeholder:o,ref:u,onChange:b=>e?.(b.target.value),onKeyDown:a,type:d}),s&&OE(vn,{onSelect:()=>g(!E),style:{border:0,userSelect:"none"},children:E?e0:Hr})]})]})});import{jsx as rs,jsxs as Gp}from"react/jsx-runtime";var QH=({sourceElementId:e,onClose:n,appState:t,scene:o,generateLinkForSelection:r=qH})=>{let i=o.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[s,l]=MP(a),[c,d]=MP(!1);kP(()=>{let p=ce(i,t),u=a;if(p.length>0&&r){let E=JH(p,t);E&&(u=jH(r(E.id,E.type)))}l(u)},[i,t,t.selectedElementIds,a,r]);let m=ZH(()=>{if(s&&s!==i.get(e)?.link){let p=i.get(e);p&&o.mutateElement(p,{link:s})}if(!s&&c&&e){let p=i.get(e);p&&o.mutateElement(p,{link:null})}n?.()},[e,s,i,c,o,n]);return kP(()=>{let p=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===zE.ENTER&&m(),t.openDialog?.name==="elementLinkSelector"&&u.key===zE.ESCAPE&&n?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[t,n,m]),Gp("div",{className:"ElementLinkDialog",children:[Gp("div",{className:"ElementLinkDialog__header",children:[rs("h2",{children:f("elementLink.title")}),rs("p",{children:f("elementLink.desc")})]}),Gp("div",{className:"ElementLinkDialog__input",children:[rs(zp,{value:s??"",onChange:p=>{c||d(!0),l(p)},onKeyDown:p=>{p.key===zE.ENTER&&m()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&s&&rs(Z,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:()=>{l(null),d(!0)},className:"ElementLinkDialog__remove",icon:Or})]}),Gp("div",{className:"ElementLinkDialog__actions",children:[rs(BE,{label:f("buttons.cancel"),onClick:()=>{n?.()},style:{marginRight:10}}),rs(BE,{label:f("buttons.confirm"),onClick:m,actionType:"primary"})]})]})},AP=QH;import eU,{useState as tU}from"react";import{Fragment as nU,jsx as GE}from"react/jsx-runtime";var DP=({children:e,onClose:n})=>{let[t,o]=tU(!!e),{container:r}=Ne(),i=eU.useCallback(()=>{o(!1),n&&n(),r?.focus()},[n,r]);return GE(nU,{children:t&&GE(wn,{size:"small",onCloseRequest:i,title:f("errorDialog.title"),children:GE("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import HE from"clsx";import Fn from"react";import{MIME_TYPES as LP,sceneCoordsToViewportCoords as UE}from"@excalidraw/common";import{getCommonBounds as BP,isInitializedImageElement as _P,ShapeCache as oU}from"@excalidraw/element";import{Fragment as lU,jsx as kt,jsxs as hi}from"react/jsx-runtime";var rU=kt("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:kt("path",{d:"M8 5v14l11 -7z"})}),iU=hi("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[kt("path",{d:"M8 5v14"}),kt("path",{d:"M16 5v14"})]}),aU=76,FP=4,nc=aU+FP,RP=8,gi=8,sU=(e,n)=>{let t=n/2;return Math.min(Math.max(e,t+gi),window.innerWidth-t-gi)},NP=(e,n)=>{let[,,t,o]=BP([e]),r=UE({sceneX:t,sceneY:o},n);return{left:Math.min(Math.max(r.x-n.offsetLeft,8),n.width-8),top:Math.min(Math.max(r.y-n.offsetTop,8),n.height-8)}},OP=({app:e,files:n,setAppState:t})=>{let o=Qn(),[,r]=Fn.useReducer(T=>T+1,0),[i,a]=Fn.useState(0),[s,l]=Fn.useState(!1),c=Fn.useRef(null),d=Fn.useRef(null),m=Fn.useRef(null),p=Fn.useRef(null),u=Fn.useRef(null),E=Fn.useRef(!1),[g,b]=Fn.useState(null);Fn.useLayoutEffect(()=>{let T=o.openPopup;if(T!=="gifSpeedPicker"&&T!=="gifFrameGallery"){g!==null&&b(null);return}let C=T==="gifSpeedPicker"?c.current:d.current,P=T==="gifSpeedPicker"?m.current:p.current;if(!C||!P)return;let M=C.getBoundingClientRect(),D=P.getBoundingClientRect(),_=sU(M.left+M.width/2,D.width),k=T==="gifSpeedPicker"?Math.max(gi,M.top-D.height-gi):Math.min(window.innerHeight-D.height-gi,M.bottom+gi),L={left:_,top:Math.max(gi,k)};b(F=>F?.left===L.left&&F.top===L.top?F:L)},[i,g,o.openPopup,o.scrollX,o.scrollY,o.zoom.value]);let w=(T,C)=>{oU.delete(T),e.scene.mutateElement(T,{gifPlayback:C}),e.scheduleUpdate(),t({}),r(),C.playing&&e.ensureGifPlaybackLoop()},y=e.scene.getNonDeletedElements().filter(T=>_P(T)&&!o.selectedElementIds[T.id]&&n[T.fileId]?.mimeType===LP.gif&&e.imageCache.get(T.fileId)?.gifDecodeStatus==="deferred").map(T=>{let C=NP(T,o);return kt("span",{className:"gif-playback-controls gif-playback-controls__deferred-badge",role:"img","aria-label":"GIF paused",style:C,children:_x},T.id)}),x=e.scene.getSelectedElements(o);return hi(lU,{children:[y,(()=>{if(x.length!==1)return null;let T=x[0];if(!_P(T)||n[T.fileId]?.mimeType!==LP.gif)return null;let C=e.imageCache.get(T.fileId),P=C?.gif,[M,,D,_]=BP([T]),k=UE({sceneX:M,sceneY:_},o),F=UE({sceneX:D,sceneY:_},o).x-k.x,Y=k.x-o.offsetLeft+F/2,z=Math.max(12,Math.min(o.height-86,k.y-o.offsetTop+16));if(C?.gifDecodeStatus==="deferred"){let K=NP(T,o);return kt("div",{className:"gif-playback-controls gif-playback-controls--deferred",style:K,onPointerDown:Ie=>Ie.stopPropagation(),children:kt("button",{type:"button",className:"gif-playback-controls__load-large",title:"Load Large GIF",onClick:()=>{e.loadDeferredGif(T.fileId)},children:"Load Large GIF"})})}if(C?.gifDecodeStatus==="pending")return null;let U=P?.frames.length??0;if(!P||U<2)return null;let V=T.gifPlayback??{frameIndex:0,speed:1,playing:!1},G=e.state,re=e.getGifPlaybackFrameIndex(T)??V.frameIndex,B=Math.min(Math.max(re,0),U-1),W=Math.min(G.height-120,z+48),ue=Math.max(12,z-52),Ee=K=>{let Ie=(K+U)%U;e.setGifPlaybackFrameIndex(T,Ie),w(T,{...V,frameIndex:Ie,playing:!1})},le=K=>{K.stopPropagation(),Ee(B+(K.deltaY<0?1:-1))},he=K=>{e.setGifPlaybackFrameIndex(T,B),w(T,{...V,frameIndex:B,playing:K})},ge=[.25,.5,.75,1,1.25,1.5,1.75,2,4],se=K=>{let Ie=ge.indexOf(K);return Ie!==-1?Ie:ge.reduce((At,fs,Cc)=>Math.abs(fs-K)<Math.abs(ge[At]-K)?Cc:At,0)},xe=K=>{w(T,{...V,speed:K})},it=K=>{let Ie=se(V.speed);xe(ge[Math.min(Math.max(Ie+K,0),ge.length-1)])},$e=Number.isInteger(V.speed)?`${V.speed}`:`${V.speed}`,ke=U*nc-FP,Zt=Math.min(Math.max(G.width*.9,1),ke),Ho=Math.max(ke-Zt,0),Uo=Math.min(i,Ho),Wo=Math.max(Math.floor(Uo/nc)-RP,0),Ii=Math.ceil(Zt/nc)+RP*2,gs=Math.min(Wo+Ii,U),ho=P.frames.slice(Wo,gs),on=K=>{K.pointerType!=="mouse"||K.button!==0||(u.current={pointerId:K.pointerId,startClientX:K.clientX,startScrollLeft:K.currentTarget.scrollLeft,didDrag:!1},K.stopPropagation())},Vo=K=>{let Ie=u.current;if(!Ie||Ie.pointerId!==K.pointerId)return;let At=K.clientX-Ie.startClientX;!Ie.didDrag&&Math.abs(At)<=3||(Ie.didDrag||(Ie.didDrag=!0,K.currentTarget.setPointerCapture?.(K.pointerId),l(!0)),K.currentTarget.scrollLeft=Ie.startScrollLeft-At,a(K.currentTarget.scrollLeft),K.preventDefault(),K.stopPropagation())},Eu=K=>{let Ie=u.current;!Ie||Ie.pointerId!==K.pointerId||(E.current=Ie.didDrag,u.current=null,K.currentTarget.hasPointerCapture?.(K.pointerId)&&K.currentTarget.releasePointerCapture(K.pointerId),l(!1),K.stopPropagation())},Ti=K=>{let Ie=u.current;!Ie||Ie.pointerId!==K.pointerId||(u.current=null,l(!1),K.stopPropagation())},go=K=>{K.pointerType!=="mouse"&&K.stopPropagation()};return hi("div",{className:"gif-playback-controls",style:{left:Y,top:z},onPointerDown:K=>K.stopPropagation(),children:[o.openPopup==="gifSpeedPicker"&&kt("div",{className:"gif-speed-picker",ref:m,style:g??{left:Y,top:ue},children:ge.map(K=>{let Ie=Number.isInteger(K)?`${K}`:`${K}`;return hi("button",{type:"button",className:HE("gif-speed-picker__speed",{"gif-speed-picker__speed--selected":K===V.speed}),onClick:()=>xe(K),title:`${Ie}x`,children:["x",Ie]},K)})}),hi("div",{className:"gif-playback-controls__bar",children:[hi("button",{type:"button",className:"gif-playback-controls__button gif-playback-controls__button--speed",ref:c,onClick:()=>t({openPopup:o.openPopup==="gifSpeedPicker"?null:"gifSpeedPicker"}),onWheel:K=>{K.stopPropagation(),it(K.deltaY<0?1:-1)},title:"Speed",children:["x",$e]}),kt("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>Ee(B-1),onWheel:le,title:"Previous frame",children:Z1}),kt("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>he(!V.playing),onWheel:le,title:V.playing?"Pause":"Play",children:V.playing?iU:rU}),kt("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>Ee(B+1),onWheel:le,title:"Next frame",children:j1}),kt("button",{type:"button",className:"gif-playback-controls__button gif-playback-controls__button--frames",ref:d,onClick:()=>{o.openPopup!=="gifFrameGallery"&&a(Math.max(B*nc-Zt/2,0)),t({openPopup:o.openPopup==="gifFrameGallery"?null:"gifFrameGallery"})},onWheel:le,title:"Frames",children:q1})]}),o.openPopup==="gifFrameGallery"&&kt("div",{className:HE("gif-frame-gallery",{"gif-frame-gallery--dragging":s}),style:{...g??{left:Y,top:W},width:Zt},ref:K=>{p.current=K,K&&K.scrollLeft!==Uo&&(K.scrollLeft=Uo)},onScroll:K=>{a(K.currentTarget.scrollLeft)},onPointerDownCapture:go,onPointerMoveCapture:go,onPointerUpCapture:go,onPointerCancelCapture:go,onPointerDown:on,onPointerMove:Vo,onPointerUp:Eu,onPointerCancel:Ti,onLostPointerCapture:Ti,onClickCapture:K=>{if(E.current){E.current=!1,K.preventDefault(),K.stopPropagation();return}E.current=!1},onWheelCapture:K=>{K.stopPropagation(),K.currentTarget.scrollLeft+=K.deltaY,a(K.currentTarget.scrollLeft)},children:kt("div",{className:"gif-frame-gallery__spacer",style:{width:ke},children:ho.map((K,Ie)=>{let At=Wo+Ie;return hi("button",{type:"button",className:HE("gif-frame-gallery__frame",{"gif-frame-gallery__frame--selected":At===B}),style:{left:At*nc},onClick:()=>Ee(At),title:`Frame ${At+1}`,children:[kt("canvas",{width:K.width,height:K.height,ref:fs=>{fs?.getContext("2d")?.drawImage(K,0,0)}}),kt("span",{children:At+1})]},At)})})})]})})()]})};import zP,{useMemo as fU}from"react";import GP from"clsx";import{isDarwin as HP,isFirefox as EU,isWindows as bU}from"@excalidraw/common";import{KEYS as is}from"@excalidraw/common";import{SHAPES as xU}from"@excalidraw/element/shapes";import{isFirefox as cU,KEYS as WE}from"@excalidraw/common";import{SHAPES as dU}from"@excalidraw/element/shapes";import{Fragment as gU,jsx as Ve,jsxs as fi}from"react/jsx-runtime";var mU=e=>fi(gU,{children:[Ve("h3",{children:e.title}),Ve("div",{className:"HelpDialog__islands-container",children:e.children})]}),VE=e=>fi("div",{className:`HelpDialog__island ${e.className}`,children:[Ve("h4",{className:"HelpDialog__island-title",children:e.caption}),Ve("div",{className:"HelpDialog__island-content",children:e.children})]});function*pU(e,n){let t=!0;for(let o of e)t||(yield n),t=!1,yield o}var uU=e=>e.replace(/\b[a-z]\b/,n=>n.toUpperCase()),It=({label:e,shortcuts:n,isOr:t=!0})=>{let o=n.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>Ve(hU,{children:uU(a)},a)));return fi("div",{className:"HelpDialog__shortcut",children:[Ve("div",{children:e}),Ve("div",{className:"HelpDialog__key-container",children:[...pU(o,t?f("helpDialog.or"):null)]})]})},hU=e=>Ve("kbd",{className:"HelpDialog__key",...e});function YE(){return fi(mU,{title:f("helpDialog.shortcuts"),children:[fi(VE,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[Ve(It,{label:f("toolBar.hand"),shortcuts:[WE.H]}),dU.filter(({myocSimplifiedMode:e})=>e).map(({value:e,key:n})=>Ve(It,{label:f(`toolBar.${e}`),shortcuts:[...n]},e)),Ve(It,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),Ve(It,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0})]}),fi(VE,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[Ve(It,{label:f("helpDialog.smartZoom"),shortcuts:[WE.F]}),Ve(It,{label:f("helpDialog.dragToZoom"),shortcuts:[`${WE.Z}+${f("helpDialog.drag")}`]}),Ve(It,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]})]}),fi(VE,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[Ve(It,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),Ve(It,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),Ve(It,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),Ve(It,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(lr||cU)&&Ve(It,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),Ve(It,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),Ve(It,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),Ve(It,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),Ve(It,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),Ve(It,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]})]})]})}import{Fragment as WP,jsx as j,jsxs as Ei}from"react/jsx-runtime";var yU=e=>Ei(WP,{children:[j("h3",{children:e.title}),j("div",{className:"HelpDialog__islands-container",children:e.children})]}),XE=e=>Ei("div",{className:`HelpDialog__island ${e.className}`,children:[j("h4",{className:"HelpDialog__island-title",children:e.caption}),j("div",{className:"HelpDialog__island-content",children:e.children})]});function*wU(e,n){let t=!0;for(let o of e)t||(yield n),t=!1,yield o}var vU=e=>e.replace(/\b[a-z]\b/,n=>n.toUpperCase()),J=({label:e,shortcuts:n,isOr:t=!0})=>{let o=n.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>j(IU,{children:vU(a)},a)));return Ei("div",{className:"HelpDialog__shortcut",children:[j("div",{children:e}),j("div",{className:"HelpDialog__key-container",children:[...wU(o,t?f("helpDialog.or"):null)]})]})},IU=e=>j("kbd",{className:"HelpDialog__key",...e}),UP=({onClose:e})=>{let[n,t]=zP.useState(!1),o=zP.useCallback(()=>{e&&e()},[e]),r=fU(()=>n?j("button",{className:GP("toggle-button",{}),onClick:()=>t(!1),children:f("helpDialog.myoc.showingAll")}):j("button",{className:GP("toggle-button",{}),onClick:()=>t(!0),children:f("helpDialog.myoc.showingBasic")}),[n]);return j(WP,{children:j(wn,{onCloseRequest:o,title:f("helpDialog.title"),className:"HelpDialog",titleButton:r,portalContainerClassName:"HelpDialog__modalContainer",children:n?Ei(yU,{title:f("helpDialog.shortcuts"),children:[Ei(XE,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[j(J,{label:f("toolBar.hand"),shortcuts:[is.H]}),xU.map(({value:i,key:a})=>j(J,{label:f(`toolBar.${i}`),shortcuts:[...a]},i)),j(J,{label:f("toolBar.frame"),shortcuts:[is.F]}),j(J,{label:f("labels.eyeDropper"),shortcuts:[is.I,"Shift+S","Shift+I"]}),j(J,{label:f("helpDialog.editLineArrowPoints"),shortcuts:[N("CtrlOrCmd+Enter")]}),j(J,{label:f("helpDialog.editText"),shortcuts:[N("Enter")]}),j(J,{label:f("helpDialog.textNewLine"),shortcuts:[N("Enter"),N("Shift+Enter")]}),j(J,{label:f("helpDialog.textFinish"),shortcuts:[N("Esc"),N("CtrlOrCmd+Enter")]}),j(J,{label:f("helpDialog.curvedArrow"),shortcuts:["A",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),j(J,{label:f("helpDialog.curvedLine"),shortcuts:["L",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),j(J,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),j(J,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0}),j(J,{label:f("toolBar.lock"),shortcuts:[is.Q]}),j(J,{label:f("helpDialog.preventBinding"),shortcuts:[N("CtrlOrCmd")]}),j(J,{label:f("toolBar.link"),shortcuts:[N("CtrlOrCmd+K")]}),j(J,{label:f("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),Ei(XE,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[j(J,{label:f("helpDialog.smartZoom"),shortcuts:[is.F]}),j(J,{label:f("helpDialog.dragToZoom"),shortcuts:[`${is.Z}+${f("helpDialog.drag")}`]}),j(J,{label:f("buttons.zoomIn"),shortcuts:[N("CtrlOrCmd++")]}),j(J,{label:f("buttons.zoomOut"),shortcuts:[N("CtrlOrCmd+-")]}),j(J,{label:f("buttons.resetZoom"),shortcuts:[N("CtrlOrCmd+0")]}),j(J,{label:f("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),j(J,{label:f("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),j(J,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]}),j(J,{label:f("labels.toggleGrid"),shortcuts:[N("CtrlOrCmd+'")]}),j(J,{label:f("labels.viewMode"),shortcuts:[N("Alt+R")]}),j(J,{label:f("stats.fullTitle"),shortcuts:[N("Alt+/")]}),j(J,{label:f("search.title"),shortcuts:[je("searchMenu")]})]}),Ei(XE,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[j(J,{label:f("labels.moveCanvas"),shortcuts:[N(`Space+${f("helpDialog.drag")}`),N(`Wheel+${f("helpDialog.drag")}`)],isOr:!0}),j(J,{label:f("labels.delete"),shortcuts:[N("Delete")]}),j(J,{label:f("labels.cut"),shortcuts:[N("CtrlOrCmd+X")]}),j(J,{label:f("labels.copy"),shortcuts:[N("CtrlOrCmd+C")]}),j(J,{label:f("labels.paste"),shortcuts:[N("CtrlOrCmd+V")]}),j(J,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),j(J,{label:f("labels.selectAll"),shortcuts:[N("CtrlOrCmd+A")]}),j(J,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),j(J,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),j(J,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(lr||EU)&&j(J,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),j(J,{label:f("labels.sendToBack"),shortcuts:[HP?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")]}),j(J,{label:f("labels.bringToFront"),shortcuts:[HP?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")]}),j(J,{label:f("labels.sendBackward"),shortcuts:[N("CtrlOrCmd+[")]}),j(J,{label:f("labels.bringForward"),shortcuts:[N("CtrlOrCmd+]")]}),j(J,{label:f("labels.alignTop"),shortcuts:[N("CtrlOrCmd+Shift+Up")]}),j(J,{label:f("labels.alignBottom"),shortcuts:[N("CtrlOrCmd+Shift+Down")]}),j(J,{label:f("labels.alignLeft"),shortcuts:[N("CtrlOrCmd+Shift+Left")]}),j(J,{label:f("labels.alignRight"),shortcuts:[N("CtrlOrCmd+Shift+Right")]}),j(J,{label:f("labels.arrangeElements"),shortcuts:[N("Shift+R")]}),j(J,{label:f("labels.duplicateSelection"),shortcuts:[N("CtrlOrCmd+D"),N(`Alt+${f("helpDialog.drag")}`)]}),j(J,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),j(J,{label:f("buttons.undo"),shortcuts:[N("CtrlOrCmd+Z")]}),j(J,{label:f("buttons.redo"),shortcuts:bU?[N("CtrlOrCmd+Y"),N("CtrlOrCmd+Shift+Z")]:[N("CtrlOrCmd+Shift+Z")]}),j(J,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),j(J,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),j(J,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),j(J,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]}),j(J,{label:f("labels.showStroke"),shortcuts:[N("S")]}),j(J,{label:f("labels.showBackground"),shortcuts:[N("G")]}),j(J,{label:f("labels.showFonts"),shortcuts:[N("Shift+F")]}),j(J,{label:f("labels.decreaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+<")]}),j(J,{label:f("labels.increaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+>")]})]})]}):j(YE,{})})})};import{useEffect as XP,useRef as KP,useState as bi}from"react";import{DEFAULT_EXPORT_PADDING as MU,EXPORT_IMAGE_TYPES as KE,isFirefox as AU,EXPORT_SCALES as DU,cloneJSON as $P}from"@excalidraw/common";import{useCallback as TU,useRef as SU,useState as CU}from"react";var PU=2e3,VP=()=>{let[e,n]=CU(null),t=SU(0),o=()=>{clearTimeout(t.current),n("success"),t.current=window.setTimeout(()=>{n(null)},PU)},r=TU(()=>{n(null)},[]);return{copyStatus:e,resetCopyStatus:r,onCopy:o}};import kU from"clsx";import{jsx as YP}from"react/jsx-runtime";var oc=({title:e,name:n,checked:t,onChange:o,disabled:r=!1})=>YP("div",{className:kU("Switch",{toggled:t,disabled:r}),children:YP("input",{name:n,id:n,title:e,type:"checkbox",checked:t,disabled:r,onChange:()=>o(!t),onKeyDown:i=>{i.key===" "&&o(!t)}})});import{jsx as Ge,jsxs as Cr}from"react/jsx-runtime";var LU=()=>Cr("div",{children:[Ge("h3",{children:f("canvasError.cannotShowPreview")}),Ge("p",{children:Ge("span",{children:f("canvasError.canvasTooBig")})}),Cr("em",{children:["(",f("canvasError.canvasTooBigTip"),")"]})]}),_U=({appStateSnapshot:e,elementsSnapshot:n,files:t,actionManager:o,onExportImage:r,name:i,exportWithDarkMode:a})=>{let s=Le(n,e),[l,c]=bi(i),[d,m]=bi(s),[p,u]=bi(e.exportBackground),[E,g]=bi(e.exportEmbedScene),[b,w]=bi(e.exportScale),y=KP(null),x=KP(0),[I,T]=bi(null),{onCopy:C,copyStatus:P,resetCopyStatus:M}=VP();XP(()=>{M()},[l,p,a,b,E,M]);let{exportedElements:D,exportingFrame:_}=$r(n,e,d);return XP(()=>{let k=y.current;if(!k)return;let L=k.offsetWidth,F=k.offsetHeight;if(!L)return;let Y=++x.current,z=()=>Y!==x.current;return Lp({elements:D,appState:{...e,name:l,exportBackground:p,exportWithDarkMode:a,exportScale:b,exportEmbedScene:E},files:t,exportPadding:MU,maxWidthOrHeight:Math.max(L,F),exportingFrame:_}).then(async U=>{if(!z()){try{await Is(U)}catch(V){throw V.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):V}z()||(T(null),k.replaceChildren(U))}}).catch(U=>{z()||(console.error(U),T(U))}),()=>{x.current+=1}},[e,t,D,_,l,p,a,b,E]),Cr("div",{className:"ImageExportModal",children:[Ge("h3",{children:f("imageExportDialog.header")}),Cr("div",{className:"ImageExportModal__preview",children:[Ge("div",{className:"ImageExportModal__preview__canvas",ref:y,children:I&&Ge(LU,{})}),Ge("div",{className:"ImageExportModal__preview__filename",children:!Pi&&Ge("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:k=>{c(k.target.value),o.executeAction(eg,"ui",k.target.value)}})})]}),Cr("div",{className:"ImageExportModal__settings",children:[Ge("h3",{children:f("imageExportDialog.header")}),s&&Ge(rc,{label:f("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Ge(oc,{name:"exportOnlySelected",checked:d,onChange:k=>{m(k)}})}),Ge(rc,{label:f("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Ge(oc,{name:"exportBackgroundSwitch",checked:p,onChange:k=>{u(k),o.executeAction(tg,"ui",k)}})}),Ge(rc,{label:f("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Ge(oc,{name:"exportDarkModeSwitch",checked:a,onChange:k=>{o.executeAction(Sw,"ui",k)}})}),Ge(rc,{label:f("imageExportDialog.label.embedScene"),tooltip:f("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Ge(oc,{name:"exportEmbedSwitch",checked:E,onChange:k=>{g(k),o.executeAction(Qd,"ui",k)}})}),Ge(rc,{label:f("imageExportDialog.label.scale"),name:"exportScale",children:Ge(Ip,{name:"exportScale",value:b,onChange:k=>{w(k),o.executeAction(Iw,"ui",k)},choices:DU.map(k=>({value:k,label:`${k}\xD7`}))})}),Cr("div",{className:"ImageExportModal__settings__buttons",children:[Ge(wr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToPng"),onClick:()=>r(KE.png,D,{exportingFrame:_}),icon:Zu,children:f("imageExportDialog.button.exportToPng")}),Ge(wr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToSvg"),onClick:()=>r(KE.svg,D,{exportingFrame:_}),icon:Zu,children:f("imageExportDialog.button.exportToSvg")}),(lr||AU)&&Ge(wr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.copyPngToClipboard"),status:P,onClick:async()=>{await r(KE.clipboard,D,{exportingFrame:_}),C()},icon:X1,children:f("imageExportDialog.button.copyPngToClipboard")})]})]})]})},rc=({label:e,children:n,tooltip:t,name:o})=>Cr("div",{className:"ImageExportModal__settings__setting",title:e,children:[Cr("label",{htmlFor:o,className:"ImageExportModal__settings__setting__label",children:[e,t&&Ge(pt,{label:t,long:!0,children:$1})]}),Ge("div",{className:"ImageExportModal__settings__setting__content",children:n})]}),ZP=({elements:e,appState:n,files:t,actionManager:o,onExportImage:r,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:s,elementsSnapshot:l}]=bi(()=>({appStateSnapshot:$P(n),elementsSnapshot:$P(e)}));return Ge(wn,{onCloseRequest:i,size:"wide",title:!1,children:Ge(_U,{elementsSnapshot:l,appStateSnapshot:s,files:t,actionManager:o,onExportImage:r,name:a,exportWithDarkMode:n.exportWithDarkMode})})};import wW from"clsx";import{CANVAS_SEARCH_TAB as hk,DEFAULT_SIDEBAR as vW}from"@excalidraw/common";import RU from"clsx";import NU from"lodash.debounce";import{Fragment as BU,memo as FU,useEffect as ic,useMemo as jP,useRef as $E,useState as qP}from"react";import{CLASSES as OU,EVENT as zU,FONT_FAMILY as ZE,FRAME_STYLE as jE,getLineHeight as GU}from"@excalidraw/common";import{getCommonBounds as HU,isElementCompletelyInViewport as UU}from"@excalidraw/element";import{measureText as ac}from"@excalidraw/element";import{KEYS as as,randomInteger as JP,addEventListener as WU,getFontString as Hp}from"@excalidraw/common";import{newTextElement as VU}from"@excalidraw/element";import{isTextElement as nk,isFrameLikeElement as Up}from"@excalidraw/element";import{getDefaultFrameName as ok}from"@excalidraw/element/frame";import{Fragment as eW,jsx as ft,jsxs as On}from"react/jsx-runtime";var YU=Qe(""),qE=Qe(null),XU=350,rk=()=>{let e=St(),n=Oe(),t=$E(null),[o,r]=He(YU),i=o.trim(),[a,s]=qP(!1),[l,c]=qP({nonce:null,items:[]}),d=$E(null),m=$E(void 0),[p,u]=He(qE),E=e.scene.getNonDeletedElementsMap();ic(()=>{a||(i!==d.current||e.scene.getSceneNonce()!==m.current)&&(d.current=null,tk(i,e,(x,I)=>{c({nonce:JP(),items:x}),d.current=i,m.current=e.scene.getSceneNonce(),n({searchMatches:x.length?{focusedId:null,matches:x.map(T=>({id:T.element.id,focus:!1,matchedLines:T.matchedLines}))}:null})}))},[a,i,E,e,n,u,m]);let g=()=>{l.items.length>0&&u(x=>x===null?0:(x+1)%l.items.length)},b=()=>{l.items.length>0&&u(x=>x===null?0:x-1<0?l.items.length-1:x-1)};ic(()=>{n(x=>x.searchMatches?{searchMatches:{focusedId:p!==null&&x.searchMatches?.matches[p]?.id||null,matches:x.searchMatches.matches.map((T,C)=>C===p?{...T,focus:!0}:{...T,focus:!1})}}:null)},[p,n]),ic(()=>{if(l.items.length>0&&p!==null){let x=l.items[p];if(x){let I=e.state.zoom.value,T=VU({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:Up(x.element)?jE.nameFontSize:x.element.fontSize,fontFamily:Up(x.element)?ZE.Assistant:x.element.fontFamily}),C=14,P=T.fontSize,M=P*I<C;if(!UU([T],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.viewport.getOffsets())||M){let D=M&&P<C?"contain":"scale-down";e.viewport.setViewport({target:HU([T]),fit:D,animation:{duration:300},offsets:{ui:!0}})}}}},[p,l,e]),ic(()=>()=>{u(null),d.current=null,m.current=void 0,n({searchMatches:null}),s(!1)},[n,u]);let w=Hi({goToNextItem:g,goToPreviousItem:b,searchMatches:l});ic(()=>{let x=I=>{if(I.key===as.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){I.preventDefault(),I.stopPropagation(),n({openSidebar:null});return}if(I[as.CTRL_OR_CMD]&&I.key===as.F){if(I.preventDefault(),I.stopPropagation(),e.state.openDialog)return;t.current?.matches(":focus")||(e.state.openDialog&&n({openDialog:null}),t.current?.focus(),t.current?.select())}I.target instanceof HTMLElement&&I.target.closest(".layer-ui__search")&&w.searchMatches.items.length&&(I.key===as.ENTER&&(I.stopPropagation(),w.goToNextItem()),I.key===as.ARROW_UP?(I.stopPropagation(),w.goToPreviousItem()):I.key===as.ARROW_DOWN&&(I.stopPropagation(),w.goToNextItem()))};return WU(window,zU.KEYDOWN,x,{capture:!0,passive:!1})},[n,w,e]);let y=`${l.items.length} ${l.items.length===1?f("search.singleResult"):f("search.multipleResults")}`;return On("div",{className:"layer-ui__search",children:[On("div",{className:"layer-ui__search-header",children:[ft(zp,{className:OU.SEARCH_MENU_INPUT_WRAPPER,value:o,ref:t,placeholder:f("search.placeholder"),icon:Jn,onChange:x=>{r(x),s(!0);let I=x.trim();tk(I,e,(T,C)=>{c({nonce:JP(),items:T}),u(C),d.current=I,m.current=e.scene.getSceneNonce(),n({searchMatches:T.length?{focusedId:null,matches:T.map(P=>({id:P.element.id,focus:!1,matchedLines:P.matchedLines}))}:null}),s(!1)})},selectOnRender:!0}),ft(vn,{"data-testid":"sidebar-close",className:"layer-ui__search-close",onSelect:()=>{n({openSidebar:null})},"aria-label":f("buttons.close"),children:an})]}),On("div",{className:"layer-ui__search-count",children:[l.items.length>0&&On(eW,{children:[p!==null&&p>-1?On("div",{children:[p+1," / ",y]}):ft("div",{children:y}),On("div",{className:"result-nav",children:[ft(vn,{onSelect:()=>{g()},className:"result-nav-btn",children:Kc}),ft(vn,{onSelect:()=>{b()},className:"result-nav-btn",children:u0})]})]}),l.items.length===0&&i&&d.current&&ft("div",{style:{margin:"1rem auto"},children:f("search.noMatch")})]}),ft(ZU,{matches:l,onItemClick:u,focusIndex:p,searchQuery:i})]})},QP=e=>{let n=[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 ft("div",{tabIndex:-1,className:RU("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:ft("div",{className:"preview-text",children:n.flatMap((t,o)=>ft(BU,{children:o===2?ft("b",{children:t}):t},o))})})},KU=e=>{let n=jP(()=>e.matches.items.filter(o=>Up(o.element)),[e.matches]),t=jP(()=>e.matches.items.filter(o=>nk(o.element)),[e.matches]);return On("div",{className:"layer-ui__search-results",children:[n.length>0&&On("div",{className:"layer-ui__search-result-container",children:[On("div",{className:"layer-ui__search-result-title",children:[ft("div",{className:"title-icon",children:jn}),ft("div",{children:f("search.frames")})]}),n.map((o,r)=>ft(QP,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r===e.focusIndex,onClick:()=>e.onItemClick(r)},o.element.id+o.index)),t.length>0&&ft("div",{className:"layer-ui__divider"})]}),t.length>0&&On("div",{className:"layer-ui__search-result-container",children:[On("div",{className:"layer-ui__search-result-title",children:[ft("div",{className:"title-icon",children:Pn}),ft("div",{children:f("search.texts")})]}),t.map((o,r)=>ft(QP,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r+n.length===e.focusIndex,onClick:()=>e.onItemClick(r+n.length)},o.element.id+o.index))]})]})},$U=(e,n)=>e.matches.nonce===n.matches.nonce&&e.focusIndex===n.focusIndex,ZU=FU(KU,$U),ek=(e,n,t)=>{let i=e.slice(0,n),a=i.split(/\s+/),s=i.endsWith(" "),l=a.length-2-1-(s?0:1),c=a.slice(l<=0?0:l).join(" ")+(s?" ":""),d=20;c=c.length>d?c.slice(-d):c;let m=e.slice(n+t.length),p=m.split(/\s+/),u=!m.startsWith(" "),E=u?6:5,g=(u?"":" ")+p.slice(0,E).join(" ");return{indexInSearchQuery:c.length,previewText:c+t+g,moreBefore:l>0,moreAfter:p.length>E}},jU=(e,n)=>{let t=e.split(`
19
19
  `),o=[],r=0;for(let i=0;i<t.length;i++){let a=t[i],s=t[i+1];if(s){let l=n.indexOf(s,r);if(l>a.length+r){let c=l-(a.length+r);for(;c>0;)a+=" ",c--}}o.push(a),r=r+a.length}return o.join(`
20
20
  `)},qU=(e,n,t)=>{let r=jU(e.text,e.originalText).split(`
21
- `),i=[],a=0,s=0;for(let m of r){let p=a,u=p+m.length-1;i.push({line:m,startIndex:p,endIndex:u,lineNumber:s}),a=u+1,s++}let l=t,c=e.originalText.slice(t,t+n.length),d=[];for(let m of i){if(c==="")break;if(l>=m.startIndex&&l<=m.endIndex){let p=m.endIndex+1-l,u=m.line.slice(0,l-m.startIndex),E=c.slice(0,p);c=c.slice(p);let g=ec(u,Np(e),e.lineHeight);if(u===""&&(g.width=0),e.textAlign!=="left"&&m.line.length>0){let I=ec(m.line,Np(e),e.lineHeight),T=e.textAlign==="center"?(e.width-I.width)/2:e.width-I.width;g.width+=T}let{width:b,height:y}=ec(E,Np(e),e.lineHeight),w=g.width,x=m.lineNumber*g.height;d.push({offsetX:w,offsetY:x,width:b,height:y,showOnCanvas:!0}),l+=p}}return d},JU=(e,n,t,o)=>{let r=e.name??ek(e),i=r.slice(t,t+n.length),a=r.slice(0,t),s=Np({fontSize:WE.nameFontSize,fontFamily:UE.Assistant}),l=GU(UE.Assistant),c=ec(a,s,l);a===""&&(c.width=0);let d=ec(i,s,l),m=c.width,p=-c.height-WE.strokeWidth,u=d.width;return[{offsetX:m,offsetY:p,width:u,height:d.height,showOnCanvas:m+u<=e.width*o}]},QU=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),JP=NU((e,n,t)=>{if(!e||e===""){t([],null);return}let o=n.scene.getNonDeletedElements(),r=o.filter(p=>QP(p)),i=o.filter(p=>Bp(p));r.sort((p,u)=>p.y-u.y),i.sort((p,u)=>p.y-u.y);let a=[],s=new RegExp(QU(e),"gi");for(let p of r){let u=null,E=p.originalText;for(;(u=s.exec(E))!==null;){let g=qP(E,u.index,e),b=qU(p,e,u.index);b.length>0&&a.push({element:p,searchQuery:e,preview:g,index:u.index,matchedLines:b})}}let l=[];for(let p of i){let u=null,E=p.name??ek(p);for(;(u=s.exec(E))!==null;){let g=qP(E,u.index,e),b=JU(p,e,u.index,n.state.zoom.value);b.length>0&&l.push({element:p,searchQuery:e,preview:g,index:u.index,matchedLines:b})}}let c=new Set(n.visibleElements.map(p=>p.id)),d=[...l,...a],m=d.findIndex(p=>c.has(p.element.id))??null;t(d,m)},XU);import uW from"clsx";import{useEffect as sk,useLayoutEffect as lk,useRef as QE,useState as hW,forwardRef as ck,useImperativeHandle as gW,useCallback as rk}from"react";import{CLASSES as fW,EVENT as ik,isDevEnv as EW,KEYS as bW,updateObject as xW}from"@excalidraw/common";import nW from"clsx";import{useContext as oW}from"react";import tW from"react";var Fp=tW.createContext({});import{jsx as YE,jsxs as nk}from"react/jsx-runtime";var XE=({children:e,className:n})=>{let t=Ee(),o=oW(Fp),r=!!(t.canFitSidebar&&o.shouldRenderDockButton);return nk("div",{className:nW("sidebar__header",n),"data-testid":"sidebar-header",children:[e,nk("div",{className:"sidebar__header__buttons",children:[r&&YE(pt,{label:f("labels.sidebarLock"),children:YE(wn,{onSelect:()=>o.onDock?.(!o.docked),selected:!!o.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":f("labels.sidebarLock"),children:Dx})}),YE(wn,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:o.onCloseRequest,"aria-label":f("buttons.close"),children:rn})]})]})};XE.displayName="SidebarHeader";import{Tabs as rW}from"radix-ui";import{jsx as ok}from"react/jsx-runtime";var KE=({children:e,tab:n,onSelect:t,...o})=>ok(rW.Trigger,{value:n,asChild:!0,onSelect:t,children:ok("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...o,children:e})});KE.displayName="SidebarTabTrigger";import{Tabs as iW}from"radix-ui";import{jsx as aW}from"react/jsx-runtime";var $E=({children:e,...n})=>aW(iW.List,{className:"sidebar-triggers",...n,children:e});$E.displayName="SidebarTabTriggers";import sW from"clsx";import{jsx as ZE,jsxs as lW}from"react/jsx-runtime";var jE=({name:e,tab:n,icon:t,title:o,children:r,onToggle:i,className:a,style:s})=>{let l=Fe(),d=be().openSidebar?.name===e;return ZE("button",{type:"button",title:o,className:"sidebar-trigger__label-element","aria-label":o,"aria-keyshortcuts":"0","aria-pressed":d,onClick:()=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let m=!d;l({openSidebar:m?{name:e,tab:n}:null,openMenu:null,openPopup:null}),i?.(m)},children:lW("div",{className:sW("sidebar-trigger",a),style:s,children:[t&&ZE("div",{children:t}),r&&ZE("div",{className:"sidebar-trigger__label",children:r})]})})};jE.displayName="SidebarTrigger";import{Tabs as cW}from"radix-ui";import{jsx as dW}from"react/jsx-runtime";var qE=({children:e,...n})=>{let t=be(),o=Fe();if(!t.openSidebar)return null;let{name:r}=t.openSidebar;return dW(cW.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>o(a=>({...a,openSidebar:{...a.openSidebar,name:r,tab:i}})),...n,children:e})};qE.displayName="SidebarTabs";import{Tabs as mW}from"radix-ui";import{jsx as pW}from"react/jsx-runtime";var JE=({tab:e,children:n,...t})=>pW(mW.Content,{...t,value:e,"data-testid":e,children:n});JE.displayName="SidebarTab";import{jsx as ak}from"react/jsx-runtime";import{createElement as yW}from"react";var eb=Je(!1),dk=ck(({name:e,children:n,onDock:t,docked:o,className:r,...i},a)=>{EW()&&t&&o==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let s=Fe(),l=Ix(eb);lk(()=>(l(!!o),()=>{l(!1)}),[l,o]);let c=QE({});c.current.onCloseRequest=()=>{s({openSidebar:null})},c.current.onDock=u=>t?.(u),c.current=xW(c.current,{docked:o,shouldRenderDockButton:!!t&&o!=null});let d=QE(null);gW(a,()=>d.current);let m=Ee(),p=rk(()=>{document.querySelector(".Dialog")||s({openSidebar:null})},[s]);return Bi(d,rk(u=>{u.target.closest(".sidebar-trigger")||(!o||!m.canFitSidebar)&&p()},[p,o,m.canFitSidebar])),sk(()=>{let u=E=>{E.key===bW.ESCAPE&&(!o||!m.canFitSidebar)&&p()};return document.addEventListener(ik.KEYDOWN,u),()=>{document.removeEventListener(ik.KEYDOWN,u)}},[p,o,m.canFitSidebar]),ak(Ue,{...i,className:uW(fW.SIDEBAR,{"sidebar--docked":o},r),"data-viewport-ui":m.formFactor!=="phone"?"side":void 0,"data-viewport-ui-name":m.formFactor!=="phone"?"sidebar":void 0,ref:d,children:ak(Fp.Provider,{value:c.current,children:n})})});dk.displayName="SidebarInner";var Ir=Object.assign(ck((e,n)=>{let t=be(),{onStateChange:o}=e,r=QE(t.openSidebar);sk(()=>{(!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&&o?.(t.openSidebar?.name!==e.name?null:t.openSidebar),r.current=t.openSidebar},[t.openSidebar,o,e.name]);let[i,a]=hW(!1);return lk(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?yW(dk,{...e,ref:n,key:e.name}):null}),{Header:XE,TabTriggers:$E,TabTrigger:KE,Tabs:qE,Tab:JE,Trigger:jE});Ir.displayName="Sidebar";import{jsx as os,jsxs as IW}from"react/jsx-runtime";import{createElement as TW}from"react";var pk=si("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:n}=nt();return os(n.In,{children:os(Ir.Trigger,{...e,className:"default-sidebar-trigger",name:vW.name})})});pk.displayName="DefaultSidebarTrigger";var uk=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:n}=nt();return os(n.In,{children:e})};uk.displayName="DefaultTabTriggers";var tb=Object.assign(si("DefaultSidebar",({children:e,className:n,docked:t,onDock:o,...r})=>{let i=be(),a=Fe(),s=i.openSidebar?.tab===mk,l=s?!1:t??i.defaultSidebarDockedPreference,c=!s&&t==null&&o!==!1;return TW(Ir,{...r,name:"default",key:"default",className:wW("default-sidebar",{"default-sidebar--search-only":s},n),docked:l,onDock:c?d=>{a({defaultSidebarDockedPreference:d}),o?.(d)}:void 0},IW(Ir.Tabs,{children:[!s&&os(Ir.Header,{}),os(Ir.Tab,{tab:mk,children:os(tk,{})}),!s&&e]}))}),{Trigger:pk,TabTriggers:uk});import CW from"react";import{getFrame as PW}from"@excalidraw/common";import{jsx as SW}from"react/jsx-runtime";var nb={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"}},ob=({children:e,color:n})=>SW("div",{className:"Card",style:{"--card-color":nb[n].base,"--card-color-darker":nb[n].darker,"--card-color-darkest":nb[n].darkest},children:e});import{Fragment as MW,jsx as On,jsxs as Op}from"react/jsx-runtime";var kW=({elements:e,appState:n,setAppState:t,files:o,actionManager:r,exportOpts:i,canvas:a,onCloseRequest:s})=>{let{onExportToBackend:l}=i;return On("div",{className:"ExportDialog ExportDialog--json",children:Op("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&Op(ob,{color:"lime",children:[On("div",{className:"Card-icon",children:$x}),On("h2",{children:f("exportDialog.disk_title")}),Op("div",{className:"Card-details",children:[f("exportDialog.disk_details"),!Ii&&r.renderAction("changeProjectName")]}),On($,{className:"Card-button",type:"button",title:f("exportDialog.disk_button"),"aria-label":f("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{r.executeAction(Js,"ui")}})]}),l&&Op(ob,{color:"pink",children:[On("div",{className:"Card-icon",children:Is}),On("h2",{children:f("exportDialog.link_title")}),On("div",{className:"Card-details",children:f("exportDialog.link_details")}),On($,{className:"Card-button",type:"button",title:f("exportDialog.link_button"),"aria-label":f("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{Be("export","link",`ui (${PW()})`),await l(e,n,o),s()}catch(c){t({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,n,o,a)]})})},hk=({elements:e,appState:n,files:t,actionManager:o,exportOpts:r,canvas:i,setAppState:a})=>{let s=CW.useCallback(()=>{a({openDialog:null})},[a]);return On(MW,{children:n.openDialog?.name==="jsonExport"&&On(yn,{onCloseRequest:s,title:f("buttons.export"),children:On(kW,{elements:e,appState:n,setAppState:a,files:t,actionManager:o,onCloseRequest:s,exportOpts:r,canvas:i})})})};import AW from"clsx";import{jsx as DW}from"react/jsx-runtime";var gk=e=>DW($,{className:AW("ToolIcon__LaserPointer",{"is-mobile":e.isMobile}),type:"toggle",size:"small",icon:qn,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,"data-testid":"toolbar-LaserPointer",onSelect:()=>e.onChange?.()});import vk from"clsx";import{useState as WW}from"react";import{CANVAS_SEARCH_TAB as VW,DEFAULT_SIDEBAR as YW,KEYS as tc}from"@excalidraw/common";import{CANVAS_SEARCH_TAB as LW,DEFAULT_SIDEBAR as _W}from"@excalidraw/common";import{isArrowElement as RW,isFlowchartNodeElement as NW,isImageElement as fk,isLinearElement as Ek,isLineElement as BW,isTextBindableContainer as FW,isTextElement as OW}from"@excalidraw/element";import{isNodeInFlowchart as zW}from"@excalidraw/element";import{jsx as rb}from"react/jsx-runtime";var Te=e=>Array.isArray(e)?`<kbd>${e.map(N).join(" + ")}</kbd>`:`<kbd>${N(e)}</kbd>`,GW=({appState:e,isMobile:n,editorInterface:t,app:o})=>{let{activeTool:r,isResizing:i,isRotating:a,lastPointerDownWith:s}=e,l=e.multiElement!==null;if(e.openSidebar?.name===_W.name&&e.openSidebar.tab===LW&&e.searchMatches?.matches.length)return f("hints.dismissSearch",{shortcut:Te("Escape")});if(e.openSidebar&&!t.canFitSidebar)return null;if(on(e))return f("hints.eraserRevert",{shortcut:Te("Alt")});let c=o.scene.getSelectedElements(e);if(e.selectedLinearElement?.isDragging&&c[0]?.type==="arrow")return f("hints.arrowBindModifiers",{shortcut_1:Te("Ctrl"),shortcut_2:Te("Alt")});if(r.type==="arrow"||r.type==="line")return l?f("hints.linearElementMulti",{shortcut_1:Te("Escape"),shortcut_2:Te("Enter")}):r.type==="arrow"?f("hints.arrowTool",{shortcut:Te("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(r.type==="autoshape")return f("hints.autoshape");if(i&&s==="mouse"&&c.length===1){let d=c[0];return Ek(d)&&d.points.length===2?f("hints.lockAngle",{shortcut:Te("Shift")}):fk(d)?f("hints.resizeImage",{shortcut_1:Te("Shift"),shortcut_2:Te("Alt")}):f("hints.resize",{shortcut_1:Te("Shift"),shortcut_2:Te("Alt")})}if(a&&s==="mouse")return f("hints.rotate",{shortcut:Te("Shift")});if(c.length===1&&OW(c[0]))return f("hints.text_selected",{shortcut:Te("Enter")});if(e.editingTextElement)return f("hints.text_editing",{shortcut_1:Te("Escape"),shortcut_2:Te(["CtrlOrCmd","Enter"])});if(e.croppingElementId)return f("hints.leaveCropEditor",{shortcut_1:Te("Enter"),shortcut_2:Te("Escape")});if(c.length===1&&fk(c[0]))return f("hints.enterCropEditor",{shortcut:Te("Enter")});if(r.type==="selection"){if(e.selectionElement&&!c.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return f("hints.deepBoxSelect",{shortcut:Te("CtrlOrCmd")});if(cr(o)&&e.selectedElementsAreBeingDragged)return f("hints.disableSnapping",{shortcut:Te("CtrlOrCmd")});if(!c.length&&!n)return f("hints.canvasPanning",{shortcut_1:Te(f("keys.mmb")),shortcut_2:Te("Space")});if(c.length===1){if(Ek(c[0]))return RW(c[0])&&e.selectedLinearElement?.elementId===c[0].id&&(e.selectedLinearElement.hoverPointIndex===0||e.selectedLinearElement.hoverPointIndex===c[0].points.length-1)?f("hints.toggleArrowhead"):e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?f("hints.lineEditor_pointSelected",{shortcut_1:Te("Delete"),shortcut_2:Te(["CtrlOrCmd","D"])}):f("hints.lineEditor_nothingSelected",{shortcut_1:Te("Shift"),shortcut_2:Te("Alt")}):BW(c[0])?f("hints.lineEditor_line_info",{shortcut:Te("Enter")}):f("hints.lineEditor_info",{shortcut_1:Te("CtrlOrCmd"),shortcut_2:Te(["CtrlOrCmd","Enter"])});if(!e.newElement&&!e.selectedElementsAreBeingDragged&&FW(c[0])){let d=f("hints.bindTextToElement",{shortcut:Te("Enter")}),m=f("hints.createFlowchart",{shortcut:Te(["CtrlOrCmd","\u2191\u2193"])});return NW(c[0])?zW(c[0],o.scene.getNonDeletedElementsMap())?[d,m]:[d,m]:d}}}return null},bk=({appState:e,isMobile:n,editorInterface:t,app:o})=>{let r=GW({appState:e,isMobile:n,editorInterface:t,app:o});if(!r)return null;let a=(Array.isArray(r)?r.map(s=>s.replace(/\. ?$/,"")).join(", "):r).split(/(<kbd>[^<]+<\/kbd>)/g).map((s,l)=>{if(l%2===1){let c=s[0]==="<"&&s.match(/^<kbd>([^<]+)<\/kbd>$/);return rb("kbd",{children:c?c[1]:s},l)}return s});return rb("div",{className:"HintViewer",children:rb("span",{children:a})})};import HW from"clsx";import{jsx as UW}from"react/jsx-runtime";var xk=e=>UW($,{className:HW("ToolIcon__lock",{"is-mobile":e.isMobile}),type:"toggle",icon:e.checked?Uo:fo,checked:e.checked,disabled:e.disabled,title:`${e.title} \u2014 Q`,"aria-label":`${e.title}`,"data-testid":"toolbar-lock",onSelect:()=>e.onChange?.()});import{Fragment as gi,jsx as ie,jsxs as Lo}from"react/jsx-runtime";var XW=(e,n)=>e==="image"&&n.tools?.image===!1,KW=({app:e,activeTool:n,type:t,shortcut:o})=>ie(ue.Item,{onSelect:()=>e.setActiveTool({type:t}),icon:Ye[t].icon,"data-testid":`toolbar-${t}`,selected:n.type===t,shortcut:o??Ji(t),disabled:qe(e,t),children:f(`toolBar.${t}`)}),yk=({app:e})=>ie(ue.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?Uo:fo,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:tc.Q.toLocaleUpperCase(),children:f("toolBar.lock-short")}),$W=({actionManager:e,app:n})=>{if(!e.isActionEnabled(Dt))return null;let t=Ze("objectsSnapMode");return ie(ue.Item,{onSelect:()=>e.executeAction(Dt,"ui"),icon:Yo,"data-testid":"toolbar-objects-snap-mode",selected:n.state.objectsSnapModeEnabled,shortcut:t,children:f("buttons.objectsSnapMode")})},ZW=({actionManager:e,app:n})=>{if(!e.isActionEnabled(Dt))return null;let t=f("buttons.objectsSnapMode"),o=Ze("objectsSnapMode");return ie($,{type:"toggle",icon:Yo,checked:n.state.objectsSnapModeEnabled,title:`${t} - ${o}`,"aria-label":t,"aria-keyshortcuts":o,"data-testid":"toolbar-objects-snap-mode",onSelect:()=>e.executeAction(Dt,"ui")})},wk=({actionManager:e,appState:n})=>{let t=f("search.title"),o=Ze("searchMenu");return ie(ue.Item,{onSelect:()=>e.executeAction(wl,"ui"),icon:Jn,"data-testid":"toolbar-search-menu",selected:n.openSidebar?.name===YW.name&&n.openSidebar.tab===VW,shortcut:o,children:t})},jW=({app:e})=>ie($,{type:"button",icon:_i,title:`${f("labels.eyeDropper")} - ${tc.I.toLocaleUpperCase()}`,"aria-label":f("labels.eyeDropper"),"aria-keyshortcuts":tc.I.toLocaleUpperCase(),keyBindingLabel:tc.I.toLocaleUpperCase(),"data-testid":"toolbar-eyedropper",onClick:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1})}),qW=({app:e,activeTool:n,setAppState:t,UIOptions:o,isMyocSimplifiedMode:r,actionManager:i})=>{let[a,s]=WW(!1),l=ct()==="full",c=n.type==="frame",d=n.type==="autoshape",m=n.type==="laser",p=n.type==="bucketfill",u=l&&n.type==="lasso"&&e.state.preferredSelectionTool.type!=="lasso",E=n.type==="embeddable",g=r&&ji.includes(n.type);return Lo(ue,{open:a,children:[ie(ue.Trigger,{className:vk("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":g||c||E||!r&&l&&d||u||p||m&&!e.props.isCollaborating}),onToggle:()=>{s(!a),t({openMenu:null,openPopup:null})},title:f("toolBar.extraTools"),children:g?Ye[n.type].icon:c?jn:E?Vo:!r&&l&&d?Br:m&&!e.props.isCollaborating?qn:u?ki:p?Zn:bs}),ie(ue.Content,{onClickOutside:()=>s(!1),onSelect:()=>s(!1),className:"App-toolbar__extra-tools-dropdown",children:r?Lo(gi,{children:[l&&ie(ue.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:ki,"data-testid":"toolbar-lasso",selected:u,disabled:qe(e,"lasso"),children:f("toolBar.lasso")}),ji.filter(b=>!XW(b,o)).map(b=>ie(KW,{app:e,activeTool:n,type:b},b)),ie("div",{className:"App-toolbar__dropdown-divider"}),ie(wk,{actionManager:i,appState:e.state}),e.props.activeTool==null&&ie(gi,{children:ie(yk,{app:e})})]}):Lo(gi,{children:[ie(ue.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:jn,shortcut:tc.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:c,disabled:qe(e,"frame"),children:f("toolBar.frame")}),ie(ue.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:Vo,"data-testid":"toolbar-embeddable",selected:E,disabled:qe(e,"embeddable"),children:f("toolBar.embeddable")}),ie(ue.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:Br,shortcut:Ji("autoshape"),"data-testid":"toolbar-autoshape",selected:d,disabled:qe(e,"autoshape"),children:f("toolBar.autoshape")}),ie(ue.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:qn,"data-testid":"toolbar-laser",selected:m,disabled:qe(e,"laser"),children:f("toolBar.laser")}),ie(ue.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:Zn,"data-testid":"toolbar-bucketfill",selected:p,disabled:qe(e,"bucketfill"),children:f("toolBar.bucketfill")}),l&&ie(ue.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:ki,"data-testid":"toolbar-lasso",selected:u,disabled:qe(e,"lasso"),children:f("toolBar.lasso")}),ie("div",{className:"App-toolbar__dropdown-divider"}),ie($W,{actionManager:i,app:e}),ie(wk,{actionManager:i,appState:e.state}),e.props.activeTool==null&&ie(yk,{app:e})]})})]})},Ik=({app:e,appState:n,setAppState:t,UIOptions:o,actionManager:r,onPenModeToggle:i,onLockToggle:a,heading:s})=>{let l=Ee(),c=ct()==="compact",d=n.activeTool,m={app:e,activeTool:d},p=n.myocSimplifiedMode,u=c?ie(Rd,{...m,setAppState:t}):n.preferredSelectionTool.type==="lasso"?ie(qy,{...m}):ie(jy,{...m});return Lo(Ue,{padding:1,className:vk("App-toolbar",{"zen-mode":n.zenModeEnabled,"App-toolbar--compact":c}),"data-viewport-ui":"top",children:[ie(bk,{appState:n,isMobile:l.formFactor==="phone",editorInterface:l,app:e}),s,Lo(Nt.Row,{gap:c?.5:1,children:[!c&&ie(Ka,{checked:n.penMode,onChange:()=>i(null),title:f("toolBar.penMode"),penDetected:n.penDetected}),e.props.activeTool==null&&!p&&Lo(gi,{children:[ie(xk,{checked:n.activeTool.locked,onChange:a,title:f("toolBar.lock"),disabled:e.props.activeTool!=null}),ie("div",{className:"App-toolbar__divider"})]}),ie(_d,{...m}),u,p?Lo(gi,{children:[ie(Ws,{...m}),ie(Vs,{...m}),ie(jW,{app:e}),o.tools?.image!==!1&&ie(Ys,{...m}),ie(Xs,{...m})]}):Lo(gi,{children:[ie(Vy,{...m}),ie(Yy,{...m}),ie(Xy,{...m}),ie(Ky,{...m}),ie($y,{...m}),c?ie(Nd,{...m}):ie(Ws,{...m}),ie(Vs,{...m}),o.tools?.image!==!1&&ie(Ys,{...m}),ie(Xs,{...m})]}),ie("div",{className:"App-toolbar__divider"}),ie(qW,{app:e,activeTool:d,setAppState:t,UIOptions:o,isMyocSimplifiedMode:p,actionManager:r}),p&&Lo(gi,{children:[ie("div",{className:"App-toolbar__divider"}),ie(ZW,{actionManager:r,app:e})]})]})]})};import{Fragment as ib,jsx as ee,jsxs as en}from"react/jsx-runtime";var rV=({UIOptions:e})=>en(Bt,{__fallback:!0,children:[ee(Bt.DefaultItems.LoadScene,{}),ee(Bt.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&ee(Bt.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&ee(Bt.DefaultItems.SaveAsImage,{}),ee(Bt.DefaultItems.SearchMenu,{}),ee(Bt.DefaultItems.Help,{}),ee(Bt.Separator,{}),ee(Bt.Group,{title:"Excalidraw links",children:ee(Bt.DefaultItems.Socials,{})}),ee(Bt.Separator,{}),ee(Bt.DefaultItems.ToggleTheme,{allowSystemTheme:!1}),ee(Bt.DefaultItems.ChangeCanvasBackground,{})]}),iV=()=>en(wp,{__fallback:!0,children:[ee(wp.Actions.SaveToDisk,{}),ee(wp.Actions.ExportToImage,{})]}),aV=({actionManager:e,appState:n,files:t,setAppState:o,elements:r,canvas:i,onLockToggle:a,onPenModeToggle:s,showExitZenModeBtn:l,renderTopLeftUI:c,renderTopRightUI:d,renderCustomStats:m,UIOptions:p,onExportImage:u,renderWelcomeScreen:E,children:g,app:b,defaultUIEnabled:y,zoomUIEnabled:w,scrollBackToContentUIEnabled:x,isCollaborating:I,generateLinkForSelection:T,currentUserControls:C})=>{let P=Ee(),A=kn(),_=ct()==="compact",k=$T(),L=_?{menuTopGap:4,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:.5,islandPadding:1,collabMarginLeft:8}:{menuTopGap:6,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:1,islandPadding:1,collabMarginLeft:8},B=k.tunnelsJotai.Provider,[V,z]=He(zt),U=()=>p.canvasActions.export?ee(hk,{elements:r,appState:n,files:t,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:o}):null,K=()=>!p.canvasActions.saveAsImage||n.openDialog?.name!=="imageExport"?null:ee(XP,{elements:r,appState:n,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>o({openDialog:null}),name:b.getName()}),G=()=>en("div",{style:{position:"relative"},children:[en("div",{className:"excalidraw-ui-top-left",children:[c?.(!1,n),ee(k.MainMenuTunnel.Out,{}),ee(k.DefaultSidebarTriggerTunnel.Out,{})]}),E&&ee(k.WelcomeScreenMenuHintTunnel.Out,{})]}),te=()=>ee(Hl,{heading:"selectedShapeActions",className:rs("selected-shape-actions zen-mode-transition",{"transition-left":n.zenModeEnabled}),children:_?ee(Ue,{className:rs("compact-shape-actions-island"),padding:0,"data-viewport-ui":"side","data-viewport-ui-name":"stylesPanel",style:{maxHeight:`${n.height-166}px`},children:ee(uS,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b,setAppState:o})}):ee(Ue,{className:QW.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${n.height-166}px`},"data-viewport-ui":"side","data-viewport-ui-name":"stylesPanel",children:ee(lS,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b})})}),F=()=>{let de=y&&oV(n,r),he=y&&n.stats.open&&!n.zenModeEnabled&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector";return ee(pp,{side:"top",children:en("div",{className:"App-menu App-menu_top",children:[en(Nt.Col,{gap:L.menuTopGap,className:rs("App-menu_top__left"),children:[G(),y&&ee("div",{className:rs("selected-shape-actions-container",{"selected-shape-actions-container--compact":_}),children:de&&te()}),y&&_&&!n.viewModeEnabled&&de&&ee(Ka,{checked:n.penMode,onChange:()=>s(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:n.penDetected})]}),y&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector"&&ee(Hl,{heading:"shapes",className:"shapes-section",children:ve=>en("div",{style:{position:"relative"},children:[E&&ee(k.WelcomeScreenToolbarHintTunnel.Out,{}),ee(Nt.Col,{gap:L.toolbarColGap,align:"start",children:en(Nt.Row,{gap:L.toolbarRowGap,className:rs("App-toolbar-container",{"zen-mode":n.zenModeEnabled}),children:[ee(Ik,{app:b,appState:n,setAppState:o,UIOptions:p,actionManager:e,onPenModeToggle:s,onLockToggle:a,heading:ve}),I&&ee(Ue,{style:{marginLeft:L.collabMarginLeft,alignSelf:"center",height:"fit-content"},children:ee(gk,{title:f("toolBar.laser"),checked:n.activeTool.type===Tk.laser,onChange:()=>b.setActiveTool({type:Tk.laser}),isMobile:!0})})]})})]})}),en("div",{className:rs("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":n.zenModeEnabled,"layer-ui__wrapper__top-right--compact":_}),children:[y&&n.collaborators.size>0&&ee(fp,{collaborators:n.collaborators,userToFollow:A.userToFollow?.socketId||null,currentUserControls:C}),d?.(P.formFactor==="phone",n),he&&ee(Zl,{app:b,onClose:()=>{e.executeAction(ar)},renderCustomStats:m})]})]})})},W=()=>ee(tb,{}),le=!1,we=en(ib,{children:[g,y&&ee(ib,{children:ee(rV,{UIOptions:p})}),ee(iV,{}),y&&n.isLoading&&ee(sp,{delay:250}),y&&n.errorMessage&&ee(PP,{onClose:()=>o({errorMessage:null}),children:n.errorMessage}),y&&V&&P.formFactor!=="phone"&&ee(_0,{colorPickerType:V.colorPickerType,onCancel:()=>{z(null)},onChange:(de,he,ve,{altKey:ae})=>{if(!(de!=="elementBackground"&&de!=="elementStroke"))if(ve.length){for(let fe of ve)tV(fe,eV(r),{[ae&&V.swapPreviewOnAlt?de==="elementBackground"?"strokeColor":"backgroundColor":de==="elementBackground"?"backgroundColor":"strokeColor"]:he}),nV.delete(fe);b.scene.triggerUpdate()}else o(de==="elementBackground"?{currentItemBackgroundColor:he}:{currentItemStrokeColor:he})},onSelect:(de,he)=>{z(ve=>ve?.keepOpenOnAlt&&he.altKey?ve:null),V?.onSelect?.(de,he)}}),n.openDialog?.name==="help"&&ee(zP,{onClose:()=>{o({openDialog:null})}}),y&&n.openDialog?.name==="elementLinkSelector"&&ee(CP,{sourceElementId:n.openDialog.sourceElementId,onClose:()=>{o({openDialog:null})},scene:b.scene,appState:n,generateLinkForSelection:T}),ee(k.OverwriteConfirmDialogTunnel.Out,{}),K(),U(),y&&n.openDialog?.name==="charts"&&ee(tC,{data:n.openDialog.data,rawText:n.openDialog.rawText,onClose:()=>o({openDialog:null})}),y&&ee(NP,{app:b,files:t,setAppState:o}),P.formFactor==="phone"&&ee(WS,{app:b,appState:n,elements:r,actionManager:e,renderJSONExportDialog:U,renderImageExportDialog:K,setAppState:o,onPenModeToggle:s,renderTopLeftUI:c,renderTopRightUI:d,renderSidebars:W,renderWelcomeScreen:E,defaultUIEnabled:y,scrollBackToContentUIEnabled:x}),P.formFactor!=="phone"&&en(ib,{children:[A.viewportStatusFrame?.border&&ee(rp,{border:A.viewportStatusFrame.border,style:le?{right:"calc(var(--right-sidebar-width) - var(--space-factor) * 2)"}:void 0}),en("div",{className:"layer-ui__wrapper",style:le?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[E&&ee(k.WelcomeScreenCenterTunnel.Out,{}),F(),ee(lC,{appState:n,actionManager:e,showExitZenModeBtn:l,renderWelcomeScreen:E,defaultUIEnabled:y,zoomUIEnabled:w}),(n.toast||x&&n.scrolledOutside||A.viewportStatusFrame?.label)&&en("div",{className:"floating-status-stack",children:[n.toast&&ee(zd,{message:n.toast.message,onClose:()=>o({toast:null}),duration:n.toast.duration,closable:n.toast.closable}),!n.toast&&x&&n.scrolledOutside&&ee("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(de=>({...wi(r,de)}))},children:f("buttons.scrollBackToContent")}),A.viewportStatusFrame?.label&&ee(ip,{label:A.viewportStatusFrame.label,border:A.viewportStatusFrame.border})]})]})]}),W()]});return ee(lh.Provider,{value:n,children:ee(B,{children:ee(jf.Provider,{value:k,children:we})})})},Sk=e=>{let{cursorButton:n,scrollX:t,scrollY:o,zoom:r,shouldCacheIgnoreZoom:i,snapLines:a,originSnapOffset:s,suggestedBinding:l,frameToHighlight:c,elementsToHighlight:d,...m}=e;return m},sV=(e,n)=>{if(e.children!==n.children)return!1;let{canvas:t,appState:o,...r}=e,{canvas:i,appState:a,...s}=n;return zp(Sk(o),Sk(a),{selectedElementIds:zp,selectedGroupIds:zp})&&zp(r,s)},Ck=JW.memo(aV,sV);import{useEffect as lV,useRef as cV}from"react";import{jsx as Pk}from"react/jsx-runtime";var kk=({trails:e})=>{let n=cV(null);return lV(()=>{if(n.current)for(let t of e)t.start(n.current);return()=>{for(let t of e)t.stop()}},e),Pk("div",{className:"SVGLayer",children:Pk("svg",{ref:n})})};import dV,{useEffect as Mk,useRef as Ak}from"react";import{isShallowEqual as mV,sceneCoordsToViewportCoords as pV}from"@excalidraw/common";import{jsx as gV}from"react/jsx-runtime";var Dk="animateInteractiveScene",uV=e=>{let n=Ak(!1),t=Ak(null);return Mk(()=>{let o=null,r=()=>{o===null&&(o=requestAnimationFrame(()=>{o=null,t.current&&Rf({...t.current,callback:()=>{}})}))},i=e.app.imageLoadingProgressEmitter.on(r),a=e.app.imageStatusEmitter.on(r);return()=>{i(),a(),o!==null&&cancelAnimationFrame(o)}},[e.app]),Mk(()=>{if(!n.current){n.current=!0;return}let o=new Map,r=new Map,i=new Map,a=new Map,s=new Map;e.appState.collaborators.forEach((c,d)=>{if(c.selectedElementIds)for(let m of Object.keys(c.selectedElementIds))i.has(m)||i.set(m,[]),i.get(m).push(d);!c.pointer||c.pointer.renderCursor===!1||(c.username&&a.set(d,c.username),c.userState&&s.set(d,c.userState),r.set(d,pV({sceneX:c.pointer.x,sceneY:c.pointer.y},e.appState)),o.set(d,c.button))});let l=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:o,remoteSelectedElementIds:i,remotePointerUsernames:a,remotePointerUserStates:s,selectionColor:l,renderScrollbars:e.renderScrollbars,lastViewportPosition:e.app.viewport.lastPosition},editorInterface:e.editorInterface,callback:e.renderInteractiveSceneCallback,animationState:{bindingHighlight:void 0},deltaTime:0},at.running(Dk)||at.start(Dk,({deltaTime:c,state:d})=>{let m=Rf({...t.current,deltaTime:c,animationState:d}).animationState;if(m){for(let p in m)if(m[p]!==void 0)return m}})}),gV("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onClick:e.onClick,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.appState.viewModeEnabled?void 0:e.onDoubleClick,children:f("labels.drawingCanvas")})},Lk=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,activeTool:e.activeTool,openDialog:e.openDialog,editingGroupId:e.editingGroupId,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,newElement:e.newElement,isBindingEnabled:e.isBindingEnabled,isMidpointSnappingEnabled:e.isMidpointSnappingEnabled,gridModeEnabled:e.gridModeEnabled,suggestedBinding:e.suggestedBinding,hoveredArrowTextAnchor:e.hoveredArrowTextAnchor,isRotating:e.isRotating,elementsToHighlight:e.elementsToHighlight,collaborators:e.collaborators,activeEmbeddable:e.activeEmbeddable,snapLines:e.snapLines,zenModeEnabled:e.zenModeEnabled,editingTextElement:e.editingTextElement,isCropping:e.isCropping,croppingElementId:e.croppingElementId,searchMatches:e.searchMatches,activeLockedId:e.activeLockedId,hoveredElementIds:e.hoveredElementIds,frameRendering:e.frameRendering,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,exportScale:e.exportScale,currentItemArrowType:e.currentItemArrowType}),hV=(e,n)=>e.selectionNonce!==n.selectionNonce||e.canvasNonce!==n.canvasNonce||e.scale!==n.scale||e.elementsMap!==n.elementsMap||e.visibleElements!==n.visibleElements||e.selectedElements!==n.selectedElements||e.renderScrollbars!==n.renderScrollbars||e.interactionEnabled!==n.interactionEnabled||e.navigationEnabled!==n.navigationEnabled?!1:mV(Lk(e.appState),Lk(n.appState)),ab=dV.memo(uV,hV);import Nk,{useEffect as Gp,useRef as nc}from"react";import{isShallowEqual as _k}from"@excalidraw/common";import{hasActiveGifDecode as fV}from"@excalidraw/element";import{jsx as xV}from"react/jsx-runtime";var EV=e=>{let n=nc(null),t=nc(!1),o=nc(e),r=nc(()=>{}),i=nc(null);o.current=e;let a=Nk.useCallback(()=>{let s=o.current,l=n.current;if(!l)return;let c=getComputedStyle(l).getPropertyValue("--color-grid-bold").trim(),d=getComputedStyle(l).getPropertyValue("--color-grid-regular").trim();dx({canvas:s.canvas,rc:s.rc,scale:s.scale,elementsMap:s.elementsMap,allElementsMap:s.allElementsMap,visibleElements:s.visibleElements,appState:s.appState,renderConfig:{...s.renderConfig,gridColorBold:c,gridColorRegular:d}},Ta());let m=s.renderConfig.imageTransitionDuration??0,p=m>0&&s.visibleElements.some(E=>{if(E.type!=="image"||!E.fileId)return!1;let g=s.renderConfig.imageCache.get(E.fileId)?.transitionStart;return g!==void 0&&performance.now()-g<m}),u=fV(s.visibleElements,s.renderConfig.imageCache);(p||u)&&i.current===null&&(i.current=requestAnimationFrame(()=>{i.current=null,r.current()}))},[]);return r.current=a,Gp(()=>{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]),Gp(()=>{let s=n.current;if(!s)return;let l=e.canvas;t.current||(t.current=!0,s.replaceChildren(l),l.classList.add("excalidraw__canvas","static")),a()}),Gp(()=>{let s=null,l=e.app.imagePlaceholderUpdateEmitter.on(()=>{s===null&&(s=requestAnimationFrame(()=>{s=null,a()}))});return()=>{l(),s!==null&&cancelAnimationFrame(s)}},[e.app,a]),Gp(()=>()=>{i.current!==null&&cancelAnimationFrame(i.current)},[]),xV("div",{className:"excalidraw__canvas-wrapper",ref:n})},Rk=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}),bV=(e,n)=>e.canvasNonce!==n.canvasNonce||e.scale!==n.scale||e.elementsMap!==n.elementsMap||e.visibleElements!==n.visibleElements?!1:_k(Rk(e.appState),Rk(n.appState))&&_k(e.renderConfig,n.renderConfig),sb=Nk.memo(EV,bV);import{useEffect as CV,useRef as PV}from"react";import{throttleRAF as yV}from"@excalidraw/common";import{getTargetFrame as wV,isInvisiblySmallElement as vV,renderElement as IV,shouldApplyFrameClip as TV}from"@excalidraw/element";var Bk=({canvas:e,rc:n,newElement:t,elementsMap:o,allElementsMap:r,scale:i,appState:a,renderConfig:s})=>{if(e){let[l,c]=Tc(e,i),d=Sc({canvas:e,scale:i,normalizedWidth:l,normalizedHeight:c});if(d.save(),d.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"){if(vV(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let u=wV(t,o,a);u&&TV(t,u,a,o)&&lx(u,d,s,a)}IV(t,o,r,n,d,s,a)}else d.clearRect(0,0,l,c);d.restore()}},SV=yV(e=>{Bk(e)}),Fk=(e,n)=>{if(n){SV(e);return}Bk(e)};import{jsx as MV}from"react/jsx-runtime";var kV=e=>{let n=PV(null);return CV(()=>{n.current&&Fk({canvas:n.current,scale:e.scale,newElement:e.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},Ta())}),MV("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:n})},Ok=kV;import AV from"clsx";import{useLayoutEffect as DV,useEffect as zk,useRef as LV,useState as _V}from"react";import{ARROW_TYPE as Gk,EVENT as Hp}from"@excalidraw/common";import{jsx as FV}from"react/jsx-runtime";var Hk=700,RV=100,NV=16,BV=5*60*1e3,Wk=Je(null),Uk=e=>e===Gk.elbow?Ko:e===Gk.round?$o:Xo,Up=class{constructor(n){v(this,"app");v(this,"lastShownAt",0);v(this,"show",n=>{let{x:t,y:o}=this.app.viewport.lastPosition;t===0&&o===0||(this.lastShownAt=Date.now(),this.app.updateEditorAtom(Wk,{content:n,nonce:Math.random()}))});v(this,"isOnCooldown",()=>Date.now()-this.lastShownAt<BV);v(this,"onArrowTypeCycled",n=>{this.show(Uk(n))});v(this,"onToolShortcut",(n,t)=>{(t==="digit"||!this.isOnCooldown())&&this.show(n==="line"?Wo:Uk(this.app.state.currentItemArrowType))});this.app=n}},Vk=()=>{let[e,n]=He(Wk),t=St(),{container:o}=Re(),r=LV(null),[i,a]=_V(!1),s=e?.nonce;return DV(()=>{if(s==null||!o)return;let l=(d,m)=>{let p=r.current;if(!p)return;let{left:u,top:E}=td({cursor:{x:d,y:m},element:{width:p.offsetWidth,height:p.offsetHeight},container:o.getBoundingClientRect(),gap:NV});p.style.transform=`translate(${u}px, ${E}px)`};l(t.viewport.lastPosition.x,t.viewport.lastPosition.y);let c=d=>{l(d.clientX,d.clientY)};return window.addEventListener(Hp.POINTER_MOVE,c),()=>{window.removeEventListener(Hp.POINTER_MOVE,c)}},[s,o,t]),zk(()=>()=>{n(null)},[n]),zk(()=>{if(s==null)return;a(!1);let l=window.setTimeout(()=>{a(!0)},Hk),c=window.setTimeout(()=>{n(null)},Hk+RV),d=()=>{n(null)};return window.addEventListener(Hp.POINTER_DOWN,d,{capture:!0}),()=>{window.clearTimeout(l),window.clearTimeout(c),window.removeEventListener(Hp.POINTER_DOWN,d,{capture:!0})}},[s,n]),e?FV("div",{ref:r,className:AV("CursorHint",{"CursorHint--fade-out":i}),"data-testid":"cursor-hint",children:e.content}):null};var Wp=class{constructor(n){this.getState=n;v(this,"listeners",[]);v(this,"onStateChange",(n,t,o)=>{let{predicate:r,getValue:i,callback:a,once:s,matchesImmediately:l}=this.normalize(n,t,o);return a?l&&(queueMicrotask(()=>{let c=this.getState();a(i(c),c)}),s)?()=>{}:this.subscribe({predicate:r,getValue:i,callback:a,once:s}):l?Promise.resolve(i(this.getState())):new Promise(c=>{this.subscribe({predicate:r,getValue:i,callback:d=>c(d),once:!0})})})}isStateChangePredicateOptions(n){return typeof n=="object"&&!Array.isArray(n)&&"predicate"in n}subscribe(n){return this.listeners.push(n),()=>{this.listeners=this.listeners.filter(t=>t!==n)}}normalize(n,t,o){let r,i,a=t,s=o?.once??!1,l=!1;if(this.isStateChangePredicateOptions(n)){let{predicate:c,callback:d,once:m}=n;r=c,i=p=>p,a=d?(p,u)=>d(u):void 0,s=m??!1,l=c(this.getState())}else if(typeof n=="function"){let c=n;r=(d,m)=>c(d)!==c(m),i=d=>c(d)}else if(Array.isArray(n)){let c=n;r=(d,m)=>c.some(p=>d[p]!==m[p]),i=d=>d}else{let c=n;r=(d,m)=>d[c]!==m[c],i=d=>d[c]}return{predicate:r,getValue:i,callback:a,once:s,matchesImmediately:l}}flush(n){if(!this.listeners.length)return;let t=this.getState(),o=[];for(let r of this.listeners)r.predicate(t,n)?(r.callback(r.getValue(t),t),r.once||o.push(r)):o.push(r);this.listeners=o}clear(){this.listeners=[]}};import{getCommonBounds as OV,getElementsInGroup as zV,isNonDeletedElement as Yk,selectGroupsFromGivenElements as GV}from"@excalidraw/element";import{sceneCoordsToViewportCoords as HV}from"@excalidraw/common";import{flushSync as UV}from"react-dom";import{jsx as VV}from"react/jsx-runtime";var WV=({app:e,activeLockedId:n})=>{let t=e.scene.getElement(n);t&&!Yk(t)&&console.error("[NONDELETED][INVARIANT] UnlockPopup: activeLockedId points to a deleted element");let o=t&&Yk(t)?t:null,r=o?[o]:zV(e.scene.getNonDeletedElementsMap(),n);if(r.length===0)return null;let[i,a]=OV(r),{x:s,y:l}=HV({sceneX:i,sceneY:a},e.state);return VV("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${s-e.state.offsetLeft}px`},onClick:()=>{UV(()=>{let c=GV(r,e.state);e.setState({selectedElementIds:r.reduce((d,m)=>({...d,[m.id]:!0}),{}),selectedGroupIds:c,activeLockedId:null})}),e.actionManager.executeAction(il)},title:f("labels.elementLock.unlock"),children:Lx})},Xk=WV;import{Fragment as UX,jsx as Ce,jsxs as Ab}from"react/jsx-runtime";var e3=vn.createContext(null),t3=vn.createContext(null),Db={formFactor:"desktop",desktopUIMode:"full",userAgent:JM(typeof navigator<"u"?navigator.userAgent:""),isTouchScreen:!1,canFitSidebar:!1,isLandscape:!0},_b=vn.createContext(Db);_b.displayName="EditorInterfaceContext";var zX={"editor:mount":{cardinality:"once",replay:"last"},"editor:initialize":{cardinality:"once",replay:"last"},"editor:unmount":{cardinality:"once",replay:"last"}},Rb=vn.createContext({container:null,id:null});Rb.displayName="ExcalidrawContainerContext";var Nb=vn.createContext([]);Nb.displayName="ExcalidrawElementsContext";var Bb=vn.createContext({...Ho(),width:0,height:0,offsetLeft:0,offsetTop:0});Bb.displayName="ExcalidrawAppStateContext";var Fb=vn.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});Fb.displayName="ExcalidrawSetAppStateContext";var Ob=vn.createContext(null);Ob.displayName="ExcalidrawActionManagerContext";var cs=vn.createContext(null);cs.displayName="ExcalidrawAPIContext";var au=vn.createContext(null);au.displayName="ExcalidrawAPISetContext";var St=()=>Oo(e3),kn=()=>Oo(t3),Ee=()=>Oo(_b),ct=()=>iu(Ee()),Re=()=>Oo(Rb),Oi=()=>Oo(Nb),Qn=()=>Oo(Bb),Fe=()=>Oo(Fb),ot=()=>Oo(Ob),Id=()=>Oo(cs),pc=!1,uc=0,hc=null,Bo=!1,tu=!1,Fo=!1,nu=!1,gc={horizontal:null,vertical:null},Pr=0,fc=!1,Mb=new Map,GX=4,ou=!1,ru=0,ZM=!1,ls=null,me={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},Lb=class e extends vn.Component{constructor(t){super(t);v(this,"canvas");v(this,"interactiveCanvas",null);v(this,"sessionExportThemeOverride");v(this,"rc");v(this,"unmounted",!1);v(this,"actionManager");v(this,"editorInterface",Db);v(this,"stylesPanelMode",iu(Db));v(this,"excalidrawContainerRef",vn.createRef());v(this,"scene");v(this,"fonts");v(this,"renderer");v(this,"visibleElements");v(this,"hasRenderableElements",!1);v(this,"resizeObserver");v(this,"id");v(this,"store");v(this,"history");v(this,"excalidrawContainerValue");v(this,"files",{});v(this,"imageCache",new Map);v(this,"imageLoadingProgress",new Map);v(this,"imageLoadingProgressEmitter",new co);v(this,"imageStatus",new Map);v(this,"imageStatusEmitter",new co);v(this,"imagePlaceholderUpdateEmitter",new co);v(this,"iFrameRefs",new Map);v(this,"embedsValidationStatus",new Map);v(this,"initializedEmbeds",new Set);v(this,"elementsPendingErasure",new Set);v(this,"_initialized",!1);v(this,"editorLifecycleEvents",new yY(zX));v(this,"onEvent",this.editorLifecycleEvents.on.bind(this.editorLifecycleEvents));v(this,"appStateObserver",new Wp(()=>this.state));v(this,"onStateChange",this.appStateObserver.onStateChange);v(this,"bucketFill",new $m(this));v(this,"flowchart",new Qm(this));v(this,"cursor",new Zm(this));v(this,"gifPlayback",new ep(this));v(this,"zDragZoom",null);v(this,"arrowText",new Km(this));v(this,"viewport",new np(this,{getContainer:()=>this.excalidrawContainerRef.current,getStylesPanelMode:()=>this.stylesPanelMode,isGestureActive:()=>me.pointers.size>=2||Fo}));v(this,"bindModeHandler",null);v(this,"textWysiwygSubmitHandler",null);v(this,"hitLinkElement");v(this,"lastPointerDownEvent",null);v(this,"lastPointerUpEvent",null);v(this,"lastPointerUpIsDoubleClick",!1);v(this,"lastPointerMoveEvent",null);v(this,"lastPointerMoveCoords",null);v(this,"lastCompletedCanvasClicks",[]);v(this,"previousPointerMoveCoords",null);v(this,"drawShape",new Jm(this));v(this,"laserTrails",new Tm(this));v(this,"eraserTrail",new Dm(this));v(this,"lassoTrail",new Am(this));v(this,"cursorHints",new Up(this));v(this,"onChangeEmitter",new co);v(this,"onPointerDownEmitter",new co);v(this,"onPointerUpEmitter",new co);v(this,"onUserFollowEmitter",new co);v(this,"onScrollChangeEmitter",new co);v(this,"missingPointerEventCleanupEmitter",new co);v(this,"onRemoveEventListenersEmitter",new co);v(this,"api");v(this,"isToolSupported",(t,o=this.props)=>{if(t==="magicframe"||o.UIOptions.tools?.[t]===!1)return!1;if(this.isInteractionEnabled(o))return!0;let r=typeof o.interaction=="object"&&o.interaction!==null?o.interaction.enabled?.tools:void 0;return t==="laser"?r?.laser===!0:t==="custom"?r?.custom===!0:!1});v(this,"updateEditorAtom",(t,...o)=>{let r=Et.set(t,...o);return this.triggerRender(),r});v(this,"previousHoveredBindableElement",null);v(this,"getEffectiveGridSize",()=>cr(this)?this.state.gridSize:null);v(this,"getTextCreationGridPoint",(t,o)=>{let r=this.getEffectiveGridSize();if(r===null)return null;let i=a=>Math.floor(a/r)*r;return{x:i(t),y:i(o)}});v(this,"handleIframeLikeElementHover",({hitElement:t,scenePointer:o,moveEvent:r})=>t&&dc(t)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(t,r,o.x,o.y))?(this.cursor.set(Me.POINTER),this.setState({activeEmbeddable:{element:t,state:"hover"}}),!0):(this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null}),!1));v(this,"isDoubleClick",(t,o)=>t!=null&&o.timeStamp-t.timeStamp<=oM);v(this,"updateEmbedValidationStatus",(t,o)=>{this.embedsValidationStatus.set(t.id,o),Ei.delete(t)});v(this,"updateEmbeddables",()=>{let t=new Set,o=!1;this.scene.getNonDeletedElements().filter(r=>{if(No(r)){if(t.add(r.id),!this.embedsValidationStatus.has(r.id)){o=!0;let i=bb(r.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(r,i)}}else fb(r)&&t.add(r.id);return!1}),o&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((r,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});v(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);v(this,"frameNameBoundsCache",{get:t=>{let o=this.frameNameBoundsCache._cache.get(t.id);if(!o||o.zoom!==this.state.zoom.value||o.versionNonce!==t.versionNonce){let r=document.getElementById(this.getFrameNameDOMId(t));if(r){let i=r.getBoundingClientRect(),a=ke({clientX:i.x,clientY:i.y},this.state),s=ke({clientX:i.right,clientY:i.bottom},this.state);return o={x:a.x,y:a.y,width:s.x-a.x,height:s.y-a.y,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,o),o}return null}return o},_cache:new Map});v(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});v(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===ic.DARK,o=this.scene.getNonDeletedFramesLikes(),r=o.length>0&&this.state.searchMatches?.focusedId&&Tt(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return o.map(i=>{if(!wM(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:s}=Kp({sceneX:i.x,sceneY:i.y},this.state),l=6,c,d=rX(i);if(i.id===this.state.editingFrame){let m=d;c=Ce("input",{autoFocus:!0,value:m,onChange:p=>{this.scene.mutateElement(i,{name:p.target.value})},onFocus:p=>p.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:p=>{(p.key===X.ESCAPE||p.key===X.ENTER)&&this.resetEditingFrame(i)},style:{background:xY(this.state.viewBackgroundColor,t),zIndex:2,border:"none",display:"block",padding:`${l}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${_o.nameFontSize}px`,transform:`translate(-${l}px, ${l}px)`,color:t?_o.nameColorDarkTheme:_o.nameColorLightTheme,overflow:"hidden",maxWidth:`${document.body.clientWidth-a-l}px`},size:m.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else c=d;return Ce("div",{id:this.getFrameNameDOMId(i),className:gb.FRAME_NAME,style:{position:"absolute",bottom:`${this.state.height+_o.nameOffsetY-s+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:Me.MOVE,pointerEvents:this.state.viewModeEnabled?is.disabled:is.enabled},onPointerDown:m=>this.handleCanvasPointerDown(m),onWheel:m=>this.handleWheel(m),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:c},i.id)})});v(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});v(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());v(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());v(this,"getSceneElements",()=>this.scene.getNonDeletedElements());v(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});v(this,"onExportImage",async(t,o,r)=>{Be("export",t,"ui");let i=await Yr(t,o,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:r.exportingFrame}).catch(EY).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&Pc(i)&&this.setState({fileHandle:i})});v(this,"openEyeDropper",({type:t,swapPreviewOnAlt:o=!0})=>{this.updateEditorAtom(zt,{swapPreviewOnAlt:o,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(r,i)=>{let a=t==="stroke"?!o||!i.altKey:o&&i.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?a?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:r},captureUpdate:Kt.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},captureUpdate:Kt.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?po(l,{[a?"strokeColor":"backgroundColor"]:r}):l),captureUpdate:Kt.IMMEDIATELY})},keepOpenOnAlt:!1})});v(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});v(this,"syncActionResult",Ke(t=>{if(this.unmounted||t===!1)return;this.store.scheduleAction(t.captureUpdate);let o=!1,r=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),o=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||r||this.state.contextMenu){let i=t?.appState?.viewModeEnabled??this.state.viewModeEnabled,a=t?.appState?.theme||this.props.theme||ic.LIGHT,s=t?.appState?.name??this.state.name,l=t?.appState?.errorMessage??this.state.errorMessage;if(typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),this.isInteractionEnabled()||(i=!0),r=t.appState?.editingTextElement||null,t.elements&&r){let c=r.id,d=t.elements.find(m=>m.id===c);r=d&&eu(d)&&Xt(d)?d:null}this.setState(c=>{let d=t.appState||{};return{...c,...d,contextMenu:null,editingTextElement:r,viewModeEnabled:i,zenModeEnabled:!1,theme:a,name:s,errorMessage:l}}),o=!0}o||this.scene.triggerUpdate()}));v(this,"scheduleCapture",()=>this.store.scheduleCapture());v(this,"scheduleUpdate",()=>this.store.scheduleAction(Kt.NEVER));v(this,"onBlur",Ke(()=>{Bo=!1,this.setState({isBindingEnabled:this.state.bindingPreference==="enabled"})}));v(this,"onUnload",()=>{this.onBlur()});v(this,"disableEvent",t=>{t.preventDefault()});v(this,"preventBrowserZoomWheel",t=>{t[X.CTRL_OR_CMD]&&t.preventDefault()});v(this,"handleNavigationModeKeyDown",t=>{if(this.maybeHandlePageScrollKeyDown(t)){t.preventDefault();return}this.actionManager.handleKeyDown(t)});v(this,"maybeHandlePageScrollKeyDown",t=>{if(t.key!==X.PAGE_UP&&t.key!==X.PAGE_DOWN)return!1;let o=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;return t.key===X.PAGE_DOWN&&(o=-o),t.shiftKey?this.viewport.translate(r=>({scrollX:r.scrollX+o})):this.viewport.translate(r=>({scrollY:r.scrollY+o})),!0});v(this,"preventBrowserZoomKeyDown",t=>{t[X.CTRL_OR_CMD]&&(t.code===Tr.EQUAL||t.code===Tr.MINUS||t.code===Tr.ZERO||t.code===Tr.NUM_ADD||t.code===Tr.NUM_SUBTRACT||t.code===Tr.NUM_ZERO)&&t.preventDefault()});v(this,"terminateActiveInteraction",()=>{if(this.maybeCleanupAfterMissingPointerUp(null),Bo=!1,tu=!1,Fo=!1,nu=!1,ls=null,me.pointers.clear(),me.lastCenter=null,me.initialDistance=null,me.initialScale=null,clearTimeout(uc),uc=0,e.resetTapTwice(),this.resetContextMenuTimer(),clearTimeout(ru),ru=0,ou=!1,this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.flowchart.clear(),Et.set(zt,null),Et.set(ro,null),this.state.editingFrame){let t=this.scene.getNonDeletedElement(this.state.editingFrame);this.resetEditingFrame(t&&Tt(t)?t:null)}queueMicrotask(()=>{(!this.isInteractionEnabled()||this.state.viewModeEnabled)&&this.textWysiwygSubmitHandler?.()}),this.setState({contextMenu:null,openMenu:null,openPopup:null,cursorButton:"up",bindMode:"orbit",activeEmbeddable:null,activeLockedId:null,selectedElementsAreBeingDragged:!1,selectionElement:null,resizingElement:null,isResizing:!1,isRotating:!1,isCropping:!1,croppingElementId:null,suggestedBinding:null,frameToHighlight:null,elementsToHighlight:null,snapLines:[],showHyperlinkPopup:!1}),this.deselectElements(),this.isInteractionEnabled()||(this.setState({originSnapOffset:null}),this.cursor.reset())});v(this,"handleInteractionStateChange",(t,o)=>{let r=this.isInteractionEnabled(t),i=r!==this.isInteractionEnabled(),a=t.viewModeEnabled!==this.props.viewModeEnabled,s=this.state.viewModeEnabled;this.isInteractionEnabled()?(a||i)&&(s=!!this.props.viewModeEnabled):s=!0,s!==this.state.viewModeEnabled&&this.setState({viewModeEnabled:s});let l=r&&!o.viewModeEnabled,c=this.isInteractionEnabled()&&!this.state.viewModeEnabled;(i&&!this.isInteractionEnabled()||l&&!c)&&this.terminateActiveInteraction(),i&&this.addEventListeners(),this.isLinksEnabled(t)!==this.isLinksEnabled()&&(this.isLinksEnabled()||(this.hitLinkElement=void 0,im(),this.cursor.reset())),this.isEmbedsEnabled(t)!==this.isEmbedsEnabled()&&(this.isEmbedsEnabled()||this.setState({activeEmbeddable:null})),this.isToolSupported(o.activeTool.type,t)!==this.isToolSupported(this.state.activeTool.type)&&(this.isToolSupported(this.state.activeTool.type)||this.laserTrails.endPath(),this.cursor.reset()),!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)&&this.state.activeTool.type!=="selection"&&this.setState({activeTool:tn(this.state,{type:"selection"})}),(this.isBrowserZoomEnabled(t)!==this.isBrowserZoomEnabled()||this.isNavigationEnabled(t)!==this.isNavigationEnabled())&&(this.addEventListeners(),this.cursor.reset()),o.viewModeEnabled!==this.state.viewModeEnabled&&(this.isInteractionEnabled()&&this.addEventListeners(),this.state.viewModeEnabled||this.deselectElements(),this.cursor.reset())});v(this,"isSameForcedTool",(t,o)=>t?.type===o?.type&&(t?.type==="custom"?t.customType??null:null)===(o?.type==="custom"?o.customType??null:null));v(this,"handleForcedToolChange",(t,o)=>{let r=this.props.activeTool;if(!r)return;let i=!this.isSameForcedTool(t.activeTool,r);if(r.type==="image"){i&&console.warn('"image" tool cannot be forced via "props.activeTool"');return}this.isSameForcedTool(r,this.state.activeTool)||(i||o.activeTool!==this.state.activeTool||this.isToolSupported(r.type,t)!==this.isToolSupported(r.type,this.props))&&this.setActiveTool(r)});v(this,"resetHistory",()=>{this.history.clear()});v(this,"resetStore",()=>{this.store.clear()});v(this,"resetScene",Ke(t=>{this.scene.replaceAllElements([]),this.setState(o=>({...Ho(),isLoading:t?.resetLoadingState?!1:o.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));v(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async l=>{if(!l.files.length)return;let c=l.files[0],d=await c.getFile();this.loadFileToCanvas(new File([d],d.name||"",{type:d.type}),c)}),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}catch(l){console.error(l),t={appState:{errorMessage:l.message||"Encountered an error during importing or restoring scene data"}}}let o=Dr(t?.elements,null,{repairBindings:!0,deleteInvisibleElements:!0}),r=Ti(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,viewModeOnly:this.props.viewModeOnly||r.viewModeOnly,viewModeEnabled:this.props.viewModeOnly||this.props.viewModeEnabled||r.viewModeEnabled,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};let a={...r,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft},s=this.props.initialState?.viewport;if(s){let l=o.filter(m=>!m.isDeleted),c=lc(l),d=this.viewport.resolveInitialViewport(s,c,a);d&&(r={...r,...d})}else t?.scrollToContent&&(r={...r,...wi(o,a)});this.resetStore(),this.resetHistory(),this.syncActionResult({elements:o,appState:r,files:t?.files,captureUpdate:Kt.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(l=>{this.fonts.onLoaded(l)}),DM(window.location.href)&&this.viewport.setViewport({target:window.location.href,fit:"scale-down",animation:!1})});v(this,"getFormFactor",(t,o)=>this.props.UIOptions.getFormFactor?.(t,o)??TY(t,o));v(this,"refreshEditorInterface",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:o,height:r}=t.getBoundingClientRect(),i=kY(),a=JM(typeof navigator<"u"?navigator.userAgent:""),s=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:tY,l=hb(this.editorInterface,{desktopUIMode:i??this.editorInterface.desktopUIMode,formFactor:this.getFormFactor(o,r),userAgent:a,canFitSidebar:o>s,isLandscape:o>r});this.editorInterface=l,this.reconcileStylesPanelMode(l)});v(this,"reconcileStylesPanelMode",t=>{let o=iu(t);if(o===this.stylesPanelMode)return;let r=this.stylesPanelMode;this.stylesPanelMode=o,this.viewport.invalidateUIOffset("stylesPanel"),r!=="full"&&o==="full"&&this.setState(i=>({preferredSelectionTool:{type:"selection",initialized:!0}}))});v(this,"setDesktopUIMode",t=>{let o=MY(t);this.editorInterface=hb(this.editorInterface,{desktopUIMode:o}),this.reconcileStylesPanelMode(this.editorInterface)});v(this,"onResize",Ke(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>Ei.delete(t)),this.refreshEditorInterface(),this.updateDOMRect(),this.setState({})}));v(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});v(this,"renderInteractiveSceneCallback",({scrollBars:t})=>{t&&(gc=t),this.scheduleImageRefresh()});v(this,"onScroll",aM(()=>{let{offsetTop:t,offsetLeft:o}=this.getCanvasOffsets();this.setState(r=>r.offsetLeft===o&&r.offsetTop===t?null:{offsetTop:t,offsetLeft:o})},nY));v(this,"onCut",Ke(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||ac(t.target)||(this.actionManager.executeAction(tm,"keyboard",t),t.preventDefault(),t.stopPropagation())}));v(this,"onCopy",Ke(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||ac(t.target)||(this.actionManager.executeAction(sa,"keyboard",t),t.preventDefault(),t.stopPropagation())}));v(this,"onTouchStart",t=>{if(this.isInteractionEnabled()){if(SY&&t.preventDefault(),!pc){pc=!0,t.touches.length===1&&(hc={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(uc),uc=window.setTimeout(e.resetTapTwice,oM);return}if(pc&&t.touches.length===1&&hc){let o=t.touches[0];so(oe(o.clientX,o.clientY),oe(hc.x,hc.y))<=dM&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:o.clientX,clientY:o.clientY,type:"touch",altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1})),pc=!1,clearTimeout(uc)}t.touches.length===2&&this.setState({selectedElementIds:Ae({},this.state),activeEmbeddable:null})}});v(this,"onTouchEnd",t=>{this.isInteractionEnabled()&&(this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:Ae(this.state.previousSelectedElementIds,this.state)}):me.pointers.clear())});v(this,"pasteFromClipboard",Ke(async t=>{if(!this.isInteractionEnabled())return;let o=!!ou,r=document.activeElement,i=this.excalidrawContainerRef.current?.contains(r);if(t&&!i)return;let a=document.elementFromPoint(this.viewport.lastPosition.x,this.viewport.lastPosition.y);if(t&&(!(a instanceof HTMLCanvasElement)||ac(r)))return;let s=await Wr(t),l=s.getFiles(),c=await Vd(s,o);if(this.state.viewModeEnabled){if(!this.containsImagePaste(c,l,o))return;if(!this.shouldInsertImageInViewMode({source:"paste",files:l.map(d=>d.file),data:c,event:t})){t?.preventDefault();return}}if(this.props.onPaste)try{if(await this.props.onPaste(c,t)===!1)return}catch(d){console.error(d)}await this.insertClipboardContent(c,l,o),this.setActiveTool({type:this.state.preferredSelectionTool.type},{keepSelection:!0}),t?.preventDefault()}));v(this,"addElementsFromPasteOrLibrary",t=>{let o=Dr(t.elements,null,{deleteInvisibleElements:!0}),[r,i,a,s]=ss(o),l=as(r,a)/2,c=as(i,s)/2,d=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.viewport.lastPosition.x:this.state.width/2+this.state.offsetLeft,m=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.viewport.lastPosition.y:this.state.height/2+this.state.offsetTop,{x:p,y:u}=ke({clientX:d,clientY:m},this.state),E=p-l,g=u-c,[b,y]=Mt(E,g,this.getEffectiveGridSize()),{duplicatedElements:w}=EM({type:"everything",elements:o.map(A=>po(A,{x:A.x+b-r,y:A.y+y-i})),randomizeSeed:!t.retainSeed,preserveFrameChildrenOrder:t.preserveFrameChildrenOrder}),x=this.scene.getElementsIncludingDeleted(),I=[...x,...w];I=this.props.onDuplicate?.(I,x)||I,NM(I,lc(w));let C=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(C){let A=iX(w,C);I=Ib(I,A,C)}this.scene.replaceAllElements(I),w.forEach(A=>{if(Xt(A)&&xM(A)){let D=SM(A,this.scene.getElementsMapIncludingDeleted());qY(A,D,this.scene)}}),PY&&go.loadElementsFonts(w).then(A=>{this.fonts.onLoaded(A)}),t.files&&this.addMissingFiles(t.files);let P=wX(w);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.editorInterface.canFitSidebar&&Et.get(eb)?this.state.openSidebar:null,...BM(P,this.scene.getNonDeletedElements(),this.state)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:this.state.preferredSelectionTool.type},{keepSelection:!0}),t.fit&&this.viewport.setViewport({target:w,fit:t.fit,animation:!1,offsets:{ui:!0}})});v(this,"addElementsFromPaste",t=>{this.addElementsFromPasteOrLibrary({...t,fit:t.fitToContent?"contain":void 0})});v(this,"setAppState",(t,o)=>{let r=a=>!a||!this.state.viewModeOnly?a:{...a,viewModeOnly:!0,viewModeEnabled:!0},i=typeof t=="function"?(a,s)=>r(t(a,s)):r(t);this.setState(i,o)});v(this,"removePointer",t=>{Pr&&this.resetContextMenuTimer(),t.type==="pointercancel"&&this.bucketFill.cancel();let o=me.pointers.size>=2;me.pointers.delete(t.pointerId),o&&me.pointers.size<2&&this.state.scrollConstraints&&this.viewport.releaseOverscroll()});v(this,"toggleLock",(t="ui")=>{this.props.activeTool||(this.state.activeTool.locked||Be("toolbar","toggleLock",`${t} (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),this.setState(o=>({activeTool:{...o.activeTool,...tn(this.state,o.activeTool.locked?{type:this.state.preferredSelectionTool.type}:o.activeTool),locked:!o.activeTool.locked}})))});v(this,"updateFrameRendering",t=>{this.setState(o=>{let r=typeof t=="function"?t(o.frameRendering):t;return{frameRendering:{enabled:r?.enabled??o.frameRendering.enabled,clip:r?.clip??o.frameRendering.clip,name:r?.name??o.frameRendering.name,outline:r?.outline??o.frameRendering.outline}}})});v(this,"togglePenMode",t=>{this.setState(o=>({penMode:t??!o.penMode,penDetected:!0,currentItemStrokeVariability:o.penDetected?o.currentItemStrokeVariability:"variable"}))});v(this,"revealIfHidden",t=>{!t.length||XY(t,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.viewport.getOffsets())||this.viewport.setViewport({target:ss(t),fit:"scale-down",animation:{duration:300},offsets:{ui:!0}})});v(this,"scrollToViewport",(t,o)=>{this.setState({scrollX:t.scrollX,scrollY:t.scrollY,zoom:{value:Yn(t.zoom)},shouldCacheIgnoreZoom:!1})});v(this,"scrollToContent",(t,o)=>{this.viewport.setViewport({target:t??this.scene.getNonDeletedElements(),fit:o?.fitToViewport?"contain":"scale-down",animation:o?.animate?{duration:o.duration??500}:!1,offsets:{ui:!0}})});v(this,"emitUserFollowIntent",t=>{this.onUserFollowEmitter.trigger(t),this.props.onUserFollow?.(t)});v(this,"requestUnfollow",()=>{this.props.userToFollow&&this.emitUserFollowIntent({userToFollow:this.props.userToFollow,action:"UNFOLLOW"})});v(this,"setToast",t=>{this.setState({toast:t})});v(this,"restoreFileFromShare",async()=>{try{let t=await caches.open("web-share-target"),o=await t.match("shared-file");if(o){let r=await o.blob(),i=new File([r],r.name||"",{type:r.type});this.loadFileToCanvas(i,null),await t.delete("shared-file"),window.history.replaceState(null,$V,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});v(this,"addFiles",Ke(t=>{let o=new Map;for(let s of t){let l=s.id,c=this.imageCache.get(l);c&&!this.files[l]&&o.set(l,Promise.resolve(c.image))}let{addedFiles:r}=this.addMissingFiles(t);this.clearImageShapeCache(r),this.scene.triggerUpdate();let i=new Set(o.keys());xb({imageCache:this.imageCache,fileIds:Array.from(i),files:this.files,onImageCacheUpdate:s=>this.handleImageCacheUpdate(s),gifAutoDecodeMaxFileSizeBytes:this.props.imageOptions.gifAutoDecodeMaxFileSizeBytes}).then(async({updatedFiles:s})=>{for(let[l,c]of o){let d=this.imageCache.get(l);!d||!s.has(l)||(this.imageCache.set(l,{...d,placeholderImage:await c,transitionStart:performance.now()}),this.clearImageLoadingProgress(l))}i.size&&this.imagePlaceholderUpdateEmitter.trigger()}),i.size||this.addNewImagesToImageCache()}));v(this,"addImageElementsToScene",async(t,o,r)=>{let i=await Promise.all(t.map(async({file:s,customData:l})=>({file:await Lr(s),customData:l??{}}))),a=i.find(({file:s})=>!Si(s));if(a)throw new Eu(a.file,f("errors.unsupportedFileType"));await this.insertImages(i.map(({file:s})=>s),o,r,i.map(({customData:s})=>s))});v(this,"addImagePlaceholder",async(t,o)=>{if(this.files[t])return;let r=await Lr(o);if(!Si(r))throw new Error(f("errors.unsupportedFileType"));let i=new Image,a=new Promise((l,c)=>{i.onload=()=>l(i),i.onerror=()=>c(new Error(f("errors.imageInsertError")))}),s={image:a,mimeType:r.type,isPlaceholder:!0,gifDecodeStatus:r.type===lo.gif?"pending":void 0};this.imageCache.set(t,s),s.gifDecodeStatus==="pending"&&this.imagePlaceholderUpdateEmitter.trigger(),i.src=await kc(r);try{let l=await a;if(this.imageCache.get(t)!==s||this.files[t])return;this.imageCache.set(t,{...s,image:l}),this.clearImageShapeCacheForFileId(t),this.imagePlaceholderUpdateEmitter.trigger()}catch(l){throw this.imageCache.get(t)===s&&(this.imageCache.delete(t),this.imagePlaceholderUpdateEmitter.trigger()),l}});v(this,"setDownloadProgress",(t,o)=>{if(o===null){this.clearImageLoadingProgress(t);return}if(!Number.isFinite(o))return;let r=oc(o,0,1);this.imageLoadingProgress.get(t)!==r&&(this.imageLoadingProgress.set(t,r),this.imageLoadingProgressEmitter.trigger())});v(this,"setDownloadError",(t,o)=>{this.updateImageStatus(t,r=>({...r,downloadError:o===!0?{}:o||null}))});v(this,"setUploadProgress",(t,o,r)=>{if(o===null){this.updateImageStatus(t,i=>({...i,uploadProgress:null}));return}typeof o=="number"&&!Number.isFinite(o)||this.updateImageStatus(t,i=>{let a=i?.uploadProgress??void 0,s=r===void 0?a:r??void 0,l=typeof o=="number";return{...i,uploadProgress:{...s,state:l?"uploading":o,...l?{progress:oc(o,0,1)}:{progress:void 0}}}})});v(this,"updateImageStatus",(t,o)=>{let r=this.imageStatus.get(t),i=o(r);this.areImageStatusesEqual(r,i)||(i.downloadError===void 0&&!i.uploadProgress?this.imageStatus.delete(t):this.imageStatus.set(t,i),this.imageStatusEmitter.trigger())});v(this,"areImageStatusesEqual",(t,o)=>!!t?.downloadError==!!o?.downloadError&&!!t?.uploadProgress==!!o?.uploadProgress&&t?.downloadError?.backgroundColor===o?.downloadError?.backgroundColor&&t?.downloadError?.color===o?.downloadError?.color&&t?.downloadError?.trackColor===o?.downloadError?.trackColor&&t?.downloadError?.text===o?.downloadError?.text&&t?.downloadError?.onClick===o?.downloadError?.onClick&&t?.uploadProgress?.backgroundColor===o?.uploadProgress?.backgroundColor&&t?.uploadProgress?.color===o?.uploadProgress?.color&&t?.uploadProgress?.trackColor===o?.uploadProgress?.trackColor&&t?.uploadProgress?.state===o?.uploadProgress?.state&&t?.uploadProgress?.text===o?.uploadProgress?.text&&t?.uploadProgress?.onClick===o?.uploadProgress?.onClick&&t?.uploadProgress?.progress===o?.uploadProgress?.progress);v(this,"clearImageLoadingProgress",t=>{this.imageLoadingProgress.delete(t)&&this.imageLoadingProgressEmitter.trigger()});v(this,"clearImageShapeCacheForFileId",t=>{for(let o of this.scene.getNonDeletedElements())fi(o)&&o.fileId===t&&Ei.delete(o)});v(this,"addMissingFiles",(t,o=!1)=>{let r=o?{}:{...this.files},i={},a=Array.isArray(t)?t:Object.values(t);for(let s of a)if(!r[s.id]&&(i[s.id]=s,r[s.id]=s,s.mimeType===lo.svg))try{let l=fx(TM(Ex(s.dataURL)),lo.svg);s.dataURL!==l&&(s.version=(s.version??1)+1,s.dataURL=l)}catch(l){console.error(l)}return this.files=r,{addedFiles:i}});v(this,"updateScene",Ke(t=>{let{elements:o,appState:r,collaborators:i,captureUpdate:a}=t;if(a){let s=o||void 0,l=r?DY({...this.store.snapshot.appState,...r}):void 0;this.store.scheduleMicroAction({action:a,elements:s,appState:l})}r&&this.setState(r),o&&this.scene.replaceAllElements(o),i&&(this.laserTrails.updateCollabTrails(i),this.setState({collaborators:i}))}));v(this,"applyDeltas",(t,o)=>{let r=UM.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return UM.applyTo(r,a,i,o)});v(this,"mutateElement",(t,o,r=!0)=>this.scene.mutateElement(t,o,{informMutation:r,isDragging:!1}));v(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});v(this,"toggleSidebar",({name:t,tab:o,force:r})=>{let i;r===void 0?i=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===o?null:t:i=r?t:null;let a=i?{name:i}:null;return a&&o&&(a.tab=o),this.setState({openSidebar:a}),!!i});v(this,"updateCurrentCursorPosition",Ke(t=>{this.viewport.lastPosition.x=t.clientX,this.viewport.lastPosition.y=t.clientY}));v(this,"onKeyDown",Ke(t=>{if(!this.isInteractionEnabled())return;if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(l,c){let d=l[c];return typeof d=="function"?d.bind(l):c==="key"?t.shiftKey?l.key.toUpperCase():l.key.toLowerCase():d}})),!sM(t.target)){if((t.key===X.ESCAPE||t.key===X.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let l=ce(this.scene.getNonDeletedElementsMap(),this.state);if(l.length===1&&Hn(l[0])&&t.key===X.ENTER){this.startImageCropping(l[0]);return}if(t.key===X.ESCAPE)this.updateEditorAtom(ro,null);else if(t.key===X.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(gb.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let c=Xm(l);Et.get(ro)?.type==="panel"&&Yf(this,{conversionType:c,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),c&&this.updateEditorAtom(ro,{type:"panel"})}if(this.flowchart.handleKeyEvent(t))return}if(t[X.CTRL_OR_CMD]&&t.key.toLowerCase()===X.V&&(ou=t.shiftKey,clearTimeout(ru),ru=window.setTimeout(()=>{ou=!1},100)),t[X.CTRL_OR_CMD]&&ac(t.target)&&(t.code===Tr.MINUS||t.code===Tr.EQUAL)){t.preventDefault();return}if(ac(t.target)&&t.key!==X.ESCAPE||db(t.key)&&sM(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(this.maybeHandlePageScrollKeyDown(t)){t.preventDefault();return}if(this.state.openDialog?.name==="elementLinkSelector")return;if(t.key===X.ALT)if(this.state.activeTool.type==="bucketfill"){this.bucketFill.openTemporaryEyeDropper(),t.preventDefault();return}else Ro("COMPLEX_BINDINGS")?this.handleSkipBindMode():Qp({app:this,event:t});if(this.actionManager.handleKeyDown(t))return;let o=this.props.viewModeEnabled===!0;if(!o&&this.state.viewModeEnabled&&t.key===X.ESCAPE){this.setActiveTool({type:"selection"});return}if(!o&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let l=Wy(t.key,this,t.shiftKey);if(this.state.viewModeEnabled&&!mM(l,["laser","hand"]))return;if(l){if(this.state.activeTool.type!==l&&Be("toolbar",l,`keyboard (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),l==="arrow"&&this.state.activeTool.type==="arrow"){let c=this.state.currentItemArrowType===Sr.sharp?Sr.round:this.state.currentItemArrowType===Sr.round?Sr.elbow:Sr.sharp;this.setState({currentItemArrowType:c}),this.cursorHints.onArrowTypeCycled(c)}else(l==="arrow"||l==="line")&&this.cursorHints.onToolShortcut(l,/^\d$/.test(t.key)?"digit":"letter");l==="bucketfill"&&this.state.activeTool.type==="bucketfill"?this.bucketFill.cycleBackgroundColor():l==="lasso"&&this.state.activeTool.type==="laser"?this.setActiveTool({type:this.state.preferredSelectionTool.type}):this.setActiveTool({type:l},{toggle:!0}),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&&(Ro("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),Ft(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.arrowText.refresh(),Qp({app:this,event:t})),db(t.key)){let l=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),c=new Set;l.filter(u=>uo(u)).filter(u=>{let E=u.startBinding&&!l.some(b=>b.id===u.startBinding?.elementId),g=u.endBinding&&!l.some(b=>b.id===u.endBinding?.elementId);return E||g}).forEach(u=>c.add(u.id)),l=l.filter(u=>!c.has(u.id));let d=this.getEffectiveGridSize()&&(t.shiftKey?nM:this.getEffectiveGridSize())||(t.shiftKey?JV:nM),m=0,p=0;t.key===X.ARROW_LEFT?m=-d:t.key===X.ARROW_RIGHT?m=d:t.key===X.ARROW_UP?p=-d:t.key===X.ARROW_DOWN&&(p=d),l.forEach(u=>{this.scene.mutateElement(u,{x:u.x+m,y:u.y+p},{informMutation:!1,isDragging:!1}),jp(u,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 c=l[0];if(t[X.CTRL_OR_CMD]||Cb(c))Ot(c)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==c.id)&&(this.store.scheduleCapture(),Yt(c)||this.actionManager.executeAction(ba));else if(Xt(c)||CM(c)){let d;Xt(c)||(d=c);let m=wb(c,this.scene.getNonDeletedElementsMap()),p=m.x,u=m.y;this.startTextEditing({sceneX:p,sceneY:u,container:d}),t.preventDefault();return}else Tt(c)&&this.setState({editingFrame:c.id})}}if(t.key===X.SPACE&&me.pointers.size===0&&(Bo=!0,this.cursor.set(Me.GRAB),t.preventDefault()),t.key.toLowerCase()===X.Z&&!t[X.CTRL_OR_CMD]&&!t.altKey&&!t.shiftKey&&(tu=!0,this.cursor.set("zoom-in"),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&&(Go(this.state.activeTool.type)||l.some(c=>Go(c.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(c=>Xt(c)||yb(c,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}let r=t.key.toLocaleLowerCase(),i=r===X.I&&!t.shiftKey&&!t[X.CTRL_OR_CMD],a=r===X.S&&t.shiftKey&&!t[X.CTRL_OR_CMD]||i,s=r===X.I&&t.shiftKey&&!t[X.CTRL_OR_CMD];(a||s)&&this.openEyeDropper({type:a?"stroke":"background",swapPreviewOnAlt:!i})}));v(this,"onKeyUp",Ke(t=>{if(this.isInteractionEnabled()){if(t.key===X.SPACE&&(this.state.viewModeEnabled&&this.state.activeTool.type!=="laser"||this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(Me.GRAB):$p(this.state.activeTool.type)?this.cursor.reset():(this.cursor.applyForTool(),this.setState({selectedElementIds:Ae({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Bo=!1),t.key.toLowerCase()===X.Z&&(tu=!1,this.cursor.reset()),t.key===X.ALT&&(this.bucketFill.closeTemporaryEyeDropper(),Qp({app:this,event:t})),(t.key===X.ALT&&this.state.bindMode==="skip"||!t[X.CTRL_OR_CMD]&&!Zp(this.state))&&(this.setState({bindMode:"orbit"}),this.lastPointerMoveEvent&&Ro("COMPLEX_BINDINGS"))){let o=ke({clientX:this.lastPointerMoveEvent.clientX,clientY:this.lastPointerMoveEvent.clientY},this.state),r=Cr(oe(o.x,o.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(this.state.selectedLinearElement){let i=ge.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());uo(i)&&this.handleDelayedBindModeChange(i,r)}}if(!t[X.CTRL_OR_CMD]){let o=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==o&&(Ft(()=>{this.setState({isBindingEnabled:o})}),this.arrowText.refresh()),Qp({app:this,event:t})}if(db(t.key)){uM(this.scene.getSelectedElements(this.state).filter(cc),this.scene,this.state);let o=this.scene.getNonDeletedElementsMap();this.scene.getSelectedElements(this.state).filter(Pb).forEach(r=>{r.startBinding&&this.scene.mutateElement(r,{startBinding:{...r.startBinding,...VM(r,o.get(r.startBinding.elementId),"start",o)}}),r.endBinding&&this.scene.mutateElement(r,{endBinding:{...r.endBinding,...VM(r,o.get(r.endBinding.elementId),"end",o)}})}),this.setState({suggestedBinding:null})}this.flowchart.handleKeyEvent(t)}}));v(this,"setActiveTool",(t,o={})=>{let{keepSelection:r=!1}=o;if(!this.isToolSupported(t.type)){console.warn(this.isInteractionEnabled()?`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`:`"${t.type}" tool cannot be activated while the editor is non-interactive (see "interaction.enabled.tools")`);return}if(this.props.activeTool&&!this.isSameForcedTool(this.props.activeTool,t)){console.warn(`"${t.type}" tool activation ignored \u2014 the active tool is controlled by the host via "props.activeTool"`);return}this.drawShape.hasPendingGesture()&&this.actionManager.executeAction(ut);let i=qi.includes(t.type),s=o.toggle===!0&&i&&this.state.activeTool.type===t.type?tn(this.state,{...this.state.activeTool.lastActiveTool||{type:this.state.preferredSelectionTool.type},lastActiveTool:null}):i&&this.state.activeTool.type!==t.type?tn(this.state,{...t,lastActiveTool:this.state.activeTool}):tn(this.state,t);s.type==="hand"?this.cursor.set(Me.GRAB):Bo||this.cursor.applyForTool(s),hY(document.activeElement)&&this.focusContainer(),WY(s.type)||this.setState({suggestedBinding:null}),s.type==="image"&&this.onImageToolbarButtonClick(),this.setState(l=>{let c={snapLines:l.snapLines.length?[]:l.snapLines,originSnapOffset:null,activeEmbeddable:null,selectedLinearElement:$p(s.type)?l.selectedLinearElement:null,frameToHighlight:null,hoveredArrowTextAnchor:null};return s.type==="freedraw"&&this.store.scheduleCapture(),s.type==="lasso"?{...l,...c,activeTool:s,...r?{}:{selectedElementIds:Ae({},l),selectedGroupIds:Ae({},l),editingGroupId:null,multiElement:null}}:s.type!=="selection"?{...l,...c,activeTool:s,selectedElementIds:Ae({},l),selectedGroupIds:Ae({},l),editingGroupId:null,multiElement:null}:{...l,...c,activeTool:s}})});v(this,"setOpenDialog",t=>{this.setState({openDialog:t})});v(this,"isTouchScreenMultiTouchGesture",()=>me.pointers.size>=2);v(this,"getName",()=>this.state.name||this.props.name||`${f("labels.untitled")}-${lM()}`);v(this,"onGestureStart",Ke(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:Ae({},this.state),activeEmbeddable:null}),me.initialScale=this.state.zoom.value)}));v(this,"onGestureChange",Ke(t=>{if(!this.isNavigationEnabled()||(t.preventDefault(),this.isTouchScreenMultiTouchGesture()))return;let o=me.initialScale;o&&this.viewport.translate(r=>({...ho({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:Yn(o*t.scale)},r)}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})}));v(this,"onGestureEnd",Ke(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:Ae(this.state.previousSelectedElementIds,this.state)}),me.initialScale=null)}));v(this,"isHittingTextAutoResizeHandle",(t,o)=>{let r=$M(t,this.state);return!!(r&&!r.isDeleted&&!r.autoResize&&z2(o,r,this.state.zoom.value,this.editorInterface.formFactor))});v(this,"handleTextAutoResizeHandlePointerDown",(t,o)=>{let r=$M(t,this.state);return!r||!this.isHittingTextAutoResizeHandle(t,o)?!1:(this.actionManager.executeAction(jg,"ui",r),this.cursor.reset(),!0)});v(this,"startTextEditing",({sceneX:t,sceneY:o,insertAtParentCenter:r=!0,container:i,autoEdit:a=!0,initialCaretSceneCoords:s,arrowEndpoint:l})=>{let c=!1,d=l&&this.arrowText.getTextBinding(l,this.getCurrentItemStrokeWidth("text"));d&&(i=null,r=!1,t=d.anchor[0],o=d.anchor[1]);let m=r&&this.getTextWysiwygSnappedToCenterPosition(t,o,this.state,i);i&&m&&(yb(i,this.scene.getNonDeletedElementsMap())||(c=!0));let p=d?null:this.getSelectedTextElement(i)||this.getTextElementAtPosition(t,o),u=p?.fontFamily||this.state.currentItemFontFamily,E=p?.lineHeight||iM(u),g=this.state.currentItemFontSize;if(!p&&c&&i&&!cc(i)){let C=uX(pb({fontSize:g,fontFamily:u}),E),P=hX(g,E),A=Math.max(i.height,P),D=Math.max(i.width,C);this.scene.mutateElement(i,{height:A,width:D}),t=i.x+D/2,o=i.y+A/2,m&&(m=this.getTextWysiwygSnappedToCenterPosition(t,o,this.state,i))}let b=this.getTextCreationGridPoint(t,o),y=d?{x:t,y:o}:m?{x:m.elementCenterX,y:m.elementCenterY}:p?{x:t,y:o}:{x:b?.x??t,y:b===null?o-_M(g,E)/2:b.y},w=this.getTopLayerFrameAtSceneCoords({x:y.x,y:y.y}),x=w&&(!c||!i||i.frameId===w.id)?w.id:null,I=p||gM({x:y.x,y:y.y,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("text"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:g,fontFamily:u,textAlign:d?.textAlign??(m?"center":this.state.currentItemTextAlign),verticalAlign:d?.verticalAlign??(m?iY.MIDDLE:eM),containerId:c?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:E,angle:i?cc(i)?0:i.angle:0,frameId:x});if(!p&&c&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:I.id})}),this.setState({editingTextElement:I}),!p)if(i&&c){let T=this.scene.getElementIndex(i.id);this.scene.insertElementsAtIndex([I],T+1)}else this.insertNewElement(I);l&&d&&this.arrowText.bindText(l,I,d.fixedPoint),a||p||i?this.handleTextWysiwyg(I,{isExistingElement:!!p,initialCaretSceneCoords:p?s:null}):this.setState({newElement:I,multiElement:null})});v(this,"startImageCropping",t=>{this.store.scheduleCapture(),this.setState({croppingElementId:t.id})});v(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});v(this,"shouldHandleBrowserCanvasDoubleClick",t=>{if(t==="touch"||this.lastCompletedCanvasClicks.length===0)return!0;if(this.lastCompletedCanvasClicks.length<2)return!1;let[o,r]=this.lastCompletedCanvasClicks;return so(oe(o.x,o.y),oe(r.x,r.y))<=dM});v(this,"handleCanvasDoubleClick",t=>{if(!this.isInteractionEnabled()||this.state.editingTextElement||!this.shouldHandleBrowserCanvasDoubleClick(t.type)||this.state.multiElement||this.state.activeTool.type!==this.state.preferredSelectionTool.type&&this.state.activeTool.type!=="autoshape")return;let o=this.scene.getSelectedElements(this.state),{x:r,y:i}=ke(t,this.state);if(o.length===1&&Ot(o[0])){let s=o[0];if((t[X.CTRL_OR_CMD]&&Pb(s)||Cb(s))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==s.id)){this.actionManager.executeAction(ba);return}else if(this.state.selectedLinearElement&&Yt(o[0])){let l=ge.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),c=l?ge.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,l,this.scene.getNonDeletedElementsMap()):-1;if(c&&c>-1){this.store.scheduleCapture(),ge.deleteFixedSegment(o[0],this.scene,c);let d=ge.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),m=d?ge.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,d,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,segmentMidpoint:{index:m,value:l,added:!1}},segmentMidPointHoveredCoords:d}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===s.id&&Cb(s))return}if(o.length===1&&Hn(o[0])){this.startImageCropping(o[0]);return}if(this.cursor.reset(),xX(this.state).length>0){let s=this.getElementAtPosition(r,i),l=s&&bX(s,this.state.selectedGroupIds);if(l){this.store.scheduleCapture(),this.setState(c=>({...c,...Un({editingGroupId:l,selectedElementIds:{[s.id]:!0}},this.scene.getNonDeletedElements(),c,this)}));return}}if(this.cursor.reset(),!this.state.viewModeEnabled){let s=this.getElementAtPosition(r,i);if(dc(s)){this.setState({activeEmbeddable:{element:s,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){let l=!t[X.CTRL_OR_CMD]&&this.getTextBindableContainerAtPosition(r,i);if(l&&(this.state.activeTool.type==="autoshape"||bM(l)||!fY(l.backgroundColor)||mc({point:oe(r,i),element:l,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(l)}))){let c=wb(l,this.scene.getNonDeletedElementsMap());r=c.x,i=c.y}this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:l||null})}}});v(this,"handleCanvasClick",t=>{if(!this.isInteractionEnabled())return;if(t.button!==zn.MAIN){this.lastCompletedCanvasClicks=[];return}let o=ke(t,this.state),r=this.getImageStatusActionAtPosition(o);if(r){t.preventDefault(),t.stopPropagation(),r();return}this.lastCompletedCanvasClicks=[...this.lastCompletedCanvasClicks.slice(-1),{x:t.clientX,y:t.clientY}]});v(this,"getImageStatusActionAtPosition",t=>{if(!this.imageStatus.size)return null;let o=this.scene.getNonDeletedElementsMap(),r=this.visibleElements.length?this.visibleElements:this.scene.getNonDeletedElements();for(let i=r.length-1;i>=0;i--){let a=r[i];if(!Hn(a)||!a.fileId)continue;let s=this.imageStatus.get(a.fileId),l=s?.uploadProgress?.onClick;if(l&&this.isPointInsideImageStatusOverlay(t,a,o,"top-right"))return()=>l(a.fileId);let c=s?.downloadError?.onClick;if(c&&this.isPointInsideImageStatusOverlay(t,a,o,"center"))return()=>c(a.fileId)}return null});v(this,"isPointInsideImageStatusOverlay",(t,o,r,i)=>{let a=Dl(o,r,this.state,i);return!!a&&so(oe(t.x,t.y),oe(a.centerX,a.centerY))<=a.radius+2/this.state.zoom.value});v(this,"getElementLinkAtPosition",(t,o)=>{if(o&&o.locked)return;let r=this.scene.getNonDeletedElements(),i=-1;for(let a=r.length-1;a>=0;a--){let s=r[a];if(o&&s.id===o.id&&(i=a),s.link&&a>=i&&Ic(s,this.scene.getNonDeletedElementsMap(),this.state,oe(t.x,t.y),this.editorInterface.formFactor==="phone"))return s}});v(this,"getElementLinkAtPositionForContextMenu",(t,o)=>{let r=this.getElementLinkAtPosition(t,o);if(r)return r;let i=this.scene.getNonDeletedElementsMap();for(let a of this.scene.getNonDeletedElements().slice().reverse())if(a.link&&!a.locked&&sx(a,i,this.state,oe(t.x,t.y)))return a});v(this,"handleElementLinkClick",t=>{let o=d=>d===zn.MAIN||d===zn.TOUCH;if(!o(this.lastPointerDownEvent.button)||!o(this.lastPointerUpEvent.button))return;let r=so(oe(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),oe(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||r>tM)return;let i=ke(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),s=Ic(this.hitLinkElement,a,this.state,oe(i.x,i.y),this.editorInterface.formFactor==="phone"),l=ke(this.lastPointerUpEvent,this.state),c=Ic(this.hitLinkElement,a,this.state,oe(l.x,l.y),this.editorInterface.formFactor==="phone");s&&c&&(im(),this.openElementLink(this.hitLinkElement,t))});v(this,"openElementLink",(t,o)=>{let r=t.link;if(!r)return;r=Xp(r);let i;if(this.props.onLinkOpen&&o&&(i=gY(J.EXCALIDRAW_LINK,o.nativeEvent),this.props.onLinkOpen({...t,link:r},i)),!i?.defaultPrevented){let a=mY(r)?"_self":"_blank",s=window.open(void 0,a);s&&(s.opener=null,s.location=r)}});v(this,"applyElementLinkHoverAffordance",()=>this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(this.cursor.set(Me.POINTER),hv(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap()),!0):(im(),!1));v(this,"maybeHandleElementLinkClick",(t,o)=>{if(this.editorInterface.isTouchScreen){let r=this.getElementAtPosition(o.x,o.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(o,r)}return this.hitLinkElement&&this.lastPointerDownEvent&&!this.state.selectedElementIds[this.hitLinkElement.id]?(this.handleElementLinkClick(t),!0):!1});v(this,"handleInteractiveContentPointerMove",t=>{let o=ke(t,this.state),r=this.getElementAtPosition(o.x,o.y,{includeLockedElements:!0});if(this.isEmbedsEnabled()){let i=r?.locked?null:r;if(this.handleIframeLikeElementHover({hitElement:i,scenePointer:o,moveEvent:t}))return}this.hitLinkElement=this.isLinksEnabled()?this.getElementLinkAtPosition(o,r):void 0,this.applyElementLinkHoverAffordance()||this.cursor.reset()});v(this,"handleInteractiveContentPointerUp",t=>{if(this.lastPointerUpEvent=t,this.isEmbedsEnabled()&&this.handleIframeLikeCenterClick())return;let o=ke(t,this.state);this.isLinksEnabled()&&this.maybeHandleElementLinkClick(t,o)||this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});v(this,"getTopLayerFrameAtSceneCoords",(t,o)=>{let r=this.scene.getNonDeletedElementsMap(),i=this.scene.getNonDeletedFramesLikes().filter(l=>!l.locked&&kM(t,l,r));if(!i.length)return null;let a=i.at(-1),s=this.getElementsAtPosition(t.x,t.y,{includeLockedElements:!0}).findLast(l=>!o?.excludeElementIds?.[l.id]);if(s){if(Tt(s)&&!s.locked)return a;let l=this.scene.getElementIndex(s.id),c=this.scene.getElementIndex(a.id);if(l!==-1&&c!==-1&&l<=c)return a;let d=o?.currentFrameId?i.find(m=>m.id===o.currentFrameId)??null:null;return d||(s.frameId?i.find(m=>m.id===s.frameId)??null:null)}return a});v(this,"updateFrameToHighlight",t=>{this.state.frameToHighlight!==t&&this.setState({frameToHighlight:t})});v(this,"maybeUpdateFrameToHighlightOnPointerMove",(t,o)=>{this.state.newElement||this.state.multiElement||this.state.selectionElement||this.state.selectedElementsAreBeingDragged||this.updateFrameToHighlight(!o&&FX(this.state.activeTool.type)?this.getTopLayerFrameAtSceneCoords(t):null)});v(this,"insertNewElements",t=>{if(!t.length)return;let o=[];for(let r of t){let i=o[o.length-1];i?.[0].frameId===r.frameId?i.push(r):o.push([r])}for(let r of o){let i=r[0].frameId,a=i?QY(this.scene.getElementsIncludingDeleted(),i):null;this.scene.insertElementsAtIndex(r,a)}});v(this,"insertNewElement",t=>{this.insertNewElements([t]);let o=t.frameId?this.scene.getNonDeletedElement(t.frameId):null;this.updateFrameToHighlight(o&&Tt(o)?o:null)});v(this,"updateZDragZoom",t=>{if(!this.zDragZoom)return;let{origin:o,initialZoom:r}=this.zDragZoom,i=t.clientX-o.clientX,a=Yn(r*Math.max(.1,1+i/100));this.viewport.translate(s=>({...ho({viewportX:o.clientX,viewportY:o.clientY,nextZoom:a},s),shouldCacheIgnoreZoom:!0}),{zoomPreConstrained:!0}),this.resetShouldCacheIgnoreZoomDebounced()});v(this,"handleCanvasPointerMove",t=>{if(!this.isInteractionEnabled()){this.isToolSupported(this.state.activeTool.type)&&this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.isNavigationEnabled()&&this.updateMultiTouchGesture(t),(this.isLinksEnabled()||this.isEmbedsEnabled())&&!Fo&&this.handleInteractiveContentPointerMove(t);return}this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent;let o=ke(t,this.state),{x:r,y:i}=o;if(this.lastPointerMoveCoords={x:r,y:i},this.zDragZoom){this.updateZDragZoom(t);return}if(this.updateMultiTouchGesture(t),Bo||Fo||nu||ps(this.state))return;let s=pf(gc,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?this.cursor.set(Me.AUTO):this.getImageStatusActionAtPosition(o)?this.cursor.set(Me.POINTER):this.cursor.applyForTool()),this.maybeUpdateFrameToHighlightOnPointerMove({x:r,y:i},s),!this.state.newElement&&N2(this.state.activeTool.type)){let{originOffset:g,snapLines:b}=R2(this.scene.getNonDeletedElements(),this,{x:r,y:i},t,this.scene.getNonDeletedElementsMap());this.setState(y=>{let w=sc(y.snapLines,b),x=y.originSnapOffset?sc(y.originSnapOffset,g):g;return y.snapLines===w&&y.originSnapOffset===x?null:{snapLines:w,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:ge.handlePointerMoveInEditMode(t,r,i,this);g&&g!==this.state.selectedLinearElement&&Ft(()=>{this.setState({selectedLinearElement:g})})}if(UY(this.state.activeTool.type)){let{newElement:g}=this.state;if(!g&&Zp(this.state)){let b=oe(r,i),y=this.scene.getNonDeletedElementsMap(),w=Cr(b,this.scene.getNonDeletedElements(),y,KM(this.state.zoom));w?this.setState({suggestedBinding:{element:w,midPoint:kb(b,w,y,this.state.zoom)}}):this.state.suggestedBinding&&this.setState({suggestedBinding:null})}}if(this.state.multiElement&&this.state.selectedLinearElement){let{multiElement:g,selectedLinearElement:b}=this.state,{x:y,y:w,points:x}=g,I=x[x.length-1],{lastCommittedPoint:T}=b;if(this.cursor.applyForTool(),I===T)so(oe(r-y,i-w),I)>=mb?(this.store.scheduleCapture(),Ft(()=>{mo(this.state.selectedLinearElement?.initialState,"initialState must be set"),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:x[x.length-1],selectedPointsIndices:[g.points.length],initialState:{...this.state.selectedLinearElement.initialState,lastClickedPoint:g.points.length}}})}),this.scene.mutateElement(g,{points:[...x,oe(r-y,i-w)]},{informMutation:!1,isDragging:!1})):this.cursor.set(Me.POINTER);else if(x.length>2&&T&&so(oe(r-y,i-w),T)<mb){this.cursor.set(Me.POINTER),this.scene.mutateElement(g,{points:x.slice(0,-1)},{informMutation:!1,isDragging:!1});let C=g.points.length-1;this.setState({selectedLinearElement:{...b,selectedPointsIndices:b.selectedPointsIndices?[...new Set(b.selectedPointsIndices.map(P=>Math.min(P,C)))]:b.selectedPointsIndices,lastCommittedPoint:g.points[C],initialState:{...b.initialState,lastClickedPoint:C}}})}else{IM(x,this.state.zoom.value)&&this.cursor.set(Me.POINTER);let C=this.scene.getNonDeletedElementsMap();if(Pb(g)){let A=Cr(oe(r,i),this.scene.getNonDeletedElements(),C);Ro("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(g,A)}mo(this.state.selectedLinearElement,"Expected selectedLinearElement to be set to operate on a linear element");let P=ge.handlePointerMove(t.nativeEvent,this,r,i,this.state.selectedLinearElement);P&&this.setState(P)}return}if(this.state.activeTool.type==="arrow"&&!this.state.newElement){let g=oe(r,i),b=Cr(g,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),KM(this.state.zoom)),y=this.scene.getNonDeletedElementsMap();b&&!XM(g,b,y)&&this.setState({suggestedBinding:{element:b,midPoint:kb(g,b,y,this.state.zoom)}})}let l=!!t.buttons,c=this.state.activeTool.type==="laser";if(l||!c&&this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let d=this.scene.getNonDeletedElements(),m=this.scene.getSelectedElements(this.state);if(this.isHittingTextAutoResizeHandle(m,o)){this.cursor.set(Me.POINTER);return}if(m.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"&&!(m.length===1&&Yt(m[0]))&&!(Ot(m[0])&&(this.editorInterface.userAgent.isMobileDevice||m[0].points.length===2))){let g=OM(d,this.state,r,i,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);if(g&&g.transformHandleType){this.cursor.set(FM(g));return}}}else if(m.length>1&&!s&&this.state.openDialog?.name!=="elementLinkSelector"){let g=zM(ss(m),r,i,this.state.zoom,t.pointerType,this.editorInterface);if(g){this.cursor.set(FM({transformHandleType:g}));return}}if(on(this.state))return;let p=this.getElementAtPosition(r,i,{preferSelected:!0,includeLockedElements:!0}),u=null;p&&p.locked?u=null:u=p;let E=this.arrowText.updateHoveredAnchor(o);if(this.handleIframeLikeElementHover({hitElement:u,scenePointer:o,moveEvent:t})||(this.hitLinkElement=this.getElementLinkAtPosition(o,p)),!this.applyElementLinkHoverAffordance()){if(c)return;u&&(u.link||No(u))&&this.state.selectedElementIds[u.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?this.cursor.set(E?Me.POINTER:Xt(u)?Me.TEXT:Me.CROSSHAIR):!t[X.CTRL_OR_CMD]&&this.isHittingCommonBoundingBoxOfSelectedElements(o,m)?this.cursor.set(Me.MOVE):this.state.viewModeEnabled?this.cursor.set(Me.GRAB):this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(Me.AUTO):s?this.cursor.set(Me.AUTO):!t[X.CTRL_OR_CMD]&&u?.id!==this.state.editingTextElement?.id?(u||this.isHittingCommonBoundingBoxOfSelectedElements(o,m))&&!u?.locked&&(!u||!Yt(u)||!(u.startBinding||u.endBinding))&&(this.state.activeTool.type!=="lasso"||m.length>0)&&this.cursor.set(Me.MOVE):this.cursor.set(Me.AUTO),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i)}this.state.openDialog?.name==="elementLinkSelector"&&u?this.setState(g=>({hoveredElementIds:sc(g.hoveredElementIds,Un({editingGroupId:g.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),g,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!u&&this.setState(g=>({hoveredElementIds:sc(g.hoveredElementIds,{})}))});v(this,"handleEraser",(t,o)=>{let r=this.eraserTrail.addPointToPath(o.x,o.y,t.altKey);this.elementsPendingErasure=new Set(r),this.triggerRender()});v(this,"handleTouchMove",t=>{this.isInteractionEnabled()&&(fc=!0)});v(this,"handleCanvasPointerDown",t=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)){(this.isLinksEnabled()||this.isEmbedsEnabled())&&(this.lastPointerDownEvent=t),this.isNavigationEnabled()&&(this.updateGestureOnPointerDown(t),Fo||this.handleCanvasPanUsingWheelOrSpaceDrag(t));return}let o=this.scene.getSelectedElements(this.state);if(!t.ctrlKey){let g=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==g&&this.setState({isBindingEnabled:g})}let r=ke(t,this.state),{x:i,y:a}=r;this.lastPointerMoveCoords={x:i,y:a};let s=t.target;if(s.setPointerCapture&&s.setPointerCapture(t.pointerId),this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.state.activeTool.type!=="laser"&&this.requestUnfollow(),this.state.searchMatches&&(this.setState(g=>({searchMatches:g.searchMatches&&{focusedId:null,matches:g.searchMatches.matches.map(b=>({...b,focus:!1}))}})),this.updateEditorAtom(VE,null)),Et.get(ro)&&this.updateEditorAtom(ro,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.state.openPopup&&this.setState({openPopup:null}),this.updateGestureOnPointerDown(t),tu){t.preventDefault(),this.focusContainer(),this.zDragZoom={origin:{clientX:t.clientX,clientY:t.clientY},initialZoom:this.state.zoom.value},this.setState({cursorButton:"down"});return}if(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(b=>b.id!==g.id)}:{},appState:{newElement:null,editingTextElement:null,suggestedBinding:null,selectedElementIds:Ae(Object.keys(this.state.selectedElementIds).filter(b=>b!==g.id).reduce((b,y)=>(b[y]=this.state.selectedElementIds[y],b),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?Kt.EVENTUALLY:Kt.NEVER});return}let l=document.getSelection();if(l?.anchorNode&&l.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(g=>({penMode:!0,penDetected:!0,currentItemStrokeVariability:"variable"})),!this.editorInterface.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.editorInterface=hb(this.editorInterface,{isTouchScreen:!0})),Fo||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===zn.ERASER&&this.isInteractionEnabled()&&!this.props.activeTool&&this.state.activeTool.type!==Gn.eraser){this.setState({activeTool:tn(this.state,{type:Gn.eraser,lastActiveTool:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let g=()=>{b(),y?.(),on(this.state)&&this.setState({activeTool:tn(this.state,{...this.state.activeTool.lastActiveTool||{type:Gn.selection},lastActiveTool:null})})},b=ye(window,J.POINTER_UP,g,{once:!0}),y;requestAnimationFrame(()=>{y=this.missingPointerEventCleanupEmitter.once(g)})});return}if(t.button!==zn.MAIN&&t.button!==zn.TOUCH&&t.button!==zn.ERASER||me.pointers.size>1)return;let c=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleTextAutoResizeHandlePointerDown(o,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(w=>{let x={...w.selectedElementIds,[c.hit.element.id]:!0},I=[];Object.keys(w.selectedElementIds).forEach(C=>{let P=this.scene.getElement(C);P&&I.push(P)});let T=c.hit.element;if(Tt(T))vb(I,T.id).forEach(C=>{delete x[C.id]});else if(T.frameId)x[T.frameId]&&delete x[T.id];else{let C=T.groupIds,P=new Set(C.flatMap(A=>bi(this.scene.getNonDeletedElements(),A)).filter(A=>Tt(A)).map(A=>A.id));P.size>0&&I.forEach(A=>{A.frameId&&P.has(A.frameId)&&(delete x[A.id],A.groupIds.flatMap(D=>bi(this.scene.getNonDeletedElements(),D)).forEach(D=>{delete x[D.id]}))})}return{...Un({editingGroupId:w.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),w,this),showHyperlinkPopup:T.link||No(T)?"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"?this.cursor.applyForTool():this.state.activeTool.type===Gn.frame||this.state.activeTool.type===Gn.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==="autoshape"?this.drawShape.handlePointerDown(c):this.state.activeTool.type===Gn.bucketfill?this.bucketFill.handlePointerDown(r):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 m=this.onPointerMoveFromPointerDownHandler(c),p=this.onPointerUpFromPointerDownHandler(c),u=this.onKeyDownFromPointerDownHandler(c),E=this.onKeyUpFromPointerDownHandler(c);this.missingPointerEventCleanupEmitter.once(g=>p(g||t.nativeEvent)),(!this.state.viewModeEnabled||this.isActiveToolPointerCapturing())&&(window.addEventListener(J.POINTER_MOVE,m),window.addEventListener(J.POINTER_UP,p),window.addEventListener(J.KEYDOWN,u),window.addEventListener(J.KEYUP,E),c.eventListeners.onMove=m,c.eventListeners.onUp=p,c.eventListeners.onKeyUp=E,c.eventListeners.onKeyDown=u)});v(this,"handleCanvasPointerUp",t=>{if(!this.isInteractionEnabled()){(this.isLinksEnabled()||this.isEmbedsEnabled())&&this.handleInteractiveContentPointerUp(t);return}if(Ro("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 o=ke({clientX:t.clientX,clientY:t.clientY},this.state),{x:r,y:i}=o;if(this.lastPointerMoveCoords={x:r,y:i},this.zDragZoom){this.updateZDragZoom(t),this.zDragZoom=null,this.setState({cursorButton:"up"});return}this.handleIframeLikeCenterClick()||!this.maybeHandleElementLinkClick(t,o)&&this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})});v(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(fc=!1,Pr?fc=!0:Pr=window.setTimeout(()=>{Pr=0,fc||this.handleCanvasContextMenu(t)},rY))});v(this,"resetContextMenuTimer",()=>{clearTimeout(Pr),Pr=0,fc=!1});v(this,"maybeCleanupAfterMissingPointerUp",t=>{ls?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});v(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(me.pointers.size<=1&&((t.button===zn.WHEEL||t.button===zn.MAIN&&Bo||ps(this.state))&&(this.isInteractionEnabled()||this.isNavigationEnabled())||this.state.viewModeEnabled&&!this.isActiveToolPointerCapturing())))return!1;Fo=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let o=!1,r=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);this.cursor.set(Me.GRABBING);let{clientX:i,clientY:a}=t,s=vm(c=>{let d=i-c.clientX,m=a-c.clientY;if(i=c.clientX,a=c.clientY,r&&!o&&(Math.abs(d)>1||Math.abs(m)>1)){o=!0;let p=E=>{document.body.removeEventListener(J.PASTE,p),E.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener(J.PASTE,p),window.removeEventListener(J.POINTER_UP,u)},100)};document.body.addEventListener(J.PASTE,p),window.addEventListener(J.POINTER_UP,u)}this.viewport.translate({scrollX:this.state.scrollX-d/this.state.zoom.value,scrollY:this.state.scrollY-m/this.state.zoom.value})}),l=Ke(ls=()=>{ls=null,Fo=!1,Bo||this.cursor.reset(),this.setState({cursorButton:"up"},this.viewport.releaseOverscroll),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(J.POINTER_MOVE,s),window.removeEventListener(J.POINTER_UP,l),window.removeEventListener(J.BLUR,l),s.flush()});return window.addEventListener(J.BLUR,l),window.addEventListener(J.POINTER_MOVE,s,{passive:!0}),window.addEventListener(J.POINTER_UP,l),!0});v(this,"updateMultiTouchGesture",t=>{me.pointers.has(t.pointerId)&&me.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let o=me.initialScale;if(me.pointers.size===2&&me.lastCenter&&o&&me.initialDistance){let r=Jg(me.pointers),i=r.x-me.lastCenter.x,a=r.y-me.lastCenter.y;me.lastCenter=r;let s=Qg(Array.from(me.pointers.values())),l=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:s/me.initialDistance,c=l?Yn(o*l):this.state.zoom.value;this.setState(d=>{let m=ho({viewportX:r.x,viewportY:r.y,nextZoom:c},d),p=m.zoom.value;return this.viewport.translate({zoom:m.zoom,scrollX:m.scrollX+2*i/p,scrollY:m.scrollY+2*a/p,shouldCacheIgnoreZoom:!0},{zoomPreConstrained:!0}),null}),this.viewport.isLockedTransitionPending||this.resetShouldCacheIgnoreZoomDebounced()}else me.lastCenter=me.initialDistance=me.initialScale=null});v(this,"clearSelectionIfNotUsingSelection",()=>{$p(this.state.activeTool.type)||this.setState({selectedElementIds:Ae({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});v(this,"handleSelectionOnPointerDown",(t,o)=>{if($p(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&&!Yt(a[0])&&!(Ot(a[0])&&(this.editorInterface.userAgent.isMobileDevice||a[0].points.length===2))&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let s=OM(r,this.state,o.origin.x,o.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);s!=null&&(s.transformHandleType==="rotation"?(this.setState({resizingElement:s.element}),o.resize.handleType=s.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:s.element}),o.resize.handleType=s.transformHandleType))}else a.length>1&&(o.resize.handleType=zM(ss(a),o.origin.x,o.origin.y,this.state.zoom,t.pointerType,this.editorInterface));if(o.resize.handleType)o.resize.isResizing=!0,o.resize.offset=ub(vX(o.resize.handleType,a,i,o.origin.x,o.origin.y)),a.length===1&&Ot(a[0])&&a[0].points.length===2&&(o.resize.arrowDirection=IX(o.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement,u=ge.handlePointerDown(t,this,this.store,o.origin,p,this.scene);if(u.hitElement&&(o.hit.element=u.hitElement),u.linearElementEditor&&this.setState({selectedLinearElement:u.linearElementEditor}),u.didAddPoint)return!0;let E=this.scene.getNonDeletedElementsMap(),g=ge.getElement(p.elementId,E);if(g&&uo(g)){let{hitFocusPoint:b,pointerOffset:y,arrowOtherEndpointInitialBinding:w}=RX(g,o,E,this.state);if(b)return this.setState({selectedLinearElement:{...p,hoveredFocusPointBinding:b,draggedFocusPointBinding:b,pointerOffset:y,initialState:{...p.initialState,arrowOtherEndpointInitialBinding:w}}}),!1}}let s=this.getElementsAtPosition(o.origin.x,o.origin.y,{includeLockedElements:!0}),l=s.filter(p=>!p.locked),c=this.getElementAtPosition(o.origin.x,o.origin.y,{allHitElements:s});if((!c||c.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),c&&c.locked&&!l.some(p=>this.state.selectedElementIds[p.id])?o.hit.element=null:o.hit.element=o.hit.element??this.getElementAtPosition(o.origin.x,o.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(o.origin,c),this.hitLinkElement)return!0;if(this.state.croppingElementId&&o.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),o.hit.element&&this.getElementLinkAtPosition({x:o.origin.x,y:o.origin.y},o.hit.element))return!1;o.hit.allHitElements=l;let d=o.hit.element,m=o.hit.allHitElements.some(p=>this.isASelectedElement(p));if((d===null||!m)&&!t.shiftKey&&!o.hit.hasHitCommonBoundingBoxOfSelectedElements&&(!this.state.selectedLinearElement?.isEditing||d&&d?.id!==this.state.selectedLinearElement?.elementId)&&this.clearSelection(d),this.state.selectedLinearElement?.isEditing)this.setState(p=>({selectedLinearElement:p.selectedLinearElement?{...p.selectedLinearElement,isEditing:!!d&&d.id===this.state.selectedLinearElement?.elementId}:null,selectedElementIds:p.selectedLinearElement?Ae({[p.selectedLinearElement.elementId]:!0},this.state):Ae({},p)}));else if(d!=null){if(t[X.CTRL_OR_CMD])return t.altKey?(this.state.openDialog?.name==="elementLinkSelector"&&this.setOpenDialog(null),this.lassoTrail.startPath(o.origin.x,o.origin.y,t.shiftKey),this.setActiveTool({type:"lasso",fromSelection:!0}),!1):(this.state.selectedElementIds[d.id]||(o.hit.wasAddedToSelection=!0),this.setState(p=>({...EX(p,d),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[d.id]||(this.state.editingGroupId&&!RM(d,this.state.editingGroupId)&&this.setState({selectedElementIds:Ae({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!m&&!o.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(p=>{let u={...p.selectedElementIds,[d.id]:!0},E=[];if(Object.keys(p.selectedElementIds).forEach(g=>{let b=this.scene.getElement(g);b&&E.push(b)}),Tt(d))vb(E,d.id).forEach(g=>{delete u[g.id]});else if(d.frameId)u[d.frameId]&&delete u[d.id];else{let g=d.groupIds,b=new Set(g.flatMap(y=>bi(this.scene.getNonDeletedElements(),y)).filter(y=>Tt(y)).map(y=>y.id));b.size>0&&E.forEach(y=>{y.frameId&&b.has(y.frameId)&&(delete u[y.id],y.groupIds.flatMap(w=>bi(this.scene.getNonDeletedElements(),w)).forEach(w=>{delete u[w.id]}))})}return p.openDialog?.name==="elementLinkSelector"&&(d.groupIds.some(g=>p.selectedGroupIds[g])||(u={[d.id]:!0})),{...Un({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:d.link||No(d)?"info":!1}}),o.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});v(this,"handleTextOnPointerDown",(t,o)=>{if(this.state.editingTextElement)return;let r=o.origin.x,i=o.origin.y;this.setState({hoveredArrowTextAnchor:null});let a=this.arrowText.getBindableEndpointAtPosition(r,i);if(a)this.startTextEditing({sceneX:r,sceneY:i,autoEdit:!1,arrowEndpoint:a});else{let s=this.getElementAtPosition(r,i,{includeBoundTextElement:!0}),l=this.getTextBindableContainerAtPosition(r,i);bM(s)&&(l=s,r=s.x+s.width/2,i=s.y+s.height/2),this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:l,autoEdit:!1,initialCaretSceneCoords:{x:r,y:i}})}this.isToolLocked()?this.cursor.reset():this.setState({activeTool:tn(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset())});v(this,"handleFreeDrawElementOnPointerDown",(t,o,r)=>{let[i,a]=Mt(r.origin.x,r.origin.y,null),s=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),l=t.pressure===.5,c=this.state.currentItemStrokeVariability,d=RY({type:o,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("freedraw"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:l,strokeOptions:{variability:c,streamline:t.pointerType!=="mouse"?jV:ZV},locked:!1,frameId:s?s.id:null,points:[oe(0,0)],pressures:l?[]:[t.pressure]});this.insertNewElement(d),this.setState(m=>{let p={...m.selectedElementIds};return delete p[d.id],{selectedElementIds:Ae(p,m)}}),this.setState({newElement:d,suggestedBinding:null})});v(this,"insertIframeElement",({sceneX:t,sceneY:o,width:r,height:i})=>{let[a,s]=Mt(t,o,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=BY({type:"iframe",x:a,y:s,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("iframe"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:r,height:i});return this.insertNewElement(l),l});v(this,"insertEmbeddableElement",({sceneX:t,sceneY:o,link:r})=>{let[i,a]=Mt(t,o,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=qp(r);if(!s)return;s.error instanceof URIError&&this.setToast({message:f("toast.unrecognizedLinkFormat"),closable:!0});let l=hM({type:"embeddable",x:i,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("embeddable"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("embeddable"),opacity:this.state.currentItemOpacity,locked:!1,width:s.intrinsicSize.w,height:s.intrinsicSize.h,link:r});return this.insertNewElement(l),l});v(this,"newImagePlaceholder",({sceneX:t,sceneY:o,addToFrameUnderCursor:r=!0,customData:i})=>{let[a,s]=Mt(t,o,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=r?this.getTopLayerFrameAtSceneCoords({x:a,y:s}):null,c=100/this.state.zoom.value;return zY({type:"image",strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("image"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:l?l.id:null,customData:i,x:a-c/2,y:s-c/2,width:c,height:c})});v(this,"handleLinearElementOnPointerDown",(t,o,r)=>{if(t.ctrlKey&&Ft(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.state.multiElement){let{multiElement:i,selectedLinearElement:a}=this.state;if(mo(a,"selectedLinearElement is expected to be set"),i.type==="line"&&IM(i.points,this.state.zoom.value)){Ft(()=>{this.setState({selectedLinearElement:{...a,lastCommittedPoint:i.points[i.points.length-1],initialState:{...a.initialState,lastClickedPoint:-1}}})}),this.actionManager.executeAction(ut);return}if(Yt(i)&&i.points.length>1){this.actionManager.executeAction(ut,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}let{x:s,y:l}=i,{lastCommittedPoint:c}=a,d=ke(t,this.state),{start:m,end:p}=uo(i)&&Zp(this.state)?OX(i,new Map([[i.points.length-1,{point:i.points[i.points.length-1],isDragging:!1}]]),d.x,d.y,this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.state,{newArrow:!!this.state.newElement,zoom:this.state.zoom}):{end:{mode:void 0}},u=this.scene.getNonDeletedElementsMap(),E=m?.mode!=null&&p.mode!=null&&m.element.id===p.element.id&&!XM(p.focusPoint,p.element,u),g=p.mode==="orbit"&&i.startBinding?.elementId!==p.element?.id,b=c&&so(oe(r.origin.x-s,r.origin.y-l),c)<mb;if(g||E||i.points.length>1&&b){this.actionManager.executeAction(ut,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}this.setState(y=>({selectedElementIds:Ae({...y.selectedElementIds,[i.id]:!0},y)})),this.cursor.set(Me.POINTER)}else{let[i,a]=Mt(r.origin.x,r.origin.y,t[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:l,currentItemEndArrowhead:c}=this.state,[d,m]=o==="arrow"?[l,c]:[null,null],p=o==="arrow"?FY({type:o,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(o),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemArrowType===Sr.round?{type:Vp.PROPORTIONAL_RADIUS}:null,startArrowhead:d,endArrowhead:m,locked:!1,frameId:s?s.id:null,elbowed:this.state.currentItemArrowType===Sr.elbow,fixedSegments:this.state.currentItemArrowType===Sr.elbow?[]:null}):GY({type:o,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(o),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness==="round"?{type:Vp.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:s?s.id:null}),u=oe(r.origin.x,r.origin.y),E=this.scene.getNonDeletedElementsMap(),g=Zp(this.state)?Cr(u,this.scene.getNonDeletedElements(),E):null;this.scene.mutateElement(p,{points:[oe(0,0),oe(0,0)]}),this.insertNewElement(p),uo(p)&&MX(p,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:Qk(t.nativeEvent)}),Ft(()=>{this.setState(b=>{let y=null,w=b.selectedElementIds;if(Ot(p)){y=new ge(p,this.scene.getNonDeletedElementsMap());let x=p.points.length-1;y={...y,selectedPointsIndices:[x],initialState:{...y.initialState,arrowStartIsInside:t.altKey,lastClickedPoint:x,origin:oe(r.origin.x,r.origin.y)}}}return w=this.isToolLocked()?b.selectedElementIds:Ae({[p.id]:!0},b),{...b,bindMode:"orbit",newElement:p,suggestedBinding:g&&uo(p)?{element:g,midPoint:kb(u,g,E,this.state.zoom)}:null,selectedElementIds:w,selectedLinearElement:y}})}),uo(p)&&Ro("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(p,g)}});v(this,"createGenericElementOnPointerDown",(t,o)=>{let[r,i]=Mt(o.origin.x,o.origin.y,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:r,y:i}),s={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(t),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:a?a.id:null},l;t==="embeddable"?l=hM({type:"embeddable",...s}):l=OY({type:t,...s}),l.type==="selection"?this.setState({selectionElement:l}):(this.insertNewElement(l),this.setState({multiElement:null,newElement:l}))});v(this,"createFrameElementOnPointerDown",(t,o)=>{let[r,i]=Mt(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},s=o===Gn.magicframe?NY(a):_Y(a);this.insertNewElement(s),this.setState({multiElement:null,newElement:s})});v(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});v(this,"eraseElements",()=>{let t=!1;this.elementsPendingErasure.forEach(r=>{let i=this.scene.getElement(r);if(uo(i)){if(i.startBinding){let a=this.scene.getElement(i.startBinding.elementId);Jp(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(s=>s.id!==i.id)})}if(i.endBinding){let a=this.scene.getElement(i.endBinding.elementId);Jp(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(s=>s.id!==i.id)})}}else Eb(i)&&i.boundElements?.forEach(a=>{if(a.type==="arrow"){let s=this.scene.getElement(a.id);s?.startBinding?.elementId===i.id&&Jp(s,this.scene.getElementsMapIncludingDeleted(),{startBinding:null}),s?.endBinding?.elementId===i.id&&Jp(s,this.scene.getElementsMapIncludingDeleted(),{endBinding:null})}})});let o=this.scene.getElementsIncludingDeleted().map(r=>this.elementsPendingErasure.has(r.id)||r.frameId&&this.elementsPendingErasure.has(r.frameId)||xM(r)&&this.elementsPendingErasure.has(r.containerId)?(t=!0,po(r,{isDeleted:!0})):r);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(o))});v(this,"initializeImage",async(t,o)=>{if(!Si(o))throw new Error(f("errors.unsupportedFileType"));this.cursor.set("wait");let r=this.gifPlayback.createPlaceholderDecodeState(t,o);if(o.type===lo.svg)try{o=wu(TM(await o.text()),o.name)}catch(d){throw console.warn(d),new Error(f("errors.svgImageInsertError"))}else if(o.type!==lo.gif){let{maxWidthOrHeight:d}=this.props.imageOptions;try{o=await(this.props.compressImageFile??bx)(o,{maxWidthOrHeight:d})}catch(m){console.error("Error trying to resize image file on insertion",m)}}let i=o.type,a=i===lo.gif,s=await(this.props.generateIdForFile?.(o)||gx(o));if(!s)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(f("errors.imageInsertError"));if(!this.files[s]?.dataURL){let{maxFileSizeBytes:d}=this.props.imageOptions;if(o.size>d)throw new Error(f("errors.fileTooBig",{maxSize:`${Math.trunc(d/1024/1024)}MB`}))}let c=this.files[s]?.dataURL||await kc(o);return new Promise(async(d,m)=>{try{let p=this.getLatestInitializedImageElement(t,s);if(this.addMissingFiles([{mimeType:i,id:s,dataURL:c,fileName:o.name,created:Date.now(),lastRetrieved:Date.now()}]),a&&(p=this.gifPlayback.ensureElementPlaybackMetadata(p),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(g=>g.id===p.id?p:g)),this.imagePlaceholderUpdateEmitter.trigger()),!this.imageCache.get(s)){a||this.addNewImagesToImageCache();let{erroredFiles:g}=await this.updateImageCache([p]);if(g.size)throw new Error("Image cache update resulted with an error.")}let u=await this.imageCache.get(s)?.image,E=u?KY(u):null;if(u&&this.state.newElement?.id!==p.id){p=this.getLatestInitializedImageElement(t,s);let g=this.getImageNaturalDimensions(p,u);Object.assign(p,g)}p=po(p,{fileName:o.name,thumbHash:E,gifPlayback:a?this.gifPlayback.ensureElementPlaybackMetadata(p,{playing:!0}).gifPlayback:null,status:"saved"}),this.files={...this.files,[s]:{...this.files[s],fileName:o.name,thumbHash:E??void 0}},r&&r!==s&&this.gifPlayback.removePlaceholderDecodeState(r),d(p)}catch(p){this.gifPlayback.removePlaceholderDecodeState(r),console.error(p),m(new Error(f("errors.imageInsertError")))}})});v(this,"getLatestInitializedImageElement",(t,o)=>{let r=this.scene.getElement(t.id)??t;return po(r,{fileId:o})});v(this,"onImageToolbarButtonClick",async()=>{try{let t=this.state.width/2+this.state.offsetLeft,o=this.state.height/2+this.state.offsetTop,{x:r,y:i}=ke({clientX:t,clientY:o},this.state),a=await ix({description:"Image",extensions:Object.keys(QV),multiple:!0});this.insertImages(a,r,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:tn(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction(ut)})}});v(this,"getImageNaturalDimensions",(t,o)=>{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(o.naturalHeight,i),s=a*(o.naturalWidth/o.naturalHeight),l=t.x+t.width/2-s/2,c=t.y+t.height/2-a/2;return{x:l,y:c,width:s,height:a,crop:null}});v(this,"handleImageCacheUpdate",t=>{for(let o of this.scene.getNonDeletedElements())fi(o)&&o.fileId===t&&Ei.delete(o);this.imagePlaceholderUpdateEmitter.trigger(),this.scene.triggerUpdate(),this.ensureGifPlaybackLoop()});v(this,"updateImageCache",async(t,o=this.files)=>{let r=new Map;for(let s of t){let l=this.imageCache.get(s.fileId);l&&r.set(s.fileId,Promise.resolve(l.image))}let{updatedFiles:i,erroredFiles:a}=await xb({imageCache:this.imageCache,fileIds:t.map(s=>s.fileId),files:o,onImageCacheUpdate:s=>this.handleImageCacheUpdate(s),gifAutoDecodeMaxFileSizeBytes:this.props.imageOptions.gifAutoDecodeMaxFileSizeBytes});for(let[s,l]of r){let c=this.imageCache.get(s);!c||!i.has(s)||this.imageCache.set(s,{...c,placeholderImage:await l,transitionStart:performance.now()})}return(a.size||i.size)&&(this.store.scheduleAction(Kt.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(s=>{if(fi(s)){if(a.has(s.fileId))return po(s,{status:"error"});if(i.has(s.fileId)&&s.status==="error")return po(s,{status:"saved"})}return s}))),{updatedFiles:i,erroredFiles:a}});v(this,"ensureGifPlaybackLoop",()=>{this.gifPlayback.ensureLoop()});v(this,"loadDeferredGif",async t=>{let o=this.imageCache.get(t);this.files[t]?.mimeType!==lo.gif||!o||(this.imageCache.set(t,{...o,gifDecodeStatus:"pending"}),this.handleImageCacheUpdate(t),await xb({imageCache:this.imageCache,fileIds:[t],files:this.files,onImageCacheUpdate:i=>this.handleImageCacheUpdate(i),forceGifDecode:!0}))});v(this,"getGifPlaybackFrameIndex",t=>this.gifPlayback.getFrameIndex(t));v(this,"setGifPlaybackFrameIndex",(t,o)=>{this.gifPlayback.setFrameIndex(t,o)});v(this,"addNewImagesToImageCache",async(t=jY(this.scene.getNonDeletedElements()),o=this.files)=>{let r=t.filter(i=>!i.isDeleted&&!this.imageCache.has(i.fileId));if(r.length){let{updatedFiles:i}=await this.updateImageCache(r,o);if(i.size)for(let a of r)i.has(a.fileId)&&Ei.delete(a);i.size&&this.scene.triggerUpdate()}});v(this,"scheduleImageRefresh",YV(()=>{this.addNewImagesToImageCache()},eY));v(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.cursor.reset(),this.interactiveCanvas.addEventListener(J.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(J.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener(J.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(J.TOUCH_END,this.onTouchEnd))});v(this,"insertImages",async(t,o,r,i)=>{let a=50/this.state.zoom.value,s=WM(t.map((u,E)=>this.newImagePlaceholder({sceneX:o,sceneY:r,customData:i?.[E]})),o,r,a);this.insertNewElements(s);let l=await Promise.all(s.map(async(u,E)=>{try{return await this.initializeImage(u,await Lr(t[E]))}catch(g){return this.setState({errorMessage:g.message||f("errors.imageInsertError")}),po(u,{isDeleted:!0})}})),c=lc(l),d=WM(l.filter(u=>!u.isDeleted),o,r,a),m=lc(d),p=this.scene.getElementsIncludingDeleted().map(u=>m.get(u.id)??c.get(u.id)??u);this.updateScene({appState:{selectedElementIds:Ae(Object.fromEntries(d.map(u=>[u.id,!0])),this.state)},elements:p,captureUpdate:Kt.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(ut)})});v(this,"handleAppOnDrop",async t=>{if(!this.isInteractionEnabled())return;let{x:o,y:r}=ke(t,this.state),i=Yh(t),a=await Wr(t),s=a.getFiles(),l=s.map(d=>d.file).filter(d=>Si(d));if(this.state.viewModeEnabled)return l.length===0||!this.isToolSupported("image")||!this.shouldInsertImageInViewMode({source:"drop",files:l,event:t})?void 0:this.insertImages(l,o,r,Wd(a,l.length,i));if(s.length===1){let{file:d,fileHandle:m}=s[0];if(d&&(d.type===lo.png||d.type===lo.svg))try{let p=await fs(d,this.state,this.scene.getElementsIncludingDeleted(),m);this.syncActionResult({...p,appState:{...p.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:Kt.IMMEDIATELY});return}catch(p){if(p.name!=="EncodingError")throw new Error(f("alerts.couldNotLoadInvalidFile"))}}if(l.length>0&&this.isToolSupported("image"))return this.insertImages(l,o,r,Wd(a,l.length,i));if(s.length>0){let{file:d,fileHandle:m}=s[0];d&&await this.loadFileToCanvas(d,m)}let c=a.findByType(lo.text);if(c){let d=c.value;if(d&&bb(d,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(d)||qp(d)?.type==="video")){let m=this.insertEmbeddableElement({sceneX:o,sceneY:r,link:Xp(d)});m&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[m.id]:!0}}))}}});v(this,"loadFileToCanvas",async(t,o)=>{t=await Lr(t);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await fs(t,this.state,r,o)}catch(a){let s=a instanceof rx;if(s&&a.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:f("errors.imageToolNotSupported")});return}let l=s?f("alerts.cannotRestoreFromImage"):f("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:l})}if(!i)return;QM(r.concat(i.elements)),this.store.scheduleMicroAction({action:Kt.NEVER,elements:r,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({elements:i.elements,files:i.files,appState:{...i.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:Kt.IMMEDIATELY})}catch(r){this.setState({isLoading:!1,errorMessage:r.message})}});v(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),!this.isInteractionEnabled()||(this.bucketFill.cancel(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==zn.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type))return;let{x:o,y:r}=ke(t,this.state),i=this.getElementAtPosition(o,r,{preferSelected:!0,includeLockedElements:!0}),a=this.isLinksEnabled()?this.getElementLinkAtPositionForContextMenu({x:o,y:r},i):void 0,s=this.scene.getSelectedElements(this.state),l=this.isHittingCommonBoundingBoxOfSelectedElements({x:o,y:r},s),c=l&&s.length===1&&s[0].link?s[0]:void 0,d=i??a??c,m=d||l?"element":"canvas",p=this.excalidrawContainerRef.current,{top:u,left:E}=p.getBoundingClientRect(),g=t.clientX-E,b=t.clientY-u;Be("contextMenu","openContextMenu",m),this.setState({...d&&!this.state.selectedElementIds[d.id]?{...this.state,...Un({editingGroupId:this.state.editingGroupId,selectedElementIds:{[d.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:Ot(d)?new ge(d,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:b,left:g,items:this.getContextMenuItems(m,d)}})})});v(this,"maybeDragNewGenericElement",(t,o,r=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&t.boxSelection.hasOccurred&&this.state.activeTool.type!=="eraser"){GM({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:as(t.origin.x,a.x),height:as(t.origin.y,a.y),shouldMaintainAspectRatio:rc(o),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let s=this.state.newElement;if(!s||this.arrowText.maybeDragNewText(s,a))return;let[l,c]=Mt(a.x,a.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=fi(s)&&this.imageCache.get(s.fileId)?.image,m=d&&!(d instanceof Promise)?d.width/d.height:null;this.maybeCacheReferenceSnapPoints(o,[s]);let{snapOffset:p,snapLines:u}=_2(s,this,o,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:l-t.originInGrid.x,y:c-t.originInGrid.y},this.scene.getNonDeletedElementsMap());l+=p.x,c+=p.y,this.setState({snapLines:u}),uo(s)||GM({newElement:s,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:l,y:c,width:as(t.originInGrid.x,l),height:as(t.originInGrid.y,c),shouldMaintainAspectRatio:Hn(s)?!rc(o):rc(o),shouldResizeFromCenter:Jk(o),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:m,originOffset:this.state.originSnapOffset,informMutation:r}),this.setState({newElement:s}),(this.state.activeTool.type===Gn.frame||this.state.activeTool.type===Gn.magicframe)&&this.setState({elementsToHighlight:Tb(this.scene.getNonDeletedElements(),s,this.state,this.scene.getNonDeletedElementsMap())})});v(this,"maybeHandleCrop",(t,o)=>{if(!this.state.croppingElementId)return!1;let r=t.resize.handleType,i=t.lastCoords,[a,s]=Mt(i.x-t.resize.offset.x,i.y-t.resize.offset.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(r&&l&&Hn(l)){let c=t.originalElements.get(l.id),d=fi(l)&&this.imageCache.get(l.fileId)?.image;if(c&&Hn(c)&&d&&!(d instanceof Promise)){let[m,p]=Mt(i.x,i.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:m-t.originInGrid.x,y:p-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(o,[l]);let{snapOffset:E,snapLines:g}=of([l],[c],this,o,u,r);this.scene.mutateElement(l,cX(l,this.scene.getNonDeletedElementsMap(),r,d.naturalWidth,d.naturalHeight,a+E.x,s+E.y,o.shiftKey?c.width/c.height:void 0)),jp(l,this.scene),this.setState({isCropping:r&&r!=="rotation",snapLines:g})}return!0}return!1});v(this,"maybeHandleResize",(t,o)=>{let r=this.scene.getSelectedElements(this.state),i=r.filter(Tt),a=t.resize.handleType;if(i.length>0&&a==="rotation"||r.length===1&&Yt(r[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let s=t.lastCoords,[l,c]=Mt(s.x-t.resize.offset.x,s.y-t.resize.offset.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=new Map;if(i.forEach(m=>{vb(this.scene.getNonDeletedElements(),m.id).forEach(u=>{d.set(m.id+u.id,{x:u.x-m.x,y:u.y-m.y})})}),!this.state.selectedElementsAreBeingDragged){let[m,p]=Mt(s.x,s.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:m-t.originInGrid.x,y:p-t.originInGrid.y},E=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(o,r);let{snapOffset:g,snapLines:b}=of(r,ce(E,this.state),this,o,u,a);l+=g.x,c+=g.y,this.setState({snapLines:b})}if(TX(t.originalElements,a,r,this.scene,Qk(o),Jk(o),r.some(m=>Hn(m))?!rc(o):rc(o),l,c,t.resize.center.x,t.resize.center.y)){let m=new Set;return i.forEach(p=>{Tb(this.scene.getNonDeletedElements(),p,this.state,this.scene.getNonDeletedElementsMap()).forEach(u=>{eu(u)?m.add(u):console.error("[NONDELETED][INVARIANT] Skipped highlighting deleted element in resizing frame")})}),this.setState({elementsToHighlight:[...m]}),!0}return!1});v(this,"getImageContextMenuItems",t=>{let o=this.props.imageContextMenuItems;if(!o)return[];let r=this.scene.getSelectedElements(this.state);return r.length>0&&r.every(i=>Hn(i))&&(!t||this.state.selectedElementIds[t.id])?[...o(r.map(i=>i.id))]:t&&Hn(t)?[...o([t.id])]:[]});v(this,"getImageActionContextMenuItems",t=>{let o=this.scene.getSelectedElements(this.state);return o.length>0&&o.every(r=>Hn(r))&&(!t||this.state.selectedElementIds[t.id])?[ng,og]:[]});v(this,"getElementLinkContextMenuItems",t=>{if(!t?.link)return[];let o=Xp(t.link),r=DM(o);return[{key:"goToLink",label:r?f("labels.link.goToElement"):"Go to link",onSelect:()=>this.openElementLink(t)},!r&&{key:"copyLink",label:f("buttons.copyLink"),onSelect:async()=>{await vo(o),this.setState({toast:{message:f("toast.elementLinkCopied"),closable:!0}})}}]});v(this,"getContextMenuItems",(t,o)=>{let r=this.getImageContextMenuItems(o),i=this.getImageActionContextMenuItems(o),a=this.getElementLinkContextMenuItems(o);if(t==="canvas")return this.state.viewModeEnabled?[el,la,va,ar]:[ag,je,ih,vv,je,la,Dt,tl,nl,va,ar];if(this.state.viewModeEnabled)return[...a,a.length>0&&je,el,sa,r.length>0&&je,...r];let s=this.editorInterface.formFactor==="desktop"?[je,th,nh,oh,rh]:[];return[je,el,je,tm,sa,ag,r.length>0&&je,...r,i.length>0&&je,...i,je,p2,u2,h2,je,Yg,je,Qh,jg,cg,dg,iv,eg,je,...s,je,rg,ig,je,ba,je,xg,a.length>0&&je,...a,je,ah,il,je,Cs]});v(this,"handleWheel",Ke(t=>{if(!this.isNavigationEnabled())return;if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement||t.target instanceof HTMLElement&&(t.target.classList.contains(gb.FRAME_NAME)||t.target.classList.contains("excalidraw-eye-dropper-backdrop")))){t[X.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),Fo)return;let{deltaX:o,deltaY:r}=t;if(t.metaKey||t.ctrlKey||this.state.wheelZoomsOnDefault){let i=Math.sign(r),a=aY*100,s=Math.abs(r),l=r;s>a&&(l=a*i);let c=this.state.zoom.value-l/100;c+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,s/20);let d=this.state.scrollConstraints?.lockZoom?this.state.scrollConstraints.zoom:sY;c=Math.max(c,d),this.viewport.translate(p=>({...ho({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:Yn(c)},p),shouldCacheIgnoreZoom:!0}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})&&this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.viewport.translate(({zoom:i,scrollX:a})=>({scrollX:a-(r||o)/i.value}));return}this.viewport.translate(({zoom:i,scrollX:a,scrollY:s})=>({scrollX:a-o/i.value,scrollY:s-r/i.value}))}));v(this,"savePointer",(t,o,r)=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)||!t||!o)return;let{x:i,y:a}=ke({clientX:t,clientY:o},this.state);isNaN(i)||isNaN(a);let s={x:i,y:a,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:s,button:r,pointersMap:me.pointers})});v(this,"resetShouldCacheIgnoreZoomDebounced",aM(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));v(this,"updateDOMRect",t=>{if(this.excalidrawContainerRef?.current){let o=this.excalidrawContainerRef.current,{width:r,height:i,left:a,top:s}=o.getBoundingClientRect(),{width:l,height:c,offsetTop:d,offsetLeft:m}=this.state;if(r===l&&i===c&&a===m&&s===d){t&&t();return}this.setState({width:r,height:i,offsetLeft:a,offsetTop:s},()=>{t&&t()}),this.viewport.constrain()}});v(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});v(this,"watchState",()=>{});let o=Ho(),{viewModeEnabled:r=!1,viewModeOnly:i=!1,gridModeEnabled:a=!1,objectsSnapModeEnabled:s=!1,theme:l=o.theme,name:c=`${f("labels.untitled")}-${lM()}`,wheelZoomsOnDefault:d=!1}=t,m=null;t.activeTool&&(t.activeTool.type==="image"?console.warn('"image" tool cannot be forced via "props.activeTool"'):this.isToolSupported(t.activeTool.type,t)?m=tn(o,t.activeTool):console.warn(`"${t.activeTool.type}" tool ("props.activeTool") cannot be activated \u2014 disabled via "UIOptions.tools", or not enabled while non-interactive (see "interaction.enabled.tools")`)),this.state={...o,theme:l,exportWithDarkMode:l===ic.DARK,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:this.isInteractionEnabled(t)?i||r:!0,viewModeOnly:i,activeTool:m??o.activeTool,zenModeEnabled:!1,objectsSnapModeEnabled:s,gridModeEnabled:a??o.gridModeEnabled,name:c,width:window.innerWidth,height:window.innerHeight,wheelZoomsOnDefault:d},this.refreshEditorInterface(),this.stylesPanelMode=iu(this.editorInterface),this.id=KV(),this.actionManager=new bm(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new HM,this.canvas=document.createElement("canvas"),this.rc=XV.canvas(this.canvas),this.renderer=new Tl(this.scene),this.visibleElements=[],this.store=new PX(this),this.history=new vl(this.store),this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new go(this.scene),this.history=new vl(this.store),this.actionManager.registerAll(Vc),this.actionManager.registerAction(b2(this.history)),this.actionManager.registerAction(x2(this.history)),this.api=this.createExcalidrawAPI()}get lastViewportPosition(){return this.viewport.lastPosition}createExcalidrawAPI(){return{isDestroyed:!1,updateScene:this.updateScene,applyDeltas:this.applyDeltas,mutateElement:this.mutateElement,addFiles:this.addFiles,addImagePlaceholder:this.addImagePlaceholder,setDownloadProgress:this.setDownloadProgress,setDownloadError:this.setDownloadError,setUploadProgress:this.setUploadProgress,addImageElementsToScene:this.addImageElementsToScene,scrollToViewport:this.scrollToViewport,scrollToContent:this.scrollToContent,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},setViewport:this.viewport.setViewport,getViewportOffsets:this.viewport.getOffsets,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:o=>{this.actionManager.registerAction(o)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.cursor.set,resetCursor:this.cursor.reset,getEditorInterface:()=>this.editorInterface,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:o=>this.onChangeEmitter.on(o),onIncrement:o=>this.store.onStoreIncrementEmitter.on(o),onPointerDown:o=>this.onPointerDownEmitter.on(o),onPointerUp:o=>this.onPointerUpEmitter.on(o),onScrollChange:o=>this.onScrollChangeEmitter.on(o),onUserFollow:o=>this.onUserFollowEmitter.on(o),onStateChange:this.onStateChange,onEvent:this.onEvent}}isInteractionEnabled(t=this.props){return t.interaction!==!1&&typeof t.interaction!="object"}isLinksEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.links===!0||t.interaction.enabled?.interactiveContent===!0:t.interaction!==!1}isNavigationEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.navigation===!0:t.interaction!==!1}isEmbedsEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.embeds===!0||t.interaction.enabled?.interactiveContent===!0:t.interaction!==!1}isBrowserZoomEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.browserZoom===!0:!1}isToolLocked(){return this.state.activeTool.locked||this.props.activeTool!=null}isActiveToolPointerCapturing(){return this.isInteractionEnabled()?this.state.activeTool.type==="laser"||this.state.activeTool.type==="custom":this.isToolSupported(this.state.activeTool.type)}isDefaultUIEnabled(t=this.props){return t.ui!==!1&&(typeof t.ui!="object"||t.ui===null)}isUIControlEnabled(t,o=this.props){return typeof o.ui=="object"&&o.ui!==null?o.ui.enabled?.[t]===!0:o.ui!==!1}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let o=null;try{o=JSON.parse(t.data)}catch{}if(o)switch(t.origin){case"https://player.vimeo.com":if(o.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:o.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(o.event==="infoDelivery"&&o.info&&o.id&&typeof o.info.playerState=="number"){let r=o.id,i=o.info.playerState;Object.values(Yp).includes(i)&&Mb.set(r,i)}break}}handleSkipBindMode(){if(this.state.selectedLinearElement?.initialState&&!this.state.selectedLinearElement.initialState.arrowStartIsInside){mo(this.lastPointerMoveCoords,"Missing last pointer move coords when changing bind skip mode for arrow start");let t=this.scene.getNonDeletedElementsMap(),o=Cr(oe(this.lastPointerMoveCoords.x,this.lastPointerMoveCoords.y),this.scene.getNonDeletedElements(),t),r=ge.getElement(this.state.selectedLinearElement.elementId,t);r?.startBinding&&o?.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),Ft(()=>{this.setState({bindMode:"skip"})}),this.lastPointerMoveCoords&&this.state.selectedLinearElement?.selectedPointsIndices&&this.state.selectedLinearElement?.selectedPointsIndices.length)){let{x:t,y:o}=this.lastPointerMoveCoords,r=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;mo(r,"Last event must exist");let i=t-this.state.selectedLinearElement.pointerOffset.x,a=o-this.state.selectedLinearElement.pointerOffset.y,s=this.state.multiElement?ge.handlePointerMove(r,this,i,a,this.state.selectedLinearElement):ge.handlePointDragging(r,this,i,a,this.state.selectedLinearElement);s&&this.setState(s)}}resetDelayedBindMode(){this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode!=="orbit"&&setTimeout(()=>this.setState({bindMode:"orbit"}))}handleDelayedBindModeChange(t,o){if(t.isDeleted||Yt(t))return;let r=()=>{if(this.bindModeHandler=null,mo(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 E=this.state.selectedLinearElement.selectedPointsIndices.includes(0),g=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1);if(!E&&!g||E&&g)return}let{x:m,y:p}=this.lastPointerMoveCoords,u=Cr(oe(m,p),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(u&&this.state.bindMode!=="skip"){mo(this.state.selectedLinearElement?.elementId===t.id,"The selectedLinearElement is expected to not change while a bind mode timeout is ticking");let E=this.state.selectedLinearElement.initialState.arrowStartIsInside||t.startBinding?.elementId===u.id;Ft(()=>{mo(this.state.selectedLinearElement,"this.state.selectedLinearElement must exist"),this.setState({bindMode:"inside",selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:E}}})});let g=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;mo(g,"Last event must exist");let b=m-this.state.selectedLinearElement.pointerOffset.x,y=p-this.state.selectedLinearElement.pointerOffset.y,w=this.state.multiElement?ge.handlePointerMove(g,this,b,y,this.state.selectedLinearElement):ge.handlePointDragging(g,this,b,y,this.state.selectedLinearElement);w&&this.setState(w)}},i=!1;if(this.state.selectedLinearElement?.selectedPointsIndices){let m=this.scene.getNonDeletedElementsMap(),p=this.state.selectedLinearElement.selectedPointsIndices.includes(0),u=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1),E=p?o:t.startBinding&&m.get(t.startBinding.elementId),g=u?o:t.endBinding&&m.get(t.endBinding.elementId),b=E&&YM(E,m),y=g&&YM(g,m);i=!!(b&&y&&E.id!==g.id&&AX(b,y))}let a=this.state.selectedLinearElement?.selectedPointsIndices?.includes(0),s=this.state.selectedLinearElement?.selectedPointsIndices?.includes(t.points.length-1),l=a?"startBinding":s?"endBinding":null,c=a?"endBinding":s?"startBinding":null,d=c&&t[c]?.mode==="inside"&&t[c]?.elementId===o?.id||l&&t[l]?.mode==="inside"&&o?.id===t[l]?.elementId;l&&c&&t[l]?.mode==="inside"&&o?.id!==t[l]?.elementId&&t[c]?.elementId!==t[l]?.elementId&&this.scene.mutateElement(t,{[l]:{...t[l],mode:"orbit"}},{informMutation:!1,isDragging:!0}),!o||this.previousHoveredBindableElement&&o.id!==this.previousHoveredBindableElement.id?(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode==="inside"&&Ft(()=>{this.setState({bindMode:"orbit"})}),this.previousHoveredBindableElement=null):!this.bindModeHandler&&(!this.state.newElement||!t.startBinding||i)&&!d&&(this.bindModeHandler=setTimeout(r,IY)),this.previousHoveredBindableElement=o}cacheEmbeddableRef(t,o){o&&this.iFrameRefs.set(t.id,o)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleIframeLikeCenterClick(){if(!this.lastPointerDownEvent||!this.lastPointerUpEvent||this.lastPointerDownEvent.button!==zn.MAIN||Bo||!mM(this.state.activeTool.type,["laser","selection","lasso"]))return!1;let t=oe(ke({clientX:this.lastPointerDownEvent.clientX,clientY:this.lastPointerDownEvent.clientY},this.state)),o=oe(ke({clientX:this.lastPointerUpEvent.clientX,clientY:this.lastPointerUpEvent.clientY},this.state));if(so(t,o)>tM)return!1;let i=this.getElementAtPosition(t[0],t[1]);if(!(i&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<=300&&me.pointers.size<2&&dc(i)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(i,this.lastPointerUpEvent,o[0],o[1]))))return!1;let s=i;if(this.state.activeEmbeddable?.element===s&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:s,state:"active"},selectedElementIds:{[s.id]:!0},newElement:null,selectionElement:null})},100),fb(s)))return!0;let l=this.getHTMLIFrameElement(s);if(!l?.contentWindow)return!0;if(l.src.includes("youtube")){let c=Mb.get(s.id);switch(c||(Mb.set(s.id,Yp.UNSTARTED),l.contentWindow.postMessage(JSON.stringify({event:"listening",id:s.id}),"*")),c){case Yp.PLAYING:case Yp.BUFFERING:l.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:l.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}return l.src.includes("player.vimeo.com")&&l.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*"),!0}isIframeLikeElementCenter(t,o,r,i){return t&&!o.altKey&&!o.shiftKey&&!o.metaKey&&!o.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,o=this.state.width,r=this.state.height,i=this.scene.getNonDeletedElements().filter(a=>No(a)&&this.embedsValidationStatus.get(a.id)===!0||fb(a));return Ce(UX,{children:i.map(a=>{let{x:s,y:l}=Kp({sceneX:a.x,sceneY:a.y},this.state),c=wM(a,o,r,this.state,this.scene.getNonDeletedElementsMap()),d=this.initializedEmbeds.has(a.id);if(c&&!d&&this.initializedEmbeds.add(a.id),!(c||d))return null;let p=qp(pY(a.link||"")),u=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="active",E=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="hover",g=p?.type==="video",b=oc(g?t:1,.75,GX);return Ce("div",{className:Kk("excalidraw__embeddable-container",{"is-hovered":E}),style:{transform:c?`translate(${s-this.state.offsetLeft}px, ${l-this.state.offsetTop}px) scale(${t})`:"none",display:c?"block":"none",opacity:fX(a,Sb(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?dY:1),"--embeddable-radius":`${$Y(Math.min(a.width,a.height),a)}px`},children:Ab("div",{className:"excalidraw__embeddable-container__inner",style:{width:c?`${a.width}px`:0,height:c?`${a.height}px`:0,transform:c?`rotate(${a.angle}rad)`:"none",pointerEvents:u?is.enabled:is.disabled},children:[E&&Ce("div",{className:"excalidraw__embeddable-hint",children:f("buttons.embeddableInteractionButton")}),Ce("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:Ce("div",{className:"excalidraw__embeddable__content",style:{width:`${b*100}%`,height:`${b*100}%`,transform:`scale(${1/b})`},children:(No(a)?this.props.renderEmbeddable?.(a,this.state):null)??Ce("iframe",{ref:y=>this.cacheEmbeddableRef(a,y),className:"excalidraw__embeddable",srcDoc:p?.type==="document"?p.srcdoc(this.state.theme):void 0,src:p?.type!=="document"?p?.link??"":void 0,scrolling:"no",referrerPolicy:"no-referrer-when-downgrade",title:"Excalidraw Embedded Content",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,sandbox:`${p?.sandbox?.allowSameOrigin?"allow-same-origin":""} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})})]})},a.id)})})}toggleOverscrollBehavior(t){document.documentElement.style.overscrollBehaviorX=t.type==="pointerenter"?"none":"auto"}render(){let t=this.scene.getSelectedElements(this.state),{renderTopRightUI:o,renderTopLeftUI:r,renderCustomStats:i}=this.props,{elementsMap:a,visibleElements:s,canvasNonce:l,newElementCanvasElement:c}=this.renderer.getRenderableElements({zoom:this.state.zoom,offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,height:this.state.height,width:this.state.width,editingTextElement:this.state.editingTextElement,newElement:this.state.newElement,selectedElements:t,selectedElementsAreBeingDragged:this.state.selectedElementsAreBeingDragged,frameToHighlight:this.state.frameToHighlight});this.visibleElements=s,this.hasRenderableElements=a.size>0;let d=this.scene.getNonDeletedElementsMap(),m="setPointerCapture"in HTMLElement.prototype?!1:this.state.selectionElement||this.state.newElement||this.state.selectedElementsAreBeingDragged||this.state.resizingElement||this.state.activeTool.type==="laser"&&this.state.cursorButton==="down",p=t[0],u=Et.get(ro)?.type==="panel";return Ce("div",{translate:"no",className:Kk("excalidraw excalidraw-container notranslate",this.props.className,{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.editorInterface.formFactor==="phone","excalidraw--non-interactive":!this.isInteractionEnabled(),"excalidraw--navigation":!this.isInteractionEnabled()&&this.isNavigationEnabled(),"excalidraw--tools":!this.isInteractionEnabled()&&this.isToolSupported(this.state.activeTool.type),"excalidraw--embeds":!this.isInteractionEnabled()&&this.isEmbedsEnabled(),"excalidraw--allow-browser-zoom":!this.isInteractionEnabled()&&this.isBrowserZoomEnabled(),"excalidraw--ui-hidden":!this.isDefaultUIEnabled(),"excalidraw--mobile-toolbar":this.editorInterface.formFactor==="phone"&&this.isDefaultUIEnabled()&&!this.state.viewModeEnabled,"excalidraw--viewport-status-border":!!this.props.viewportStatusFrame?.border,"excalidraw--viewport-status-label":!!this.props.viewportStatusFrame?.label,"excalidraw--zen-mode":this.state.zenModeEnabled}),style:{"--ui-pointerEvents":m?is.disabled:is.enabled,"--right-sidebar-width":`${$f}px`},ref:this.excalidrawContainerRef,onDrop:this.isInteractionEnabled()?this.handleAppOnDrop:void 0,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally||!this.isInteractionEnabled()?void 0:this.onKeyDown,onPointerEnter:this.isInteractionEnabled()?this.toggleOverscrollBehavior:void 0,onPointerLeave:this.isInteractionEnabled()?this.toggleOverscrollBehavior:void 0,children:Ce(cs.Provider,{value:this.api,children:Ce(e3.Provider,{value:this,children:Ce(t3.Provider,{value:this.props,children:Ce(Rb.Provider,{value:this.excalidrawContainerValue,children:Ce(_b.Provider,{value:this.editorInterface,children:Ce(Fb.Provider,{value:this.setAppState,children:Ce(Bb.Provider,{value:this.state,children:Ab(Nb.Provider,{value:this.scene.getNonDeletedElements(),children:[Ab(Ob.Provider,{value:this.actionManager,children:[Ce(Ck,{canvas:this.canvas,appState:this.state,defaultUIEnabled:this.isDefaultUIEnabled(),zoomUIEnabled:this.isUIControlEnabled("zoom"),scrollBackToContentUIEnabled:this.isUIControlEnabled("scrollBackToContent"),files:this.files,setAppState:this.setAppState,actionManager:this.actionManager,elements:this.scene.getNonDeletedElements(),onLockToggle:this.toggleLock,onPenModeToggle:this.togglePenMode,langCode:Kn().code,renderTopLeftUI:r,renderTopRightUI:o,renderCustomStats:i,showExitZenModeBtn:!1,UIOptions:this.props.UIOptions,onExportImage:this.onExportImage,renderWelcomeScreen:!this.state.isLoading&&this.state.showWelcomeScreen&&this.state.activeTool.type===this.state.preferredSelectionTool.type&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,currentUserControls:this.props.currentUserControls,children:this.props.children}),Ce("div",{className:"excalidraw-textEditorContainer"}),Ce("div",{className:"excalidraw-contextMenuContainer"}),Ce("div",{className:"excalidraw-eye-dropper-container"}),Ce(kk,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail,this.drawShape.trail]}),this.isDefaultUIEnabled()&&Ce(Vk,{}),this.isDefaultUIEnabled()&&t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&Ce(pv,{element:p,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},p.id),this.isDefaultUIEnabled()&&this.state.contextMenu&&Ce(XT,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:E=>{this.setState({contextMenu:null},()=>{this.focusContainer(),E?.()})}}),Ce(sb,{app:this,canvas:this.canvas,rc:this.rc,elementsMap:a,allElementsMap:d,visibleElements:s,canvasNonce:l,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,getGifFrameIndex:this.gifPlayback.getFrameIndex,isExporting:!1,renderGrid:cr(this),renderLinks:this.isLinksEnabled(),imageTransitionDuration:this.props.imageOptions.placeholderTransitionDuration,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowchart.pendingNodes,theme:this.state.theme}}),c&&Ce(Ok,{appState:this.state,newElement:c,scale:window.devicePixelRatio,rc:this.rc,elementsMap:a,allElementsMap:d,renderConfig:{imageCache:this.imageCache,getGifFrameIndex:this.gifPlayback.getFrameIndex,isExporting:!1,imageTransitionDuration:this.props.imageOptions.placeholderTransitionDuration,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null,theme:this.state.theme}}),Ce(ab,{app:this,containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:a,visibleElements:s,allElementsMap:d,selectedElements:t,canvasNonce:l,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderScrollbars:this.props.renderScrollbars===!0,editorInterface:this.editorInterface,interactionEnabled:this.isInteractionEnabled(),navigationEnabled:this.isNavigationEnabled(),renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onClick:this.handleCanvasClick,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.props.viewportStatusFrame?.border&&this.editorInterface.formFactor==="phone"&&Ce(rp,{border:this.props.viewportStatusFrame.border}),this.renderFrameNames(),this.isDefaultUIEnabled()&&this.state.activeLockedId&&Ce(Xk,{app:this,activeLockedId:this.state.activeLockedId}),this.isDefaultUIEnabled()&&u&&Ce(bT,{app:this})]}),this.renderEmbeddables()]})})})})})})})})})}clearImageShapeCache(t){let o=t??this.files;this.scene.getNonDeletedElements().forEach(r=>{fi(r)&&o[r.fileId]&&(this.imageCache.delete(r.fileId),Ei.delete(r))})}async componentDidMount(){if(this.unmounted=!1,this.api=this.createExcalidrawAPI(),this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,jM()||qM()){let r=this.setState.bind(this);Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...i)=>this.setState(...i)},app:{configurable:!0,value:this},history:{configurable:!0,value:this.history},store:{configurable:!0,value:this.store},fonts:{configurable:!0,value:this.fonts}})}this.store.onDurableIncrementEmitter.on(r=>{this.history.record(r.delta)}),this.props.onIncrement&&this.store.onStoreIncrementEmitter.on(r=>{this.props.onIncrement?.(r)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),lY&&this.excalidrawContainerRef.current&&(this.resizeObserver=new ResizeObserver(()=>{this.refreshEditorInterface(),this.updateDOMRect()}),this.resizeObserver?.observe(this.excalidrawContainerRef.current)),new URLSearchParams(window.location.search.slice(1)).has("web-share-target")?this.restoreFileFromShare():this.updateDOMRect(this.initializeScene),CY()&&!mX()&&this.setState({errorMessage:Ce(OT,{})});let o={excalidrawAPI:this.api,container:this.excalidrawContainerRef.current};this.editorLifecycleEvents.emit("editor:mount",o),this.props.onMount?.(o),this.props.onExcalidrawAPI?.(this.api)}componentWillUnmount(){this.gifPlayback.stop(),this.api={...this.api,isDestroyed:!0};for(let t of Object.keys(this.api))(t.startsWith("get")||t==="onStateChange"||t==="onEvent")&&typeof this.api[t]=="function"&&(this.api[t]=()=>{throw new Error("ExcalidrawAPI is no longer usable after the editor has been unmounted and will return invalid/empty data. You should check for `ExcalidrawAPI.isDestroyed` before calling get* methods on subscribing to state/event changes.")});this.editorLifecycleEvents.emit("editor:unmount"),this.props.onUnmount?.(),this.props.onExcalidrawAPI?.(null),window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new HM,this.fonts=new go(this.scene),this.renderer=new Tl(this.scene),this.files={},this.imageCache.clear(),this.resizeObserver?.disconnect(),this.unmounted=!0,this.viewport.destroy(),this.removeEventListeners(),this.laserTrails.stop(),this.drawShape.stop(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),this.store.onStoreIncrementEmitter.clear(),this.store.onDurableIncrementEmitter.clear(),this.appStateObserver.clear(),this.editorLifecycleEvents.clear(),Ei.destroy(),hn.destroy(),clearTimeout(Pr),De.clearCache(),Un.clearCache(),Pr=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){if(this.removeEventListeners(),this.onRemoveEventListenersEmitter.once(ye(window,J.MESSAGE,this.onWindowMessage,!1),ye(document,J.POINTER_UP,this.removePointer,{passive:!1}),ye(document.fonts,"loadingdone",t=>{let o=t.fontfaces;this.fonts.onLoaded(o)},{passive:!1}),ye(window,J.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.isInteractionEnabled()){this.isNavigationEnabled()&&this.onRemoveEventListenersEmitter.once(ye(this.excalidrawContainerRef.current,J.WHEEL,this.handleWheel,{passive:!1}),ye(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,J.KEYDOWN,this.handleNavigationModeKeyDown,!1),ye(document,J.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),ye(document,J.GESTURE_START,this.onGestureStart,!1),ye(document,J.GESTURE_CHANGE,this.onGestureChange,!1),ye(document,J.GESTURE_END,this.onGestureEnd,!1)),this.isBrowserZoomEnabled()||(this.isNavigationEnabled()||this.onRemoveEventListenersEmitter.once(ye(this.excalidrawContainerRef.current,J.WHEEL,this.preventBrowserZoomWheel,{passive:!1}),ye(this.excalidrawContainerRef.current,J.GESTURE_START,this.disableEvent,!1),ye(this.excalidrawContainerRef.current,J.GESTURE_CHANGE,this.disableEvent,!1),ye(this.excalidrawContainerRef.current,J.GESTURE_END,this.disableEvent,!1)),this.onRemoveEventListenersEmitter.once(ye(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,J.KEYDOWN,this.preventBrowserZoomKeyDown,!1)));return}this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(ye(document,J.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(ye(this.excalidrawContainerRef.current,J.WHEEL,this.handleWheel,{passive:!1}),ye(document,J.COPY,this.onCopy,{passive:!1}),ye(document,J.KEYUP,this.onKeyUp,{passive:!0}),ye(document,J.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),ye(document,J.GESTURE_START,this.onGestureStart,!1),ye(document,J.GESTURE_CHANGE,this.onGestureChange,!1),ye(document,J.GESTURE_END,this.onGestureEnd,!1),ye(document,J.PASTE,this.pasteFromClipboard,{passive:!1}),ye(this.excalidrawContainerRef.current,J.DRAG_OVER,this.disableEvent,!1),ye(this.excalidrawContainerRef.current,J.DROP,this.disableEvent,!1)),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(ye(document,J.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),ye(document,J.CUT,this.onCut,{passive:!1}),ye(window,J.RESIZE,this.onResize,!1),ye(window,J.UNLOAD,this.onUnload,!1),ye(window,J.BLUR,this.onBlur,!1),ye(this.excalidrawContainerRef.current,J.WHEEL,this.handleWheel,{passive:!1})),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(ye(uY(this.excalidrawContainerRef.current),J.SCROLL,this.onScroll,{passive:!1})))}componentDidUpdate(t,o){!this._initialized&&!this.state.isLoading&&(this._initialized=!0,this.editorLifecycleEvents.emit("editor:initialize",this.api),this.props.onInitialize?.(this.api)),this.handleInteractionStateChange(t,o),this.handleForcedToolChange(t,o),this.ensureGifPlaybackLoop(),this.appStateObserver.flush(o),this.updateEmbeddables();let r=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted(),a=(this.sessionExportThemeOverride??this.state.theme)===ic.DARK;this.state.exportWithDarkMode!==a&&this.setState({exportWithDarkMode:a}),!this.state.showWelcomeScreen&&!r.length&&this.setState({showWelcomeScreen:!0}),(o.zoom.value!==this.state.zoom.value||o.scrollX!==this.state.scrollX||o.scrollY!==this.state.scrollY)&&(this.props?.onScrollChange?.(this.state.scrollX,this.state.scrollY,this.state.zoom),this.onScrollChangeEmitter.trigger(this.state.scrollX,this.state.scrollY,this.state.zoom)),Object.keys(this.state.selectedElementIds).length&&on(this.state)&&this.setState({activeTool:tn(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&o.theme!==this.state.theme&&this.cursor.applyForTool(),this.state.activeTool.type==="bucketfill"&&o.currentItemBackgroundColor!==this.state.currentItemBackgroundColor&&this.cursor.applyForTool(),o.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),t.langCode!==this.props.langCode&&this.updateLanguage(),on(o)&&!on(this.state)&&this.eraserTrail.endPath(),(o.openDialog?.name==="elementLinkSelector"||this.state.openDialog?.name==="elementLinkSelector")&&o.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),t.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===ic.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(ut)});let s=Object.keys(this.state.selectedElementIds);if(s.length){let c=s.filter(d=>{let m=this.scene.getElement(d);return!m||m.isDeleted});c.length&&this.setState(d=>{let m={...d.selectedElementIds};for(let p of c)delete m[p];return{selectedElementIds:Ae(m,d)}})}if(this.state.editingTextElement){let c=this.scene.getElement(this.state.editingTextElement.id);(!c||c.isDeleted)&&this.setState({editingTextElement:null})}let l=this.state.editingTextElement||this.viewport.isAnimating?!1:!this.visibleElements.length&&this.hasRenderableElements;this.state.scrolledOutside!==l&&this.setState({scrolledOutside:l}),this.store.commit(i,this.state),this.state.isLoading||(this.props.onChange?.(r,this.state,this.files),this.onChangeEmitter.trigger(r,this.state,this.files))}static resetTapTwice(){pc=!1,hc=null}async insertClipboardContent(t,o,r){let{x:i,y:a}=ke({clientX:this.viewport.lastPosition.x,clientY:this.viewport.lastPosition.y},this.state);if(t.errorMessage){this.setState({errorMessage:t.errorMessage});return}if(o.length===0&&!r&&t.mixedContent){await this.addElementsFromMixedContentPaste(t.mixedContent,{isPlainPaste:r,sceneX:i,sceneY:a});return}if(!r&&t.text){let d=Om(t.text);if(d.ok){this.setState({openDialog:{name:"charts",data:d.data,rawText:t.text}});return}}let s=o.map(d=>d.file);if(s.length===0&&t.text&&!r){let d=t.text.trim();d.startsWith("<svg")&&d.endsWith("</svg>")&&s.push(wu(d))}if(s.length>0){this.isToolSupported("image")?await this.insertImages(s,i,a):this.setState({errorMessage:f("errors.imageToolNotSupported")});return}if(t.elements){let d=t.programmaticAPI?DX(t.elements):t.elements;this.addElementsFromPasteOrLibrary({elements:d,files:t.files||null,position:this.editorInterface.formFactor==="desktop"?"cursor":"center",retainSeed:r,preserveFrameChildrenOrder:!0});return}if(!t.text)return;let l=bY(t.text).split(/\n+/).map(d=>d.trim()).filter(Boolean),c=l.map(d=>ZY(d)).filter(d=>bb(d,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(d)||qp(d)?.type==="video"));if(!r&&c.length>0&&c.length===l.length){let d=[];for(let m of c){let p=d[d.length-1],u=this.insertEmbeddableElement({sceneX:p?p.x+p.width+20:i,sceneY:a,link:Xp(m)});u&&d.push(u)}d.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(d.map(m=>[m.id,!0]))}));return}this.addTextFromPaste(t.text,r)}containsImagePaste(t,o,r){if(o.some(a=>Si(a.file))||!r&&t.mixedContent?.some(a=>a.type==="imageUrl"))return!0;if(r||!t.text)return!1;let i=t.text.trim();return i.startsWith("<svg")&&i.endsWith("</svg>")}shouldInsertImageInViewMode({source:t,files:o,data:r,event:i}){return this.state.viewModeEnabled?this.state.viewModeOnly||this.props.viewModeImageInsertBehavior==="reject"?(this.props.onViewModeImageInsertRejected?.({source:t,files:o,data:r,event:i}),!1):(Ft(()=>{this.setState({viewModeEnabled:!1})}),!0):!0}async addElementsFromMixedContentPaste(t,{isPlainPaste:o,sceneX:r,sceneY:i}){if(!o&&t.some(a=>a.type==="imageUrl")&&this.isToolSupported("image")){let a=t.filter(d=>d.type==="imageUrl").map(d=>d.value),s=await Promise.all(a.map(async d=>{try{return{file:await xx(d)}}catch(m){let p=m.message;return m.cause==="FETCH_ERROR"?p=f("errors.failedToFetchImage"):m.cause==="UNSUPPORTED"&&(p=f("errors.unsupportedFileType")),{errorMessage:p}}})),l=s.filter(d=>!!d.file).map(d=>d.file);await this.insertImages(l,r,i);let c=s.find(d=>!!d.errorMessage);c&&c.errorMessage&&this.setState({errorMessage:c.errorMessage})}else{let a=t.filter(s=>s.type==="text");a.length&&this.addTextFromPaste(a.map(s=>s.value).join(`
21
+ `),i=[],a=0,s=0;for(let m of r){let p=a,u=p+m.length-1;i.push({line:m,startIndex:p,endIndex:u,lineNumber:s}),a=u+1,s++}let l=t,c=e.originalText.slice(t,t+n.length),d=[];for(let m of i){if(c==="")break;if(l>=m.startIndex&&l<=m.endIndex){let p=m.endIndex+1-l,u=m.line.slice(0,l-m.startIndex),E=c.slice(0,p);c=c.slice(p);let g=ac(u,Hp(e),e.lineHeight);if(u===""&&(g.width=0),e.textAlign!=="left"&&m.line.length>0){let I=ac(m.line,Hp(e),e.lineHeight),T=e.textAlign==="center"?(e.width-I.width)/2:e.width-I.width;g.width+=T}let{width:b,height:w}=ac(E,Hp(e),e.lineHeight),y=g.width,x=m.lineNumber*g.height;d.push({offsetX:y,offsetY:x,width:b,height:w,showOnCanvas:!0}),l+=p}}return d},JU=(e,n,t,o)=>{let r=e.name??ok(e),i=r.slice(t,t+n.length),a=r.slice(0,t),s=Hp({fontSize:jE.nameFontSize,fontFamily:ZE.Assistant}),l=GU(ZE.Assistant),c=ac(a,s,l);a===""&&(c.width=0);let d=ac(i,s,l),m=c.width,p=-c.height-jE.strokeWidth,u=d.width;return[{offsetX:m,offsetY:p,width:u,height:d.height,showOnCanvas:m+u<=e.width*o}]},QU=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),tk=NU((e,n,t)=>{if(!e||e===""){t([],null);return}let o=n.scene.getNonDeletedElements(),r=o.filter(p=>nk(p)),i=o.filter(p=>Up(p));r.sort((p,u)=>p.y-u.y),i.sort((p,u)=>p.y-u.y);let a=[],s=new RegExp(QU(e),"gi");for(let p of r){let u=null,E=p.originalText;for(;(u=s.exec(E))!==null;){let g=ek(E,u.index,e),b=qU(p,e,u.index);b.length>0&&a.push({element:p,searchQuery:e,preview:g,index:u.index,matchedLines:b})}}let l=[];for(let p of i){let u=null,E=p.name??ok(p);for(;(u=s.exec(E))!==null;){let g=ek(E,u.index,e),b=JU(p,e,u.index,n.state.zoom.value);b.length>0&&l.push({element:p,searchQuery:e,preview:g,index:u.index,matchedLines:b})}}let c=new Set(n.visibleElements.map(p=>p.id)),d=[...l,...a],m=d.findIndex(p=>c.has(p.element.id))??null;t(d,m)},XU);import uW from"clsx";import{useEffect as dk,useLayoutEffect as mk,useRef as ab,useState as hW,forwardRef as pk,useImperativeHandle as gW,useCallback as sk}from"react";import{CLASSES as fW,EVENT as lk,isDevEnv as EW,KEYS as bW,updateObject as xW}from"@excalidraw/common";import nW from"clsx";import{useContext as oW}from"react";import tW from"react";var Wp=tW.createContext({});import{jsx as JE,jsxs as ik}from"react/jsx-runtime";var QE=({children:e,className:n})=>{let t=be(),o=oW(Wp),r=!!(t.canFitSidebar&&o.shouldRenderDockButton);return ik("div",{className:nW("sidebar__header",n),"data-testid":"sidebar-header",children:[e,ik("div",{className:"sidebar__header__buttons",children:[r&&JE(pt,{label:f("labels.sidebarLock"),children:JE(vn,{onSelect:()=>o.onDock?.(!o.docked),selected:!!o.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":f("labels.sidebarLock"),children:Nx})}),JE(vn,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:o.onCloseRequest,"aria-label":f("buttons.close"),children:an})]})]})};QE.displayName="SidebarHeader";import{Tabs as rW}from"radix-ui";import{jsx as ak}from"react/jsx-runtime";var eb=({children:e,tab:n,onSelect:t,...o})=>ak(rW.Trigger,{value:n,asChild:!0,onSelect:t,children:ak("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...o,children:e})});eb.displayName="SidebarTabTrigger";import{Tabs as iW}from"radix-ui";import{jsx as aW}from"react/jsx-runtime";var tb=({children:e,...n})=>aW(iW.List,{className:"sidebar-triggers",...n,children:e});tb.displayName="SidebarTabTriggers";import sW from"clsx";import{jsx as nb,jsxs as lW}from"react/jsx-runtime";var ob=({name:e,tab:n,icon:t,title:o,children:r,onToggle:i,className:a,style:s})=>{let l=Oe(),d=ye().openSidebar?.name===e;return nb("button",{type:"button",title:o,className:"sidebar-trigger__label-element","aria-label":o,"aria-keyshortcuts":"0","aria-pressed":d,onClick:()=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let m=!d;l({openSidebar:m?{name:e,tab:n}:null,openMenu:null,openPopup:null}),i?.(m)},children:lW("div",{className:sW("sidebar-trigger",a),style:s,children:[t&&nb("div",{children:t}),r&&nb("div",{className:"sidebar-trigger__label",children:r})]})})};ob.displayName="SidebarTrigger";import{Tabs as cW}from"radix-ui";import{jsx as dW}from"react/jsx-runtime";var rb=({children:e,...n})=>{let t=ye(),o=Oe();if(!t.openSidebar)return null;let{name:r}=t.openSidebar;return dW(cW.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>o(a=>({...a,openSidebar:{...a.openSidebar,name:r,tab:i}})),...n,children:e})};rb.displayName="SidebarTabs";import{Tabs as mW}from"radix-ui";import{jsx as pW}from"react/jsx-runtime";var ib=({tab:e,children:n,...t})=>pW(mW.Content,{...t,value:e,"data-testid":e,children:n});ib.displayName="SidebarTab";import{jsx as ck}from"react/jsx-runtime";import{createElement as yW}from"react";var sb=Qe(!1),uk=pk(({name:e,children:n,onDock:t,docked:o,className:r,...i},a)=>{EW()&&t&&o==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let s=Oe(),l=Px(sb);mk(()=>(l(!!o),()=>{l(!1)}),[l,o]);let c=ab({});c.current.onCloseRequest=()=>{s({openSidebar:null})},c.current.onDock=u=>t?.(u),c.current=xW(c.current,{docked:o,shouldRenderDockButton:!!t&&o!=null});let d=ab(null);gW(a,()=>d.current);let m=be(),p=sk(()=>{document.querySelector(".Dialog")||s({openSidebar:null})},[s]);return Gi(d,sk(u=>{u.target.closest(".sidebar-trigger")||(!o||!m.canFitSidebar)&&p()},[p,o,m.canFitSidebar])),dk(()=>{let u=E=>{E.key===bW.ESCAPE&&(!o||!m.canFitSidebar)&&p()};return document.addEventListener(lk.KEYDOWN,u),()=>{document.removeEventListener(lk.KEYDOWN,u)}},[p,o,m.canFitSidebar]),ck(Ue,{...i,className:uW(fW.SIDEBAR,{"sidebar--docked":o},r),"data-viewport-ui":m.formFactor!=="phone"?"side":void 0,"data-viewport-ui-name":m.formFactor!=="phone"?"sidebar":void 0,ref:d,children:ck(Wp.Provider,{value:c.current,children:n})})});uk.displayName="SidebarInner";var Pr=Object.assign(pk((e,n)=>{let t=ye(),{onStateChange:o}=e,r=ab(t.openSidebar);dk(()=>{(!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&&o?.(t.openSidebar?.name!==e.name?null:t.openSidebar),r.current=t.openSidebar},[t.openSidebar,o,e.name]);let[i,a]=hW(!1);return mk(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?yW(uk,{...e,ref:n,key:e.name}):null}),{Header:QE,TabTriggers:tb,TabTrigger:eb,Tabs:rb,Tab:ib,Trigger:ob});Pr.displayName="Sidebar";import{jsx as ss,jsxs as IW}from"react/jsx-runtime";import{createElement as TW}from"react";var gk=mi("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:n}=ot();return ss(n.In,{children:ss(Pr.Trigger,{...e,className:"default-sidebar-trigger",name:vW.name})})});gk.displayName="DefaultSidebarTrigger";var fk=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:n}=ot();return ss(n.In,{children:e})};fk.displayName="DefaultTabTriggers";var lb=Object.assign(mi("DefaultSidebar",({children:e,className:n,docked:t,onDock:o,...r})=>{let i=ye(),a=Oe(),s=i.openSidebar?.tab===hk,l=s?!1:t??i.defaultSidebarDockedPreference,c=!s&&t==null&&o!==!1;return TW(Pr,{...r,name:"default",key:"default",className:wW("default-sidebar",{"default-sidebar--search-only":s},n),docked:l,onDock:c?d=>{a({defaultSidebarDockedPreference:d}),o?.(d)}:void 0},IW(Pr.Tabs,{children:[!s&&ss(Pr.Header,{}),ss(Pr.Tab,{tab:hk,children:ss(rk,{})}),!s&&e]}))}),{Trigger:gk,TabTriggers:fk});import CW from"react";import{getFrame as PW}from"@excalidraw/common";import{jsx as SW}from"react/jsx-runtime";var cb={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"}},db=({children:e,color:n})=>SW("div",{className:"Card",style:{"--card-color":cb[n].base,"--card-color-darker":cb[n].darker,"--card-color-darkest":cb[n].darkest},children:e});import{Fragment as MW,jsx as zn,jsxs as Vp}from"react/jsx-runtime";var kW=({elements:e,appState:n,setAppState:t,files:o,actionManager:r,exportOpts:i,canvas:a,onCloseRequest:s})=>{let{onExportToBackend:l}=i;return zn("div",{className:"ExportDialog ExportDialog--json",children:Vp("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&Vp(db,{color:"lime",children:[zn("div",{className:"Card-icon",children:Jx}),zn("h2",{children:f("exportDialog.disk_title")}),Vp("div",{className:"Card-details",children:[f("exportDialog.disk_details"),!Pi&&r.renderAction("changeProjectName")]}),zn(Z,{className:"Card-button",type:"button",title:f("exportDialog.disk_button"),"aria-label":f("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{r.executeAction(rl,"ui")}})]}),l&&Vp(db,{color:"pink",children:[zn("div",{className:"Card-icon",children:Ms}),zn("h2",{children:f("exportDialog.link_title")}),zn("div",{className:"Card-details",children:f("exportDialog.link_details")}),zn(Z,{className:"Card-button",type:"button",title:f("exportDialog.link_button"),"aria-label":f("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{Fe("export","link",`ui (${PW()})`),await l(e,n,o),s()}catch(c){t({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,n,o,a)]})})},Ek=({elements:e,appState:n,files:t,actionManager:o,exportOpts:r,canvas:i,setAppState:a})=>{let s=CW.useCallback(()=>{a({openDialog:null})},[a]);return zn(MW,{children:n.openDialog?.name==="jsonExport"&&zn(wn,{onCloseRequest:s,title:f("buttons.export"),children:zn(kW,{elements:e,appState:n,setAppState:a,files:t,actionManager:o,onCloseRequest:s,exportOpts:r,canvas:i})})})};import AW from"clsx";import{jsx as DW}from"react/jsx-runtime";var bk=e=>DW(Z,{className:AW("ToolIcon__LaserPointer",{"is-mobile":e.isMobile}),type:"toggle",size:"small",icon:qn,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,"data-testid":"toolbar-LaserPointer",onSelect:()=>e.onChange?.()});import Sk from"clsx";import{useState as WW}from"react";import{CANVAS_SEARCH_TAB as VW,DEFAULT_SIDEBAR as YW,KEYS as sc}from"@excalidraw/common";import{CANVAS_SEARCH_TAB as LW,DEFAULT_SIDEBAR as _W}from"@excalidraw/common";import{isArrowElement as RW,isFlowchartNodeElement as NW,isImageElement as xk,isLinearElement as yk,isLineElement as BW,isTextBindableContainer as FW,isTextElement as OW}from"@excalidraw/element";import{isNodeInFlowchart as zW}from"@excalidraw/element";import{jsx as mb}from"react/jsx-runtime";var Se=e=>Array.isArray(e)?`<kbd>${e.map(N).join(" + ")}</kbd>`:`<kbd>${N(e)}</kbd>`,GW=({appState:e,isMobile:n,editorInterface:t,app:o})=>{let{activeTool:r,isResizing:i,isRotating:a,lastPointerDownWith:s}=e,l=e.multiElement!==null;if(e.openSidebar?.name===_W.name&&e.openSidebar.tab===LW&&e.searchMatches?.matches.length)return f("hints.dismissSearch",{shortcut:Se("Escape")});if(e.openSidebar&&!t.canFitSidebar)return null;if(rn(e))return f("hints.eraserRevert",{shortcut:Se("Alt")});let c=o.scene.getSelectedElements(e);if(e.selectedLinearElement?.isDragging&&c[0]?.type==="arrow")return f("hints.arrowBindModifiers",{shortcut_1:Se("Ctrl"),shortcut_2:Se("Alt")});if(r.type==="arrow"||r.type==="line")return l?f("hints.linearElementMulti",{shortcut_1:Se("Escape"),shortcut_2:Se("Enter")}):r.type==="arrow"?f("hints.arrowTool",{shortcut:Se("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(r.type==="autoshape")return f("hints.autoshape");if(i&&s==="mouse"&&c.length===1){let d=c[0];return yk(d)&&d.points.length===2?f("hints.lockAngle",{shortcut:Se("Shift")}):xk(d)?f("hints.resizeImage",{shortcut_1:Se("Shift"),shortcut_2:Se("Alt")}):f("hints.resize",{shortcut_1:Se("Shift"),shortcut_2:Se("Alt")})}if(a&&s==="mouse")return f("hints.rotate",{shortcut:Se("Shift")});if(c.length===1&&OW(c[0]))return f("hints.text_selected",{shortcut:Se("Enter")});if(e.editingTextElement)return f("hints.text_editing",{shortcut_1:Se("Escape"),shortcut_2:Se(["CtrlOrCmd","Enter"])});if(e.croppingElementId)return f("hints.leaveCropEditor",{shortcut_1:Se("Enter"),shortcut_2:Se("Escape")});if(c.length===1&&xk(c[0]))return f("hints.enterCropEditor",{shortcut:Se("Enter")});if(r.type==="selection"){if(e.selectionElement&&!c.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return f("hints.deepBoxSelect",{shortcut:Se("CtrlOrCmd")});if(hr(o)&&e.selectedElementsAreBeingDragged)return f("hints.disableSnapping",{shortcut:Se("CtrlOrCmd")});if(!c.length&&!n)return f("hints.canvasPanning",{shortcut_1:Se(f("keys.mmb")),shortcut_2:Se("Space")});if(c.length===1){if(yk(c[0]))return RW(c[0])&&e.selectedLinearElement?.elementId===c[0].id&&(e.selectedLinearElement.hoverPointIndex===0||e.selectedLinearElement.hoverPointIndex===c[0].points.length-1)?f("hints.toggleArrowhead"):e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?f("hints.lineEditor_pointSelected",{shortcut_1:Se("Delete"),shortcut_2:Se(["CtrlOrCmd","D"])}):f("hints.lineEditor_nothingSelected",{shortcut_1:Se("Shift"),shortcut_2:Se("Alt")}):BW(c[0])?f("hints.lineEditor_line_info",{shortcut:Se("Enter")}):f("hints.lineEditor_info",{shortcut_1:Se("CtrlOrCmd"),shortcut_2:Se(["CtrlOrCmd","Enter"])});if(!e.newElement&&!e.selectedElementsAreBeingDragged&&FW(c[0])){let d=f("hints.bindTextToElement",{shortcut:Se("Enter")}),m=f("hints.createFlowchart",{shortcut:Se(["CtrlOrCmd","\u2191\u2193"])});return NW(c[0])?zW(c[0],o.scene.getNonDeletedElementsMap())?[d,m]:[d,m]:d}}}return null},wk=({appState:e,isMobile:n,editorInterface:t,app:o})=>{let r=GW({appState:e,isMobile:n,editorInterface:t,app:o});if(!r)return null;let a=(Array.isArray(r)?r.map(s=>s.replace(/\. ?$/,"")).join(", "):r).split(/(<kbd>[^<]+<\/kbd>)/g).map((s,l)=>{if(l%2===1){let c=s[0]==="<"&&s.match(/^<kbd>([^<]+)<\/kbd>$/);return mb("kbd",{children:c?c[1]:s},l)}return s});return mb("div",{className:"HintViewer",children:mb("span",{children:a})})};import HW from"clsx";import{jsx as UW}from"react/jsx-runtime";var vk=e=>UW(Z,{className:HW("ToolIcon__lock",{"is-mobile":e.isMobile}),type:"toggle",icon:e.checked?Ko:bo,checked:e.checked,disabled:e.disabled,title:`${e.title} \u2014 Q`,"aria-label":`${e.title}`,"data-testid":"toolbar-lock",onSelect:()=>e.onChange?.()});import{Fragment as xi,jsx as ie,jsxs as Ro}from"react/jsx-runtime";var XW=(e,n)=>e==="image"&&n.tools?.image===!1,KW=({app:e,activeTool:n,type:t,shortcut:o})=>ie(pe.Item,{onSelect:()=>e.setActiveTool({type:t}),icon:Ye[t].icon,"data-testid":`toolbar-${t}`,selected:n.type===t,shortcut:o??na(t),disabled:Je(e,t),children:f(`toolBar.${t}`)}),Ik=({app:e})=>ie(pe.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?Ko:bo,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:sc.Q.toLocaleUpperCase(),children:f("toolBar.lock-short")}),$W=({actionManager:e,app:n})=>{if(!e.isActionEnabled(Lt))return null;let t=je("objectsSnapMode");return ie(pe.Item,{onSelect:()=>e.executeAction(Lt,"ui"),icon:jo,"data-testid":"toolbar-objects-snap-mode",selected:n.state.objectsSnapModeEnabled,shortcut:t,children:f("buttons.objectsSnapMode")})},ZW=({actionManager:e,app:n})=>{if(!e.isActionEnabled(Lt))return null;let t=f("buttons.objectsSnapMode"),o=je("objectsSnapMode");return ie(Z,{type:"toggle",icon:jo,checked:n.state.objectsSnapModeEnabled,title:`${t} - ${o}`,"aria-label":t,"aria-keyshortcuts":o,"data-testid":"toolbar-objects-snap-mode",onSelect:()=>e.executeAction(Lt,"ui")})},Tk=({actionManager:e,appState:n})=>{let t=f("search.title"),o=je("searchMenu");return ie(pe.Item,{onSelect:()=>e.executeAction(Pl,"ui"),icon:Jn,"data-testid":"toolbar-search-menu",selected:n.openSidebar?.name===YW.name&&n.openSidebar.tab===VW,shortcut:o,children:t})},jW=({app:e})=>ie(Z,{type:"button",icon:Fi,title:`${f("labels.eyeDropper")} - ${sc.I.toLocaleUpperCase()}`,"aria-label":f("labels.eyeDropper"),"aria-keyshortcuts":sc.I.toLocaleUpperCase(),keyBindingLabel:sc.I.toLocaleUpperCase(),"data-testid":"toolbar-eyedropper",onClick:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1})}),qW=({app:e,activeTool:n,setAppState:t,UIOptions:o,isMyocSimplifiedMode:r,actionManager:i})=>{let[a,s]=WW(!1),l=ct()==="full",c=n.type==="frame",d=n.type==="autoshape",m=n.type==="laser",p=n.type==="bucketfill",u=l&&n.type==="lasso"&&e.state.preferredSelectionTool.type!=="lasso",E=n.type==="embeddable",g=r&&ea.includes(n.type);return Ro(pe,{open:a,children:[ie(pe.Trigger,{className:Sk("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":g||c||E||!r&&l&&d||u||p||m&&!e.props.isCollaborating}),onToggle:()=>{s(!a),t({openMenu:null,openPopup:null})},title:f("toolBar.extraTools"),children:g?Ye[n.type].icon:c?jn:E?Zo:!r&&l&&d?Gr:m&&!e.props.isCollaborating?qn:u?Li:p?Zn:Ts}),ie(pe.Content,{onClickOutside:()=>s(!1),onSelect:()=>s(!1),className:"App-toolbar__extra-tools-dropdown",children:r?Ro(xi,{children:[l&&ie(pe.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:Li,"data-testid":"toolbar-lasso",selected:u,disabled:Je(e,"lasso"),children:f("toolBar.lasso")}),ea.filter(b=>!XW(b,o)).map(b=>ie(KW,{app:e,activeTool:n,type:b},b)),ie("div",{className:"App-toolbar__dropdown-divider"}),ie(Tk,{actionManager:i,appState:e.state}),e.props.activeTool==null&&ie(xi,{children:ie(Ik,{app:e})})]}):Ro(xi,{children:[ie(pe.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:jn,shortcut:sc.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:c,disabled:Je(e,"frame"),children:f("toolBar.frame")}),ie(pe.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:Zo,"data-testid":"toolbar-embeddable",selected:E,disabled:Je(e,"embeddable"),children:f("toolBar.embeddable")}),ie(pe.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:Gr,shortcut:na("autoshape"),"data-testid":"toolbar-autoshape",selected:d,disabled:Je(e,"autoshape"),children:f("toolBar.autoshape")}),ie(pe.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:qn,"data-testid":"toolbar-laser",selected:m,disabled:Je(e,"laser"),children:f("toolBar.laser")}),ie(pe.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:Zn,"data-testid":"toolbar-bucketfill",selected:p,disabled:Je(e,"bucketfill"),children:f("toolBar.bucketfill")}),l&&ie(pe.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:Li,"data-testid":"toolbar-lasso",selected:u,disabled:Je(e,"lasso"),children:f("toolBar.lasso")}),ie("div",{className:"App-toolbar__dropdown-divider"}),ie($W,{actionManager:i,app:e}),ie(Tk,{actionManager:i,appState:e.state}),e.props.activeTool==null&&ie(Ik,{app:e})]})})]})},Ck=({app:e,appState:n,setAppState:t,UIOptions:o,actionManager:r,onPenModeToggle:i,onLockToggle:a,heading:s})=>{let l=be(),c=ct()==="compact",d=n.activeTool,m={app:e,activeTool:d},p=n.myocSimplifiedMode,u=c?ie(Gd,{...m,setAppState:t}):n.preferredSelectionTool.type==="lasso"?ie(tw,{...m}):ie(ew,{...m});return Ro(Ue,{padding:1,className:Sk("App-toolbar",{"zen-mode":n.zenModeEnabled,"App-toolbar--compact":c}),"data-viewport-ui":"top",children:[ie(wk,{appState:n,isMobile:l.formFactor==="phone",editorInterface:l,app:e}),s,Ro(Bt.Row,{gap:c?.5:1,children:[!c&&ie(qa,{checked:n.penMode,onChange:()=>i(null),title:f("toolBar.penMode"),penDetected:n.penDetected}),e.props.activeTool==null&&!p&&Ro(xi,{children:[ie(vk,{checked:n.activeTool.locked,onChange:a,title:f("toolBar.lock"),disabled:e.props.activeTool!=null}),ie("div",{className:"App-toolbar__divider"})]}),ie(zd,{...m}),u,p?Ro(xi,{children:[ie(Zs,{...m}),ie(js,{...m}),ie(jW,{app:e}),o.tools?.image!==!1&&ie(qs,{...m}),ie(Js,{...m})]}):Ro(xi,{children:[ie($y,{...m}),ie(Zy,{...m}),ie(jy,{...m}),ie(qy,{...m}),ie(Jy,{...m}),c?ie(Hd,{...m}):ie(Zs,{...m}),ie(js,{...m}),o.tools?.image!==!1&&ie(qs,{...m}),ie(Js,{...m})]}),ie("div",{className:"App-toolbar__divider"}),ie(qW,{app:e,activeTool:d,setAppState:t,UIOptions:o,isMyocSimplifiedMode:p,actionManager:r}),p&&Ro(xi,{children:[ie("div",{className:"App-toolbar__divider"}),ie(ZW,{actionManager:r,app:e})]})]})]})};import{Fragment as pb,jsx as te,jsxs as tn}from"react/jsx-runtime";var rV=({UIOptions:e})=>tn(Ft,{__fallback:!0,children:[te(Ft.DefaultItems.LoadScene,{}),te(Ft.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&te(Ft.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&te(Ft.DefaultItems.SaveAsImage,{}),te(Ft.DefaultItems.SearchMenu,{}),te(Ft.DefaultItems.Help,{}),te(Ft.Separator,{}),te(Ft.Group,{title:"Excalidraw links",children:te(Ft.DefaultItems.Socials,{})}),te(Ft.Separator,{}),te(Ft.DefaultItems.ToggleTheme,{allowSystemTheme:!1}),te(Ft.DefaultItems.ChangeCanvasBackground,{})]}),iV=()=>tn(Pp,{__fallback:!0,children:[te(Pp.Actions.SaveToDisk,{}),te(Pp.Actions.ExportToImage,{})]}),aV=({actionManager:e,appState:n,files:t,setAppState:o,elements:r,canvas:i,onLockToggle:a,onPenModeToggle:s,showExitZenModeBtn:l,renderTopLeftUI:c,renderTopRightUI:d,renderCustomStats:m,UIOptions:p,onExportImage:u,renderWelcomeScreen:E,children:g,app:b,defaultUIEnabled:w,zoomUIEnabled:y,scrollBackToContentUIEnabled:x,isCollaborating:I,generateLinkForSelection:T,currentUserControls:C})=>{let P=be(),M=kn(),_=ct()==="compact",k=JT(),L=_?{menuTopGap:4,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:.5,islandPadding:1,collabMarginLeft:8}:{menuTopGap:6,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:1,islandPadding:1,collabMarginLeft:8},F=k.tunnelsJotai.Provider,[Y,z]=He(Gt),U=()=>p.canvasActions.export?te(Ek,{elements:r,appState:n,files:t,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:o}):null,V=()=>!p.canvasActions.saveAsImage||n.openDialog?.name!=="imageExport"?null:te(ZP,{elements:r,appState:n,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>o({openDialog:null}),name:b.getName()}),G=()=>tn("div",{style:{position:"relative"},children:[tn("div",{className:"excalidraw-ui-top-left",children:[c?.(!1,n),te(k.MainMenuTunnel.Out,{}),te(k.DefaultSidebarTriggerTunnel.Out,{})]}),E&&te(k.WelcomeScreenMenuHintTunnel.Out,{})]}),re=()=>te(Kl,{heading:"selectedShapeActions",className:ls("selected-shape-actions zen-mode-transition",{"transition-left":n.zenModeEnabled}),children:_?te(Ue,{className:ls("compact-shape-actions-island"),padding:0,"data-viewport-ui":"side","data-viewport-ui-name":"stylesPanel",style:{maxHeight:`${n.height-166}px`},children:te(ES,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b,setAppState:o})}):te(Ue,{className:QW.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${n.height-166}px`},"data-viewport-ui":"side","data-viewport-ui-name":"stylesPanel",children:te(pS,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b})})}),B=()=>{let le=w&&oV(n,r),he=w&&n.stats.open&&!n.zenModeEnabled&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector";return te(bp,{side:"top",children:tn("div",{className:"App-menu App-menu_top",children:[tn(Bt.Col,{gap:L.menuTopGap,className:ls("App-menu_top__left"),children:[G(),w&&te("div",{className:ls("selected-shape-actions-container",{"selected-shape-actions-container--compact":_}),children:le&&re()}),w&&_&&!n.viewModeEnabled&&le&&te(qa,{checked:n.penMode,onChange:()=>s(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:n.penDetected})]}),w&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector"&&te(Kl,{heading:"shapes",className:"shapes-section",children:ge=>tn("div",{style:{position:"relative"},children:[E&&te(k.WelcomeScreenToolbarHintTunnel.Out,{}),te(Bt.Col,{gap:L.toolbarColGap,align:"start",children:tn(Bt.Row,{gap:L.toolbarRowGap,className:ls("App-toolbar-container",{"zen-mode":n.zenModeEnabled}),children:[te(Ck,{app:b,appState:n,setAppState:o,UIOptions:p,actionManager:e,onPenModeToggle:s,onLockToggle:a,heading:ge}),I&&te(Ue,{style:{marginLeft:L.collabMarginLeft,alignSelf:"center",height:"fit-content"},children:te(bk,{title:f("toolBar.laser"),checked:n.activeTool.type===Pk.laser,onChange:()=>b.setActiveTool({type:Pk.laser}),isMobile:!0})})]})})]})}),tn("div",{className:ls("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":n.zenModeEnabled,"layer-ui__wrapper__top-right--compact":_}),children:[w&&n.collaborators.size>0&&te(vp,{collaborators:n.collaborators,userToFollow:M.userToFollow?.socketId||null,currentUserControls:C}),d?.(P.formFactor==="phone",n),he&&te(tc,{app:b,onClose:()=>{e.executeAction(mr)},renderCustomStats:m})]})]})})},W=()=>te(lb,{}),ue=!1,Ee=tn(pb,{children:[g,w&&te(pb,{children:te(rV,{UIOptions:p})}),te(iV,{}),w&&n.isLoading&&te(up,{delay:250}),w&&n.errorMessage&&te(DP,{onClose:()=>o({errorMessage:null}),children:n.errorMessage}),w&&Y&&P.formFactor!=="phone"&&te(F0,{colorPickerType:Y.colorPickerType,onCancel:()=>{z(null)},onChange:(le,he,ge,{altKey:se})=>{if(!(le!=="elementBackground"&&le!=="elementStroke"))if(ge.length){for(let xe of ge)tV(xe,eV(r),{[se&&Y.swapPreviewOnAlt?le==="elementBackground"?"strokeColor":"backgroundColor":le==="elementBackground"?"backgroundColor":"strokeColor"]:he}),nV.delete(xe);b.scene.triggerUpdate()}else o(le==="elementBackground"?{currentItemBackgroundColor:he}:{currentItemStrokeColor:he})},onSelect:(le,he)=>{z(ge=>ge?.keepOpenOnAlt&&he.altKey?ge:null),Y?.onSelect?.(le,he)}}),n.openDialog?.name==="help"&&te(UP,{onClose:()=>{o({openDialog:null})}}),w&&n.openDialog?.name==="elementLinkSelector"&&te(AP,{sourceElementId:n.openDialog.sourceElementId,onClose:()=>{o({openDialog:null})},scene:b.scene,appState:n,generateLinkForSelection:T}),te(k.OverwriteConfirmDialogTunnel.Out,{}),V(),U(),w&&n.openDialog?.name==="charts"&&te(iC,{data:n.openDialog.data,rawText:n.openDialog.rawText,onClose:()=>o({openDialog:null})}),w&&te(OP,{app:b,files:t,setAppState:o}),P.formFactor==="phone"&&te(KS,{app:b,appState:n,elements:r,actionManager:e,renderJSONExportDialog:U,renderImageExportDialog:V,setAppState:o,onPenModeToggle:s,renderTopLeftUI:c,renderTopRightUI:d,renderSidebars:W,renderWelcomeScreen:E,defaultUIEnabled:w,scrollBackToContentUIEnabled:x}),P.formFactor!=="phone"&&tn(pb,{children:[M.viewportStatusFrame?.border&&te(dp,{border:M.viewportStatusFrame.border,style:ue?{right:"calc(var(--right-sidebar-width) - var(--space-factor) * 2)"}:void 0}),tn("div",{className:"layer-ui__wrapper",style:ue?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[E&&te(k.WelcomeScreenCenterTunnel.Out,{}),B(),te(pC,{appState:n,actionManager:e,showExitZenModeBtn:l,renderWelcomeScreen:E,defaultUIEnabled:w,zoomUIEnabled:y}),(n.toast||x&&n.scrolledOutside||M.viewportStatusFrame?.label)&&tn("div",{className:"floating-status-stack",children:[n.toast&&te(Yd,{message:n.toast.message,onClose:()=>o({toast:null}),duration:n.toast.duration,closable:n.toast.closable}),!n.toast&&x&&n.scrolledOutside&&te("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(le=>({...Si(r,le)}))},children:f("buttons.scrollBackToContent")}),M.viewportStatusFrame?.label&&te(mp,{label:M.viewportStatusFrame.label,border:M.viewportStatusFrame.border})]})]})]}),W()]});return te(hh.Provider,{value:n,children:te(F,{children:te(nE.Provider,{value:k,children:Ee})})})},kk=e=>{let{cursorButton:n,scrollX:t,scrollY:o,zoom:r,shouldCacheIgnoreZoom:i,snapLines:a,originSnapOffset:s,suggestedBinding:l,frameToHighlight:c,elementsToHighlight:d,...m}=e;return m},sV=(e,n)=>{if(e.children!==n.children)return!1;let{canvas:t,appState:o,...r}=e,{canvas:i,appState:a,...s}=n;return Yp(kk(o),kk(a),{selectedElementIds:Yp,selectedGroupIds:Yp})&&Yp(r,s)},Mk=JW.memo(aV,sV);import{useEffect as lV,useRef as cV}from"react";import{jsx as Ak}from"react/jsx-runtime";var Dk=({trails:e})=>{let n=cV(null);return lV(()=>{if(n.current)for(let t of e)t.start(n.current);return()=>{for(let t of e)t.stop()}},e),Ak("div",{className:"SVGLayer",children:Ak("svg",{ref:n})})};import dV,{useEffect as Lk,useRef as _k}from"react";import{isShallowEqual as mV,sceneCoordsToViewportCoords as pV}from"@excalidraw/common";import{jsx as gV}from"react/jsx-runtime";var Rk="animateInteractiveScene",uV=e=>{let n=_k(!1),t=_k(null);return Lk(()=>{let o=null,r=()=>{o===null&&(o=requestAnimationFrame(()=>{o=null,t.current&&Gf({...t.current,callback:()=>{}})}))},i=e.app.imageLoadingProgressEmitter.on(r),a=e.app.imageStatusEmitter.on(r);return()=>{i(),a(),o!==null&&cancelAnimationFrame(o)}},[e.app]),Lk(()=>{if(!n.current){n.current=!0;return}let o=new Map,r=new Map,i=new Map,a=new Map,s=new Map;e.appState.collaborators.forEach((c,d)=>{if(c.selectedElementIds)for(let m of Object.keys(c.selectedElementIds))i.has(m)||i.set(m,[]),i.get(m).push(d);!c.pointer||c.pointer.renderCursor===!1||(c.username&&a.set(d,c.username),c.userState&&s.set(d,c.userState),r.set(d,pV({sceneX:c.pointer.x,sceneY:c.pointer.y},e.appState)),o.set(d,c.button))});let l=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:o,remoteSelectedElementIds:i,remotePointerUsernames:a,remotePointerUserStates:s,selectionColor:l,renderScrollbars:e.renderScrollbars,lastViewportPosition:e.app.viewport.lastPosition},editorInterface:e.editorInterface,callback:e.renderInteractiveSceneCallback,animationState:{bindingHighlight:void 0},deltaTime:0},st.running(Rk)||st.start(Rk,({deltaTime:c,state:d})=>{let m=Gf({...t.current,deltaTime:c,animationState:d}).animationState;if(m){for(let p in m)if(m[p]!==void 0)return m}})}),gV("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onClick:e.onClick,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.appState.viewModeEnabled?void 0:e.onDoubleClick,children:f("labels.drawingCanvas")})},Nk=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,activeTool:e.activeTool,openDialog:e.openDialog,editingGroupId:e.editingGroupId,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,newElement:e.newElement,isBindingEnabled:e.isBindingEnabled,isMidpointSnappingEnabled:e.isMidpointSnappingEnabled,gridModeEnabled:e.gridModeEnabled,suggestedBinding:e.suggestedBinding,hoveredArrowTextAnchor:e.hoveredArrowTextAnchor,isRotating:e.isRotating,elementsToHighlight:e.elementsToHighlight,collaborators:e.collaborators,activeEmbeddable:e.activeEmbeddable,snapLines:e.snapLines,zenModeEnabled:e.zenModeEnabled,editingTextElement:e.editingTextElement,isCropping:e.isCropping,croppingElementId:e.croppingElementId,searchMatches:e.searchMatches,activeLockedId:e.activeLockedId,hoveredElementIds:e.hoveredElementIds,frameRendering:e.frameRendering,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,exportScale:e.exportScale,currentItemArrowType:e.currentItemArrowType}),hV=(e,n)=>e.selectionNonce!==n.selectionNonce||e.canvasNonce!==n.canvasNonce||e.scale!==n.scale||e.elementsMap!==n.elementsMap||e.visibleElements!==n.visibleElements||e.selectedElements!==n.selectedElements||e.renderScrollbars!==n.renderScrollbars||e.interactionEnabled!==n.interactionEnabled||e.navigationEnabled!==n.navigationEnabled?!1:mV(Nk(e.appState),Nk(n.appState)),ub=dV.memo(uV,hV);import Ok,{useEffect as Xp,useRef as lc}from"react";import{isShallowEqual as Bk}from"@excalidraw/common";import{hasActiveGifDecode as fV}from"@excalidraw/element";import{jsx as xV}from"react/jsx-runtime";var EV=e=>{let n=lc(null),t=lc(!1),o=lc(e),r=lc(()=>{}),i=lc(null);o.current=e;let a=Ok.useCallback(()=>{let s=o.current,l=n.current;if(!l)return;let c=getComputedStyle(l).getPropertyValue("--color-grid-bold").trim(),d=getComputedStyle(l).getPropertyValue("--color-grid-regular").trim();hx({canvas:s.canvas,rc:s.rc,scale:s.scale,elementsMap:s.elementsMap,allElementsMap:s.allElementsMap,visibleElements:s.visibleElements,appState:s.appState,renderConfig:{...s.renderConfig,gridColorBold:c,gridColorRegular:d}},ka());let m=s.renderConfig.imageTransitionDuration??0,p=m>0&&s.visibleElements.some(E=>{if(E.type!=="image"||!E.fileId)return!1;let g=s.renderConfig.imageCache.get(E.fileId)?.transitionStart;return g!==void 0&&performance.now()-g<m}),u=fV(s.visibleElements,s.renderConfig.imageCache);(p||u)&&i.current===null&&(i.current=requestAnimationFrame(()=>{i.current=null,r.current()}))},[]);return r.current=a,Xp(()=>{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]),Xp(()=>{let s=n.current;if(!s)return;let l=e.canvas;t.current||(t.current=!0,s.replaceChildren(l),l.classList.add("excalidraw__canvas","static")),a()}),Xp(()=>{let s=null,l=e.app.imagePlaceholderUpdateEmitter.on(()=>{s===null&&(s=requestAnimationFrame(()=>{s=null,a()}))});return()=>{l(),s!==null&&cancelAnimationFrame(s)}},[e.app,a]),Xp(()=>()=>{i.current!==null&&cancelAnimationFrame(i.current)},[]),xV("div",{className:"excalidraw__canvas-wrapper",ref:n})},Fk=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}),bV=(e,n)=>e.canvasNonce!==n.canvasNonce||e.scale!==n.scale||e.elementsMap!==n.elementsMap||e.visibleElements!==n.visibleElements?!1:Bk(Fk(e.appState),Fk(n.appState))&&Bk(e.renderConfig,n.renderConfig),hb=Ok.memo(EV,bV);import{useEffect as CV,useRef as PV}from"react";import{throttleRAF as yV}from"@excalidraw/common";import{getTargetFrame as wV,isInvisiblySmallElement as vV,renderElement as IV,shouldApplyFrameClip as TV}from"@excalidraw/element";var zk=({canvas:e,rc:n,newElement:t,elementsMap:o,allElementsMap:r,scale:i,appState:a,renderConfig:s})=>{if(e){let[l,c]=Ac(e,i),d=Dc({canvas:e,scale:i,normalizedWidth:l,normalizedHeight:c});if(d.save(),d.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"){if(vV(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let u=wV(t,o,a);u&&TV(t,u,a,o)&&px(u,d,s,a)}IV(t,o,r,n,d,s,a)}else d.clearRect(0,0,l,c);d.restore()}},SV=yV(e=>{zk(e)}),Gk=(e,n)=>{if(n){SV(e);return}zk(e)};import{jsx as MV}from"react/jsx-runtime";var kV=e=>{let n=PV(null);return CV(()=>{n.current&&Gk({canvas:n.current,scale:e.scale,newElement:e.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},ka())}),MV("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:n})},Hk=kV;import AV from"clsx";import{useLayoutEffect as DV,useEffect as Uk,useRef as LV,useState as _V}from"react";import{ARROW_TYPE as Wk,EVENT as Kp}from"@excalidraw/common";import{jsx as FV}from"react/jsx-runtime";var Vk=700,RV=100,NV=16,BV=5*60*1e3,Xk=Qe(null),Yk=e=>e===Wk.elbow?Jo:e===Wk.round?Qo:qo,$p=class{constructor(n){v(this,"app");v(this,"lastShownAt",0);v(this,"show",n=>{let{x:t,y:o}=this.app.viewport.lastPosition;t===0&&o===0||(this.lastShownAt=Date.now(),this.app.updateEditorAtom(Xk,{content:n,nonce:Math.random()}))});v(this,"isOnCooldown",()=>Date.now()-this.lastShownAt<BV);v(this,"onArrowTypeCycled",n=>{this.show(Yk(n))});v(this,"onToolShortcut",(n,t)=>{(t==="digit"||!this.isOnCooldown())&&this.show(n==="line"?$o:Yk(this.app.state.currentItemArrowType))});this.app=n}},Kk=()=>{let[e,n]=He(Xk),t=St(),{container:o}=Ne(),r=LV(null),[i,a]=_V(!1),s=e?.nonce;return DV(()=>{if(s==null||!o)return;let l=(d,m)=>{let p=r.current;if(!p)return;let{left:u,top:E}=sd({cursor:{x:d,y:m},element:{width:p.offsetWidth,height:p.offsetHeight},container:o.getBoundingClientRect(),gap:NV});p.style.transform=`translate(${u}px, ${E}px)`};l(t.viewport.lastPosition.x,t.viewport.lastPosition.y);let c=d=>{l(d.clientX,d.clientY)};return window.addEventListener(Kp.POINTER_MOVE,c),()=>{window.removeEventListener(Kp.POINTER_MOVE,c)}},[s,o,t]),Uk(()=>()=>{n(null)},[n]),Uk(()=>{if(s==null)return;a(!1);let l=window.setTimeout(()=>{a(!0)},Vk),c=window.setTimeout(()=>{n(null)},Vk+RV),d=()=>{n(null)};return window.addEventListener(Kp.POINTER_DOWN,d,{capture:!0}),()=>{window.clearTimeout(l),window.clearTimeout(c),window.removeEventListener(Kp.POINTER_DOWN,d,{capture:!0})}},[s,n]),e?FV("div",{ref:r,className:AV("CursorHint",{"CursorHint--fade-out":i}),"data-testid":"cursor-hint",children:e.content}):null};var Zp=class{constructor(n){this.getState=n;v(this,"listeners",[]);v(this,"onStateChange",(n,t,o)=>{let{predicate:r,getValue:i,callback:a,once:s,matchesImmediately:l}=this.normalize(n,t,o);return a?l&&(queueMicrotask(()=>{let c=this.getState();a(i(c),c)}),s)?()=>{}:this.subscribe({predicate:r,getValue:i,callback:a,once:s}):l?Promise.resolve(i(this.getState())):new Promise(c=>{this.subscribe({predicate:r,getValue:i,callback:d=>c(d),once:!0})})})}isStateChangePredicateOptions(n){return typeof n=="object"&&!Array.isArray(n)&&"predicate"in n}subscribe(n){return this.listeners.push(n),()=>{this.listeners=this.listeners.filter(t=>t!==n)}}normalize(n,t,o){let r,i,a=t,s=o?.once??!1,l=!1;if(this.isStateChangePredicateOptions(n)){let{predicate:c,callback:d,once:m}=n;r=c,i=p=>p,a=d?(p,u)=>d(u):void 0,s=m??!1,l=c(this.getState())}else if(typeof n=="function"){let c=n;r=(d,m)=>c(d)!==c(m),i=d=>c(d)}else if(Array.isArray(n)){let c=n;r=(d,m)=>c.some(p=>d[p]!==m[p]),i=d=>d}else{let c=n;r=(d,m)=>d[c]!==m[c],i=d=>d[c]}return{predicate:r,getValue:i,callback:a,once:s,matchesImmediately:l}}flush(n){if(!this.listeners.length)return;let t=this.getState(),o=[];for(let r of this.listeners)r.predicate(t,n)?(r.callback(r.getValue(t),t),r.once||o.push(r)):o.push(r);this.listeners=o}clear(){this.listeners=[]}};import{getCommonBounds as OV,getElementsInGroup as zV,isNonDeletedElement as $k,selectGroupsFromGivenElements as GV}from"@excalidraw/element";import{sceneCoordsToViewportCoords as HV}from"@excalidraw/common";import{flushSync as UV}from"react-dom";import{jsx as VV}from"react/jsx-runtime";var WV=({app:e,activeLockedId:n})=>{let t=e.scene.getElement(n);t&&!$k(t)&&console.error("[NONDELETED][INVARIANT] UnlockPopup: activeLockedId points to a deleted element");let o=t&&$k(t)?t:null,r=o?[o]:zV(e.scene.getNonDeletedElementsMap(),n);if(r.length===0)return null;let[i,a]=OV(r),{x:s,y:l}=HV({sceneX:i,sceneY:a},e.state);return VV("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${s-e.state.offsetLeft}px`},onClick:()=>{UV(()=>{let c=GV(r,e.state);e.setState({selectedElementIds:r.reduce((d,m)=>({...d,[m.id]:!0}),{}),selectedGroupIds:c,activeLockedId:null})}),e.actionManager.executeAction(ml)},title:f("labels.elementLock.unlock"),children:Bx})},Zk=WV;import{Fragment as UX,jsx as Pe,jsxs as Fb}from"react/jsx-runtime";var o3=In.createContext(null),r3=In.createContext(null),Ob={formFactor:"desktop",desktopUIMode:"full",userAgent:t3(typeof navigator<"u"?navigator.userAgent:""),isTouchScreen:!1,canFitSidebar:!1,isLandscape:!0},Gb=In.createContext(Ob);Gb.displayName="EditorInterfaceContext";var zX={"editor:mount":{cardinality:"once",replay:"last"},"editor:initialize":{cardinality:"once",replay:"last"},"editor:unmount":{cardinality:"once",replay:"last"}},Hb=In.createContext({container:null,id:null});Hb.displayName="ExcalidrawContainerContext";var Ub=In.createContext([]);Ub.displayName="ExcalidrawElementsContext";var Wb=In.createContext({...Xo(),width:0,height:0,offsetLeft:0,offsetTop:0});Wb.displayName="ExcalidrawAppStateContext";var Vb=In.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});Vb.displayName="ExcalidrawSetAppStateContext";var Yb=In.createContext(null);Yb.displayName="ExcalidrawActionManagerContext";var us=In.createContext(null);us.displayName="ExcalidrawAPIContext";var pu=In.createContext(null);pu.displayName="ExcalidrawAPISetContext";var St=()=>Go(o3),kn=()=>Go(r3),be=()=>Go(Gb),ct=()=>mu(be()),Ne=()=>Go(Hb),Ui=()=>Go(Ub),Qn=()=>Go(Wb),Oe=()=>Go(Vb),rt=()=>Go(Yb),Md=()=>Go(us),bc=!1,xc=0,yc=null,Oo=!1,su=!1,zo=!1,lu=!1,wc={horizontal:null,vertical:null},Dr=0,vc=!1,Bb=new Map,GX=4,cu=!1,du=0,JM=!1,ps=null,de={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},zb=class e extends In.Component{constructor(t){super(t);v(this,"canvas");v(this,"interactiveCanvas",null);v(this,"sessionExportThemeOverride");v(this,"rc");v(this,"unmounted",!1);v(this,"actionManager");v(this,"editorInterface",Ob);v(this,"stylesPanelMode",mu(Ob));v(this,"excalidrawContainerRef",In.createRef());v(this,"scene");v(this,"fonts");v(this,"renderer");v(this,"visibleElements");v(this,"hasRenderableElements",!1);v(this,"resizeObserver");v(this,"id");v(this,"store");v(this,"history");v(this,"excalidrawContainerValue");v(this,"files",{});v(this,"imageCache",new Map);v(this,"imageLoadingProgress",new Map);v(this,"imageLoadingProgressEmitter",new co);v(this,"imageStatus",new Map);v(this,"imageStatusEmitter",new co);v(this,"imagePlaceholderUpdateEmitter",new co);v(this,"iFrameRefs",new Map);v(this,"embedsValidationStatus",new Map);v(this,"initializedEmbeds",new Set);v(this,"elementsPendingErasure",new Set);v(this,"_initialized",!1);v(this,"editorLifecycleEvents",new yY(zX));v(this,"onEvent",this.editorLifecycleEvents.on.bind(this.editorLifecycleEvents));v(this,"appStateObserver",new Zp(()=>this.state));v(this,"onStateChange",this.appStateObserver.onStateChange);v(this,"bucketFill",new ep(this));v(this,"flowchart",new ip(this));v(this,"cursor",new tp(this));v(this,"gifPlayback",new ap(this));v(this,"zDragZoom",null);v(this,"arrowText",new Qm(this));v(this,"viewport",new lp(this,{getContainer:()=>this.excalidrawContainerRef.current,getStylesPanelMode:()=>this.stylesPanelMode,isGestureActive:()=>de.pointers.size>=2||zo}));v(this,"bindModeHandler",null);v(this,"textWysiwygSubmitHandler",null);v(this,"hitLinkElement");v(this,"lastPointerDownEvent",null);v(this,"lastPointerUpEvent",null);v(this,"lastPointerUpIsDoubleClick",!1);v(this,"lastPointerMoveEvent",null);v(this,"lastPointerMoveCoords",null);v(this,"lastCompletedCanvasClicks",[]);v(this,"previousPointerMoveCoords",null);v(this,"drawShape",new rp(this));v(this,"laserTrails",new Am(this));v(this,"eraserTrail",new Fm(this));v(this,"lassoTrail",new Bm(this));v(this,"cursorHints",new $p(this));v(this,"onChangeEmitter",new co);v(this,"onPointerDownEmitter",new co);v(this,"onPointerUpEmitter",new co);v(this,"onUserFollowEmitter",new co);v(this,"onScrollChangeEmitter",new co);v(this,"missingPointerEventCleanupEmitter",new co);v(this,"onRemoveEventListenersEmitter",new co);v(this,"api");v(this,"isToolSupported",(t,o=this.props)=>{if(t==="magicframe"||o.UIOptions.tools?.[t]===!1)return!1;if(this.isInteractionEnabled(o))return!0;let r=typeof o.interaction=="object"&&o.interaction!==null?o.interaction.enabled?.tools:void 0;return t==="laser"?r?.laser===!0:t==="custom"?r?.custom===!0:!1});v(this,"updateEditorAtom",(t,...o)=>{let r=Et.set(t,...o);return this.triggerRender(),r});v(this,"previousHoveredBindableElement",null);v(this,"getEffectiveGridSize",()=>hr(this)?this.state.gridSize:null);v(this,"getTextCreationGridPoint",(t,o)=>{let r=this.getEffectiveGridSize();if(r===null)return null;let i=a=>Math.floor(a/r)*r;return{x:i(t),y:i(o)}});v(this,"handleIframeLikeElementHover",({hitElement:t,scenePointer:o,moveEvent:r})=>t&&fc(t)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(t,r,o.x,o.y))?(this.cursor.set(Ae.POINTER),this.setState({activeEmbeddable:{element:t,state:"hover"}}),!0):(this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null}),!1));v(this,"isDoubleClick",(t,o)=>t!=null&&o.timeStamp-t.timeStamp<=aM);v(this,"updateEmbedValidationStatus",(t,o)=>{this.embedsValidationStatus.set(t.id,o),wi.delete(t)});v(this,"updateEmbeddables",()=>{let t=new Set,o=!1;this.scene.getNonDeletedElements().filter(r=>{if(Fo(r)){if(t.add(r.id),!this.embedsValidationStatus.has(r.id)){o=!0;let i=Sb(r.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(r,i)}}else Ib(r)&&t.add(r.id);return!1}),o&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((r,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});v(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);v(this,"frameNameBoundsCache",{get:t=>{let o=this.frameNameBoundsCache._cache.get(t.id);if(!o||o.zoom!==this.state.zoom.value||o.versionNonce!==t.versionNonce){let r=document.getElementById(this.getFrameNameDOMId(t));if(r){let i=r.getBoundingClientRect(),a=Me({clientX:i.x,clientY:i.y},this.state),s=Me({clientX:i.right,clientY:i.bottom},this.state);return o={x:a.x,y:a.y,width:s.x-a.x,height:s.y-a.y,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,o),o}return null}return o},_cache:new Map});v(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});v(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===mc.DARK,o=this.scene.getNonDeletedFramesLikes(),r=o.length>0&&this.state.searchMatches?.focusedId&&Tt(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return o.map(i=>{if(!TM(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:s}=Qp({sceneX:i.x,sceneY:i.y},this.state),l=6,c,d=rX(i);if(i.id===this.state.editingFrame){let m=d;c=Pe("input",{autoFocus:!0,value:m,onChange:p=>{this.scene.mutateElement(i,{name:p.target.value})},onFocus:p=>p.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:p=>{(p.key===$.ESCAPE||p.key===$.ENTER)&&this.resetEditingFrame(i)},style:{background:xY(this.state.viewBackgroundColor,t),zIndex:2,border:"none",display:"block",padding:`${l}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${No.nameFontSize}px`,transform:`translate(-${l}px, ${l}px)`,color:t?No.nameColorDarkTheme:No.nameColorLightTheme,overflow:"hidden",maxWidth:`${document.body.clientWidth-a-l}px`},size:m.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else c=d;return Pe("div",{id:this.getFrameNameDOMId(i),className:vb.FRAME_NAME,style:{position:"absolute",bottom:`${this.state.height+No.nameOffsetY-s+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:No.nameFontSize,color:t?No.nameColorDarkTheme:No.nameColorLightTheme,lineHeight:No.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:Ae.MOVE,pointerEvents:this.state.viewModeEnabled?cs.disabled:cs.enabled},onPointerDown:m=>this.handleCanvasPointerDown(m),onWheel:m=>this.handleWheel(m),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:c},i.id)})});v(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});v(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());v(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());v(this,"getSceneElements",()=>this.scene.getNonDeletedElements());v(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});v(this,"onExportImage",async(t,o,r)=>{Fe("export",t,"ui");let i=await Zr(t,o,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:r.exportingFrame}).catch(EY).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&_c(i)&&this.setState({fileHandle:i})});v(this,"openEyeDropper",({type:t,swapPreviewOnAlt:o=!0})=>{this.updateEditorAtom(Gt,{swapPreviewOnAlt:o,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(r,i)=>{let a=t==="stroke"?!o||!i.altKey:o&&i.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?a?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:r},captureUpdate:$t.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},captureUpdate:$t.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?po(l,{[a?"strokeColor":"backgroundColor"]:r}):l),captureUpdate:$t.IMMEDIATELY})},keepOpenOnAlt:!1})});v(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});v(this,"syncActionResult",Ke(t=>{if(this.unmounted||t===!1)return;this.store.scheduleAction(t.captureUpdate);let o=!1,r=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),o=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||r||this.state.contextMenu){let i=t?.appState?.viewModeEnabled??this.state.viewModeEnabled,a=t?.appState?.theme||this.props.theme||mc.LIGHT,s=t?.appState?.name??this.state.name,l=t?.appState?.errorMessage??this.state.errorMessage;if(typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),this.isInteractionEnabled()||(i=!0),r=t.appState?.editingTextElement||null,t.elements&&r){let c=r.id,d=t.elements.find(m=>m.id===c);r=d&&au(d)&&Kt(d)?d:null}this.setState(c=>{let d=t.appState||{};return{...c,...d,contextMenu:null,editingTextElement:r,viewModeEnabled:i,zenModeEnabled:!1,theme:a,name:s,errorMessage:l}}),o=!0}o||this.scene.triggerUpdate()}));v(this,"scheduleCapture",()=>this.store.scheduleCapture());v(this,"scheduleUpdate",()=>this.store.scheduleAction($t.NEVER));v(this,"onBlur",Ke(()=>{Oo=!1,this.setState({isBindingEnabled:this.state.bindingPreference==="enabled"})}));v(this,"onUnload",()=>{this.onBlur()});v(this,"disableEvent",t=>{t.preventDefault()});v(this,"preventBrowserZoomWheel",t=>{t[$.CTRL_OR_CMD]&&t.preventDefault()});v(this,"handleNavigationModeKeyDown",t=>{if(this.maybeHandlePageScrollKeyDown(t)){t.preventDefault();return}this.actionManager.handleKeyDown(t)});v(this,"maybeHandlePageScrollKeyDown",t=>{if(t.key!==$.PAGE_UP&&t.key!==$.PAGE_DOWN)return!1;let o=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;return t.key===$.PAGE_DOWN&&(o=-o),t.shiftKey?this.viewport.translate(r=>({scrollX:r.scrollX+o})):this.viewport.translate(r=>({scrollY:r.scrollY+o})),!0});v(this,"preventBrowserZoomKeyDown",t=>{t[$.CTRL_OR_CMD]&&(t.code===kr.EQUAL||t.code===kr.MINUS||t.code===kr.ZERO||t.code===kr.NUM_ADD||t.code===kr.NUM_SUBTRACT||t.code===kr.NUM_ZERO)&&t.preventDefault()});v(this,"terminateActiveInteraction",()=>{if(this.maybeCleanupAfterMissingPointerUp(null),Oo=!1,su=!1,zo=!1,lu=!1,ps=null,de.pointers.clear(),de.lastCenter=null,de.initialDistance=null,de.initialScale=null,clearTimeout(xc),xc=0,e.resetTapTwice(),this.resetContextMenuTimer(),clearTimeout(du),du=0,cu=!1,this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.flowchart.clear(),Et.set(Gt,null),Et.set(ro,null),this.state.editingFrame){let t=this.scene.getNonDeletedElement(this.state.editingFrame);this.resetEditingFrame(t&&Tt(t)?t:null)}queueMicrotask(()=>{(!this.isInteractionEnabled()||this.state.viewModeEnabled)&&this.textWysiwygSubmitHandler?.()}),this.setState({contextMenu:null,openMenu:null,openPopup:null,cursorButton:"up",bindMode:"orbit",activeEmbeddable:null,activeLockedId:null,selectedElementsAreBeingDragged:!1,selectionElement:null,resizingElement:null,isResizing:!1,isRotating:!1,isCropping:!1,croppingElementId:null,suggestedBinding:null,frameToHighlight:null,elementsToHighlight:null,snapLines:[],showHyperlinkPopup:!1}),this.deselectElements(),this.isInteractionEnabled()||(this.setState({originSnapOffset:null}),this.cursor.reset())});v(this,"handleInteractionStateChange",(t,o)=>{let r=this.isInteractionEnabled(t),i=r!==this.isInteractionEnabled(),a=t.viewModeEnabled!==this.props.viewModeEnabled,s=this.state.viewModeEnabled;this.isInteractionEnabled()?(a||i)&&(s=!!this.props.viewModeEnabled):s=!0,s!==this.state.viewModeEnabled&&this.setState({viewModeEnabled:s});let l=r&&!o.viewModeEnabled,c=this.isInteractionEnabled()&&!this.state.viewModeEnabled;(i&&!this.isInteractionEnabled()||l&&!c)&&this.terminateActiveInteraction(),i&&this.addEventListeners(),this.isLinksEnabled(t)!==this.isLinksEnabled()&&(this.isLinksEnabled()||(this.hitLinkElement=void 0,mm(),this.cursor.reset())),this.isEmbedsEnabled(t)!==this.isEmbedsEnabled()&&(this.isEmbedsEnabled()||this.setState({activeEmbeddable:null})),this.isToolSupported(o.activeTool.type,t)!==this.isToolSupported(this.state.activeTool.type)&&(this.isToolSupported(this.state.activeTool.type)||this.laserTrails.endPath(),this.cursor.reset()),!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)&&this.state.activeTool.type!=="selection"&&this.setState({activeTool:nn(this.state,{type:"selection"})}),(this.isBrowserZoomEnabled(t)!==this.isBrowserZoomEnabled()||this.isNavigationEnabled(t)!==this.isNavigationEnabled())&&(this.addEventListeners(),this.cursor.reset()),o.viewModeEnabled!==this.state.viewModeEnabled&&(this.isInteractionEnabled()&&this.addEventListeners(),this.state.viewModeEnabled||this.deselectElements(),this.cursor.reset())});v(this,"isSameForcedTool",(t,o)=>t?.type===o?.type&&(t?.type==="custom"?t.customType??null:null)===(o?.type==="custom"?o.customType??null:null));v(this,"handleForcedToolChange",(t,o)=>{let r=this.props.activeTool;if(!r)return;let i=!this.isSameForcedTool(t.activeTool,r);if(r.type==="image"){i&&console.warn('"image" tool cannot be forced via "props.activeTool"');return}this.isSameForcedTool(r,this.state.activeTool)||(i||o.activeTool!==this.state.activeTool||this.isToolSupported(r.type,t)!==this.isToolSupported(r.type,this.props))&&this.setActiveTool(r)});v(this,"resetHistory",()=>{this.history.clear()});v(this,"resetStore",()=>{this.store.clear()});v(this,"resetScene",Ke(t=>{this.scene.replaceAllElements([]),this.setState(o=>({...Xo(),isLoading:t?.resetLoadingState?!1:o.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));v(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async l=>{if(!l.files.length)return;let c=l.files[0],d=await c.getFile();this.loadFileToCanvas(new File([d],d.name||"",{type:d.type}),c)}),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}catch(l){console.error(l),t={appState:{errorMessage:l.message||"Encountered an error during importing or restoring scene data"}}}let o=Nr(t?.elements,null,{repairBindings:!0,deleteInvisibleElements:!0}),r=ki(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,viewModeOnly:this.props.viewModeOnly||r.viewModeOnly,viewModeEnabled:this.props.viewModeOnly||this.props.viewModeEnabled||r.viewModeEnabled,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};let a={...r,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft},s=this.props.initialState?.viewport;if(s){let l=o.filter(m=>!m.isDeleted),c=hc(l),d=this.viewport.resolveInitialViewport(s,c,a);d&&(r={...r,...d})}else t?.scrollToContent&&(r={...r,...Si(o,a)});this.resetStore(),this.resetHistory(),this.syncActionResult({elements:o,appState:r,files:t?.files,captureUpdate:$t.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(l=>{this.fonts.onLoaded(l)}),RM(window.location.href)&&this.viewport.setViewport({target:window.location.href,fit:"scale-down",animation:!1})});v(this,"getFormFactor",(t,o)=>this.props.UIOptions.getFormFactor?.(t,o)??TY(t,o));v(this,"refreshEditorInterface",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:o,height:r}=t.getBoundingClientRect(),i=kY(),a=t3(typeof navigator<"u"?navigator.userAgent:""),s=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:tY,l=wb(this.editorInterface,{desktopUIMode:i??this.editorInterface.desktopUIMode,formFactor:this.getFormFactor(o,r),userAgent:a,canFitSidebar:o>s,isLandscape:o>r});this.editorInterface=l,this.reconcileStylesPanelMode(l)});v(this,"reconcileStylesPanelMode",t=>{let o=mu(t);if(o===this.stylesPanelMode)return;let r=this.stylesPanelMode;this.stylesPanelMode=o,this.viewport.invalidateUIOffset("stylesPanel"),r!=="full"&&o==="full"&&this.setState(i=>({preferredSelectionTool:{type:"selection",initialized:!0}}))});v(this,"setDesktopUIMode",t=>{let o=MY(t);this.editorInterface=wb(this.editorInterface,{desktopUIMode:o}),this.reconcileStylesPanelMode(this.editorInterface)});v(this,"onResize",Ke(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>wi.delete(t)),this.refreshEditorInterface(),this.updateDOMRect(),this.setState({})}));v(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});v(this,"renderInteractiveSceneCallback",({scrollBars:t})=>{t&&(wc=t),this.scheduleImageRefresh()});v(this,"onScroll",cM(()=>{let{offsetTop:t,offsetLeft:o}=this.getCanvasOffsets();this.setState(r=>r.offsetLeft===o&&r.offsetTop===t?null:{offsetTop:t,offsetLeft:o})},nY));v(this,"onCut",Ke(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||pc(t.target)||(this.actionManager.executeAction(sm,"keyboard",t),t.preventDefault(),t.stopPropagation())}));v(this,"onCopy",Ke(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||pc(t.target)||(this.actionManager.executeAction(ma,"keyboard",t),t.preventDefault(),t.stopPropagation())}));v(this,"onTouchStart",t=>{if(this.isInteractionEnabled()){if(SY&&t.preventDefault(),!bc){bc=!0,t.touches.length===1&&(yc={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(xc),xc=window.setTimeout(e.resetTapTwice,aM);return}if(bc&&t.touches.length===1&&yc){let o=t.touches[0];so(oe(o.clientX,o.clientY),oe(yc.x,yc.y))<=uM&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:o.clientX,clientY:o.clientY,type:"touch",altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1})),bc=!1,clearTimeout(xc)}t.touches.length===2&&this.setState({selectedElementIds:De({},this.state),activeEmbeddable:null})}});v(this,"onTouchEnd",t=>{this.isInteractionEnabled()&&(this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:De(this.state.previousSelectedElementIds,this.state)}):de.pointers.clear())});v(this,"pasteFromClipboard",Ke(async t=>{if(!this.isInteractionEnabled())return;let o=!!cu,r=document.activeElement,i=this.excalidrawContainerRef.current?.contains(r);if(t&&!i)return;let a=document.elementFromPoint(this.viewport.lastPosition.x,this.viewport.lastPosition.y);if(t&&(!(a instanceof HTMLCanvasElement)||pc(r)))return;let s=await Kr(t),l=s.getFiles(),c=await jd(s,o);if(this.state.viewModeEnabled){if(!this.containsImagePaste(c,l,o))return;if(!this.shouldInsertImageInViewMode({source:"paste",files:l.map(d=>d.file),data:c,event:t})){t?.preventDefault();return}}if(this.props.onPaste)try{if(await this.props.onPaste(c,t)===!1)return}catch(d){console.error(d)}await this.insertClipboardContent(c,l,o),this.setActiveTool({type:this.state.preferredSelectionTool.type},{keepSelection:!0}),t?.preventDefault()}));v(this,"addElementsFromPasteOrLibrary",t=>{let o=Nr(t.elements,null,{deleteInvisibleElements:!0}),[r,i,a,s]=ms(o),l=ds(r,a)/2,c=ds(i,s)/2,d=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.viewport.lastPosition.x:this.state.width/2+this.state.offsetLeft,m=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.viewport.lastPosition.y:this.state.height/2+this.state.offsetTop,{x:p,y:u}=Me({clientX:d,clientY:m},this.state),E=p-l,g=u-c,[b,w]=Mt(E,g,this.getEffectiveGridSize()),{duplicatedElements:y}=yM({type:"everything",elements:o.map(M=>po(M,{x:M.x+b-r,y:M.y+w-i})),randomizeSeed:!t.retainSeed,preserveFrameChildrenOrder:t.preserveFrameChildrenOrder}),x=this.scene.getElementsIncludingDeleted(),I=[...x,...y];I=this.props.onDuplicate?.(I,x)||I,OM(I,hc(y));let C=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(C){let M=iX(y,C);I=Ab(I,M,C)}this.scene.replaceAllElements(I),y.forEach(M=>{if(Kt(M)&&vM(M)){let D=kM(M,this.scene.getElementsMapIncludingDeleted());qY(M,D,this.scene)}}),PY&&Eo.loadElementsFonts(y).then(M=>{this.fonts.onLoaded(M)}),t.files&&this.addMissingFiles(t.files);let P=wX(y);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.editorInterface.canFitSidebar&&Et.get(sb)?this.state.openSidebar:null,...zM(P,this.scene.getNonDeletedElements(),this.state)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:this.state.preferredSelectionTool.type},{keepSelection:!0}),t.fit&&this.viewport.setViewport({target:y,fit:t.fit,animation:!1,offsets:{ui:!0}})});v(this,"addElementsFromPaste",t=>{this.addElementsFromPasteOrLibrary({...t,fit:t.fitToContent?"contain":void 0})});v(this,"setAppState",(t,o)=>{let r=a=>!a||!this.state.viewModeOnly?a:{...a,viewModeOnly:!0,viewModeEnabled:!0},i=typeof t=="function"?(a,s)=>r(t(a,s)):r(t);this.setState(i,o)});v(this,"removePointer",t=>{Dr&&this.resetContextMenuTimer(),t.type==="pointercancel"&&this.bucketFill.cancel();let o=de.pointers.size>=2;de.pointers.delete(t.pointerId),o&&de.pointers.size<2&&this.state.scrollConstraints&&this.viewport.releaseOverscroll()});v(this,"toggleLock",(t="ui")=>{this.props.activeTool||(this.state.activeTool.locked||Fe("toolbar","toggleLock",`${t} (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),this.setState(o=>({activeTool:{...o.activeTool,...nn(this.state,o.activeTool.locked?{type:this.state.preferredSelectionTool.type}:o.activeTool),locked:!o.activeTool.locked}})))});v(this,"updateFrameRendering",t=>{this.setState(o=>{let r=typeof t=="function"?t(o.frameRendering):t;return{frameRendering:{enabled:r?.enabled??o.frameRendering.enabled,clip:r?.clip??o.frameRendering.clip,name:r?.name??o.frameRendering.name,outline:r?.outline??o.frameRendering.outline}}})});v(this,"togglePenMode",t=>{this.setState(o=>({penMode:t??!o.penMode,penDetected:!0,currentItemStrokeVariability:o.penDetected?o.currentItemStrokeVariability:"variable"}))});v(this,"revealIfHidden",t=>{!t.length||XY(t,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.viewport.getOffsets())||this.viewport.setViewport({target:ms(t),fit:"scale-down",animation:{duration:300},offsets:{ui:!0}})});v(this,"scrollToViewport",(t,o)=>{this.setState({scrollX:t.scrollX,scrollY:t.scrollY,zoom:{value:Yn(t.zoom)},shouldCacheIgnoreZoom:!1})});v(this,"scrollToContent",(t,o)=>{this.viewport.setViewport({target:t??this.scene.getNonDeletedElements(),fit:o?.fitToViewport?"contain":"scale-down",animation:o?.animate?{duration:o.duration??500}:!1,offsets:{ui:!0}})});v(this,"emitUserFollowIntent",t=>{this.onUserFollowEmitter.trigger(t),this.props.onUserFollow?.(t)});v(this,"requestUnfollow",()=>{this.props.userToFollow&&this.emitUserFollowIntent({userToFollow:this.props.userToFollow,action:"UNFOLLOW"})});v(this,"setToast",t=>{this.setState({toast:t})});v(this,"restoreFileFromShare",async()=>{try{let t=await caches.open("web-share-target"),o=await t.match("shared-file");if(o){let r=await o.blob(),i=new File([r],r.name||"",{type:r.type});this.loadFileToCanvas(i,null),await t.delete("shared-file"),window.history.replaceState(null,$V,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});v(this,"addFiles",Ke(t=>{let o=new Map;for(let s of t){let l=s.id,c=this.imageCache.get(l);c&&!this.files[l]&&o.set(l,Promise.resolve(c.image))}let{addedFiles:r}=this.addMissingFiles(t);this.clearImageShapeCache(r),this.scene.triggerUpdate();let i=new Set(o.keys());Cb({imageCache:this.imageCache,fileIds:Array.from(i),files:this.files,onImageCacheUpdate:s=>this.handleImageCacheUpdate(s),gifAutoDecodeMaxFileSizeBytes:this.props.imageOptions.gifAutoDecodeMaxFileSizeBytes}).then(async({updatedFiles:s})=>{for(let[l,c]of o){let d=this.imageCache.get(l);!d||!s.has(l)||(this.imageCache.set(l,{...d,placeholderImage:await c,transitionStart:performance.now()}),this.clearImageLoadingProgress(l))}i.size&&this.imagePlaceholderUpdateEmitter.trigger()}),i.size||this.addNewImagesToImageCache()}));v(this,"addImageElementsToScene",async(t,o,r)=>{let i=await Promise.all(t.map(async({file:s,customData:l})=>({file:await Br(s),customData:l??{}}))),a=i.find(({file:s})=>!Mi(s));if(a)throw new Iu(a.file,f("errors.unsupportedFileType"));await this.insertImages(i.map(({file:s})=>s),o,r,i.map(({customData:s})=>s))});v(this,"addImagePlaceholder",async(t,o)=>{if(this.files[t])return;let r=await Br(o);if(!Mi(r))throw new Error(f("errors.unsupportedFileType"));let i=new Image,a=new Promise((l,c)=>{i.onload=()=>l(i),i.onerror=()=>c(new Error(f("errors.imageInsertError")))}),s={image:a,mimeType:r.type,isPlaceholder:!0,gifDecodeStatus:r.type===lo.gif?"pending":void 0};this.imageCache.set(t,s),s.gifDecodeStatus==="pending"&&this.imagePlaceholderUpdateEmitter.trigger(),i.src=await Rc(r);try{let l=await a;if(this.imageCache.get(t)!==s||this.files[t])return;this.imageCache.set(t,{...s,image:l}),this.clearImageShapeCacheForFileId(t),this.imagePlaceholderUpdateEmitter.trigger()}catch(l){throw this.imageCache.get(t)===s&&(this.imageCache.delete(t),this.imagePlaceholderUpdateEmitter.trigger()),l}});v(this,"setDownloadProgress",(t,o)=>{if(o===null){this.clearImageLoadingProgress(t);return}if(!Number.isFinite(o))return;let r=cc(o,0,1);this.imageLoadingProgress.get(t)!==r&&(this.imageLoadingProgress.set(t,r),this.imageLoadingProgressEmitter.trigger())});v(this,"setDownloadError",(t,o)=>{this.updateImageStatus(t,r=>({...r,downloadError:o===!0?{}:o||null}))});v(this,"setUploadProgress",(t,o,r)=>{if(o===null){this.updateImageStatus(t,i=>({...i,uploadProgress:null}));return}typeof o=="number"&&!Number.isFinite(o)||this.updateImageStatus(t,i=>{let a=i?.uploadProgress??void 0,s=r===void 0?a:r??void 0,l=typeof o=="number";return{...i,uploadProgress:{...s,state:l?"uploading":o,...l?{progress:cc(o,0,1)}:{progress:void 0}}}})});v(this,"updateImageStatus",(t,o)=>{let r=this.imageStatus.get(t),i=o(r);this.areImageStatusesEqual(r,i)||(i.downloadError===void 0&&!i.uploadProgress?this.imageStatus.delete(t):this.imageStatus.set(t,i),this.imageStatusEmitter.trigger())});v(this,"areImageStatusesEqual",(t,o)=>!!t?.downloadError==!!o?.downloadError&&!!t?.uploadProgress==!!o?.uploadProgress&&t?.downloadError?.backgroundColor===o?.downloadError?.backgroundColor&&t?.downloadError?.color===o?.downloadError?.color&&t?.downloadError?.trackColor===o?.downloadError?.trackColor&&t?.downloadError?.text===o?.downloadError?.text&&t?.downloadError?.onClick===o?.downloadError?.onClick&&t?.uploadProgress?.backgroundColor===o?.uploadProgress?.backgroundColor&&t?.uploadProgress?.color===o?.uploadProgress?.color&&t?.uploadProgress?.trackColor===o?.uploadProgress?.trackColor&&t?.uploadProgress?.state===o?.uploadProgress?.state&&t?.uploadProgress?.text===o?.uploadProgress?.text&&t?.uploadProgress?.onClick===o?.uploadProgress?.onClick&&t?.uploadProgress?.progress===o?.uploadProgress?.progress);v(this,"clearImageLoadingProgress",t=>{this.imageLoadingProgress.delete(t)&&this.imageLoadingProgressEmitter.trigger()});v(this,"clearImageShapeCacheForFileId",t=>{for(let o of this.scene.getNonDeletedElements())yi(o)&&o.fileId===t&&wi.delete(o)});v(this,"addMissingFiles",(t,o=!1)=>{let r=o?{}:{...this.files},i={},a=Array.isArray(t)?t:Object.values(t);for(let s of a)if(!r[s.id]&&(i[s.id]=s,r[s.id]=s,s.mimeType===lo.svg))try{let l=yx(PM(wx(s.dataURL)),lo.svg);s.dataURL!==l&&(s.version=(s.version??1)+1,s.dataURL=l)}catch(l){console.error(l)}return this.files=r,{addedFiles:i}});v(this,"updateScene",Ke(t=>{let{elements:o,appState:r,collaborators:i,captureUpdate:a}=t;if(a){let s=o||void 0,l=r?DY({...this.store.snapshot.appState,...r}):void 0;this.store.scheduleMicroAction({action:a,elements:s,appState:l})}r&&this.setState(r),o&&this.scene.replaceAllElements(o),i&&(this.laserTrails.updateCollabTrails(i),this.setState({collaborators:i}))}));v(this,"applyDeltas",(t,o)=>{let r=YM.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return YM.applyTo(r,a,i,o)});v(this,"mutateElement",(t,o,r=!0)=>this.scene.mutateElement(t,o,{informMutation:r,isDragging:!1}));v(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});v(this,"toggleSidebar",({name:t,tab:o,force:r})=>{let i;r===void 0?i=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===o?null:t:i=r?t:null;let a=i?{name:i}:null;return a&&o&&(a.tab=o),this.setState({openSidebar:a}),!!i});v(this,"updateCurrentCursorPosition",Ke(t=>{this.viewport.lastPosition.x=t.clientX,this.viewport.lastPosition.y=t.clientY}));v(this,"onKeyDown",Ke(t=>{if(!this.isInteractionEnabled())return;if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(l,c){let d=l[c];return typeof d=="function"?d.bind(l):c==="key"?t.shiftKey?l.key.toUpperCase():l.key.toLowerCase():d}})),!dM(t.target)){if((t.key===$.ESCAPE||t.key===$.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let l=ce(this.scene.getNonDeletedElementsMap(),this.state);if(l.length===1&&Un(l[0])&&t.key===$.ENTER){this.startImageCropping(l[0]);return}if(t.key===$.ESCAPE)this.updateEditorAtom(ro,null);else if(t.key===$.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(vb.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let c=Jm(l);Et.get(ro)?.type==="panel"&&qf(this,{conversionType:c,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),c&&this.updateEditorAtom(ro,{type:"panel"})}if(this.flowchart.handleKeyEvent(t))return}if(t[$.CTRL_OR_CMD]&&t.key.toLowerCase()===$.V&&(cu=t.shiftKey,clearTimeout(du),du=window.setTimeout(()=>{cu=!1},100)),t[$.CTRL_OR_CMD]&&pc(t.target)&&(t.code===kr.MINUS||t.code===kr.EQUAL)){t.preventDefault();return}if(pc(t.target)&&t.key!==$.ESCAPE||Eb(t.key)&&dM(t.target))return;if(t.key===$.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===$.E&&t.shiftKey&&t[$.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(this.maybeHandlePageScrollKeyDown(t)){t.preventDefault();return}if(this.state.openDialog?.name==="elementLinkSelector")return;if(t.key===$.ALT)if(this.state.activeTool.type==="bucketfill"){this.bucketFill.openTemporaryEyeDropper(),t.preventDefault();return}else Bo("COMPLEX_BINDINGS")?this.handleSkipBindMode():iu({app:this,event:t});if(this.actionManager.handleKeyDown(t))return;let o=this.props.viewModeEnabled===!0;if(!o&&this.state.viewModeEnabled&&t.key===$.ESCAPE){this.setActiveTool({type:"selection"});return}if(!o&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let l=Ky(t.key,this,t.shiftKey);if(this.state.viewModeEnabled&&!hM(l,["laser","hand"]))return;if(l){if(this.state.activeTool.type!==l&&Fe("toolbar",l,`keyboard (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),l==="arrow"&&this.state.activeTool.type==="arrow"){let c=this.state.currentItemArrowType===Mr.sharp?Mr.round:this.state.currentItemArrowType===Mr.round?Mr.elbow:Mr.sharp;this.setState({currentItemArrowType:c}),this.cursorHints.onArrowTypeCycled(c)}else(l==="arrow"||l==="line")&&this.cursorHints.onToolShortcut(l,/^\d$/.test(t.key)?"digit":"letter");l==="bucketfill"&&this.state.activeTool.type==="bucketfill"?this.bucketFill.cycleBackgroundColor():l==="lasso"&&this.state.activeTool.type==="laser"?this.setActiveTool({type:this.state.preferredSelectionTool.type}):this.setActiveTool({type:l},{toggle:!0}),t.stopPropagation();return}else if(t.key===$.Q){this.toggleLock("keyboard"),t.stopPropagation();return}}if(this.state.viewModeEnabled)return;if(t[$.CTRL_OR_CMD]&&!t.repeat&&(Bo("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),Ot(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.arrowText.refresh(),iu({app:this,event:t})),Eb(t.key)){let l=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),c=new Set;l.filter(u=>uo(u)).filter(u=>{let E=u.startBinding&&!l.some(b=>b.id===u.startBinding?.elementId),g=u.endBinding&&!l.some(b=>b.id===u.endBinding?.elementId);return E||g}).forEach(u=>c.add(u.id)),l=l.filter(u=>!c.has(u.id));let d=this.getEffectiveGridSize()&&(t.shiftKey?iM:this.getEffectiveGridSize())||(t.shiftKey?JV:iM),m=0,p=0;t.key===$.ARROW_LEFT?m=-d:t.key===$.ARROW_RIGHT?m=d:t.key===$.ARROW_UP?p=-d:t.key===$.ARROW_DOWN&&(p=d),l.forEach(u=>{this.scene.mutateElement(u,{x:u.x+m,y:u.y+p},{informMutation:!1,isDragging:!1}),nu(u,this.scene,{simultaneouslyUpdated:l})}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===$.ENTER){let l=this.scene.getSelectedElements(this.state);if(l.length===1){let c=l[0];if(t[$.CTRL_OR_CMD]||_b(c))zt(c)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==c.id)&&(this.store.scheduleCapture(),Xt(c)||this.actionManager.executeAction(va));else if(Kt(c)||MM(c)){let d;Kt(c)||(d=c);let m=kb(c,this.scene.getNonDeletedElementsMap()),p=m.x,u=m.y;this.startTextEditing({sceneX:p,sceneY:u,container:d}),t.preventDefault();return}else Tt(c)&&this.setState({editingFrame:c.id})}}if(t.key===$.SPACE&&de.pointers.size===0&&(Oo=!0,this.cursor.set(Ae.GRAB),t.preventDefault()),t.key.toLowerCase()===$.Z&&!t[$.CTRL_OR_CMD]&&!t.altKey&&!t.shiftKey&&(su=!0,this.cursor.set("zoom-in"),t.preventDefault()),(t.key===$.G||t.key===$.S)&&!t.altKey&&!t[$.CTRL_OR_CMD]){let l=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!l.length)return;t.key===$.G&&(Yo(this.state.activeTool.type)||l.some(c=>Yo(c.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===$.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[$.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===$.F){let l=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!l.length)return;(this.state.activeTool.type==="text"||l.find(c=>Kt(c)||Pb(c,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}let r=t.key.toLocaleLowerCase(),i=r===$.I&&!t.shiftKey&&!t[$.CTRL_OR_CMD],a=r===$.S&&t.shiftKey&&!t[$.CTRL_OR_CMD]||i,s=r===$.I&&t.shiftKey&&!t[$.CTRL_OR_CMD];(a||s)&&this.openEyeDropper({type:a?"stroke":"background",swapPreviewOnAlt:!i})}));v(this,"onKeyUp",Ke(t=>{if(this.isInteractionEnabled()){if(t.key===$.SPACE&&(this.state.viewModeEnabled&&this.state.activeTool.type!=="laser"||this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(Ae.GRAB):eu(this.state.activeTool.type)?this.cursor.reset():(this.cursor.applyForTool(),this.setState({selectedElementIds:De({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Oo=!1),t.key.toLowerCase()===$.Z&&(su=!1,this.cursor.reset()),t.key===$.ALT&&(this.bucketFill.closeTemporaryEyeDropper(),iu({app:this,event:t})),(t.key===$.ALT&&this.state.bindMode==="skip"||!t[$.CTRL_OR_CMD]&&!tu(this.state))&&(this.setState({bindMode:"orbit"}),this.lastPointerMoveEvent&&Bo("COMPLEX_BINDINGS"))){let o=Me({clientX:this.lastPointerMoveEvent.clientX,clientY:this.lastPointerMoveEvent.clientY},this.state),r=Ar(oe(o.x,o.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(this.state.selectedLinearElement){let i=fe.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());uo(i)&&this.handleDelayedBindModeChange(i,r)}}if(!t[$.CTRL_OR_CMD]){let o=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==o&&(Ot(()=>{this.setState({isBindingEnabled:o})}),this.arrowText.refresh()),iu({app:this,event:t})}if(Eb(t.key)){fM(this.scene.getSelectedElements(this.state).filter(gc),this.scene,this.state);let o=this.scene.getNonDeletedElementsMap();this.scene.getSelectedElements(this.state).filter(Rb).forEach(r=>{r.startBinding&&this.scene.mutateElement(r,{startBinding:{...r.startBinding,...KM(r,o.get(r.startBinding.elementId),"start",o)}}),r.endBinding&&this.scene.mutateElement(r,{endBinding:{...r.endBinding,...KM(r,o.get(r.endBinding.elementId),"end",o)}})}),this.setState({suggestedBinding:null})}this.flowchart.handleKeyEvent(t)}}));v(this,"setActiveTool",(t,o={})=>{let{keepSelection:r=!1}=o;if(!this.isToolSupported(t.type)){console.warn(this.isInteractionEnabled()?`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`:`"${t.type}" tool cannot be activated while the editor is non-interactive (see "interaction.enabled.tools")`);return}if(this.props.activeTool&&!this.isSameForcedTool(this.props.activeTool,t)){console.warn(`"${t.type}" tool activation ignored \u2014 the active tool is controlled by the host via "props.activeTool"`);return}this.drawShape.hasPendingGesture()&&this.actionManager.executeAction(ut);let i=ta.includes(t.type),s=o.toggle===!0&&i&&this.state.activeTool.type===t.type?nn(this.state,{...this.state.activeTool.lastActiveTool||{type:this.state.preferredSelectionTool.type},lastActiveTool:null}):i&&this.state.activeTool.type!==t.type?nn(this.state,{...t,lastActiveTool:this.state.activeTool}):nn(this.state,t);s.type==="hand"?this.cursor.set(Ae.GRAB):Oo||this.cursor.applyForTool(s),hY(document.activeElement)&&this.focusContainer(),WY(s.type)||this.setState({suggestedBinding:null}),s.type==="image"&&this.onImageToolbarButtonClick(),this.setState(l=>{let c={snapLines:l.snapLines.length?[]:l.snapLines,originSnapOffset:null,activeEmbeddable:null,selectedLinearElement:eu(s.type)?l.selectedLinearElement:null,frameToHighlight:null,hoveredArrowTextAnchor:null};return s.type==="freedraw"&&this.store.scheduleCapture(),s.type==="lasso"?{...l,...c,activeTool:s,...r?{}:{selectedElementIds:De({},l),selectedGroupIds:De({},l),editingGroupId:null,multiElement:null}}:s.type!=="selection"?{...l,...c,activeTool:s,selectedElementIds:De({},l),selectedGroupIds:De({},l),editingGroupId:null,multiElement:null}:{...l,...c,activeTool:s}})});v(this,"setOpenDialog",t=>{this.setState({openDialog:t})});v(this,"isTouchScreenMultiTouchGesture",()=>de.pointers.size>=2);v(this,"getName",()=>this.state.name||this.props.name||`${f("labels.untitled")}-${mM()}`);v(this,"onGestureStart",Ke(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:De({},this.state),activeEmbeddable:null}),de.initialScale=this.state.zoom.value)}));v(this,"onGestureChange",Ke(t=>{if(!this.isNavigationEnabled()||(t.preventDefault(),this.isTouchScreenMultiTouchGesture()))return;let o=de.initialScale;o&&this.viewport.translate(r=>({...fo({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:Yn(o*t.scale)},r)}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})}));v(this,"onGestureEnd",Ke(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:De(this.state.previousSelectedElementIds,this.state)}),de.initialScale=null)}));v(this,"isHittingTextAutoResizeHandle",(t,o)=>{let r=qM(t,this.state);return!!(r&&!r.isDeleted&&!r.autoResize&&W2(o,r,this.state.zoom.value,this.editorInterface.formFactor))});v(this,"handleTextAutoResizeHandlePointerDown",(t,o)=>{let r=qM(t,this.state);return!r||!this.isHittingTextAutoResizeHandle(t,o)?!1:(this.actionManager.executeAction(nf,"ui",r),this.cursor.reset(),!0)});v(this,"startTextEditing",({sceneX:t,sceneY:o,insertAtParentCenter:r=!0,container:i,autoEdit:a=!0,initialCaretSceneCoords:s,arrowEndpoint:l})=>{let c=!1,d=l&&this.arrowText.getTextBinding(l,this.getCurrentItemStrokeWidth("text"));d&&(i=null,r=!1,t=d.anchor[0],o=d.anchor[1]);let m=r&&this.getTextWysiwygSnappedToCenterPosition(t,o,this.state,i);i&&m&&(Pb(i,this.scene.getNonDeletedElementsMap())||(c=!0));let p=d?null:this.getSelectedTextElement(i)||this.getTextElementAtPosition(t,o),u=p?.fontFamily||this.state.currentItemFontFamily,E=p?.lineHeight||lM(u),g=this.state.currentItemFontSize;if(!p&&c&&i&&!gc(i)){let C=uX(xb({fontSize:g,fontFamily:u}),E),P=hX(g,E),M=Math.max(i.height,P),D=Math.max(i.width,C);this.scene.mutateElement(i,{height:M,width:D}),t=i.x+D/2,o=i.y+M/2,m&&(m=this.getTextWysiwygSnappedToCenterPosition(t,o,this.state,i))}let b=this.getTextCreationGridPoint(t,o),w=d?{x:t,y:o}:m?{x:m.elementCenterX,y:m.elementCenterY}:p?{x:t,y:o}:{x:b?.x??t,y:b===null?o-BM(g,E)/2:b.y},y=this.getTopLayerFrameAtSceneCoords({x:w.x,y:w.y}),x=y&&(!c||!i||i.frameId===y.id)?y.id:null,I=p||bM({x:w.x,y:w.y,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("text"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:g,fontFamily:u,textAlign:d?.textAlign??(m?"center":this.state.currentItemTextAlign),verticalAlign:d?.verticalAlign??(m?iY.MIDDLE:oM),containerId:c?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:E,angle:i?gc(i)?0:i.angle:0,frameId:x});if(!p&&c&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:I.id})}),this.setState({editingTextElement:I}),!p)if(i&&c){let T=this.scene.getElementIndex(i.id);this.scene.insertElementsAtIndex([I],T+1)}else this.insertNewElement(I);l&&d&&this.arrowText.bindText(l,I,d.fixedPoint),a||p||i?this.handleTextWysiwyg(I,{isExistingElement:!!p,initialCaretSceneCoords:p?s:null}):this.setState({newElement:I,multiElement:null})});v(this,"startImageCropping",t=>{this.store.scheduleCapture(),this.setState({croppingElementId:t.id})});v(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});v(this,"shouldHandleBrowserCanvasDoubleClick",t=>{if(t==="touch"||this.lastCompletedCanvasClicks.length===0)return!0;if(this.lastCompletedCanvasClicks.length<2)return!1;let[o,r]=this.lastCompletedCanvasClicks;return so(oe(o.x,o.y),oe(r.x,r.y))<=uM});v(this,"handleCanvasDoubleClick",t=>{if(!this.isInteractionEnabled()||this.state.editingTextElement||!this.shouldHandleBrowserCanvasDoubleClick(t.type)||this.state.multiElement||this.state.activeTool.type!==this.state.preferredSelectionTool.type&&this.state.activeTool.type!=="autoshape")return;let o=this.scene.getSelectedElements(this.state),{x:r,y:i}=Me(t,this.state);if(o.length===1&&zt(o[0])){let s=o[0];if((t[$.CTRL_OR_CMD]&&Rb(s)||_b(s))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==s.id)){this.actionManager.executeAction(va);return}else if(this.state.selectedLinearElement&&Xt(o[0])){let l=fe.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),c=l?fe.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,l,this.scene.getNonDeletedElementsMap()):-1;if(c&&c>-1){this.store.scheduleCapture(),fe.deleteFixedSegment(o[0],this.scene,c);let d=fe.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),m=d?fe.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,d,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,segmentMidpoint:{index:m,value:l,added:!1}},segmentMidPointHoveredCoords:d}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===s.id&&_b(s))return}if(o.length===1&&Un(o[0])){this.startImageCropping(o[0]);return}if(this.cursor.reset(),xX(this.state).length>0){let s=this.getElementAtPosition(r,i),l=s&&bX(s,this.state.selectedGroupIds);if(l){this.store.scheduleCapture(),this.setState(c=>({...c,...Wn({editingGroupId:l,selectedElementIds:{[s.id]:!0}},this.scene.getNonDeletedElements(),c,this)}));return}}if(this.cursor.reset(),!this.state.viewModeEnabled){let s=this.getElementAtPosition(r,i);if(fc(s)){this.setState({activeEmbeddable:{element:s,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){let l=!t[$.CTRL_OR_CMD]&&this.getTextBindableContainerAtPosition(r,i);if(l&&(this.state.activeTool.type==="autoshape"||wM(l)||!fY(l.backgroundColor)||Ec({point:oe(r,i),element:l,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(l)}))){let c=kb(l,this.scene.getNonDeletedElementsMap());r=c.x,i=c.y}this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:l||null})}}});v(this,"handleCanvasClick",t=>{if(!this.isInteractionEnabled())return;if(t.button!==Gn.MAIN){this.lastCompletedCanvasClicks=[];return}let o=Me(t,this.state),r=this.getImageStatusActionAtPosition(o);if(r){t.preventDefault(),t.stopPropagation(),r();return}this.lastCompletedCanvasClicks=[...this.lastCompletedCanvasClicks.slice(-1),{x:t.clientX,y:t.clientY}]});v(this,"getImageStatusActionAtPosition",t=>{if(!this.imageStatus.size)return null;let o=this.scene.getNonDeletedElementsMap(),r=this.visibleElements.length?this.visibleElements:this.scene.getNonDeletedElements();for(let i=r.length-1;i>=0;i--){let a=r[i];if(!Un(a)||!a.fileId)continue;let s=this.imageStatus.get(a.fileId),l=s?.uploadProgress?.onClick;if(l&&this.isPointInsideImageStatusOverlay(t,a,o,"top-right"))return()=>l(a.fileId);let c=s?.downloadError?.onClick;if(c&&this.isPointInsideImageStatusOverlay(t,a,o,"center"))return()=>c(a.fileId)}return null});v(this,"isPointInsideImageStatusOverlay",(t,o,r,i)=>{let a=Fl(o,r,this.state,i);return!!a&&so(oe(t.x,t.y),oe(a.centerX,a.centerY))<=a.radius+2/this.state.zoom.value});v(this,"getElementLinkAtPosition",(t,o)=>{if(o&&o.locked)return;let r=this.scene.getNonDeletedElements(),i=-1;for(let a=r.length-1;a>=0;a--){let s=r[a];if(o&&s.id===o.id&&(i=a),s.link&&a>=i&&Mc(s,this.scene.getNonDeletedElementsMap(),this.state,oe(t.x,t.y),this.editorInterface.formFactor==="phone"))return s}});v(this,"getElementLinkAtPositionForContextMenu",(t,o)=>{let r=this.getElementLinkAtPosition(t,o);if(r)return r;let i=this.scene.getNonDeletedElementsMap();for(let a of this.scene.getNonDeletedElements().slice().reverse())if(a.link&&!a.locked&&mx(a,i,this.state,oe(t.x,t.y)))return a});v(this,"handleElementLinkClick",t=>{let o=d=>d===Gn.MAIN||d===Gn.TOUCH;if(!o(this.lastPointerDownEvent.button)||!o(this.lastPointerUpEvent.button))return;let r=so(oe(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),oe(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||r>rM)return;let i=Me(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),s=Mc(this.hitLinkElement,a,this.state,oe(i.x,i.y),this.editorInterface.formFactor==="phone"),l=Me(this.lastPointerUpEvent,this.state),c=Mc(this.hitLinkElement,a,this.state,oe(l.x,l.y),this.editorInterface.formFactor==="phone");s&&c&&(mm(),this.openElementLink(this.hitLinkElement,t))});v(this,"openElementLink",(t,o)=>{let r=t.link;if(!r)return;r=Jp(r);let i;if(this.props.onLinkOpen&&o&&(i=gY(Q.EXCALIDRAW_LINK,o.nativeEvent),this.props.onLinkOpen({...t,link:r},i)),!i?.defaultPrevented){let a=mY(r)?"_self":"_blank",s=window.open(void 0,a);s&&(s.opener=null,s.location=r)}});v(this,"applyElementLinkHoverAffordance",()=>this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(this.cursor.set(Ae.POINTER),bv(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap()),!0):(mm(),!1));v(this,"maybeHandleElementLinkClick",(t,o)=>{if(this.editorInterface.isTouchScreen){let r=this.getElementAtPosition(o.x,o.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(o,r)}return this.hitLinkElement&&this.lastPointerDownEvent&&!this.state.selectedElementIds[this.hitLinkElement.id]?(this.handleElementLinkClick(t),!0):!1});v(this,"handleInteractiveContentPointerMove",t=>{let o=Me(t,this.state),r=this.getElementAtPosition(o.x,o.y,{includeLockedElements:!0});if(this.isEmbedsEnabled()){let i=r?.locked?null:r;if(this.handleIframeLikeElementHover({hitElement:i,scenePointer:o,moveEvent:t}))return}this.hitLinkElement=this.isLinksEnabled()?this.getElementLinkAtPosition(o,r):void 0,this.applyElementLinkHoverAffordance()||this.cursor.reset()});v(this,"handleInteractiveContentPointerUp",t=>{if(this.lastPointerUpEvent=t,this.isEmbedsEnabled()&&this.handleIframeLikeCenterClick())return;let o=Me(t,this.state);this.isLinksEnabled()&&this.maybeHandleElementLinkClick(t,o)||this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});v(this,"getTopLayerFrameAtSceneCoords",(t,o)=>{let r=this.scene.getNonDeletedElementsMap(),i=this.scene.getNonDeletedFramesLikes().filter(l=>!l.locked&&DM(t,l,r));if(!i.length)return null;let a=i.at(-1),s=this.getElementsAtPosition(t.x,t.y,{includeLockedElements:!0}).findLast(l=>!o?.excludeElementIds?.[l.id]);if(s){if(Tt(s)&&!s.locked)return a;let l=this.scene.getElementIndex(s.id),c=this.scene.getElementIndex(a.id);if(l!==-1&&c!==-1&&l<=c)return a;let d=o?.currentFrameId?i.find(m=>m.id===o.currentFrameId)??null:null;return d||(s.frameId?i.find(m=>m.id===s.frameId)??null:null)}return a});v(this,"updateFrameToHighlight",t=>{this.state.frameToHighlight!==t&&this.setState({frameToHighlight:t})});v(this,"maybeUpdateFrameToHighlightOnPointerMove",(t,o)=>{this.state.newElement||this.state.multiElement||this.state.selectionElement||this.state.selectedElementsAreBeingDragged||this.updateFrameToHighlight(!o&&FX(this.state.activeTool.type)?this.getTopLayerFrameAtSceneCoords(t):null)});v(this,"insertNewElements",t=>{if(!t.length)return;let o=[];for(let r of t){let i=o[o.length-1];i?.[0].frameId===r.frameId?i.push(r):o.push([r])}for(let r of o){let i=r[0].frameId,a=i?QY(this.scene.getElementsIncludingDeleted(),i):null;this.scene.insertElementsAtIndex(r,a)}});v(this,"insertNewElement",t=>{this.insertNewElements([t]);let o=t.frameId?this.scene.getNonDeletedElement(t.frameId):null;this.updateFrameToHighlight(o&&Tt(o)?o:null)});v(this,"updateZDragZoom",t=>{if(!this.zDragZoom)return;let{origin:o,initialZoom:r}=this.zDragZoom,i=t.clientX-o.clientX,a=Yn(r*Math.max(.1,1+i/100));this.viewport.translate(s=>({...fo({viewportX:o.clientX,viewportY:o.clientY,nextZoom:a},s),shouldCacheIgnoreZoom:!0}),{zoomPreConstrained:!0}),this.resetShouldCacheIgnoreZoomDebounced()});v(this,"handleCanvasPointerMove",t=>{if(!this.isInteractionEnabled()){this.isToolSupported(this.state.activeTool.type)&&this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.isNavigationEnabled()&&this.updateMultiTouchGesture(t),(this.isLinksEnabled()||this.isEmbedsEnabled())&&!zo&&this.handleInteractiveContentPointerMove(t);return}this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent;let o=Me(t,this.state),{x:r,y:i}=o;if(this.lastPointerMoveCoords={x:r,y:i},this.zDragZoom){this.updateZDragZoom(t);return}if(this.updateMultiTouchGesture(t),Oo||zo||lu||bs(this.state))return;let s=bf(wc,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?this.cursor.set(Ae.AUTO):this.getImageStatusActionAtPosition(o)?this.cursor.set(Ae.POINTER):this.cursor.applyForTool()),this.maybeUpdateFrameToHighlightOnPointerMove({x:r,y:i},s),!this.state.newElement&&z2(this.state.activeTool.type)){let{originOffset:g,snapLines:b}=O2(this.scene.getNonDeletedElements(),this,{x:r,y:i},t,this.scene.getNonDeletedElementsMap());this.setState(w=>{let y=uc(w.snapLines,b),x=w.originSnapOffset?uc(w.originSnapOffset,g):g;return w.snapLines===y&&w.originSnapOffset===x?null:{snapLines:y,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:fe.handlePointerMoveInEditMode(t,r,i,this);g&&g!==this.state.selectedLinearElement&&Ot(()=>{this.setState({selectedLinearElement:g})})}if(UY(this.state.activeTool.type)){let{newElement:g}=this.state;if(!g&&tu(this.state)){let b=oe(r,i),w=this.scene.getNonDeletedElementsMap(),y=Ar(b,this.scene.getNonDeletedElements(),w,jM(this.state.zoom));y?this.setState({suggestedBinding:{element:y,midPoint:Nb(b,y,w,this.state.zoom)}}):this.state.suggestedBinding&&this.setState({suggestedBinding:null})}}if(this.state.multiElement&&this.state.selectedLinearElement){let{multiElement:g,selectedLinearElement:b}=this.state,{x:w,y,points:x}=g,I=x[x.length-1],{lastCommittedPoint:T}=b;if(this.cursor.applyForTool(),I===T)so(oe(r-w,i-y),I)>=bb?(this.store.scheduleCapture(),Ot(()=>{mo(this.state.selectedLinearElement?.initialState,"initialState must be set"),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:x[x.length-1],selectedPointsIndices:[g.points.length],initialState:{...this.state.selectedLinearElement.initialState,lastClickedPoint:g.points.length}}})}),this.scene.mutateElement(g,{points:[...x,oe(r-w,i-y)]},{informMutation:!1,isDragging:!1})):this.cursor.set(Ae.POINTER);else if(x.length>2&&T&&so(oe(r-w,i-y),T)<bb){this.cursor.set(Ae.POINTER),this.scene.mutateElement(g,{points:x.slice(0,-1)},{informMutation:!1,isDragging:!1});let C=g.points.length-1;this.setState({selectedLinearElement:{...b,selectedPointsIndices:b.selectedPointsIndices?[...new Set(b.selectedPointsIndices.map(P=>Math.min(P,C)))]:b.selectedPointsIndices,lastCommittedPoint:g.points[C],initialState:{...b.initialState,lastClickedPoint:C}}})}else{CM(x,this.state.zoom.value)&&this.cursor.set(Ae.POINTER);let C=this.scene.getNonDeletedElementsMap();if(Rb(g)){let M=Ar(oe(r,i),this.scene.getNonDeletedElements(),C);Bo("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(g,M)}mo(this.state.selectedLinearElement,"Expected selectedLinearElement to be set to operate on a linear element");let P=fe.handlePointerMove(t.nativeEvent,this,r,i,this.state.selectedLinearElement);P&&this.setState(P)}return}if(this.state.activeTool.type==="arrow"&&!this.state.newElement){let g=oe(r,i),b=Ar(g,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),jM(this.state.zoom)),w=this.scene.getNonDeletedElementsMap();b&&!ZM(g,b,w)&&this.setState({suggestedBinding:{element:b,midPoint:Nb(g,b,w,this.state.zoom)}})}let l=!!t.buttons,c=this.state.activeTool.type==="laser";if(l||!c&&this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let d=this.scene.getNonDeletedElements(),m=this.scene.getSelectedElements(this.state);if(this.isHittingTextAutoResizeHandle(m,o)){this.cursor.set(Ae.POINTER);return}if(m.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"&&!(m.length===1&&Xt(m[0]))&&!(zt(m[0])&&(this.editorInterface.userAgent.isMobileDevice||m[0].points.length===2))){let g=HM(d,this.state,r,i,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);if(g&&g.transformHandleType){this.cursor.set(GM(g));return}}}else if(m.length>1&&!s&&this.state.openDialog?.name!=="elementLinkSelector"){let g=UM(ms(m),r,i,this.state.zoom,t.pointerType,this.editorInterface);if(g){this.cursor.set(GM({transformHandleType:g}));return}}if(rn(this.state))return;let p=this.getElementAtPosition(r,i,{preferSelected:!0,includeLockedElements:!0}),u=null;p&&p.locked?u=null:u=p;let E=this.arrowText.updateHoveredAnchor(o);if(this.handleIframeLikeElementHover({hitElement:u,scenePointer:o,moveEvent:t})||(this.hitLinkElement=this.getElementLinkAtPosition(o,p)),!this.applyElementLinkHoverAffordance()){if(c)return;u&&(u.link||Fo(u))&&this.state.selectedElementIds[u.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?this.cursor.set(E?Ae.POINTER:Kt(u)?Ae.TEXT:Ae.CROSSHAIR):!t[$.CTRL_OR_CMD]&&this.isHittingCommonBoundingBoxOfSelectedElements(o,m)?this.cursor.set(Ae.MOVE):this.state.viewModeEnabled?this.cursor.set(Ae.GRAB):this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(Ae.AUTO):s?this.cursor.set(Ae.AUTO):!t[$.CTRL_OR_CMD]&&u?.id!==this.state.editingTextElement?.id?(u||this.isHittingCommonBoundingBoxOfSelectedElements(o,m))&&!u?.locked&&(!u||!Xt(u)||!(u.startBinding||u.endBinding))&&(this.state.activeTool.type!=="lasso"||m.length>0)&&this.cursor.set(Ae.MOVE):this.cursor.set(Ae.AUTO),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i)}this.state.openDialog?.name==="elementLinkSelector"&&u?this.setState(g=>({hoveredElementIds:uc(g.hoveredElementIds,Wn({editingGroupId:g.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),g,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!u&&this.setState(g=>({hoveredElementIds:uc(g.hoveredElementIds,{})}))});v(this,"handleEraser",(t,o)=>{let r=this.eraserTrail.addPointToPath(o.x,o.y,t.altKey);this.elementsPendingErasure=new Set(r),this.triggerRender()});v(this,"handleTouchMove",t=>{this.isInteractionEnabled()&&(vc=!0)});v(this,"handleCanvasPointerDown",t=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)){(this.isLinksEnabled()||this.isEmbedsEnabled())&&(this.lastPointerDownEvent=t),this.isNavigationEnabled()&&(this.updateGestureOnPointerDown(t),zo||this.handleCanvasPanUsingWheelOrSpaceDrag(t));return}let o=this.scene.getSelectedElements(this.state);if(!t.ctrlKey){let g=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==g&&this.setState({isBindingEnabled:g})}let r=Me(t,this.state),{x:i,y:a}=r;this.lastPointerMoveCoords={x:i,y:a};let s=t.target;if(s.setPointerCapture&&s.setPointerCapture(t.pointerId),this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.state.activeTool.type!=="laser"&&this.requestUnfollow(),this.state.searchMatches&&(this.setState(g=>({searchMatches:g.searchMatches&&{focusedId:null,matches:g.searchMatches.matches.map(b=>({...b,focus:!1}))}})),this.updateEditorAtom(qE,null)),Et.get(ro)&&this.updateEditorAtom(ro,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.state.openPopup&&this.setState({openPopup:null}),this.updateGestureOnPointerDown(t),su){t.preventDefault(),this.focusContainer(),this.zDragZoom={origin:{clientX:t.clientX,clientY:t.clientY},initialZoom:this.state.zoom.value},this.setState({cursorButton:"down"});return}if(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(b=>b.id!==g.id)}:{},appState:{newElement:null,editingTextElement:null,suggestedBinding:null,selectedElementIds:De(Object.keys(this.state.selectedElementIds).filter(b=>b!==g.id).reduce((b,w)=>(b[w]=this.state.selectedElementIds[w],b),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?$t.EVENTUALLY:$t.NEVER});return}let l=document.getSelection();if(l?.anchorNode&&l.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(g=>({penMode:!0,penDetected:!0,currentItemStrokeVariability:"variable"})),!this.editorInterface.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.editorInterface=wb(this.editorInterface,{isTouchScreen:!0})),zo||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===Gn.ERASER&&this.isInteractionEnabled()&&!this.props.activeTool&&this.state.activeTool.type!==Hn.eraser){this.setState({activeTool:nn(this.state,{type:Hn.eraser,lastActiveTool:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let g=()=>{b(),w?.(),rn(this.state)&&this.setState({activeTool:nn(this.state,{...this.state.activeTool.lastActiveTool||{type:Hn.selection},lastActiveTool:null})})},b=ve(window,Q.POINTER_UP,g,{once:!0}),w;requestAnimationFrame(()=>{w=this.missingPointerEventCleanupEmitter.once(g)})});return}if(t.button!==Gn.MAIN&&t.button!==Gn.TOUCH&&t.button!==Gn.ERASER||de.pointers.size>1)return;let c=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleTextAutoResizeHandlePointerDown(o,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[$.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(y=>{let x={...y.selectedElementIds,[c.hit.element.id]:!0},I=[];Object.keys(y.selectedElementIds).forEach(C=>{let P=this.scene.getElement(C);P&&I.push(P)});let T=c.hit.element;if(Tt(T))Mb(I,T.id).forEach(C=>{delete x[C.id]});else if(T.frameId)x[T.frameId]&&delete x[T.id];else{let C=T.groupIds,P=new Set(C.flatMap(M=>vi(this.scene.getNonDeletedElements(),M)).filter(M=>Tt(M)).map(M=>M.id));P.size>0&&I.forEach(M=>{M.frameId&&P.has(M.frameId)&&(delete x[M.id],M.groupIds.flatMap(D=>vi(this.scene.getNonDeletedElements(),D)).forEach(D=>{delete x[D.id]}))})}return{...Wn({editingGroupId:y.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),y,this),showHyperlinkPopup:T.link||Fo(T)?"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"?this.cursor.applyForTool():this.state.activeTool.type===Hn.frame||this.state.activeTool.type===Hn.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==="autoshape"?this.drawShape.handlePointerDown(c):this.state.activeTool.type===Hn.bucketfill?this.bucketFill.handlePointerDown(r):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 m=this.onPointerMoveFromPointerDownHandler(c),p=this.onPointerUpFromPointerDownHandler(c),u=this.onKeyDownFromPointerDownHandler(c),E=this.onKeyUpFromPointerDownHandler(c);this.missingPointerEventCleanupEmitter.once(g=>p(g||t.nativeEvent)),(!this.state.viewModeEnabled||this.isActiveToolPointerCapturing())&&(window.addEventListener(Q.POINTER_MOVE,m),window.addEventListener(Q.POINTER_UP,p),window.addEventListener(Q.KEYDOWN,u),window.addEventListener(Q.KEYUP,E),c.eventListeners.onMove=m,c.eventListeners.onUp=p,c.eventListeners.onKeyUp=E,c.eventListeners.onKeyDown=u)});v(this,"handleCanvasPointerUp",t=>{if(!this.isInteractionEnabled()){(this.isLinksEnabled()||this.isEmbedsEnabled())&&this.handleInteractiveContentPointerUp(t);return}if(Bo("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 o=Me({clientX:t.clientX,clientY:t.clientY},this.state),{x:r,y:i}=o;if(this.lastPointerMoveCoords={x:r,y:i},this.zDragZoom){this.updateZDragZoom(t),this.zDragZoom=null,this.setState({cursorButton:"up"});return}this.handleIframeLikeCenterClick()||!this.maybeHandleElementLinkClick(t,o)&&this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})});v(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(vc=!1,Dr?vc=!0:Dr=window.setTimeout(()=>{Dr=0,vc||this.handleCanvasContextMenu(t)},rY))});v(this,"resetContextMenuTimer",()=>{clearTimeout(Dr),Dr=0,vc=!1});v(this,"maybeCleanupAfterMissingPointerUp",t=>{ps?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});v(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(de.pointers.size<=1&&((t.button===Gn.WHEEL||t.button===Gn.MAIN&&Oo||bs(this.state))&&(this.isInteractionEnabled()||this.isNavigationEnabled())||this.state.viewModeEnabled&&!this.isActiveToolPointerCapturing())))return!1;zo=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let o=!1,r=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);this.cursor.set(Ae.GRABBING);let{clientX:i,clientY:a}=t,s=km(c=>{let d=i-c.clientX,m=a-c.clientY;if(i=c.clientX,a=c.clientY,r&&!o&&(Math.abs(d)>1||Math.abs(m)>1)){o=!0;let p=E=>{document.body.removeEventListener(Q.PASTE,p),E.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener(Q.PASTE,p),window.removeEventListener(Q.POINTER_UP,u)},100)};document.body.addEventListener(Q.PASTE,p),window.addEventListener(Q.POINTER_UP,u)}this.viewport.translate({scrollX:this.state.scrollX-d/this.state.zoom.value,scrollY:this.state.scrollY-m/this.state.zoom.value})}),l=Ke(ps=()=>{ps=null,zo=!1,Oo||this.cursor.reset(),this.setState({cursorButton:"up"},this.viewport.releaseOverscroll),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(Q.POINTER_MOVE,s),window.removeEventListener(Q.POINTER_UP,l),window.removeEventListener(Q.BLUR,l),s.flush()});return window.addEventListener(Q.BLUR,l),window.addEventListener(Q.POINTER_MOVE,s,{passive:!0}),window.addEventListener(Q.POINTER_UP,l),!0});v(this,"updateMultiTouchGesture",t=>{de.pointers.has(t.pointerId)&&de.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let o=de.initialScale;if(de.pointers.size===2&&de.lastCenter&&o&&de.initialDistance){let r=rf(de.pointers),i=r.x-de.lastCenter.x,a=r.y-de.lastCenter.y;de.lastCenter=r;let s=af(Array.from(de.pointers.values())),l=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:s/de.initialDistance,c=l?Yn(o*l):this.state.zoom.value;this.setState(d=>{let m=fo({viewportX:r.x,viewportY:r.y,nextZoom:c},d),p=m.zoom.value;return this.viewport.translate({zoom:m.zoom,scrollX:m.scrollX+2*i/p,scrollY:m.scrollY+2*a/p,shouldCacheIgnoreZoom:!0},{zoomPreConstrained:!0}),null}),this.viewport.isLockedTransitionPending||this.resetShouldCacheIgnoreZoomDebounced()}else de.lastCenter=de.initialDistance=de.initialScale=null});v(this,"clearSelectionIfNotUsingSelection",()=>{eu(this.state.activeTool.type)||this.setState({selectedElementIds:De({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});v(this,"handleSelectionOnPointerDown",(t,o)=>{if(eu(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&&!Xt(a[0])&&!(zt(a[0])&&(this.editorInterface.userAgent.isMobileDevice||a[0].points.length===2))&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let s=HM(r,this.state,o.origin.x,o.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);s!=null&&(s.transformHandleType==="rotation"?(this.setState({resizingElement:s.element}),o.resize.handleType=s.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:s.element}),o.resize.handleType=s.transformHandleType))}else a.length>1&&(o.resize.handleType=UM(ms(a),o.origin.x,o.origin.y,this.state.zoom,t.pointerType,this.editorInterface));if(o.resize.handleType)o.resize.isResizing=!0,o.resize.offset=yb(vX(o.resize.handleType,a,i,o.origin.x,o.origin.y)),a.length===1&&zt(a[0])&&a[0].points.length===2&&(o.resize.arrowDirection=IX(o.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement,u=fe.handlePointerDown(t,this,this.store,o.origin,p,this.scene);if(u.hitElement&&(o.hit.element=u.hitElement),u.linearElementEditor&&this.setState({selectedLinearElement:u.linearElementEditor}),u.didAddPoint)return!0;let E=this.scene.getNonDeletedElementsMap(),g=fe.getElement(p.elementId,E);if(g&&uo(g)){let{hitFocusPoint:b,pointerOffset:w,arrowOtherEndpointInitialBinding:y}=RX(g,o,E,this.state);if(b)return this.setState({selectedLinearElement:{...p,hoveredFocusPointBinding:b,draggedFocusPointBinding:b,pointerOffset:w,initialState:{...p.initialState,arrowOtherEndpointInitialBinding:y}}}),!1}}let s=this.getElementsAtPosition(o.origin.x,o.origin.y,{includeLockedElements:!0}),l=s.filter(p=>!p.locked),c=this.getElementAtPosition(o.origin.x,o.origin.y,{allHitElements:s});if((!c||c.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),c&&c.locked&&!l.some(p=>this.state.selectedElementIds[p.id])?o.hit.element=null:o.hit.element=o.hit.element??this.getElementAtPosition(o.origin.x,o.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(o.origin,c),this.hitLinkElement)return!0;if(this.state.croppingElementId&&o.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),o.hit.element&&this.getElementLinkAtPosition({x:o.origin.x,y:o.origin.y},o.hit.element))return!1;o.hit.allHitElements=l;let d=o.hit.element,m=o.hit.allHitElements.some(p=>this.isASelectedElement(p));if((d===null||!m)&&!t.shiftKey&&!o.hit.hasHitCommonBoundingBoxOfSelectedElements&&(!this.state.selectedLinearElement?.isEditing||d&&d?.id!==this.state.selectedLinearElement?.elementId)&&this.clearSelection(d),this.state.selectedLinearElement?.isEditing)this.setState(p=>({selectedLinearElement:p.selectedLinearElement?{...p.selectedLinearElement,isEditing:!!d&&d.id===this.state.selectedLinearElement?.elementId}:null,selectedElementIds:p.selectedLinearElement?De({[p.selectedLinearElement.elementId]:!0},this.state):De({},p)}));else if(d!=null){if(t[$.CTRL_OR_CMD])return t.altKey?(this.state.openDialog?.name==="elementLinkSelector"&&this.setOpenDialog(null),this.lassoTrail.startPath(o.origin.x,o.origin.y,t.shiftKey),this.setActiveTool({type:"lasso",fromSelection:!0}),!1):(this.state.selectedElementIds[d.id]||(o.hit.wasAddedToSelection=!0),this.setState(p=>({...EX(p,d),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[d.id]||(this.state.editingGroupId&&!FM(d,this.state.editingGroupId)&&this.setState({selectedElementIds:De({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!m&&!o.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(p=>{let u={...p.selectedElementIds,[d.id]:!0},E=[];if(Object.keys(p.selectedElementIds).forEach(g=>{let b=this.scene.getElement(g);b&&E.push(b)}),Tt(d))Mb(E,d.id).forEach(g=>{delete u[g.id]});else if(d.frameId)u[d.frameId]&&delete u[d.id];else{let g=d.groupIds,b=new Set(g.flatMap(w=>vi(this.scene.getNonDeletedElements(),w)).filter(w=>Tt(w)).map(w=>w.id));b.size>0&&E.forEach(w=>{w.frameId&&b.has(w.frameId)&&(delete u[w.id],w.groupIds.flatMap(y=>vi(this.scene.getNonDeletedElements(),y)).forEach(y=>{delete u[y.id]}))})}return p.openDialog?.name==="elementLinkSelector"&&(d.groupIds.some(g=>p.selectedGroupIds[g])||(u={[d.id]:!0})),{...Wn({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:d.link||Fo(d)?"info":!1}}),o.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});v(this,"handleTextOnPointerDown",(t,o)=>{if(this.state.editingTextElement)return;let r=o.origin.x,i=o.origin.y;this.setState({hoveredArrowTextAnchor:null});let a=this.arrowText.getBindableEndpointAtPosition(r,i);if(a)this.startTextEditing({sceneX:r,sceneY:i,autoEdit:!1,arrowEndpoint:a});else{let s=this.getElementAtPosition(r,i,{includeBoundTextElement:!0}),l=this.getTextBindableContainerAtPosition(r,i);wM(s)&&(l=s,r=s.x+s.width/2,i=s.y+s.height/2),this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:l,autoEdit:!1,initialCaretSceneCoords:{x:r,y:i}})}this.isToolLocked()?this.cursor.reset():this.setState({activeTool:nn(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset())});v(this,"handleFreeDrawElementOnPointerDown",(t,o,r)=>{let[i,a]=Mt(r.origin.x,r.origin.y,null),s=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),l=t.pressure===.5,c=this.state.currentItemStrokeVariability,d=RY({type:o,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("freedraw"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:l,strokeOptions:{variability:c,streamline:t.pointerType!=="mouse"?jV:ZV},locked:!1,frameId:s?s.id:null,points:[oe(0,0)],pressures:l?[]:[t.pressure]});this.insertNewElement(d),this.setState(m=>{let p={...m.selectedElementIds};return delete p[d.id],{selectedElementIds:De(p,m)}}),this.setState({newElement:d,suggestedBinding:null})});v(this,"insertIframeElement",({sceneX:t,sceneY:o,width:r,height:i})=>{let[a,s]=Mt(t,o,this.lastPointerDownEvent?.[$.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=BY({type:"iframe",x:a,y:s,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("iframe"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:r,height:i});return this.insertNewElement(l),l});v(this,"insertEmbeddableElement",({sceneX:t,sceneY:o,link:r})=>{let[i,a]=Mt(t,o,this.lastPointerDownEvent?.[$.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=ou(r);if(!s)return;s.error instanceof URIError&&this.setToast({message:f("toast.unrecognizedLinkFormat"),closable:!0});let l=EM({type:"embeddable",x:i,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("embeddable"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("embeddable"),opacity:this.state.currentItemOpacity,locked:!1,width:s.intrinsicSize.w,height:s.intrinsicSize.h,link:r});return this.insertNewElement(l),l});v(this,"newImagePlaceholder",({sceneX:t,sceneY:o,addToFrameUnderCursor:r=!0,customData:i})=>{let[a,s]=Mt(t,o,this.lastPointerDownEvent?.[$.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=r?this.getTopLayerFrameAtSceneCoords({x:a,y:s}):null,c=100/this.state.zoom.value;return zY({type:"image",strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("image"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:l?l.id:null,customData:i,x:a-c/2,y:s-c/2,width:c,height:c})});v(this,"handleLinearElementOnPointerDown",(t,o,r)=>{if(t.ctrlKey&&Ot(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.state.multiElement){let{multiElement:i,selectedLinearElement:a}=this.state;if(mo(a,"selectedLinearElement is expected to be set"),i.type==="line"&&CM(i.points,this.state.zoom.value)){Ot(()=>{this.setState({selectedLinearElement:{...a,lastCommittedPoint:i.points[i.points.length-1],initialState:{...a.initialState,lastClickedPoint:-1}}})}),this.actionManager.executeAction(ut);return}if(Xt(i)&&i.points.length>1){this.actionManager.executeAction(ut,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}let{x:s,y:l}=i,{lastCommittedPoint:c}=a,d=Me(t,this.state),{start:m,end:p}=uo(i)&&tu(this.state)?OX(i,new Map([[i.points.length-1,{point:i.points[i.points.length-1],isDragging:!1}]]),d.x,d.y,this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.state,{newArrow:!!this.state.newElement,zoom:this.state.zoom}):{end:{mode:void 0}},u=this.scene.getNonDeletedElementsMap(),E=m?.mode!=null&&p.mode!=null&&m.element.id===p.element.id&&!ZM(p.focusPoint,p.element,u),g=p.mode==="orbit"&&i.startBinding?.elementId!==p.element?.id,b=c&&so(oe(r.origin.x-s,r.origin.y-l),c)<bb;if(g||E||i.points.length>1&&b){this.actionManager.executeAction(ut,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}this.setState(w=>({selectedElementIds:De({...w.selectedElementIds,[i.id]:!0},w)})),this.cursor.set(Ae.POINTER)}else{let[i,a]=Mt(r.origin.x,r.origin.y,t[$.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:l,currentItemEndArrowhead:c}=this.state,[d,m]=o==="arrow"?[l,c]:[null,null],p=o==="arrow"?FY({type:o,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(o),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemArrowType===Mr.round?{type:jp.PROPORTIONAL_RADIUS}:null,startArrowhead:d,endArrowhead:m,locked:!1,frameId:s?s.id:null,elbowed:this.state.currentItemArrowType===Mr.elbow,fixedSegments:this.state.currentItemArrowType===Mr.elbow?[]:null}):GY({type:o,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(o),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness==="round"?{type:jp.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:s?s.id:null}),u=oe(r.origin.x,r.origin.y),E=this.scene.getNonDeletedElementsMap(),g=tu(this.state)?Ar(u,this.scene.getNonDeletedElements(),E):null;this.scene.mutateElement(p,{points:[oe(0,0),oe(0,0)]}),this.insertNewElement(p),uo(p)&&MX(p,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:nM(t.nativeEvent)}),Ot(()=>{this.setState(b=>{let w=null,y=b.selectedElementIds;if(zt(p)){w=new fe(p,this.scene.getNonDeletedElementsMap());let x=p.points.length-1;w={...w,selectedPointsIndices:[x],initialState:{...w.initialState,arrowStartIsInside:t.altKey,lastClickedPoint:x,origin:oe(r.origin.x,r.origin.y)}}}return y=this.isToolLocked()?b.selectedElementIds:De({[p.id]:!0},b),{...b,bindMode:"orbit",newElement:p,suggestedBinding:g&&uo(p)?{element:g,midPoint:Nb(u,g,E,this.state.zoom)}:null,selectedElementIds:y,selectedLinearElement:w}})}),uo(p)&&Bo("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(p,g)}});v(this,"createGenericElementOnPointerDown",(t,o)=>{let[r,i]=Mt(o.origin.x,o.origin.y,this.lastPointerDownEvent?.[$.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:r,y:i}),s={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(t),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:a?a.id:null},l;t==="embeddable"?l=EM({type:"embeddable",...s}):l=OY({type:t,...s}),l.type==="selection"?this.setState({selectionElement:l}):(this.insertNewElement(l),this.setState({multiElement:null,newElement:l}))});v(this,"createFrameElementOnPointerDown",(t,o)=>{let[r,i]=Mt(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[$.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:r,y:i,opacity:this.state.currentItemOpacity,locked:!1,...No},s=o===Hn.magicframe?NY(a):_Y(a);this.insertNewElement(s),this.setState({multiElement:null,newElement:s})});v(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});v(this,"eraseElements",()=>{let t=!1;this.elementsPendingErasure.forEach(r=>{let i=this.scene.getElement(r);if(uo(i)){if(i.startBinding){let a=this.scene.getElement(i.startBinding.elementId);ru(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(s=>s.id!==i.id)})}if(i.endBinding){let a=this.scene.getElement(i.endBinding.elementId);ru(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(s=>s.id!==i.id)})}}else Tb(i)&&i.boundElements?.forEach(a=>{if(a.type==="arrow"){let s=this.scene.getElement(a.id);s?.startBinding?.elementId===i.id&&ru(s,this.scene.getElementsMapIncludingDeleted(),{startBinding:null}),s?.endBinding?.elementId===i.id&&ru(s,this.scene.getElementsMapIncludingDeleted(),{endBinding:null})}})});let o=this.scene.getElementsIncludingDeleted().map(r=>this.elementsPendingErasure.has(r.id)||r.frameId&&this.elementsPendingErasure.has(r.frameId)||vM(r)&&this.elementsPendingErasure.has(r.containerId)?(t=!0,po(r,{isDeleted:!0})):r);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(o))});v(this,"initializeImage",async(t,o)=>{if(!Mi(o))throw new Error(f("errors.unsupportedFileType"));this.cursor.set("wait");let r=this.gifPlayback.createPlaceholderDecodeState(t,o);if(o.type===lo.svg)try{o=Pu(PM(await o.text()),o.name)}catch(d){throw console.warn(d),new Error(f("errors.svgImageInsertError"))}else if(o.type!==lo.gif){let{maxWidthOrHeight:d}=this.props.imageOptions;try{o=await(this.props.compressImageFile??vx)(o,{maxWidthOrHeight:d})}catch(m){console.error("Error trying to resize image file on insertion",m)}}let i=o.type,a=i===lo.gif,s=await(this.props.generateIdForFile?.(o)||xx(o));if(!s)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(f("errors.imageInsertError"));if(!this.files[s]?.dataURL){let{maxFileSizeBytes:d}=this.props.imageOptions;if(o.size>d)throw new Error(f("errors.fileTooBig",{maxSize:`${Math.trunc(d/1024/1024)}MB`}))}let c=this.files[s]?.dataURL||await Rc(o);return new Promise(async(d,m)=>{try{let p=this.getLatestInitializedImageElement(t,s);if(this.addMissingFiles([{mimeType:i,id:s,dataURL:c,fileName:o.name,created:Date.now(),lastRetrieved:Date.now()}]),a&&(p=this.gifPlayback.ensureElementPlaybackMetadata(p),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(g=>g.id===p.id?p:g)),this.imagePlaceholderUpdateEmitter.trigger()),!this.imageCache.get(s)){a||this.addNewImagesToImageCache();let{erroredFiles:g}=await this.updateImageCache([p]);if(g.size)throw new Error("Image cache update resulted with an error.")}let u=await this.imageCache.get(s)?.image,E=u?KY(u):null;if(u&&this.state.newElement?.id!==p.id){p=this.getLatestInitializedImageElement(t,s);let g=this.getImageNaturalDimensions(p,u);Object.assign(p,g)}p=po(p,{fileName:o.name,thumbHash:E,gifPlayback:a?this.gifPlayback.ensureElementPlaybackMetadata(p,{playing:!0}).gifPlayback:null,status:"saved"}),this.files={...this.files,[s]:{...this.files[s],fileName:o.name,thumbHash:E??void 0}},r&&r!==s&&this.gifPlayback.removePlaceholderDecodeState(r),d(p)}catch(p){this.gifPlayback.removePlaceholderDecodeState(r),console.error(p),m(new Error(f("errors.imageInsertError")))}})});v(this,"getLatestInitializedImageElement",(t,o)=>{let r=this.scene.getElement(t.id)??t;return po(r,{fileId:o})});v(this,"onImageToolbarButtonClick",async()=>{try{let t=this.state.width/2+this.state.offsetLeft,o=this.state.height/2+this.state.offsetTop,{x:r,y:i}=Me({clientX:t,clientY:o},this.state),a=await cx({description:"Image",extensions:Object.keys(QV),multiple:!0});this.insertImages(a,r,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:nn(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction(ut)})}});v(this,"getImageNaturalDimensions",(t,o)=>{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(o.naturalHeight,i),s=a*(o.naturalWidth/o.naturalHeight),l=t.x+t.width/2-s/2,c=t.y+t.height/2-a/2;return{x:l,y:c,width:s,height:a,crop:null}});v(this,"handleImageCacheUpdate",t=>{for(let o of this.scene.getNonDeletedElements())yi(o)&&o.fileId===t&&wi.delete(o);this.imagePlaceholderUpdateEmitter.trigger(),this.scene.triggerUpdate(),this.ensureGifPlaybackLoop()});v(this,"updateImageCache",async(t,o=this.files)=>{let r=new Map;for(let s of t){let l=this.imageCache.get(s.fileId);l&&r.set(s.fileId,Promise.resolve(l.image))}let{updatedFiles:i,erroredFiles:a}=await Cb({imageCache:this.imageCache,fileIds:t.map(s=>s.fileId),files:o,onImageCacheUpdate:s=>this.handleImageCacheUpdate(s),gifAutoDecodeMaxFileSizeBytes:this.props.imageOptions.gifAutoDecodeMaxFileSizeBytes});for(let[s,l]of r){let c=this.imageCache.get(s);!c||!i.has(s)||this.imageCache.set(s,{...c,placeholderImage:await l,transitionStart:performance.now()})}return(a.size||i.size)&&(this.store.scheduleAction($t.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(s=>{if(yi(s)){if(a.has(s.fileId))return po(s,{status:"error"});if(i.has(s.fileId)&&s.status==="error")return po(s,{status:"saved"})}return s}))),{updatedFiles:i,erroredFiles:a}});v(this,"ensureGifPlaybackLoop",()=>{this.gifPlayback.ensureLoop()});v(this,"loadDeferredGif",async t=>{let o=this.imageCache.get(t);this.files[t]?.mimeType!==lo.gif||!o||(this.imageCache.set(t,{...o,gifDecodeStatus:"pending"}),this.handleImageCacheUpdate(t),await Cb({imageCache:this.imageCache,fileIds:[t],files:this.files,onImageCacheUpdate:i=>this.handleImageCacheUpdate(i),forceGifDecode:!0}))});v(this,"getGifPlaybackFrameIndex",t=>this.gifPlayback.getFrameIndex(t));v(this,"setGifPlaybackFrameIndex",(t,o)=>{this.gifPlayback.setFrameIndex(t,o)});v(this,"addNewImagesToImageCache",async(t=jY(this.scene.getNonDeletedElements()),o=this.files)=>{let r=t.filter(i=>!i.isDeleted&&!this.imageCache.has(i.fileId));if(r.length){let{updatedFiles:i}=await this.updateImageCache(r,o);if(i.size)for(let a of r)i.has(a.fileId)&&wi.delete(a);i.size&&this.scene.triggerUpdate()}});v(this,"scheduleImageRefresh",YV(()=>{this.addNewImagesToImageCache()},eY));v(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.cursor.reset(),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))});v(this,"insertImages",async(t,o,r,i)=>{let a=50/this.state.zoom.value,s=XM(t.map((u,E)=>this.newImagePlaceholder({sceneX:o,sceneY:r,customData:i?.[E]})),o,r,a);this.insertNewElements(s);let l=await Promise.all(s.map(async(u,E)=>{try{return await this.initializeImage(u,await Br(t[E]))}catch(g){return this.setState({errorMessage:g.message||f("errors.imageInsertError")}),po(u,{isDeleted:!0})}})),c=hc(l),d=XM(l.filter(u=>!u.isDeleted),o,r,a),m=hc(d),p=this.scene.getElementsIncludingDeleted().map(u=>m.get(u.id)??c.get(u.id)??u);this.updateScene({appState:{selectedElementIds:De(Object.fromEntries(d.map(u=>[u.id,!0])),this.state)},elements:p,captureUpdate:$t.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(ut)})});v(this,"handleAppOnDrop",async t=>{if(!this.isInteractionEnabled())return;let{x:o,y:r}=Me(t,this.state),i=qh(t),a=await Kr(t),s=a.getFiles(),l=s.map(d=>d.file).filter(d=>Mi(d));if(this.state.viewModeEnabled)return l.length===0||!this.isToolSupported("image")||!this.shouldInsertImageInViewMode({source:"drop",files:l,event:t})?void 0:this.insertImages(l,o,r,Zd(a,l.length,i));if(s.length===1){let{file:d,fileHandle:m}=s[0];if(d&&(d.type===lo.png||d.type===lo.svg))try{let p=await vs(d,this.state,this.scene.getElementsIncludingDeleted(),m);this.syncActionResult({...p,appState:{...p.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:$t.IMMEDIATELY});return}catch(p){if(p.name!=="EncodingError")throw new Error(f("alerts.couldNotLoadInvalidFile"))}}if(l.length>0&&this.isToolSupported("image"))return this.insertImages(l,o,r,Zd(a,l.length,i));if(s.length>0){let{file:d,fileHandle:m}=s[0];d&&await this.loadFileToCanvas(d,m)}let c=a.findByType(lo.text);if(c){let d=c.value;if(d&&Sb(d,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(d)||ou(d)?.type==="video")){let m=this.insertEmbeddableElement({sceneX:o,sceneY:r,link:Jp(d)});m&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[m.id]:!0}}))}}});v(this,"loadFileToCanvas",async(t,o)=>{t=await Br(t);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await vs(t,this.state,r,o)}catch(a){let s=a instanceof lx;if(s&&a.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:f("errors.imageToolNotSupported")});return}let l=s?f("alerts.cannotRestoreFromImage"):f("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:l})}if(!i)return;n3(r.concat(i.elements)),this.store.scheduleMicroAction({action:$t.NEVER,elements:r,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({elements:i.elements,files:i.files,appState:{...i.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:$t.IMMEDIATELY})}catch(r){this.setState({isLoading:!1,errorMessage:r.message})}});v(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),!this.isInteractionEnabled()||(this.bucketFill.cancel(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==Gn.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type))return;let{x:o,y:r}=Me(t,this.state),i=this.getElementAtPosition(o,r,{preferSelected:!0,includeLockedElements:!0}),a=this.isLinksEnabled()?this.getElementLinkAtPositionForContextMenu({x:o,y:r},i):void 0,s=this.scene.getSelectedElements(this.state),l=this.isHittingCommonBoundingBoxOfSelectedElements({x:o,y:r},s),c=l&&s.length===1&&s[0].link?s[0]:void 0,d=i??a??c,m=d||l?"element":"canvas",p=this.excalidrawContainerRef.current,{top:u,left:E}=p.getBoundingClientRect(),g=t.clientX-E,b=t.clientY-u;Fe("contextMenu","openContextMenu",m),this.setState({...d&&!this.state.selectedElementIds[d.id]?{...this.state,...Wn({editingGroupId:this.state.editingGroupId,selectedElementIds:{[d.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:zt(d)?new fe(d,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:b,left:g,items:this.getContextMenuItems(m,d)}})})});v(this,"maybeDragNewGenericElement",(t,o,r=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&t.boxSelection.hasOccurred&&this.state.activeTool.type!=="eraser"){WM({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:ds(t.origin.x,a.x),height:ds(t.origin.y,a.y),shouldMaintainAspectRatio:dc(o),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let s=this.state.newElement;if(!s||this.arrowText.maybeDragNewText(s,a))return;let[l,c]=Mt(a.x,a.y,o[$.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=yi(s)&&this.imageCache.get(s.fileId)?.image,m=d&&!(d instanceof Promise)?d.width/d.height:null;this.maybeCacheReferenceSnapPoints(o,[s]);let{snapOffset:p,snapLines:u}=F2(s,this,o,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:l-t.originInGrid.x,y:c-t.originInGrid.y},this.scene.getNonDeletedElementsMap());l+=p.x,c+=p.y,this.setState({snapLines:u}),uo(s)||WM({newElement:s,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:l,y:c,width:ds(t.originInGrid.x,l),height:ds(t.originInGrid.y,c),shouldMaintainAspectRatio:Un(s)?!dc(o):dc(o),shouldResizeFromCenter:tM(o),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:m,originOffset:this.state.originSnapOffset,informMutation:r}),this.setState({newElement:s}),(this.state.activeTool.type===Hn.frame||this.state.activeTool.type===Hn.magicframe)&&this.setState({elementsToHighlight:Db(this.scene.getNonDeletedElements(),s,this.state,this.scene.getNonDeletedElementsMap())})});v(this,"maybeHandleCrop",(t,o)=>{if(!this.state.croppingElementId)return!1;let r=t.resize.handleType,i=t.lastCoords,[a,s]=Mt(i.x-t.resize.offset.x,i.y-t.resize.offset.y,o[$.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(r&&l&&Un(l)){let c=t.originalElements.get(l.id),d=yi(l)&&this.imageCache.get(l.fileId)?.image;if(c&&Un(c)&&d&&!(d instanceof Promise)){let[m,p]=Mt(i.x,i.y,o[$.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:m-t.originInGrid.x,y:p-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(o,[l]);let{snapOffset:E,snapLines:g}=df([l],[c],this,o,u,r);this.scene.mutateElement(l,cX(l,this.scene.getNonDeletedElementsMap(),r,d.naturalWidth,d.naturalHeight,a+E.x,s+E.y,o.shiftKey?c.width/c.height:void 0)),nu(l,this.scene),this.setState({isCropping:r&&r!=="rotation",snapLines:g})}return!0}return!1});v(this,"maybeHandleResize",(t,o)=>{let r=this.scene.getSelectedElements(this.state),i=r.filter(Tt),a=t.resize.handleType;if(i.length>0&&a==="rotation"||r.length===1&&Xt(r[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let s=t.lastCoords,[l,c]=Mt(s.x-t.resize.offset.x,s.y-t.resize.offset.y,o[$.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=new Map;if(i.forEach(m=>{Mb(this.scene.getNonDeletedElements(),m.id).forEach(u=>{d.set(m.id+u.id,{x:u.x-m.x,y:u.y-m.y})})}),!this.state.selectedElementsAreBeingDragged){let[m,p]=Mt(s.x,s.y,o[$.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:m-t.originInGrid.x,y:p-t.originInGrid.y},E=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(o,r);let{snapOffset:g,snapLines:b}=df(r,ce(E,this.state),this,o,u,a);l+=g.x,c+=g.y,this.setState({snapLines:b})}if(TX(t.originalElements,a,r,this.scene,nM(o),tM(o),r.some(m=>Un(m))?!dc(o):dc(o),l,c,t.resize.center.x,t.resize.center.y)){let m=new Set;return i.forEach(p=>{Db(this.scene.getNonDeletedElements(),p,this.state,this.scene.getNonDeletedElementsMap()).forEach(u=>{au(u)?m.add(u):console.error("[NONDELETED][INVARIANT] Skipped highlighting deleted element in resizing frame")})}),this.setState({elementsToHighlight:[...m]}),!0}return!1});v(this,"getImageContextMenuItems",t=>{let o=this.props.imageContextMenuItems;if(!o)return[];let r=this.scene.getSelectedElements(this.state);return r.length>0&&r.every(i=>Un(i))&&(!t||this.state.selectedElementIds[t.id])?[...o(r.map(i=>i.id))]:t&&Un(t)?[...o([t.id])]:[]});v(this,"getImageActionContextMenuItems",t=>{let o=this.scene.getSelectedElements(this.state);return o.length>0&&o.every(r=>Un(r))&&(!t||this.state.selectedElementIds[t.id])?[lg,cg]:[]});v(this,"getElementLinkContextMenuItems",t=>{if(!t?.link)return[];let o=Jp(t.link),r=RM(o);return[{key:"goToLink",label:r?f("labels.link.goToElement"):"Go to link",onSelect:()=>this.openElementLink(t)},!r&&{key:"copyLink",label:f("buttons.copyLink"),onSelect:async()=>{await To(o),this.setState({toast:{message:f("toast.elementLinkCopied"),closable:!0}})}}]});v(this,"getContextMenuItems",(t,o)=>{let r=this.getImageContextMenuItems(o),i=this.getImageActionContextMenuItems(o),a=this.getElementLinkContextMenuItems(o);if(t==="canvas")return this.state.viewModeEnabled?[al,pa,Ca,mr]:[pg,qe,mh,Cv,qe,pa,Lt,sl,ll,Ca,mr];if(this.state.viewModeEnabled)return[...a,a.length>0&&qe,al,ma,r.length>0&&qe,...r];let s=this.editorInterface.formFactor==="desktop"?[qe,sh,lh,ch,dh]:[];return[qe,al,qe,sm,ma,pg,r.length>0&&qe,...r,i.length>0&&qe,...i,qe,f2,E2,b2,qe,qg,qe,ig,nf,gg,fg,cv,ag,qe,...s,qe,dg,mg,qe,va,qe,Sg,a.length>0&&qe,...a,qe,ph,ml,qe,Ls]});v(this,"handleWheel",Ke(t=>{if(!this.isNavigationEnabled())return;if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement||t.target instanceof HTMLElement&&(t.target.classList.contains(vb.FRAME_NAME)||t.target.classList.contains("excalidraw-eye-dropper-backdrop")))){t[$.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),zo)return;let{deltaX:o,deltaY:r}=t;if(t.metaKey||t.ctrlKey||this.state.wheelZoomsOnDefault){let i=Math.sign(r),a=aY*100,s=Math.abs(r),l=r;s>a&&(l=a*i);let c=this.state.zoom.value-l/100;c+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,s/20);let d=this.state.scrollConstraints?.lockZoom?this.state.scrollConstraints.zoom:sY;c=Math.max(c,d),this.viewport.translate(p=>({...fo({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:Yn(c)},p),shouldCacheIgnoreZoom:!0}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})&&this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.viewport.translate(({zoom:i,scrollX:a})=>({scrollX:a-(r||o)/i.value}));return}this.viewport.translate(({zoom:i,scrollX:a,scrollY:s})=>({scrollX:a-o/i.value,scrollY:s-r/i.value}))}));v(this,"savePointer",(t,o,r)=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)||!t||!o)return;let{x:i,y:a}=Me({clientX:t,clientY:o},this.state);isNaN(i)||isNaN(a);let s={x:i,y:a,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:s,button:r,pointersMap:de.pointers})});v(this,"resetShouldCacheIgnoreZoomDebounced",cM(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));v(this,"updateDOMRect",t=>{if(this.excalidrawContainerRef?.current){let o=this.excalidrawContainerRef.current,{width:r,height:i,left:a,top:s}=o.getBoundingClientRect(),{width:l,height:c,offsetTop:d,offsetLeft:m}=this.state;if(r===l&&i===c&&a===m&&s===d){t&&t();return}this.setState({width:r,height:i,offsetLeft:a,offsetTop:s},()=>{t&&t()}),this.viewport.constrain()}});v(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});v(this,"watchState",()=>{});let o=Xo(),{viewModeEnabled:r=!1,viewModeOnly:i=!1,gridModeEnabled:a=!1,objectsSnapModeEnabled:s=!1,theme:l=o.theme,name:c=`${f("labels.untitled")}-${mM()}`,wheelZoomsOnDefault:d=!1}=t,m=null;t.activeTool&&(t.activeTool.type==="image"?console.warn('"image" tool cannot be forced via "props.activeTool"'):this.isToolSupported(t.activeTool.type,t)?m=nn(o,t.activeTool):console.warn(`"${t.activeTool.type}" tool ("props.activeTool") cannot be activated \u2014 disabled via "UIOptions.tools", or not enabled while non-interactive (see "interaction.enabled.tools")`)),this.state={...o,theme:l,exportWithDarkMode:l===mc.DARK,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:this.isInteractionEnabled(t)?i||r:!0,viewModeOnly:i,activeTool:m??o.activeTool,zenModeEnabled:!1,objectsSnapModeEnabled:s,gridModeEnabled:a??o.gridModeEnabled,name:c,width:window.innerWidth,height:window.innerHeight,wheelZoomsOnDefault:d},this.refreshEditorInterface(),this.stylesPanelMode=mu(this.editorInterface),this.id=KV(),this.actionManager=new Tm(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new VM,this.canvas=document.createElement("canvas"),this.rc=XV.canvas(this.canvas),this.renderer=new Al(this.scene),this.visibleElements=[],this.store=new PX(this),this.history=new kl(this.store),this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new Eo(this.scene),this.history=new kl(this.store),this.actionManager.registerAll(jc),this.actionManager.registerAction(v2(this.history)),this.actionManager.registerAction(I2(this.history)),this.api=this.createExcalidrawAPI()}get lastViewportPosition(){return this.viewport.lastPosition}createExcalidrawAPI(){return{isDestroyed:!1,updateScene:this.updateScene,applyDeltas:this.applyDeltas,mutateElement:this.mutateElement,addFiles:this.addFiles,addImagePlaceholder:this.addImagePlaceholder,setDownloadProgress:this.setDownloadProgress,setDownloadError:this.setDownloadError,setUploadProgress:this.setUploadProgress,addImageElementsToScene:this.addImageElementsToScene,scrollToViewport:this.scrollToViewport,scrollToContent:this.scrollToContent,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},setViewport:this.viewport.setViewport,getViewportOffsets:this.viewport.getOffsets,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:o=>{this.actionManager.registerAction(o)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.cursor.set,resetCursor:this.cursor.reset,getEditorInterface:()=>this.editorInterface,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:o=>this.onChangeEmitter.on(o),onIncrement:o=>this.store.onStoreIncrementEmitter.on(o),onPointerDown:o=>this.onPointerDownEmitter.on(o),onPointerUp:o=>this.onPointerUpEmitter.on(o),onScrollChange:o=>this.onScrollChangeEmitter.on(o),onUserFollow:o=>this.onUserFollowEmitter.on(o),onStateChange:this.onStateChange,onEvent:this.onEvent}}isInteractionEnabled(t=this.props){return t.interaction!==!1&&typeof t.interaction!="object"}isLinksEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.links===!0||t.interaction.enabled?.interactiveContent===!0:t.interaction!==!1}isNavigationEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.navigation===!0:t.interaction!==!1}isEmbedsEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.embeds===!0||t.interaction.enabled?.interactiveContent===!0:t.interaction!==!1}isBrowserZoomEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.browserZoom===!0:!1}isToolLocked(){return this.state.activeTool.locked||this.props.activeTool!=null}isActiveToolPointerCapturing(){return this.isInteractionEnabled()?this.state.activeTool.type==="laser"||this.state.activeTool.type==="custom":this.isToolSupported(this.state.activeTool.type)}isDefaultUIEnabled(t=this.props){return t.ui!==!1&&(typeof t.ui!="object"||t.ui===null)}isUIControlEnabled(t,o=this.props){return typeof o.ui=="object"&&o.ui!==null?o.ui.enabled?.[t]===!0:o.ui!==!1}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let o=null;try{o=JSON.parse(t.data)}catch{}if(o)switch(t.origin){case"https://player.vimeo.com":if(o.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:o.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(o.event==="infoDelivery"&&o.info&&o.id&&typeof o.info.playerState=="number"){let r=o.id,i=o.info.playerState;Object.values(qp).includes(i)&&Bb.set(r,i)}break}}handleSkipBindMode(){if(this.state.selectedLinearElement?.initialState&&!this.state.selectedLinearElement.initialState.arrowStartIsInside){mo(this.lastPointerMoveCoords,"Missing last pointer move coords when changing bind skip mode for arrow start");let t=this.scene.getNonDeletedElementsMap(),o=Ar(oe(this.lastPointerMoveCoords.x,this.lastPointerMoveCoords.y),this.scene.getNonDeletedElements(),t),r=fe.getElement(this.state.selectedLinearElement.elementId,t);r?.startBinding&&o?.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),Ot(()=>{this.setState({bindMode:"skip"})}),this.lastPointerMoveCoords&&this.state.selectedLinearElement?.selectedPointsIndices&&this.state.selectedLinearElement?.selectedPointsIndices.length)){let{x:t,y:o}=this.lastPointerMoveCoords,r=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;mo(r,"Last event must exist");let i=t-this.state.selectedLinearElement.pointerOffset.x,a=o-this.state.selectedLinearElement.pointerOffset.y,s=this.state.multiElement?fe.handlePointerMove(r,this,i,a,this.state.selectedLinearElement):fe.handlePointDragging(r,this,i,a,this.state.selectedLinearElement);s&&this.setState(s)}}resetDelayedBindMode(){this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode!=="orbit"&&setTimeout(()=>this.setState({bindMode:"orbit"}))}handleDelayedBindModeChange(t,o){if(t.isDeleted||Xt(t))return;let r=()=>{if(this.bindModeHandler=null,mo(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 E=this.state.selectedLinearElement.selectedPointsIndices.includes(0),g=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1);if(!E&&!g||E&&g)return}let{x:m,y:p}=this.lastPointerMoveCoords,u=Ar(oe(m,p),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(u&&this.state.bindMode!=="skip"){mo(this.state.selectedLinearElement?.elementId===t.id,"The selectedLinearElement is expected to not change while a bind mode timeout is ticking");let E=this.state.selectedLinearElement.initialState.arrowStartIsInside||t.startBinding?.elementId===u.id;Ot(()=>{mo(this.state.selectedLinearElement,"this.state.selectedLinearElement must exist"),this.setState({bindMode:"inside",selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:E}}})});let g=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;mo(g,"Last event must exist");let b=m-this.state.selectedLinearElement.pointerOffset.x,w=p-this.state.selectedLinearElement.pointerOffset.y,y=this.state.multiElement?fe.handlePointerMove(g,this,b,w,this.state.selectedLinearElement):fe.handlePointDragging(g,this,b,w,this.state.selectedLinearElement);y&&this.setState(y)}},i=!1;if(this.state.selectedLinearElement?.selectedPointsIndices){let m=this.scene.getNonDeletedElementsMap(),p=this.state.selectedLinearElement.selectedPointsIndices.includes(0),u=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1),E=p?o:t.startBinding&&m.get(t.startBinding.elementId),g=u?o:t.endBinding&&m.get(t.endBinding.elementId),b=E&&$M(E,m),w=g&&$M(g,m);i=!!(b&&w&&E.id!==g.id&&AX(b,w))}let a=this.state.selectedLinearElement?.selectedPointsIndices?.includes(0),s=this.state.selectedLinearElement?.selectedPointsIndices?.includes(t.points.length-1),l=a?"startBinding":s?"endBinding":null,c=a?"endBinding":s?"startBinding":null,d=c&&t[c]?.mode==="inside"&&t[c]?.elementId===o?.id||l&&t[l]?.mode==="inside"&&o?.id===t[l]?.elementId;l&&c&&t[l]?.mode==="inside"&&o?.id!==t[l]?.elementId&&t[c]?.elementId!==t[l]?.elementId&&this.scene.mutateElement(t,{[l]:{...t[l],mode:"orbit"}},{informMutation:!1,isDragging:!0}),!o||this.previousHoveredBindableElement&&o.id!==this.previousHoveredBindableElement.id?(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode==="inside"&&Ot(()=>{this.setState({bindMode:"orbit"})}),this.previousHoveredBindableElement=null):!this.bindModeHandler&&(!this.state.newElement||!t.startBinding||i)&&!d&&(this.bindModeHandler=setTimeout(r,IY)),this.previousHoveredBindableElement=o}cacheEmbeddableRef(t,o){o&&this.iFrameRefs.set(t.id,o)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleIframeLikeCenterClick(){if(!this.lastPointerDownEvent||!this.lastPointerUpEvent||this.lastPointerDownEvent.button!==Gn.MAIN||Oo||!hM(this.state.activeTool.type,["laser","selection","lasso"]))return!1;let t=oe(Me({clientX:this.lastPointerDownEvent.clientX,clientY:this.lastPointerDownEvent.clientY},this.state)),o=oe(Me({clientX:this.lastPointerUpEvent.clientX,clientY:this.lastPointerUpEvent.clientY},this.state));if(so(t,o)>rM)return!1;let i=this.getElementAtPosition(t[0],t[1]);if(!(i&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<=300&&de.pointers.size<2&&fc(i)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(i,this.lastPointerUpEvent,o[0],o[1]))))return!1;let s=i;if(this.state.activeEmbeddable?.element===s&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:s,state:"active"},selectedElementIds:{[s.id]:!0},newElement:null,selectionElement:null})},100),Ib(s)))return!0;let l=this.getHTMLIFrameElement(s);if(!l?.contentWindow)return!0;if(l.src.includes("youtube")){let c=Bb.get(s.id);switch(c||(Bb.set(s.id,qp.UNSTARTED),l.contentWindow.postMessage(JSON.stringify({event:"listening",id:s.id}),"*")),c){case qp.PLAYING:case qp.BUFFERING:l.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:l.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}return l.src.includes("player.vimeo.com")&&l.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*"),!0}isIframeLikeElementCenter(t,o,r,i){return t&&!o.altKey&&!o.shiftKey&&!o.metaKey&&!o.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,o=this.state.width,r=this.state.height,i=this.scene.getNonDeletedElements().filter(a=>Fo(a)&&this.embedsValidationStatus.get(a.id)===!0||Ib(a));return Pe(UX,{children:i.map(a=>{let{x:s,y:l}=Qp({sceneX:a.x,sceneY:a.y},this.state),c=TM(a,o,r,this.state,this.scene.getNonDeletedElementsMap()),d=this.initializedEmbeds.has(a.id);if(c&&!d&&this.initializedEmbeds.add(a.id),!(c||d))return null;let p=ou(pY(a.link||"")),u=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="active",E=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="hover",g=p?.type==="video",b=cc(g?t:1,.75,GX);return Pe("div",{className:jk("excalidraw__embeddable-container",{"is-hovered":E}),style:{transform:c?`translate(${s-this.state.offsetLeft}px, ${l-this.state.offsetTop}px) scale(${t})`:"none",display:c?"block":"none",opacity:fX(a,Lb(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?dY:1),"--embeddable-radius":`${$Y(Math.min(a.width,a.height),a)}px`},children:Fb("div",{className:"excalidraw__embeddable-container__inner",style:{width:c?`${a.width}px`:0,height:c?`${a.height}px`:0,transform:c?`rotate(${a.angle}rad)`:"none",pointerEvents:u?cs.enabled:cs.disabled},children:[E&&Pe("div",{className:"excalidraw__embeddable-hint",children:f("buttons.embeddableInteractionButton")}),Pe("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:Pe("div",{className:"excalidraw__embeddable__content",style:{width:`${b*100}%`,height:`${b*100}%`,transform:`scale(${1/b})`},children:(Fo(a)?this.props.renderEmbeddable?.(a,this.state):null)??Pe("iframe",{ref:w=>this.cacheEmbeddableRef(a,w),className:"excalidraw__embeddable",srcDoc:p?.type==="document"?p.srcdoc(this.state.theme):void 0,src:p?.type!=="document"?p?.link??"":void 0,scrolling:"no",referrerPolicy:"no-referrer-when-downgrade",title:"Excalidraw Embedded Content",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,sandbox:`${p?.sandbox?.allowSameOrigin?"allow-same-origin":""} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})})]})},a.id)})})}toggleOverscrollBehavior(t){document.documentElement.style.overscrollBehaviorX=t.type==="pointerenter"?"none":"auto"}render(){let t=this.scene.getSelectedElements(this.state),{renderTopRightUI:o,renderTopLeftUI:r,renderCustomStats:i}=this.props,{elementsMap:a,visibleElements:s,canvasNonce:l,newElementCanvasElement:c}=this.renderer.getRenderableElements({zoom:this.state.zoom,offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,height:this.state.height,width:this.state.width,editingTextElement:this.state.editingTextElement,newElement:this.state.newElement,selectedElements:t,selectedElementsAreBeingDragged:this.state.selectedElementsAreBeingDragged,frameToHighlight:this.state.frameToHighlight});this.visibleElements=s,this.hasRenderableElements=a.size>0;let d=this.scene.getNonDeletedElementsMap(),m="setPointerCapture"in HTMLElement.prototype?!1:this.state.selectionElement||this.state.newElement||this.state.selectedElementsAreBeingDragged||this.state.resizingElement||this.state.activeTool.type==="laser"&&this.state.cursorButton==="down",p=t[0],u=Et.get(ro)?.type==="panel";return Pe("div",{translate:"no",className:jk("excalidraw excalidraw-container notranslate",this.props.className,{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.editorInterface.formFactor==="phone","excalidraw--non-interactive":!this.isInteractionEnabled(),"excalidraw--navigation":!this.isInteractionEnabled()&&this.isNavigationEnabled(),"excalidraw--tools":!this.isInteractionEnabled()&&this.isToolSupported(this.state.activeTool.type),"excalidraw--embeds":!this.isInteractionEnabled()&&this.isEmbedsEnabled(),"excalidraw--allow-browser-zoom":!this.isInteractionEnabled()&&this.isBrowserZoomEnabled(),"excalidraw--ui-hidden":!this.isDefaultUIEnabled(),"excalidraw--mobile-toolbar":this.editorInterface.formFactor==="phone"&&this.isDefaultUIEnabled()&&!this.state.viewModeEnabled,"excalidraw--viewport-status-border":!!this.props.viewportStatusFrame?.border,"excalidraw--viewport-status-label":!!this.props.viewportStatusFrame?.label,"excalidraw--zen-mode":this.state.zenModeEnabled}),style:{"--ui-pointerEvents":m?cs.disabled:cs.enabled,"--right-sidebar-width":`${eE}px`},ref:this.excalidrawContainerRef,onDrop:this.isInteractionEnabled()?this.handleAppOnDrop:void 0,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally||!this.isInteractionEnabled()?void 0:this.onKeyDown,onPointerEnter:this.isInteractionEnabled()?this.toggleOverscrollBehavior:void 0,onPointerLeave:this.isInteractionEnabled()?this.toggleOverscrollBehavior:void 0,children:Pe(us.Provider,{value:this.api,children:Pe(o3.Provider,{value:this,children:Pe(r3.Provider,{value:this.props,children:Pe(Hb.Provider,{value:this.excalidrawContainerValue,children:Pe(Gb.Provider,{value:this.editorInterface,children:Pe(Vb.Provider,{value:this.setAppState,children:Pe(Wb.Provider,{value:this.state,children:Fb(Ub.Provider,{value:this.scene.getNonDeletedElements(),children:[Fb(Yb.Provider,{value:this.actionManager,children:[Pe(Mk,{canvas:this.canvas,appState:this.state,defaultUIEnabled:this.isDefaultUIEnabled(),zoomUIEnabled:this.isUIControlEnabled("zoom"),scrollBackToContentUIEnabled:this.isUIControlEnabled("scrollBackToContent"),files:this.files,setAppState:this.setAppState,actionManager:this.actionManager,elements:this.scene.getNonDeletedElements(),onLockToggle:this.toggleLock,onPenModeToggle:this.togglePenMode,langCode:Kn().code,renderTopLeftUI:r,renderTopRightUI:o,renderCustomStats:i,showExitZenModeBtn:!1,UIOptions:this.props.UIOptions,onExportImage:this.onExportImage,renderWelcomeScreen:!this.state.isLoading&&this.state.showWelcomeScreen&&this.state.activeTool.type===this.state.preferredSelectionTool.type&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,currentUserControls:this.props.currentUserControls,children:this.props.children}),Pe("div",{className:"excalidraw-textEditorContainer"}),Pe("div",{className:"excalidraw-contextMenuContainer"}),Pe("div",{className:"excalidraw-eye-dropper-container"}),Pe(Dk,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail,this.drawShape.trail]}),this.isDefaultUIEnabled()&&Pe(Kk,{}),this.isDefaultUIEnabled()&&t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&Pe(fv,{element:p,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},p.id),this.isDefaultUIEnabled()&&this.state.contextMenu&&Pe(jT,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:E=>{this.setState({contextMenu:null},()=>{this.focusContainer(),E?.()})}}),Pe(hb,{app:this,canvas:this.canvas,rc:this.rc,elementsMap:a,allElementsMap:d,visibleElements:s,canvasNonce:l,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,getGifFrameIndex:this.gifPlayback.getFrameIndex,isExporting:!1,renderGrid:hr(this),renderLinks:this.isLinksEnabled(),imageTransitionDuration:this.props.imageOptions.placeholderTransitionDuration,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowchart.pendingNodes,theme:this.state.theme}}),c&&Pe(Hk,{appState:this.state,newElement:c,scale:window.devicePixelRatio,rc:this.rc,elementsMap:a,allElementsMap:d,renderConfig:{imageCache:this.imageCache,getGifFrameIndex:this.gifPlayback.getFrameIndex,isExporting:!1,imageTransitionDuration:this.props.imageOptions.placeholderTransitionDuration,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null,theme:this.state.theme}}),Pe(ub,{app:this,containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:a,visibleElements:s,allElementsMap:d,selectedElements:t,canvasNonce:l,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderScrollbars:this.props.renderScrollbars===!0,editorInterface:this.editorInterface,interactionEnabled:this.isInteractionEnabled(),navigationEnabled:this.isNavigationEnabled(),renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onClick:this.handleCanvasClick,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.props.viewportStatusFrame?.border&&this.editorInterface.formFactor==="phone"&&Pe(dp,{border:this.props.viewportStatusFrame.border}),this.renderFrameNames(),this.isDefaultUIEnabled()&&this.state.activeLockedId&&Pe(Zk,{app:this,activeLockedId:this.state.activeLockedId}),this.isDefaultUIEnabled()&&u&&Pe(vT,{app:this})]}),this.renderEmbeddables()]})})})})})})})})})}clearImageShapeCache(t){let o=t??this.files;this.scene.getNonDeletedElements().forEach(r=>{yi(r)&&o[r.fileId]&&(this.imageCache.delete(r.fileId),wi.delete(r))})}async componentDidMount(){if(this.unmounted=!1,this.api=this.createExcalidrawAPI(),this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,QM()||e3()){let r=this.setState.bind(this);Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...i)=>this.setState(...i)},app:{configurable:!0,value:this},history:{configurable:!0,value:this.history},store:{configurable:!0,value:this.store},fonts:{configurable:!0,value:this.fonts}})}this.store.onDurableIncrementEmitter.on(r=>{this.history.record(r.delta)}),this.props.onIncrement&&this.store.onStoreIncrementEmitter.on(r=>{this.props.onIncrement?.(r)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),lY&&this.excalidrawContainerRef.current&&(this.resizeObserver=new ResizeObserver(()=>{this.refreshEditorInterface(),this.updateDOMRect()}),this.resizeObserver?.observe(this.excalidrawContainerRef.current)),new URLSearchParams(window.location.search.slice(1)).has("web-share-target")?this.restoreFileFromShare():this.updateDOMRect(this.initializeScene),CY()&&!mX()&&this.setState({errorMessage:Pe(UT,{})});let o={excalidrawAPI:this.api,container:this.excalidrawContainerRef.current};this.editorLifecycleEvents.emit("editor:mount",o),this.props.onMount?.(o),this.props.onExcalidrawAPI?.(this.api)}componentWillUnmount(){this.gifPlayback.stop(),this.api={...this.api,isDestroyed:!0};for(let t of Object.keys(this.api))(t.startsWith("get")||t==="onStateChange"||t==="onEvent")&&typeof this.api[t]=="function"&&(this.api[t]=()=>{throw new Error("ExcalidrawAPI is no longer usable after the editor has been unmounted and will return invalid/empty data. You should check for `ExcalidrawAPI.isDestroyed` before calling get* methods on subscribing to state/event changes.")});this.editorLifecycleEvents.emit("editor:unmount"),this.props.onUnmount?.(),this.props.onExcalidrawAPI?.(null),window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new VM,this.fonts=new Eo(this.scene),this.renderer=new Al(this.scene),this.files={},this.imageCache.clear(),this.resizeObserver?.disconnect(),this.unmounted=!0,this.viewport.destroy(),this.removeEventListeners(),this.laserTrails.stop(),this.drawShape.stop(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),this.store.onStoreIncrementEmitter.clear(),this.store.onDurableIncrementEmitter.clear(),this.appStateObserver.clear(),this.editorLifecycleEvents.clear(),wi.destroy(),gn.destroy(),clearTimeout(Dr),Le.clearCache(),Wn.clearCache(),Dr=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){if(this.removeEventListeners(),this.onRemoveEventListenersEmitter.once(ve(window,Q.MESSAGE,this.onWindowMessage,!1),ve(document,Q.POINTER_UP,this.removePointer,{passive:!1}),ve(document.fonts,"loadingdone",t=>{let o=t.fontfaces;this.fonts.onLoaded(o)},{passive:!1}),ve(window,Q.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.isInteractionEnabled()){this.isNavigationEnabled()&&this.onRemoveEventListenersEmitter.once(ve(this.excalidrawContainerRef.current,Q.WHEEL,this.handleWheel,{passive:!1}),ve(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,Q.KEYDOWN,this.handleNavigationModeKeyDown,!1),ve(document,Q.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),ve(document,Q.GESTURE_START,this.onGestureStart,!1),ve(document,Q.GESTURE_CHANGE,this.onGestureChange,!1),ve(document,Q.GESTURE_END,this.onGestureEnd,!1)),this.isBrowserZoomEnabled()||(this.isNavigationEnabled()||this.onRemoveEventListenersEmitter.once(ve(this.excalidrawContainerRef.current,Q.WHEEL,this.preventBrowserZoomWheel,{passive:!1}),ve(this.excalidrawContainerRef.current,Q.GESTURE_START,this.disableEvent,!1),ve(this.excalidrawContainerRef.current,Q.GESTURE_CHANGE,this.disableEvent,!1),ve(this.excalidrawContainerRef.current,Q.GESTURE_END,this.disableEvent,!1)),this.onRemoveEventListenersEmitter.once(ve(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,Q.KEYDOWN,this.preventBrowserZoomKeyDown,!1)));return}this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(ve(document,Q.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(ve(this.excalidrawContainerRef.current,Q.WHEEL,this.handleWheel,{passive:!1}),ve(document,Q.COPY,this.onCopy,{passive:!1}),ve(document,Q.KEYUP,this.onKeyUp,{passive:!0}),ve(document,Q.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),ve(document,Q.GESTURE_START,this.onGestureStart,!1),ve(document,Q.GESTURE_CHANGE,this.onGestureChange,!1),ve(document,Q.GESTURE_END,this.onGestureEnd,!1),ve(document,Q.PASTE,this.pasteFromClipboard,{passive:!1}),ve(this.excalidrawContainerRef.current,Q.DRAG_OVER,this.disableEvent,!1),ve(this.excalidrawContainerRef.current,Q.DROP,this.disableEvent,!1)),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(ve(document,Q.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),ve(document,Q.CUT,this.onCut,{passive:!1}),ve(window,Q.RESIZE,this.onResize,!1),ve(window,Q.UNLOAD,this.onUnload,!1),ve(window,Q.BLUR,this.onBlur,!1),ve(this.excalidrawContainerRef.current,Q.WHEEL,this.handleWheel,{passive:!1})),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(ve(uY(this.excalidrawContainerRef.current),Q.SCROLL,this.onScroll,{passive:!1})))}componentDidUpdate(t,o){!this._initialized&&!this.state.isLoading&&(this._initialized=!0,this.editorLifecycleEvents.emit("editor:initialize",this.api),this.props.onInitialize?.(this.api)),this.handleInteractionStateChange(t,o),this.handleForcedToolChange(t,o),this.ensureGifPlaybackLoop(),this.appStateObserver.flush(o),this.updateEmbeddables();let r=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted(),a=(this.sessionExportThemeOverride??this.state.theme)===mc.DARK;this.state.exportWithDarkMode!==a&&this.setState({exportWithDarkMode:a}),!this.state.showWelcomeScreen&&!r.length&&this.setState({showWelcomeScreen:!0}),(o.zoom.value!==this.state.zoom.value||o.scrollX!==this.state.scrollX||o.scrollY!==this.state.scrollY)&&(this.props?.onScrollChange?.(this.state.scrollX,this.state.scrollY,this.state.zoom),this.onScrollChangeEmitter.trigger(this.state.scrollX,this.state.scrollY,this.state.zoom)),Object.keys(this.state.selectedElementIds).length&&rn(this.state)&&this.setState({activeTool:nn(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&o.theme!==this.state.theme&&this.cursor.applyForTool(),this.state.activeTool.type==="bucketfill"&&o.currentItemBackgroundColor!==this.state.currentItemBackgroundColor&&this.cursor.applyForTool(),o.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),t.langCode!==this.props.langCode&&this.updateLanguage(),rn(o)&&!rn(this.state)&&this.eraserTrail.endPath(),(o.openDialog?.name==="elementLinkSelector"||this.state.openDialog?.name==="elementLinkSelector")&&o.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),t.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===mc.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(ut)});let s=Object.keys(this.state.selectedElementIds);if(s.length){let c=s.filter(d=>{let m=this.scene.getElement(d);return!m||m.isDeleted});c.length&&this.setState(d=>{let m={...d.selectedElementIds};for(let p of c)delete m[p];return{selectedElementIds:De(m,d)}})}if(this.state.editingTextElement){let c=this.scene.getElement(this.state.editingTextElement.id);(!c||c.isDeleted)&&this.setState({editingTextElement:null})}let l=this.state.editingTextElement||this.viewport.isAnimating?!1:!this.visibleElements.length&&this.hasRenderableElements;this.state.scrolledOutside!==l&&this.setState({scrolledOutside:l}),this.store.commit(i,this.state),this.state.isLoading||(this.props.onChange?.(r,this.state,this.files),this.onChangeEmitter.trigger(r,this.state,this.files))}static resetTapTwice(){bc=!1,yc=null}async insertClipboardContent(t,o,r){let{x:i,y:a}=Me({clientX:this.viewport.lastPosition.x,clientY:this.viewport.lastPosition.y},this.state);if(t.errorMessage){this.setState({errorMessage:t.errorMessage});return}if(o.length===0&&!r&&t.mixedContent){await this.addElementsFromMixedContentPaste(t.mixedContent,{isPlainPaste:r,sceneX:i,sceneY:a});return}if(!r&&t.text){let d=Vm(t.text);if(d.ok){this.setState({openDialog:{name:"charts",data:d.data,rawText:t.text}});return}}let s=o.map(d=>d.file);if(s.length===0&&t.text&&!r){let d=t.text.trim();d.startsWith("<svg")&&d.endsWith("</svg>")&&s.push(Pu(d))}if(s.length>0){this.isToolSupported("image")?await this.insertImages(s,i,a):this.setState({errorMessage:f("errors.imageToolNotSupported")});return}if(t.elements){let d=t.programmaticAPI?DX(t.elements):t.elements;this.addElementsFromPasteOrLibrary({elements:d,files:t.files||null,position:this.editorInterface.formFactor==="desktop"?"cursor":"center",retainSeed:r,preserveFrameChildrenOrder:!0});return}if(!t.text)return;let l=bY(t.text).split(/\n+/).map(d=>d.trim()).filter(Boolean),c=l.map(d=>ZY(d)).filter(d=>Sb(d,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(d)||ou(d)?.type==="video"));if(!r&&c.length>0&&c.length===l.length){let d=[];for(let m of c){let p=d[d.length-1],u=this.insertEmbeddableElement({sceneX:p?p.x+p.width+20:i,sceneY:a,link:Jp(m)});u&&d.push(u)}d.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(d.map(m=>[m.id,!0]))}));return}this.addTextFromPaste(t.text,r)}containsImagePaste(t,o,r){if(o.some(a=>Mi(a.file))||!r&&t.mixedContent?.some(a=>a.type==="imageUrl"))return!0;if(r||!t.text)return!1;let i=t.text.trim();return i.startsWith("<svg")&&i.endsWith("</svg>")}shouldInsertImageInViewMode({source:t,files:o,data:r,event:i}){return this.state.viewModeEnabled?this.state.viewModeOnly||this.props.viewModeImageInsertBehavior==="reject"?(this.props.onViewModeImageInsertRejected?.({source:t,files:o,data:r,event:i}),!1):(Ot(()=>{this.setState({viewModeEnabled:!1})}),!0):!0}async addElementsFromMixedContentPaste(t,{isPlainPaste:o,sceneX:r,sceneY:i}){if(!o&&t.some(a=>a.type==="imageUrl")&&this.isToolSupported("image")){let a=t.filter(d=>d.type==="imageUrl").map(d=>d.value),s=await Promise.all(a.map(async d=>{try{return{file:await Ix(d)}}catch(m){let p=m.message;return m.cause==="FETCH_ERROR"?p=f("errors.failedToFetchImage"):m.cause==="UNSUPPORTED"&&(p=f("errors.unsupportedFileType")),{errorMessage:p}}})),l=s.filter(d=>!!d.file).map(d=>d.file);await this.insertImages(l,r,i);let c=s.find(d=>!!d.errorMessage);c&&c.errorMessage&&this.setState({errorMessage:c.errorMessage})}else{let a=t.filter(s=>s.type==="text");a.length&&this.addTextFromPaste(a.map(s=>s.value).join(`
22
22
 
23
- `),o)}}addTextFromPaste(t,o=!1){let{x:r,y:i}=ke({clientX:this.viewport.lastPosition.x,clientY:this.viewport.lastPosition.y},this.state),a={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("text"),strokeStyle:this.state.currentItemStrokeStyle,roundness:null,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:t,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:cY,verticalAlign:eM,locked:!1},s=pb({fontSize:a.fontSize,fontFamily:a.fontFamily}),l=iM(a.fontFamily),[c,,d]=lX(this.state),m=Math.max(Math.min((d-c)*.5,800),200),p=10,u=i,E=o?[t]:t.split(`
24
- `),g=E.reduce((b,y,w)=>{let x=pX(y).trim();if(x.length){let I=this.getTopLayerFrameAtSceneCoords({x:r,y:u}),T=LM(x,s,l),C=T.width>m,P=C?dX(x,s,m):x;T=C?LM(P,s,l):T;let A=r-T.width/2,D=u-T.height/2,_=gM({...a,x:A,y:D,text:P,originalText:x,lineHeight:l,autoResize:!C,frameId:I?I.id:null});b.push(_),u+=_.height+p}else E[w-1]?.trim()&&(u+=_M(a.fontSize,l)+p);return b},[]);g.length!==0&&(this.insertNewElements(g),this.store.scheduleCapture(),this.setState({selectedElementIds:Ae(Object.fromEntries(g.map(b=>[b.id,!0])),this.state)}),!o&&g.length>1&&ZM===!1&&this.editorInterface.formFactor!=="phone"&&(this.setToast({message:f("toast.pasteAsSingleElement",{shortcut:N("CtrlOrCmd+Shift+V")}),duration:5e3}),ZM=!0))}handleTextWysiwyg(t,{isExistingElement:o=!1,initialCaretSceneCoords:r=null}){let i=this.scene.getElementsMapIncludingDeleted(),a=(s,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(c=>c.id===t.id&&Xt(c)?po(c,{originalText:s,isDeleted:l??c.isDeleted,...HY(c,SM(c,i),i,s)}):c)])};this.textWysiwygSubmitHandler=j2({canvas:this.canvas,getViewportCoords:(s,l)=>{let{x:c,y:d}=Kp({sceneX:s,sceneY:l},this.state);return[c-this.state.offsetLeft,d-this.state.offsetTop]},onChange:Ke(s=>{a(s,!1),eu(t)&&jp(t,this.scene)}),onSubmit:Ke(({viaKeyboard:s,nextOriginalText:l})=>{this.textWysiwygSubmitHandler=null;let c=!l.trim();a(l,c);let d=s&&!this.isToolLocked()&&this.state.activeTool.type!=="autoshape"?t.containerId||(c?null:t.id):null;d&&Ft(()=>{this.setState(m=>({selectedElementIds:Ae({...m.selectedElementIds,[d]:!0},m)}))}),c&&LY(this.scene.getNonDeletedElements(),[t]),(!c||o)&&this.store.scheduleCapture(),Ft(()=>{this.setState({newElement:null,editingTextElement:null})}),(this.isToolLocked()||this.state.activeTool.type==="autoshape")&&this.cursor.applyForTool(),this.focusContainer()}),element:t,excalidrawContainer:this.excalidrawContainerRef.current,app:this,initialCaretSceneCoords:r,autoSelect:!this.editorInterface.isTouchScreen}),this.deselectElements(),a(t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:Ae({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getSelectedTextElement(t){let o=this.scene.getSelectedElements(this.state);if(o.length!==1)return null;let r=o[0];return Xt(r)?r:t?yb(r,this.scene.getNonDeletedElementsMap()):null}getSelectedTextEditingContainerAtPosition(t,o){let r=this.scene.getSelectedElements(this.state);if(r.length!==1||!t||t.id!==r[0].id)return null;let i=r[0];if(Xt(i))return null;if(!CM(i))return;let a=this.getSelectedTextElement(i),s=this.getTextElementAtPosition(o.x,o.y);if(!(!a||s?.id!==a.id))return i}getTextElementAtPosition(t,o){let r=this.getElementAtPosition(t,o,{includeBoundTextElement:!0});return r&&Xt(r)&&!r.isDeleted?r:null}getElementAtPosition(t,o,r){let i=[];if(r&&"allHitElements"in r?i=r?.allHitElements||[]:i=this.getElementsAtPosition(t,o,{includeBoundTextElement:r?.includeBoundTextElement,includeLockedElements:r?.includeLockedElements}),i.length>1){if(r?.preferSelected){for(let s=i.length-1;s>-1;s--)if(this.state.selectedElementIds[i[s].id])return i[s]}let a=i[i.length-1];return mc({point:oe(t,o),element:a,threshold:this.getElementHitThreshold(a)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Tt(a)?this.frameNameBoundsCache.get(a):null})?a:i[i.length-2]}return i.length===1?i[0]:null}getElementsAtPosition(t,o,r){let i=[],a=this.scene.getNonDeletedElementsMap();return(r?.includeBoundTextElement&&r?.includeLockedElements?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(l=>(r?.includeLockedElements||!l.locked)&&(r?.includeBoundTextElement||!(Xt(l)&&l.containerId)))).filter(l=>this.hitElement(t,o,l)).filter(l=>{let c=Sb(l,a);return c&&!eu(c)&&console.error("[NONDELETED][INVARIANT] Containing frame is deleted"),c&&this.state.frameRendering.enabled&&this.state.frameRendering.clip&&!dc(l)?kM({x:t,y:o},c,a):!0}).filter(l=>dc(l)?(i.push(l),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(rM/this.state.zoom.value))}hitElement(t,o,r,i=!0){return i&&this.state.selectedElementIds[r.id]&&JY([r],this.state,this.editorInterface)&&kX(oe(t,o),r,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(r))||aX(oe(t,o),r,this.scene.getNonDeletedElementsMap())?!0:mc({point:oe(t,o),element:r,threshold:this.getElementHitThreshold(r),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Tt(r)?this.frameNameBoundsCache.get(r):null})}getTextBindableContainerAtPosition(t,o){let r=this.scene.getNonDeletedElements(),i=this.scene.getSelectedElements(this.state);if(i.length===1)return yM(i[0],!1)?i[0]:null;let a=null;for(let s=r.length-1;s>=0;--s){if(r[s].isDeleted)continue;let[l,c,d,m]=pM(r[s],this.scene.getNonDeletedElementsMap());if(cc(r[s])&&mc({point:oe(t,o),element:r[s],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(r[s])})){a=r[s];break}else if(l<t&&t<d&&c<o&&o<m){if(Tt(r[s]))continue;a=r[s];break}}return yM(a,!1)?a:null}isEditingTextContent(){return!!this.state.editingTextElement||Xt(this.state.newElement)}handleHoverSelectedLinearElement(t,o,r){let i=this.scene.getNonDeletedElementsMap(),a=ge.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let s=-1,l=null;mc({point:oe(o,r),element:a,elementsMap:i,threshold:this.getElementHitThreshold(a)})?(s=ge.getPointIndexUnderCursor(a,i,this.state.zoom,o,r),l=ge.getSegmentMidpointHitCoords(t,{x:o,y:r},this.state,this.scene.getNonDeletedElementsMap()),(Yt(a)?s===0||s===a.points.length-1:s>=0)||l?this.cursor.set(Me.POINTER):this.hitElement(o,r,a)&&(!Yt(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Me.MOVE)):this.hitElement(o,r,a)&&(!Yt(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Me.MOVE),this.state.selectedLinearElement.hoverPointIndex!==s&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:s}}),ge.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,l)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:l}});let c=null,d=a;(d.startBinding||d.endBinding)&&(c=_X(a,o,r,this.scene,this.state)),this.state.selectedLinearElement.hoveredFocusPointBinding!==c&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!1,hoveredFocusPointBinding:c}}),c&&this.cursor.set(Me.POINTER)}else this.cursor.set(Me.AUTO)}updateGestureOnPointerDown(t){me.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),me.pointers.size===2&&(me.lastCenter=Jg(me.pointers),me.initialScale=this.state.zoom.value,me.initialDistance=Qg(Array.from(me.pointers.values())))}initialPointerDownState(t){let o=ke(t,this.state),r=this.scene.getSelectedElements(this.state),[i,a,s,l]=ss(r),c=r.findIndex(Yt)===0;return{origin:o,withCmdOrCtrl:t[X.CTRL_OR_CMD],originInGrid:ub(Mt(o.x,o.y,t[X.CTRL_OR_CMD]||c?null:this.getEffectiveGridSize())),scrollbars:pf(gc,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...o},originalElements:this.scene.getNonDeletedElements().reduce((d,m)=>(d.set(m.id,fM(m)),d),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(s+i)/2,y:(l+a)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(o,r)},drag:{hasOccurred:!1,offset:null,origin:{...o},blockDragging:!1},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,o){if(!(o.scrollbars.isOverEither&&!this.state.multiElement))return!1;nu=!0,o.lastCoords.x=t.clientX,o.lastCoords.y=t.clientY;let r=vm(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,o)}),i=Ke(()=>{ls=null,nu=!1,this.cursor.applyForTool(),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(J.POINTER_MOVE,r),window.removeEventListener(J.POINTER_UP,i),r.flush()});return ls=i,window.addEventListener(J.POINTER_MOVE,r),window.addEventListener(J.POINTER_UP,i),!0}isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,o){if(o.length<2)return!1;let r=Math.max(rM/this.state.zoom.value,1),i=qV*2/this.state.zoom.value,[a,s,l,c]=ss(o);return t.x>a-i-r&&t.x<l+i+r&&t.y>s-i-r&&t.y<c+i+r}getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:VY(t)?Vp.ADAPTIVE_RADIUS:Vp.PROPORTIONAL_RADIUS}:null}getCurrentItemStrokeWidth(t){return AY(t,this.state.currentItemStrokeWidthKey)}maybeCacheReferenceSnapPoints(t,o,r=!1){Co({event:t,app:this,selectedElements:o})&&(r||!hn.getReferenceSnapPoints())&&hn.setReferenceSnapPoints(D2(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,o,r=!1){Co({event:t,app:this,selectedElements:o})&&(r||!hn.getVisibleGaps())&&hn.setVisibleGaps(A2(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return Ke(o=>{this.maybeHandleResize(t,o)||this.maybeDragNewGenericElement(t,o)})}onKeyUpFromPointerDownHandler(t){return Ke(o=>{o.key===X.ALT&&o.preventDefault(),!this.maybeHandleResize(t,o)&&this.maybeDragNewGenericElement(t,o)})}onPointerMoveFromPointerDownHandler(t){return vm(o=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let r=ke(o,this.state);if(this.state.activeLockedId&&this.setState({activeLockedId:null}),this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.initialState.segmentMidpoint.index){let[p,u]=Mt(r.x,r.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),E=this.state.selectedLinearElement.initialState.segmentMidpoint.index;if(E<0){let b=ge.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:p,y:u},this.state,this.scene.getNonDeletedElementsMap());E=b?ge.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,b,this.scene.getNonDeletedElementsMap()):-1}let g=ge.moveFixedSegment(this.state.selectedLinearElement,E,p,u,this.scene);this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!0,segmentMidPointHoveredCoords:g.segmentMidPointHoveredCoords,initialState:g.initialState}});return}let i=this.previousPointerMoveCoords??t.origin;if(this.previousPointerMoveCoords=r,t.drag.offset===null&&(t.drag.offset=ub(CX(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(o.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(o,t))return;if(on(this.state)){this.handleEraser(o,r);return}if(this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(r.x,r.y),this.drawShape.handlePointerMove(r))return;let[s,l]=Mt(r.x,r.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(t.resize.isResizing&&(t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeHandleCrop(t,o)||this.maybeHandleResize(t,o)))return!0;let c=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement;if(p.draggedFocusPointBinding){LX(p,c,r,this.scene,this.state,this.getEffectiveGridSize(),o.altKey),this.setState({selectedLinearElement:{...p,isDragging:!1,selectedPointsIndices:[],initialState:{...p.initialState,lastClickedPoint:-1}}});return}if(ge.shouldAddMidpoint(this.state.selectedLinearElement,r,this.state,c)){let u=ge.addMidpoint(this.state.selectedLinearElement,r,this,!o[X.CTRL_OR_CMD],this.scene);if(!u)return;Ft(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:u.pointerDownState,selectedPointsIndices:u.selectedPointsIndices,segmentMidPointHoveredCoords:null,isDragging:!0}})});return}else{if(p.initialState.segmentMidpoint.value!==null&&!p.initialState.segmentMidpoint.added)return;if(p.initialState.lastClickedPoint>-1){let u=ge.getElement(p.elementId,c);if(u?.isDeleted)return;if(uo(u)){let g=Cr(oe(r.x,r.y),this.scene.getNonDeletedElements(),c);Ro("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(u,g)}if(o.altKey&&!this.state.selectedLinearElement?.initialState?.arrowStartIsInside&&Ro("COMPLEX_BINDINGS")&&this.handleSkipBindMode(),p.initialState.lastClickedPoint===-1)return;let E=ge.handlePointDragging(o,this,r.x,r.y,p);if(E){t.lastCoords.x=r.x,t.lastCoords.y=r.y,t.drag.hasOccurred=!0,(E.suggestedBinding!==this.state.suggestedBinding||!cM(E.selectedLinearElement?.selectedPointsIndices??[],this.state.selectedLinearElement?.selectedPointsIndices??[])||E.selectedLinearElement?.hoverPointIndex!==this.state.selectedLinearElement?.hoverPointIndex||E.selectedLinearElement?.customLineAngle!==this.state.selectedLinearElement?.customLineAngle||this.state.selectedLinearElement.isDragging!==E.selectedLinearElement?.isDragging||this.state.selectedLinearElement?.initialState?.altFocusPoint!==E.selectedLinearElement?.initialState?.altFocusPoint)&&this.setState(E);return}}}}let d=t.hit.allHitElements.some(p=>this.isASelectedElement(p)),m=this.state.selectedLinearElement?.isEditing&&o.shiftKey&&this.state.selectedLinearElement.elementId===t.hit.element?.id;if((d||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!m&&!t.drag.blockDragging){let p=this.scene.getSelectedElements(this.state);if(p.length>0&&p.every(g=>g.locked))return;let E=p.some(g=>Tt(g))?null:this.getTopLayerFrameAtSceneCoords(r,{currentFrameId:PM(p),excludeElementIds:this.state.selectedElementIds});if(this.updateFrameToHighlight(E),t.drag.hasOccurred=!0,this.state.activeTool.type==="lasso"&&this.lassoTrail.hasCurrentTrail&&!(this.editorInterface.formFactor!=="desktop"&&t.hit.element)&&!this.state.activeTool.fromSelection)return;if(this.state.activeTool.type==="lasso"&&p.length>0&&t.drag.hasOccurred&&!this.state.activeTool.fromSelection&&this.lassoTrail.endPath(),p.length>0&&!t.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!=="active"){let g={x:r.x-t.drag.origin.x,y:r.y-t.drag.origin.y},b=[...t.originalElements.values()],y=o.shiftKey;if(y){let I=Math.abs(g.x),T=Math.abs(g.y),C=y&&I<T,P=y&&I>T;C&&(g.x=0),P&&(g.y=0)}if(this.state.croppingElementId){let I=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(I&&Hn(I)&&I.crop!==null&&t.hit.element===I){let T=I.crop,C=fi(I)&&this.imageCache.get(I.fileId)?.image;if(C&&!(C instanceof Promise)){let P=BX(I),A=$k(r.x-i.x,r.y-i.y);A[0]*=C.naturalWidth/P.width,A[1]*=C.naturalHeight/P.height;let[D,_,k,L,B,V]=pM(I,c),z=cb(lb(oe(D,_),oe(B,V),I.angle)),U=cb(lb(oe(k,_),oe(B,V),I.angle)),K=cb(lb(oe(D,L),oe(B,V),I.angle)),G=qk(Zk(U,z)),te=qk(Zk(K,z)),F=$k(jk(A,G),jk(A,te)),W={...T,x:oc(T.x-F[0]*Math.sign(I.scale[0]),0,C.naturalWidth-T.width),y:oc(T.y-F[1]*Math.sign(I.scale[1]),0,C.naturalHeight-T.height)};this.scene.mutateElement(I,{crop:W});return}}}this.maybeCacheVisibleGaps(o,p),this.maybeCacheReferenceSnapPoints(o,p);let{snapOffset:w,snapLines:x}=L2(b,g,this,o,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:x}),this.state.editingFrame||SX(t,p,g,this.scene,w,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),o.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let I=this.scene.getElementsIncludingDeleted(),T=t.hit.element,C=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});T&&t.hit.wasAddedToSelection&&!C.find(z=>z.id===T.id)&&C.push(T);let P=new Map(C.map(z=>[z.id,z])),{duplicatedElements:A,duplicateElementsMap:D,elementsWithDuplicates:_,origIdToDuplicateId:k}=EM({type:"in-place",elements:I,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:P,overrides:({duplicateElement:z,origElement:U})=>({frameId:z.frameId??U.frameId,seed:wY()})});A.forEach(z=>{t.originalElements.set(z.id,fM(z))});let L=_.map(z=>{if(P.has(z.id)){let U=t.originalElements.get(z.id);if(U)return po(z,{x:U.x,y:U.y})}return z}),B=this.props.onDuplicate?.(L,I),V=NM(B||L,lc(A));Ft(()=>{if(t.hit.element){let z=k.get(t.hit.element.id),U=z&&D.get(z);t.hit.element=U||null}t.hit.allHitElements=t.hit.allHitElements.reduce((z,U)=>{let K=k.get(U.id),G=K&&D.get(K);return G&&z.push(G),z},[]),t.drag.origin=ke(o,this.state),this.setState(z=>({...BM(A,this.scene.getNonDeletedElements(),z)})),this.scene.replaceAllElements(V),C.forEach(z=>{Eb(z)&&z.boundElements?.some(U=>U.type==="arrow")&&jp(z,this.scene)}),this.maybeCacheVisibleGaps(o,C,!0),this.maybeCacheReferenceSnapPoints(o,C,!0)})}return}}if(this.state.selectionElement){if(t.lastCoords.x=r.x,t.lastCoords.y=r.y,o.altKey){this.setActiveTool({type:"lasso",fromSelection:!0},{keepSelection:o.shiftKey}),this.lassoTrail.startPath(t.origin.x,t.origin.y,o.shiftKey),this.setAppState({selectionElement:null});return}this.maybeDragNewGenericElement(t,o)}else if(this.state.activeTool.type==="lasso")!o.altKey&&this.state.activeTool.fromSelection?(this.setActiveTool({type:"selection"}),this.createGenericElementOnPointerDown("selection",t),t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeDragNewGenericElement(t,o),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(r.x,r.y,o.shiftKey);else{let p=this.state.newElement;if(!p)return;if(p.type==="freedraw"){let u=p.points,E=r.x-p.x,g=r.y-p.y,b=u.length>0&&u[u.length-1];if(!(b&&b[0]===E&&b[1]===g)){let w=p.simulatePressure?p.pressures:[...p.pressures,o.pressure];this.scene.mutateElement(p,{points:[...u,oe(E,g)],pressures:w},{informMutation:!1,isDragging:!1}),this.setState({newElement:p})}}else if(Ot(p)&&!p.isDeleted){t.drag.hasOccurred=!0;let u=p.points;mo(u.length>1,"Do not create linear elements with less than 2 points");let E=this.state.selectedLinearElement;(!E||E.elementId!==p.id)&&(E=new ge(p,this.scene.getNonDeletedElementsMap())),E&&(E.initialState.lastClickedPoint<0||E.initialState.lastClickedPoint>=u.length)&&(console.warn("Last clicked point is out of bounds. Attempting to fix it."),E={...E,selectedPointsIndices:[u.length-1],initialState:{...E.initialState,prevSelectedPointsIndices:null,lastClickedPoint:u.length-1},hoverPointIndex:u.length-1}),this.setState({newElement:p,...ge.handlePointDragging(o,this,s,l,E)})}else t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeDragNewGenericElement(t,o,!1)}if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let p=this.scene.getNonDeletedElements();if(this.state.selectedLinearElement?.isEditing)ge.handleBoxSelection(o,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!o.shiftKey&&De(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(g=>Un({...g,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),g,this)):u=!1);let E=this.state.selectionElement?ex(p,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1,this.state.boxSelectionMode):[];this.setState(g=>{let b={...u&&g.selectedElementIds,...E.reduce((y,w)=>(y[w.id]=!0,y),{})};return t.hit.element&&(E.length?delete b[t.hit.element.id]:b[t.hit.element.id]=!0),g=u?g:{...g,selectedGroupIds:{},editingGroupId:null},{...Un({editingGroupId:g.editingGroupId,selectedElementIds:b},this.scene.getNonDeletedElements(),g,this),selectedLinearElement:E.length===1&&Ot(E[0])?new ge(E[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:E.length===1&&(E[0].link||No(E[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(t,o){if(o.scrollbars.isOverHorizontal){let r=t.clientX,i=r-o.lastCoords.x;return this.viewport.translate({scrollX:this.state.scrollX-i*(gc.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),o.lastCoords.x=r,!0}if(o.scrollbars.isOverVertical){let r=t.clientY,i=r-o.lastCoords.y;return this.viewport.translate({scrollY:this.state.scrollY-i*(gc.vertical?.deltaMultiplier||1)/this.state.zoom.value}),o.lastCoords.y=r,!0}return!1}onPointerUpFromPointerDownHandler(t){return Ke(o=>{let r=this.scene.getNonDeletedElementsMap();this.removePointer(o),t.drag.blockDragging=!1,t.eventListeners.onMove&&t.eventListeners.onMove.flush(),o.type==="pointerup"&&this.state.activeTool.type===Gn.bucketfill?this.bucketFill.handlePointerUp():this.bucketFill.cancel();let{newElement:i,resizingElement:a,croppingElementId:s,multiElement:l,activeTool:c,isResizing:d,isRotating:m,isCropping:p}=this.state;this.setState(x=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:sc(x.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.previousPointerMoveCoords=null,hn.setReferenceSnapPoints(null),hn.setVisibleGaps(null),this.savePointer(o.clientX,o.clientY,"up");let u=t.hit.allHitElements,E=ke({clientX:o.clientX,clientY:o.clientY},this.state);if(this.state.activeTool.type==="selection"&&!t.boxSelection.hasOccurred&&!t.resize.isResizing&&!u.some(x=>this.state.selectedElementIds[x.id])){let x=this.getElementAtPosition(E.x,E.y,{includeLockedElements:!0});this.isEditingTextContent()||this.store.scheduleCapture(),x?.locked?this.setState({activeLockedId:x.groupIds.length>0?x.groupIds.at(-1)||"":x.id}):this.setState({activeLockedId:null})}else this.setState({activeLockedId:null});if(Ro("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.setState({selectedElementsAreBeingDragged:!1,bindMode:"orbit"}),t.drag.hasOccurred&&t.hit?.element?.id){let x=r.get(t.hit.element.id);Eb(x)&&x.boundElements?.filter(I=>I.type==="arrow").map(I=>r.get(I.id)).filter(I=>Yt(I)).forEach(I=>{I&&this.scene.mutateElement(I,{})})}if(this.state.selectedLinearElement?.isEditing&&!this.state.newElement&&this.state.selectedLinearElement.draggedFocusPointBinding===null)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.selectedLinearElement.elementId&&this.state.selectedLinearElement.draggedFocusPointBinding===null)this.actionManager.executeAction(ut);else{let x=ge.handlePointerUp(o,this.state.selectedLinearElement,this.state,this.scene);this.actionManager.executeAction(ut,"ui",{event:o,sceneCoords:E}),x!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:x,suggestedBinding:null})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let x=ge.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());x&&this.scene.mutateElement(x,{})}if(this.state.selectedLinearElement.draggedFocusPointBinding?(NX(this.state.selectedLinearElement,this.scene),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,draggedFocusPointBinding:null,initialState:{...this.state.selectedLinearElement.initialState,arrowOtherEndpointInitialBinding:null}}})):t.hit?.element?.id!==this.state.selectedLinearElement.elementId?this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null}):this.state.selectedLinearElement.isDragging&&(this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!1}}),this.actionManager.executeAction(ut,"ui",{event:o,sceneCoords:E})),this.state.newElement&&this.state.multiElement&&Ot(this.state.newElement)&&this.state.selectedLinearElement){let{multiElement:x}=this.state;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:x.points[x.points.length-1]}})}}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener(J.POINTER_MOVE,t.eventListeners.onMove),window.removeEventListener(J.POINTER_UP,t.eventListeners.onUp),window.removeEventListener(J.KEYDOWN,t.eventListeners.onKeyDown),window.removeEventListener(J.KEYUP,t.eventListeners.onKeyUp),this.props?.onPointerUp?.(c,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,o),i?.type==="freedraw"){let x=ke(o,this.state),I=i.points,T=x.x-i.x,C=x.y-i.y;T===I[0][0]&&C===I[0][1]&&(C+=1e-4,T+=1e-4);let P=i.simulatePressure?[]:[...i.pressures,o.pressure];this.scene.mutateElement(i,{points:[...I,oe(T,C)],pressures:P}),this.actionManager.executeAction(ut);return}if(Ot(i)&&this.state.activeTool.type!=="autoshape"){let x=ke(o,this.state),I=so(oe(x.x,x.y),oe(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||I<vY)&&i&&!l)if(this.editorInterface.isTouchScreen){let T=Math.min(this.state.width*.7/this.state.zoom.value,100);this.scene.mutateElement(i,{x:i.x-T/2,points:[oe(0,0),oe(T,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(ut)}else this.setState({multiElement:i,newElement:i});else t.drag.hasOccurred&&!l&&(this.store.scheduleCapture(),Ot(i)&&this.actionManager.executeAction(ut,"ui",{event:o,sceneCoords:E}),this.setState({suggestedBinding:null}),this.isToolLocked()?this.setState({newElement:null}):this.setState(T=>({newElement:null,activeTool:tn(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:Ae({...T.selectedElementIds,[i.id]:!0},T),selectedLinearElement:new ge(i,this.scene.getNonDeletedElementsMap())}),()=>this.cursor.reset()),this.scene.triggerUpdate());return}if(Xt(i)){let x=gX(pb({fontSize:i.fontSize,fontFamily:i.fontFamily}),i.lineHeight);i.width<x&&this.scene.mutateElement(i,{autoResize:!0}),this.cursor.reset(),this.handleTextWysiwyg(i,{isExistingElement:!0})}if(c.type!=="selection"&&i&&vM(i)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==i.id),appState:{newElement:null},captureUpdate:Kt.NEVER});return}if(Tt(i)){let x=nX(this.scene.getElementsIncludingDeleted(),i,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(Ib(this.scene.getElementsMapIncludingDeleted(),x,i))}if(i&&(this.scene.mutateElement(i,YY(i),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let x=ke(o,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let I=this.scene.getElement(this.state.selectedLinearElement.elementId);if(I?.frameId){let T=Sb(I,r);T&&I&&(oX(I,T,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(I,{groupIds:[]}),tX([I],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let I=this.scene.getSelectedElements(this.state),T=this.getTopLayerFrameAtSceneCoords(x,{currentFrameId:PM(I),excludeElementIds:this.state.selectedElementIds}),C=this.scene.getElementsMapIncludingDeleted(),P=A=>{if(A.length>0){for(let D of A){let _=D.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(D,{groupIds:D.groupIds.slice(0,_)},{informMutation:!1,isDragging:!1})}C.forEach(D=>{D.groupIds.length&&bi(C,D.groupIds[D.groupIds.length-1]).length<2&&this.scene.mutateElement(D,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(T&&!this.state.selectedElementIds[T.id]){let A=I.filter(D=>AM(D,C,this.state));this.state.editingGroupId&&P(A),C=Ib(C,A,T)}else if(!T&&this.state.editingGroupId){let A=I.filter(D=>D.frameId&&!AM(D,C,this.state));P(A)}C=MM(C,this.state,this),this.scene.replaceAllElements(C)}}if(a&&this.store.scheduleCapture(),a&&vM(a)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==a.id),captureUpdate:Kt.NEVER}),t.resize.isResizing){let x=MM(this.scene.getElementsIncludingDeleted(),this.state,this),I=this.scene.getSelectedElements(this.state).filter(Tt);for(let T of I)x=eX(x,Tb(this.scene.getElementsIncludingDeleted(),T,this.state,r),T);this.scene.replaceAllElements(x)}let g=t.hit.element;this.state.selectedLinearElement?.elementId!==g?.id&&Ot(g)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new ge(g,this.scene.getNonDeletedElementsMap())}),(!s||s&&(!g&&!p||g&&g.id!==s))&&this.finishImageCropping();let b=this.lastPointerDownEvent,y=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(on(this.state)&&b&&y){if(this.eraserTrail.endPath(),so(oe(b.clientX,b.clientY),oe(y.clientX,y.clientY))===0){let I=ke({clientX:y.clientX,clientY:y.clientY},this.state);this.getElementsAtPosition(I.x,I.y).forEach(C=>this.elementsPendingErasure.add(C.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(g&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.selectedLinearElement?.isEditing||!t.boxSelection.hasOccurred)&&this.state.activeTool.type!=="lasso"&&(o.shiftKey&&!this.state.selectedLinearElement?.isEditing?this.state.selectedElementIds[g.id]?yX(this.state,g)?this.setState(x=>{let I={...x.selectedElementIds};for(let T of g.groupIds.flatMap(C=>bi(this.scene.getNonDeletedElements(),C)))delete I[T.id];return{selectedGroupIds:{...x.selectedElementIds,...g.groupIds.map(T=>({[T]:!1})).reduce((T,C)=>({...T,...C}),{})},selectedElementIds:Ae(I,x)}}):this.state.selectedLinearElement?.isDragging||this.setState(x=>{let I={...x.selectedElementIds};delete I[g.id];let T=ce(this.scene.getNonDeletedElements(),{selectedElementIds:I});return{...Un({editingGroupId:x.editingGroupId,selectedElementIds:I},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:T.length===1&&Ot(T[0])?new ge(T[0],this.scene.getNonDeletedElementsMap()):x.selectedLinearElement}}):g.frameId&&this.state.selectedElementIds[g.frameId]?this.setState(x=>{let I={...x.selectedElementIds,[g.id]:!0};return delete I[g.frameId],(this.scene.getElement(g.frameId)?.groupIds??[]).flatMap(T=>bi(this.scene.getNonDeletedElements(),T)).forEach(T=>{delete I[T.id]}),{...Un({editingGroupId:x.editingGroupId,selectedElementIds:I},this.scene.getNonDeletedElements(),x,this),showHyperlinkPopup:g.link||No(g)?"info":!1}}):this.setState(x=>({selectedElementIds:Ae({...x.selectedElementIds,[g.id]:!0},x)})):this.setState(x=>({...Un({editingGroupId:x.editingGroupId,selectedElementIds:{[g.id]:!0}},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:Ot(g)&&x.selectedLinearElement?.elementId!==g.id?new ge(g,this.scene.getNonDeletedElementsMap()):x.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(g&&Yt(g))&&!t.drag.hasOccurred&&!this.state.isResizing&&(g&&sX({point:oe(t.origin.x,t.origin.y),element:g,elementsMap:r,threshold:this.getElementHitThreshold(g),frameNameBound:Tt(g)?this.frameNameBoundsCache.get(g):null},r)||!g&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(ba):this.setState({selectedElementIds:Ae({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),this.cursor.set(Me.AUTO);return}let w=this.getSelectedTextEditingContainerAtPosition(g,E);if(c.type===this.state.preferredSelectionTool.type&&!this.state.editingTextElement&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&!o.shiftKey&&!o[X.CTRL_OR_CMD]&&!o.altKey&&o.pointerType!=="touch"&&g&&(Xt(g)&&this.state.selectedElementIds[g.id]&&this.scene.getSelectedElements(this.state).length===1||w)){this.startTextEditing({sceneX:E.x,sceneY:E.y,container:w,initialCaretSceneCoords:this.lastPointerUpIsDoubleClick?void 0:E});return}if(!this.isToolLocked()&&c.type!=="freedraw"&&i&&this.setState(x=>({selectedElementIds:Ae({...x.selectedElementIds,[i.id]:!0},x),showHyperlinkPopup:No(i)&&!i.link?"editor":x.showHyperlinkPopup})),!this.isEditingTextContent()&&(c.type!=="selection"||De(this.scene.getNonDeletedElements(),this.state)||!cM(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),t.drag.hasOccurred&&!this.state.selectedLinearElement||d||m||p){let x=this.scene.getSelectedElements(this.state).filter(cc);uM(x,this.scene,this.state)}if(c.type==="laser"){this.laserTrails.endPath();return}if(c.type==="autoshape"){this.actionManager.executeAction(ut);return}!this.isToolLocked()&&c.type!=="freedraw"&&c.type!==Gn.bucketfill&&(c.type!=="lasso"||c.type==="lasso"&&c.fromSelection)?this.setState({newElement:null,suggestedBinding:null,activeTool:tn(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset()):this.setState({newElement:null,suggestedBinding:null})})}clearSelection(t){this.setState(o=>({selectedElementIds:Ae({},o),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:o.editingGroupId&&t!=null&&RM(t,o.editingGroupId)?o.editingGroupId:null})),this.setState({selectedElementIds:Ae({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds,selectedLinearElement:null})}getTextWysiwygSnappedToCenterPosition(t,o,r,i){if(i){let a=i.x+i.width/2,s=i.y+i.height/2,l=wb(i,this.scene.getNonDeletedElementsMap());if(l&&(a=l.x,s=l.y),Math.hypot(t-a,o-s)<oY){let{x:m,y:p}=Kp({sceneX:a,sceneY:s},r);return{viewportX:m,viewportY:p,elementCenterX:a,elementCenterY:s}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let t=this.excalidrawContainerRef.current,{left:o,top:r}=t.getBoundingClientRect();return{offsetLeft:o,offsetTop:r}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=Pi.find(o=>o.code===this.props.langCode)||Xn;await Dc(t),this.setAppState({})}},HX=()=>{(jM()||qM())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(QM(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};HX();var n3=Lb;import{useEffect as WX,useState as VX}from"react";import{jsx as YX}from"react/jsx-runtime";var o3=e=>{let[n,t]=VX(!0);return WX(()=>{let o=async()=>{await Dc(r),t(!1)},r=Pi.find(i=>i.code===e.langCode)||Xn;o()},[e.langCode]),n?YX(sp,{theme:e.theme}):e.children};import XX from"clsx";import{jsx as r3}from"react/jsx-runtime";var i3=({children:e})=>{let{FooterCenterTunnel:n}=nt(),t=be();return r3(n.In,{children:r3("div",{className:XX("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},KX=i3;i3.displayName="FooterCenter";import $X from"clsx";import{MQ_MIN_WIDTH_DESKTOP as ZX}from"@excalidraw/common";import{jsx as qX,jsxs as JX}from"react/jsx-runtime";var a3=({isCollaborating:e,onSelect:n,editorInterface:t,...o})=>{let r=be(),i=t?.formFactor!=="desktop"||r.width<ZX;return JX(wn,{...o,className:$X("collab-button",{active:e}),type:"button",onSelect:n,style:{position:"relative",width:i?void 0:"auto"},title:f("labels.liveCollaboration"),children:[i?qx:f("labels.share"),r.collaborators.size>0&&qX("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},jX=a3;a3.displayName="LiveCollaborationTrigger";import{jsx as kr,jsxs as l3}from"react/jsx-runtime";var QX=()=>kr("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:kr("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"})}),eK=()=>l3("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[kr("path",{d:"M429.27 96.74c2.47-1.39 4.78-3.02 6.83-4.95 1.43-1.35 2.73-2.86 3.81-4.51-.66.9-1.4 1.77-2.23 2.59-2.91 2.84-5.72 5.09-8.42 6.87h.01ZM343.6 69.36c.33 3.13.58 6.27.79 9.4.09 1.37.18 2.75.25 4.12-.12-4.46-.27-8.93-.5-13.39-.11-2.08-.24-4.16-.4-6.24-.06 1.79-.11 3.85-.13 6.11h-.01ZM378.47 98.34c.01-.37.07-1.13.01-6.51-.11 1.9-.22 3.81-.31 5.71-.07 1.42-.22 2.91-.16 4.35.39.03.78.07 1.17.1-.92-.85-.76-2.01-.72-3.66l.01.01ZM344.09 86.12c-.09-2.41-.22-4.83-.39-7.24v12.21c.15-.05.32-.09.47-.14.05-1.61-.03-3.23-.09-4.83h.01ZM440.69 66.79c-.22-.34-.45-.67-.69-.99-3.71-4.87-9.91-7.14-15.65-8.55-1.05-.26-2.12-.49-3.18-.71 2.29.59 4.48 1.26 6.64 2.02 7.19 2.54 10.57 5.41 12.88 8.23ZM305.09 72.46l1.2 3.6c.84 2.53 1.67 5.06 2.46 7.61.24.78.5 1.57.73 2.36.22-.04.44-.08.67-.12a776.9 776.9 0 0 1-5.01-13.57c-.02.04-.03.09-.05.13v-.01ZM345.49 90.25v.31c1.48-.42 3.05-.83 4.66-1.2-1.56.25-3.12.52-4.66.89ZM371.02 90.22c0-.57-.04-1.14-.11-1.71-.06-.02-.12-.04-.19-.05-.21-.05-.43-.08-.65-.11.42.16.74.88.95 1.87ZM398.93 54.23c-.13 0-.27-.01-.4-.02l.03.4c.11-.15.23-.27.37-.38ZM401.57 62.28v-.15c-1.22-.24-2.86-.61-3.23-1.25-.09-.15-.18-.51-.27-.98-.09.37-.2.73-.33 1.09 1.24.56 2.52.98 3.83 1.29ZM421.73 88.68c-2.97 1.65-6.28 3.12-9.69 3.68v.18c4.72-.14 11.63-3.85 16.33-8.38-2.04 1.75-4.33 3.24-6.63 4.53l-.01-.01ZM411.28 80.92c-.05-1.2-.09-2.4-.15-3.6-.21 5.66-.46 11.38-.47 14.51.24-.02.48-.04.71-.07.15-3.61.05-7.23-.09-10.83v-.01Z",transform:"translate(-144.023 -51.76)"}),kr("path",{d:"M425.38 67.41c-3.5-1.45-7.19-2.57-14.06-3.62.09 1.97.06 4.88-.03 8.12.03.04.06.09.06.15.19 1.36.28 2.73.37 4.1.25 3.77.39 7.55.41 11.33 0 1.38-.01 2.76-.07 4.13 1.4-.25 2.78-.65 4.12-1.15 4.07-1.5 7.94-3.78 11.28-6.54 2.33-1.92 5.13-4.49 5.88-7.58.63-3.53-2.45-6.68-7.97-8.96l.01.02ZM411.35 92.53v-.06l-.34.03c.11.01.22.03.34.03ZM314.26 64.06c-.23-.59-.47-1.17-.7-1.75.57 1.62 1.11 3.25 1.6 4.9l.15.54 2.35 6.05c.32.82.66 1.64.98 2.46-1.38-4.1-2.83-8.17-4.39-12.2h.01ZM156.82 103.07c-.18.13-.38.23-.58.33 1.32-.03 2.66-.2 3.93-.34.86-.09 1.72-.22 2.58-.33-2.12.1-4.12.17-5.94.34h.01ZM210.14 68.88s.03.04.05.07c.18-.31.39-.64.58-.96-.21.3-.42.6-.64.89h.01ZM201.65 82.8c-.5.77-1.02 1.56-1.49 2.37 1.11-1.55 2.21-3.1 3.2-4.59-.23.23-.49.51-.75.79-.32.47-.65.95-.96 1.43ZM194.03 98.66c-.33-.4-.65-.84-1.05-1.17-.24-.2-.07-.49.17-.56-.23-.26-.42-.5-.63-.75 1.51-2.55 3.93-5.87 6.4-9.28-.17-.08-.29-.28-.2-.49.04-.09.09-.17.13-.26-1.21 1.78-2.42 3.55-3.61 5.33-.87 1.31-1.74 2.64-2.54 4-.29.5-.63 1.04-.87 1.61.81.65 1.63 1.27 2.47 1.88-.09-.11-.18-.21-.27-.32v.01ZM307.79 82.93c-1-3.17-2.05-6.32-3.1-9.48-1.62 4.08-3.69 9.17-6.16 15.19 3.32-1.04 6.77-1.87 10.27-2.5-.32-1.08-.67-2.15-1.01-3.21ZM149.5 80.7c.05-1.71.04-3.43 0-5.14-.1 2.26-.16 4.51-.22 6.77-.02.73-.03 1.46-.04 2.19.14-1.27.2-2.55.24-3.82h.02ZM228.98 98.3c.39 1.25.91 3.03.94 3.91.06-.03.12-.07.17-.1.08-1.29-.55-2.65-1.11-3.81ZM307.72 53.36c.81.5 1.53 1.04 2.07 1.49-.38-.8-.78-1.58-1.21-2.35-.17.03-.34.06-.51.11-.43.12-.86.26-1.29.41.35-.01.53.1.94.34ZM283.69 96.14c3.91-7.25 6.89-13.35 8.88-18.15l1.1-2.66c-1.27 2.64-2.56 5.27-3.83 7.9-1.53 3.15-3.06 6.31-4.58 9.47-.87 1.81-1.76 3.62-2.54 5.47.04.02.07.04.11.07.05.05.1.09.15.14.05-.73.27-1.48.71-2.24ZM289.92 103.23s-.04.01-.05.03c0-.02.04-.03.05-.04.05-.05.11-.1.16-.15l.21-.21c-.55 0-1.5-.27-2.55-.72.4.26.8.51 1.22.74.24.13.48.26.73.37.05.02.1.03.14.05a.27.27 0 0 1 .08-.07h.01ZM269.23 68.49c-.39-.19-.82-.48-1.33-.87-3.06-1.56-6.31-2.78-9.36-2.35-3.5.49-5.7 1.11-7.74 2.44 5.71-2.6 12.82-2.07 18.44.79l-.01-.01ZM177.87 53.69l1.06.03c-.96-.22-2-.25-2.89-.3-4.95-.26-9.99.33-14.86 1.19-2.44.43-4.88.95-7.28 1.59 9.09-1.76 15.69-2.77 23.97-2.51ZM219.85 55.51c-.18.12-.36.27-.56.45-.45.53-.86 1.11-1.26 1.66-1.91 2.61-3.71 5.31-5.57 7.95l-.12.18 8.05-10.11c-.18-.05-.36-.1-.55-.13h.01ZM510.71 54.1c.12-.15.29-.3.53-.45.69-.4 3.72-.63 5.87-.74-.36-.02-.73-.04-1.09-.05-1.84-.03-3.67.09-5.49.35.05.3.12.59.18.88v.01ZM510.76 86.02c1.37-3.07 2.49-6.27 3.57-9.46.55-1.64 1.12-3.3 1.6-4.97-1.59 4.01-3.67 9.14-6.2 15.3.24-.08.5-.14.74-.22.1-.22.19-.44.29-.65ZM566.95 75.76c.11-.02.23.03.31.11-.05-.13-.09-.26-.14-.39-.05.09-.11.18-.17.28ZM511.33 86.41c3.08-.89 6.24-1.62 9.46-2.14-1.51-3.98-2.98-7.96-4.39-11.87-.05.15-.09.31-.14.46-1.02 3.32-2.15 6.61-3.39 9.85-.48 1.25-.98 2.49-1.53 3.7h-.01ZM578.24 74.45c.11-.44.23-.87.35-1.31-.31.7-.64 1.39-.97 2.08.09.21.19.4.28.61.12-.46.23-.92.35-1.38h-.01ZM520.62 53.11c-.09 0-.18-.01-.28-.02.38.34.29 1.08.93 2.53l6.65 17.15c2.2 5.68 4.69 11.36 7.41 16.87l1.06 2.17c-2.95-7.05-5.92-14.08-8.87-21.13-1.58-3.79-3.16-7.59-4.7-11.4-.78-1.92-1.73-3.89-2.25-5.91-.03-.1 0-.19.04-.26h.01ZM578.78 77.87c1.45-5.77 3.07-10.43 3.58-13.36.05-.34.16-.88.31-1.55-.67 1.79-1.37 3.56-2.08 5.33-.12.43-.23.86-.35 1.29-.65 2.43-1.29 4.86-1.9 7.3.14.33.29.65.43 1l.01-.01ZM545.3 94.66c.02-.44.03-.83.05-1.12.02-1.01.05-2.02.11-3.02.03-6.66-.46-14.33-1.46-22.8-.13-.42-.27-1.24-.56-2.89 0-.02 0-.04-.01-.06.62 6.61.95 13.25 1.32 19.87.17 3.08.33 6.16.52 9.23.02.25.03.52.04.78l-.01.01ZM580.77 102.81c.13.2.27.38.37.49.27-.11.53-.22.8-.32-.43.09-.82.05-1.17-.16v-.01ZM530.48 104.07h.33c-.36-.13-.71-.32-1.04-.56.14.24.3.47.45.7.06-.08.14-.13.26-.13v-.01ZM542.63 58.82c.06.23.11.47.15.71.14-.33.36-.62.7-.86-.28.05-.57.11-.85.15ZM583.81 57.87c.15-.7.29-1.41.42-2.11-.14.45-.28.9-.42 1.34-.46 1.44-.89 2.89-1.31 4.34.44-1.19.88-2.37 1.31-3.57ZM523.62 91.48c-4.66 1.17-9.05 2.89-14.02 5.27 4.65-1.84 9.48-3.29 14.28-4.63-.09-.22-.17-.41-.26-.64ZM460.64 78.3c-.04-2.9-.11-5.81-.28-8.71-.1-1.68-.17-3.43-.5-5.09-.07.02-.14.03-.2.05.3 6.54.45 12.17.51 17.12.17-.07.34-.14.51-.2 0-1.06-.01-2.11-.03-3.17h-.01ZM470.63 63.24c-3.38-.26-6.81.32-10.1 1.1.41 2.01.47 4.14.57 6.18.18 3.55.25 7.11.27 10.67 3.31-1.38 6.5-3.12 9.3-5.35 1.96-1.56 3.86-3.41 5.02-5.66.73-1.41 1.19-3.22.26-4.65-1.09-1.7-3.46-2.14-5.32-2.29ZM460.29 63.68c1-.24 2.01-.46 3.04-.65-1.15.16-2.37.38-3.71.69v.13c.07-.02.15-.04.22-.05.11-.13.3-.18.45-.11v-.01ZM457.24 100.96c.43-.03.86-.07 1.29-.11.14-.49.27-.99.38-1.49-.44.7-1 1.23-1.67 1.6ZM482.88 104.98c-.18.23-.36.38-.55.47.14.09.27.19.4.28a70.76 70.76 0 0 0 4.37-4.63c.76-.89 1.52-1.81 2.19-2.77-.3-.27-.61-.53-.92-.79-.07 1.94-4.62 6.32-5.49 7.45v-.01Z",transform:"translate(-144.023 -51.76)"}),kr("path",{d:"M474.36 63.31c-.4-.16-.84-.27-1.29-.37 1.56.42 3.08 1.22 3.76 2.74.62 1.4.32 2.95-.28 4.32.7-1.22.94-2.34.74-3.47-.24-1.33-1.19-2.54-2.93-3.21v-.01ZM477.34 89.18c-1.2-.81-2.4-1.62-3.6-2.42-.14.1-.26.19-.4.29 1.4.67 2.73 1.39 4 2.13ZM465.88 93.85c.37.25.74.5 1.1.75.46.32.92.65 1.38.97-1.57-1.2-2.01-1.61-2.49-1.72h.01ZM574.92 90.06c-2.28-5.21-4.93-11.13-5.67-12.26-.1-.15-1.57-3.01-1.63-3.08 0 0-.01.02-.02.02.4 1.37 1.09 2.69 1.65 3.99 2.14 4.95 4.36 9.86 6.67 14.73.6 1.26 1.21 2.52 1.83 3.78-.75-2.01-1.64-4.45-2.83-7.18ZM448.73 65.29c.1.2.22.38.34.57.22-.02.43-.06.65-.08v-.08c-.14-.05-.25 0-.99-.41ZM460.16 94.81c-.02.31-.06.59-.1.89-.03 1.71-.33 3.43-.79 5.07.15-.02.3-.03.45-.05.01-.04.02-.08.03-.11.09-.34.15-.69.2-1.03.17-1.07.25-2.16.33-3.24.05-.69.08-1.39.12-2.08-.27.1-.27.26-.24.57v-.02Z",transform:"translate(-144.023 -51.76)"}),kr("path",{d:"m328.67 98.12-3.22-6.58c-1.29-2.63-2.53-5.29-3.72-7.97-.25-.85-.52-1.69-.79-2.53-.81-2.57-1.67-5.12-2.55-7.67-1.92-5.53-3.9-11.08-6.32-16.41-.72-1.58-1.46-3.44-2.63-4.79-.03-.17-.16-.29-.34-.36a.282.282 0 0 0-.23-.04c-.06-.01-.12 0-.18.01-.74.06-1.5.38-2.19.61-2.22.77-4.4 1.64-6.63 2.38-.03-.08-.06-.16-.09-.25-.15-.42-.82-.24-.67.19.03.09.07.19.1.28l-.18.06c-.36.11-.28.6 0 .68.18 1.18.63 2.36.98 3.49.03.09.06.17.08.26-.08.23-.17.46-.24.64-.37.98-.79 1.94-1.21 2.9-1.27 2.89-2.62 5.75-3.98 8.6-3.18 6.67-6.44 13.31-9.64 19.97-1.08 2.25-2.2 4.5-3.15 6.81-.13.32.24.5.5.37 1.34 1.33 2.84 2.5 4.4 3.57.65.44 1.31.87 2.01 1.24.4.22.86.48 1.33.5.24.01.35-.19.33-.37.11-.1.21-.21.28-.28.41-.41.81-.84 1.2-1.26.85-.92 1.69-1.87 2.5-2.84 6.31-2.34 12.6-4.31 18.71-5.84 2.14 5.3 3.43 8.43 3.97 9.58.55 1.05 1.15 1.88 1.82 2.52 1.32.56 6.96-.03 9.23-1.96.87-1.28 1.19-2.67.93-4.15-.09-.5-.22-.95-.4-1.33l-.01-.03Zm-20.09-45.61c.43.77.83 1.56 1.21 2.35-.54-.45-1.27-.99-2.07-1.49-.42-.24-.6-.35-.94-.34.43-.15.85-.29 1.29-.41.17-.05.34-.08.51-.11Zm-25.86 45.66c.78-1.85 1.67-3.66 2.54-5.47 1.51-3.16 3.05-6.31 4.58-9.47 1.28-2.63 2.56-5.26 3.83-7.9l-1.1 2.66c-1.99 4.79-4.97 10.9-8.88 18.15-.43.76-.66 1.51-.71 2.24-.05-.05-.1-.09-.15-.14a.259.259 0 0 0-.11-.07Zm6.24 4.71c-.42-.23-.82-.48-1.22-.74 1.05.45 2 .72 2.55.72l-.21.21c-.05.05-.11.1-.16.15-.01.01-.04.03-.05.04 0-.02.03-.02.05-.03a.27.27 0 0 0-.08.07c-.05-.02-.1-.03-.14-.05-.25-.1-.49-.24-.73-.37h-.01Zm15.73-29.43c1.05 3.15 2.1 6.31 3.1 9.48.34 1.06.69 2.13 1.01 3.21-3.5.63-6.95 1.46-10.27 2.5 2.48-6.03 4.54-11.11 6.16-15.19Zm4.79 12.57c-.23-.79-.49-1.58-.73-2.36-.79-2.54-1.63-5.08-2.46-7.61l-1.2-3.6c.02-.04.04-.09.05-.13 1.6 4.45 3.28 9 5.01 13.57l-.67.12v.01Zm5.83-18.27-.15-.54c-.49-1.64-1.03-3.28-1.6-4.9.23.58.47 1.17.7 1.75 1.56 4.03 3.01 8.1 4.39 12.2-.33-.82-.67-1.64-.98-2.46l-2.35-6.05h-.01ZM390.43 79.37c-.13-10.43-.22-17.5-.24-19.97-.24-1.6.21-2.88-.65-3.65-.14-.13-.32-.23-.52-.32h.03c.45 0 .45-.69 0-.7-1.75-.03-3.5-.04-5.25-.14-1.38-.08-2.76-.21-4.15-.31-.07 0-.12.01-.17.04-.21-.07-.47.03-.45.31l.03.45c-.11.14-.19.3-.22.5-.21 1.26-.32 13.67-.36 23.59-.32 5.79-.67 11.57-.97 17.36-.09 1.73-.29 3.54-.21 5.3-.39.02-.38.64.04.69v.12c.05.44.74.45.7 0v-.06c1.1.09 2.2.21 3.3.3 1.14.19 2.44.2 3.29.17 1.73-.05 2.92-.05 3.8-.37.45-.05.9-.11 1.35-.17.44-.06.25-.73-.19-.67h-.01c.24-.32.45-.72.62-1.25.66-1.84.41-6.36.34-11.33l-.13-9.9.02.01Zm-12.26 18.17c.09-1.91.2-3.81.31-5.71.06 5.38 0 6.14-.01 6.51-.05 1.65-.21 2.81.72 3.66-.39-.04-.78-.07-1.17-.1-.06-1.44.09-2.93.16-4.35l-.01-.01ZM588.97 53.85c-2.06-.25-3.17-.51-3.76-.6a.3.3 0 0 1 .04-.08c.22-.39-.39-.75-.6-.35-.56 1.02-.9 2.19-1.26 3.29-.61 1.88-1.17 3.78-1.72 5.68-.63 2.19-1.24 4.39-1.83 6.59-.81 2.03-1.67 4.05-2.61 6.03-1.7-3.64-3.11-6.04-4.03-7.57-2.26-3.74-2.85-5.48-3.57-6.08l.31-.09c.43-.12.25-.8-.19-.67-1.06.3-2.12.6-3.17.95-.93.32-1.85.69-2.76 1.07-.13.05-.19.16-.22.27-.04.02-.08.05-.11.07-.04-.06-.07-.12-.11-.18a.354.354 0 0 0-.48-.12c-.16.09-.22.32-.13.48l.33.54c0 .09.02.18.06.28.51 1.16.78 1.38.72 1.47-2.42 3.44-5.41 7.86-6.2 9.1-1.27 1.97-2.01 3.14-2.45 3.84l-.91-6.56-.43-4.1c-.19-1.85-.37-3.23-.53-4.13-.19-1.1-.3-2.15-.45-3.16-.2-1.36-.29-2.06-.47-2.42h.04c.45.02.45-.68 0-.7-3.43-.16-6.81.94-10.17 1.48-.24-.22-.73-.04-.58.32.24.59.33 1.25.43 1.87.17 1.06.29 2.13.4 3.2.32 3.09.53 6.2.74 9.3.44 6.75.77 13.51 1.17 20.26.11 1.95.13 3.96.46 5.89.05.3.37.31.55.14.74 1.71 2.87 1.27 6.13 1.27 1.34 0 2.39.04 2.99-.11.02.32.48.53.63.18 3.61-8.26 7.41-16.46 12.05-24.2.03-.05.04-.1.05-.15.3.73.64 1.45.94 2.16.97 2.26 1.97 4.52 2.98 6.76 2.26 5.03 4.54 10.07 7.09 14.96.47.9.94 1.79 1.47 2.65.2.32.4.67.66.96-.18.25 0 .68.34.54.91-.38 1.82-.75 2.76-1.07 1.04-.35 2.11-.65 3.17-.95.39-.11.28-.66-.07-.68.62-.4.95-.96.87-1.91-.3-3.34.72-7.47.86-8.52l2.14-11.43c1.75-10.74 3.13-17.51 3.23-20.86.02-.49.08-2.84.13-3.24.17-1.25.48-1-4.96-1.65l.03-.02Zm-46.19 5.67c-.04-.24-.09-.48-.15-.71l.85-.15c-.34.24-.56.53-.7.86Zm1.95 25.12c-.36-6.63-.7-13.26-1.32-19.87 0 .02 0 .04.01.06.29 1.65.44 2.47.56 2.89 1 8.46 1.5 16.14 1.46 22.8-.06.99-.1 2-.11 3.02-.01.29-.03.68-.05 1.12-.01-.26-.03-.53-.04-.78-.19-3.08-.35-6.16-.52-9.23l.01-.01Zm36.4 18.66c-.11-.11-.24-.29-.37-.49.35.21.74.26 1.17.16-.27.11-.53.22-.8.32v.01Zm-.89-33.72c.12-.43.23-.86.35-1.29.71-1.77 1.41-3.55 2.08-5.33-.15.68-.26 1.22-.31 1.55-.5 2.94-2.13 7.59-3.58 13.36-.15-.35-.29-.66-.43-1 .61-2.44 1.25-4.87 1.9-7.3l-.01.01Zm3.56-12.48c.14-.44.28-.89.42-1.34-.13.7-.27 1.41-.42 2.11-.43 1.19-.86 2.38-1.31 3.57.42-1.45.85-2.9 1.31-4.34Zm-5.22 16.05c-.11.44-.23.87-.35 1.31-.12.46-.23.92-.35 1.38-.1-.22-.19-.4-.28-.61.34-.69.66-1.38.97-2.08h.01Zm-11.64 2.62c.06-.1.12-.19.17-.28.05.13.09.26.14.39a.398.398 0 0 0-.31-.11Zm2.3 2.98c-.56-1.3-1.25-2.63-1.65-3.99 0 0 .01-.02.02-.02.06.08 1.52 2.93 1.63 3.08.73 1.13 3.38 7.04 5.67 12.26 1.2 2.73 2.08 5.17 2.83 7.18-.62-1.25-1.23-2.51-1.83-3.78-2.31-4.87-4.53-9.78-6.67-14.73ZM275.92 87.03c-1.06-2.18-1.13-3.45-2.44-2.93-1.52.57-2.94 1.3-4.5 2.1-1.4.72-2.68 1.44-3.92 2.12.01-.25-.24-.5-.51-.34-4.8 2.93-12.41 4.7-17.28 1.31-1.98-1.77-3.32-4.15-3.97-5.78-.29-.95-.49-1.94-.63-2.93-.14-3.34 1.58-6.53 3.9-9.12.8-.79 1.68-1.51 2.66-2.12 3.7-2.3 8.22-3.07 12.51-2.51 2.71.35 5.32 1.24 7.71 2.55.39.22.75-.39.35-.6-.18-.1-.37-.18-.55-.27.56.27 1.03.33 1.51.19l-.48.39c-.15.11-.23.3-.13.48.09.15.33.24.48.13 1.3-.97 2.46-2.09 3.45-3.37.37-.29.64-.6.65-.97v-.02c.08-.33-.03-.7-.21-1.08-.31-.87-.98-2.01-2.19-3.26-2.43-2.52-3.79-3.45-5.68-4.26-1.14-.49-3.12-1.06-4.42-1.23-3.28-.42-10.64-1.21-18.18 4.11-7.74 5.46-11.94 12.3-12.23 20.61-.08 2.06.04 3.98.34 5.71.74 4.18 2.57 8 5.44 11.34 4.26 4.99 9.76 7.52 16.34 7.52 4.85 0 9.69-1.77 14.89-4.62.23-.12.45-.23.68-.35 2.19-1.1 4.37-2.23 6.46-3.5.49-.3 1.03-.61 1.5-.98 1.47-.87 1.11-1.12.49-2.95-.39-1.14-.76-2.7-2.06-5.36l.02-.01Zm-17.38-21.76c3.05-.42 6.31.79 9.36 2.35.51.39.94.68 1.33.87-5.61-2.86-12.72-3.39-18.44-.79 2.05-1.33 4.24-1.95 7.74-2.44l.01.01ZM443.67 72.67c-.4-2.2-1.15-4.33-2.37-6.22-1.49-2.32-3.58-4.19-5.91-5.64-6.17-3.81-13.75-5.11-20.83-6.01-3.23-.41-6.47-.69-9.72-.92l-1.39-.12c-.85-.07-1.52-.1-2.05-.1-1.08-.06-2.17-.12-3.25-.17-.08 0-.14.02-.19.05-.1.05-.18.14-.16.3.27 2.55-.01 5.12-.92 7.52-.15.38.4.56.62.28 1.32.59 2.68 1.05 4.08 1.37 0 2.78-.14 7.58-.33 12.91 0 0 0 .02-.01.03-.61 3.66-.79 7.42-1 11.12-.23 4.01-.43 8.03-.44 12.05 0 .64 0 1.28.03 1.93.02.31 0 .68.15.96.06.11.14.16.24.17-.2.17-.21.54.11.59 3.83.67 7.78.71 11.68.25 2.3-.19 4.87-.65 7.65-1.56 1.85-.54 3.67-1.18 5.43-1.91 7.2-3.02 14.31-8.07 17.35-15.53.76-1.86 1.17-3.8 1.31-5.75.3-1.93.28-3.82-.09-5.58l.01-.02Zm-19.32-15.42c5.74 1.41 11.94 3.68 15.65 8.55.25.32.47.65.69.99-2.3-2.82-5.68-5.69-12.88-8.23-2.16-.76-4.35-1.43-6.64-2.02 1.06.21 2.13.45 3.18.71Zm-25.82-3.04c.13 0 .27.01.4.02-.14.1-.26.23-.37.38 0-.13-.02-.26-.03-.4Zm34.82 22.17c-.75 3.09-3.55 5.66-5.88 7.58-3.35 2.76-7.21 5.03-11.28 6.54-1.33.49-2.71.9-4.12 1.15.06-1.38.08-2.76.07-4.13-.02-3.78-.16-7.56-.41-11.33-.09-1.37-.18-2.74-.37-4.1 0-.06-.03-.11-.06-.15.09-3.25.12-6.16.03-8.12 6.86 1.05 10.56 2.17 14.06 3.62 5.52 2.28 8.59 5.44 7.97 8.96l-.01-.02Zm-22 16.15c-.12 0-.23-.02-.34-.03l.34-.03v.06Zm-.69-.7c0-3.13.26-8.84.47-14.51.06 1.2.11 2.41.15 3.6.15 3.6.25 7.23.09 10.83-.24.03-.48.05-.71.07v.01Zm-12.33-30.94c.37.63 2.01 1.01 3.23 1.25v.15c-1.31-.31-2.59-.73-3.83-1.29.12-.36.23-.72.33-1.09.08.48.18.84.27.98Zm13.7 31.65v-.18c3.41-.56 6.71-2.02 9.69-3.68 2.31-1.28 4.59-2.78 6.63-4.53-4.69 4.53-11.61 8.24-16.33 8.38l.01.01Zm24.07-.75c-2.05 1.93-4.37 3.56-6.83 4.95 2.7-1.78 5.52-4.03 8.42-6.87.82-.82 1.56-1.69 2.23-2.59-1.08 1.65-2.38 3.16-3.81 4.51h-.01ZM187.16 92.14c-.79-2.47-2.1-7.12-3.1-6.87-.19-.01-2.09.77-4.08 1.54-3.06 1.18-5.91 2.13-10.09 2.82-2.74.42-5.87 1.01-10.61 1.06.04-3.34.05-6.01.05-7.99 7.97-.65 12.33-2.11 16.37-3.55 1.11-.39 2.69-1.01 2.63-1.8-.08-.35-.55-1.39-1.17-2.61-.47-1.16-.98-2.31-1.61-3.38-.42-.71-1.04-1.69-1.86-2.06-.11-.08-.22-.13-.29-.12-.02 0-.04 0-.07.01-.19-.04-.39-.05-.6-.01-.17.03-.24.15-.25.28-.04.02-.09.04-.14.05-4.33 1.48-8.85 2.33-13.24 3.61a499.1 499.1 0 0 0-.31-8.19c4.51-.99 8.88-1.38 13.11-1.82 3.68-.38 6.28.12 7.47.34.59.11.9.16 1.16.18h.1c-.1.37.44.66.62.28.02-.04.03-.08.05-.13.15.2.53.22.62-.1.17-.58.19-1.21.21-1.81v-.36c.03-.15.05-.3.07-.45.52-2.47.33-5.09-.64-7.44-.11-.27-.44-.28-.6-.14-.08-.21-.15-.42-.24-.62-.19-.41-.79-.05-.6.35.03.07.05.15.09.22-.98-.42-2.15-.54-3.17-.63-2.17-.19-4.37-.14-6.54 0-5.7.35-11.4 1.3-16.91 2.79-2.08.56-4.13 1.22-6.14 2-4.54 1.05-3.79 1.51-2.17 6.07.18.51.46 1.68.54 1.94.82 2.47 1.08 2.13 3.1 2.13s0 .05 0 .08h.52c-.48 2.66-.51 5.45-.62 8.13-.15 3.48-.22 6.96-.28 10.45 0 .41-.01.82-.02 1.23-.16.29-.33.57-.51.85-.05.38-.09.77-.14 1.18-.42 3.52-.59 6.48-.52 8.8v.34c.02.47.05.76.06.87.16 1.57-.26 3.47 1.35 3.79 1.61.32 3.5.55 4.85.55.11 0 .22-.02.33-.02 1.79.24 3.67.05 5.45-.12 2.85-.28 5.69-.7 8.51-1.19 3.03-.53 6.05-1.14 9.04-1.86 2.4-.58 4.82-1.19 7.13-2.06.51-.19 1.73-.57 2.46-1.14 1.81-.68 2.18-1 1.57-2.67-.23-.62-.48-1.49-.91-2.78l-.03-.02Zm-11.12-38.71c.89.05 1.93.08 2.89.3-.33 0-.68-.02-1.06-.03-8.28-.26-14.88.75-23.97 2.51 2.41-.64 4.85-1.16 7.28-1.59 4.87-.86 9.91-1.45 14.86-1.19Zm-26.53 22.13c.03 1.71.04 3.43 0 5.14-.04 1.27-.11 2.55-.24 3.82 0-.73.02-1.46.04-2.19.05-2.26.12-4.51.22-6.77h-.02Zm6.73 27.85c.2-.1.4-.21.58-.33 1.82-.17 3.82-.24 5.94-.34-.86.11-1.72.24-2.58.33-1.27.14-2.61.31-3.93.34h-.01ZM534.48 85.44c-3.52-8.38-7.07-16.75-10.5-25.17-.63-1.54-1.25-3.09-1.86-4.65-.31-.8-.65-1.6-.87-2.43-.04-.17-.17-.24-.31-.25.1-.2 0-.51-.29-.53-1.59-.08-3.18-.22-4.78-.25-1.96-.03-3.91.13-5.84.42-.31.05-.31.38-.13.56-.03.06-.05.14-.04.22.23 1.54.63 3.06 1.16 4.53.13.35.27.7.41 1.06l-2.68 6.18c-.11.03-.2.09-.25.22-.67 1.9-1.52 3.73-2.34 5.56a536.85 536.85 0 0 1-3.9 8.45c-2.64 5.64-5.34 11.25-7.91 16.93-.44.97-.88 1.94-1.29 2.93-.2.48-.47 1-.55 1.52v.05c-.02.12.02.26.16.34 1.19.73 2.41 1.41 3.66 2.05 1.2.62 2.45 1.25 3.76 1.61.43.12.62-.55.19-.67-1.13-.31-2.2-.83-3.24-1.36 1.09.36 2.1.69 2.75.93 2.82 1.01 2.38 1.1 4.3-3.75 2.1-1.09 4.34-1.96 6.53-2.79 4.35-1.64 8.8-3.03 13.27-4.29.82 2.01 1.77 3.97 2.72 5.92.35.83.62 1.45.79 1.82.22.42.45.8.69 1.15.17.33.33.67.5 1 .42.8.84 1.63 1.4 2.35.23.29.6 0 .55-.31 1.53-.02 3.06-.07 4.58-.27.92-.12 1.82-.32 2.71-.54 1.39-.27 3.85-1.11 3.74-1.42-.67-1.96-1.55-3.87-2.34-5.78-1.57-3.78-3.16-7.56-4.75-11.33v-.01Zm-11.65-26.16c1.54 3.81 3.12 7.6 4.7 11.4 2.94 7.05 5.91 14.09 8.87 21.13l-1.06-2.17c-2.71-5.51-5.2-11.19-7.41-16.87l-6.65-17.15c-.65-1.45-.55-2.19-.93-2.53.09 0 .18.01.28.02a.29.29 0 0 0-.04.26c.52 2.02 1.47 3.98 2.25 5.91h-.01Zm-6.58 13.58c.05-.15.09-.31.14-.46 1.41 3.92 2.88 7.9 4.39 11.87-3.22.52-6.38 1.25-9.46 2.14.55-1.22 1.05-2.46 1.53-3.7 1.24-3.24 2.37-6.53 3.39-9.85h.01Zm-.23-20c.36 0 .73.03 1.09.05-2.15.1-5.18.33-5.87.74-.24.15-.41.3-.53.45-.06-.29-.13-.58-.18-.88 1.82-.26 3.65-.39 5.49-.35v-.01Zm-.09 18.72c-.49 1.67-1.05 3.33-1.6 4.97-1.07 3.19-2.19 6.38-3.57 9.46-.09.21-.19.43-.29.65-.25.07-.5.14-.74.22 2.53-6.16 4.61-11.29 6.2-15.3Zm-6.34 25.16c4.97-2.38 9.37-4.1 14.02-5.27l.26.64c-4.8 1.35-9.63 2.8-14.28 4.63Zm20.17 6.76c.33.23.68.42 1.04.56h-.33c-.12 0-.21.06-.26.13-.15-.23-.31-.45-.45-.7v.01ZM226.57 91.75c-3.55-4.74-6.68-9.11-9.31-12.99 9.2-15.25 10.05-17.81 10.35-18.38.17-.34 1.09-2.27.64-2.53-1.13-.65-1.03-.65-2.97-1.71-1.19-.65-3.04-1.61-4.53-2.12-1.71-.59-1.24-.36-3 2.77-.06.1-.11.2-.17.3-.75 1.02-1.48 2.05-2.2 3.09-1.88 2.71-3.73 5.45-5.69 8.1-3.68-4.91-6.88-8.76-9.51-11.43-.15-.15-.3-.29-.46-.42-1.27-1.28-7.24 3.53-7.93 5.58-.09.09-.19.16-.28.25-.27.26.03.64.33.58.19.65.5 1.29.94 1.91 3.85 5.06 7.19 9.76 9.94 14-1.23 2.61-3.06 5-4.67 7.38l-2.28 3.33c-.5.66-.93 1.23-1.29 1.69-.67.93-2.09 2.61-2.3 3.87-.51.85-1.16 1.84-1.29 2.83-.06.44.61.63.67.19.01-.08.04-.15.06-.22 1.36 1.08 2.76 2.11 4.19 3.11 1.3.91 2.62 1.85 4.04 2.56.21.1.4 0 .48-.17.24.07.48.14.72.2.44.1.62-.57.19-.67-2.02-.48-3.77-1.57-5.23-3.02-.47-.46-.9-.96-1.32-1.46 1.74 1.35 4.2 2.89 5.89 4.14 1.39 1.03 2.85-2.27 4.22-4.2 1.86-2.64 3.96-5.86 5.52-8.29l10.39 14.51c.67.81 1.14 1.21 1.57 1.36-.05.24.12.51.41.4 1.53-.58 3.05-1.19 4.54-1.87 1.52-.69 3.06-1.45 4.36-2.5a.28.28 0 0 0 .12-.23c1.66-1.1.81-1.74-1.41-4.91-1.13-1.58-1.71-2.36-3.7-5.01l-.03-.02Zm2.41 6.54c.56 1.15 1.19 2.52 1.11 3.81-.06.04-.12.07-.17.1-.03-.88-.55-2.66-.94-3.91Zm-16.51-32.73c1.86-2.65 3.65-5.35 5.57-7.95.4-.55.81-1.13 1.26-1.66.19-.18.38-.33.56-.45.18.03.36.08.55.13l-8.05 10.11.12-.18h-.01ZM192.7 95.48c.79-1.37 1.66-2.69 2.54-4 1.19-1.79 2.4-3.56 3.61-5.33-.04.09-.09.17-.13.26-.1.22.03.41.2.49-2.47 3.42-4.89 6.73-6.4 9.28.21.24.4.48.63.75-.24.07-.4.36-.17.56.4.33.72.77 1.05 1.17.09.11.18.21.27.32-.84-.61-1.66-1.24-2.47-1.88.24-.57.58-1.11.87-1.61v-.01Zm7.46-10.32c.47-.81.98-1.59 1.49-2.37.31-.48.64-.95.96-1.43.26-.29.52-.56.75-.79-.99 1.48-2.09 3.03-3.2 4.59Zm10.03-16.22s-.03-.05-.05-.07c.22-.29.43-.59.64-.89-.2.32-.4.65-.58.96h-.01ZM371.54 87.96c-.01-.08-.01-.16-.03-.23-.06-.38-.58-.29-.66.03-.3-.05-.6-.08-.81-.11-1.14-.15-2.29-.19-3.44-.2 1.04-.09 2.09-.18 3.14-.23.45-.02.45-.72 0-.7-6.57.35-13.14 1.23-19.65 2.11-1.53.21-3.05.42-4.57.68-.01 0-.02.01-.04.01-.04-3.33-.13-6.66-.24-9.99-.19-5.7-.4-11.41-.88-17.1-.13-1.51-.23-3.07-.49-4.58 0-.25 0-.48-.02-.68-.06-1.19-.04-2.61-.68-2.78-.16-.07-.72-.16-1.5-.24.22-.17.16-.62-.2-.63-1.19-.04-2.39.09-3.57.23-1.2.14-2.41.32-3.59.6-.16-.1-.41-.06-.5.12-.06.02-.13.03-.19.05-.35.1-.29.55-.03.66-.26.6-.19 2.27-.21 3-.02.66-.66 33.73-.9 40.3-.03.65.06 1.12.04 1.45-.16 3.05.87 4.96 6.34 3.93 1.09-.08 2.75-.77 5.36-1.43 4.13-1.04 5.78-1.52 6.2-1.65 6.43-1.69 6.78-1.97 11.72-2.43.55-.05 4.8-.38 6.03-.3.64.04 1.19.07 1.65.1.09 0 .16-.03.24-.05.1.27.56.33.66-.02.39-1.32.61-2.71.78-4.08.2-1.61.29-3.24.15-4.86.24.03.52-.23.38-.53-.09-.2-.27-.33-.49-.43v-.02Zm-.63.56c.07.57.11 1.14.11 1.71-.21-.99-.53-1.71-.95-1.87.22.03.44.06.65.11.06.01.12.04.19.05Zm-25.41 1.73c1.54-.36 3.1-.64 4.66-.89-1.61.37-3.18.77-4.66 1.2v-.31Zm-.86-7.37c-.07-1.37-.16-2.75-.25-4.12-.21-3.13-.45-6.27-.79-9.4.02-2.25.08-4.31.13-6.11.16 2.08.29 4.16.4 6.24.23 4.46.38 8.93.5 13.39h.01Zm-.94-4c.16 2.41.29 4.83.39 7.24.06 1.6.14 3.22.09 4.83-.15.05-.32.09-.47.14V78.88h-.01ZM483.72 92.83c-3.05-2.28-6.22-4.4-9.38-6.51 8.86-6.49 13.49-12.95 13.73-19.23.04-.76 0-1.5-.13-2.2-.67-3.82-3.5-6.68-8.39-8.48.13.04.27.08.4.13 3.92 1.39 7.74 4.23 8.5 8.56.34 1.95-.05 3.96-.98 5.69-.21.4.39.75.6.35 1.86-3.46 1.46-7.55-.97-10.63-3.53-4.47-9.76-5.88-15.16-6.16-2.32-.12-4.64-.04-6.95.19-6 .32-12.71 1.68-17.63 3.21-.37.11-.67.23-.92.35-.2-.17-.62.02-.57.37v.03c-.64.68-.18 1.64.48 3.21.38.91.67 1.89 1.15 2.58.32.76.68 1.51 1.13 2.19.14.21.38.19.53.07.19-.02.38-.05.57-.08v1.57c-.06.06-.1.13-.11.23-.27 4.18-.34 8.38-.48 12.57l-.3 9.03c-.24 3.91-.44 6.77-.46 7.26-.05.88-.11 1.95.07 2.81-.01.22-.02.43-.04.65 0 .11-.02.23-.03.35 0 .05-.03.27-.01.16-.05.4.5.59.64.28.05.04.12.08.2.08 1.75.13 3.5.28 5.25.3 1.69.02 3.38-.12 5.06-.32.08.23.36.39.55.15.06-.08.11-.17.16-.26.18-.09.24-.32.18-.48.05-.2.1-.4.13-.6.16-.86.25-1.74.33-2.62.11-1.17.17-2.34.23-3.51.15-.01.32-.03.52-.04.36-.03 1.73-.15 2.06-.15.39 0 .7-.02.95-.04 1.76 1.11 3.45 2.35 5.14 3.55 2.83 2.01 5.64 4.04 8.47 6.04 1.42 1 2.85 2 4.29 2.97.1.06.19.07.27.04.08 0 .17-.02.25-.1 1.61-1.56 3.15-3.18 4.6-4.88.75-.88 1.49-1.78 2.15-2.73.01.01.03.02.04.03.34.3.83-.2.49-.49-2.16-1.9-4.34-3.76-6.64-5.48l.03-.01Zm-6.38-3.65a55.72 55.72 0 0 0-4-2.13c.14-.1.26-.19.4-.29 1.2.81 2.4 1.61 3.6 2.42Zm-20.1 11.78c.67-.37 1.23-.91 1.67-1.6-.11.5-.24 1-.38 1.49-.43.04-.86.08-1.29.11Zm2.38-37.24c1.34-.31 2.56-.52 3.71-.69-1.03.19-2.04.41-3.04.65-.14-.07-.34-.02-.45.11-.07.02-.15.04-.22.05v-.13.01Zm.04.84c.07-.02.14-.03.2-.05.34 1.66.41 3.41.5 5.09.17 2.9.24 5.81.28 8.71l.03 3.17c-.17.07-.34.14-.51.2-.06-4.96-.21-10.58-.51-17.12h.01Zm16.04 5.62c-1.16 2.25-3.06 4.1-5.02 5.66-2.8 2.23-5.99 3.97-9.3 5.35-.01-3.56-.09-7.12-.27-10.67-.1-2.04-.16-4.16-.57-6.18 3.3-.78 6.72-1.36 10.1-1.1 1.85.14 4.23.59 5.32 2.29.92 1.43.46 3.24-.26 4.65Zm.85-.18c.6-1.37.9-2.92.28-4.32-.67-1.52-2.2-2.32-3.76-2.74.46.1.89.21 1.29.37 1.74.67 2.69 1.88 2.93 3.21.2 1.13-.05 2.25-.74 3.47V70Zm-27.47-4.14c-.12-.19-.23-.38-.34-.57.74.42.85.36.99.41v.08c-.22.03-.43.06-.65.08Zm11.21 30.46c-.08 1.08-.16 2.17-.33 3.24-.05.35-.11.69-.2 1.03 0 .04-.02.07-.03.11-.15.02-.3.04-.45.05.45-1.64.76-3.36.79-5.07.03-.29.08-.57.1-.89-.03-.31-.03-.47.24-.57-.04.69-.07 1.39-.12 2.08v.02Zm5.6-2.47c.48.11.92.52 2.49 1.72-.46-.32-.92-.65-1.38-.97-.37-.25-.73-.5-1.1-.75h-.01Zm21.23 7.24a70.76 70.76 0 0 1-4.37 4.63c-.14-.09-.27-.19-.4-.28.19-.09.37-.24.55-.47.87-1.14 5.43-5.51 5.49-7.45.31.26.62.53.92.79-.67.97-1.42 1.88-2.19 2.77v.01Z",fill:"currentColor",transform:"translate(-144.023 -51.76)"})]}),s3=({style:e,size:n="small",withText:t})=>l3("div",{className:`ExcalidrawLogo is-${n}`,style:e,children:[kr(QX,{}),t&&kr(eK,{})]});import{Fragment as m3,jsx as st,jsxs as zb}from"react/jsx-runtime";var Gb=({icon:e,shortcut:n,children:t})=>{let o=Ee();return zb(m3,{children:[st("div",{className:"welcome-screen-menu-item__icon",children:e}),st("div",{className:"welcome-screen-menu-item__text",children:t}),n&&o.formFactor!=="phone"&&st("div",{className:"welcome-screen-menu-item__shortcut",children:n})]})};Gb.displayName="WelcomeScreenMenuItemContent";var Ec=({onSelect:e,children:n,icon:t,shortcut:o,className:r="",...i})=>st("button",{...i,type:"button",className:`welcome-screen-menu-item ${r}`,onClick:e,children:st(Gb,{icon:t,shortcut:o,children:n})});Ec.displayName="WelcomeScreenMenuItem";var c3=({children:e,href:n,icon:t,shortcut:o,className:r="",...i})=>st("a",{...i,className:`welcome-screen-menu-item ${r}`,href:n,target:"_blank",rel:"noopener",children:st(Gb,{icon:t,shortcut:o,children:e})});c3.displayName="WelcomeScreenMenuItemLink";var In=({children:e})=>{let{WelcomeScreenCenterTunnel:n}=nt();return st(n.In,{children:st("div",{className:"welcome-screen-center",children:e||zb(m3,{children:[st(Hb,{}),st(Ub,{children:f("welcomeScreen.defaults.center_heading")}),zb(Wb,{children:[st(Yb,{}),st(Vb,{})]})]})})})};In.displayName="Center";var Hb=({children:e})=>st("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||st(s3,{withText:!0})});Hb.displayName="Logo";var Ub=({children:e})=>st("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});Ub.displayName="Heading";var Wb=({children:e})=>st("div",{className:"welcome-screen-menu",children:e});Wb.displayName="Menu";var Vb=()=>{let e=ot();return st(Ec,{onSelect:()=>e.executeAction(Kr),shortcut:"?",icon:Li,children:f("helpDialog.title")})};Vb.displayName="MenuItemHelp";var Yb=()=>{let e=be(),n=ot();return e.viewModeEnabled?null:st(Ec,{onSelect:()=>n.executeAction(ea),shortcut:Ze("loadScene"),icon:Bc,children:f("buttons.load")})};Yb.displayName="MenuItemLoadScene";var d3=({onSelect:e})=>{let{t:n}=Le();return st(Ec,{shortcut:null,onSelect:e,icon:Fc,children:n("labels.liveCollaboration")})};d3.displayName="MenuItemLiveCollaborationTrigger";In.Logo=Hb;In.Heading=Ub;In.Menu=Wb;In.MenuItem=Ec;In.MenuItemLink=c3;In.MenuItemHelp=Vb;In.MenuItemLoadScene=Yb;In.MenuItemLiveCollaborationTrigger=d3;import{jsx as ds,jsxs as Xb}from"react/jsx-runtime";var su=({children:e})=>{let{WelcomeScreenMenuHintTunnel:n}=nt();return ds(n.In,{children:Xb("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[_x,ds("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.menuHint")})]})})};su.displayName="MenuHint";var lu=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:n}=nt();return ds(n.In,{children:Xb("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[ds("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.toolbarHint")}),Nx]})})};lu.displayName="ToolbarHint";var cu=({children:e})=>{let{WelcomeScreenHelpHintTunnel:n}=nt();return ds(n.In,{children:Xb("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[ds("div",{children:e||f("welcomeScreen.defaults.helpHint")}),Rx]})})};cu.displayName="HelpHint";import{Fragment as p3,jsx as bc,jsxs as nK}from"react/jsx-runtime";var du=e=>bc(p3,{children:e.children||nK(p3,{children:[bc(In,{}),bc(su,{}),bc(lu,{}),bc(cu,{})]})});du.displayName="WelcomeScreen";du.Center=In;du.Hints={MenuHint:su,ToolbarHint:lu,HelpHint:cu};var tK=du;var oK=()=>{Array.prototype.at||Object.defineProperty(Array.prototype,"at",{value:function(e){if(e=Math.trunc(e)||0,e<0&&(e+=this.length),!(e<0||e>=this.length))return this[e]},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.findLast||Object.defineProperty(Array.prototype,"findLast",{value:function(e,n){return this.slice().reverse().find((t,o)=>e.call(n,t,this.length-o-1,this))},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.findIndex||Object.defineProperty(Array.prototype,"findIndex",{value:function(e,n){for(let t=0;t<this.length;t++)if(e.call(n,this[t],t,this))return t;return-1},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.findLastIndex||Object.defineProperty(Array.prototype,"findLastIndex",{value:function(e,n){let t=this.slice().reverse().findIndex((o,r)=>e.call(n,o,this.length-r-1,this));return t===-1?-1:this.length-t-1},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.toReversed||Object.defineProperty(Array.prototype,"toReversed",{value:function(){return this.slice().reverse()},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.toSorted||Object.defineProperty(Array.prototype,"toSorted",{value:function(e){return this.slice().sort(e)},writable:!0,enumerable:!1,configurable:!0}),Element.prototype.replaceChildren||(Element.prototype.replaceChildren=function(...e){this.innerHTML="",this.append(...e)})},u3=oK;import{getSceneVersion as qVe,hashElementsVersion as JVe,hashString as QVe,getNonDeletedElements as eYe}from"@excalidraw/element";import{getTextFromElements as nYe}from"@excalidraw/element";import{isInvisiblySmallElement as rYe}from"@excalidraw/element";import rK from"lodash.throttle";import{arrayToMap as iK,isDevEnv as h3,isTestEnv as g3}from"@excalidraw/common";import{orderByFractionalIndex as aK,syncInvalidIndices as f3,validateFractionalIndices as sK}from"@excalidraw/element";var lK=(e,n,t)=>!!(n&&(n.id===e.editingTextElement?.id||n.id===e.resizingElement?.id||n.id===e.newElement?.id||n.version>t.version||n.version===t.version&&n.versionNonce<=t.versionNonce)),cK=rK((e,n,t)=>{if(h3()||g3()||window?.DEBUG_FRACTIONAL_INDICES){let o=f3(e.map(r=>({...r})));sK(o,{shouldThrow:g3()||h3(),includeBoundTextValidation:!0,reconciliationContext:{localElements:n,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),dK=(e,n,t)=>{let o=iK(e),r=[],i=new Set;for(let s of n)if(!i.has(s.id)){let l=o.get(s.id),c=lK(t,l,s);l&&c?(r.push(l),i.add(l.id)):(r.push(s),i.add(s.id))}for(let s of e)i.has(s.id)||(r.push(s),i.add(s.id));let a=aK(r);return cK(a,e,n),f3(a),a};import{isLinearElement as hYe}from"@excalidraw/element";import{FONT_FAMILY as fYe,THEME as EYe,MIME_TYPES as bYe,ROUNDNESS as xYe,DEFAULT_LASER_COLOR as yYe,UserIdleState as wYe,normalizeLink as vYe,sceneCoordsToViewportCoords as IYe,viewportCoordsToSceneCoords as TYe,getFormFactor as SYe,throttleRAF as CYe}from"@excalidraw/common";import{mutateElement as kYe,newElementWith as MYe,bumpVersion as AYe}from"@excalidraw/element";import{CaptureUpdateAction as LYe}from"@excalidraw/element";import{getCommonBounds as HYe,getVisibleSceneBounds as UYe,convertToExcalidrawElements as WYe}from"@excalidraw/element";import{elementsOverlappingBBox as YYe}from"@excalidraw/element";import{isElementLink as $Ye}from"@excalidraw/element";import{setCustomTextMetricsProvider as qYe}from"@excalidraw/element";import{jsx as xc}from"react/jsx-runtime";u3();var XVe=({children:e})=>{let[n,t]=fK(null);return xc(cs.Provider,{value:n,children:xc(au.Provider,{value:t,children:e})})},bK=e=>{let{onExport:n,className:t,onChange:o,onThemeChange:r,onIncrement:i,initialData:a,initialState:s,onExcalidrawAPI:l,onMount:c,onUnmount:d,onInitialize:m,isCollaborating:p=!1,onPointerUpdate:u,renderTopLeftUI:E,renderTopRightUI:g,langCode:b=Xn.code,viewModeEnabled:y,viewModeOnly:w,interaction:x,ui:I,activeTool:T,gridModeEnabled:C,theme:P,renderCustomizations:A,name:D,renderCustomStats:_,editorPreferences:k,onEditorPreferencesChange:L,onPaste:B,viewModeImageInsertBehavior:V,onViewModeImageInsertRejected:z,detectScroll:U=!0,handleKeyboardGlobally:K=!1,autoFocus:G=!1,compressImageFile:te,generateIdForFile:F,onLinkOpen:W,generateLinkForSelection:le,onPointerDown:we,onPointerUp:de,onScrollChange:he,onUserFollow:ve,userToFollow:ae,onDuplicate:fe,imageContextMenuItems:rt,children:Ge,validateEmbeddable:Pe,renderEmbeddable:Wn,showDeprecatedFonts:zo,wheelZoomsOnDefault:xi,strokeColorTopPicks:re,backgroundColorTopPicks:lt,renderScrollbars:$t,viewportStatusFrame:Sn,currentUserControls:nn,imageOptions:yi,showDropEventDebugAlert:b3}=e,mu=e.UIOptions?.canvasActions,yc={...e.UIOptions,canvasActions:{...E3.canvasActions,...mu},tools:{image:e.UIOptions?.tools?.image??!0}};mu?.export&&(yc.canvasActions.export.saveFileToDisk=mu.export?.saveFileToDisk??E3.canvasActions.export.saveFileToDisk),yc.canvasActions.toggleTheme===null&&(P==null||r)&&(yc.canvasActions.toggleTheme=!0);let x3={maxFileSizeBytes:yi?.maxFileSizeBytes??Tn.maxFileSizeBytes,maxWidthOrHeight:yi?.maxWidthOrHeight??Tn.maxWidthOrHeight,gifAutoDecodeMaxFileSizeBytes:yi?.gifAutoDecodeMaxFileSizeBytes??Tn.gifAutoDecodeMaxFileSizeBytes,placeholderTransitionDuration:yi?.placeholderTransitionDuration??Tn.placeholderTransitionDuration},Kb=uK(au),$b=gK(l);$b.current=l;let y3=pK(pu=>{Kb?.(pu),$b.current?.(pu)},[Kb]),Zb=typeof x=="object"&&x!==null&&x.enabled?.browserZoom===!0&&x.enabled?.navigation!==!0;return hK(()=>{if((async()=>{await import("canvas-roundrect-polyfill")})(),Zb)return;let jb=uu=>{typeof uu.scale=="number"&&uu.scale!==1&&uu.preventDefault()};return document.addEventListener("touchmove",jb,{passive:!1}),()=>{document.removeEventListener("touchmove",jb)}},[Zb]),xc(Sx,{store:Et,children:xc(o3,{langCode:b,theme:P,children:xc(n3,{onExport:n,className:t,onChange:o,onThemeChange:r,onIncrement:i,initialData:a,initialState:s,onExcalidrawAPI:y3,onMount:c,onUnmount:d,onInitialize:m,isCollaborating:p,onPointerUpdate:u,renderTopLeftUI:E,renderTopRightUI:g,langCode:b,viewModeEnabled:y,viewModeOnly:w,interaction:x,ui:I,activeTool:T,gridModeEnabled:C,theme:P,renderCustomizations:A,name:D,renderCustomStats:_,editorPreferences:k,onEditorPreferencesChange:L,UIOptions:yc,onPaste:B,viewModeImageInsertBehavior:V,onViewModeImageInsertRejected:z,detectScroll:U,handleKeyboardGlobally:K,autoFocus:G,compressImageFile:te,generateIdForFile:F,onLinkOpen:W,generateLinkForSelection:le,onPointerDown:we,onPointerUp:de,onScrollChange:he,onUserFollow:ve,userToFollow:ae,onDuplicate:fe,imageContextMenuItems:rt,validateEmbeddable:Pe,renderEmbeddable:Wn,showDeprecatedFonts:zo,wheelZoomsOnDefault:xi,strokeColorTopPicks:re,backgroundColorTopPicks:lt,renderScrollbars:$t,viewportStatusFrame:Sn,currentUserControls:nn,imageOptions:x3,showDropEventDebugAlert:b3,children:Ge})})})},xK=(e,n)=>{if(e.children!==n.children)return!1;let{initialData:t,UIOptions:o={},imageOptions:r,interaction:i,ui:a,activeTool:s,...l}=e,{initialData:c,UIOptions:d={},imageOptions:m,interaction:p,ui:u,activeTool:E,...g}=n;if(!(s===E||s?.type===E?.type&&(s?.type==="custom"?s.customType:null)===(E?.type==="custom"?E.customType:null))||!(i===p||typeof i=="object"&&i!==null&&typeof p=="object"&&p!==null&&!!i.enabled?.links==!!p.enabled?.links&&!!i.enabled?.embeds==!!p.enabled?.embeds&&!!i.enabled?.interactiveContent==!!p.enabled?.interactiveContent&&!!i.enabled?.navigation==!!p.enabled?.navigation&&!!i.enabled?.browserZoom==!!p.enabled?.browserZoom&&!!i.enabled?.tools?.laser==!!p.enabled?.tools?.laser&&!!i.enabled?.tools?.custom==!!p.enabled?.tools?.custom)||!(a===u||typeof a=="object"&&a!==null&&typeof u=="object"&&u!==null&&!!a.enabled?.zoom==!!u.enabled?.zoom&&!!a.enabled?.scrollBackToContent==!!u.enabled?.scrollBackToContent))return!1;let x=Object.keys(o),I=Object.keys(d);if(x.length!==I.length)return!1;let T=x.every(P=>P==="getFormFactor"?!0:P==="canvasActions"?Object.keys(o.canvasActions).every(D=>D==="export"&&o?.canvasActions?.export&&d?.canvasActions?.export?o.canvasActions.export.saveFileToDisk===d.canvasActions.export.saveFileToDisk:o?.canvasActions?.[D]===d?.canvasActions?.[D]):o[P]===d[P]),C=(r?.maxWidthOrHeight??Tn.maxWidthOrHeight)===(m?.maxWidthOrHeight??Tn.maxWidthOrHeight)&&(r?.maxFileSizeBytes??Tn.maxFileSizeBytes)===(m?.maxFileSizeBytes??Tn.maxFileSizeBytes)&&(r?.gifAutoDecodeMaxFileSizeBytes??Tn.gifAutoDecodeMaxFileSizeBytes)===(m?.gifAutoDecodeMaxFileSizeBytes??Tn.gifAutoDecodeMaxFileSizeBytes)&&(r?.placeholderTransitionDuration??Tn.placeholderTransitionDuration)===(m?.placeholderTransitionDuration??Tn.placeholderTransitionDuration);return T&&C&&EK(l,g)},yK=mK.memo(bK,xK);yK.displayName="Excalidraw";function KVe(e){return Ki(e,!1)}export{wn as Button,LYe as CaptureUpdateAction,yYe as DEFAULT_LASER_COLOR,gu as DEFAULT_OVERSCROLL,tb as DefaultSidebar,Ns as Ellipsify,yK as Excalidraw,cs as ExcalidrawAPIContext,XVe as ExcalidrawAPIProvider,fYe as FONT_FAMILY,go as Fonts,KX as Footer,jX as LiveCollaborationTrigger,bYe as MIME_TYPES,Bt as MainMenu,xYe as ROUNDNESS,Ir as Sidebar,Zl as Stats,EYe as THEME,Eu as UnsupportedImageFileTypeError,wYe as UserIdleState,tK as WelcomeScreen,DVe as applyDarkModeFilter,AYe as bumpVersion,Yh as captureDragEventData,WYe as convertToExcalidrawElements,Xn as defaultLang,YYe as elementsOverlappingBBox,lP as exportToBlob,Cp as exportToCanvas,$G as exportToClipboard,cP as exportToSvg,HYe as getCommonBounds,kc as getDataURL,SYe as getFormFactor,eYe as getNonDeletedElements,qVe as getSceneVersion,LVe as getStrokeWidthByKey,nYe as getTextFromElements,UYe as getVisibleSceneBounds,JVe as hashElementsVersion,QVe as hashString,$Ye as isElementLink,rYe as isInvisiblySmallElement,hYe as isLinearElement,Aa as isSpreadsheetValidForChartType,Pi as languages,fs as loadFromBlob,kYe as mutateElement,MYe as newElementWith,vYe as normalizeLink,Wr as parseDataTransferEvent,Wd as parseDragImageMetadata,dK as reconcileElements,Cf as renderSpreadsheet,Ti as restoreAppState,v3 as restoreElement,Dr as restoreElements,IYe as sceneCoordsToViewportCoords,us as serializeAsJSON,qYe as setCustomTextMetricsProvider,CYe as throttleRAF,Om as tryParseSpreadsheet,Ee as useEditorInterface,Id as useExcalidrawAPI,KVe as useExcalidrawStateValue,Le as useI18n,L6 as useOnExcalidrawStateChange,ct as useStylesPanelMode,TYe as viewportCoordsToSceneCoords,Mr as zoomToFitBounds};
23
+ `),o)}}addTextFromPaste(t,o=!1){let{x:r,y:i}=Me({clientX:this.viewport.lastPosition.x,clientY:this.viewport.lastPosition.y},this.state),a={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("text"),strokeStyle:this.state.currentItemStrokeStyle,roundness:null,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:t,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:cY,verticalAlign:oM,locked:!1},s=xb({fontSize:a.fontSize,fontFamily:a.fontFamily}),l=lM(a.fontFamily),[c,,d]=lX(this.state),m=Math.max(Math.min((d-c)*.5,800),200),p=10,u=i,E=o?[t]:t.split(`
24
+ `),g=E.reduce((b,w,y)=>{let x=pX(w).trim();if(x.length){let I=this.getTopLayerFrameAtSceneCoords({x:r,y:u}),T=NM(x,s,l),C=T.width>m,P=C?dX(x,s,m):x;T=C?NM(P,s,l):T;let M=r-T.width/2,D=u-T.height/2,_=bM({...a,x:M,y:D,text:P,originalText:x,lineHeight:l,autoResize:!C,frameId:I?I.id:null});b.push(_),u+=_.height+p}else E[y-1]?.trim()&&(u+=BM(a.fontSize,l)+p);return b},[]);g.length!==0&&(this.insertNewElements(g),this.store.scheduleCapture(),this.setState({selectedElementIds:De(Object.fromEntries(g.map(b=>[b.id,!0])),this.state)}),!o&&g.length>1&&JM===!1&&this.editorInterface.formFactor!=="phone"&&(this.setToast({message:f("toast.pasteAsSingleElement",{shortcut:N("CtrlOrCmd+Shift+V")}),duration:5e3}),JM=!0))}handleTextWysiwyg(t,{isExistingElement:o=!1,initialCaretSceneCoords:r=null}){let i=this.scene.getElementsMapIncludingDeleted(),a=(s,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(c=>c.id===t.id&&Kt(c)?po(c,{originalText:s,isDeleted:l??c.isDeleted,...HY(c,kM(c,i),i,s)}):c)])};this.textWysiwygSubmitHandler=eI({canvas:this.canvas,getViewportCoords:(s,l)=>{let{x:c,y:d}=Qp({sceneX:s,sceneY:l},this.state);return[c-this.state.offsetLeft,d-this.state.offsetTop]},onChange:Ke(s=>{a(s,!1),au(t)&&nu(t,this.scene)}),onSubmit:Ke(({viaKeyboard:s,nextOriginalText:l})=>{this.textWysiwygSubmitHandler=null;let c=!l.trim();a(l,c);let d=s&&!this.isToolLocked()&&this.state.activeTool.type!=="autoshape"?t.containerId||(c?null:t.id):null;d&&Ot(()=>{this.setState(m=>({selectedElementIds:De({...m.selectedElementIds,[d]:!0},m)}))}),c&&LY(this.scene.getNonDeletedElements(),[t]),(!c||o)&&this.store.scheduleCapture(),Ot(()=>{this.setState({newElement:null,editingTextElement:null})}),(this.isToolLocked()||this.state.activeTool.type==="autoshape")&&this.cursor.applyForTool(),this.focusContainer()}),element:t,excalidrawContainer:this.excalidrawContainerRef.current,app:this,initialCaretSceneCoords:r,autoSelect:!this.editorInterface.isTouchScreen}),this.deselectElements(),a(t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:De({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getSelectedTextElement(t){let o=this.scene.getSelectedElements(this.state);if(o.length!==1)return null;let r=o[0];return Kt(r)?r:t?Pb(r,this.scene.getNonDeletedElementsMap()):null}getSelectedTextEditingContainerAtPosition(t,o){let r=this.scene.getSelectedElements(this.state);if(r.length!==1||!t||t.id!==r[0].id)return null;let i=r[0];if(Kt(i))return null;if(!MM(i))return;let a=this.getSelectedTextElement(i),s=this.getTextElementAtPosition(o.x,o.y);if(!(!a||s?.id!==a.id))return i}getTextElementAtPosition(t,o){let r=this.getElementAtPosition(t,o,{includeBoundTextElement:!0});return r&&Kt(r)&&!r.isDeleted?r:null}getElementAtPosition(t,o,r){let i=[];if(r&&"allHitElements"in r?i=r?.allHitElements||[]:i=this.getElementsAtPosition(t,o,{includeBoundTextElement:r?.includeBoundTextElement,includeLockedElements:r?.includeLockedElements}),i.length>1){if(r?.preferSelected){for(let s=i.length-1;s>-1;s--)if(this.state.selectedElementIds[i[s].id])return i[s]}let a=i[i.length-1];return Ec({point:oe(t,o),element:a,threshold:this.getElementHitThreshold(a)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Tt(a)?this.frameNameBoundsCache.get(a):null})?a:i[i.length-2]}return i.length===1?i[0]:null}getElementsAtPosition(t,o,r){let i=[],a=this.scene.getNonDeletedElementsMap();return(r?.includeBoundTextElement&&r?.includeLockedElements?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(l=>(r?.includeLockedElements||!l.locked)&&(r?.includeBoundTextElement||!(Kt(l)&&l.containerId)))).filter(l=>this.hitElement(t,o,l)).filter(l=>{let c=Lb(l,a);return c&&!au(c)&&console.error("[NONDELETED][INVARIANT] Containing frame is deleted"),c&&this.state.frameRendering.enabled&&this.state.frameRendering.clip&&!fc(l)?DM({x:t,y:o},c,a):!0}).filter(l=>fc(l)?(i.push(l),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(sM/this.state.zoom.value))}hitElement(t,o,r,i=!0){return i&&this.state.selectedElementIds[r.id]&&JY([r],this.state,this.editorInterface)&&kX(oe(t,o),r,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(r))||aX(oe(t,o),r,this.scene.getNonDeletedElementsMap())?!0:Ec({point:oe(t,o),element:r,threshold:this.getElementHitThreshold(r),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Tt(r)?this.frameNameBoundsCache.get(r):null})}getTextBindableContainerAtPosition(t,o){let r=this.scene.getNonDeletedElements(),i=this.scene.getSelectedElements(this.state);if(i.length===1)return IM(i[0],!1)?i[0]:null;let a=null;for(let s=r.length-1;s>=0;--s){if(r[s].isDeleted)continue;let[l,c,d,m]=gM(r[s],this.scene.getNonDeletedElementsMap());if(gc(r[s])&&Ec({point:oe(t,o),element:r[s],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(r[s])})){a=r[s];break}else if(l<t&&t<d&&c<o&&o<m){if(Tt(r[s]))continue;a=r[s];break}}return IM(a,!1)?a:null}isEditingTextContent(){return!!this.state.editingTextElement||Kt(this.state.newElement)}handleHoverSelectedLinearElement(t,o,r){let i=this.scene.getNonDeletedElementsMap(),a=fe.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let s=-1,l=null;Ec({point:oe(o,r),element:a,elementsMap:i,threshold:this.getElementHitThreshold(a)})?(s=fe.getPointIndexUnderCursor(a,i,this.state.zoom,o,r),l=fe.getSegmentMidpointHitCoords(t,{x:o,y:r},this.state,this.scene.getNonDeletedElementsMap()),(Xt(a)?s===0||s===a.points.length-1:s>=0)||l?this.cursor.set(Ae.POINTER):this.hitElement(o,r,a)&&(!Xt(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Ae.MOVE)):this.hitElement(o,r,a)&&(!Xt(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Ae.MOVE),this.state.selectedLinearElement.hoverPointIndex!==s&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:s}}),fe.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,l)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:l}});let c=null,d=a;(d.startBinding||d.endBinding)&&(c=_X(a,o,r,this.scene,this.state)),this.state.selectedLinearElement.hoveredFocusPointBinding!==c&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!1,hoveredFocusPointBinding:c}}),c&&this.cursor.set(Ae.POINTER)}else this.cursor.set(Ae.AUTO)}updateGestureOnPointerDown(t){de.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),de.pointers.size===2&&(de.lastCenter=rf(de.pointers),de.initialScale=this.state.zoom.value,de.initialDistance=af(Array.from(de.pointers.values())))}initialPointerDownState(t){let o=Me(t,this.state),r=this.scene.getSelectedElements(this.state),[i,a,s,l]=ms(r),c=r.findIndex(Xt)===0;return{origin:o,withCmdOrCtrl:t[$.CTRL_OR_CMD],originInGrid:yb(Mt(o.x,o.y,t[$.CTRL_OR_CMD]||c?null:this.getEffectiveGridSize())),scrollbars:bf(wc,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...o},originalElements:this.scene.getNonDeletedElements().reduce((d,m)=>(d.set(m.id,xM(m)),d),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(s+i)/2,y:(l+a)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(o,r)},drag:{hasOccurred:!1,offset:null,origin:{...o},blockDragging:!1},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,o){if(!(o.scrollbars.isOverEither&&!this.state.multiElement))return!1;lu=!0,o.lastCoords.x=t.clientX,o.lastCoords.y=t.clientY;let r=km(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,o)}),i=Ke(()=>{ps=null,lu=!1,this.cursor.applyForTool(),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(Q.POINTER_MOVE,r),window.removeEventListener(Q.POINTER_UP,i),r.flush()});return ps=i,window.addEventListener(Q.POINTER_MOVE,r),window.addEventListener(Q.POINTER_UP,i),!0}isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,o){if(o.length<2)return!1;let r=Math.max(sM/this.state.zoom.value,1),i=qV*2/this.state.zoom.value,[a,s,l,c]=ms(o);return t.x>a-i-r&&t.x<l+i+r&&t.y>s-i-r&&t.y<c+i+r}getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:VY(t)?jp.ADAPTIVE_RADIUS:jp.PROPORTIONAL_RADIUS}:null}getCurrentItemStrokeWidth(t){return AY(t,this.state.currentItemStrokeWidthKey)}maybeCacheReferenceSnapPoints(t,o,r=!1){ko({event:t,app:this,selectedElements:o})&&(r||!gn.getReferenceSnapPoints())&&gn.setReferenceSnapPoints(N2(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,o,r=!1){ko({event:t,app:this,selectedElements:o})&&(r||!gn.getVisibleGaps())&&gn.setVisibleGaps(R2(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return Ke(o=>{this.maybeHandleResize(t,o)||this.maybeDragNewGenericElement(t,o)})}onKeyUpFromPointerDownHandler(t){return Ke(o=>{o.key===$.ALT&&o.preventDefault(),!this.maybeHandleResize(t,o)&&this.maybeDragNewGenericElement(t,o)})}onPointerMoveFromPointerDownHandler(t){return km(o=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let r=Me(o,this.state);if(this.state.activeLockedId&&this.setState({activeLockedId:null}),this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.initialState.segmentMidpoint.index){let[p,u]=Mt(r.x,r.y,o[$.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),E=this.state.selectedLinearElement.initialState.segmentMidpoint.index;if(E<0){let b=fe.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:p,y:u},this.state,this.scene.getNonDeletedElementsMap());E=b?fe.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,b,this.scene.getNonDeletedElementsMap()):-1}let g=fe.moveFixedSegment(this.state.selectedLinearElement,E,p,u,this.scene);this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!0,segmentMidPointHoveredCoords:g.segmentMidPointHoveredCoords,initialState:g.initialState}});return}let i=this.previousPointerMoveCoords??t.origin;if(this.previousPointerMoveCoords=r,t.drag.offset===null&&(t.drag.offset=yb(CX(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(o.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(o,t))return;if(rn(this.state)){this.handleEraser(o,r);return}if(this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(r.x,r.y),this.drawShape.handlePointerMove(r))return;let[s,l]=Mt(r.x,r.y,o[$.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(t.resize.isResizing&&(t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeHandleCrop(t,o)||this.maybeHandleResize(t,o)))return!0;let c=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement;if(p.draggedFocusPointBinding){LX(p,c,r,this.scene,this.state,this.getEffectiveGridSize(),o.altKey),this.setState({selectedLinearElement:{...p,isDragging:!1,selectedPointsIndices:[],initialState:{...p.initialState,lastClickedPoint:-1}}});return}if(fe.shouldAddMidpoint(this.state.selectedLinearElement,r,this.state,c)){let u=fe.addMidpoint(this.state.selectedLinearElement,r,this,!o[$.CTRL_OR_CMD],this.scene);if(!u)return;Ot(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:u.pointerDownState,selectedPointsIndices:u.selectedPointsIndices,segmentMidPointHoveredCoords:null,isDragging:!0}})});return}else{if(p.initialState.segmentMidpoint.value!==null&&!p.initialState.segmentMidpoint.added)return;if(p.initialState.lastClickedPoint>-1){let u=fe.getElement(p.elementId,c);if(u?.isDeleted)return;if(uo(u)){let g=Ar(oe(r.x,r.y),this.scene.getNonDeletedElements(),c);Bo("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(u,g)}if(o.altKey&&!this.state.selectedLinearElement?.initialState?.arrowStartIsInside&&Bo("COMPLEX_BINDINGS")&&this.handleSkipBindMode(),p.initialState.lastClickedPoint===-1)return;let E=fe.handlePointDragging(o,this,r.x,r.y,p);if(E){t.lastCoords.x=r.x,t.lastCoords.y=r.y,t.drag.hasOccurred=!0,(E.suggestedBinding!==this.state.suggestedBinding||!pM(E.selectedLinearElement?.selectedPointsIndices??[],this.state.selectedLinearElement?.selectedPointsIndices??[])||E.selectedLinearElement?.hoverPointIndex!==this.state.selectedLinearElement?.hoverPointIndex||E.selectedLinearElement?.customLineAngle!==this.state.selectedLinearElement?.customLineAngle||this.state.selectedLinearElement.isDragging!==E.selectedLinearElement?.isDragging||this.state.selectedLinearElement?.initialState?.altFocusPoint!==E.selectedLinearElement?.initialState?.altFocusPoint)&&this.setState(E);return}}}}let d=t.hit.allHitElements.some(p=>this.isASelectedElement(p)),m=this.state.selectedLinearElement?.isEditing&&o.shiftKey&&this.state.selectedLinearElement.elementId===t.hit.element?.id;if((d||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!m&&!t.drag.blockDragging){let p=this.scene.getSelectedElements(this.state);if(p.length>0&&p.every(g=>g.locked))return;let E=p.some(g=>Tt(g))?null:this.getTopLayerFrameAtSceneCoords(r,{currentFrameId:AM(p),excludeElementIds:this.state.selectedElementIds});if(this.updateFrameToHighlight(E),t.drag.hasOccurred=!0,this.state.activeTool.type==="lasso"&&this.lassoTrail.hasCurrentTrail&&!(this.editorInterface.formFactor!=="desktop"&&t.hit.element)&&!this.state.activeTool.fromSelection)return;if(this.state.activeTool.type==="lasso"&&p.length>0&&t.drag.hasOccurred&&!this.state.activeTool.fromSelection&&this.lassoTrail.endPath(),p.length>0&&!t.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!=="active"){let g={x:r.x-t.drag.origin.x,y:r.y-t.drag.origin.y},b=[...t.originalElements.values()],w=o.shiftKey;if(w){let I=Math.abs(g.x),T=Math.abs(g.y),C=w&&I<T,P=w&&I>T;C&&(g.x=0),P&&(g.y=0)}if(this.state.croppingElementId){let I=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(I&&Un(I)&&I.crop!==null&&t.hit.element===I){let T=I.crop,C=yi(I)&&this.imageCache.get(I.fileId)?.image;if(C&&!(C instanceof Promise)){let P=BX(I),M=qk(r.x-i.x,r.y-i.y);M[0]*=C.naturalWidth/P.width,M[1]*=C.naturalHeight/P.height;let[D,_,k,L,F,Y]=gM(I,c),z=fb(gb(oe(D,_),oe(F,Y),I.angle)),U=fb(gb(oe(k,_),oe(F,Y),I.angle)),V=fb(gb(oe(D,L),oe(F,Y),I.angle)),G=eM(Jk(U,z)),re=eM(Jk(V,z)),B=qk(Qk(M,G),Qk(M,re)),W={...T,x:cc(T.x-B[0]*Math.sign(I.scale[0]),0,C.naturalWidth-T.width),y:cc(T.y-B[1]*Math.sign(I.scale[1]),0,C.naturalHeight-T.height)};this.scene.mutateElement(I,{crop:W});return}}}this.maybeCacheVisibleGaps(o,p),this.maybeCacheReferenceSnapPoints(o,p);let{snapOffset:y,snapLines:x}=B2(b,g,this,o,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:x}),this.state.editingFrame||SX(t,p,g,this.scene,y,o[$.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),o.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let I=this.scene.getElementsIncludingDeleted(),T=t.hit.element,C=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});T&&t.hit.wasAddedToSelection&&!C.find(z=>z.id===T.id)&&C.push(T);let P=new Map(C.map(z=>[z.id,z])),{duplicatedElements:M,duplicateElementsMap:D,elementsWithDuplicates:_,origIdToDuplicateId:k}=yM({type:"in-place",elements:I,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:P,overrides:({duplicateElement:z,origElement:U})=>({frameId:z.frameId??U.frameId,seed:wY()})});M.forEach(z=>{t.originalElements.set(z.id,xM(z))});let L=_.map(z=>{if(P.has(z.id)){let U=t.originalElements.get(z.id);if(U)return po(z,{x:U.x,y:U.y})}return z}),F=this.props.onDuplicate?.(L,I),Y=OM(F||L,hc(M));Ot(()=>{if(t.hit.element){let z=k.get(t.hit.element.id),U=z&&D.get(z);t.hit.element=U||null}t.hit.allHitElements=t.hit.allHitElements.reduce((z,U)=>{let V=k.get(U.id),G=V&&D.get(V);return G&&z.push(G),z},[]),t.drag.origin=Me(o,this.state),this.setState(z=>({...zM(M,this.scene.getNonDeletedElements(),z)})),this.scene.replaceAllElements(Y),C.forEach(z=>{Tb(z)&&z.boundElements?.some(U=>U.type==="arrow")&&nu(z,this.scene)}),this.maybeCacheVisibleGaps(o,C,!0),this.maybeCacheReferenceSnapPoints(o,C,!0)})}return}}if(this.state.selectionElement){if(t.lastCoords.x=r.x,t.lastCoords.y=r.y,o.altKey){this.setActiveTool({type:"lasso",fromSelection:!0},{keepSelection:o.shiftKey}),this.lassoTrail.startPath(t.origin.x,t.origin.y,o.shiftKey),this.setAppState({selectionElement:null});return}this.maybeDragNewGenericElement(t,o)}else if(this.state.activeTool.type==="lasso")!o.altKey&&this.state.activeTool.fromSelection?(this.setActiveTool({type:"selection"}),this.createGenericElementOnPointerDown("selection",t),t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeDragNewGenericElement(t,o),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(r.x,r.y,o.shiftKey);else{let p=this.state.newElement;if(!p)return;if(p.type==="freedraw"){let u=p.points,E=r.x-p.x,g=r.y-p.y,b=u.length>0&&u[u.length-1];if(!(b&&b[0]===E&&b[1]===g)){let y=p.simulatePressure?p.pressures:[...p.pressures,o.pressure];this.scene.mutateElement(p,{points:[...u,oe(E,g)],pressures:y},{informMutation:!1,isDragging:!1}),this.setState({newElement:p})}}else if(zt(p)&&!p.isDeleted){t.drag.hasOccurred=!0;let u=p.points;mo(u.length>1,"Do not create linear elements with less than 2 points");let E=this.state.selectedLinearElement;(!E||E.elementId!==p.id)&&(E=new fe(p,this.scene.getNonDeletedElementsMap())),E&&(E.initialState.lastClickedPoint<0||E.initialState.lastClickedPoint>=u.length)&&(console.warn("Last clicked point is out of bounds. Attempting to fix it."),E={...E,selectedPointsIndices:[u.length-1],initialState:{...E.initialState,prevSelectedPointsIndices:null,lastClickedPoint:u.length-1},hoverPointIndex:u.length-1}),this.setState({newElement:p,...fe.handlePointDragging(o,this,s,l,E)})}else t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeDragNewGenericElement(t,o,!1)}if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let p=this.scene.getNonDeletedElements();if(this.state.selectedLinearElement?.isEditing)fe.handleBoxSelection(o,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!o.shiftKey&&Le(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(g=>Wn({...g,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),g,this)):u=!1);let E=this.state.selectionElement?rx(p,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1,this.state.boxSelectionMode):[];this.setState(g=>{let b={...u&&g.selectedElementIds,...E.reduce((w,y)=>(w[y.id]=!0,w),{})};return t.hit.element&&(E.length?delete b[t.hit.element.id]:b[t.hit.element.id]=!0),g=u?g:{...g,selectedGroupIds:{},editingGroupId:null},{...Wn({editingGroupId:g.editingGroupId,selectedElementIds:b},this.scene.getNonDeletedElements(),g,this),selectedLinearElement:E.length===1&&zt(E[0])?new fe(E[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:E.length===1&&(E[0].link||Fo(E[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(t,o){if(o.scrollbars.isOverHorizontal){let r=t.clientX,i=r-o.lastCoords.x;return this.viewport.translate({scrollX:this.state.scrollX-i*(wc.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),o.lastCoords.x=r,!0}if(o.scrollbars.isOverVertical){let r=t.clientY,i=r-o.lastCoords.y;return this.viewport.translate({scrollY:this.state.scrollY-i*(wc.vertical?.deltaMultiplier||1)/this.state.zoom.value}),o.lastCoords.y=r,!0}return!1}onPointerUpFromPointerDownHandler(t){return Ke(o=>{let r=this.scene.getNonDeletedElementsMap();this.removePointer(o),t.drag.blockDragging=!1,t.eventListeners.onMove&&t.eventListeners.onMove.flush(),o.type==="pointerup"&&this.state.activeTool.type===Hn.bucketfill?this.bucketFill.handlePointerUp():this.bucketFill.cancel();let{newElement:i,resizingElement:a,croppingElementId:s,multiElement:l,activeTool:c,isResizing:d,isRotating:m,isCropping:p}=this.state;this.setState(x=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:uc(x.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.previousPointerMoveCoords=null,gn.setReferenceSnapPoints(null),gn.setVisibleGaps(null),this.savePointer(o.clientX,o.clientY,"up");let u=t.hit.allHitElements,E=Me({clientX:o.clientX,clientY:o.clientY},this.state);if(this.state.activeTool.type==="selection"&&!t.boxSelection.hasOccurred&&!t.resize.isResizing&&!u.some(x=>this.state.selectedElementIds[x.id])){let x=this.getElementAtPosition(E.x,E.y,{includeLockedElements:!0});this.isEditingTextContent()||this.store.scheduleCapture(),x?.locked?this.setState({activeLockedId:x.groupIds.length>0?x.groupIds.at(-1)||"":x.id}):this.setState({activeLockedId:null})}else this.setState({activeLockedId:null});if(Bo("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.setState({selectedElementsAreBeingDragged:!1,bindMode:"orbit"}),t.drag.hasOccurred&&t.hit?.element?.id){let x=r.get(t.hit.element.id);Tb(x)&&x.boundElements?.filter(I=>I.type==="arrow").map(I=>r.get(I.id)).filter(I=>Xt(I)).forEach(I=>{I&&this.scene.mutateElement(I,{})})}if(this.state.selectedLinearElement?.isEditing&&!this.state.newElement&&this.state.selectedLinearElement.draggedFocusPointBinding===null)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.selectedLinearElement.elementId&&this.state.selectedLinearElement.draggedFocusPointBinding===null)this.actionManager.executeAction(ut);else{let x=fe.handlePointerUp(o,this.state.selectedLinearElement,this.state,this.scene);this.actionManager.executeAction(ut,"ui",{event:o,sceneCoords:E}),x!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:x,suggestedBinding:null})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let x=fe.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());x&&this.scene.mutateElement(x,{})}if(this.state.selectedLinearElement.draggedFocusPointBinding?(NX(this.state.selectedLinearElement,this.scene),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,draggedFocusPointBinding:null,initialState:{...this.state.selectedLinearElement.initialState,arrowOtherEndpointInitialBinding:null}}})):t.hit?.element?.id!==this.state.selectedLinearElement.elementId?this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null}):this.state.selectedLinearElement.isDragging&&(this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!1}}),this.actionManager.executeAction(ut,"ui",{event:o,sceneCoords:E})),this.state.newElement&&this.state.multiElement&&zt(this.state.newElement)&&this.state.selectedLinearElement){let{multiElement:x}=this.state;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:x.points[x.points.length-1]}})}}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener(Q.POINTER_MOVE,t.eventListeners.onMove),window.removeEventListener(Q.POINTER_UP,t.eventListeners.onUp),window.removeEventListener(Q.KEYDOWN,t.eventListeners.onKeyDown),window.removeEventListener(Q.KEYUP,t.eventListeners.onKeyUp),this.props?.onPointerUp?.(c,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,o),i?.type==="freedraw"){let x=Me(o,this.state),I=i.points,T=x.x-i.x,C=x.y-i.y;T===I[0][0]&&C===I[0][1]&&(C+=1e-4,T+=1e-4);let P=i.simulatePressure?[]:[...i.pressures,o.pressure];this.scene.mutateElement(i,{points:[...I,oe(T,C)],pressures:P}),this.actionManager.executeAction(ut);return}if(zt(i)&&this.state.activeTool.type!=="autoshape"){let x=Me(o,this.state),I=so(oe(x.x,x.y),oe(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||I<vY)&&i&&!l)if(this.editorInterface.isTouchScreen){let T=Math.min(this.state.width*.7/this.state.zoom.value,100);this.scene.mutateElement(i,{x:i.x-T/2,points:[oe(0,0),oe(T,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(ut)}else this.setState({multiElement:i,newElement:i});else t.drag.hasOccurred&&!l&&(this.store.scheduleCapture(),zt(i)&&this.actionManager.executeAction(ut,"ui",{event:o,sceneCoords:E}),this.setState({suggestedBinding:null}),this.isToolLocked()?this.setState({newElement:null}):this.setState(T=>({newElement:null,activeTool:nn(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:De({...T.selectedElementIds,[i.id]:!0},T),selectedLinearElement:new fe(i,this.scene.getNonDeletedElementsMap())}),()=>this.cursor.reset()),this.scene.triggerUpdate());return}if(Kt(i)){let x=gX(xb({fontSize:i.fontSize,fontFamily:i.fontFamily}),i.lineHeight);i.width<x&&this.scene.mutateElement(i,{autoResize:!0}),this.cursor.reset(),this.handleTextWysiwyg(i,{isExistingElement:!0})}if(c.type!=="selection"&&i&&SM(i)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==i.id),appState:{newElement:null},captureUpdate:$t.NEVER});return}if(Tt(i)){let x=nX(this.scene.getElementsIncludingDeleted(),i,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(Ab(this.scene.getElementsMapIncludingDeleted(),x,i))}if(i&&(this.scene.mutateElement(i,YY(i),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let x=Me(o,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let I=this.scene.getElement(this.state.selectedLinearElement.elementId);if(I?.frameId){let T=Lb(I,r);T&&I&&(oX(I,T,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(I,{groupIds:[]}),tX([I],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let I=this.scene.getSelectedElements(this.state),T=this.getTopLayerFrameAtSceneCoords(x,{currentFrameId:AM(I),excludeElementIds:this.state.selectedElementIds}),C=this.scene.getElementsMapIncludingDeleted(),P=M=>{if(M.length>0){for(let D of M){let _=D.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(D,{groupIds:D.groupIds.slice(0,_)},{informMutation:!1,isDragging:!1})}C.forEach(D=>{D.groupIds.length&&vi(C,D.groupIds[D.groupIds.length-1]).length<2&&this.scene.mutateElement(D,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(T&&!this.state.selectedElementIds[T.id]){let M=I.filter(D=>_M(D,C,this.state));this.state.editingGroupId&&P(M),C=Ab(C,M,T)}else if(!T&&this.state.editingGroupId){let M=I.filter(D=>D.frameId&&!_M(D,C,this.state));P(M)}C=LM(C,this.state,this),this.scene.replaceAllElements(C)}}if(a&&this.store.scheduleCapture(),a&&SM(a)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==a.id),captureUpdate:$t.NEVER}),t.resize.isResizing){let x=LM(this.scene.getElementsIncludingDeleted(),this.state,this),I=this.scene.getSelectedElements(this.state).filter(Tt);for(let T of I)x=eX(x,Db(this.scene.getElementsIncludingDeleted(),T,this.state,r),T);this.scene.replaceAllElements(x)}let g=t.hit.element;this.state.selectedLinearElement?.elementId!==g?.id&&zt(g)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new fe(g,this.scene.getNonDeletedElementsMap())}),(!s||s&&(!g&&!p||g&&g.id!==s))&&this.finishImageCropping();let b=this.lastPointerDownEvent,w=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(rn(this.state)&&b&&w){if(this.eraserTrail.endPath(),so(oe(b.clientX,b.clientY),oe(w.clientX,w.clientY))===0){let I=Me({clientX:w.clientX,clientY:w.clientY},this.state);this.getElementsAtPosition(I.x,I.y).forEach(C=>this.elementsPendingErasure.add(C.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(g&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.selectedLinearElement?.isEditing||!t.boxSelection.hasOccurred)&&this.state.activeTool.type!=="lasso"&&(o.shiftKey&&!this.state.selectedLinearElement?.isEditing?this.state.selectedElementIds[g.id]?yX(this.state,g)?this.setState(x=>{let I={...x.selectedElementIds};for(let T of g.groupIds.flatMap(C=>vi(this.scene.getNonDeletedElements(),C)))delete I[T.id];return{selectedGroupIds:{...x.selectedElementIds,...g.groupIds.map(T=>({[T]:!1})).reduce((T,C)=>({...T,...C}),{})},selectedElementIds:De(I,x)}}):this.state.selectedLinearElement?.isDragging||this.setState(x=>{let I={...x.selectedElementIds};delete I[g.id];let T=ce(this.scene.getNonDeletedElements(),{selectedElementIds:I});return{...Wn({editingGroupId:x.editingGroupId,selectedElementIds:I},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:T.length===1&&zt(T[0])?new fe(T[0],this.scene.getNonDeletedElementsMap()):x.selectedLinearElement}}):g.frameId&&this.state.selectedElementIds[g.frameId]?this.setState(x=>{let I={...x.selectedElementIds,[g.id]:!0};return delete I[g.frameId],(this.scene.getElement(g.frameId)?.groupIds??[]).flatMap(T=>vi(this.scene.getNonDeletedElements(),T)).forEach(T=>{delete I[T.id]}),{...Wn({editingGroupId:x.editingGroupId,selectedElementIds:I},this.scene.getNonDeletedElements(),x,this),showHyperlinkPopup:g.link||Fo(g)?"info":!1}}):this.setState(x=>({selectedElementIds:De({...x.selectedElementIds,[g.id]:!0},x)})):this.setState(x=>({...Wn({editingGroupId:x.editingGroupId,selectedElementIds:{[g.id]:!0}},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:zt(g)&&x.selectedLinearElement?.elementId!==g.id?new fe(g,this.scene.getNonDeletedElementsMap()):x.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(g&&Xt(g))&&!t.drag.hasOccurred&&!this.state.isResizing&&(g&&sX({point:oe(t.origin.x,t.origin.y),element:g,elementsMap:r,threshold:this.getElementHitThreshold(g),frameNameBound:Tt(g)?this.frameNameBoundsCache.get(g):null},r)||!g&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(va):this.setState({selectedElementIds:De({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),this.cursor.set(Ae.AUTO);return}let y=this.getSelectedTextEditingContainerAtPosition(g,E);if(c.type===this.state.preferredSelectionTool.type&&!this.state.editingTextElement&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&!o.shiftKey&&!o[$.CTRL_OR_CMD]&&!o.altKey&&o.pointerType!=="touch"&&g&&(Kt(g)&&this.state.selectedElementIds[g.id]&&this.scene.getSelectedElements(this.state).length===1||y)){this.startTextEditing({sceneX:E.x,sceneY:E.y,container:y,initialCaretSceneCoords:this.lastPointerUpIsDoubleClick?void 0:E});return}if(!this.isToolLocked()&&c.type!=="freedraw"&&i&&this.setState(x=>({selectedElementIds:De({...x.selectedElementIds,[i.id]:!0},x),showHyperlinkPopup:Fo(i)&&!i.link?"editor":x.showHyperlinkPopup})),!this.isEditingTextContent()&&(c.type!=="selection"||Le(this.scene.getNonDeletedElements(),this.state)||!pM(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),t.drag.hasOccurred&&!this.state.selectedLinearElement||d||m||p){let x=this.scene.getSelectedElements(this.state).filter(gc);fM(x,this.scene,this.state)}if(c.type==="laser"){this.laserTrails.endPath();return}if(c.type==="autoshape"){this.actionManager.executeAction(ut);return}!this.isToolLocked()&&c.type!=="freedraw"&&c.type!==Hn.bucketfill&&(c.type!=="lasso"||c.type==="lasso"&&c.fromSelection)?this.setState({newElement:null,suggestedBinding:null,activeTool:nn(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset()):this.setState({newElement:null,suggestedBinding:null})})}clearSelection(t){this.setState(o=>({selectedElementIds:De({},o),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:o.editingGroupId&&t!=null&&FM(t,o.editingGroupId)?o.editingGroupId:null})),this.setState({selectedElementIds:De({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds,selectedLinearElement:null})}getTextWysiwygSnappedToCenterPosition(t,o,r,i){if(i){let a=i.x+i.width/2,s=i.y+i.height/2,l=kb(i,this.scene.getNonDeletedElementsMap());if(l&&(a=l.x,s=l.y),Math.hypot(t-a,o-s)<oY){let{x:m,y:p}=Qp({sceneX:a,sceneY:s},r);return{viewportX:m,viewportY:p,elementCenterX:a,elementCenterY:s}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let t=this.excalidrawContainerRef.current,{left:o,top:r}=t.getBoundingClientRect();return{offsetLeft:o,offsetTop:r}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=Di.find(o=>o.code===this.props.langCode)||Xn;await Fc(t),this.setAppState({})}},HX=()=>{(QM()||e3())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(n3(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};HX();var i3=zb;import{useEffect as WX,useState as VX}from"react";import{jsx as YX}from"react/jsx-runtime";var a3=e=>{let[n,t]=VX(!0);return WX(()=>{let o=async()=>{await Fc(r),t(!1)},r=Di.find(i=>i.code===e.langCode)||Xn;o()},[e.langCode]),n?YX(up,{theme:e.theme}):e.children};import XX from"clsx";import{jsx as s3}from"react/jsx-runtime";var l3=({children:e})=>{let{FooterCenterTunnel:n}=ot(),t=ye();return s3(n.In,{children:s3("div",{className:XX("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},KX=l3;l3.displayName="FooterCenter";import $X from"clsx";import{MQ_MIN_WIDTH_DESKTOP as ZX}from"@excalidraw/common";import{jsx as qX,jsxs as JX}from"react/jsx-runtime";var c3=({isCollaborating:e,onSelect:n,editorInterface:t,...o})=>{let r=ye(),i=t?.formFactor!=="desktop"||r.width<ZX;return JX(vn,{...o,className:$X("collab-button",{active:e}),type:"button",onSelect:n,style:{position:"relative",width:i?void 0:"auto"},title:f("labels.liveCollaboration"),children:[i?t1:f("labels.share"),r.collaborators.size>0&&qX("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},jX=c3;c3.displayName="LiveCollaborationTrigger";import{jsx as Lr,jsxs as m3}from"react/jsx-runtime";var QX=()=>Lr("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Lr("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"})}),eK=()=>m3("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Lr("path",{d:"M429.27 96.74c2.47-1.39 4.78-3.02 6.83-4.95 1.43-1.35 2.73-2.86 3.81-4.51-.66.9-1.4 1.77-2.23 2.59-2.91 2.84-5.72 5.09-8.42 6.87h.01ZM343.6 69.36c.33 3.13.58 6.27.79 9.4.09 1.37.18 2.75.25 4.12-.12-4.46-.27-8.93-.5-13.39-.11-2.08-.24-4.16-.4-6.24-.06 1.79-.11 3.85-.13 6.11h-.01ZM378.47 98.34c.01-.37.07-1.13.01-6.51-.11 1.9-.22 3.81-.31 5.71-.07 1.42-.22 2.91-.16 4.35.39.03.78.07 1.17.1-.92-.85-.76-2.01-.72-3.66l.01.01ZM344.09 86.12c-.09-2.41-.22-4.83-.39-7.24v12.21c.15-.05.32-.09.47-.14.05-1.61-.03-3.23-.09-4.83h.01ZM440.69 66.79c-.22-.34-.45-.67-.69-.99-3.71-4.87-9.91-7.14-15.65-8.55-1.05-.26-2.12-.49-3.18-.71 2.29.59 4.48 1.26 6.64 2.02 7.19 2.54 10.57 5.41 12.88 8.23ZM305.09 72.46l1.2 3.6c.84 2.53 1.67 5.06 2.46 7.61.24.78.5 1.57.73 2.36.22-.04.44-.08.67-.12a776.9 776.9 0 0 1-5.01-13.57c-.02.04-.03.09-.05.13v-.01ZM345.49 90.25v.31c1.48-.42 3.05-.83 4.66-1.2-1.56.25-3.12.52-4.66.89ZM371.02 90.22c0-.57-.04-1.14-.11-1.71-.06-.02-.12-.04-.19-.05-.21-.05-.43-.08-.65-.11.42.16.74.88.95 1.87ZM398.93 54.23c-.13 0-.27-.01-.4-.02l.03.4c.11-.15.23-.27.37-.38ZM401.57 62.28v-.15c-1.22-.24-2.86-.61-3.23-1.25-.09-.15-.18-.51-.27-.98-.09.37-.2.73-.33 1.09 1.24.56 2.52.98 3.83 1.29ZM421.73 88.68c-2.97 1.65-6.28 3.12-9.69 3.68v.18c4.72-.14 11.63-3.85 16.33-8.38-2.04 1.75-4.33 3.24-6.63 4.53l-.01-.01ZM411.28 80.92c-.05-1.2-.09-2.4-.15-3.6-.21 5.66-.46 11.38-.47 14.51.24-.02.48-.04.71-.07.15-3.61.05-7.23-.09-10.83v-.01Z",transform:"translate(-144.023 -51.76)"}),Lr("path",{d:"M425.38 67.41c-3.5-1.45-7.19-2.57-14.06-3.62.09 1.97.06 4.88-.03 8.12.03.04.06.09.06.15.19 1.36.28 2.73.37 4.1.25 3.77.39 7.55.41 11.33 0 1.38-.01 2.76-.07 4.13 1.4-.25 2.78-.65 4.12-1.15 4.07-1.5 7.94-3.78 11.28-6.54 2.33-1.92 5.13-4.49 5.88-7.58.63-3.53-2.45-6.68-7.97-8.96l.01.02ZM411.35 92.53v-.06l-.34.03c.11.01.22.03.34.03ZM314.26 64.06c-.23-.59-.47-1.17-.7-1.75.57 1.62 1.11 3.25 1.6 4.9l.15.54 2.35 6.05c.32.82.66 1.64.98 2.46-1.38-4.1-2.83-8.17-4.39-12.2h.01ZM156.82 103.07c-.18.13-.38.23-.58.33 1.32-.03 2.66-.2 3.93-.34.86-.09 1.72-.22 2.58-.33-2.12.1-4.12.17-5.94.34h.01ZM210.14 68.88s.03.04.05.07c.18-.31.39-.64.58-.96-.21.3-.42.6-.64.89h.01ZM201.65 82.8c-.5.77-1.02 1.56-1.49 2.37 1.11-1.55 2.21-3.1 3.2-4.59-.23.23-.49.51-.75.79-.32.47-.65.95-.96 1.43ZM194.03 98.66c-.33-.4-.65-.84-1.05-1.17-.24-.2-.07-.49.17-.56-.23-.26-.42-.5-.63-.75 1.51-2.55 3.93-5.87 6.4-9.28-.17-.08-.29-.28-.2-.49.04-.09.09-.17.13-.26-1.21 1.78-2.42 3.55-3.61 5.33-.87 1.31-1.74 2.64-2.54 4-.29.5-.63 1.04-.87 1.61.81.65 1.63 1.27 2.47 1.88-.09-.11-.18-.21-.27-.32v.01ZM307.79 82.93c-1-3.17-2.05-6.32-3.1-9.48-1.62 4.08-3.69 9.17-6.16 15.19 3.32-1.04 6.77-1.87 10.27-2.5-.32-1.08-.67-2.15-1.01-3.21ZM149.5 80.7c.05-1.71.04-3.43 0-5.14-.1 2.26-.16 4.51-.22 6.77-.02.73-.03 1.46-.04 2.19.14-1.27.2-2.55.24-3.82h.02ZM228.98 98.3c.39 1.25.91 3.03.94 3.91.06-.03.12-.07.17-.1.08-1.29-.55-2.65-1.11-3.81ZM307.72 53.36c.81.5 1.53 1.04 2.07 1.49-.38-.8-.78-1.58-1.21-2.35-.17.03-.34.06-.51.11-.43.12-.86.26-1.29.41.35-.01.53.1.94.34ZM283.69 96.14c3.91-7.25 6.89-13.35 8.88-18.15l1.1-2.66c-1.27 2.64-2.56 5.27-3.83 7.9-1.53 3.15-3.06 6.31-4.58 9.47-.87 1.81-1.76 3.62-2.54 5.47.04.02.07.04.11.07.05.05.1.09.15.14.05-.73.27-1.48.71-2.24ZM289.92 103.23s-.04.01-.05.03c0-.02.04-.03.05-.04.05-.05.11-.1.16-.15l.21-.21c-.55 0-1.5-.27-2.55-.72.4.26.8.51 1.22.74.24.13.48.26.73.37.05.02.1.03.14.05a.27.27 0 0 1 .08-.07h.01ZM269.23 68.49c-.39-.19-.82-.48-1.33-.87-3.06-1.56-6.31-2.78-9.36-2.35-3.5.49-5.7 1.11-7.74 2.44 5.71-2.6 12.82-2.07 18.44.79l-.01-.01ZM177.87 53.69l1.06.03c-.96-.22-2-.25-2.89-.3-4.95-.26-9.99.33-14.86 1.19-2.44.43-4.88.95-7.28 1.59 9.09-1.76 15.69-2.77 23.97-2.51ZM219.85 55.51c-.18.12-.36.27-.56.45-.45.53-.86 1.11-1.26 1.66-1.91 2.61-3.71 5.31-5.57 7.95l-.12.18 8.05-10.11c-.18-.05-.36-.1-.55-.13h.01ZM510.71 54.1c.12-.15.29-.3.53-.45.69-.4 3.72-.63 5.87-.74-.36-.02-.73-.04-1.09-.05-1.84-.03-3.67.09-5.49.35.05.3.12.59.18.88v.01ZM510.76 86.02c1.37-3.07 2.49-6.27 3.57-9.46.55-1.64 1.12-3.3 1.6-4.97-1.59 4.01-3.67 9.14-6.2 15.3.24-.08.5-.14.74-.22.1-.22.19-.44.29-.65ZM566.95 75.76c.11-.02.23.03.31.11-.05-.13-.09-.26-.14-.39-.05.09-.11.18-.17.28ZM511.33 86.41c3.08-.89 6.24-1.62 9.46-2.14-1.51-3.98-2.98-7.96-4.39-11.87-.05.15-.09.31-.14.46-1.02 3.32-2.15 6.61-3.39 9.85-.48 1.25-.98 2.49-1.53 3.7h-.01ZM578.24 74.45c.11-.44.23-.87.35-1.31-.31.7-.64 1.39-.97 2.08.09.21.19.4.28.61.12-.46.23-.92.35-1.38h-.01ZM520.62 53.11c-.09 0-.18-.01-.28-.02.38.34.29 1.08.93 2.53l6.65 17.15c2.2 5.68 4.69 11.36 7.41 16.87l1.06 2.17c-2.95-7.05-5.92-14.08-8.87-21.13-1.58-3.79-3.16-7.59-4.7-11.4-.78-1.92-1.73-3.89-2.25-5.91-.03-.1 0-.19.04-.26h.01ZM578.78 77.87c1.45-5.77 3.07-10.43 3.58-13.36.05-.34.16-.88.31-1.55-.67 1.79-1.37 3.56-2.08 5.33-.12.43-.23.86-.35 1.29-.65 2.43-1.29 4.86-1.9 7.3.14.33.29.65.43 1l.01-.01ZM545.3 94.66c.02-.44.03-.83.05-1.12.02-1.01.05-2.02.11-3.02.03-6.66-.46-14.33-1.46-22.8-.13-.42-.27-1.24-.56-2.89 0-.02 0-.04-.01-.06.62 6.61.95 13.25 1.32 19.87.17 3.08.33 6.16.52 9.23.02.25.03.52.04.78l-.01.01ZM580.77 102.81c.13.2.27.38.37.49.27-.11.53-.22.8-.32-.43.09-.82.05-1.17-.16v-.01ZM530.48 104.07h.33c-.36-.13-.71-.32-1.04-.56.14.24.3.47.45.7.06-.08.14-.13.26-.13v-.01ZM542.63 58.82c.06.23.11.47.15.71.14-.33.36-.62.7-.86-.28.05-.57.11-.85.15ZM583.81 57.87c.15-.7.29-1.41.42-2.11-.14.45-.28.9-.42 1.34-.46 1.44-.89 2.89-1.31 4.34.44-1.19.88-2.37 1.31-3.57ZM523.62 91.48c-4.66 1.17-9.05 2.89-14.02 5.27 4.65-1.84 9.48-3.29 14.28-4.63-.09-.22-.17-.41-.26-.64ZM460.64 78.3c-.04-2.9-.11-5.81-.28-8.71-.1-1.68-.17-3.43-.5-5.09-.07.02-.14.03-.2.05.3 6.54.45 12.17.51 17.12.17-.07.34-.14.51-.2 0-1.06-.01-2.11-.03-3.17h-.01ZM470.63 63.24c-3.38-.26-6.81.32-10.1 1.1.41 2.01.47 4.14.57 6.18.18 3.55.25 7.11.27 10.67 3.31-1.38 6.5-3.12 9.3-5.35 1.96-1.56 3.86-3.41 5.02-5.66.73-1.41 1.19-3.22.26-4.65-1.09-1.7-3.46-2.14-5.32-2.29ZM460.29 63.68c1-.24 2.01-.46 3.04-.65-1.15.16-2.37.38-3.71.69v.13c.07-.02.15-.04.22-.05.11-.13.3-.18.45-.11v-.01ZM457.24 100.96c.43-.03.86-.07 1.29-.11.14-.49.27-.99.38-1.49-.44.7-1 1.23-1.67 1.6ZM482.88 104.98c-.18.23-.36.38-.55.47.14.09.27.19.4.28a70.76 70.76 0 0 0 4.37-4.63c.76-.89 1.52-1.81 2.19-2.77-.3-.27-.61-.53-.92-.79-.07 1.94-4.62 6.32-5.49 7.45v-.01Z",transform:"translate(-144.023 -51.76)"}),Lr("path",{d:"M474.36 63.31c-.4-.16-.84-.27-1.29-.37 1.56.42 3.08 1.22 3.76 2.74.62 1.4.32 2.95-.28 4.32.7-1.22.94-2.34.74-3.47-.24-1.33-1.19-2.54-2.93-3.21v-.01ZM477.34 89.18c-1.2-.81-2.4-1.62-3.6-2.42-.14.1-.26.19-.4.29 1.4.67 2.73 1.39 4 2.13ZM465.88 93.85c.37.25.74.5 1.1.75.46.32.92.65 1.38.97-1.57-1.2-2.01-1.61-2.49-1.72h.01ZM574.92 90.06c-2.28-5.21-4.93-11.13-5.67-12.26-.1-.15-1.57-3.01-1.63-3.08 0 0-.01.02-.02.02.4 1.37 1.09 2.69 1.65 3.99 2.14 4.95 4.36 9.86 6.67 14.73.6 1.26 1.21 2.52 1.83 3.78-.75-2.01-1.64-4.45-2.83-7.18ZM448.73 65.29c.1.2.22.38.34.57.22-.02.43-.06.65-.08v-.08c-.14-.05-.25 0-.99-.41ZM460.16 94.81c-.02.31-.06.59-.1.89-.03 1.71-.33 3.43-.79 5.07.15-.02.3-.03.45-.05.01-.04.02-.08.03-.11.09-.34.15-.69.2-1.03.17-1.07.25-2.16.33-3.24.05-.69.08-1.39.12-2.08-.27.1-.27.26-.24.57v-.02Z",transform:"translate(-144.023 -51.76)"}),Lr("path",{d:"m328.67 98.12-3.22-6.58c-1.29-2.63-2.53-5.29-3.72-7.97-.25-.85-.52-1.69-.79-2.53-.81-2.57-1.67-5.12-2.55-7.67-1.92-5.53-3.9-11.08-6.32-16.41-.72-1.58-1.46-3.44-2.63-4.79-.03-.17-.16-.29-.34-.36a.282.282 0 0 0-.23-.04c-.06-.01-.12 0-.18.01-.74.06-1.5.38-2.19.61-2.22.77-4.4 1.64-6.63 2.38-.03-.08-.06-.16-.09-.25-.15-.42-.82-.24-.67.19.03.09.07.19.1.28l-.18.06c-.36.11-.28.6 0 .68.18 1.18.63 2.36.98 3.49.03.09.06.17.08.26-.08.23-.17.46-.24.64-.37.98-.79 1.94-1.21 2.9-1.27 2.89-2.62 5.75-3.98 8.6-3.18 6.67-6.44 13.31-9.64 19.97-1.08 2.25-2.2 4.5-3.15 6.81-.13.32.24.5.5.37 1.34 1.33 2.84 2.5 4.4 3.57.65.44 1.31.87 2.01 1.24.4.22.86.48 1.33.5.24.01.35-.19.33-.37.11-.1.21-.21.28-.28.41-.41.81-.84 1.2-1.26.85-.92 1.69-1.87 2.5-2.84 6.31-2.34 12.6-4.31 18.71-5.84 2.14 5.3 3.43 8.43 3.97 9.58.55 1.05 1.15 1.88 1.82 2.52 1.32.56 6.96-.03 9.23-1.96.87-1.28 1.19-2.67.93-4.15-.09-.5-.22-.95-.4-1.33l-.01-.03Zm-20.09-45.61c.43.77.83 1.56 1.21 2.35-.54-.45-1.27-.99-2.07-1.49-.42-.24-.6-.35-.94-.34.43-.15.85-.29 1.29-.41.17-.05.34-.08.51-.11Zm-25.86 45.66c.78-1.85 1.67-3.66 2.54-5.47 1.51-3.16 3.05-6.31 4.58-9.47 1.28-2.63 2.56-5.26 3.83-7.9l-1.1 2.66c-1.99 4.79-4.97 10.9-8.88 18.15-.43.76-.66 1.51-.71 2.24-.05-.05-.1-.09-.15-.14a.259.259 0 0 0-.11-.07Zm6.24 4.71c-.42-.23-.82-.48-1.22-.74 1.05.45 2 .72 2.55.72l-.21.21c-.05.05-.11.1-.16.15-.01.01-.04.03-.05.04 0-.02.03-.02.05-.03a.27.27 0 0 0-.08.07c-.05-.02-.1-.03-.14-.05-.25-.1-.49-.24-.73-.37h-.01Zm15.73-29.43c1.05 3.15 2.1 6.31 3.1 9.48.34 1.06.69 2.13 1.01 3.21-3.5.63-6.95 1.46-10.27 2.5 2.48-6.03 4.54-11.11 6.16-15.19Zm4.79 12.57c-.23-.79-.49-1.58-.73-2.36-.79-2.54-1.63-5.08-2.46-7.61l-1.2-3.6c.02-.04.04-.09.05-.13 1.6 4.45 3.28 9 5.01 13.57l-.67.12v.01Zm5.83-18.27-.15-.54c-.49-1.64-1.03-3.28-1.6-4.9.23.58.47 1.17.7 1.75 1.56 4.03 3.01 8.1 4.39 12.2-.33-.82-.67-1.64-.98-2.46l-2.35-6.05h-.01ZM390.43 79.37c-.13-10.43-.22-17.5-.24-19.97-.24-1.6.21-2.88-.65-3.65-.14-.13-.32-.23-.52-.32h.03c.45 0 .45-.69 0-.7-1.75-.03-3.5-.04-5.25-.14-1.38-.08-2.76-.21-4.15-.31-.07 0-.12.01-.17.04-.21-.07-.47.03-.45.31l.03.45c-.11.14-.19.3-.22.5-.21 1.26-.32 13.67-.36 23.59-.32 5.79-.67 11.57-.97 17.36-.09 1.73-.29 3.54-.21 5.3-.39.02-.38.64.04.69v.12c.05.44.74.45.7 0v-.06c1.1.09 2.2.21 3.3.3 1.14.19 2.44.2 3.29.17 1.73-.05 2.92-.05 3.8-.37.45-.05.9-.11 1.35-.17.44-.06.25-.73-.19-.67h-.01c.24-.32.45-.72.62-1.25.66-1.84.41-6.36.34-11.33l-.13-9.9.02.01Zm-12.26 18.17c.09-1.91.2-3.81.31-5.71.06 5.38 0 6.14-.01 6.51-.05 1.65-.21 2.81.72 3.66-.39-.04-.78-.07-1.17-.1-.06-1.44.09-2.93.16-4.35l-.01-.01ZM588.97 53.85c-2.06-.25-3.17-.51-3.76-.6a.3.3 0 0 1 .04-.08c.22-.39-.39-.75-.6-.35-.56 1.02-.9 2.19-1.26 3.29-.61 1.88-1.17 3.78-1.72 5.68-.63 2.19-1.24 4.39-1.83 6.59-.81 2.03-1.67 4.05-2.61 6.03-1.7-3.64-3.11-6.04-4.03-7.57-2.26-3.74-2.85-5.48-3.57-6.08l.31-.09c.43-.12.25-.8-.19-.67-1.06.3-2.12.6-3.17.95-.93.32-1.85.69-2.76 1.07-.13.05-.19.16-.22.27-.04.02-.08.05-.11.07-.04-.06-.07-.12-.11-.18a.354.354 0 0 0-.48-.12c-.16.09-.22.32-.13.48l.33.54c0 .09.02.18.06.28.51 1.16.78 1.38.72 1.47-2.42 3.44-5.41 7.86-6.2 9.1-1.27 1.97-2.01 3.14-2.45 3.84l-.91-6.56-.43-4.1c-.19-1.85-.37-3.23-.53-4.13-.19-1.1-.3-2.15-.45-3.16-.2-1.36-.29-2.06-.47-2.42h.04c.45.02.45-.68 0-.7-3.43-.16-6.81.94-10.17 1.48-.24-.22-.73-.04-.58.32.24.59.33 1.25.43 1.87.17 1.06.29 2.13.4 3.2.32 3.09.53 6.2.74 9.3.44 6.75.77 13.51 1.17 20.26.11 1.95.13 3.96.46 5.89.05.3.37.31.55.14.74 1.71 2.87 1.27 6.13 1.27 1.34 0 2.39.04 2.99-.11.02.32.48.53.63.18 3.61-8.26 7.41-16.46 12.05-24.2.03-.05.04-.1.05-.15.3.73.64 1.45.94 2.16.97 2.26 1.97 4.52 2.98 6.76 2.26 5.03 4.54 10.07 7.09 14.96.47.9.94 1.79 1.47 2.65.2.32.4.67.66.96-.18.25 0 .68.34.54.91-.38 1.82-.75 2.76-1.07 1.04-.35 2.11-.65 3.17-.95.39-.11.28-.66-.07-.68.62-.4.95-.96.87-1.91-.3-3.34.72-7.47.86-8.52l2.14-11.43c1.75-10.74 3.13-17.51 3.23-20.86.02-.49.08-2.84.13-3.24.17-1.25.48-1-4.96-1.65l.03-.02Zm-46.19 5.67c-.04-.24-.09-.48-.15-.71l.85-.15c-.34.24-.56.53-.7.86Zm1.95 25.12c-.36-6.63-.7-13.26-1.32-19.87 0 .02 0 .04.01.06.29 1.65.44 2.47.56 2.89 1 8.46 1.5 16.14 1.46 22.8-.06.99-.1 2-.11 3.02-.01.29-.03.68-.05 1.12-.01-.26-.03-.53-.04-.78-.19-3.08-.35-6.16-.52-9.23l.01-.01Zm36.4 18.66c-.11-.11-.24-.29-.37-.49.35.21.74.26 1.17.16-.27.11-.53.22-.8.32v.01Zm-.89-33.72c.12-.43.23-.86.35-1.29.71-1.77 1.41-3.55 2.08-5.33-.15.68-.26 1.22-.31 1.55-.5 2.94-2.13 7.59-3.58 13.36-.15-.35-.29-.66-.43-1 .61-2.44 1.25-4.87 1.9-7.3l-.01.01Zm3.56-12.48c.14-.44.28-.89.42-1.34-.13.7-.27 1.41-.42 2.11-.43 1.19-.86 2.38-1.31 3.57.42-1.45.85-2.9 1.31-4.34Zm-5.22 16.05c-.11.44-.23.87-.35 1.31-.12.46-.23.92-.35 1.38-.1-.22-.19-.4-.28-.61.34-.69.66-1.38.97-2.08h.01Zm-11.64 2.62c.06-.1.12-.19.17-.28.05.13.09.26.14.39a.398.398 0 0 0-.31-.11Zm2.3 2.98c-.56-1.3-1.25-2.63-1.65-3.99 0 0 .01-.02.02-.02.06.08 1.52 2.93 1.63 3.08.73 1.13 3.38 7.04 5.67 12.26 1.2 2.73 2.08 5.17 2.83 7.18-.62-1.25-1.23-2.51-1.83-3.78-2.31-4.87-4.53-9.78-6.67-14.73ZM275.92 87.03c-1.06-2.18-1.13-3.45-2.44-2.93-1.52.57-2.94 1.3-4.5 2.1-1.4.72-2.68 1.44-3.92 2.12.01-.25-.24-.5-.51-.34-4.8 2.93-12.41 4.7-17.28 1.31-1.98-1.77-3.32-4.15-3.97-5.78-.29-.95-.49-1.94-.63-2.93-.14-3.34 1.58-6.53 3.9-9.12.8-.79 1.68-1.51 2.66-2.12 3.7-2.3 8.22-3.07 12.51-2.51 2.71.35 5.32 1.24 7.71 2.55.39.22.75-.39.35-.6-.18-.1-.37-.18-.55-.27.56.27 1.03.33 1.51.19l-.48.39c-.15.11-.23.3-.13.48.09.15.33.24.48.13 1.3-.97 2.46-2.09 3.45-3.37.37-.29.64-.6.65-.97v-.02c.08-.33-.03-.7-.21-1.08-.31-.87-.98-2.01-2.19-3.26-2.43-2.52-3.79-3.45-5.68-4.26-1.14-.49-3.12-1.06-4.42-1.23-3.28-.42-10.64-1.21-18.18 4.11-7.74 5.46-11.94 12.3-12.23 20.61-.08 2.06.04 3.98.34 5.71.74 4.18 2.57 8 5.44 11.34 4.26 4.99 9.76 7.52 16.34 7.52 4.85 0 9.69-1.77 14.89-4.62.23-.12.45-.23.68-.35 2.19-1.1 4.37-2.23 6.46-3.5.49-.3 1.03-.61 1.5-.98 1.47-.87 1.11-1.12.49-2.95-.39-1.14-.76-2.7-2.06-5.36l.02-.01Zm-17.38-21.76c3.05-.42 6.31.79 9.36 2.35.51.39.94.68 1.33.87-5.61-2.86-12.72-3.39-18.44-.79 2.05-1.33 4.24-1.95 7.74-2.44l.01.01ZM443.67 72.67c-.4-2.2-1.15-4.33-2.37-6.22-1.49-2.32-3.58-4.19-5.91-5.64-6.17-3.81-13.75-5.11-20.83-6.01-3.23-.41-6.47-.69-9.72-.92l-1.39-.12c-.85-.07-1.52-.1-2.05-.1-1.08-.06-2.17-.12-3.25-.17-.08 0-.14.02-.19.05-.1.05-.18.14-.16.3.27 2.55-.01 5.12-.92 7.52-.15.38.4.56.62.28 1.32.59 2.68 1.05 4.08 1.37 0 2.78-.14 7.58-.33 12.91 0 0 0 .02-.01.03-.61 3.66-.79 7.42-1 11.12-.23 4.01-.43 8.03-.44 12.05 0 .64 0 1.28.03 1.93.02.31 0 .68.15.96.06.11.14.16.24.17-.2.17-.21.54.11.59 3.83.67 7.78.71 11.68.25 2.3-.19 4.87-.65 7.65-1.56 1.85-.54 3.67-1.18 5.43-1.91 7.2-3.02 14.31-8.07 17.35-15.53.76-1.86 1.17-3.8 1.31-5.75.3-1.93.28-3.82-.09-5.58l.01-.02Zm-19.32-15.42c5.74 1.41 11.94 3.68 15.65 8.55.25.32.47.65.69.99-2.3-2.82-5.68-5.69-12.88-8.23-2.16-.76-4.35-1.43-6.64-2.02 1.06.21 2.13.45 3.18.71Zm-25.82-3.04c.13 0 .27.01.4.02-.14.1-.26.23-.37.38 0-.13-.02-.26-.03-.4Zm34.82 22.17c-.75 3.09-3.55 5.66-5.88 7.58-3.35 2.76-7.21 5.03-11.28 6.54-1.33.49-2.71.9-4.12 1.15.06-1.38.08-2.76.07-4.13-.02-3.78-.16-7.56-.41-11.33-.09-1.37-.18-2.74-.37-4.1 0-.06-.03-.11-.06-.15.09-3.25.12-6.16.03-8.12 6.86 1.05 10.56 2.17 14.06 3.62 5.52 2.28 8.59 5.44 7.97 8.96l-.01-.02Zm-22 16.15c-.12 0-.23-.02-.34-.03l.34-.03v.06Zm-.69-.7c0-3.13.26-8.84.47-14.51.06 1.2.11 2.41.15 3.6.15 3.6.25 7.23.09 10.83-.24.03-.48.05-.71.07v.01Zm-12.33-30.94c.37.63 2.01 1.01 3.23 1.25v.15c-1.31-.31-2.59-.73-3.83-1.29.12-.36.23-.72.33-1.09.08.48.18.84.27.98Zm13.7 31.65v-.18c3.41-.56 6.71-2.02 9.69-3.68 2.31-1.28 4.59-2.78 6.63-4.53-4.69 4.53-11.61 8.24-16.33 8.38l.01.01Zm24.07-.75c-2.05 1.93-4.37 3.56-6.83 4.95 2.7-1.78 5.52-4.03 8.42-6.87.82-.82 1.56-1.69 2.23-2.59-1.08 1.65-2.38 3.16-3.81 4.51h-.01ZM187.16 92.14c-.79-2.47-2.1-7.12-3.1-6.87-.19-.01-2.09.77-4.08 1.54-3.06 1.18-5.91 2.13-10.09 2.82-2.74.42-5.87 1.01-10.61 1.06.04-3.34.05-6.01.05-7.99 7.97-.65 12.33-2.11 16.37-3.55 1.11-.39 2.69-1.01 2.63-1.8-.08-.35-.55-1.39-1.17-2.61-.47-1.16-.98-2.31-1.61-3.38-.42-.71-1.04-1.69-1.86-2.06-.11-.08-.22-.13-.29-.12-.02 0-.04 0-.07.01-.19-.04-.39-.05-.6-.01-.17.03-.24.15-.25.28-.04.02-.09.04-.14.05-4.33 1.48-8.85 2.33-13.24 3.61a499.1 499.1 0 0 0-.31-8.19c4.51-.99 8.88-1.38 13.11-1.82 3.68-.38 6.28.12 7.47.34.59.11.9.16 1.16.18h.1c-.1.37.44.66.62.28.02-.04.03-.08.05-.13.15.2.53.22.62-.1.17-.58.19-1.21.21-1.81v-.36c.03-.15.05-.3.07-.45.52-2.47.33-5.09-.64-7.44-.11-.27-.44-.28-.6-.14-.08-.21-.15-.42-.24-.62-.19-.41-.79-.05-.6.35.03.07.05.15.09.22-.98-.42-2.15-.54-3.17-.63-2.17-.19-4.37-.14-6.54 0-5.7.35-11.4 1.3-16.91 2.79-2.08.56-4.13 1.22-6.14 2-4.54 1.05-3.79 1.51-2.17 6.07.18.51.46 1.68.54 1.94.82 2.47 1.08 2.13 3.1 2.13s0 .05 0 .08h.52c-.48 2.66-.51 5.45-.62 8.13-.15 3.48-.22 6.96-.28 10.45 0 .41-.01.82-.02 1.23-.16.29-.33.57-.51.85-.05.38-.09.77-.14 1.18-.42 3.52-.59 6.48-.52 8.8v.34c.02.47.05.76.06.87.16 1.57-.26 3.47 1.35 3.79 1.61.32 3.5.55 4.85.55.11 0 .22-.02.33-.02 1.79.24 3.67.05 5.45-.12 2.85-.28 5.69-.7 8.51-1.19 3.03-.53 6.05-1.14 9.04-1.86 2.4-.58 4.82-1.19 7.13-2.06.51-.19 1.73-.57 2.46-1.14 1.81-.68 2.18-1 1.57-2.67-.23-.62-.48-1.49-.91-2.78l-.03-.02Zm-11.12-38.71c.89.05 1.93.08 2.89.3-.33 0-.68-.02-1.06-.03-8.28-.26-14.88.75-23.97 2.51 2.41-.64 4.85-1.16 7.28-1.59 4.87-.86 9.91-1.45 14.86-1.19Zm-26.53 22.13c.03 1.71.04 3.43 0 5.14-.04 1.27-.11 2.55-.24 3.82 0-.73.02-1.46.04-2.19.05-2.26.12-4.51.22-6.77h-.02Zm6.73 27.85c.2-.1.4-.21.58-.33 1.82-.17 3.82-.24 5.94-.34-.86.11-1.72.24-2.58.33-1.27.14-2.61.31-3.93.34h-.01ZM534.48 85.44c-3.52-8.38-7.07-16.75-10.5-25.17-.63-1.54-1.25-3.09-1.86-4.65-.31-.8-.65-1.6-.87-2.43-.04-.17-.17-.24-.31-.25.1-.2 0-.51-.29-.53-1.59-.08-3.18-.22-4.78-.25-1.96-.03-3.91.13-5.84.42-.31.05-.31.38-.13.56-.03.06-.05.14-.04.22.23 1.54.63 3.06 1.16 4.53.13.35.27.7.41 1.06l-2.68 6.18c-.11.03-.2.09-.25.22-.67 1.9-1.52 3.73-2.34 5.56a536.85 536.85 0 0 1-3.9 8.45c-2.64 5.64-5.34 11.25-7.91 16.93-.44.97-.88 1.94-1.29 2.93-.2.48-.47 1-.55 1.52v.05c-.02.12.02.26.16.34 1.19.73 2.41 1.41 3.66 2.05 1.2.62 2.45 1.25 3.76 1.61.43.12.62-.55.19-.67-1.13-.31-2.2-.83-3.24-1.36 1.09.36 2.1.69 2.75.93 2.82 1.01 2.38 1.1 4.3-3.75 2.1-1.09 4.34-1.96 6.53-2.79 4.35-1.64 8.8-3.03 13.27-4.29.82 2.01 1.77 3.97 2.72 5.92.35.83.62 1.45.79 1.82.22.42.45.8.69 1.15.17.33.33.67.5 1 .42.8.84 1.63 1.4 2.35.23.29.6 0 .55-.31 1.53-.02 3.06-.07 4.58-.27.92-.12 1.82-.32 2.71-.54 1.39-.27 3.85-1.11 3.74-1.42-.67-1.96-1.55-3.87-2.34-5.78-1.57-3.78-3.16-7.56-4.75-11.33v-.01Zm-11.65-26.16c1.54 3.81 3.12 7.6 4.7 11.4 2.94 7.05 5.91 14.09 8.87 21.13l-1.06-2.17c-2.71-5.51-5.2-11.19-7.41-16.87l-6.65-17.15c-.65-1.45-.55-2.19-.93-2.53.09 0 .18.01.28.02a.29.29 0 0 0-.04.26c.52 2.02 1.47 3.98 2.25 5.91h-.01Zm-6.58 13.58c.05-.15.09-.31.14-.46 1.41 3.92 2.88 7.9 4.39 11.87-3.22.52-6.38 1.25-9.46 2.14.55-1.22 1.05-2.46 1.53-3.7 1.24-3.24 2.37-6.53 3.39-9.85h.01Zm-.23-20c.36 0 .73.03 1.09.05-2.15.1-5.18.33-5.87.74-.24.15-.41.3-.53.45-.06-.29-.13-.58-.18-.88 1.82-.26 3.65-.39 5.49-.35v-.01Zm-.09 18.72c-.49 1.67-1.05 3.33-1.6 4.97-1.07 3.19-2.19 6.38-3.57 9.46-.09.21-.19.43-.29.65-.25.07-.5.14-.74.22 2.53-6.16 4.61-11.29 6.2-15.3Zm-6.34 25.16c4.97-2.38 9.37-4.1 14.02-5.27l.26.64c-4.8 1.35-9.63 2.8-14.28 4.63Zm20.17 6.76c.33.23.68.42 1.04.56h-.33c-.12 0-.21.06-.26.13-.15-.23-.31-.45-.45-.7v.01ZM226.57 91.75c-3.55-4.74-6.68-9.11-9.31-12.99 9.2-15.25 10.05-17.81 10.35-18.38.17-.34 1.09-2.27.64-2.53-1.13-.65-1.03-.65-2.97-1.71-1.19-.65-3.04-1.61-4.53-2.12-1.71-.59-1.24-.36-3 2.77-.06.1-.11.2-.17.3-.75 1.02-1.48 2.05-2.2 3.09-1.88 2.71-3.73 5.45-5.69 8.1-3.68-4.91-6.88-8.76-9.51-11.43-.15-.15-.3-.29-.46-.42-1.27-1.28-7.24 3.53-7.93 5.58-.09.09-.19.16-.28.25-.27.26.03.64.33.58.19.65.5 1.29.94 1.91 3.85 5.06 7.19 9.76 9.94 14-1.23 2.61-3.06 5-4.67 7.38l-2.28 3.33c-.5.66-.93 1.23-1.29 1.69-.67.93-2.09 2.61-2.3 3.87-.51.85-1.16 1.84-1.29 2.83-.06.44.61.63.67.19.01-.08.04-.15.06-.22 1.36 1.08 2.76 2.11 4.19 3.11 1.3.91 2.62 1.85 4.04 2.56.21.1.4 0 .48-.17.24.07.48.14.72.2.44.1.62-.57.19-.67-2.02-.48-3.77-1.57-5.23-3.02-.47-.46-.9-.96-1.32-1.46 1.74 1.35 4.2 2.89 5.89 4.14 1.39 1.03 2.85-2.27 4.22-4.2 1.86-2.64 3.96-5.86 5.52-8.29l10.39 14.51c.67.81 1.14 1.21 1.57 1.36-.05.24.12.51.41.4 1.53-.58 3.05-1.19 4.54-1.87 1.52-.69 3.06-1.45 4.36-2.5a.28.28 0 0 0 .12-.23c1.66-1.1.81-1.74-1.41-4.91-1.13-1.58-1.71-2.36-3.7-5.01l-.03-.02Zm2.41 6.54c.56 1.15 1.19 2.52 1.11 3.81-.06.04-.12.07-.17.1-.03-.88-.55-2.66-.94-3.91Zm-16.51-32.73c1.86-2.65 3.65-5.35 5.57-7.95.4-.55.81-1.13 1.26-1.66.19-.18.38-.33.56-.45.18.03.36.08.55.13l-8.05 10.11.12-.18h-.01ZM192.7 95.48c.79-1.37 1.66-2.69 2.54-4 1.19-1.79 2.4-3.56 3.61-5.33-.04.09-.09.17-.13.26-.1.22.03.41.2.49-2.47 3.42-4.89 6.73-6.4 9.28.21.24.4.48.63.75-.24.07-.4.36-.17.56.4.33.72.77 1.05 1.17.09.11.18.21.27.32-.84-.61-1.66-1.24-2.47-1.88.24-.57.58-1.11.87-1.61v-.01Zm7.46-10.32c.47-.81.98-1.59 1.49-2.37.31-.48.64-.95.96-1.43.26-.29.52-.56.75-.79-.99 1.48-2.09 3.03-3.2 4.59Zm10.03-16.22s-.03-.05-.05-.07c.22-.29.43-.59.64-.89-.2.32-.4.65-.58.96h-.01ZM371.54 87.96c-.01-.08-.01-.16-.03-.23-.06-.38-.58-.29-.66.03-.3-.05-.6-.08-.81-.11-1.14-.15-2.29-.19-3.44-.2 1.04-.09 2.09-.18 3.14-.23.45-.02.45-.72 0-.7-6.57.35-13.14 1.23-19.65 2.11-1.53.21-3.05.42-4.57.68-.01 0-.02.01-.04.01-.04-3.33-.13-6.66-.24-9.99-.19-5.7-.4-11.41-.88-17.1-.13-1.51-.23-3.07-.49-4.58 0-.25 0-.48-.02-.68-.06-1.19-.04-2.61-.68-2.78-.16-.07-.72-.16-1.5-.24.22-.17.16-.62-.2-.63-1.19-.04-2.39.09-3.57.23-1.2.14-2.41.32-3.59.6-.16-.1-.41-.06-.5.12-.06.02-.13.03-.19.05-.35.1-.29.55-.03.66-.26.6-.19 2.27-.21 3-.02.66-.66 33.73-.9 40.3-.03.65.06 1.12.04 1.45-.16 3.05.87 4.96 6.34 3.93 1.09-.08 2.75-.77 5.36-1.43 4.13-1.04 5.78-1.52 6.2-1.65 6.43-1.69 6.78-1.97 11.72-2.43.55-.05 4.8-.38 6.03-.3.64.04 1.19.07 1.65.1.09 0 .16-.03.24-.05.1.27.56.33.66-.02.39-1.32.61-2.71.78-4.08.2-1.61.29-3.24.15-4.86.24.03.52-.23.38-.53-.09-.2-.27-.33-.49-.43v-.02Zm-.63.56c.07.57.11 1.14.11 1.71-.21-.99-.53-1.71-.95-1.87.22.03.44.06.65.11.06.01.12.04.19.05Zm-25.41 1.73c1.54-.36 3.1-.64 4.66-.89-1.61.37-3.18.77-4.66 1.2v-.31Zm-.86-7.37c-.07-1.37-.16-2.75-.25-4.12-.21-3.13-.45-6.27-.79-9.4.02-2.25.08-4.31.13-6.11.16 2.08.29 4.16.4 6.24.23 4.46.38 8.93.5 13.39h.01Zm-.94-4c.16 2.41.29 4.83.39 7.24.06 1.6.14 3.22.09 4.83-.15.05-.32.09-.47.14V78.88h-.01ZM483.72 92.83c-3.05-2.28-6.22-4.4-9.38-6.51 8.86-6.49 13.49-12.95 13.73-19.23.04-.76 0-1.5-.13-2.2-.67-3.82-3.5-6.68-8.39-8.48.13.04.27.08.4.13 3.92 1.39 7.74 4.23 8.5 8.56.34 1.95-.05 3.96-.98 5.69-.21.4.39.75.6.35 1.86-3.46 1.46-7.55-.97-10.63-3.53-4.47-9.76-5.88-15.16-6.16-2.32-.12-4.64-.04-6.95.19-6 .32-12.71 1.68-17.63 3.21-.37.11-.67.23-.92.35-.2-.17-.62.02-.57.37v.03c-.64.68-.18 1.64.48 3.21.38.91.67 1.89 1.15 2.58.32.76.68 1.51 1.13 2.19.14.21.38.19.53.07.19-.02.38-.05.57-.08v1.57c-.06.06-.1.13-.11.23-.27 4.18-.34 8.38-.48 12.57l-.3 9.03c-.24 3.91-.44 6.77-.46 7.26-.05.88-.11 1.95.07 2.81-.01.22-.02.43-.04.65 0 .11-.02.23-.03.35 0 .05-.03.27-.01.16-.05.4.5.59.64.28.05.04.12.08.2.08 1.75.13 3.5.28 5.25.3 1.69.02 3.38-.12 5.06-.32.08.23.36.39.55.15.06-.08.11-.17.16-.26.18-.09.24-.32.18-.48.05-.2.1-.4.13-.6.16-.86.25-1.74.33-2.62.11-1.17.17-2.34.23-3.51.15-.01.32-.03.52-.04.36-.03 1.73-.15 2.06-.15.39 0 .7-.02.95-.04 1.76 1.11 3.45 2.35 5.14 3.55 2.83 2.01 5.64 4.04 8.47 6.04 1.42 1 2.85 2 4.29 2.97.1.06.19.07.27.04.08 0 .17-.02.25-.1 1.61-1.56 3.15-3.18 4.6-4.88.75-.88 1.49-1.78 2.15-2.73.01.01.03.02.04.03.34.3.83-.2.49-.49-2.16-1.9-4.34-3.76-6.64-5.48l.03-.01Zm-6.38-3.65a55.72 55.72 0 0 0-4-2.13c.14-.1.26-.19.4-.29 1.2.81 2.4 1.61 3.6 2.42Zm-20.1 11.78c.67-.37 1.23-.91 1.67-1.6-.11.5-.24 1-.38 1.49-.43.04-.86.08-1.29.11Zm2.38-37.24c1.34-.31 2.56-.52 3.71-.69-1.03.19-2.04.41-3.04.65-.14-.07-.34-.02-.45.11-.07.02-.15.04-.22.05v-.13.01Zm.04.84c.07-.02.14-.03.2-.05.34 1.66.41 3.41.5 5.09.17 2.9.24 5.81.28 8.71l.03 3.17c-.17.07-.34.14-.51.2-.06-4.96-.21-10.58-.51-17.12h.01Zm16.04 5.62c-1.16 2.25-3.06 4.1-5.02 5.66-2.8 2.23-5.99 3.97-9.3 5.35-.01-3.56-.09-7.12-.27-10.67-.1-2.04-.16-4.16-.57-6.18 3.3-.78 6.72-1.36 10.1-1.1 1.85.14 4.23.59 5.32 2.29.92 1.43.46 3.24-.26 4.65Zm.85-.18c.6-1.37.9-2.92.28-4.32-.67-1.52-2.2-2.32-3.76-2.74.46.1.89.21 1.29.37 1.74.67 2.69 1.88 2.93 3.21.2 1.13-.05 2.25-.74 3.47V70Zm-27.47-4.14c-.12-.19-.23-.38-.34-.57.74.42.85.36.99.41v.08c-.22.03-.43.06-.65.08Zm11.21 30.46c-.08 1.08-.16 2.17-.33 3.24-.05.35-.11.69-.2 1.03 0 .04-.02.07-.03.11-.15.02-.3.04-.45.05.45-1.64.76-3.36.79-5.07.03-.29.08-.57.1-.89-.03-.31-.03-.47.24-.57-.04.69-.07 1.39-.12 2.08v.02Zm5.6-2.47c.48.11.92.52 2.49 1.72-.46-.32-.92-.65-1.38-.97-.37-.25-.73-.5-1.1-.75h-.01Zm21.23 7.24a70.76 70.76 0 0 1-4.37 4.63c-.14-.09-.27-.19-.4-.28.19-.09.37-.24.55-.47.87-1.14 5.43-5.51 5.49-7.45.31.26.62.53.92.79-.67.97-1.42 1.88-2.19 2.77v.01Z",fill:"currentColor",transform:"translate(-144.023 -51.76)"})]}),d3=({style:e,size:n="small",withText:t})=>m3("div",{className:`ExcalidrawLogo is-${n}`,style:e,children:[Lr(QX,{}),t&&Lr(eK,{})]});import{Fragment as h3,jsx as lt,jsxs as Xb}from"react/jsx-runtime";var Kb=({icon:e,shortcut:n,children:t})=>{let o=be();return Xb(h3,{children:[lt("div",{className:"welcome-screen-menu-item__icon",children:e}),lt("div",{className:"welcome-screen-menu-item__text",children:t}),n&&o.formFactor!=="phone"&&lt("div",{className:"welcome-screen-menu-item__shortcut",children:n})]})};Kb.displayName="WelcomeScreenMenuItemContent";var Ic=({onSelect:e,children:n,icon:t,shortcut:o,className:r="",...i})=>lt("button",{...i,type:"button",className:`welcome-screen-menu-item ${r}`,onClick:e,children:lt(Kb,{icon:t,shortcut:o,children:n})});Ic.displayName="WelcomeScreenMenuItem";var p3=({children:e,href:n,icon:t,shortcut:o,className:r="",...i})=>lt("a",{...i,className:`welcome-screen-menu-item ${r}`,href:n,target:"_blank",rel:"noopener",children:lt(Kb,{icon:t,shortcut:o,children:e})});p3.displayName="WelcomeScreenMenuItemLink";var Tn=({children:e})=>{let{WelcomeScreenCenterTunnel:n}=ot();return lt(n.In,{children:lt("div",{className:"welcome-screen-center",children:e||Xb(h3,{children:[lt($b,{}),lt(Zb,{children:f("welcomeScreen.defaults.center_heading")}),Xb(jb,{children:[lt(Jb,{}),lt(qb,{})]})]})})})};Tn.displayName="Center";var $b=({children:e})=>lt("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||lt(d3,{withText:!0})});$b.displayName="Logo";var Zb=({children:e})=>lt("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});Zb.displayName="Heading";var jb=({children:e})=>lt("div",{className:"welcome-screen-menu",children:e});jb.displayName="Menu";var qb=()=>{let e=rt();return lt(Ic,{onSelect:()=>e.executeAction(qr),shortcut:"?",icon:Bi,children:f("helpDialog.title")})};qb.displayName="MenuItemHelp";var Jb=()=>{let e=ye(),n=rt();return e.viewModeEnabled?null:lt(Ic,{onSelect:()=>n.executeAction(ra),shortcut:je("loadScene"),icon:Uc,children:f("buttons.load")})};Jb.displayName="MenuItemLoadScene";var u3=({onSelect:e})=>{let{t:n}=_e();return lt(Ic,{shortcut:null,onSelect:e,icon:Wc,children:n("labels.liveCollaboration")})};u3.displayName="MenuItemLiveCollaborationTrigger";Tn.Logo=$b;Tn.Heading=Zb;Tn.Menu=jb;Tn.MenuItem=Ic;Tn.MenuItemLink=p3;Tn.MenuItemHelp=qb;Tn.MenuItemLoadScene=Jb;Tn.MenuItemLiveCollaborationTrigger=u3;import{jsx as hs,jsxs as Qb}from"react/jsx-runtime";var uu=({children:e})=>{let{WelcomeScreenMenuHintTunnel:n}=ot();return hs(n.In,{children:Qb("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[Fx,hs("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.menuHint")})]})})};uu.displayName="MenuHint";var hu=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:n}=ot();return hs(n.In,{children:Qb("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[hs("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.toolbarHint")}),zx]})})};hu.displayName="ToolbarHint";var gu=({children:e})=>{let{WelcomeScreenHelpHintTunnel:n}=ot();return hs(n.In,{children:Qb("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[hs("div",{children:e||f("welcomeScreen.defaults.helpHint")}),Ox]})})};gu.displayName="HelpHint";import{Fragment as g3,jsx as Tc,jsxs as nK}from"react/jsx-runtime";var fu=e=>Tc(g3,{children:e.children||nK(g3,{children:[Tc(Tn,{}),Tc(uu,{}),Tc(hu,{}),Tc(gu,{})]})});fu.displayName="WelcomeScreen";fu.Center=Tn;fu.Hints={MenuHint:uu,ToolbarHint:hu,HelpHint:gu};var tK=fu;var oK=()=>{Array.prototype.at||Object.defineProperty(Array.prototype,"at",{value:function(e){if(e=Math.trunc(e)||0,e<0&&(e+=this.length),!(e<0||e>=this.length))return this[e]},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.findLast||Object.defineProperty(Array.prototype,"findLast",{value:function(e,n){return this.slice().reverse().find((t,o)=>e.call(n,t,this.length-o-1,this))},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.findIndex||Object.defineProperty(Array.prototype,"findIndex",{value:function(e,n){for(let t=0;t<this.length;t++)if(e.call(n,this[t],t,this))return t;return-1},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.findLastIndex||Object.defineProperty(Array.prototype,"findLastIndex",{value:function(e,n){let t=this.slice().reverse().findIndex((o,r)=>e.call(n,o,this.length-r-1,this));return t===-1?-1:this.length-t-1},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.toReversed||Object.defineProperty(Array.prototype,"toReversed",{value:function(){return this.slice().reverse()},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.toSorted||Object.defineProperty(Array.prototype,"toSorted",{value:function(e){return this.slice().sort(e)},writable:!0,enumerable:!1,configurable:!0}),Element.prototype.replaceChildren||(Element.prototype.replaceChildren=function(...e){this.innerHTML="",this.append(...e)})},f3=oK;import{configureGifWorkerUrl as qVe,getSceneVersion as JVe,hashElementsVersion as QVe,hashString as eYe,getNonDeletedElements as tYe}from"@excalidraw/element";import{getTextFromElements as oYe}from"@excalidraw/element";import{isInvisiblySmallElement as iYe}from"@excalidraw/element";import rK from"lodash.throttle";import{arrayToMap as iK,isDevEnv as E3,isTestEnv as b3}from"@excalidraw/common";import{orderByFractionalIndex as aK,syncInvalidIndices as x3,validateFractionalIndices as sK}from"@excalidraw/element";var lK=(e,n,t)=>!!(n&&(n.id===e.editingTextElement?.id||n.id===e.resizingElement?.id||n.id===e.newElement?.id||n.version>t.version||n.version===t.version&&n.versionNonce<=t.versionNonce)),cK=rK((e,n,t)=>{if(E3()||b3()||window?.DEBUG_FRACTIONAL_INDICES){let o=x3(e.map(r=>({...r})));sK(o,{shouldThrow:b3()||E3(),includeBoundTextValidation:!0,reconciliationContext:{localElements:n,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),dK=(e,n,t)=>{let o=iK(e),r=[],i=new Set;for(let s of n)if(!i.has(s.id)){let l=o.get(s.id),c=lK(t,l,s);l&&c?(r.push(l),i.add(l.id)):(r.push(s),i.add(s.id))}for(let s of e)i.has(s.id)||(r.push(s),i.add(s.id));let a=aK(r);return cK(a,e,n),x3(a),a};import{isLinearElement as gYe}from"@excalidraw/element";import{FONT_FAMILY as EYe,THEME as bYe,MIME_TYPES as xYe,ROUNDNESS as yYe,DEFAULT_LASER_COLOR as wYe,UserIdleState as vYe,normalizeLink as IYe,sceneCoordsToViewportCoords as TYe,viewportCoordsToSceneCoords as SYe,getFormFactor as CYe,throttleRAF as PYe}from"@excalidraw/common";import{mutateElement as MYe,newElementWith as AYe,bumpVersion as DYe}from"@excalidraw/element";import{CaptureUpdateAction as _Ye}from"@excalidraw/element";import{getCommonBounds as UYe,getVisibleSceneBounds as WYe,convertToExcalidrawElements as VYe}from"@excalidraw/element";import{elementsOverlappingBBox as XYe}from"@excalidraw/element";import{isElementLink as ZYe}from"@excalidraw/element";import{setCustomTextMetricsProvider as JYe}from"@excalidraw/element";import{jsx as Sc}from"react/jsx-runtime";f3();var XVe=({children:e})=>{let[n,t]=fK(null);return Sc(us.Provider,{value:n,children:Sc(pu.Provider,{value:t,children:e})})},bK=e=>{let{onExport:n,className:t,onChange:o,onThemeChange:r,onIncrement:i,initialData:a,initialState:s,onExcalidrawAPI:l,onMount:c,onUnmount:d,onInitialize:m,isCollaborating:p=!1,onPointerUpdate:u,renderTopLeftUI:E,renderTopRightUI:g,langCode:b=Xn.code,viewModeEnabled:w,viewModeOnly:y,interaction:x,ui:I,activeTool:T,gridModeEnabled:C,theme:P,renderCustomizations:M,name:D,renderCustomStats:_,editorPreferences:k,onEditorPreferencesChange:L,onPaste:F,viewModeImageInsertBehavior:Y,onViewModeImageInsertRejected:z,detectScroll:U=!0,handleKeyboardGlobally:V=!1,autoFocus:G=!1,compressImageFile:re,generateIdForFile:B,onLinkOpen:W,generateLinkForSelection:ue,onPointerDown:Ee,onPointerUp:le,onScrollChange:he,onUserFollow:ge,userToFollow:se,onDuplicate:xe,imageContextMenuItems:it,children:$e,validateEmbeddable:ke,renderEmbeddable:Zt,showDeprecatedFonts:Ho,wheelZoomsOnDefault:Uo,strokeColorTopPicks:Wo,backgroundColorTopPicks:Ii,renderScrollbars:gs,viewportStatusFrame:ho,currentUserControls:on,imageOptions:Vo,showDropEventDebugAlert:Eu}=e,Ti=e.UIOptions?.canvasActions,go={...e.UIOptions,canvasActions:{...y3.canvasActions,...Ti},tools:{image:e.UIOptions?.tools?.image??!0}};Ti?.export&&(go.canvasActions.export.saveFileToDisk=Ti.export?.saveFileToDisk??y3.canvasActions.export.saveFileToDisk),go.canvasActions.toggleTheme===null&&(P==null||r)&&(go.canvasActions.toggleTheme=!0);let K={maxFileSizeBytes:Vo?.maxFileSizeBytes??Sn.maxFileSizeBytes,maxWidthOrHeight:Vo?.maxWidthOrHeight??Sn.maxWidthOrHeight,gifAutoDecodeMaxFileSizeBytes:Vo?.gifAutoDecodeMaxFileSizeBytes??Sn.gifAutoDecodeMaxFileSizeBytes,placeholderTransitionDuration:Vo?.placeholderTransitionDuration??Sn.placeholderTransitionDuration},Ie=uK(pu),At=gK(l);At.current=l;let fs=pK(bu=>{Ie?.(bu),At.current?.(bu)},[Ie]),Cc=typeof x=="object"&&x!==null&&x.enabled?.browserZoom===!0&&x.enabled?.navigation!==!0;return hK(()=>{if((async()=>{await import("canvas-roundrect-polyfill")})(),Cc)return;let ex=xu=>{typeof xu.scale=="number"&&xu.scale!==1&&xu.preventDefault()};return document.addEventListener("touchmove",ex,{passive:!1}),()=>{document.removeEventListener("touchmove",ex)}},[Cc]),Sc(Mx,{store:Et,children:Sc(a3,{langCode:b,theme:P,children:Sc(i3,{onExport:n,className:t,onChange:o,onThemeChange:r,onIncrement:i,initialData:a,initialState:s,onExcalidrawAPI:fs,onMount:c,onUnmount:d,onInitialize:m,isCollaborating:p,onPointerUpdate:u,renderTopLeftUI:E,renderTopRightUI:g,langCode:b,viewModeEnabled:w,viewModeOnly:y,interaction:x,ui:I,activeTool:T,gridModeEnabled:C,theme:P,renderCustomizations:M,name:D,renderCustomStats:_,editorPreferences:k,onEditorPreferencesChange:L,UIOptions:go,onPaste:F,viewModeImageInsertBehavior:Y,onViewModeImageInsertRejected:z,detectScroll:U,handleKeyboardGlobally:V,autoFocus:G,compressImageFile:re,generateIdForFile:B,onLinkOpen:W,generateLinkForSelection:ue,onPointerDown:Ee,onPointerUp:le,onScrollChange:he,onUserFollow:ge,userToFollow:se,onDuplicate:xe,imageContextMenuItems:it,validateEmbeddable:ke,renderEmbeddable:Zt,showDeprecatedFonts:Ho,wheelZoomsOnDefault:Uo,strokeColorTopPicks:Wo,backgroundColorTopPicks:Ii,renderScrollbars:gs,viewportStatusFrame:ho,currentUserControls:on,imageOptions:K,showDropEventDebugAlert:Eu,children:$e})})})},xK=(e,n)=>{if(e.children!==n.children)return!1;let{initialData:t,UIOptions:o={},imageOptions:r,interaction:i,ui:a,activeTool:s,...l}=e,{initialData:c,UIOptions:d={},imageOptions:m,interaction:p,ui:u,activeTool:E,...g}=n;if(!(s===E||s?.type===E?.type&&(s?.type==="custom"?s.customType:null)===(E?.type==="custom"?E.customType:null))||!(i===p||typeof i=="object"&&i!==null&&typeof p=="object"&&p!==null&&!!i.enabled?.links==!!p.enabled?.links&&!!i.enabled?.embeds==!!p.enabled?.embeds&&!!i.enabled?.interactiveContent==!!p.enabled?.interactiveContent&&!!i.enabled?.navigation==!!p.enabled?.navigation&&!!i.enabled?.browserZoom==!!p.enabled?.browserZoom&&!!i.enabled?.tools?.laser==!!p.enabled?.tools?.laser&&!!i.enabled?.tools?.custom==!!p.enabled?.tools?.custom)||!(a===u||typeof a=="object"&&a!==null&&typeof u=="object"&&u!==null&&!!a.enabled?.zoom==!!u.enabled?.zoom&&!!a.enabled?.scrollBackToContent==!!u.enabled?.scrollBackToContent))return!1;let x=Object.keys(o),I=Object.keys(d);if(x.length!==I.length)return!1;let T=x.every(P=>P==="getFormFactor"?!0:P==="canvasActions"?Object.keys(o.canvasActions).every(D=>D==="export"&&o?.canvasActions?.export&&d?.canvasActions?.export?o.canvasActions.export.saveFileToDisk===d.canvasActions.export.saveFileToDisk:o?.canvasActions?.[D]===d?.canvasActions?.[D]):o[P]===d[P]),C=(r?.maxWidthOrHeight??Sn.maxWidthOrHeight)===(m?.maxWidthOrHeight??Sn.maxWidthOrHeight)&&(r?.maxFileSizeBytes??Sn.maxFileSizeBytes)===(m?.maxFileSizeBytes??Sn.maxFileSizeBytes)&&(r?.gifAutoDecodeMaxFileSizeBytes??Sn.gifAutoDecodeMaxFileSizeBytes)===(m?.gifAutoDecodeMaxFileSizeBytes??Sn.gifAutoDecodeMaxFileSizeBytes)&&(r?.placeholderTransitionDuration??Sn.placeholderTransitionDuration)===(m?.placeholderTransitionDuration??Sn.placeholderTransitionDuration);return T&&C&&EK(l,g)},yK=mK.memo(bK,xK);yK.displayName="Excalidraw";function KVe(e){return qi(e,!1)}export{vn as Button,_Ye as CaptureUpdateAction,wYe as DEFAULT_LASER_COLOR,wu as DEFAULT_OVERSCROLL,lb as DefaultSidebar,Hs as Ellipsify,yK as Excalidraw,us as ExcalidrawAPIContext,XVe as ExcalidrawAPIProvider,EYe as FONT_FAMILY,Eo as Fonts,KX as Footer,jX as LiveCollaborationTrigger,xYe as MIME_TYPES,Ft as MainMenu,yYe as ROUNDNESS,Pr as Sidebar,tc as Stats,bYe as THEME,Iu as UnsupportedImageFileTypeError,vYe as UserIdleState,tK as WelcomeScreen,DVe as applyDarkModeFilter,DYe as bumpVersion,qh as captureDragEventData,qVe as configureGifWorkerUrl,VYe as convertToExcalidrawElements,Xn as defaultLang,XYe as elementsOverlappingBBox,pP as exportToBlob,Lp as exportToCanvas,$G as exportToClipboard,uP as exportToSvg,UYe as getCommonBounds,Rc as getDataURL,CYe as getFormFactor,tYe as getNonDeletedElements,JVe as getSceneVersion,LVe as getStrokeWidthByKey,oYe as getTextFromElements,WYe as getVisibleSceneBounds,QVe as hashElementsVersion,eYe as hashString,ZYe as isElementLink,iYe as isInvisiblySmallElement,gYe as isLinearElement,Ra as isSpreadsheetValidForChartType,Di as languages,vs as loadFromBlob,MYe as mutateElement,AYe as newElementWith,IYe as normalizeLink,Kr as parseDataTransferEvent,Zd as parseDragImageMetadata,dK as reconcileElements,Lf as renderSpreadsheet,ki as restoreAppState,v3 as restoreElement,Nr as restoreElements,TYe as sceneCoordsToViewportCoords,xs as serializeAsJSON,JYe as setCustomTextMetricsProvider,PYe as throttleRAF,Vm as tryParseSpreadsheet,be as useEditorInterface,Md as useExcalidrawAPI,KVe as useExcalidrawStateValue,_e as useI18n,L6 as useOnExcalidrawStateChange,ct as useStylesPanelMode,SYe as viewportCoordsToSceneCoords,_r as zoomToFitBounds};